home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / viewClockInOutadd.aspx.vb < prev    next >
Text File  |  2014-11-01  |  51KB  |  1,180 lines

  1. Imports System.Data
  2. Imports System.Data.Common
  3. Imports System.Xml
  4. Imports System.IO
  5. Imports System.Data.OleDb
  6. Imports Microsoft.Exchange.WebServices.Data
  7. Imports Microsoft.Exchange.WebServices.Autodiscover
  8. Imports System.Net
  9. Imports System.Net.Security
  10. Imports System.Security.Cryptography.X509Certificates
  11. '
  12. ' ASP.NET code-behind class (Page)
  13. '
  14.  
  15. Partial Class viewClockInOutadd
  16.     Inherits AspNetMaker7_tfpssnet
  17.  
  18.     ' Page object
  19.     Public viewClockInOut_add As cviewClockInOut_add
  20.  
  21.     '
  22.     ' Page Class
  23.     '
  24.     Class cviewClockInOut_add
  25.         Inherits AspNetMakerPage
  26.         Implements IDisposable        
  27.  
  28.         ' Used by system generated functions
  29.         Private RsWrk As Object, sSqlWrk As String, sWhereWrk As String
  30.  
  31.         Private arwrk As Object
  32.  
  33.         Private armultiwrk() As String        
  34.  
  35.         ' Page URL
  36.         Public ReadOnly Property PageUrl() As String
  37.             Get
  38.                 Dim Url As String = ew_CurrentPage() & "?"
  39.                 If viewClockInOut.UseTokenInUrl Then Url = Url & "t=" & viewClockInOut.TableVar & "&" ' Add page token
  40.                 Return Url    
  41.             End Get
  42.         End Property
  43.  
  44.         ' Validate page request
  45.         Public Function IsPageRequest() As Boolean
  46.             Dim Result As Boolean
  47.             If viewClockInOut.UseTokenInUrl Then
  48.                 Result = False
  49.                 If ObjForm IsNot Nothing Then
  50.                     Result = (viewClockInOut.TableVar = ObjForm.GetValue("t"))
  51.                 End If
  52.                 If ew_Get("t") <> "" Then
  53.                     Result = (viewClockInOut.TableVar = ew_Get("t"))
  54.                 End If
  55.                 Return Result
  56.             End If
  57.             Return True            
  58.         End Function    
  59.  
  60.         ' viewClockInOut
  61.         Public Property viewClockInOut() As cviewClockInOut
  62.             Get                
  63.                 Return ParentPage.viewClockInOut
  64.             End Get
  65.             Set(ByVal v As cviewClockInOut)
  66.                 ParentPage.viewClockInOut = v    
  67.             End Set    
  68.         End Property
  69.  
  70.         ' viewClockInOut
  71.         Public Property tblEmployees() As ctblEmployees
  72.             Get                
  73.                 Return ParentPage.tblEmployees
  74.             End Get
  75.             Set(ByVal v As ctblEmployees)
  76.                 ParentPage.tblEmployees = v    
  77.             End Set    
  78.         End Property
  79.  
  80.         '
  81.         '  Constructor
  82.         '  - init objects
  83.         '  - open connection
  84.         '
  85.         Public Sub New(ByRef APage As AspNetMaker7_tfpssnet)                
  86.             m_ParentPage = APage
  87.             m_Page = Me    
  88.             m_PageID = "add"
  89.             m_PageObjName = "viewClockInOut_add"
  90.             m_PageObjTypeName = "cviewClockInOut_add"
  91.  
  92.             ' Table Name
  93.             m_TableName = "viewClockInOut"
  94.  
  95.             ' Initialize table object
  96.             viewClockInOut = New cviewClockInOut(Me)
  97.             tblEmployees = New ctblEmployees(Me)
  98.  
  99.             ' Connect to database
  100.             Conn = New cConnection()
  101.         End Sub
  102.  
  103.         '
  104.         '  Subroutine Page_Init
  105.         '  - called before page main
  106.         '  - check Security
  107.         '  - set up response header
  108.         '  - call page load events
  109.         '
  110.         Public Sub Page_Init()
  111.             Security = New cAdvancedSecurity(Me)
  112.             If Not Security.IsLoggedIn() Then Security.AutoLogin()
  113.             If Not Security.IsLoggedIn() Then
  114.                 Security.SaveLastUrl()
  115.                 Page_Terminate("login.aspx")
  116.             End If
  117.  
  118.             ' Table Permission loading event
  119.             Security.TablePermission_Loading()
  120.             Security.LoadCurrentUserLevel(TableName)
  121.  
  122.             ' Table Permission loaded event
  123.             Security.TablePermission_Loaded()
  124.             If Not Security.CanAdd Then
  125.                 Security.SaveLastUrl()
  126.                 Page_Terminate("viewClockInOutlist.aspx")
  127.             End If
  128.  
  129.             ' User ID loading event
  130.             Security.UserID_Loading()
  131.             If Security.IsLoggedIn() Then Call Security.LoadUserID()
  132.  
  133.             ' User ID loaded event
  134.             Security.UserID_Loaded()
  135.             If Security.IsLoggedIn() And ew_Empty(Security.CurrentUserID) Then
  136.                 Message = "You do not have the right permission to view the page"
  137.                 Page_Terminate("viewClockInOutlist.aspx")
  138.             End If
  139.  
  140.             ' Global page loading event (in ewglobal*.vb)
  141.             ParentPage.Page_Loading()
  142.  
  143.             ' Page load event, used in current page
  144.             Page_Load()
  145.         End Sub
  146.  
  147.         '
  148.         '  Class terminate
  149.         '  - clean up page object
  150.         '
  151.         Public Sub Dispose() Implements IDisposable.Dispose
  152.             Page_Terminate("")
  153.         End Sub
  154.  
  155.         '
  156.         '  Sub Page_Terminate
  157.         '  - called when exit page
  158.         '  - clean up connection and objects
  159.         '  - if URL specified, redirect to URL
  160.         '
  161.         Sub Page_Terminate(url As String)
  162.  
  163.             ' Page unload event, used in current page
  164.             Page_Unload()
  165.  
  166.             ' Global page unloaded event (in ewglobal*.vb)
  167.             ParentPage.Page_Unloaded()
  168.  
  169.             ' Close connection
  170.             Conn.Dispose()
  171.             Security = Nothing
  172.             viewClockInOut.Dispose()
  173.             tblEmployees.Dispose()
  174.  
  175.             ' Go to URL if specified
  176.             If url <> "" Then
  177.                 HttpContext.Current.Response.Clear()
  178.                 HttpContext.Current.Response.Redirect(url)
  179.             End If
  180.         End Sub
  181.  
  182.     Public x_ewPriv As Integer
  183.  
  184.     '
  185.     ' Page main processing
  186.     '
  187.     Sub Page_Main()
  188.  
  189.         ' Load key values from QueryString
  190.         Dim bCopy As Boolean = True
  191.         If ew_Get("schSchID") <> "" Then
  192.             viewClockInOut.schSchID.QueryStringValue = ew_Get("schSchID")
  193.         Else
  194.             bCopy = False
  195.         End If
  196.  
  197.         ' Create form object
  198.         ObjForm = New cFormObj
  199.  
  200.         ' Process form if post back
  201.         If ObjForm.GetValue("a_add") <> "" Then
  202.             viewClockInOut.CurrentAction = ObjForm.GetValue("a_add") ' Get form action
  203.             LoadFormValues() ' Load form values
  204.  
  205.             ' Validate Form
  206.             If Not ValidateForm() Then
  207.                 viewClockInOut.CurrentAction = "I" ' Form error, reset action
  208.                 Message = ParentPage.gsFormError
  209.             End If
  210.  
  211.         ' Not post back
  212.         Else
  213.             If bCopy Then
  214.                 viewClockInOut.CurrentAction = "C" ' Copy Record
  215.             Else
  216.                 viewClockInOut.CurrentAction = "I" ' Display Blank Record
  217.                 LoadDefaultValues() ' Load default values
  218.             End If
  219.         End If
  220.  
  221.         ' Perform action based on action code
  222.         Select Case viewClockInOut.CurrentAction
  223.             Case "I" ' Blank record, no action required
  224.             Case "C" ' Copy an existing record
  225.                 If Not LoadRow() Then ' Load record based on key
  226.                     Message = "No records found" ' No record found
  227.                     Page_Terminate("viewClockInOutlist.aspx") ' No matching record, return to list
  228.                 End If
  229.             Case "A" ' Add new record
  230.                 viewClockInOut.SendEmail = True ' Send email on add success
  231.                 If AddRow() Then ' Add successful
  232.  
  233.                         'Dim service As New ExchangeService(requestedServerVersion:=ExchangeVersion.Exchange2010)
  234.                         Dim service As New ExchangeService(ExchangeVersion.Exchange2010_SP1)
  235.                         'Add a valid EWS service end point here or user Autodiscover
  236.                         'service.Url = New Uri("https://server14/ews/exchange.asmx")
  237.                         service.Url = New Uri("https://outlook.office365.com/EWS/Exchange.asmx")
  238.  
  239.                         'Add a valid user credentials
  240.                         'service.Credentials = New WebCredentials("prodservices", "production88", "Business")
  241.                         service.Credentials = New WebCredentials("productionservices@tfc.org", "production88")
  242.                         service.AutodiscoverUrl("productionservices@tfc.org", AddressOf RedirectionUrlValaditionCallBack)
  243.  
  244.                         'To address the SSL challenge
  245.                         ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidateCertificate)
  246.  
  247.                         Dim tmpSchDate As Date, tmpEvtDescription As String, tmpPrtDescription As String, tmpCallTime As Date
  248.                         Dim tmpStartTime As Date, tmpEndTime As Date, tmpOutTime As Date, tmpLocDescription As String, tmpPosDescription As String, tmpStDescription As String
  249.                         Dim tmpTypDescription As String, tmpEmpName As String, tmpEmail As String, tmpBody As String, tmpAction As String = "", tmpStatus As String, tmpType As String, tmpNotes As String
  250.                         Dim intResult As Integer, tmpMessage As String, tmpNewStatus As String, smtpStatus As Boolean, smtpMessage As String
  251.                         Dim tlcsub As New AspNetMaker7_tfpssnet
  252.                         intResult = tlcsub.tlcGetEventInfo(viewClockInOut.schSchID.CurrentValue, tmpSchDate, tmpEvtDescription, tmpPrtDescription, tmpCallTime, tmpStartTime, tmpEndTime, tmpOutTime, tmpLocDescription, tmpPosDescription, tmpStDescription, tmpTypDescription, tmpEmpName, tmpEmail, tmpStatus, tmpNotes)
  253.                         If intResult = True Then
  254.                             tmpMessage = " for the following event:<br><br>"
  255.                             tmpMessage = tmpMessage & "<b>Date:</b> " & ew_FormatDateTime(tmpSchDate, 2) & "<br> "
  256.                             tmpMessage = tmpMessage & "<b>Event:</b> " & tmpEvtDescription & "<br> "
  257.                             tmpMessage = tmpMessage & "<b>Part:</b> " & tmpPrtDescription & "<br>"
  258.                             tmpMessage = tmpMessage & "<b>Call Time:</b> " & ew_FormatDateTime(tmpCallTime, 14) & "<br>"
  259.                             tmpMessage = tmpMessage & "<b>Start Time:</b> " & ew_FormatDateTime(tmpStartTime, 14) & "<br>"
  260.                             'tmpMessage = tmpMessage & "<b>End Time:</b> " & ew_FormatDateTime(tmpEndTime, 14) & "<br>"
  261.                             'tmpMessage = tmpMessage & "<b>Out Time:</b> " & ew_FormatDateTime(tmpOutTime, 14) & "<br>"
  262.                             tmpMessage = tmpMessage & "<b>Location:</b> " & tmpLocDescription & "<br>"
  263.                             tmpMessage = tmpMessage & "<b>Position:</b> " & tmpPosDescription & "<br>"
  264.                             tmpMessage = tmpMessage & "<b>Status:</b> " & tmpNewStatus & "<br>"
  265.                             tmpMessage = tmpMessage & "<b>Type:</b> " & tmpTypDescription & "<br>"
  266.                             tmpMessage = tmpMessage & "<b>Notes:</b> " & tmpNotes & "<br><br>"
  267.                             tmpMessage = tmpMessage & "sent from PSS viewClockInOutadd."
  268.                             '                        ew_SendEmail("prodservices@tfchurch.org", "kirkmanton@tfchurch.org", "", "", "PSS Unscheduled Shift Clocked In for " & tmpEmpName, tmpMessage, "html")
  269.                             Try
  270.                                 'Create new message object and set properties required to send a mail
  271.                                 Dim msg As EmailMessage = New EmailMessage(service)
  272.                                 msg.Subject = "PSS Unscheduled Shift Clocked In for " & ew_Session("tfpssnet_Status_UserName")
  273.                                 msg.Body = tmpMessage
  274.                                 'msg.ToRecipients.Add("tony.clayton@suddenlink.net")
  275.                                 'msg.ToRecipients.Add("tonyc@tfchurch.org")
  276.                                 msg.ToRecipients.Add("kirkmanton@tfc.org")
  277.                                 msg.From = "productionservices@tfc.org"
  278.                                 msg.SendAndSaveCopy()
  279.                                 '                                            Message = "Email sent."
  280.                                 Message = "Add succeeded" ' Set up success message
  281.                             Catch ex As Exception
  282.                                 Message = ex.Message
  283.                             End Try
  284.                         End If
  285.                         Dim sReturnUrl As String = viewClockInOut.ReturnUrl
  286.                         Page_Terminate(sReturnUrl) ' Clean up and return
  287.                     Else
  288.                         RestoreFormValues() ' Add failed, restore form values
  289.                     End If
  290.             End Select
  291.  
  292.         ' Render row based on row type
  293.         viewClockInOut.RowType = EW_ROWTYPE_ADD ' Render add type
  294.  
  295.         ' Render row
  296.         RenderRow()
  297.     End Sub
  298.  
  299.         Private Function ValidateCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As SslPolicyErrors) As Boolean
  300.             'Return True to force the certificate to be accepted.
  301.             Return True
  302.         End Function
  303.  
  304.         Private Shared Function RedirectionUrlValaditionCallBack(ByVal redirectionURL As String) As Boolean
  305.             Dim result As Boolean = False
  306.             Dim redirectionuri As New Uri(redirectionURL)
  307.             If redirectionuri.Scheme = "https" Then
  308.                 result = True
  309.             End If
  310.             Return result
  311.         End Function
  312.     '
  313.     ' Get upload file
  314.     '
  315.     Sub GetUploadFiles()
  316.  
  317.         ' Get upload data
  318.     End Sub
  319.  
  320.     '
  321.     ' Load default values
  322.     '
  323.     Sub LoadDefaultValues()
  324.         viewClockInOut.schDate.CurrentValue = ew_CurrentDate()
  325.         viewClockInOut.schEvtID.CurrentValue = 40
  326.         viewClockInOut.schPartsID.CurrentValue = 61
  327.         viewClockInOut.schCallTime.CurrentValue = ew_CurrentTime()
  328.         viewClockInOut.schStartTime.CurrentValue = ew_CurrentTime()
  329.             'viewClockInOut.schTypID.CurrentValue = 10
  330.             viewClockInOut.schTypID.CurrentValue = 2
  331.             viewClockInOut.schActualStart.CurrentValue = ew_CurrentTime()
  332.         viewClockInOut.schDateCreated.CurrentValue = ew_CurrentDate()
  333.         viewClockInOut.schStatus.CurrentValue = 1
  334.     End Sub
  335.  
  336.     '
  337.     ' Load form values
  338.     '
  339.     Sub LoadFormValues()
  340.         viewClockInOut.schDate.FormValue = ObjForm.GetValue("x_schDate")
  341.         viewClockInOut.schDate.CurrentValue = ew_UnFormatDateTime(viewClockInOut.schDate.CurrentValue, 6)
  342.         viewClockInOut.schDate.OldValue = ObjForm.GetValue("o_schDate")
  343.         viewClockInOut.schEvtID.FormValue = ObjForm.GetValue("x_schEvtID")
  344.         viewClockInOut.schEvtID.OldValue = ObjForm.GetValue("o_schEvtID")
  345.         viewClockInOut.schPartsID.FormValue = ObjForm.GetValue("x_schPartsID")
  346.         viewClockInOut.schPartsID.OldValue = ObjForm.GetValue("o_schPartsID")
  347.         viewClockInOut.schCallTime.FormValue = ObjForm.GetValue("x_schCallTime")
  348.         viewClockInOut.schCallTime.CurrentValue = ew_UnFormatDateTime(viewClockInOut.schCallTime.CurrentValue, 4)
  349.         viewClockInOut.schCallTime.OldValue = ObjForm.GetValue("o_schCallTime")
  350.         viewClockInOut.schStartTime.FormValue = ObjForm.GetValue("x_schStartTime")
  351.         viewClockInOut.schStartTime.CurrentValue = ew_UnFormatDateTime(viewClockInOut.schStartTime.CurrentValue, 4)
  352.         viewClockInOut.schStartTime.OldValue = ObjForm.GetValue("o_schStartTime")
  353.         viewClockInOut.schLocID.FormValue = ObjForm.GetValue("x_schLocID")
  354.         viewClockInOut.schLocID.OldValue = ObjForm.GetValue("o_schLocID")
  355.         viewClockInOut.schEmpID.FormValue = ObjForm.GetValue("x_schEmpID")
  356.         viewClockInOut.schEmpID.OldValue = ObjForm.GetValue("o_schEmpID")
  357.         viewClockInOut.schPosID.FormValue = ObjForm.GetValue("x_schPosID")
  358.         viewClockInOut.schPosID.OldValue = ObjForm.GetValue("o_schPosID")
  359.         viewClockInOut.schTypID.FormValue = ObjForm.GetValue("x_schTypID")
  360.         viewClockInOut.schTypID.OldValue = ObjForm.GetValue("o_schTypID")
  361.         viewClockInOut.schNotes.FormValue = ObjForm.GetValue("x_schNotes")
  362.         viewClockInOut.schNotes.OldValue = ObjForm.GetValue("o_schNotes")
  363.         viewClockInOut.schActualStart.FormValue = ObjForm.GetValue("x_schActualStart")
  364.         viewClockInOut.schActualStart.CurrentValue = ew_UnFormatDateTime(viewClockInOut.schActualStart.CurrentValue, 4)
  365.         viewClockInOut.schActualStart.OldValue = ObjForm.GetValue("o_schActualStart")
  366.         viewClockInOut.schDateCreated.FormValue = ObjForm.GetValue("x_schDateCreated")
  367.         viewClockInOut.schDateCreated.CurrentValue = ew_UnFormatDateTime(viewClockInOut.schDateCreated.CurrentValue, 6)
  368.         viewClockInOut.schDateCreated.OldValue = ObjForm.GetValue("o_schDateCreated")
  369.         viewClockInOut.schStatus.FormValue = ObjForm.GetValue("x_schStatus")
  370.         viewClockInOut.schStatus.OldValue = ObjForm.GetValue("o_schStatus")
  371.         viewClockInOut.schSchID.FormValue = ObjForm.GetValue("x_schSchID")
  372.     End Sub
  373.  
  374.     '
  375.     ' Restore form values
  376.     '
  377.     Sub RestoreFormValues()
  378.         viewClockInOut.schDate.CurrentValue = viewClockInOut.schDate.FormValue
  379.         viewClockInOut.schDate.CurrentValue = ew_UnFormatDateTime(viewClockInOut.schDate.CurrentValue, 6)
  380.         viewClockInOut.schEvtID.CurrentValue = viewClockInOut.schEvtID.FormValue
  381.         viewClockInOut.schPartsID.CurrentValue = viewClockInOut.schPartsID.FormValue
  382.         viewClockInOut.schCallTime.CurrentValue = viewClockInOut.schCallTime.FormValue
  383.         viewClockInOut.schCallTime.CurrentValue = ew_UnFormatDateTime(viewClockInOut.schCallTime.CurrentValue, 4)
  384.         viewClockInOut.schStartTime.CurrentValue = viewClockInOut.schStartTime.FormValue
  385.         viewClockInOut.schStartTime.CurrentValue = ew_UnFormatDateTime(viewClockInOut.schStartTime.CurrentValue, 4)
  386.         viewClockInOut.schLocID.CurrentValue = viewClockInOut.schLocID.FormValue
  387.         viewClockInOut.schEmpID.CurrentValue = viewClockInOut.schEmpID.FormValue
  388.         viewClockInOut.schPosID.CurrentValue = viewClockInOut.schPosID.FormValue
  389.         viewClockInOut.schTypID.CurrentValue = viewClockInOut.schTypID.FormValue
  390.         viewClockInOut.schNotes.CurrentValue = viewClockInOut.schNotes.FormValue
  391.         viewClockInOut.schActualStart.CurrentValue = viewClockInOut.schActualStart.FormValue
  392.         viewClockInOut.schActualStart.CurrentValue = ew_UnFormatDateTime(viewClockInOut.schActualStart.CurrentValue, 4)
  393.         viewClockInOut.schDateCreated.CurrentValue = viewClockInOut.schDateCreated.FormValue
  394.         viewClockInOut.schDateCreated.CurrentValue = ew_UnFormatDateTime(viewClockInOut.schDateCreated.CurrentValue, 6)
  395.         viewClockInOut.schStatus.CurrentValue = viewClockInOut.schStatus.FormValue
  396.         viewClockInOut.schSchID.CurrentValue = viewClockInOut.schSchID.FormValue
  397.     End Sub
  398.  
  399.     '
  400.     ' Load row based on key values
  401.     '
  402.     Function LoadRow() As Boolean
  403.         Dim RsRow As OleDbDataReader
  404.         Dim sFilter As String = viewClockInOut.KeyFilter
  405.  
  406.         ' Row Selecting event
  407.         viewClockInOut.Row_Selecting(sFilter)
  408.  
  409.         ' Load SQL based on filter
  410.         viewClockInOut.CurrentFilter = sFilter
  411.         Dim sSql As String = viewClockInOut.SQL
  412.  
  413.         ' Write SQL for debug
  414.         If EW_DEBUG_ENABLED Then ew_Write(sSql)
  415.         Try
  416.             RsRow = Conn.GetTempDataReader(sSql)    
  417.             If Not RsRow.Read() Then
  418.                 Return False
  419.             Else                
  420.                 LoadRowValues(RsRow) ' Load row values
  421.  
  422.                 ' Row Selected event
  423.                 viewClockInOut.Row_Selected(RsRow)
  424.                 Return True    
  425.             End If
  426.         Catch
  427.             If EW_DEBUG_ENABLED Then Throw
  428.             Return False
  429.         Finally
  430.             Conn.CloseTempDataReader()
  431.         End Try
  432.     End Function
  433.  
  434.     '
  435.     ' Load row values from recordset
  436.     '
  437.     Sub LoadRowValues(ByRef RsRow As OleDbDataReader)
  438.         viewClockInOut.schSchID.DbValue = RsRow("schSchID")
  439.         viewClockInOut.schDate.DbValue = RsRow("schDate")
  440.         viewClockInOut.schEvtID.DbValue = RsRow("schEvtID")
  441.         viewClockInOut.schPartsID.DbValue = RsRow("schPartsID")
  442.         viewClockInOut.schCallTime.DbValue = RsRow("schCallTime")
  443.         viewClockInOut.schStartTime.DbValue = RsRow("schStartTime")
  444.         viewClockInOut.schEndTime.DbValue = RsRow("schEndTime")
  445.         viewClockInOut.schOutTime.DbValue = RsRow("schOutTime")
  446.         viewClockInOut.schLocID.DbValue = RsRow("schLocID")
  447.         viewClockInOut.schEmpID.DbValue = RsRow("schEmpID")
  448.         viewClockInOut.schPosID.DbValue = RsRow("schPosID")
  449.         viewClockInOut.schTypID.DbValue = RsRow("schTypID")
  450.         viewClockInOut.schNotes.DbValue = RsRow("schNotes")
  451.         viewClockInOut.schActualStart.DbValue = RsRow("schActualStart")
  452.         viewClockInOut.schActualEnd.DbValue = RsRow("schActualEnd")
  453.         viewClockInOut.schDateCreated.DbValue = RsRow("schDateCreated")
  454.         viewClockInOut.schStatus.DbValue = RsRow("schStatus")
  455.     End Sub
  456.  
  457.     '
  458.     ' Render row values based on field settings
  459.     '
  460.     Sub RenderRow()
  461.  
  462.         ' Row Rendering event
  463.         viewClockInOut.Row_Rendering()
  464.  
  465.         '
  466.         '  Common render codes for all row types
  467.         '
  468.         ' schDate
  469.  
  470.         viewClockInOut.schDate.CellCssStyle = ""
  471.         viewClockInOut.schDate.CellCssClass = ""
  472.  
  473.         ' schEvtID
  474.         viewClockInOut.schEvtID.CellCssStyle = ""
  475.         viewClockInOut.schEvtID.CellCssClass = ""
  476.  
  477.         ' schPartsID
  478.         viewClockInOut.schPartsID.CellCssStyle = ""
  479.         viewClockInOut.schPartsID.CellCssClass = ""
  480.  
  481.         ' schCallTime
  482.         viewClockInOut.schCallTime.CellCssStyle = ""
  483.         viewClockInOut.schCallTime.CellCssClass = ""
  484.  
  485.         ' schStartTime
  486.         viewClockInOut.schStartTime.CellCssStyle = ""
  487.         viewClockInOut.schStartTime.CellCssClass = ""
  488.  
  489.         ' schLocID
  490.         viewClockInOut.schLocID.CellCssStyle = ""
  491.         viewClockInOut.schLocID.CellCssClass = ""
  492.  
  493.         ' schEmpID
  494.         viewClockInOut.schEmpID.CellCssStyle = ""
  495.         viewClockInOut.schEmpID.CellCssClass = ""
  496.  
  497.         ' schPosID
  498.         viewClockInOut.schPosID.CellCssStyle = ""
  499.         viewClockInOut.schPosID.CellCssClass = ""
  500.  
  501.         ' schTypID
  502.         viewClockInOut.schTypID.CellCssStyle = ""
  503.         viewClockInOut.schTypID.CellCssClass = ""
  504.  
  505.         ' schNotes
  506.         viewClockInOut.schNotes.CellCssStyle = ""
  507.         viewClockInOut.schNotes.CellCssClass = ""
  508.  
  509.         ' schActualStart
  510.         viewClockInOut.schActualStart.CellCssStyle = ""
  511.         viewClockInOut.schActualStart.CellCssClass = ""
  512.  
  513.         ' schDateCreated
  514.         viewClockInOut.schDateCreated.CellCssStyle = ""
  515.         viewClockInOut.schDateCreated.CellCssClass = ""
  516.  
  517.         ' schStatus
  518.         viewClockInOut.schStatus.CellCssStyle = ""
  519.         viewClockInOut.schStatus.CellCssClass = ""
  520.  
  521.         '
  522.         '  View  Row
  523.         '
  524.  
  525.         If viewClockInOut.RowType = EW_ROWTYPE_VIEW Then ' View row
  526.  
  527.             ' schDate
  528.             viewClockInOut.schDate.ViewValue = viewClockInOut.schDate.CurrentValue
  529.             viewClockInOut.schDate.ViewValue = ew_FormatDateTime(viewClockInOut.schDate.ViewValue, 6)
  530.             viewClockInOut.schDate.CssStyle = ""
  531.             viewClockInOut.schDate.CssClass = ""
  532.             viewClockInOut.schDate.ViewCustomAttributes = ""
  533.  
  534.             ' schEvtID
  535.             If ew_NotEmpty(viewClockInOut.schEvtID.CurrentValue) Then
  536.                     sSqlWrk = "SELECT [evtDescription] FROM [tblEvents] WHERE [evtID] = " & ew_AdjustSql(viewClockInOut.schEvtID.CurrentValue) & " AND [evtIsActive]=True"
  537.                 sSqlWrk = sSqlWrk & " ORDER BY [evtDescription] "
  538.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  539.                 If RsWrk.Read() Then
  540.                     viewClockInOut.schEvtID.ViewValue = RsWrk("evtDescription")
  541.                 Else
  542.                     viewClockInOut.schEvtID.ViewValue = viewClockInOut.schEvtID.CurrentValue
  543.                 End If
  544.                 Conn.CloseTempDataReader()
  545.             Else
  546.                 viewClockInOut.schEvtID.ViewValue = System.DBNull.Value
  547.             End If
  548.             viewClockInOut.schEvtID.CssStyle = ""
  549.             viewClockInOut.schEvtID.CssClass = ""
  550.             viewClockInOut.schEvtID.ViewCustomAttributes = ""
  551.  
  552.             ' schPartsID
  553.             If ew_NotEmpty(viewClockInOut.schPartsID.CurrentValue) Then
  554.                     sSqlWrk = "SELECT [prtDescription] FROM [tblParts] WHERE [prtID] = " & ew_AdjustSql(viewClockInOut.schPartsID.CurrentValue) & " AND [prtIsActive]=True"
  555.                 sSqlWrk = sSqlWrk & " ORDER BY [prtDescription] "
  556.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  557.                 If RsWrk.Read() Then
  558.                     viewClockInOut.schPartsID.ViewValue = RsWrk("prtDescription")
  559.                 Else
  560.                     viewClockInOut.schPartsID.ViewValue = viewClockInOut.schPartsID.CurrentValue
  561.                 End If
  562.                 Conn.CloseTempDataReader()
  563.             Else
  564.                 viewClockInOut.schPartsID.ViewValue = System.DBNull.Value
  565.             End If
  566.             viewClockInOut.schPartsID.CssStyle = ""
  567.             viewClockInOut.schPartsID.CssClass = ""
  568.             viewClockInOut.schPartsID.ViewCustomAttributes = ""
  569.  
  570.             ' schCallTime
  571.             viewClockInOut.schCallTime.ViewValue = viewClockInOut.schCallTime.CurrentValue
  572.                 viewClockInOut.schCallTime.ViewValue = ew_FormatDateTime(viewClockInOut.schCallTime.ViewValue, 14)
  573.             viewClockInOut.schCallTime.CssStyle = ""
  574.             viewClockInOut.schCallTime.CssClass = ""
  575.             viewClockInOut.schCallTime.ViewCustomAttributes = ""
  576.  
  577.             ' schStartTime
  578.             viewClockInOut.schStartTime.ViewValue = viewClockInOut.schStartTime.CurrentValue
  579.                 viewClockInOut.schStartTime.ViewValue = ew_FormatDateTime(viewClockInOut.schStartTime.ViewValue, 14)
  580.             viewClockInOut.schStartTime.CssStyle = ""
  581.             viewClockInOut.schStartTime.CssClass = ""
  582.             viewClockInOut.schStartTime.ViewCustomAttributes = ""
  583.  
  584.             ' schEndTime
  585.             viewClockInOut.schEndTime.ViewValue = viewClockInOut.schEndTime.CurrentValue
  586.                 viewClockInOut.schEndTime.ViewValue = ew_FormatDateTime(viewClockInOut.schEndTime.ViewValue, 14)
  587.             viewClockInOut.schEndTime.CssStyle = ""
  588.             viewClockInOut.schEndTime.CssClass = ""
  589.             viewClockInOut.schEndTime.ViewCustomAttributes = ""
  590.  
  591.             ' schOutTime
  592.             viewClockInOut.schOutTime.ViewValue = viewClockInOut.schOutTime.CurrentValue
  593.                 viewClockInOut.schOutTime.ViewValue = ew_FormatDateTime(viewClockInOut.schOutTime.ViewValue, 14)
  594.             viewClockInOut.schOutTime.CssStyle = ""
  595.             viewClockInOut.schOutTime.CssClass = ""
  596.             viewClockInOut.schOutTime.ViewCustomAttributes = ""
  597.  
  598.             ' schLocID
  599.             If ew_NotEmpty(viewClockInOut.schLocID.CurrentValue) Then
  600.                     sSqlWrk = "SELECT [locDescription] FROM [tblLocations] WHERE [locID] = " & ew_AdjustSql(viewClockInOut.schLocID.CurrentValue) & " AND [locIsActive]=True"
  601.                 sSqlWrk = sSqlWrk & " ORDER BY [locDescription] "
  602.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  603.                 If RsWrk.Read() Then
  604.                     viewClockInOut.schLocID.ViewValue = RsWrk("locDescription")
  605.                 Else
  606.                     viewClockInOut.schLocID.ViewValue = viewClockInOut.schLocID.CurrentValue
  607.                 End If
  608.                 Conn.CloseTempDataReader()
  609.             Else
  610.                 viewClockInOut.schLocID.ViewValue = System.DBNull.Value
  611.             End If
  612.             viewClockInOut.schLocID.CssStyle = ""
  613.             viewClockInOut.schLocID.CssClass = ""
  614.             viewClockInOut.schLocID.ViewCustomAttributes = ""
  615.  
  616.             ' schEmpID
  617.             If ew_NotEmpty(viewClockInOut.schEmpID.CurrentValue) Then
  618.                     sSqlWrk = "SELECT [empName] FROM [tblEmployees] WHERE [empID] = " & ew_AdjustSql(viewClockInOut.schEmpID.CurrentValue) & " AND [empIsActive]=True"
  619.                     sSqlWrk = sSqlWrk & " ORDER BY [empFirstName] "
  620.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  621.                 If RsWrk.Read() Then
  622.                     viewClockInOut.schEmpID.ViewValue = RsWrk("empName")
  623.                 Else
  624.                     viewClockInOut.schEmpID.ViewValue = viewClockInOut.schEmpID.CurrentValue
  625.                 End If
  626.                 Conn.CloseTempDataReader()
  627.             Else
  628.                 viewClockInOut.schEmpID.ViewValue = System.DBNull.Value
  629.             End If
  630.             viewClockInOut.schEmpID.CssStyle = ""
  631.             viewClockInOut.schEmpID.CssClass = ""
  632.             viewClockInOut.schEmpID.ViewCustomAttributes = ""
  633.  
  634.             ' schPosID
  635.             If ew_NotEmpty(viewClockInOut.schPosID.CurrentValue) Then
  636.                     sSqlWrk = "SELECT [posDescription] FROM [tblPositions] WHERE [posID] = " & ew_AdjustSql(viewClockInOut.schPosID.CurrentValue) & " AND [posIsActive]=True"
  637.                 sSqlWrk = sSqlWrk & " ORDER BY [posDescription] "
  638.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  639.                 If RsWrk.Read() Then
  640.                     viewClockInOut.schPosID.ViewValue = RsWrk("posDescription")
  641.                 Else
  642.                     viewClockInOut.schPosID.ViewValue = viewClockInOut.schPosID.CurrentValue
  643.                 End If
  644.                 Conn.CloseTempDataReader()
  645.             Else
  646.                 viewClockInOut.schPosID.ViewValue = System.DBNull.Value
  647.             End If
  648.             viewClockInOut.schPosID.CssStyle = ""
  649.             viewClockInOut.schPosID.CssClass = ""
  650.             viewClockInOut.schPosID.ViewCustomAttributes = ""
  651.  
  652.             ' schTypID
  653.             If ew_NotEmpty(viewClockInOut.schTypID.CurrentValue) Then
  654.                     sSqlWrk = "SELECT [typDescription] FROM [tblTypes] WHERE [typID] = " & ew_AdjustSql(viewClockInOut.schTypID.CurrentValue) & " AND [typIsActive]=True"
  655.                 sSqlWrk = sSqlWrk & " ORDER BY [typDescription] "
  656.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  657.                 If RsWrk.Read() Then
  658.                     viewClockInOut.schTypID.ViewValue = RsWrk("typDescription")
  659.                 Else
  660.                     viewClockInOut.schTypID.ViewValue = viewClockInOut.schTypID.CurrentValue
  661.                 End If
  662.                 Conn.CloseTempDataReader()
  663.             Else
  664.                 viewClockInOut.schTypID.ViewValue = System.DBNull.Value
  665.             End If
  666.             viewClockInOut.schTypID.CssStyle = ""
  667.             viewClockInOut.schTypID.CssClass = ""
  668.             viewClockInOut.schTypID.ViewCustomAttributes = ""
  669.  
  670.             ' schNotes
  671.             viewClockInOut.schNotes.ViewValue = viewClockInOut.schNotes.CurrentValue
  672.             viewClockInOut.schNotes.CssStyle = ""
  673.             viewClockInOut.schNotes.CssClass = ""
  674.             viewClockInOut.schNotes.ViewCustomAttributes = ""
  675.  
  676.             ' schActualStart
  677.             viewClockInOut.schActualStart.ViewValue = viewClockInOut.schActualStart.CurrentValue
  678.                 viewClockInOut.schActualStart.ViewValue = ew_FormatDateTime(viewClockInOut.schActualStart.ViewValue, 14)
  679.             viewClockInOut.schActualStart.CssStyle = ""
  680.             viewClockInOut.schActualStart.CssClass = ""
  681.             viewClockInOut.schActualStart.ViewCustomAttributes = ""
  682.  
  683.             ' schActualEnd
  684.             viewClockInOut.schActualEnd.ViewValue = viewClockInOut.schActualEnd.CurrentValue
  685.                 viewClockInOut.schActualEnd.ViewValue = ew_FormatDateTime(viewClockInOut.schActualEnd.ViewValue, 14)
  686.             viewClockInOut.schActualEnd.CssStyle = ""
  687.             viewClockInOut.schActualEnd.CssClass = ""
  688.             viewClockInOut.schActualEnd.ViewCustomAttributes = ""
  689.  
  690.             ' schDateCreated
  691.             viewClockInOut.schDateCreated.ViewValue = viewClockInOut.schDateCreated.CurrentValue
  692.             viewClockInOut.schDateCreated.ViewValue = ew_FormatDateTime(viewClockInOut.schDateCreated.ViewValue, 6)
  693.             viewClockInOut.schDateCreated.CssStyle = ""
  694.             viewClockInOut.schDateCreated.CssClass = ""
  695.             viewClockInOut.schDateCreated.ViewCustomAttributes = ""
  696.  
  697.             ' schStatus
  698.             If ew_NotEmpty(viewClockInOut.schStatus.CurrentValue) Then
  699.                     sSqlWrk = "SELECT [stDescription] FROM [tblScheduleStatus] WHERE [stID] = " & ew_AdjustSql(viewClockInOut.schStatus.CurrentValue) & " AND [stIsActive]=True"
  700.                 sSqlWrk = sSqlWrk & " ORDER BY [stDescription] "
  701.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  702.                 If RsWrk.Read() Then
  703.                     viewClockInOut.schStatus.ViewValue = RsWrk("stDescription")
  704.                 Else
  705.                     viewClockInOut.schStatus.ViewValue = viewClockInOut.schStatus.CurrentValue
  706.                 End If
  707.                 Conn.CloseTempDataReader()
  708.             Else
  709.                 viewClockInOut.schStatus.ViewValue = System.DBNull.Value
  710.             End If
  711.             viewClockInOut.schStatus.CssStyle = ""
  712.             viewClockInOut.schStatus.CssClass = ""
  713.             viewClockInOut.schStatus.ViewCustomAttributes = ""
  714.  
  715.             ' View refer script
  716.             ' schDate
  717.  
  718.             viewClockInOut.schDate.HrefValue = ""
  719.  
  720.             ' schEvtID
  721.             viewClockInOut.schEvtID.HrefValue = ""
  722.  
  723.             ' schPartsID
  724.             viewClockInOut.schPartsID.HrefValue = ""
  725.  
  726.             ' schCallTime
  727.             viewClockInOut.schCallTime.HrefValue = ""
  728.  
  729.             ' schStartTime
  730.             viewClockInOut.schStartTime.HrefValue = ""
  731.  
  732.             ' schLocID
  733.             viewClockInOut.schLocID.HrefValue = ""
  734.  
  735.             ' schEmpID
  736.             viewClockInOut.schEmpID.HrefValue = ""
  737.  
  738.             ' schPosID
  739.             viewClockInOut.schPosID.HrefValue = ""
  740.  
  741.             ' schTypID
  742.             viewClockInOut.schTypID.HrefValue = ""
  743.  
  744.             ' schNotes
  745.             viewClockInOut.schNotes.HrefValue = ""
  746.  
  747.             ' schActualStart
  748.             viewClockInOut.schActualStart.HrefValue = ""
  749.  
  750.             ' schDateCreated
  751.             viewClockInOut.schDateCreated.HrefValue = ""
  752.  
  753.             ' schStatus
  754.             viewClockInOut.schStatus.HrefValue = ""
  755.  
  756.         '
  757.         '  Add Row
  758.         '
  759.  
  760.         ElseIf viewClockInOut.RowType = EW_ROWTYPE_ADD Then ' Add row
  761.  
  762.             ' schDate
  763.             viewClockInOut.schDate.EditCustomAttributes = ""
  764.             viewClockInOut.schDate.EditValue = ew_FormatDateTime(viewClockInOut.schDate.CurrentValue, 6)
  765.  
  766.                 ' schEvtID
  767.                 viewClockInOut.schEvtID.EditCustomAttributes = ""
  768.                 If Not Security.IsAdmin And Security.IsLoggedIn() Then ' Non system admin
  769.                     'viewClockInOut.schEvtID.CurrentValue = Security.CurrentUserID
  770.                     If ew_NotEmpty(viewClockInOut.schEvtID.CurrentValue) Then
  771.                         sSqlWrk = "SELECT [evtDescription] FROM [tblEvents] WHERE [evtID] = " & ew_AdjustSql(viewClockInOut.schEvtID.CurrentValue) & " AND [evtIsActive]=True"
  772.                         sSqlWrk = sSqlWrk & " ORDER BY [evtDescription] "
  773.                         RsWrk = Conn.GetTempDataReader(sSqlWrk)
  774.                         If RsWrk.Read() Then
  775.                             viewClockInOut.schEvtID.EditValue = RsWrk("evtDescription")
  776.                         Else
  777.                             viewClockInOut.schEvtID.EditValue = viewClockInOut.schEvtID.CurrentValue
  778.                         End If
  779.                         Conn.CloseTempDataReader()
  780.                     Else
  781.                         viewClockInOut.schEvtID.EditValue = System.DBNull.Value
  782.                     End If
  783.                     viewClockInOut.schEvtID.CssStyle = ""
  784.                     viewClockInOut.schEvtID.CssClass = ""
  785.                     viewClockInOut.schEvtID.ViewCustomAttributes = ""
  786.                 Else
  787.                     viewClockInOut.schEvtID.EditCustomAttributes = ""
  788.                     sSqlWrk = "SELECT [evtID], [evtDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblEvents]"
  789.                     sWhereWrk = "[evtIsActive]=True"
  790.                     If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  791.                     sSqlWrk = sSqlWrk & " ORDER BY [evtDescription] "
  792.                     arwrk = Conn.GetRows(sSqlWrk)
  793.                     arwrk.Insert(0, New Object() {"", "Please Select"})
  794.                     viewClockInOut.schEvtID.EditValue = arwrk
  795.                 End If
  796.  
  797.                 ' schPartsID
  798.                 viewClockInOut.schPartsID.EditCustomAttributes = ""
  799.                 If Not Security.IsAdmin And Security.IsLoggedIn() Then ' Non system admin
  800.                     'viewClockInOut.schPartsID.CurrentValue = Security.CurrentUserID
  801.                     If ew_NotEmpty(viewClockInOut.schPartsID.CurrentValue) Then
  802.                         sSqlWrk = "SELECT [prtDescription] FROM [tblParts] WHERE [prtID] = " & ew_AdjustSql(viewClockInOut.schPartsID.CurrentValue) & " AND [prtIsActive]=True"
  803.                         sSqlWrk = sSqlWrk & " ORDER BY [prtDescription] "
  804.                         RsWrk = Conn.GetTempDataReader(sSqlWrk)
  805.                         If RsWrk.Read() Then
  806.                             viewClockInOut.schPartsID.EditValue = RsWrk("prtDescription")
  807.                         Else
  808.                             viewClockInOut.schPartsID.EditValue = viewClockInOut.schPartsID.CurrentValue
  809.                         End If
  810.                         Conn.CloseTempDataReader()
  811.                     Else
  812.                         viewClockInOut.schPartsID.EditValue = System.DBNull.Value
  813.                     End If
  814.                     viewClockInOut.schPartsID.CssStyle = ""
  815.                     viewClockInOut.schPartsID.CssClass = ""
  816.                     viewClockInOut.schPartsID.ViewCustomAttributes = ""
  817.                 Else
  818.                     viewClockInOut.schPartsID.EditCustomAttributes = ""
  819.                     sSqlWrk = "SELECT [prtID], [prtDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblParts]"
  820.                     sWhereWrk = "[prtIsActive]=True"
  821.                     If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  822.                     sSqlWrk = sSqlWrk & " ORDER BY [prtDescription] "
  823.                     arwrk = Conn.GetRows(sSqlWrk)
  824.                     arwrk.Insert(0, New Object() {"", "Please Select"})
  825.                     viewClockInOut.schPartsID.EditValue = arwrk
  826.                 End If
  827.  
  828.                 ' schCallTime
  829.                 viewClockInOut.schCallTime.EditCustomAttributes = ""
  830.                 viewClockInOut.schCallTime.EditValue = ew_FormatDateTime(viewClockInOut.schCallTime.CurrentValue, 14)
  831.  
  832.                 ' schStartTime
  833.                 viewClockInOut.schStartTime.EditCustomAttributes = ""
  834.                 viewClockInOut.schStartTime.EditValue = ew_FormatDateTime(viewClockInOut.schStartTime.CurrentValue, 14)
  835.  
  836.                 ' schLocID
  837.                 viewClockInOut.schLocID.EditCustomAttributes = ""
  838.                 sSqlWrk = "SELECT [locID], [locDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblLocations]"
  839.                 sWhereWrk = "[locIsActive]=True"
  840.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  841.                 sSqlWrk = sSqlWrk & " ORDER BY [locDescription] "
  842.                 arwrk = Conn.GetRows(sSqlWrk)
  843.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  844.                 viewClockInOut.schLocID.EditValue = arwrk
  845.  
  846.                 ' schEmpID
  847.                 viewClockInOut.schEmpID.EditCustomAttributes = ""
  848.                 If Not Security.IsAdmin And Security.IsLoggedIn() Then ' Non system admin
  849.                     viewClockInOut.schEmpID.CurrentValue = Security.CurrentUserID
  850.                     If ew_NotEmpty(viewClockInOut.schEmpID.CurrentValue) Then
  851.                         sSqlWrk = "SELECT [empName] FROM [tblEmployees] WHERE [empID] = " & ew_AdjustSql(viewClockInOut.schEmpID.CurrentValue) & " AND [empIsActive]=True"
  852.                         sSqlWrk = sSqlWrk & " ORDER BY [empFirstName] "
  853.                         RsWrk = Conn.GetTempDataReader(sSqlWrk)
  854.                         If RsWrk.Read() Then
  855.                             viewClockInOut.schEmpID.EditValue = RsWrk("empName")
  856.                         Else
  857.                             viewClockInOut.schEmpID.EditValue = viewClockInOut.schEmpID.CurrentValue
  858.                         End If
  859.                         Conn.CloseTempDataReader()
  860.                     Else
  861.                         viewClockInOut.schEmpID.EditValue = System.DBNull.Value
  862.                     End If
  863.                     viewClockInOut.schEmpID.CssStyle = ""
  864.                     viewClockInOut.schEmpID.CssClass = ""
  865.                     viewClockInOut.schEmpID.ViewCustomAttributes = ""
  866.                 Else
  867.                     sSqlWrk = "SELECT [empID], [empName], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblEmployees]"
  868.                     sWhereWrk = "[empIsActive]=True"
  869.                     sWhereWrk = tblEmployees.AddUserIDFilter(sWhereWrk)
  870.                     If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  871.                     sSqlWrk = sSqlWrk & " ORDER BY [empFirstName] "
  872.                     arwrk = Conn.GetRows(sSqlWrk)
  873.                     arwrk.Insert(0, New Object() {"", "Please Select"})
  874.                     viewClockInOut.schEmpID.EditValue = arwrk
  875.                 End If
  876.  
  877.                 ' schPosID
  878.                 viewClockInOut.schPosID.EditCustomAttributes = ""
  879.                 sSqlWrk = "SELECT [posID], [posDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblPositions]"
  880.                 sWhereWrk = "[posIsActive]=True"
  881.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  882.                 sSqlWrk = sSqlWrk & " ORDER BY [posDescription] "
  883.                 arwrk = Conn.GetRows(sSqlWrk)
  884.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  885.                 viewClockInOut.schPosID.EditValue = arwrk
  886.  
  887.                 ' schTypID
  888.                 viewClockInOut.schTypID.EditCustomAttributes = ""
  889.                 If Not Security.IsAdmin And Security.IsLoggedIn() Then ' Non system admin
  890.                     'viewClockInOut.schTypID.CurrentValue = Security.CurrentUserID
  891.                     If ew_NotEmpty(viewClockInOut.schTypID.CurrentValue) Then
  892.                         sSqlWrk = "SELECT [typDescription] FROM [tblTypes] WHERE [typID] = " & ew_AdjustSql(viewClockInOut.schTypID.CurrentValue) & " AND [typIsActive]=True"
  893.                         sSqlWrk = sSqlWrk & " ORDER BY [typDescription] "
  894.                         RsWrk = Conn.GetTempDataReader(sSqlWrk)
  895.                         If RsWrk.Read() Then
  896.                             viewClockInOut.schTypID.EditValue = RsWrk("typDescription")
  897.                         Else
  898.                             viewClockInOut.schTypID.EditValue = viewClockInOut.schTypID.CurrentValue
  899.                         End If
  900.                         Conn.CloseTempDataReader()
  901.                     Else
  902.                         viewClockInOut.schTypID.EditValue = System.DBNull.Value
  903.                     End If
  904.                     viewClockInOut.schTypID.CssStyle = ""
  905.                     viewClockInOut.schTypID.CssClass = ""
  906.                     viewClockInOut.schTypID.ViewCustomAttributes = ""
  907.                 Else
  908.                     viewClockInOut.schTypID.EditCustomAttributes = ""
  909.                     sSqlWrk = "SELECT [typID], [typDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblTypes]"
  910.                     sWhereWrk = "[typIsActive]=True"
  911.                     If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  912.                     sSqlWrk = sSqlWrk & " ORDER BY [typDescription] "
  913.                     arwrk = Conn.GetRows(sSqlWrk)
  914.                     arwrk.Insert(0, New Object() {"", "Please Select"})
  915.                     viewClockInOut.schTypID.EditValue = arwrk
  916.                 End If
  917.  
  918.                 ' schNotes
  919.                 viewClockInOut.schNotes.EditCustomAttributes = ""
  920.                 viewClockInOut.schNotes.EditValue = ew_HtmlEncode(viewClockInOut.schNotes.CurrentValue)
  921.  
  922.                 ' schActualStart
  923.                 viewClockInOut.schActualStart.EditCustomAttributes = ""
  924.                 viewClockInOut.schActualStart.EditValue = ew_FormatDateTime(viewClockInOut.schActualStart.CurrentValue, 14)
  925.  
  926.                 ' schDateCreated
  927.                 viewClockInOut.schDateCreated.EditCustomAttributes = ""
  928.                 viewClockInOut.schDateCreated.EditValue = ew_FormatDateTime(viewClockInOut.schDateCreated.CurrentValue, 6)
  929.  
  930.                 ' schStatus
  931.                 viewClockInOut.schStatus.EditCustomAttributes = ""
  932.                 sSqlWrk = "SELECT [stID], [stDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblScheduleStatus]"
  933.                 sWhereWrk = "[stIsActive]=True"
  934.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  935.                 sSqlWrk = sSqlWrk & " ORDER BY [stDescription] "
  936.                 arwrk = Conn.GetRows(sSqlWrk)
  937.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  938.                 viewClockInOut.schStatus.EditValue = arwrk
  939.                 End If
  940.  
  941.                 ' Row Rendered event
  942.                 viewClockInOut.Row_Rendered()
  943.         End Sub
  944.  
  945.     '
  946.     ' Validate form
  947.     '
  948.     Function ValidateForm() As Boolean
  949.  
  950.         ' Initialize
  951.         ParentPage.gsFormError = ""
  952.  
  953.         ' Check if validation required
  954.         If Not EW_SERVER_VALIDATE Then Return (ParentPage.gsFormError = "")
  955.         If ew_Empty(viewClockInOut.schDate.FormValue) Then
  956.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  957.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Date"
  958.         End If
  959.         If Not ew_CheckUSDate(viewClockInOut.schDate.FormValue) Then
  960.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  961.             ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect date, format = mm/dd/yyyy - Date"
  962.         End If
  963.         If ew_Empty(viewClockInOut.schEvtID.FormValue) Then
  964.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  965.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Event"
  966.         End If
  967.         If ew_Empty(viewClockInOut.schPartsID.FormValue) Then
  968.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  969.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Part"
  970.         End If
  971.         If Not ew_CheckTime(viewClockInOut.schCallTime.FormValue) Then
  972.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  973.             ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect time (hh:mm:ss) - Call Time"
  974.         End If
  975.         If Not ew_CheckTime(viewClockInOut.schStartTime.FormValue) Then
  976.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  977.             ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect time (hh:mm:ss) - Start Time"
  978.         End If
  979.         If ew_Empty(viewClockInOut.schLocID.FormValue) Then
  980.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  981.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Location"
  982.         End If
  983.         If ew_Empty(viewClockInOut.schEmpID.FormValue) Then
  984.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  985.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Employee"
  986.         End If
  987.         If ew_Empty(viewClockInOut.schPosID.FormValue) Then
  988.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  989.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Position"
  990.         End If
  991.         If ew_Empty(viewClockInOut.schTypID.FormValue) Then
  992.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  993.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Type"
  994.         End If
  995.         If ew_Empty(viewClockInOut.schNotes.FormValue) Then
  996.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  997.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Reason for Unscheduled Shift"
  998.         End If
  999.         If Not ew_CheckTime(viewClockInOut.schActualStart.FormValue) Then
  1000.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1001.             ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect time (hh:mm:ss) - Actual Start"
  1002.         End If
  1003.         If Not ew_CheckUSDate(viewClockInOut.schDateCreated.FormValue) Then
  1004.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1005.             ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect date, format = mm/dd/yyyy - Date Created"
  1006.         End If
  1007.         If ew_Empty(viewClockInOut.schStatus.FormValue) Then
  1008.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1009.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Status"
  1010.         End If
  1011.  
  1012.         ' Return validate result
  1013.         Dim Valid As Boolean = (ParentPage.gsFormError = "")
  1014.  
  1015.         ' Form_CustomValidate event
  1016.         Dim sFormCustomError As String = ""
  1017.         Valid = Valid And Form_CustomValidate(sFormCustomError)
  1018.         If sFormCustomError <> "" Then
  1019.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1020.             ParentPage.gsFormError = ParentPage.gsFormError & sFormCustomError
  1021.         End If
  1022.         Return Valid
  1023.     End Function
  1024.  
  1025.     '
  1026.     ' Add record
  1027.     '
  1028.     Function AddRow() As Boolean
  1029.         Dim Rs As New OrderedDictionary
  1030.         Dim sSql As String, sFilter As String
  1031.         Dim bInsertRow As Boolean
  1032.         Dim RsChk As OleDbDataReader
  1033.         Dim sIdxErrMsg As String
  1034.         Dim LastInsertId As Object
  1035.  
  1036.         ' Check if valid user ID
  1037.         Dim bValidUser As Boolean = False, sUserIdMsg As String
  1038.         If ew_NotEmpty(Security.CurrentUserID) AndAlso Not Security.IsAdmin() Then ' Non system admin
  1039.             bValidUser = Security.IsValidUserID(viewClockInOut.schEmpID.CurrentValue)
  1040.             If Not bValidUser Then
  1041.                 sUserIdMsg = "The current user (%c) is not authorized to assign the user ID (%u).".Replace("%c", Security.CurrentUserID)
  1042.                 sUserIdMsg = sUserIdMsg.Replace("%u", viewClockInOut.schEmpID.CurrentValue)
  1043.                 Message = sUserIdMsg
  1044.                 Return False
  1045.             End If
  1046.         End If
  1047.  
  1048.         ' schDate
  1049.         viewClockInOut.schDate.SetDbValue(ew_UnFormatDateTime(viewClockInOut.schDate.CurrentValue, 6), System.DBNull.Value)
  1050.             Rs("schDate") = viewClockInOut.schDate.DbValue
  1051.  
  1052.             ' schDayOfWeek
  1053.             viewClockInOut.schDayOfWeek.SetDbValue(Weekday(viewClockInOut.schDate.DbValue) + 1, System.DBNull.Value)
  1054.             Rs("schDayOfWeek") = Weekday(viewClockInOut.schDate.DbValue)
  1055.  
  1056.         ' schEvtID
  1057.         viewClockInOut.schEvtID.SetDbValue(viewClockInOut.schEvtID.CurrentValue, System.DBNull.Value)
  1058.         Rs("schEvtID") = viewClockInOut.schEvtID.DbValue
  1059.  
  1060.         ' schPartsID
  1061.         viewClockInOut.schPartsID.SetDbValue(viewClockInOut.schPartsID.CurrentValue, System.DBNull.Value)
  1062.         Rs("schPartsID") = viewClockInOut.schPartsID.DbValue
  1063.  
  1064.         ' schCallTime
  1065.         viewClockInOut.schCallTime.SetDbValue(ew_UnFormatDateTime(viewClockInOut.schCallTime.CurrentValue, 4), System.DBNull.Value)
  1066.         Rs("schCallTime") = viewClockInOut.schCallTime.DbValue
  1067.  
  1068.         ' schStartTime
  1069.         viewClockInOut.schStartTime.SetDbValue(ew_UnFormatDateTime(viewClockInOut.schStartTime.CurrentValue, 4), System.DBNull.Value)
  1070.         Rs("schStartTime") = viewClockInOut.schStartTime.DbValue
  1071.  
  1072.         ' schLocID
  1073.         viewClockInOut.schLocID.SetDbValue(viewClockInOut.schLocID.CurrentValue, System.DBNull.Value)
  1074.         Rs("schLocID") = viewClockInOut.schLocID.DbValue
  1075.  
  1076.         ' schEmpID
  1077.         viewClockInOut.schEmpID.SetDbValue(viewClockInOut.schEmpID.CurrentValue, System.DBNull.Value)
  1078.         Rs("schEmpID") = viewClockInOut.schEmpID.DbValue
  1079.  
  1080.         ' schPosID
  1081.         viewClockInOut.schPosID.SetDbValue(viewClockInOut.schPosID.CurrentValue, System.DBNull.Value)
  1082.         Rs("schPosID") = viewClockInOut.schPosID.DbValue
  1083.  
  1084.         ' schTypID
  1085.         viewClockInOut.schTypID.SetDbValue(viewClockInOut.schTypID.CurrentValue, System.DBNull.Value)
  1086.         Rs("schTypID") = viewClockInOut.schTypID.DbValue
  1087.  
  1088.         ' schNotes
  1089.         viewClockInOut.schNotes.SetDbValue(viewClockInOut.schNotes.CurrentValue, System.DBNull.Value)
  1090.         Rs("schNotes") = viewClockInOut.schNotes.DbValue
  1091.  
  1092.         ' schActualStart
  1093.         viewClockInOut.schActualStart.SetDbValue(ew_UnFormatDateTime(viewClockInOut.schActualStart.CurrentValue, 4), System.DBNull.Value)
  1094.         Rs("schActualStart") = viewClockInOut.schActualStart.DbValue
  1095.  
  1096.         ' schDateCreated
  1097.         viewClockInOut.schDateCreated.SetDbValue(ew_UnFormatDateTime(viewClockInOut.schDateCreated.CurrentValue, 6), System.DBNull.Value)
  1098.         Rs("schDateCreated") = viewClockInOut.schDateCreated.DbValue
  1099.  
  1100.         ' schStatus
  1101.         viewClockInOut.schStatus.SetDbValue(viewClockInOut.schStatus.CurrentValue, System.DBNull.Value)
  1102.         Rs("schStatus") = viewClockInOut.schStatus.DbValue
  1103.  
  1104.         ' Row Inserting event
  1105.         bInsertRow = viewClockInOut.Row_Inserting(Rs)
  1106.         If bInsertRow Then
  1107.             Try    
  1108.                 viewClockInOut.Insert(Rs)
  1109.                 AddRow = True
  1110.             Catch e As Exception
  1111.                 If EW_DEBUG_ENABLED Then Throw
  1112.                 Message = e.Message                
  1113.                 AddRow = False
  1114.             End Try
  1115.         Else
  1116.             If viewClockInOut.CancelMessage <> "" Then
  1117.                 Message = viewClockInOut.CancelMessage
  1118.                 viewClockInOut.CancelMessage = ""
  1119.             Else
  1120.                 Message = "Insert cancelled"
  1121.             End If
  1122.             AddRow = False
  1123.         End If
  1124.         If AddRow Then
  1125.             LastInsertId = Conn.GetLastInsertId()
  1126.             viewClockInOut.schSchID.DbValue = LastInsertId
  1127.             Rs("schSchID") = viewClockInOut.schSchID.DbValue        
  1128.  
  1129.             ' Row Inserted event
  1130.             viewClockInOut.Row_Inserted(Rs)
  1131.         End If
  1132.     End Function
  1133.  
  1134.         ' Page Load event
  1135.         Public Sub Page_Load()
  1136.  
  1137.             'HttpContext.Current.Response.Write("Page Load")
  1138.         End Sub
  1139.  
  1140.         ' Page Unload event
  1141.         Public Sub Page_Unload()
  1142.  
  1143.             'HttpContext.Current.Response.Write("Page Unload")
  1144.         End Sub
  1145.  
  1146.     ' Form Custom Validate event
  1147.     Public Function Form_CustomValidate(ByRef CustomError As String) As Boolean
  1148.  
  1149.         'Return error message in CustomError
  1150.         Return True
  1151.     End Function
  1152.     End Class
  1153.  
  1154.     '
  1155.     ' ASP.NET Page_Load event
  1156.     '
  1157.  
  1158.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  1159.         Response.Buffer = EW_RESPONSE_BUFFER
  1160.         Response.Cache.SetCacheability(HttpCacheability.NoCache)
  1161.  
  1162.         ' Page init
  1163.         viewClockInOut_add = New cviewClockInOut_add(Me)        
  1164.         viewClockInOut_add.Page_Init()
  1165.  
  1166.         ' Page main processing
  1167.         viewClockInOut_add.Page_Main()
  1168.     End Sub
  1169.  
  1170.     '
  1171.     ' ASP.NET Page_Unload event
  1172.     '
  1173.  
  1174.     Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
  1175.  
  1176.         ' Dispose page object
  1177.         If viewClockInOut_add IsNot Nothing Then viewClockInOut_add.Dispose()
  1178.     End Sub
  1179. End Class
  1180.