Mini Kabibi Habibi

Current Path : C:/Users/Public/Documents/DXperience 13.1 Demos/ASP.NET/CS/MoneyMonkey/
Upload File :
Current File : C:/Users/Public/Documents/DXperience 13.1 Demos/ASP.NET/CS/MoneyMonkey/Global.asax

<%@ Application Language="C#" %>
<script RunAt="server">
    static bool DatabaseModified = false;


    void Application_Start(object sender, EventArgs e) {
        if(!DatabaseModified) {
            DatabaseModified = true;
            ModifyDatabase();
        }
        DevExpress.Web.ASPxClasses.Internal.DemoUtils.RegisterDemo("MoneyMonkey");
        Application["PageTitle"] = "Money Monkey";
    }

    void ModifyDatabase() {
        var now = DateTime.Now;
        DataClassesDataContext dc = new DataClassesDataContext();

        var transactions = from tr in dc.Transactions
                           orderby tr.Date descending
                           select tr;
        var currentDayIntervalLag = (int)(now - transactions.First().Date).TotalDays;

        if(currentDayIntervalLag > 0) {
            foreach(var transaction in transactions)
                transaction.Date = transaction.Date.AddDays(currentDayIntervalLag);
            dc.SubmitChanges();
        }
    }

    void Application_End(object sender, EventArgs e) {
        //  Code that runs on application shutdown

    }

    void Application_Error(object sender, EventArgs e) {
        // Code that runs when an unhandled error occurs

    }

    void Session_Start(object sender, EventArgs e) {
        // Code that runs when a new session is started

    }

    void Session_End(object sender, EventArgs e) {
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.

    }
       
</script>