Mini Kabibi Habibi
<%@ 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>