Mini Kabibi Habibi

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

<%@ Application Language="vb" %>
<script RunAt="server">
	Dim Shared DatabaseModified As Boolean = False


	Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
		If (Not DatabaseModified) Then
			DatabaseModified = True
			ModifyDatabase()
		End If
		DevExpress.Web.ASPxClasses.Internal.DemoUtils.RegisterDemo("MoneyMonkey")
		Application("PageTitle") = "Money Monkey"
	End Sub

	Sub ModifyDatabase()
		Dim now = DateTime.Now
		Dim dc As New DataClassesDataContext()

		Dim transactions = _
			From tr In dc.Transactions _
			Order By tr.Date Descending _
			Select tr
		Dim currentDayIntervalLag = CInt(Fix((now - transactions.First().Date).TotalDays))

		If currentDayIntervalLag > 0 Then
			For Each transaction In transactions
				transaction.Date = transaction.Date.AddDays(currentDayIntervalLag)
			Next transaction
			dc.SubmitChanges()
		End If
	End Sub

	Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
		'  Code that runs on application shutdown

	End Sub

	Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
		' Code that runs when an unhandled error occurs

	End Sub

	Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
		' Code that runs when a new session is started

	End Sub

	Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
		' 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.

	End Sub

</script>