home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / tblEventsadd.aspx.vb < prev    next >
Text File  |  2015-05-13  |  20KB  |  652 lines

  1. Imports System.Data
  2. Imports System.Data.Common
  3. Imports System.Xml
  4. Imports System.IO
  5. Imports System.Data.OleDb
  6.  
  7. '
  8. ' ASP.NET code-behind class (Page)
  9. '
  10.  
  11. Partial Class tblEventsadd
  12.     Inherits AspNetMaker7_tfpssnet
  13.  
  14.     ' Page object
  15.     Public tblEvents_add As ctblEvents_add
  16.  
  17.     '
  18.     ' Page Class
  19.     '
  20.     Class ctblEvents_add
  21.         Inherits AspNetMakerPage
  22.         Implements IDisposable        
  23.  
  24.         ' Used by system generated functions
  25.         Private RsWrk As Object, sSqlWrk As String, sWhereWrk As String
  26.  
  27.         Private arwrk As Object
  28.  
  29.         Private armultiwrk() As String        
  30.  
  31.         ' Page URL
  32.         Public ReadOnly Property PageUrl() As String
  33.             Get
  34.                 Dim Url As String = ew_CurrentPage() & "?"
  35.                 If tblEvents.UseTokenInUrl Then Url = Url & "t=" & tblEvents.TableVar & "&" ' Add page token
  36.                 Return Url    
  37.             End Get
  38.         End Property
  39.  
  40.         ' Validate page request
  41.         Public Function IsPageRequest() As Boolean
  42.             Dim Result As Boolean
  43.             If tblEvents.UseTokenInUrl Then
  44.                 Result = False
  45.                 If ObjForm IsNot Nothing Then
  46.                     Result = (tblEvents.TableVar = ObjForm.GetValue("t"))
  47.                 End If
  48.                 If ew_Get("t") <> "" Then
  49.                     Result = (tblEvents.TableVar = ew_Get("t"))
  50.                 End If
  51.                 Return Result
  52.             End If
  53.             Return True            
  54.         End Function    
  55.  
  56.         ' tblEvents
  57.         Public Property tblEvents() As ctblEvents
  58.             Get                
  59.                 Return ParentPage.tblEvents
  60.             End Get
  61.             Set(ByVal v As ctblEvents)
  62.                 ParentPage.tblEvents = v    
  63.             End Set    
  64.         End Property
  65.  
  66.         ' tblEvents
  67.         Public Property tblEmployees() As ctblEmployees
  68.             Get                
  69.                 Return ParentPage.tblEmployees
  70.             End Get
  71.             Set(ByVal v As ctblEmployees)
  72.                 ParentPage.tblEmployees = v    
  73.             End Set    
  74.         End Property
  75.  
  76.         '
  77.         '  Constructor
  78.         '  - init objects
  79.         '  - open connection
  80.         '
  81.         Public Sub New(ByRef APage As AspNetMaker7_tfpssnet)                
  82.             m_ParentPage = APage
  83.             m_Page = Me    
  84.             m_PageID = "add"
  85.             m_PageObjName = "tblEvents_add"
  86.             m_PageObjTypeName = "ctblEvents_add"
  87.  
  88.             ' Table Name
  89.             m_TableName = "tblEvents"
  90.  
  91.             ' Initialize table object
  92.             tblEvents = New ctblEvents(Me)
  93.             tblEmployees = New ctblEmployees(Me)
  94.  
  95.             ' Connect to database
  96.             Conn = New cConnection()
  97.         End Sub
  98.  
  99.         '
  100.         '  Subroutine Page_Init
  101.         '  - called before page main
  102.         '  - check Security
  103.         '  - set up response header
  104.         '  - call page load events
  105.         '
  106.         Public Sub Page_Init()
  107.             Security = New cAdvancedSecurity(Me)
  108.             If Not Security.IsLoggedIn() Then Security.AutoLogin()
  109.             If Not Security.IsLoggedIn() Then
  110.                 Security.SaveLastUrl()
  111.                 Page_Terminate("login.aspx")
  112.             End If
  113.  
  114.             ' Table Permission loading event
  115.             Security.TablePermission_Loading()
  116.             Security.LoadCurrentUserLevel(TableName)
  117.  
  118.             ' Table Permission loaded event
  119.             Security.TablePermission_Loaded()
  120.             If Not Security.CanAdd Then
  121.                 Security.SaveLastUrl()
  122.                 Page_Terminate("tblEventslist.aspx")
  123.             End If
  124.  
  125.             ' User ID loading event
  126.             Security.UserID_Loading()
  127.             If Security.IsLoggedIn() Then Call Security.LoadUserID()
  128.  
  129.             ' User ID loaded event
  130.             Security.UserID_Loaded()
  131.  
  132.             ' Global page loading event (in ewglobal*.vb)
  133.             ParentPage.Page_Loading()
  134.  
  135.             ' Page load event, used in current page
  136.             Page_Load()
  137.         End Sub
  138.  
  139.         '
  140.         '  Class terminate
  141.         '  - clean up page object
  142.         '
  143.         Public Sub Dispose() Implements IDisposable.Dispose
  144.             Page_Terminate("")
  145.         End Sub
  146.  
  147.         '
  148.         '  Sub Page_Terminate
  149.         '  - called when exit page
  150.         '  - clean up connection and objects
  151.         '  - if URL specified, redirect to URL
  152.         '
  153.         Sub Page_Terminate(url As String)
  154.  
  155.             ' Page unload event, used in current page
  156.             Page_Unload()
  157.  
  158.             ' Global page unloaded event (in ewglobal*.vb)
  159.             ParentPage.Page_Unloaded()
  160.  
  161.             ' Close connection
  162.             Conn.Dispose()
  163.             Security = Nothing
  164.             tblEvents.Dispose()
  165.             tblEmployees.Dispose()
  166.  
  167.             ' Go to URL if specified
  168.             If url <> "" Then
  169.                 HttpContext.Current.Response.Clear()
  170.                 HttpContext.Current.Response.Redirect(url)
  171.             End If
  172.         End Sub
  173.  
  174.     Public x_ewPriv As Integer
  175.  
  176.     '
  177.     ' Page main processing
  178.     '
  179.     Sub Page_Main()
  180.  
  181.         ' Load key values from QueryString
  182.         Dim bCopy As Boolean = True
  183.         If ew_Get("evtID") <> "" Then
  184.             tblEvents.evtID.QueryStringValue = ew_Get("evtID")
  185.         Else
  186.             bCopy = False
  187.         End If
  188.  
  189.         ' Create form object
  190.         ObjForm = New cFormObj
  191.  
  192.         ' Process form if post back
  193.         If ObjForm.GetValue("a_add") <> "" Then
  194.             tblEvents.CurrentAction = ObjForm.GetValue("a_add") ' Get form action
  195.             LoadFormValues() ' Load form values
  196.  
  197.             ' Validate Form
  198.             If Not ValidateForm() Then
  199.                 tblEvents.CurrentAction = "I" ' Form error, reset action
  200.                 Message = ParentPage.gsFormError
  201.             End If
  202.  
  203.         ' Not post back
  204.         Else
  205.             If bCopy Then
  206.                 tblEvents.CurrentAction = "C" ' Copy Record
  207.             Else
  208.                 tblEvents.CurrentAction = "I" ' Display Blank Record
  209.                 LoadDefaultValues() ' Load default values
  210.             End If
  211.         End If
  212.  
  213.         ' Perform action based on action code
  214.         Select Case tblEvents.CurrentAction
  215.             Case "I" ' Blank record, no action required
  216.             Case "C" ' Copy an existing record
  217.                 If Not LoadRow() Then ' Load record based on key
  218.                     Message = "No records found" ' No record found
  219.                     Page_Terminate("tblEventslist.aspx") ' No matching record, return to list
  220.                 End If
  221.             Case "A" ' Add new record
  222.                 tblEvents.SendEmail = True ' Send email on add success
  223.                 If AddRow() Then ' Add successful
  224.                     Message = "Add succeeded" ' Set up success message
  225.                     Dim sReturnUrl As String = tblEvents.ReturnUrl
  226.                     Page_Terminate(sReturnUrl) ' Clean up and return
  227.                 Else
  228.                     RestoreFormValues() ' Add failed, restore form values
  229.                 End If
  230.         End Select
  231.  
  232.         ' Render row based on row type
  233.         tblEvents.RowType = EW_ROWTYPE_ADD ' Render add type
  234.  
  235.         ' Render row
  236.         RenderRow()
  237.     End Sub
  238.  
  239.     '
  240.     ' Get upload file
  241.     '
  242.     Sub GetUploadFiles()
  243.  
  244.         ' Get upload data
  245.     End Sub
  246.  
  247.     '
  248.     ' Load default values
  249.     '
  250.     Sub LoadDefaultValues()
  251.     End Sub
  252.  
  253.     '
  254.     ' Load form values
  255.     '
  256.     Sub LoadFormValues()
  257.             tblEvents.evtDescription.FormValue = ObjForm.GetValue("x_evtDescription")
  258.             tblEvents.evtDescription.OldValue = ObjForm.GetValue("o_evtDescription")
  259.             tblEvents.evtIsActive.FormValue = ObjForm.GetValue("x_evtIsActive")
  260.             tblEvents.evtIsActive.OldValue = ObjForm.GetValue("o_evtIsActive")
  261.             tblEvents.evtAllocateBilling.FormValue = ObjForm.GetValue("x_evtAllocateBilling")
  262.             tblEvents.evtAllocateBilling.OldValue = ObjForm.GetValue("o_evtAllocateBilling")
  263.             tblEvents.evtBillingNotes.FormValue = ObjForm.GetValue("x_evtBillingNotes")
  264.             tblEvents.evtBillingNotes.OldValue = ObjForm.GetValue("o_evtBillingNotes")
  265.             tblEvents.evtTierLevel.FormValue = ObjForm.GetValue("x_evtTierLevel")
  266.             tblEvents.evtTierLevel.OldValue = ObjForm.GetValue("o_evtTierLevel")
  267.             tblEvents.evtOverTimePriority.FormValue = ObjForm.GetValue("x_evtOverTimePriority")
  268.             tblEvents.evtOverTimePriority.OldValue = ObjForm.GetValue("o_evtOverTimePriority")
  269.             tblEvents.evtID.FormValue = ObjForm.GetValue("x_evtID")
  270.     End Sub
  271.  
  272.     '
  273.     ' Restore form values
  274.     '
  275.     Sub RestoreFormValues()
  276.             tblEvents.evtDescription.CurrentValue = tblEvents.evtDescription.FormValue
  277.             tblEvents.evtIsActive.CurrentValue = tblEvents.evtIsActive.FormValue
  278.             tblEvents.evtAllocateBilling.CurrentValue = tblEvents.evtAllocateBilling.FormValue
  279.             tblEvents.evtBillingNotes.CurrentValue = tblEvents.evtBillingNotes.FormValue
  280.             tblEvents.evtTierLevel.CurrentValue = tblEvents.evtTierLevel.FormValue
  281.             tblEvents.evtOverTimePriority.CurrentValue = tblEvents.evtOverTimePriority.FormValue
  282.             tblEvents.evtID.CurrentValue = tblEvents.evtID.FormValue
  283.     End Sub
  284.  
  285.     '
  286.     ' Load row based on key values
  287.     '
  288.     Function LoadRow() As Boolean
  289.         Dim RsRow As OleDbDataReader
  290.         Dim sFilter As String = tblEvents.KeyFilter
  291.  
  292.         ' Row Selecting event
  293.         tblEvents.Row_Selecting(sFilter)
  294.  
  295.         ' Load SQL based on filter
  296.         tblEvents.CurrentFilter = sFilter
  297.         Dim sSql As String = tblEvents.SQL
  298.  
  299.         ' Write SQL for debug
  300.         If EW_DEBUG_ENABLED Then ew_Write(sSql)
  301.         Try
  302.             RsRow = Conn.GetTempDataReader(sSql)    
  303.             If Not RsRow.Read() Then
  304.                 Return False
  305.             Else                
  306.                 LoadRowValues(RsRow) ' Load row values
  307.  
  308.                 ' Row Selected event
  309.                 tblEvents.Row_Selected(RsRow)
  310.                 Return True    
  311.             End If
  312.         Catch
  313.             If EW_DEBUG_ENABLED Then Throw
  314.             Return False
  315.         Finally
  316.             Conn.CloseTempDataReader()
  317.         End Try
  318.     End Function
  319.  
  320.     '
  321.     ' Load row values from recordset
  322.     '
  323.     Sub LoadRowValues(ByRef RsRow As OleDbDataReader)
  324.         tblEvents.evtID.DbValue = RsRow("evtID")
  325.         tblEvents.evtDescription.DbValue = RsRow("evtDescription")
  326.             tblEvents.evtIsActive.DbValue = IIf(ew_ConvertToBool(RsRow("evtIsActive")), "1", "0")
  327.             tblEvents.evtAllocateBilling.DbValue = IIf(ew_ConvertToBool(RsRow("evtAllocateBilling")), "1", "0")
  328.             tblEvents.evtBillingNotes.DbValue = RsRow("evtBillingNotes")
  329.             tblEvents.evtTierLevel.DbValue = RsRow("evtTierLevel")
  330.             tblEvents.evtOverTimePriority.DbValue = RsRow("evtOverTimePriority")
  331.         End Sub
  332.  
  333.     '
  334.     ' Render row values based on field settings
  335.     '
  336.     Sub RenderRow()
  337.  
  338.         ' Row Rendering event
  339.         tblEvents.Row_Rendering()
  340.  
  341.         '
  342.         '  Common render codes for all row types
  343.         '
  344.             ' evtDescription
  345.  
  346.             tblEvents.evtDescription.CellCssStyle = ""
  347.             tblEvents.evtDescription.CellCssClass = ""
  348.  
  349.             ' evtIsActive
  350.  
  351.             tblEvents.evtIsActive.CellCssStyle = ""
  352.             tblEvents.evtIsActive.CellCssClass = ""
  353.  
  354.             ' evtAllocateBilling
  355.  
  356.             tblEvents.evtAllocateBilling.CellCssStyle = ""
  357.             tblEvents.evtAllocateBilling.CellCssClass = ""
  358.  
  359.             ' evtBillingNotes
  360.  
  361.             tblEvents.evtBillingNotes.CellCssStyle = ""
  362.             tblEvents.evtBillingNotes.CellCssClass = ""
  363.  
  364.             ' evtTierLevel
  365.  
  366.             tblEvents.evtTierLevel.CellCssStyle = ""
  367.             tblEvents.evtTierLevel.CellCssClass = ""
  368.  
  369.             ' evtOverTimePriority
  370.  
  371.             tblEvents.evtOverTimePriority.CellCssStyle = ""
  372.             tblEvents.evtOverTimePriority.CellCssClass = ""
  373.  
  374.             '
  375.         '  View  Row
  376.         '
  377.  
  378.         If tblEvents.RowType = EW_ROWTYPE_VIEW Then ' View row
  379.  
  380.             ' evtID
  381.             tblEvents.evtID.ViewValue = tblEvents.evtID.CurrentValue
  382.             tblEvents.evtID.CssStyle = ""
  383.             tblEvents.evtID.CssClass = ""
  384.             tblEvents.evtID.ViewCustomAttributes = ""
  385.  
  386.             ' evtDescription
  387.             tblEvents.evtDescription.ViewValue = tblEvents.evtDescription.CurrentValue
  388.             tblEvents.evtDescription.CssStyle = ""
  389.             tblEvents.evtDescription.CssClass = ""
  390.             tblEvents.evtDescription.ViewCustomAttributes = ""
  391.  
  392.                 ' evtIsActive
  393.                 If Convert.ToString(tblEvents.evtIsActive.CurrentValue) = "1" Then
  394.                     tblEvents.evtIsActive.ViewValue = "Yes"
  395.                 Else
  396.                     tblEvents.evtIsActive.ViewValue = "No"
  397.                 End If
  398.                 tblEvents.evtIsActive.CssStyle = ""
  399.                 tblEvents.evtIsActive.CssClass = ""
  400.                 tblEvents.evtIsActive.ViewCustomAttributes = ""
  401.  
  402.                 ' evtAllocateBilling
  403.                 If Convert.ToString(tblEvents.evtAllocateBilling.CurrentValue) = "1" Then
  404.                     tblEvents.evtAllocateBilling.ViewValue = "Yes"
  405.                 Else
  406.                     tblEvents.evtAllocateBilling.ViewValue = "No"
  407.                 End If
  408.                 tblEvents.evtAllocateBilling.CssStyle = ""
  409.                 tblEvents.evtAllocateBilling.CssClass = ""
  410.                 tblEvents.evtAllocateBilling.ViewCustomAttributes = ""
  411.  
  412.                 ' evtBillingNotes
  413.                 tblEvents.evtBillingNotes.ViewValue = tblEvents.evtBillingNotes.CurrentValue
  414.                 tblEvents.evtBillingNotes.CssStyle = ""
  415.                 tblEvents.evtBillingNotes.CssClass = ""
  416.                 tblEvents.evtBillingNotes.ViewCustomAttributes = ""
  417.  
  418.                 ' evtTierLevel
  419.                 If Not IsDBNull(tblEvents.evtTierLevel.CurrentValue) Then
  420.                     Select Case tblEvents.evtTierLevel.CurrentValue
  421.                         Case "0"
  422.                             tblEvents.evtTierLevel.ViewValue = "0"
  423.                         Case "1"
  424.                             tblEvents.evtTierLevel.ViewValue = "1"
  425.                         Case "2"
  426.                             tblEvents.evtTierLevel.ViewValue = "2"
  427.                         Case "3"
  428.                             tblEvents.evtTierLevel.ViewValue = "3"
  429.                         Case "4"
  430.                             tblEvents.evtTierLevel.ViewValue = "4"
  431.                         Case "5"
  432.                             tblEvents.evtTierLevel.ViewValue = "5"
  433.                         Case Else
  434.                             tblEvents.evtTierLevel.ViewValue = tblEvents.evtTierLevel.CurrentValue
  435.                     End Select
  436.                 Else
  437.                     tblEvents.evtTierLevel.ViewValue = System.DBNull.Value
  438.                 End If
  439.                 tblEvents.evtTierLevel.CssStyle = ""
  440.                 tblEvents.evtTierLevel.CssClass = ""
  441.                 tblEvents.evtTierLevel.ViewCustomAttributes = ""
  442.  
  443.                 ' evtOverTimePriority
  444.                 tblEvents.evtOverTimePriority.ViewValue = tblEvents.evtOverTimePriority.CurrentValue
  445.                 tblEvents.evtOverTimePriority.CssStyle = ""
  446.                 tblEvents.evtOverTimePriority.CssClass = ""
  447.                 tblEvents.evtOverTimePriority.ViewCustomAttributes = ""
  448.  
  449.                 ' View refer script
  450.                 ' evtDescription
  451.  
  452.                 tblEvents.evtDescription.HrefValue = ""
  453.  
  454.                 ' evtIsActive
  455.  
  456.                 tblEvents.evtIsActive.HrefValue = ""
  457.  
  458.                 ' evtAllocateBilling
  459.  
  460.                 tblEvents.evtAllocateBilling.HrefValue = ""
  461.  
  462.                 ' evtBillingNotes
  463.  
  464.                 tblEvents.evtBillingNotes.HrefValue = ""
  465.  
  466.                 ' evtTierLevel
  467.  
  468.                 tblEvents.evtTierLevel.HrefValue = ""
  469.  
  470.                 ' evtOverTimePriority
  471.  
  472.                 tblEvents.evtOverTimePriority.HrefValue = ""
  473.  
  474.                 '
  475.         '  Add Row
  476.         '
  477.  
  478.         ElseIf tblEvents.RowType = EW_ROWTYPE_ADD Then ' Add row
  479.  
  480.             ' evtDescription
  481.             tblEvents.evtDescription.EditCustomAttributes = ""
  482.             tblEvents.evtDescription.EditValue = ew_HtmlEncode(tblEvents.evtDescription.CurrentValue)
  483.  
  484.                 ' empIsActive   
  485.                 tblEvents.evtIsActive.EditCustomAttributes = ""
  486.                 tblEvents.evtIsActive.EditValue = ew_HtmlEncode(tblEvents.evtIsActive.CurrentValue)
  487.  
  488.                 ' evtAllocateBilling   
  489.                 tblEvents.evtAllocateBilling.EditCustomAttributes = ""
  490.                 tblEvents.evtAllocateBilling.EditValue = ew_HtmlEncode(tblEvents.evtAllocateBilling.CurrentValue)
  491.  
  492.                 ' evtBillingNotes   
  493.                 tblEvents.evtBillingNotes.EditCustomAttributes = ""
  494.                 tblEvents.evtBillingNotes.EditValue = ew_HtmlEncode(tblEvents.evtBillingNotes.CurrentValue)
  495.  
  496.                 ' evtTierLevel
  497.                 tblEvents.evtTierLevel.EditCustomAttributes = ""
  498.                 arwrk = New ArrayList
  499.                 arwrk.Add(New String() {"0", "0"})
  500.                 arwrk.Add(New String() {"1", "1"})
  501.                 arwrk.Add(New String() {"2", "2"})
  502.                 arwrk.Add(New String() {"3", "3"})
  503.                 arwrk.Add(New String() {"4", "4"})
  504.                 arwrk.Add(New String() {"5", "5"})
  505.                 arwrk.Insert(0, New String() {"", "Please Select"})
  506.                 tblEvents.evtTierLevel.EditValue = arwrk
  507.  
  508.                 ' evtOverTimePriority   
  509.                 tblEvents.evtOverTimePriority.EditCustomAttributes = ""
  510.                 tblEvents.evtOverTimePriority.EditValue = ew_HtmlEncode(tblEvents.evtOverTimePriority.CurrentValue)
  511.  
  512.             End If
  513.  
  514.         ' Row Rendered event
  515.         tblEvents.Row_Rendered()
  516.     End Sub
  517.  
  518.     '
  519.     ' Validate form
  520.     '
  521.     Function ValidateForm() As Boolean
  522.  
  523.         ' Initialize
  524.         ParentPage.gsFormError = ""
  525.  
  526.         ' Check if validation required
  527.         If Not EW_SERVER_VALIDATE Then Return (ParentPage.gsFormError = "")
  528.  
  529.         ' Return validate result
  530.         Dim Valid As Boolean = (ParentPage.gsFormError = "")
  531.  
  532.         ' Form_CustomValidate event
  533.         Dim sFormCustomError As String = ""
  534.         Valid = Valid And Form_CustomValidate(sFormCustomError)
  535.         If sFormCustomError <> "" Then
  536.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  537.             ParentPage.gsFormError = ParentPage.gsFormError & sFormCustomError
  538.         End If
  539.         Return Valid
  540.     End Function
  541.  
  542.     '
  543.     ' Add record
  544.     '
  545.     Function AddRow() As Boolean
  546.         Dim Rs As New OrderedDictionary
  547.         Dim sSql As String, sFilter As String
  548.         Dim bInsertRow As Boolean
  549.         Dim RsChk As OleDbDataReader
  550.         Dim sIdxErrMsg As String
  551.         Dim LastInsertId As Object
  552.  
  553.         ' evtDescription
  554.         tblEvents.evtDescription.SetDbValue(tblEvents.evtDescription.CurrentValue, System.DBNull.Value)
  555.         Rs("evtDescription") = tblEvents.evtDescription.DbValue
  556.  
  557.             ' evtIsActive
  558.             Rs("evtIsActive") = True
  559.  
  560.             ' evtAllocateBilling
  561.             tblEvents.evtAllocateBilling.SetDbValue((tblEvents.evtAllocateBilling.CurrentValue <> "" And Not IsDBNull(tblEvents.evtAllocateBilling.CurrentValue)), System.DBNull.Value)
  562.             Rs("evtAllocateBilling") = tblEvents.evtAllocateBilling.DbValue
  563.  
  564.             ' evtBillingNotes
  565.             tblEvents.evtBillingNotes.SetDbValue(tblEvents.evtBillingNotes.CurrentValue, System.DBNull.Value)
  566.             Rs("evtBillingNotes") = tblEvents.evtBillingNotes.DbValue
  567.  
  568.             ' evtTierLevel
  569.             tblEvents.evtTierLevel.SetDbValue(tblEvents.evtTierLevel.CurrentValue, System.DBNull.Value)
  570.             Rs("evtTierLevel") = tblEvents.evtTierLevel.DbValue
  571.  
  572.             ' evtOverTimePriority
  573.             tblEvents.evtOverTimePriority.SetDbValue(tblEvents.evtOverTimePriority.CurrentValue, System.DBNull.Value)
  574.             Rs("evtOverTimePriority") = tblEvents.evtOverTimePriority.DbValue
  575.  
  576.             ' Row Inserting event
  577.         bInsertRow = tblEvents.Row_Inserting(Rs)
  578.         If bInsertRow Then
  579.             Try    
  580.                 tblEvents.Insert(Rs)
  581.                 AddRow = True
  582.             Catch e As Exception
  583.                 If EW_DEBUG_ENABLED Then Throw
  584.                 Message = e.Message                
  585.                 AddRow = False
  586.             End Try
  587.         Else
  588.             If tblEvents.CancelMessage <> "" Then
  589.                 Message = tblEvents.CancelMessage
  590.                 tblEvents.CancelMessage = ""
  591.             Else
  592.                 Message = "Insert cancelled"
  593.             End If
  594.             AddRow = False
  595.         End If
  596.         If AddRow Then
  597.             LastInsertId = Conn.GetLastInsertId()
  598.             tblEvents.evtID.DbValue = LastInsertId
  599.             Rs("evtID") = tblEvents.evtID.DbValue        
  600.  
  601.             ' Row Inserted event
  602.             tblEvents.Row_Inserted(Rs)
  603.         End If
  604.     End Function
  605.  
  606.         ' Page Load event
  607.         Public Sub Page_Load()
  608.  
  609.             'HttpContext.Current.Response.Write("Page Load")
  610.         End Sub
  611.  
  612.         ' Page Unload event
  613.         Public Sub Page_Unload()
  614.  
  615.             'HttpContext.Current.Response.Write("Page Unload")
  616.         End Sub
  617.  
  618.     ' Form Custom Validate event
  619.     Public Function Form_CustomValidate(ByRef CustomError As String) As Boolean
  620.  
  621.         'Return error message in CustomError
  622.         Return True
  623.     End Function
  624.     End Class
  625.  
  626.     '
  627.     ' ASP.NET Page_Load event
  628.     '
  629.  
  630.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  631.         Response.Buffer = EW_RESPONSE_BUFFER
  632.         Response.Cache.SetCacheability(HttpCacheability.NoCache)
  633.  
  634.         ' Page init
  635.         tblEvents_add = New ctblEvents_add(Me)        
  636.         tblEvents_add.Page_Init()
  637.  
  638.         ' Page main processing
  639.         tblEvents_add.Page_Main()
  640.     End Sub
  641.  
  642.     '
  643.     ' ASP.NET Page_Unload event
  644.     '
  645.  
  646.     Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
  647.  
  648.         ' Dispose page object
  649.         If tblEvents_add IsNot Nothing Then tblEvents_add.Dispose()
  650.     End Sub
  651. End Class
  652.