home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / tblSchedulemdelete.aspx.vb < prev    next >
Text File  |  2010-09-02  |  77KB  |  1,637 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 tblSchedulemdelete
  12.     Inherits AspNetMaker7_tfpssnet
  13.  
  14.     ' Page object
  15.     Public tblSchedule_update As ctblSchedule_update
  16.  
  17.     '
  18.     ' Page Class
  19.     '
  20.     Class ctblSchedule_update
  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 tblSchedule.UseTokenInUrl Then Url = Url & "t=" & tblSchedule.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 tblSchedule.UseTokenInUrl Then
  44.                 Result = False
  45.                 If ObjForm IsNot Nothing Then
  46.                     Result = (tblSchedule.TableVar = ObjForm.GetValue("t"))
  47.                 End If
  48.                 If ew_Get("t") <> "" Then
  49.                     Result = (tblSchedule.TableVar = ew_Get("t"))
  50.                 End If
  51.                 Return Result
  52.             End If
  53.             Return True
  54.         End Function
  55.  
  56.         ' tblSchedule
  57.         Public Property tblSchedule() As ctblSchedule
  58.             Get
  59.                 Return ParentPage.tblSchedule
  60.             End Get
  61.             Set(ByVal v As ctblSchedule)
  62.                 ParentPage.tblSchedule = v
  63.             End Set
  64.         End Property
  65.  
  66.         ' tblSchedule
  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 = "update"
  85.             m_PageObjName = "tblSchedule_update"
  86.             m_PageObjTypeName = "ctblSchedule_update"
  87.  
  88.             ' Table Name
  89.             m_TableName = "tblSchedule"
  90.  
  91.             ' Initialize table object
  92.             tblSchedule = New ctblSchedule(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.CanEdit Then
  121.                 Security.SaveLastUrl()
  122.                 Page_Terminate("tblSchedulelist.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.             If Security.IsLoggedIn() And ew_Empty(Security.CurrentUserID) Then
  132.                 Message = "You do not have the right permission to view the page"
  133.                 Page_Terminate("tblSchedulelist.aspx")
  134.             End If
  135.  
  136.             ' Global page loading event (in ewglobal*.vb)
  137.             ParentPage.Page_Loading()
  138.  
  139.             ' Page load event, used in current page
  140.             Page_Load()
  141.         End Sub
  142.  
  143.         '
  144.         '  Class terminate
  145.         '  - clean up page object
  146.         '
  147.         Public Sub Dispose() Implements IDisposable.Dispose
  148.             Page_Terminate("")
  149.         End Sub
  150.  
  151.         '
  152.         '  Sub Page_Terminate
  153.         '  - called when exit page
  154.         '  - clean up connection and objects
  155.         '  - if URL specified, redirect to URL
  156.         '
  157.         Sub Page_Terminate(ByVal url As String)
  158.  
  159.             ' Page unload event, used in current page
  160.             Page_Unload()
  161.  
  162.             ' Global page unloaded event (in ewglobal*.vb)
  163.             ParentPage.Page_Unloaded()
  164.  
  165.             ' Close connection
  166.             Conn.Dispose()
  167.             Security = Nothing
  168.             tblSchedule.Dispose()
  169.             tblEmployees.Dispose()
  170.  
  171.             ' Go to URL if specified
  172.             If url <> "" Then
  173.                 HttpContext.Current.Response.Clear()
  174.                 HttpContext.Current.Response.Redirect(url)
  175.             End If
  176.         End Sub
  177.  
  178.         Public arRecKeys() As String
  179.  
  180.         Public sDisabled As String
  181.  
  182.         Public lTotalRecs As Integer
  183.  
  184.         '
  185.         ' Page main processing
  186.         '
  187.         Sub Page_Main()
  188.             Dim sKeyName As String
  189.             Dim sKey As String
  190.             Dim nKeySelected As Integer = 0
  191.             Dim bUpdateSelected
  192.  
  193.             ' Try to load keys from list form
  194.             If HttpContext.Current.Request.RequestType = "POST" Then
  195.                 If ew_Post("key_m") <> "" Then ' Key count > 0
  196.                     arRecKeys = HttpContext.Current.Request.Form.GetValues("key_m")
  197.                     nKeySelected = arRecKeys.Length
  198.                     LoadMultiUpdateValues() ' Load initial values to form
  199.                 End If
  200.             End If
  201.  
  202.             ' Try to load key from update form
  203.             If nKeySelected = 0 Then
  204.                 Array.Resize(arRecKeys, 1)
  205.  
  206.                 ' Create form object
  207.                 ObjForm = New cFormObj
  208.                 If ObjForm.GetValue("a_update") <> "" Then
  209.  
  210.                     ' Get action
  211.                     tblSchedule.CurrentAction = ObjForm.GetValue("a_update")
  212.  
  213.                     ' Get record keys
  214.                     sKeyName = "k" & Convert.ToString(nKeySelected + 1) & "_key"
  215.                     sKey = ObjForm.GetValue(sKeyName)
  216.                     Do While sKey <> ""
  217.                         If nKeySelected > 0 Then
  218.                             Array.Resize(arRecKeys, nKeySelected + 1)
  219.                         End If
  220.                         arRecKeys(nKeySelected) = sKey
  221.                         nKeySelected = nKeySelected + 1
  222.                         sKeyName = "k" & Convert.ToString(nKeySelected + 1) & "_key"
  223.                         sKey = ObjForm.GetValue(sKeyName)
  224.                     Loop
  225.                     LoadFormValues() ' Get form values
  226.  
  227.                     ' Validate Form
  228.                     'If Not ValidateForm() Then
  229.                     '    tblSchedule.CurrentAction = "I" ' Form error, reset action
  230.                     '    Message = ParentPage.gsFormError
  231.                     'End If
  232.                 End If
  233.             End If
  234.             If nKeySelected <= 0 Then Page_Terminate("tblSchedulelist.aspx") ' No records selected, return to list
  235.             Select Case tblSchedule.CurrentAction
  236.                 Case "U" ' Update
  237.                     'If UpdateRows() Then ' Update Records based on key
  238.                     '    Message = "Update succeeded" ' Set update success message
  239.                     '    Page_Terminate(tblSchedule.ReturnUrl) ' Return to caller
  240.                     'Else
  241.                     '    RestoreFormValues() ' Restore form values
  242.                     'End If
  243.                 Case "D" ' Delete
  244.                     If DeleteRows() Then ' Delete Records based on key
  245.                         Message = "Multiple Delete succeeded" ' Set update success message
  246.                         Page_Terminate(tblSchedule.ReturnUrl) ' Return to caller
  247.                     Else
  248.                         RestoreFormValues() ' Restore form values
  249.                     End If
  250.             End Select
  251.  
  252.             ' Render row
  253.             tblSchedule.RowType = EW_ROWTYPE_EDIT ' Render edit
  254.  
  255.             ' Render row
  256.             RenderRow()
  257.         End Sub
  258.  
  259.         ' 
  260.         ' Load initial values to form if field values are identical in all selected records
  261.         '
  262.         Sub LoadMultiUpdateValues()
  263.             Dim i As Integer = 1
  264.             Try
  265.                 tblSchedule.CurrentFilter = BuildKeyFilter()
  266.  
  267.                 ' Load recordset
  268.                 Dim Rs As OleDbDataReader = LoadRecordset()
  269.                 Do While Rs.Read()
  270.                     If i = 1 Then
  271.                         tblSchedule.schDate.DbValue = Rs("schDate")
  272.                         tblSchedule.schEvtID.DbValue = Rs("schEvtID")
  273.                         tblSchedule.schPartsID.DbValue = Rs("schPartsID")
  274.                         tblSchedule.schCallTime.DbValue = Rs("schCallTime")
  275.                         tblSchedule.schStartTime.DbValue = Rs("schStartTime")
  276.                         tblSchedule.schEndTime.DbValue = Rs("schEndTime")
  277.                         tblSchedule.schOutTime.DbValue = Rs("schOutTime")
  278.                         tblSchedule.schLocID.DbValue = Rs("schLocID")
  279.                         tblSchedule.schEmpID.DbValue = Rs("schEmpID")
  280.                         tblSchedule.schPosID.DbValue = Rs("schPosID")
  281.                         tblSchedule.schTypID.DbValue = Rs("schTypID")
  282.                         tblSchedule.schDepID.DbValue = Rs("schDepID")
  283.                         tblSchedule.schNotes.DbValue = Rs("schNotes")
  284.                         tblSchedule.schRate.DbValue = Rs("schRate")
  285.                         tblSchedule.schActualStart.DbValue = Rs("schActualStart")
  286.                         tblSchedule.schActualEnd.DbValue = Rs("schActualEnd")
  287.                         tblSchedule.schDateCreated.DbValue = Rs("schDateCreated")
  288.                         tblSchedule.schDoubleBooked.DbValue = Rs("schDoubleBooked")
  289.                         tblSchedule.schStatus.DbValue = Rs("schStatus")
  290.                     Else
  291.                         If Not ew_CompareValue(tblSchedule.schDate.DbValue, Rs("schDate")) Then
  292.                             tblSchedule.schDate.CurrentValue = System.DBNull.Value
  293.                         End If
  294.                         If Not ew_CompareValue(tblSchedule.schEvtID.DbValue, Rs("schEvtID")) Then
  295.                             tblSchedule.schEvtID.CurrentValue = System.DBNull.Value
  296.                         End If
  297.                         If Not ew_CompareValue(tblSchedule.schPartsID.DbValue, Rs("schPartsID")) Then
  298.                             tblSchedule.schPartsID.CurrentValue = System.DBNull.Value
  299.                         End If
  300.                         If Not ew_CompareValue(tblSchedule.schCallTime.DbValue, Rs("schCallTime")) Then
  301.                             tblSchedule.schCallTime.CurrentValue = System.DBNull.Value
  302.                         End If
  303.                         If Not ew_CompareValue(tblSchedule.schStartTime.DbValue, Rs("schStartTime")) Then
  304.                             tblSchedule.schStartTime.CurrentValue = System.DBNull.Value
  305.                         End If
  306.                         If Not ew_CompareValue(tblSchedule.schEndTime.DbValue, Rs("schEndTime")) Then
  307.                             tblSchedule.schEndTime.CurrentValue = System.DBNull.Value
  308.                         End If
  309.                         If Not ew_CompareValue(tblSchedule.schOutTime.DbValue, Rs("schOutTime")) Then
  310.                             tblSchedule.schOutTime.CurrentValue = System.DBNull.Value
  311.                         End If
  312.                         If Not ew_CompareValue(tblSchedule.schLocID.DbValue, Rs("schLocID")) Then
  313.                             tblSchedule.schLocID.CurrentValue = System.DBNull.Value
  314.                         End If
  315.                         If Not ew_CompareValue(tblSchedule.schEmpID.DbValue, Rs("schEmpID")) Then
  316.                             tblSchedule.schEmpID.CurrentValue = System.DBNull.Value
  317.                         End If
  318.                         If Not ew_CompareValue(tblSchedule.schPosID.DbValue, Rs("schPosID")) Then
  319.                             tblSchedule.schPosID.CurrentValue = System.DBNull.Value
  320.                         End If
  321.                         If Not ew_CompareValue(tblSchedule.schTypID.DbValue, Rs("schTypID")) Then
  322.                             tblSchedule.schTypID.CurrentValue = System.DBNull.Value
  323.                         End If
  324.                         If Not ew_CompareValue(tblSchedule.schDepID.DbValue, Rs("schDepID")) Then
  325.                             tblSchedule.schDepID.CurrentValue = System.DBNull.Value
  326.                         End If
  327.                         If Not ew_CompareValue(tblSchedule.schNotes.DbValue, Rs("schNotes")) Then
  328.                             tblSchedule.schNotes.CurrentValue = System.DBNull.Value
  329.                         End If
  330.                         If Not ew_CompareValue(tblSchedule.schRate.DbValue, Rs("schRate")) Then
  331.                             tblSchedule.schRate.CurrentValue = System.DBNull.Value
  332.                         End If
  333.                         If Not ew_CompareValue(tblSchedule.schActualStart.DbValue, Rs("schActualStart")) Then
  334.                             tblSchedule.schActualStart.CurrentValue = System.DBNull.Value
  335.                         End If
  336.                         If Not ew_CompareValue(tblSchedule.schActualEnd.DbValue, Rs("schActualEnd")) Then
  337.                             tblSchedule.schActualEnd.CurrentValue = System.DBNull.Value
  338.                         End If
  339.                         If Not ew_CompareValue(tblSchedule.schDateCreated.DbValue, Rs("schDateCreated")) Then
  340.                             tblSchedule.schDateCreated.CurrentValue = System.DBNull.Value
  341.                         End If
  342.                         If Not ew_CompareValue(tblSchedule.schDoubleBooked.DbValue, Rs("schDoubleBooked")) Then
  343.                             tblSchedule.schDoubleBooked.CurrentValue = System.DBNull.Value
  344.                         End If
  345.                         If Not ew_CompareValue(tblSchedule.schStatus.DbValue, Rs("schStatus")) Then
  346.                             tblSchedule.schStatus.CurrentValue = System.DBNull.Value
  347.                         End If
  348.                     End If
  349.                     i = i + 1
  350.                 Loop
  351.                 Rs.Close()
  352.                 Rs.Dispose()
  353.             Catch
  354.                 If EW_DEBUG_ENABLED Then Throw
  355.             End Try
  356.         End Sub
  357.  
  358.         '
  359.         '  Build filter for all keys
  360.         '
  361.         Function BuildKeyFilter()
  362.             Dim sKey As String
  363.             Dim sWrkFilter As String = "", sFilter As String
  364.             For i As Integer = 0 To arRecKeys.GetUpperBound(0)
  365.                 sKey = arRecKeys(i).Trim()
  366.                 If SetupKeyValues(sKey) Then
  367.                     sFilter = tblSchedule.KeyFilter
  368.                     If sWrkFilter <> "" Then sWrkFilter = sWrkFilter & " OR "
  369.                     sWrkFilter = sWrkFilter & sFilter
  370.                 Else
  371.                     sWrkFilter = "0=1"
  372.                     Exit For
  373.                 End If
  374.             Next
  375.             BuildKeyFilter = sWrkFilter
  376.         End Function
  377.  
  378.         '
  379.         '  Set up key value
  380.         '
  381.         Function SetupKeyValues(ByVal key As String) As Boolean
  382.             Dim sKeyFld As String, arKeyFlds() As String
  383.             Dim sWrkFilter As String, sFilter As String
  384.             sKeyFld = key
  385.             If Not IsNumeric(sKeyFld) Then Return False
  386.             tblSchedule.schSchID.CurrentValue = sKeyFld ' Set up key value
  387.             Return True
  388.         End Function
  389.  
  390.         '
  391.         ' Update all selected rows
  392.         '
  393.         Function UpdateRows() As Boolean
  394.             Dim sKey As String = "", sThisKey As String, sSql As String
  395.             Dim RsOld As ArrayList, RsNew As ArrayList
  396.             Conn.BeginTrans() ' Begin transaction
  397.  
  398.             ' Get old recordset
  399.             tblSchedule.CurrentFilter = BuildKeyFilter()
  400.             sSql = tblSchedule.SQL
  401.             RsOld = Conn.GetRows(sSql)
  402.  
  403.             ' Update all rows
  404.             For i As Integer = 0 To arRecKeys.GetUpperBound(0)
  405.                 sThisKey = arRecKeys(i).Trim()
  406.                 If SetupKeyValues(sThisKey) Then
  407.                     tblSchedule.SendEmail = False ' Do not send email on update success
  408.                     UpdateRows = EditRow() ' Update this row
  409.                 Else
  410.                     UpdateRows = False
  411.                 End If
  412.                 If Not UpdateRows Then Exit For ' Update failed
  413.                 If sKey <> "" Then sKey = sKey & ", "
  414.                 sKey = sKey & sThisKey
  415.             Next
  416.             If UpdateRows Then
  417.                 Conn.CommitTrans() ' Commit transaction
  418.  
  419.                 ' Get new recordset
  420.                 RsNew = Conn.GetRows(sSql)
  421.             Else
  422.                 Conn.RollbackTrans() ' Rollback transaction            
  423.             End If
  424.         End Function
  425.  
  426.         '
  427.         ' Delete all selected rows
  428.         '
  429.         Function DeleteRows() As Boolean
  430.             Dim sKey As String = "", sThisKey As String, sSql As String, tmpSql As String
  431.             Dim RsOld As ArrayList, RsNew As ArrayList
  432.             '            Conn.BeginTrans() ' Begin transaction
  433.  
  434.             ' Get old recordset
  435.             tblSchedule.CurrentFilter = BuildKeyFilter()
  436.             sSql = tblSchedule.SQL
  437.             RsOld = Conn.GetRows(sSql)
  438.  
  439.             ' Delete all rows
  440.             For i As Integer = 0 To arRecKeys.GetUpperBound(0)
  441.                 sThisKey = arRecKeys(i).Trim()
  442.                 If SetupKeyValues(sThisKey) Then
  443.                     tblSchedule.SendEmail = False ' Do not send email on update success
  444.                     '                    DeleteRows = EditRow() ' Update this row
  445.                     tmpSql = "DELETE tblSchedule.schSchID FROM tblSchedule WHERE tblSchedule.schSchID = " & sThisKey
  446.                     ew_Execute(tmpSql)
  447.                     DeleteRows = True
  448.                 Else
  449.                     DeleteRows = False
  450.                 End If
  451.                 If Not DeleteRows Then Exit For ' Update failed
  452.                 If sKey <> "" Then sKey = sKey & ", "
  453.                 sKey = sKey & sThisKey
  454.             Next
  455.             'If DeleteRows Then
  456.             '    Conn.CommitTrans() ' Commit transaction
  457.  
  458.             '    ' Get new recordset
  459.             '    RsNew = Conn.GetRows(sSql)
  460.             'Else
  461.             '    Conn.RollbackTrans() ' Rollback transaction            
  462.             'End If
  463.         End Function
  464.  
  465.         '
  466.         ' Get upload file
  467.         '
  468.         Sub GetUploadFiles()
  469.  
  470.             ' Get upload data
  471.         End Sub
  472.  
  473.         '
  474.         ' Load default values
  475.         '
  476.         Sub LoadDefaultValues()
  477.         End Sub
  478.  
  479.         '
  480.         ' Load form values
  481.         '
  482.         Sub LoadFormValues()
  483.             tblSchedule.schDate.FormValue = ObjForm.GetValue("x_schDate")
  484.             tblSchedule.schDate.CurrentValue = ew_UnFormatDateTime(tblSchedule.schDate.CurrentValue, 6)
  485.             tblSchedule.schDate.MultiUpdate = ObjForm.GetValue("u_schDate")
  486.             tblSchedule.schDate.OldValue = ObjForm.GetValue("o_schDate")
  487.             tblSchedule.schEvtID.FormValue = ObjForm.GetValue("x_schEvtID")
  488.             tblSchedule.schEvtID.MultiUpdate = ObjForm.GetValue("u_schEvtID")
  489.             tblSchedule.schEvtID.OldValue = ObjForm.GetValue("o_schEvtID")
  490.             tblSchedule.schPartsID.FormValue = ObjForm.GetValue("x_schPartsID")
  491.             tblSchedule.schPartsID.MultiUpdate = ObjForm.GetValue("u_schPartsID")
  492.             tblSchedule.schPartsID.OldValue = ObjForm.GetValue("o_schPartsID")
  493.             tblSchedule.schCallTime.FormValue = ObjForm.GetValue("x_schCallTime")
  494.             tblSchedule.schCallTime.CurrentValue = ew_UnFormatDateTime(tblSchedule.schCallTime.CurrentValue, 3)
  495.             tblSchedule.schCallTime.MultiUpdate = ObjForm.GetValue("u_schCallTime")
  496.             tblSchedule.schCallTime.OldValue = ObjForm.GetValue("o_schCallTime")
  497.             tblSchedule.schStartTime.FormValue = ObjForm.GetValue("x_schStartTime")
  498.             tblSchedule.schStartTime.CurrentValue = ew_UnFormatDateTime(tblSchedule.schStartTime.CurrentValue, 3)
  499.             tblSchedule.schStartTime.MultiUpdate = ObjForm.GetValue("u_schStartTime")
  500.             tblSchedule.schStartTime.OldValue = ObjForm.GetValue("o_schStartTime")
  501.             tblSchedule.schEndTime.FormValue = ObjForm.GetValue("x_schEndTime")
  502.             tblSchedule.schEndTime.CurrentValue = ew_UnFormatDateTime(tblSchedule.schEndTime.CurrentValue, 3)
  503.             tblSchedule.schEndTime.MultiUpdate = ObjForm.GetValue("u_schEndTime")
  504.             tblSchedule.schEndTime.OldValue = ObjForm.GetValue("o_schEndTime")
  505.             tblSchedule.schOutTime.FormValue = ObjForm.GetValue("x_schOutTime")
  506.             tblSchedule.schOutTime.CurrentValue = ew_UnFormatDateTime(tblSchedule.schOutTime.CurrentValue, 3)
  507.             tblSchedule.schOutTime.MultiUpdate = ObjForm.GetValue("u_schOutTime")
  508.             tblSchedule.schOutTime.OldValue = ObjForm.GetValue("o_schOutTime")
  509.             tblSchedule.schLocID.FormValue = ObjForm.GetValue("x_schLocID")
  510.             tblSchedule.schLocID.MultiUpdate = ObjForm.GetValue("u_schLocID")
  511.             tblSchedule.schLocID.OldValue = ObjForm.GetValue("o_schLocID")
  512.             tblSchedule.schEmpID.FormValue = ObjForm.GetValue("x_schEmpID")
  513.             tblSchedule.schEmpID.MultiUpdate = ObjForm.GetValue("u_schEmpID")
  514.             tblSchedule.schEmpID.OldValue = ObjForm.GetValue("o_schEmpID")
  515.             tblSchedule.schPosID.FormValue = ObjForm.GetValue("x_schPosID")
  516.             tblSchedule.schPosID.MultiUpdate = ObjForm.GetValue("u_schPosID")
  517.             tblSchedule.schPosID.OldValue = ObjForm.GetValue("o_schPosID")
  518.             tblSchedule.schTypID.FormValue = ObjForm.GetValue("x_schTypID")
  519.             tblSchedule.schTypID.MultiUpdate = ObjForm.GetValue("u_schTypID")
  520.             tblSchedule.schTypID.OldValue = ObjForm.GetValue("o_schTypID")
  521.             tblSchedule.schDepID.FormValue = ObjForm.GetValue("x_schDepID")
  522.             tblSchedule.schDepID.MultiUpdate = ObjForm.GetValue("u_schDepID")
  523.             tblSchedule.schDepID.OldValue = ObjForm.GetValue("o_schDepID")
  524.             tblSchedule.schNotes.FormValue = ObjForm.GetValue("x_schNotes")
  525.             tblSchedule.schNotes.MultiUpdate = ObjForm.GetValue("u_schNotes")
  526.             tblSchedule.schNotes.OldValue = ObjForm.GetValue("o_schNotes")
  527.             tblSchedule.schRate.FormValue = ObjForm.GetValue("x_schRate")
  528.             tblSchedule.schRate.MultiUpdate = ObjForm.GetValue("u_schRate")
  529.             tblSchedule.schRate.OldValue = ObjForm.GetValue("o_schRate")
  530.             tblSchedule.schActualStart.FormValue = ObjForm.GetValue("x_schActualStart")
  531.             tblSchedule.schActualStart.CurrentValue = ew_UnFormatDateTime(tblSchedule.schActualStart.CurrentValue, 3)
  532.             tblSchedule.schActualStart.MultiUpdate = ObjForm.GetValue("u_schActualStart")
  533.             tblSchedule.schActualStart.OldValue = ObjForm.GetValue("o_schActualStart")
  534.             tblSchedule.schActualEnd.FormValue = ObjForm.GetValue("x_schActualEnd")
  535.             tblSchedule.schActualEnd.CurrentValue = ew_UnFormatDateTime(tblSchedule.schActualEnd.CurrentValue, 3)
  536.             tblSchedule.schActualEnd.MultiUpdate = ObjForm.GetValue("u_schActualEnd")
  537.             tblSchedule.schActualEnd.OldValue = ObjForm.GetValue("o_schActualEnd")
  538.             tblSchedule.schDateCreated.FormValue = ObjForm.GetValue("x_schDateCreated")
  539.             tblSchedule.schDateCreated.CurrentValue = ew_UnFormatDateTime(tblSchedule.schDateCreated.CurrentValue, 6)
  540.             tblSchedule.schDateCreated.MultiUpdate = ObjForm.GetValue("u_schDateCreated")
  541.             tblSchedule.schDateCreated.OldValue = ObjForm.GetValue("o_schDateCreated")
  542.             tblSchedule.schDoubleBooked.FormValue = ObjForm.GetValue("x_schDoubleBooked")
  543.             tblSchedule.schDoubleBooked.MultiUpdate = ObjForm.GetValue("u_schDoubleBooked")
  544.             tblSchedule.schDoubleBooked.OldValue = ObjForm.GetValue("o_schDoubleBooked")
  545.             tblSchedule.schStatus.FormValue = ObjForm.GetValue("x_schStatus")
  546.             tblSchedule.schStatus.MultiUpdate = ObjForm.GetValue("u_schStatus")
  547.             tblSchedule.schStatus.OldValue = ObjForm.GetValue("o_schStatus")
  548.             tblSchedule.schSchID.FormValue = ObjForm.GetValue("x_schSchID")
  549.         End Sub
  550.  
  551.         '
  552.         ' Restore form values
  553.         '
  554.         Sub RestoreFormValues()
  555.             tblSchedule.schDate.CurrentValue = tblSchedule.schDate.FormValue
  556.             tblSchedule.schDate.CurrentValue = ew_UnFormatDateTime(tblSchedule.schDate.CurrentValue, 6)
  557.             tblSchedule.schEvtID.CurrentValue = tblSchedule.schEvtID.FormValue
  558.             tblSchedule.schPartsID.CurrentValue = tblSchedule.schPartsID.FormValue
  559.             tblSchedule.schCallTime.CurrentValue = tblSchedule.schCallTime.FormValue
  560.             tblSchedule.schCallTime.CurrentValue = ew_UnFormatDateTime(tblSchedule.schCallTime.CurrentValue, 3)
  561.             tblSchedule.schStartTime.CurrentValue = tblSchedule.schStartTime.FormValue
  562.             tblSchedule.schStartTime.CurrentValue = ew_UnFormatDateTime(tblSchedule.schStartTime.CurrentValue, 3)
  563.             tblSchedule.schEndTime.CurrentValue = tblSchedule.schEndTime.FormValue
  564.             tblSchedule.schEndTime.CurrentValue = ew_UnFormatDateTime(tblSchedule.schEndTime.CurrentValue, 3)
  565.             tblSchedule.schOutTime.CurrentValue = tblSchedule.schOutTime.FormValue
  566.             tblSchedule.schOutTime.CurrentValue = ew_UnFormatDateTime(tblSchedule.schOutTime.CurrentValue, 3)
  567.             tblSchedule.schLocID.CurrentValue = tblSchedule.schLocID.FormValue
  568.             tblSchedule.schEmpID.CurrentValue = tblSchedule.schEmpID.FormValue
  569.             tblSchedule.schPosID.CurrentValue = tblSchedule.schPosID.FormValue
  570.             tblSchedule.schTypID.CurrentValue = tblSchedule.schTypID.FormValue
  571.             tblSchedule.schDepID.CurrentValue = tblSchedule.schDepID.FormValue
  572.             tblSchedule.schNotes.CurrentValue = tblSchedule.schNotes.FormValue
  573.             tblSchedule.schRate.CurrentValue = tblSchedule.schRate.FormValue
  574.             tblSchedule.schActualStart.CurrentValue = tblSchedule.schActualStart.FormValue
  575.             tblSchedule.schActualStart.CurrentValue = ew_UnFormatDateTime(tblSchedule.schActualStart.CurrentValue, 3)
  576.             tblSchedule.schActualEnd.CurrentValue = tblSchedule.schActualEnd.FormValue
  577.             tblSchedule.schActualEnd.CurrentValue = ew_UnFormatDateTime(tblSchedule.schActualEnd.CurrentValue, 3)
  578.             tblSchedule.schDateCreated.CurrentValue = tblSchedule.schDateCreated.FormValue
  579.             tblSchedule.schDateCreated.CurrentValue = ew_UnFormatDateTime(tblSchedule.schDateCreated.CurrentValue, 6)
  580.             tblSchedule.schDoubleBooked.CurrentValue = tblSchedule.schDoubleBooked.FormValue
  581.             tblSchedule.schStatus.CurrentValue = tblSchedule.schStatus.FormValue
  582.             tblSchedule.schSchID.CurrentValue = tblSchedule.schSchID.FormValue
  583.         End Sub
  584.  
  585.         '
  586.         ' Load recordset
  587.         '
  588.         Function LoadRecordset() As OleDbDataReader
  589.  
  590.             ' Recordset Selecting event
  591.             tblSchedule.Recordset_Selecting(tblSchedule.CurrentFilter)
  592.  
  593.             ' Load list page SQL
  594.             Dim sSql As String = tblSchedule.ListSQL
  595.  
  596.             ' Write SQL for debug
  597.             If EW_DEBUG_ENABLED Then ew_Write(sSql)
  598.  
  599.             ' Count
  600.             lTotalRecs = -1
  601.             Try
  602.                 If sSql.StartsWith("SELECT * FROM ", StringComparison.InvariantCultureIgnoreCase) AndAlso _
  603.                  ew_Empty(tblSchedule.SqlGroupBy) AndAlso _
  604.                  ew_Empty(tblSchedule.SqlHaving) Then
  605.                     Dim sCntSql As String = tblSchedule.SelectCountSQL
  606.  
  607.                     ' Write SQL for debug
  608.                     If EW_DEBUG_ENABLED Then ew_Write("<br>" & sCntSql)
  609.                     lTotalRecs = Conn.ExecuteScalar(sCntSql)
  610.                 End If
  611.             Catch
  612.             End Try
  613.  
  614.             ' Load recordset
  615.             Dim Rs As OleDbDataReader = Conn.GetDataReader(sSql)
  616.             If lTotalRecs < 0 AndAlso Rs.HasRows Then
  617.                 lTotalRecs = 0
  618.                 While Rs.Read()
  619.                     lTotalRecs = lTotalRecs + 1
  620.                 End While
  621.                 Rs.Close()
  622.                 Rs = Conn.GetDataReader(sSql)
  623.             End If
  624.  
  625.             ' Recordset Selected event
  626.             tblSchedule.Recordset_Selected(Rs)
  627.             Return Rs
  628.         End Function
  629.  
  630.         '
  631.         ' Render row values based on field settings
  632.         '
  633.         Sub RenderRow()
  634.  
  635.             ' Row Rendering event
  636.             tblSchedule.Row_Rendering()
  637.  
  638.             '
  639.             '  Common render codes for all row types
  640.             '
  641.             ' schDate
  642.  
  643.             tblSchedule.schDate.CellCssStyle = ""
  644.             tblSchedule.schDate.CellCssClass = ""
  645.  
  646.             ' schEvtID
  647.             tblSchedule.schEvtID.CellCssStyle = ""
  648.             tblSchedule.schEvtID.CellCssClass = ""
  649.  
  650.             ' schPartsID
  651.             tblSchedule.schPartsID.CellCssStyle = ""
  652.             tblSchedule.schPartsID.CellCssClass = ""
  653.  
  654.             ' schCallTime
  655.             tblSchedule.schCallTime.CellCssStyle = ""
  656.             tblSchedule.schCallTime.CellCssClass = ""
  657.  
  658.             ' schStartTime
  659.             tblSchedule.schStartTime.CellCssStyle = ""
  660.             tblSchedule.schStartTime.CellCssClass = ""
  661.  
  662.             ' schEndTime
  663.             tblSchedule.schEndTime.CellCssStyle = ""
  664.             tblSchedule.schEndTime.CellCssClass = ""
  665.  
  666.             ' schOutTime
  667.             tblSchedule.schOutTime.CellCssStyle = ""
  668.             tblSchedule.schOutTime.CellCssClass = ""
  669.  
  670.             ' schLocID
  671.             tblSchedule.schLocID.CellCssStyle = ""
  672.             tblSchedule.schLocID.CellCssClass = ""
  673.  
  674.             ' schEmpID
  675.             tblSchedule.schEmpID.CellCssStyle = ""
  676.             tblSchedule.schEmpID.CellCssClass = ""
  677.  
  678.             ' schPosID
  679.             tblSchedule.schPosID.CellCssStyle = ""
  680.             tblSchedule.schPosID.CellCssClass = ""
  681.  
  682.             ' schTypID
  683.             tblSchedule.schTypID.CellCssStyle = ""
  684.             tblSchedule.schTypID.CellCssClass = ""
  685.  
  686.             ' schDepID
  687.             tblSchedule.schDepID.CellCssStyle = ""
  688.             tblSchedule.schDepID.CellCssClass = ""
  689.  
  690.             ' schNotes
  691.             tblSchedule.schNotes.CellCssStyle = ""
  692.             tblSchedule.schNotes.CellCssClass = ""
  693.  
  694.             ' schRate
  695.             tblSchedule.schRate.CellCssStyle = ""
  696.             tblSchedule.schRate.CellCssClass = ""
  697.  
  698.             ' schActualStart
  699.             tblSchedule.schActualStart.CellCssStyle = ""
  700.             tblSchedule.schActualStart.CellCssClass = ""
  701.  
  702.             ' schActualEnd
  703.             tblSchedule.schActualEnd.CellCssStyle = ""
  704.             tblSchedule.schActualEnd.CellCssClass = ""
  705.  
  706.             ' schDateCreated
  707.             tblSchedule.schDateCreated.CellCssStyle = ""
  708.             tblSchedule.schDateCreated.CellCssClass = ""
  709.  
  710.             ' schDoubleBooked
  711.             tblSchedule.schDoubleBooked.CellCssStyle = ""
  712.             tblSchedule.schDoubleBooked.CellCssClass = ""
  713.  
  714.             ' schStatus
  715.             tblSchedule.schStatus.CellCssStyle = ""
  716.             tblSchedule.schStatus.CellCssClass = ""
  717.  
  718.             '
  719.             '  View  Row
  720.             '
  721.  
  722.             If tblSchedule.RowType = EW_ROWTYPE_VIEW Then ' View row
  723.  
  724.                 ' schDate
  725.                 tblSchedule.schDate.ViewValue = tblSchedule.schDate.CurrentValue
  726.                 tblSchedule.schDate.ViewValue = ew_FormatDateTime(tblSchedule.schDate.ViewValue, 6)
  727.                 tblSchedule.schDate.CssStyle = ""
  728.                 tblSchedule.schDate.CssClass = ""
  729.                 tblSchedule.schDate.ViewCustomAttributes = ""
  730.  
  731.                 ' schEvtID
  732.                 If ew_NotEmpty(tblSchedule.schEvtID.CurrentValue) Then
  733.                     sSqlWrk = "SELECT [evtDescription] FROM [tblEvents] WHERE [evtID] = " & ew_AdjustSql(tblSchedule.schEvtID.CurrentValue) & ""
  734.                     sSqlWrk = sSqlWrk & " ORDER BY [evtDescription] "
  735.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  736.                     If RsWrk.Read() Then
  737.                         tblSchedule.schEvtID.ViewValue = RsWrk("evtDescription")
  738.                     Else
  739.                         tblSchedule.schEvtID.ViewValue = tblSchedule.schEvtID.CurrentValue
  740.                     End If
  741.                     Conn.CloseTempDataReader()
  742.                 Else
  743.                     tblSchedule.schEvtID.ViewValue = System.DBNull.Value
  744.                 End If
  745.                 tblSchedule.schEvtID.CssStyle = ""
  746.                 tblSchedule.schEvtID.CssClass = ""
  747.                 tblSchedule.schEvtID.ViewCustomAttributes = ""
  748.  
  749.                 ' schPartsID
  750.                 If ew_NotEmpty(tblSchedule.schPartsID.CurrentValue) Then
  751.                     sSqlWrk = "SELECT [prtDescription] FROM [tblParts] WHERE [prtID] = " & ew_AdjustSql(tblSchedule.schPartsID.CurrentValue) & ""
  752.                     sSqlWrk = sSqlWrk & " ORDER BY [prtDescription] "
  753.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  754.                     If RsWrk.Read() Then
  755.                         tblSchedule.schPartsID.ViewValue = RsWrk("prtDescription")
  756.                     Else
  757.                         tblSchedule.schPartsID.ViewValue = tblSchedule.schPartsID.CurrentValue
  758.                     End If
  759.                     Conn.CloseTempDataReader()
  760.                 Else
  761.                     tblSchedule.schPartsID.ViewValue = System.DBNull.Value
  762.                 End If
  763.                 tblSchedule.schPartsID.CssStyle = ""
  764.                 tblSchedule.schPartsID.CssClass = ""
  765.                 tblSchedule.schPartsID.ViewCustomAttributes = ""
  766.  
  767.                 ' schCallTime
  768.                 tblSchedule.schCallTime.ViewValue = tblSchedule.schCallTime.CurrentValue
  769.                 tblSchedule.schCallTime.ViewValue = ew_FormatDateTime(tblSchedule.schCallTime.ViewValue, 14)
  770.                 tblSchedule.schCallTime.CssStyle = ""
  771.                 tblSchedule.schCallTime.CssClass = ""
  772.                 tblSchedule.schCallTime.ViewCustomAttributes = ""
  773.  
  774.                 ' schStartTime
  775.                 tblSchedule.schStartTime.ViewValue = tblSchedule.schStartTime.CurrentValue
  776.                 tblSchedule.schStartTime.ViewValue = ew_FormatDateTime(tblSchedule.schStartTime.ViewValue, 14)
  777.                 tblSchedule.schStartTime.CssStyle = ""
  778.                 tblSchedule.schStartTime.CssClass = ""
  779.                 tblSchedule.schStartTime.ViewCustomAttributes = ""
  780.  
  781.                 ' schEndTime
  782.                 tblSchedule.schEndTime.ViewValue = tblSchedule.schEndTime.CurrentValue
  783.                 tblSchedule.schEndTime.ViewValue = ew_FormatDateTime(tblSchedule.schEndTime.ViewValue, 14)
  784.                 tblSchedule.schEndTime.CssStyle = ""
  785.                 tblSchedule.schEndTime.CssClass = ""
  786.                 tblSchedule.schEndTime.ViewCustomAttributes = ""
  787.  
  788.                 ' schOutTime
  789.                 tblSchedule.schOutTime.ViewValue = tblSchedule.schOutTime.CurrentValue
  790.                 tblSchedule.schOutTime.ViewValue = ew_FormatDateTime(tblSchedule.schOutTime.ViewValue, 14)
  791.                 tblSchedule.schOutTime.CssStyle = ""
  792.                 tblSchedule.schOutTime.CssClass = ""
  793.                 tblSchedule.schOutTime.ViewCustomAttributes = ""
  794.  
  795.                 ' schLocID
  796.                 If ew_NotEmpty(tblSchedule.schLocID.CurrentValue) Then
  797.                     sSqlWrk = "SELECT [locDescription] FROM [tblLocations] WHERE [locID] = " & ew_AdjustSql(tblSchedule.schLocID.CurrentValue) & ""
  798.                     sSqlWrk = sSqlWrk & " ORDER BY [locDescription] "
  799.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  800.                     If RsWrk.Read() Then
  801.                         tblSchedule.schLocID.ViewValue = RsWrk("locDescription")
  802.                     Else
  803.                         tblSchedule.schLocID.ViewValue = tblSchedule.schLocID.CurrentValue
  804.                     End If
  805.                     Conn.CloseTempDataReader()
  806.                 Else
  807.                     tblSchedule.schLocID.ViewValue = System.DBNull.Value
  808.                 End If
  809.                 tblSchedule.schLocID.CssStyle = ""
  810.                 tblSchedule.schLocID.CssClass = ""
  811.                 tblSchedule.schLocID.ViewCustomAttributes = ""
  812.  
  813.                 ' schEmpID
  814.                 If ew_NotEmpty(tblSchedule.schEmpID.CurrentValue) Then
  815.                     sSqlWrk = "SELECT [empName] FROM [tblEmployees] WHERE [empID] = " & ew_AdjustSql(tblSchedule.schEmpID.CurrentValue) & ""
  816.                     sSqlWrk = sSqlWrk & " ORDER BY [empFirstName] "
  817.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  818.                     If RsWrk.Read() Then
  819.                         tblSchedule.schEmpID.ViewValue = RsWrk("empName")
  820.                     Else
  821.                         tblSchedule.schEmpID.ViewValue = tblSchedule.schEmpID.CurrentValue
  822.                     End If
  823.                     Conn.CloseTempDataReader()
  824.                 Else
  825.                     tblSchedule.schEmpID.ViewValue = System.DBNull.Value
  826.                 End If
  827.                 tblSchedule.schEmpID.CssStyle = ""
  828.                 tblSchedule.schEmpID.CssClass = ""
  829.                 tblSchedule.schEmpID.ViewCustomAttributes = ""
  830.  
  831.                 ' schPosID
  832.                 If ew_NotEmpty(tblSchedule.schPosID.CurrentValue) Then
  833.                     sSqlWrk = "SELECT [posDescription] FROM [tblPositions] WHERE [posID] = " & ew_AdjustSql(tblSchedule.schPosID.CurrentValue) & ""
  834.                     sSqlWrk = sSqlWrk & " ORDER BY [posDescription] "
  835.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  836.                     If RsWrk.Read() Then
  837.                         tblSchedule.schPosID.ViewValue = RsWrk("posDescription")
  838.                     Else
  839.                         tblSchedule.schPosID.ViewValue = tblSchedule.schPosID.CurrentValue
  840.                     End If
  841.                     Conn.CloseTempDataReader()
  842.                 Else
  843.                     tblSchedule.schPosID.ViewValue = System.DBNull.Value
  844.                 End If
  845.                 tblSchedule.schPosID.CssStyle = ""
  846.                 tblSchedule.schPosID.CssClass = ""
  847.                 tblSchedule.schPosID.ViewCustomAttributes = ""
  848.  
  849.                 ' schTypID
  850.                 If ew_NotEmpty(tblSchedule.schTypID.CurrentValue) Then
  851.                     sSqlWrk = "SELECT [typDescription] FROM [tblTypes] WHERE [typID] = " & ew_AdjustSql(tblSchedule.schTypID.CurrentValue) & ""
  852.                     sSqlWrk = sSqlWrk & " ORDER BY [typDescription] "
  853.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  854.                     If RsWrk.Read() Then
  855.                         tblSchedule.schTypID.ViewValue = RsWrk("typDescription")
  856.                     Else
  857.                         tblSchedule.schTypID.ViewValue = tblSchedule.schTypID.CurrentValue
  858.                     End If
  859.                     Conn.CloseTempDataReader()
  860.                 Else
  861.                     tblSchedule.schTypID.ViewValue = System.DBNull.Value
  862.                 End If
  863.                 tblSchedule.schTypID.CssStyle = ""
  864.                 tblSchedule.schTypID.CssClass = ""
  865.                 tblSchedule.schTypID.ViewCustomAttributes = ""
  866.  
  867.                 ' schDepID
  868.                 If ew_NotEmpty(tblSchedule.schDepID.CurrentValue) Then
  869.                     sSqlWrk = "SELECT [depDescription] FROM [tblDepartments] WHERE [depID] = " & ew_AdjustSql(tblSchedule.schDepID.CurrentValue) & ""
  870.                     sSqlWrk = sSqlWrk & " ORDER BY [depDescription] "
  871.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  872.                     If RsWrk.Read() Then
  873.                         tblSchedule.schDepID.ViewValue = RsWrk("depDescription")
  874.                     Else
  875.                         tblSchedule.schDepID.ViewValue = tblSchedule.schDepID.CurrentValue
  876.                     End If
  877.                     Conn.CloseTempDataReader()
  878.                 Else
  879.                     tblSchedule.schDepID.ViewValue = System.DBNull.Value
  880.                 End If
  881.                 tblSchedule.schDepID.CssStyle = ""
  882.                 tblSchedule.schDepID.CssClass = ""
  883.                 tblSchedule.schDepID.ViewCustomAttributes = ""
  884.  
  885.                 ' schNotes
  886.                 tblSchedule.schNotes.ViewValue = tblSchedule.schNotes.CurrentValue
  887.                 tblSchedule.schNotes.CssStyle = ""
  888.                 tblSchedule.schNotes.CssClass = ""
  889.                 tblSchedule.schNotes.ViewCustomAttributes = ""
  890.  
  891.                 ' schRate
  892.                 tblSchedule.schRate.ViewValue = tblSchedule.schRate.CurrentValue
  893.                 tblSchedule.schRate.CssStyle = ""
  894.                 tblSchedule.schRate.CssClass = ""
  895.                 tblSchedule.schRate.ViewCustomAttributes = ""
  896.  
  897.                 ' schActualStart
  898.                 tblSchedule.schActualStart.ViewValue = tblSchedule.schActualStart.CurrentValue
  899.                 tblSchedule.schActualStart.ViewValue = ew_FormatDateTime(tblSchedule.schActualStart.ViewValue, 14)
  900.                 tblSchedule.schActualStart.CssStyle = ""
  901.                 tblSchedule.schActualStart.CssClass = ""
  902.                 tblSchedule.schActualStart.ViewCustomAttributes = ""
  903.  
  904.                 ' schActualEnd
  905.                 tblSchedule.schActualEnd.ViewValue = tblSchedule.schActualEnd.CurrentValue
  906.                 tblSchedule.schActualEnd.ViewValue = ew_FormatDateTime(tblSchedule.schActualEnd.ViewValue, 14)
  907.                 tblSchedule.schActualEnd.CssStyle = ""
  908.                 tblSchedule.schActualEnd.CssClass = ""
  909.                 tblSchedule.schActualEnd.ViewCustomAttributes = ""
  910.  
  911.                 ' schDateCreated
  912.                 tblSchedule.schDateCreated.ViewValue = tblSchedule.schDateCreated.CurrentValue
  913.                 tblSchedule.schDateCreated.ViewValue = ew_FormatDateTime(tblSchedule.schDateCreated.ViewValue, 6)
  914.                 tblSchedule.schDateCreated.CssStyle = ""
  915.                 tblSchedule.schDateCreated.CssClass = ""
  916.                 tblSchedule.schDateCreated.ViewCustomAttributes = ""
  917.  
  918.                 ' schDoubleBooked
  919.                 If Convert.ToString(tblSchedule.schDoubleBooked.CurrentValue) = "1" Then
  920.                     tblSchedule.schDoubleBooked.ViewValue = "Yes"
  921.                 Else
  922.                     tblSchedule.schDoubleBooked.ViewValue = "No"
  923.                 End If
  924.                 tblSchedule.schDoubleBooked.CssStyle = ""
  925.                 tblSchedule.schDoubleBooked.CssClass = ""
  926.                 tblSchedule.schDoubleBooked.ViewCustomAttributes = ""
  927.  
  928.                 ' schStatus
  929.                 If ew_NotEmpty(tblSchedule.schStatus.CurrentValue) Then
  930.                     sSqlWrk = "SELECT [stDescription] FROM [tblScheduleStatus] WHERE [stID] = " & ew_AdjustSql(tblSchedule.schStatus.CurrentValue) & ""
  931.                     sSqlWrk = sSqlWrk & " ORDER BY [stDescription] "
  932.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  933.                     If RsWrk.Read() Then
  934.                         tblSchedule.schStatus.ViewValue = RsWrk("stDescription")
  935.                     Else
  936.                         tblSchedule.schStatus.ViewValue = tblSchedule.schStatus.CurrentValue
  937.                     End If
  938.                     Conn.CloseTempDataReader()
  939.                 Else
  940.                     tblSchedule.schStatus.ViewValue = System.DBNull.Value
  941.                 End If
  942.                 tblSchedule.schStatus.CssStyle = ""
  943.                 tblSchedule.schStatus.CssClass = ""
  944.                 tblSchedule.schStatus.ViewCustomAttributes = ""
  945.  
  946.                 ' View refer script
  947.                 ' schDate
  948.  
  949.                 tblSchedule.schDate.HrefValue = ""
  950.  
  951.                 ' schEvtID
  952.                 tblSchedule.schEvtID.HrefValue = ""
  953.  
  954.                 ' schPartsID
  955.                 tblSchedule.schPartsID.HrefValue = ""
  956.  
  957.                 ' schCallTime
  958.                 tblSchedule.schCallTime.HrefValue = ""
  959.  
  960.                 ' schStartTime
  961.                 tblSchedule.schStartTime.HrefValue = ""
  962.  
  963.                 ' schEndTime
  964.                 tblSchedule.schEndTime.HrefValue = ""
  965.  
  966.                 ' schOutTime
  967.                 tblSchedule.schOutTime.HrefValue = ""
  968.  
  969.                 ' schLocID
  970.                 tblSchedule.schLocID.HrefValue = ""
  971.  
  972.                 ' schEmpID
  973.                 tblSchedule.schEmpID.HrefValue = ""
  974.  
  975.                 ' schPosID
  976.                 tblSchedule.schPosID.HrefValue = ""
  977.  
  978.                 ' schTypID
  979.                 tblSchedule.schTypID.HrefValue = ""
  980.  
  981.                 ' schDepID
  982.                 tblSchedule.schDepID.HrefValue = ""
  983.  
  984.                 ' schNotes
  985.                 tblSchedule.schNotes.HrefValue = ""
  986.  
  987.                 ' schRate
  988.                 tblSchedule.schRate.HrefValue = ""
  989.  
  990.                 ' schActualStart
  991.                 tblSchedule.schActualStart.HrefValue = ""
  992.  
  993.                 ' schActualEnd
  994.                 tblSchedule.schActualEnd.HrefValue = ""
  995.  
  996.                 ' schDateCreated
  997.                 tblSchedule.schDateCreated.HrefValue = ""
  998.  
  999.                 ' schDoubleBooked
  1000.                 tblSchedule.schDoubleBooked.HrefValue = ""
  1001.  
  1002.                 ' schStatus
  1003.                 tblSchedule.schStatus.HrefValue = ""
  1004.  
  1005.                 '
  1006.                 '  Edit Row
  1007.                 '
  1008.  
  1009.             ElseIf tblSchedule.RowType = EW_ROWTYPE_EDIT Then ' Edit row
  1010.  
  1011.                 ' schDate
  1012.                 tblSchedule.schDate.EditCustomAttributes = ""
  1013.                 tblSchedule.schDate.EditValue = ew_FormatDateTime(tblSchedule.schDate.CurrentValue, 6)
  1014.  
  1015.                 ' schEvtID
  1016.                 tblSchedule.schEvtID.EditCustomAttributes = ""
  1017.                 sSqlWrk = "SELECT [evtID], [evtDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblEvents]"
  1018.                 sWhereWrk = ""
  1019.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1020.                 sSqlWrk = sSqlWrk & " ORDER BY [evtDescription] "
  1021.                 arwrk = Conn.GetRows(sSqlWrk)
  1022.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  1023.                 tblSchedule.schEvtID.EditValue = arwrk
  1024.  
  1025.                 ' schPartsID
  1026.                 tblSchedule.schPartsID.EditCustomAttributes = ""
  1027.                 sSqlWrk = "SELECT [prtID], [prtDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblParts]"
  1028.                 sWhereWrk = ""
  1029.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1030.                 sSqlWrk = sSqlWrk & " ORDER BY [prtDescription] "
  1031.                 arwrk = Conn.GetRows(sSqlWrk)
  1032.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  1033.                 tblSchedule.schPartsID.EditValue = arwrk
  1034.  
  1035.                 ' schCallTime
  1036.                 tblSchedule.schCallTime.EditCustomAttributes = ""
  1037.                 tblSchedule.schCallTime.EditValue = ew_FormatDateTime(tblSchedule.schCallTime.CurrentValue, 14)
  1038.  
  1039.                 ' schStartTime
  1040.                 tblSchedule.schStartTime.EditCustomAttributes = ""
  1041.                 tblSchedule.schStartTime.EditValue = ew_FormatDateTime(tblSchedule.schStartTime.CurrentValue, 14)
  1042.  
  1043.                 ' schEndTime
  1044.                 tblSchedule.schEndTime.EditCustomAttributes = ""
  1045.                 tblSchedule.schEndTime.EditValue = ew_FormatDateTime(tblSchedule.schEndTime.CurrentValue, 14)
  1046.  
  1047.                 ' schOutTime
  1048.                 tblSchedule.schOutTime.EditCustomAttributes = ""
  1049.                 tblSchedule.schOutTime.EditValue = ew_FormatDateTime(tblSchedule.schOutTime.CurrentValue, 14)
  1050.  
  1051.                 ' schLocID
  1052.                 tblSchedule.schLocID.EditCustomAttributes = ""
  1053.                 sSqlWrk = "SELECT [locID], [locDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblLocations]"
  1054.                 sWhereWrk = ""
  1055.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1056.                 sSqlWrk = sSqlWrk & " ORDER BY [locDescription] "
  1057.                 arwrk = Conn.GetRows(sSqlWrk)
  1058.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  1059.                 tblSchedule.schLocID.EditValue = arwrk
  1060.  
  1061.                 ' schEmpID
  1062.                 tblSchedule.schEmpID.EditCustomAttributes = ""
  1063.                 If Not Security.IsAdmin And Security.IsLoggedIn() Then ' Non system admin
  1064.                     tblSchedule.schEmpID.CurrentValue = Security.CurrentUserID
  1065.                     If ew_NotEmpty(tblSchedule.schEmpID.CurrentValue) Then
  1066.                         sSqlWrk = "SELECT [empName] FROM [tblEmployees] WHERE [empID] = " & ew_AdjustSql(tblSchedule.schEmpID.CurrentValue) & ""
  1067.                         sSqlWrk = sSqlWrk & " ORDER BY [empFirstName] "
  1068.                         RsWrk = Conn.GetTempDataReader(sSqlWrk)
  1069.                         If RsWrk.Read() Then
  1070.                             tblSchedule.schEmpID.EditValue = RsWrk("empName")
  1071.                         Else
  1072.                             tblSchedule.schEmpID.EditValue = tblSchedule.schEmpID.CurrentValue
  1073.                         End If
  1074.                         Conn.CloseTempDataReader()
  1075.                     Else
  1076.                         tblSchedule.schEmpID.EditValue = System.DBNull.Value
  1077.                     End If
  1078.                     tblSchedule.schEmpID.CssStyle = ""
  1079.                     tblSchedule.schEmpID.CssClass = ""
  1080.                     tblSchedule.schEmpID.ViewCustomAttributes = ""
  1081.                 Else
  1082.                     sSqlWrk = "SELECT [empID], [empName], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblEmployees]"
  1083.                     sWhereWrk = ""
  1084.                     sWhereWrk = tblEmployees.AddUserIDFilter(sWhereWrk)
  1085.                     If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1086.                     sSqlWrk = sSqlWrk & " ORDER BY [empFirstName] "
  1087.                     arwrk = Conn.GetRows(sSqlWrk)
  1088.                     arwrk.Insert(0, New Object() {"", "Please Select"})
  1089.                     tblSchedule.schEmpID.EditValue = arwrk
  1090.                 End If
  1091.  
  1092.                 ' schPosID
  1093.                 tblSchedule.schPosID.EditCustomAttributes = ""
  1094.                 sSqlWrk = "SELECT [posID], [posDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblPositions]"
  1095.                 sWhereWrk = ""
  1096.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1097.                 sSqlWrk = sSqlWrk & " ORDER BY [posDescription] "
  1098.                 arwrk = Conn.GetRows(sSqlWrk)
  1099.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  1100.                 tblSchedule.schPosID.EditValue = arwrk
  1101.  
  1102.                 ' schTypID
  1103.                 tblSchedule.schTypID.EditCustomAttributes = ""
  1104.                 sSqlWrk = "SELECT [typID], [typDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblTypes]"
  1105.                 sWhereWrk = ""
  1106.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1107.                 sSqlWrk = sSqlWrk & " ORDER BY [typDescription] "
  1108.                 arwrk = Conn.GetRows(sSqlWrk)
  1109.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  1110.                 tblSchedule.schTypID.EditValue = arwrk
  1111.  
  1112.                 ' schDepID
  1113.                 tblSchedule.schDepID.EditCustomAttributes = ""
  1114.                 sSqlWrk = "SELECT [depID], [depDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblDepartments]"
  1115.                 sWhereWrk = ""
  1116.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1117.                 sSqlWrk = sSqlWrk & " ORDER BY [depDescription] "
  1118.                 arwrk = Conn.GetRows(sSqlWrk)
  1119.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  1120.                 tblSchedule.schDepID.EditValue = arwrk
  1121.  
  1122.                 ' schNotes
  1123.                 tblSchedule.schNotes.EditCustomAttributes = ""
  1124.                 tblSchedule.schNotes.EditValue = ew_HtmlEncode(tblSchedule.schNotes.CurrentValue)
  1125.  
  1126.                 ' schRate
  1127.                 tblSchedule.schRate.EditCustomAttributes = ""
  1128.                 tblSchedule.schRate.EditValue = ew_HtmlEncode(tblSchedule.schRate.CurrentValue)
  1129.  
  1130.                 ' schActualStart
  1131.                 tblSchedule.schActualStart.EditCustomAttributes = ""
  1132.                 tblSchedule.schActualStart.EditValue = ew_FormatDateTime(tblSchedule.schActualStart.CurrentValue, 14)
  1133.  
  1134.                 ' schActualEnd
  1135.                 tblSchedule.schActualEnd.EditCustomAttributes = ""
  1136.                 tblSchedule.schActualEnd.EditValue = ew_FormatDateTime(tblSchedule.schActualEnd.CurrentValue, 14)
  1137.  
  1138.                 ' schDateCreated
  1139.                 ' schDoubleBooked
  1140.  
  1141.                 tblSchedule.schDoubleBooked.EditCustomAttributes = ""
  1142.  
  1143.                 ' schStatus
  1144.                 tblSchedule.schStatus.EditCustomAttributes = ""
  1145.                 sSqlWrk = "SELECT [stID], [stDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblScheduleStatus]"
  1146.                 sWhereWrk = ""
  1147.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1148.                 sSqlWrk = sSqlWrk & " ORDER BY [stDescription] "
  1149.                 arwrk = Conn.GetRows(sSqlWrk)
  1150.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  1151.                 tblSchedule.schStatus.EditValue = arwrk
  1152.  
  1153.                 ' Edit refer script
  1154.                 ' schDate
  1155.  
  1156.                 tblSchedule.schDate.HrefValue = ""
  1157.  
  1158.                 ' schEvtID
  1159.                 tblSchedule.schEvtID.HrefValue = ""
  1160.  
  1161.                 ' schPartsID
  1162.                 tblSchedule.schPartsID.HrefValue = ""
  1163.  
  1164.                 ' schCallTime
  1165.                 tblSchedule.schCallTime.HrefValue = ""
  1166.  
  1167.                 ' schStartTime
  1168.                 tblSchedule.schStartTime.HrefValue = ""
  1169.  
  1170.                 ' schEndTime
  1171.                 tblSchedule.schEndTime.HrefValue = ""
  1172.  
  1173.                 ' schOutTime
  1174.                 tblSchedule.schOutTime.HrefValue = ""
  1175.  
  1176.                 ' schLocID
  1177.                 tblSchedule.schLocID.HrefValue = ""
  1178.  
  1179.                 ' schEmpID
  1180.                 tblSchedule.schEmpID.HrefValue = ""
  1181.  
  1182.                 ' schPosID
  1183.                 tblSchedule.schPosID.HrefValue = ""
  1184.  
  1185.                 ' schTypID
  1186.                 tblSchedule.schTypID.HrefValue = ""
  1187.  
  1188.                 ' schDepID
  1189.                 tblSchedule.schDepID.HrefValue = ""
  1190.  
  1191.                 ' schNotes
  1192.                 tblSchedule.schNotes.HrefValue = ""
  1193.  
  1194.                 ' schRate
  1195.                 tblSchedule.schRate.HrefValue = ""
  1196.  
  1197.                 ' schActualStart
  1198.                 tblSchedule.schActualStart.HrefValue = ""
  1199.  
  1200.                 ' schActualEnd
  1201.                 tblSchedule.schActualEnd.HrefValue = ""
  1202.  
  1203.                 ' schDateCreated
  1204.                 tblSchedule.schDateCreated.HrefValue = ""
  1205.  
  1206.                 ' schDoubleBooked
  1207.                 tblSchedule.schDoubleBooked.HrefValue = ""
  1208.  
  1209.                 ' schStatus
  1210.                 tblSchedule.schStatus.HrefValue = ""
  1211.             End If
  1212.  
  1213.             ' Row Rendered event
  1214.             tblSchedule.Row_Rendered()
  1215.         End Sub
  1216.  
  1217.         '
  1218.         ' Validate form
  1219.         '
  1220.         Function ValidateForm() As Boolean
  1221.  
  1222.             ' Initialize
  1223.             ParentPage.gsFormError = ""
  1224.             Dim lUpdateCnt As Integer = 0
  1225.             If tblSchedule.schDate.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1226.             If tblSchedule.schEvtID.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1227.             If tblSchedule.schPartsID.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1228.             If tblSchedule.schCallTime.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1229.             If tblSchedule.schStartTime.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1230.             If tblSchedule.schEndTime.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1231.             If tblSchedule.schOutTime.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1232.             If tblSchedule.schLocID.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1233.             If tblSchedule.schEmpID.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1234.             If tblSchedule.schPosID.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1235.             If tblSchedule.schTypID.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1236.             If tblSchedule.schDepID.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1237.             If tblSchedule.schNotes.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1238.             If tblSchedule.schRate.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1239.             If tblSchedule.schActualStart.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1240.             If tblSchedule.schActualEnd.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1241.             If tblSchedule.schDateCreated.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1242.             If tblSchedule.schDoubleBooked.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1243.             If tblSchedule.schStatus.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
  1244.             If lUpdateCnt = 0 Then
  1245.                 ParentPage.gsFormError = "No field selected for update"
  1246.                 Return False
  1247.             End If
  1248.  
  1249.             ' Check if validation required
  1250.             If Not EW_SERVER_VALIDATE Then Return (ParentPage.gsFormError = "")
  1251.             If tblSchedule.schDate.MultiUpdate <> "" Then
  1252.                 If ew_Empty(tblSchedule.schDate.FormValue) Then
  1253.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1254.                     ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Date"
  1255.                 End If
  1256.             End If
  1257.             If tblSchedule.schDate.MultiUpdate <> "" Then
  1258.                 If Not ew_CheckUSDate(tblSchedule.schDate.FormValue) Then
  1259.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1260.                     ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect date, format = mm/dd/yyyy - Date"
  1261.                 End If
  1262.             End If
  1263.             If tblSchedule.schEvtID.MultiUpdate <> "" Then
  1264.                 If ew_Empty(tblSchedule.schEvtID.FormValue) Then
  1265.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1266.                     ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Event"
  1267.                 End If
  1268.             End If
  1269.             If tblSchedule.schPartsID.MultiUpdate <> "" Then
  1270.                 If ew_Empty(tblSchedule.schPartsID.FormValue) Then
  1271.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1272.                     ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Part"
  1273.                 End If
  1274.             End If
  1275.             If tblSchedule.schCallTime.MultiUpdate <> "" Then
  1276.                 If Not ew_CheckUSDate(tblSchedule.schCallTime.FormValue) Then
  1277.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1278.                     ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect date, format = mm/dd/yyyy - Call Time"
  1279.                 End If
  1280.             End If
  1281.             If tblSchedule.schStartTime.MultiUpdate <> "" Then
  1282.                 If Not ew_CheckUSDate(tblSchedule.schStartTime.FormValue) Then
  1283.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1284.                     ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect date, format = mm/dd/yyyy - Start Time"
  1285.                 End If
  1286.             End If
  1287.             If tblSchedule.schEndTime.MultiUpdate <> "" Then
  1288.                 If Not ew_CheckUSDate(tblSchedule.schEndTime.FormValue) Then
  1289.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1290.                     ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect date, format = mm/dd/yyyy - End Time"
  1291.                 End If
  1292.             End If
  1293.             If tblSchedule.schOutTime.MultiUpdate <> "" Then
  1294.                 If Not ew_CheckUSDate(tblSchedule.schOutTime.FormValue) Then
  1295.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1296.                     ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect date, format = mm/dd/yyyy - Out Time"
  1297.                 End If
  1298.             End If
  1299.             If tblSchedule.schLocID.MultiUpdate <> "" Then
  1300.                 If ew_Empty(tblSchedule.schLocID.FormValue) Then
  1301.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1302.                     ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Location"
  1303.                 End If
  1304.             End If
  1305.             If tblSchedule.schEmpID.MultiUpdate <> "" Then
  1306.                 If ew_Empty(tblSchedule.schEmpID.FormValue) Then
  1307.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1308.                     ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Employee"
  1309.                 End If
  1310.             End If
  1311.             If tblSchedule.schPosID.MultiUpdate <> "" Then
  1312.                 If ew_Empty(tblSchedule.schPosID.FormValue) Then
  1313.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1314.                     ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Position"
  1315.                 End If
  1316.             End If
  1317.             If tblSchedule.schTypID.MultiUpdate <> "" Then
  1318.                 If ew_Empty(tblSchedule.schTypID.FormValue) Then
  1319.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1320.                     ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Type"
  1321.                 End If
  1322.             End If
  1323.             If tblSchedule.schDepID.MultiUpdate <> "" Then
  1324.                 If ew_Empty(tblSchedule.schDepID.FormValue) Then
  1325.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1326.                     ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Department"
  1327.                 End If
  1328.             End If
  1329.             If tblSchedule.schRate.MultiUpdate <> "" Then
  1330.                 If Not ew_CheckNumber(tblSchedule.schRate.FormValue) Then
  1331.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1332.                     ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect floating point number - Rate"
  1333.                 End If
  1334.             End If
  1335.             If tblSchedule.schActualStart.MultiUpdate <> "" Then
  1336.                 If Not ew_CheckUSDate(tblSchedule.schActualStart.FormValue) Then
  1337.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1338.                     ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect date, format = mm/dd/yyyy - Actual Start"
  1339.                 End If
  1340.             End If
  1341.             If tblSchedule.schActualEnd.MultiUpdate <> "" Then
  1342.                 If Not ew_CheckUSDate(tblSchedule.schActualEnd.FormValue) Then
  1343.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1344.                     ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect date, format = mm/dd/yyyy - Actual End"
  1345.                 End If
  1346.             End If
  1347.             If tblSchedule.schStatus.MultiUpdate <> "" Then
  1348.                 If ew_Empty(tblSchedule.schStatus.FormValue) Then
  1349.                     If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1350.                     ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Status"
  1351.                 End If
  1352.             End If
  1353.  
  1354.             ' Return validate result
  1355.             Dim Valid As Boolean = (ParentPage.gsFormError = "")
  1356.  
  1357.             ' Form_CustomValidate event
  1358.             Dim sFormCustomError As String = ""
  1359.             Valid = Valid And Form_CustomValidate(sFormCustomError)
  1360.             If sFormCustomError <> "" Then
  1361.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1362.                 ParentPage.gsFormError = ParentPage.gsFormError & sFormCustomError
  1363.             End If
  1364.             Return Valid
  1365.         End Function
  1366.  
  1367.         '
  1368.         ' Update record based on key values
  1369.         '
  1370.         Function EditRow() As Boolean
  1371.             Dim RsEdit As OleDbDataReader, RsChk As OleDbDataReader
  1372.             Dim sSql As String, sFilter As String
  1373.             Dim sSqlChk As String, sFilterChk As String
  1374.             Dim bUpdateRow As Boolean
  1375.             Dim RsOld As OrderedDictionary
  1376.             Dim sIdxErrMsg As String
  1377.             Dim Rs As New OrderedDictionary
  1378.             sFilter = tblSchedule.KeyFilter
  1379.             tblSchedule.CurrentFilter = sFilter
  1380.             sSql = tblSchedule.SQL
  1381.             Try
  1382.                 RsEdit = Conn.GetDataReader(sSql)
  1383.             Catch e As Exception
  1384.                 If EW_DEBUG_ENABLED Then Throw
  1385.                 Message = e.Message
  1386.                 RsEdit.Close()
  1387.                 EditRow = False
  1388.             End Try
  1389.             If Not RsEdit.Read() Then
  1390.                 RsEdit.Close()
  1391.                 EditRow = False ' Update Failed
  1392.             Else
  1393.                 RsOld = Conn.GetRow(RsEdit)
  1394.                 RsEdit.Close()
  1395.  
  1396.                 ' schDate
  1397.                 If tblSchedule.schDate.MultiUpdate = "1" Then
  1398.                     tblSchedule.schDate.SetDbValue(ew_UnFormatDateTime(tblSchedule.schDate.CurrentValue, 6), System.DBNull.Value)
  1399.                     Rs("schDate") = tblSchedule.schDate.DbValue
  1400.                 End If
  1401.  
  1402.                 ' schEvtID
  1403.                 If tblSchedule.schEvtID.MultiUpdate = "1" Then
  1404.                     tblSchedule.schEvtID.SetDbValue(tblSchedule.schEvtID.CurrentValue, System.DBNull.Value)
  1405.                     Rs("schEvtID") = tblSchedule.schEvtID.DbValue
  1406.                 End If
  1407.  
  1408.                 ' schPartsID
  1409.                 If tblSchedule.schPartsID.MultiUpdate = "1" Then
  1410.                     tblSchedule.schPartsID.SetDbValue(tblSchedule.schPartsID.CurrentValue, System.DBNull.Value)
  1411.                     Rs("schPartsID") = tblSchedule.schPartsID.DbValue
  1412.                 End If
  1413.  
  1414.                 ' schCallTime
  1415.                 If tblSchedule.schCallTime.MultiUpdate = "1" Then
  1416.                     tblSchedule.schCallTime.SetDbValue(ew_UnFormatDateTime(tblSchedule.schCallTime.CurrentValue, 3), System.DBNull.Value)
  1417.                     Rs("schCallTime") = tblSchedule.schCallTime.DbValue
  1418.                 End If
  1419.  
  1420.                 ' schStartTime
  1421.                 If tblSchedule.schStartTime.MultiUpdate = "1" Then
  1422.                     tblSchedule.schStartTime.SetDbValue(ew_UnFormatDateTime(tblSchedule.schStartTime.CurrentValue, 3), System.DBNull.Value)
  1423.                     Rs("schStartTime") = tblSchedule.schStartTime.DbValue
  1424.                 End If
  1425.  
  1426.                 ' schEndTime
  1427.                 If tblSchedule.schEndTime.MultiUpdate = "1" Then
  1428.                     tblSchedule.schEndTime.SetDbValue(ew_UnFormatDateTime(tblSchedule.schEndTime.CurrentValue, 3), System.DBNull.Value)
  1429.                     Rs("schEndTime") = tblSchedule.schEndTime.DbValue
  1430.                 End If
  1431.  
  1432.                 ' schOutTime
  1433.                 If tblSchedule.schOutTime.MultiUpdate = "1" Then
  1434.                     tblSchedule.schOutTime.SetDbValue(ew_UnFormatDateTime(tblSchedule.schOutTime.CurrentValue, 3), System.DBNull.Value)
  1435.                     Rs("schOutTime") = tblSchedule.schOutTime.DbValue
  1436.                 End If
  1437.  
  1438.                 ' schLocID
  1439.                 If tblSchedule.schLocID.MultiUpdate = "1" Then
  1440.                     tblSchedule.schLocID.SetDbValue(tblSchedule.schLocID.CurrentValue, System.DBNull.Value)
  1441.                     Rs("schLocID") = tblSchedule.schLocID.DbValue
  1442.                 End If
  1443.  
  1444.                 ' schEmpID
  1445.                 If tblSchedule.schEmpID.MultiUpdate = "1" Then
  1446.                     tblSchedule.schEmpID.SetDbValue(tblSchedule.schEmpID.CurrentValue, System.DBNull.Value)
  1447.                     Rs("schEmpID") = tblSchedule.schEmpID.DbValue
  1448.                 End If
  1449.  
  1450.                 ' schPosID
  1451.                 If tblSchedule.schPosID.MultiUpdate = "1" Then
  1452.                     tblSchedule.schPosID.SetDbValue(tblSchedule.schPosID.CurrentValue, System.DBNull.Value)
  1453.                     Rs("schPosID") = tblSchedule.schPosID.DbValue
  1454.                 End If
  1455.  
  1456.                 ' schTypID
  1457.                 If tblSchedule.schTypID.MultiUpdate = "1" Then
  1458.                     tblSchedule.schTypID.SetDbValue(tblSchedule.schTypID.CurrentValue, System.DBNull.Value)
  1459.                     Rs("schTypID") = tblSchedule.schTypID.DbValue
  1460.                 End If
  1461.  
  1462.                 ' schDepID
  1463.                 If tblSchedule.schDepID.MultiUpdate = "1" Then
  1464.                     tblSchedule.schDepID.SetDbValue(tblSchedule.schDepID.CurrentValue, System.DBNull.Value)
  1465.                     Rs("schDepID") = tblSchedule.schDepID.DbValue
  1466.                 End If
  1467.  
  1468.                 ' schNotes
  1469.                 If tblSchedule.schNotes.MultiUpdate = "1" Then
  1470.                     tblSchedule.schNotes.SetDbValue(tblSchedule.schNotes.CurrentValue, System.DBNull.Value)
  1471.                     Rs("schNotes") = tblSchedule.schNotes.DbValue
  1472.                 End If
  1473.  
  1474.                 ' schRate
  1475.                 If tblSchedule.schRate.MultiUpdate = "1" Then
  1476.                     tblSchedule.schRate.SetDbValue(tblSchedule.schRate.CurrentValue, System.DBNull.Value)
  1477.                     Rs("schRate") = tblSchedule.schRate.DbValue
  1478.                 End If
  1479.  
  1480.                 ' schActualStart
  1481.                 If tblSchedule.schActualStart.MultiUpdate = "1" Then
  1482.                     tblSchedule.schActualStart.SetDbValue(ew_UnFormatDateTime(tblSchedule.schActualStart.CurrentValue, 3), System.DBNull.Value)
  1483.                     Rs("schActualStart") = tblSchedule.schActualStart.DbValue
  1484.                 End If
  1485.  
  1486.                 ' schActualEnd
  1487.                 If tblSchedule.schActualEnd.MultiUpdate = "1" Then
  1488.                     tblSchedule.schActualEnd.SetDbValue(ew_UnFormatDateTime(tblSchedule.schActualEnd.CurrentValue, 3), System.DBNull.Value)
  1489.                     Rs("schActualEnd") = tblSchedule.schActualEnd.DbValue
  1490.                 End If
  1491.  
  1492.                 ' schDateCreated
  1493.                 If tblSchedule.schDateCreated.MultiUpdate = "1" Then
  1494.                     tblSchedule.schDateCreated.DbValue = ew_CurrentDate()
  1495.                     Rs("schDateCreated") = tblSchedule.schDateCreated.DbValue
  1496.                 End If
  1497.  
  1498.                 ' schDoubleBooked
  1499.                 If tblSchedule.schDoubleBooked.MultiUpdate = "1" Then
  1500.                     tblSchedule.schDoubleBooked.SetDbValue((tblSchedule.schDoubleBooked.CurrentValue <> "" And Not IsDBNull(tblSchedule.schDoubleBooked.CurrentValue)), System.DBNull.Value)
  1501.                     Rs("schDoubleBooked") = tblSchedule.schDoubleBooked.DbValue
  1502.                 End If
  1503.  
  1504.                 ' schStatus
  1505.                 If tblSchedule.schStatus.MultiUpdate = "1" Then
  1506.                     tblSchedule.schStatus.SetDbValue(tblSchedule.schStatus.CurrentValue, System.DBNull.Value)
  1507.                     Rs("schStatus") = tblSchedule.schStatus.DbValue
  1508.                 End If
  1509.  
  1510.                 ' Row Updating event
  1511.                 bUpdateRow = tblSchedule.Row_Updating(RsOld, Rs)
  1512.                 If bUpdateRow Then
  1513.                     Try
  1514.                         tblSchedule.Update(Rs)
  1515.                         EditRow = True
  1516.                     Catch e As Exception
  1517.                         If EW_DEBUG_ENABLED Then Throw
  1518.                         Message = e.Message
  1519.                         EditRow = False
  1520.                     End Try
  1521.                 Else
  1522.                     If tblSchedule.CancelMessage <> "" Then
  1523.                         Message = tblSchedule.CancelMessage
  1524.                         tblSchedule.CancelMessage = ""
  1525.                     Else
  1526.                         Message = "Update cancelled"
  1527.                     End If
  1528.                     EditRow = False
  1529.                 End If
  1530.             End If
  1531.  
  1532.             ' Row Updated event
  1533.             If EditRow Then
  1534.                 tblSchedule.Row_Updated(RsOld, Rs)
  1535.             End If
  1536.         End Function
  1537.  
  1538.         '
  1539.         ' Delete record based on key values
  1540.         '
  1541.         Function DeleteRow() As Boolean
  1542.             Dim RsEdit As OleDbDataReader, RsChk As OleDbDataReader
  1543.             Dim sSql As String, sFilter As String
  1544.             Dim sSqlChk As String, sFilterChk As String
  1545.             Dim bDeleteRow As Boolean
  1546.             Dim RsOld As OrderedDictionary
  1547.             Dim sIdxErrMsg As String
  1548.             Dim Rs As New OrderedDictionary
  1549.             sFilter = tblSchedule.KeyFilter
  1550.             tblSchedule.CurrentFilter = sFilter
  1551.             sSql = tblSchedule.SQL
  1552.             Try
  1553.                 RsEdit = Conn.GetDataReader(sSql)
  1554.             Catch e As Exception
  1555.                 If EW_DEBUG_ENABLED Then Throw
  1556.                 Message = e.Message
  1557.                 RsEdit.Close()
  1558.                 DeleteRow = False
  1559.             End Try
  1560.             If Not RsEdit.Read() Then
  1561.                 RsEdit.Close()
  1562.                 DeleteRow = False ' Delete Failed
  1563.             Else
  1564.                 RsOld = Conn.GetRow(RsEdit)
  1565.                 RsEdit.Close()
  1566.  
  1567.                 If bDeleteRow Then
  1568.                     Try
  1569.                         tblSchedule.Delete(Rs)
  1570.                         DeleteRow = True
  1571.                     Catch e As Exception
  1572.                         If EW_DEBUG_ENABLED Then Throw
  1573.                         Message = e.Message
  1574.                         DeleteRow = False
  1575.                     End Try
  1576.                 Else
  1577.                     If tblSchedule.CancelMessage <> "" Then
  1578.                         Message = tblSchedule.CancelMessage
  1579.                         tblSchedule.CancelMessage = ""
  1580.                     Else
  1581.                         Message = "Delete cancelled"
  1582.                     End If
  1583.                     DeleteRow = False
  1584.                 End If
  1585.             End If
  1586.  
  1587.         End Function
  1588.  
  1589.  
  1590.  
  1591.         ' Page Load event
  1592.         Public Sub Page_Load()
  1593.  
  1594.             'HttpContext.Current.Response.Write("Page Load")
  1595.         End Sub
  1596.  
  1597.         ' Page Unload event
  1598.         Public Sub Page_Unload()
  1599.  
  1600.             'HttpContext.Current.Response.Write("Page Unload")
  1601.         End Sub
  1602.  
  1603.         ' Form Custom Validate event
  1604.         Public Function Form_CustomValidate(ByRef CustomError As String) As Boolean
  1605.  
  1606.             'Return error message in CustomError
  1607.             Return True
  1608.         End Function
  1609.     End Class
  1610.  
  1611.     '
  1612.     ' ASP.NET Page_Load event
  1613.     '
  1614.  
  1615.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  1616.         Response.Buffer = EW_RESPONSE_BUFFER
  1617.         Response.Cache.SetCacheability(HttpCacheability.NoCache)
  1618.  
  1619.         ' Page init
  1620.         tblSchedule_update = New ctblSchedule_update(Me)
  1621.         tblSchedule_update.Page_Init()
  1622.  
  1623.         ' Page main processing
  1624.         tblSchedule_update.Page_Main()
  1625.     End Sub
  1626.  
  1627.     '
  1628.     ' ASP.NET Page_Unload event
  1629.     '
  1630.  
  1631.     Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
  1632.  
  1633.         ' Dispose page object
  1634.         If tblSchedule_update IsNot Nothing Then tblSchedule_update.Dispose()
  1635.     End Sub
  1636. End Class
  1637.