home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / tblSchedulelist.aspx.vb < prev    next >
Text File  |  2014-12-14  |  94KB  |  1,933 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. '
  13. ' ASP.NET code-behind class (Page)
  14. '
  15.  
  16. Partial Class tblSchedulelist
  17.     Inherits AspNetMaker7_tfpssnet
  18.  
  19.     ' Page object
  20.     Public tblSchedule_list As ctblSchedule_list
  21.  
  22.     '
  23.     ' Page Class
  24.     '
  25.     Class ctblSchedule_list
  26.         Inherits AspNetMakerPage
  27.         Implements IDisposable        
  28.  
  29.         ' Used by system generated functions
  30.         Private RsWrk As Object, sSqlWrk As String, sWhereWrk As String
  31.  
  32.         Private arwrk As Object
  33.  
  34.         Private armultiwrk() As String        
  35.  
  36.         ' Page URL
  37.         Public ReadOnly Property PageUrl() As String
  38.             Get
  39.                 Dim Url As String = ew_CurrentPage() & "?"
  40.                 If tblSchedule.UseTokenInUrl Then Url = Url & "t=" & tblSchedule.TableVar & "&" ' Add page token
  41.                 Return Url    
  42.             End Get
  43.         End Property
  44.  
  45.         ' Validate page request
  46.         Public Function IsPageRequest() As Boolean
  47.             Dim Result As Boolean
  48.             If tblSchedule.UseTokenInUrl Then
  49.                 Result = False
  50.                 If ObjForm IsNot Nothing Then
  51.                     Result = (tblSchedule.TableVar = ObjForm.GetValue("t"))
  52.                 End If
  53.                 If ew_Get("t") <> "" Then
  54.                     Result = (tblSchedule.TableVar = ew_Get("t"))
  55.                 End If
  56.                 Return Result
  57.             End If
  58.             Return True            
  59.         End Function    
  60.  
  61.         ' tblSchedule
  62.         Public Property tblSchedule() As ctblSchedule
  63.             Get                
  64.                 Return ParentPage.tblSchedule
  65.             End Get
  66.             Set(ByVal v As ctblSchedule)
  67.                 ParentPage.tblSchedule = v    
  68.             End Set    
  69.         End Property
  70.  
  71.         ' tblSchedule
  72.         Public Property tblEmployees() As ctblEmployees
  73.             Get                
  74.                 Return ParentPage.tblEmployees
  75.             End Get
  76.             Set(ByVal v As ctblEmployees)
  77.                 ParentPage.tblEmployees = v    
  78.             End Set    
  79.         End Property
  80.  
  81.         '
  82.         '  Constructor
  83.         '  - init objects
  84.         '  - open connection
  85.         '
  86.         Public Sub New(ByRef APage As AspNetMaker7_tfpssnet)                
  87.             m_ParentPage = APage
  88.             m_Page = Me    
  89.             m_PageID = "list"
  90.             m_PageObjName = "tblSchedule_list"
  91.             m_PageObjTypeName = "ctblSchedule_list"
  92.  
  93.             ' Table Name
  94.             m_TableName = "tblSchedule"
  95.  
  96.             ' Initialize table object
  97.             tblSchedule = New ctblSchedule(Me)
  98.             tblEmployees = New ctblEmployees(Me)
  99.  
  100.             ' Connect to database
  101.             Conn = New cConnection()
  102.  
  103.             ' Initialize list options
  104.             ListOptions = New cListOptions
  105.         End Sub
  106.  
  107.         '
  108.         '  Subroutine Page_Init
  109.         '  - called before page main
  110.         '  - check Security
  111.         '  - set up response header
  112.         '  - call page load events
  113.         '
  114.         Public Sub Page_Init()
  115.             Security = New cAdvancedSecurity(Me)
  116.             If Not Security.IsLoggedIn() Then Security.AutoLogin()
  117.             If Not Security.IsLoggedIn() Then
  118.                 Security.SaveLastUrl()
  119.                 Page_Terminate("login.aspx")
  120.             End If
  121.  
  122.             ' Table Permission loading event
  123.             Security.TablePermission_Loading()
  124.             Security.LoadCurrentUserLevel(TableName)
  125.  
  126.             ' Table Permission loaded event
  127.             Security.TablePermission_Loaded()
  128.             If Not Security.CanList Then
  129.                 Security.SaveLastUrl()
  130.                 Page_Terminate("login.aspx")
  131.             End If
  132.  
  133.             ' User ID loading event
  134.             Security.UserID_Loading()
  135.             If Security.IsLoggedIn() Then Call Security.LoadUserID()
  136.  
  137.             ' User ID loaded event
  138.             Security.UserID_Loaded()
  139.             If Security.IsLoggedIn() And ew_Empty(Security.CurrentUserID) Then
  140.                 Message = "You do not have the right permission to view the page"
  141.                 Page_Terminate("")
  142.             End If
  143.             tblSchedule.Export = ew_Get("export") ' Get export parameter
  144.             ParentPage.gsExport = tblSchedule.Export ' Get export parameter, used in header
  145.             ParentPage.gsExportFile = tblSchedule.TableVar ' Get export file, used in header
  146.  
  147.             ' Global page loading event (in ewglobal*.vb)
  148.             ParentPage.Page_Loading()
  149.  
  150.             ' Page load event, used in current page
  151.             Page_Load()
  152.         End Sub
  153.  
  154.         '
  155.         '  Class terminate
  156.         '  - clean up page object
  157.         '
  158.         Public Sub Dispose() Implements IDisposable.Dispose
  159.             Page_Terminate("")
  160.         End Sub
  161.  
  162.         '
  163.         '  Sub Page_Terminate
  164.         '  - called when exit page
  165.         '  - clean up connection and objects
  166.         '  - if URL specified, redirect to URL
  167.         '
  168.         Sub Page_Terminate(url As String)
  169.  
  170.             ' Page unload event, used in current page
  171.             Page_Unload()
  172.  
  173.             ' Global page unloaded event (in ewglobal*.vb)
  174.             ParentPage.Page_Unloaded()
  175.  
  176.             ' Close connection
  177.             Conn.Dispose()
  178.             Security = Nothing
  179.             tblSchedule.Dispose()
  180.             tblEmployees.Dispose()
  181.             ListOptions = Nothing
  182.  
  183.             ' Go to URL if specified
  184.             If url <> "" Then
  185.                 HttpContext.Current.Response.Clear()
  186.                 HttpContext.Current.Response.Redirect(url)
  187.             End If
  188.         End Sub
  189.  
  190.     Public lDisplayRecs As Integer ' Number of display records
  191.  
  192.     Public lStartRec As Integer, lStopRec As Integer, lTotalRecs As Integer, lRecRange As Integer
  193.  
  194.     Public sSrchWhere As String
  195.  
  196.     Public lRecCnt As Integer
  197.  
  198.     Public lEditRowCnt As Integer
  199.  
  200.     Public lRowCnt As Integer, lRowIndex As Integer
  201.  
  202.     Public lOptionCnt As Integer
  203.  
  204.     Public lRecPerRow As Integer, lColCnt As Integer
  205.  
  206.     Public sDeleteConfirmMsg As String ' Delete confirm message
  207.  
  208.     Public sDbMasterFilter As String, sDbDetailFilter As String
  209.  
  210.     Public bMasterRecordExists As Boolean
  211.  
  212.     Public ListOptions As Object
  213.  
  214.     Public sMultiSelectKey As String
  215.  
  216.         Public x_ewPriv As Integer
  217.  
  218.         Public PSSSendEmailConfirmation As Boolean
  219.  
  220.         Public PSSSyncExchangeCalendar As Boolean
  221.  
  222.     '
  223.     ' Page main processing
  224.     '
  225.     Public Sub Page_Main()
  226.             Dim tlcsub As New AspNetMaker7_tfpssnet
  227.             PSSSendEmailConfirmation = tlcsub.tlcGetPSSEmailConfirmation()
  228.             PSSSyncExchangeCalendar = tlcsub.tlcGetPSSUpdateExchangeCalendar()
  229.  
  230.             'Dim service As New ExchangeService(requestedServerVersion:=ExchangeVersion.Exchange2010)
  231.             Dim service As New ExchangeService(ExchangeVersion.Exchange2010_SP1)
  232.             Dim tmpNewStatus As String
  233.  
  234.             lDisplayRecs = 20
  235.             lRecRange = EW_PAGER_RANGE
  236.             lRecCnt = 0 ' Record count
  237.  
  238.             ' Search filters        
  239.             Dim sSrchAdvanced As String = "" ' Advanced search filter
  240.             Dim sSrchBasic As String = "" ' Basic search filter
  241.             Dim sFilter As String = ""
  242.             sSrchWhere = "" ' Search WHERE clause        
  243.  
  244.             ' Master/Detail
  245.             sDbMasterFilter = "" ' Master filter
  246.             sDbDetailFilter = "" ' Detail filter
  247.  
  248.             ' Create form object
  249.             ObjForm = New cFormObj
  250.  
  251.             If IsPageRequest() Then ' Validate request
  252.  
  253.                 ' Set up records per page dynamically
  254.                 SetUpDisplayRecs()
  255.  
  256.                 ' Handle reset command
  257.                 ResetCmd()
  258.  
  259.                 ' Check QueryString parameters
  260.                 If ObjForm.GetValue("a_list") = "" Then ' Check if post back first
  261.                     If ew_Get("a") <> "" Then
  262.                         tblSchedule.CurrentAction = ew_Get("a")
  263.  
  264.                         If tblSchedule.CurrentAction = "confirm" Or tblSchedule.CurrentAction = "unconfirm" Or tblSchedule.CurrentAction = "cannotwork" Or tblSchedule.CurrentAction = "tentative" Then
  265.                             Dim Sql As String, key As String, arRecKeys As String(), values As String
  266.                             values = ObjForm.GetValue("key_m")
  267.                             arRecKeys = values.Split(",")
  268.                             For Each key In arRecKeys
  269.                                 Select Case tblSchedule.CurrentAction
  270.                                     Case "confirm"
  271.                                         Sql = "UPDATE [tblSchedule] SET [schStatus] = 1"
  272.                                         tmpNewStatus = "Confirmed"
  273.                                     Case "unconfirm"
  274.                                         Sql = "UPDATE [tblSchedule] SET [schStatus] = 2"
  275.                                         tmpNewStatus = "Un-confirmed"
  276.                                     Case "cannotwork"
  277.                                         Sql = "UPDATE [tblSchedule] SET [schStatus] = 3"
  278.                                         tmpNewStatus = "Cannot Work"
  279.                                     Case "tentative"
  280.                                         Sql = "UPDATE [tblSchedule] SET [schStatus] = 4"
  281.                                         tmpNewStatus = "Tentative"
  282.                                 End Select
  283.                                 tblSchedule.schSchID.QueryStringValue = key
  284.                                 Sql = Sql & " WHERE schSchID = " & tblSchedule.schSchID.QueryStringValue
  285.                                 Conn = New cConnection()
  286.                                 Dim command As OleDbCommand = Conn.GetCommand(Sql)
  287.                                 command.ExecuteNonQuery()
  288.                                 Conn.Dispose()
  289.  
  290.                                 'Dim tlcsub As New AspNetMaker7_tfpssnet
  291.                                 'Dim intResult As Integer, tmpMessage As String
  292.                                 'Dim tmpSchDate As Date, tmpEvtDescription As String, tmpPrtDescription As String, tmpCallTime As Date
  293.                                 'Dim tmpStartTime As Date, tmpEndTime As Date, tmpOutTime As Date, tmpLocDescription As String, tmpPosDescription As String, tmpStDescription As String
  294.                                 'Dim tmpTypDescription As String, tmpEmpName As String, tmpEmail As String, tmpBody As String, tmpAction As String, tmpStatus As String, tmpType As String
  295.                                 'tblSchedule.schSchID.QueryStringValue = key
  296.                                 'intResult = tlcsub.tlcGetEventInfo(key, tmpSchDate, tmpEvtDescription, tmpPrtDescription, tmpCallTime, tmpStartTime, tmpEndTime, tmpOutTime, tmpLocDescription, tmpPosDescription, tmpStDescription, tmpTypDescription, tmpEmpName, tmpEmail, tmpStatus)
  297.                                 'ew_Session("intResult") = intResult
  298.  
  299.                                 'tmpMessage += " for the following event:<br><br>"
  300.                                 'tmpMessage = tmpMessage & "<b>Date:</b> " & ew_FormatDateTime(tmpSchDate, 2) & "<br> "
  301.                                 'tmpMessage = tmpMessage & "<b>Event:</b> " & tmpEvtDescription & "<br> "
  302.                                 'tmpMessage = tmpMessage & "<b>Part:</b> " & tmpPrtDescription & "<br>"
  303.                                 'tmpMessage = tmpMessage & "<b>Call Time:</b> " & ew_FormatDateTime(tmpCallTime, 14) & "<br>"
  304.                                 'tmpMessage = tmpMessage & "<b>Start Time:</b> " & ew_FormatDateTime(tmpStartTime, 14) & "<br>"
  305.                                 'tmpMessage = tmpMessage & "<b>End Time:</b> " & ew_FormatDateTime(tmpEndTime, 14) & "<br>"
  306.                                 'tmpMessage = tmpMessage & "<b>Out Time:</b> " & ew_FormatDateTime(tmpOutTime, 14) & "<br>"
  307.                                 'tmpMessage = tmpMessage & "<b>Location:</b> " & tmpLocDescription & "<br>"
  308.                                 'tmpMessage = tmpMessage & "<b>Position:</b> " & tmpPosDescription & "<br>"
  309.                                 'tmpMessage = tmpMessage & "<b>Status:</b> " & tmpNewStatus & "<br>"
  310.                                 'tmpMessage = tmpMessage & "<b>Type:</b> " & tmpTypDescription & "<br><br>"
  311.                                 'ew_SendEmail("prodservices@tfchurch.org", "tonyclayton@tfchurch.org", "", "", "PSS Event status change for " & ew_Session("TFProduction_Status_UserID"), tmpMessage, "html")
  312.  
  313.                                 Dim tmpSchDate As Date, tmpEvtDescription As String, tmpPrtDescription As String, tmpCallTime As Date
  314.                                 Dim tmpStartTime As Date, tmpEndTime As Date, tmpOutTime As Date, tmpLocDescription As String, tmpPosDescription As String, tmpStDescription As String
  315.                                 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
  316.                                 Dim intResult As Integer, tmpMessage As String, smtpStatus As Boolean, smtpMessage As String
  317.                                 'Dim tlcsub As New AspNetMaker7_tfpssnet
  318.                                 intResult = tlcsub.tlcGetEventInfo(key, tmpSchDate, tmpEvtDescription, tmpPrtDescription, tmpCallTime, tmpStartTime, tmpEndTime, tmpOutTime, tmpLocDescription, tmpPosDescription, tmpStDescription, tmpTypDescription, tmpEmpName, tmpEmail, tmpStatus, tmpNotes)
  319.                                 If intResult = True Then
  320.                                     Select Case tblSchedule.CurrentAction
  321.                                         Case "confirm"
  322.                                             tmpAction = "A"
  323.                                             tmpStatus = "BUSY"
  324.                                             tmpType = "C"
  325.                                             tmpNewStatus = "Confirmed"
  326.                                         Case "unconfirm"
  327.                                             tmpAction = "D"
  328.                                             tmpType = "U"
  329.                                             tmpNewStatus = "Un-confirmed"
  330.                                         Case "cannotwork"
  331.                                             tmpAction = "D"
  332.                                             tmpType = "X"
  333.                                             tmpNewStatus = "Cannot Work"
  334.                                         Case "tentative"
  335.                                             tmpAction = "A"
  336.                                             tmpStatus = "TENTATIVE"
  337.                                             tmpType = "T"
  338.                                             tmpNewStatus = "Tentative"
  339.                                     End Select
  340.                                     'intResult = tlcsub.tlcSendEventInfo(key, tmpSchDate, tmpEvtDescription, tmpPrtDescription, tmpCallTime, tmpStartTime, tmpEndTime, tmpOutTime, tmpLocDescription, tmpPosDescription, tmpStDescription, tmpTypDescription, tmpEmpName, tmpEmail, tmpAction, tmpStatus, tmpType, smtpStatus, smtpMessage)
  341.                                     '                                    Message = smtpMessage
  342.  
  343.                                     If PSSSyncExchangeCalendar = True Or PSSSendEmailConfirmation = True Then
  344.                                         'Add a valid EWS service end point here or user Autodiscover
  345.                                         'service.Url = New Uri("https://server14/ews/exchange.asmx")
  346.                                         service.Url = New Uri("https://outlook.office365.com/EWS/Exchange.asmx")
  347.  
  348.                                         'Add a valid user credentials
  349.                                         'service.Credentials = New WebCredentials("prodservices", "production88", "Business")
  350.                                         service.Credentials = New WebCredentials("productionservices@tfc.org", "production88")
  351.                                         service.AutodiscoverUrl("productionservices@tfc.org", AddressOf RedirectionUrlValaditionCallBack)
  352.  
  353.                                         'To address the SSL challenge
  354.                                         ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidateCertificate)
  355.                                     End If
  356.  
  357.                                     If PSSSendEmailConfirmation = True And tmpEmail <> "kirkmanton@tfc.org" Then
  358.                                         tmpMessage = " for the following event:<br><br>"
  359.                                         tmpMessage = tmpMessage & "<b>Employee:</b> " & tmpEmpName & "<br> "
  360.                                         tmpMessage = tmpMessage & "<b>Date:</b> " & ew_FormatDateTime(tmpSchDate, 2) & "<br> "
  361.                                         tmpMessage = tmpMessage & "<b>Event:</b> " & tmpEvtDescription & "<br> "
  362.                                         tmpMessage = tmpMessage & "<b>Part:</b> " & tmpPrtDescription & "<br>"
  363.                                         tmpMessage = tmpMessage & "<b>Call Time:</b> " & ew_FormatDateTime(tmpCallTime, 14) & "<br>"
  364.                                         tmpMessage = tmpMessage & "<b>Start Time:</b> " & ew_FormatDateTime(tmpStartTime, 14) & "<br>"
  365.                                         'tmpMessage = tmpMessage & "<b>End Time:</b> " & ew_FormatDateTime(tmpEndTime, 14) & "<br>"
  366.                                         'tmpMessage = tmpMessage & "<b>Out Time:</b> " & ew_FormatDateTime(tmpOutTime, 14) & "<br>"
  367.                                         tmpMessage = tmpMessage & "<b>Location:</b> " & tmpLocDescription & "<br>"
  368.                                         tmpMessage = tmpMessage & "<b>Position:</b> " & tmpPosDescription & "<br>"
  369.                                         tmpMessage = tmpMessage & "<b>Status:</b> " & tmpNewStatus & "<br>"
  370.                                         tmpMessage = tmpMessage & "<b>Type:</b> " & tmpTypDescription & "<br>"
  371.                                         tmpMessage = tmpMessage & "<b>Notes:</b> " & tmpNotes & "<br><br>"
  372.                                         tmpMessage = tmpMessage & "sent from PSS tblSchedulelist."
  373.                                         'ew_SendEmail("prodservices@tfchurch.org", "kirkmanton@tfchurch.org", "", "", "PSS Event status change for " & ew_Session("tfpssnet_Status_UserName"), tmpMessage, "html")
  374.                                         Try
  375.                                             If tmpEmail <> "kirkmanton@tfc.org" Then
  376.                                                 If service.ImpersonatedUserId IsNot Nothing Then
  377.                                                     service.ImpersonatedUserId = Nothing
  378.                                                 End If
  379.                                             End If
  380.                                             'Create new message object and set properties required to send a mail
  381.                                             Dim msg As EmailMessage = New EmailMessage(service)
  382.                                             msg.Subject = "PSS Event status change by " & ew_Session("tfpssnet_Status_UserName")
  383.                                             msg.Body = tmpMessage
  384.                                             'msg.ToRecipients.Add("tony.clayton@suddenlink.net")
  385.                                             'msg.ToRecipients.Add("tonyc@tfchurch.org")
  386.                                             msg.ToRecipients.Add("kirkmanton@tfc.org")
  387.                                             msg.From = "productionservices@tfc.org"
  388.                                             msg.SendAndSaveCopy()
  389.                                             '                                            Message = "Email sent."
  390.                                         Catch ex As Exception
  391.                                             Message = ex.Message
  392.                                         End Try
  393.                                     End If
  394.  
  395.                                     If tmpEmail = ew_Session("tfpssnet_Status_UserEmail") Then
  396.                                         If tmpEmail <> "kirkmanton@tfc.org" And InStr(tmpEmail, "@tfc.org") > 0 Then
  397.                                             If PSSSendEmailConfirmation = True Or PSSSyncExchangeCalendar = True Then
  398.                                                 service.ImpersonatedUserId = New ImpersonatedUserId(ConnectingIdType.SmtpAddress, tmpEmail)
  399.                                             End If
  400.                                         End If
  401.                                         Try
  402.                                             If InStr(tmpEmail, "@tfc.org") > 0 And PSSSyncExchangeCalendar = True Then
  403.                                                 'Create appointment object and set properties as required
  404.                                                 Dim appt As Appointment = New Appointment(service)
  405.                                                 appt.Subject = tmpEvtDescription & " - " & tmpPrtDescription
  406.                                                 'tmpBody = "Event: " & tmpEvtDescription & ", Part: " & tmpPrtDescription & ", Call Time: " & tmpCallTime & _
  407.                                                 '            ", Start Time: " & tmpStartTime & ", End Time: " & tmpEndTime & ", Out Time: " & tmpOutTime & ", Location: " & tmpLocDescription & _
  408.                                                 '            ", Position: " & tmpPosDescription & ", Type: " & tmpTypDescription & ", Status: " & tmpStDescription & ", Notes: " & tmpNotes
  409.                                                 tmpBody = "Position: " & tmpPosDescription & vbCrLf & "Notes: " & tmpNotes
  410.                                                 appt.Body = tmpBody
  411.                                                 appt.Location = tmpLocDescription
  412.                                                 appt.Start = tmpSchDate & " " & tmpCallTime
  413.                                                 If tmpOutTime = Nothing Then
  414.                                                     appt.End = tmpSchDate & " " & tmpStartTime.AddHours(1)
  415.                                                 Else
  416.                                                     appt.End = tmpSchDate & " " & tmpOutTime
  417.                                                 End If
  418.                                                 appt.IsReminderSet = False
  419.                                                 'see if it already exists - if so, delete and re-add
  420.                                                 Dim findResults As FindItemsResults(Of Appointment) = service.FindAppointments(WellKnownFolderName.Calendar, New CalendarView(tmpSchDate, tmpSchDate.AddHours(24)))
  421.                                                 Dim items As New List(Of Item)()
  422.                                                 For Each appointment As Appointment In findResults
  423.                                                     items.Add(appointment)
  424.                                                 Next
  425.                                                 If items.Count <> 0 Then
  426.                                                     service.LoadPropertiesForItems(items, PropertySet.FirstClassProperties)
  427.                                                     For Each Appointment As Appointment In items
  428.                                                         If Not Appointment.IsCancelled Then
  429.                                                             If Appointment.Subject = tmpEvtDescription & " - " & tmpPrtDescription Or Appointment.Subject = tmpEvtDescription Then
  430.                                                                 Appointment.Delete(DeleteMode.HardDelete)
  431.                                                                 Message = "EWS Appointment deleted from Outlook calendar."
  432.                                                             End If
  433.                                                         End If
  434.                                                     Next
  435.                                                 End If
  436.                                                 If tmpType = "C" Or tmpType = "T" Then
  437.                                                     If tmpNewStatus = "Tentative" Then
  438.                                                         appt.LegacyFreeBusyStatus = LegacyFreeBusyStatus.Tentative
  439.                                                     End If
  440.                                                     appt.Save(WellKnownFolderName.Calendar, SendInvitationsMode.SendToNone)
  441.                                                     Message = "EWS Appointment added to Outlook calendar."
  442.                                                 End If
  443.                                                 'If tmpType = "T" Then
  444.                                                 '    'service.ImpersonatedUserId = Nothing
  445.                                                 '    Dim findResults2 As FindItemsResults(Of Appointment) = service.FindAppointments(WellKnownFolderName.Calendar, New CalendarView(tmpSchDate, tmpSchDate.AddHours(24)))
  446.                                                 '    Dim items2 As New List(Of Item)()
  447.                                                 '    For Each appointment As Appointment In findResults2
  448.                                                 '        items2.Add(appointment)
  449.                                                 '    Next
  450.                                                 '    If items2.Count <> 0 Then
  451.                                                 '        service.LoadPropertiesForItems(items2, PropertySet.FirstClassProperties)
  452.                                                 '        For Each Appointment As Appointment In items2
  453.                                                 '            If Not Appointment.IsCancelled Then
  454.                                                 '                If Appointment.Subject = tmpEvtDescription & " - " & tmpPrtDescription or Appointment.Subject = tmpEvtDescription Then
  455.                                                 '                    'appt.AcceptTentatively(False)
  456.                                                 '                    Appointment.LegacyFreeBusyStatus = LegacyFreeBusyStatus.Tentative
  457.                                                 '                    Message = "EWS Appointment marked as Tentative in Outlook calendar."
  458.                                                 '                End If
  459.                                                 '            End If
  460.                                                 '        Next
  461.                                                 '    End If
  462.                                                 'End If
  463.                                             End If
  464.                                         Catch ex As Exception
  465.                                             Message = ex.Message
  466.                                         End Try
  467.                                     End If
  468.  
  469.                                 End If
  470.  
  471.                             Next
  472.                             Page_Terminate("tblScheduleList.aspx")
  473.                         ElseIf tblSchedule.CurrentAction = "mailAdd" Or tblSchedule.CurrentAction = "mailDel" Then
  474.                             Dim key As String, arRecKeys As String(), values As String, strResult As String, intResult As Integer
  475.                             Dim tmpSchDate As Date, tmpEvtDescription As String, tmpPrtDescription As String, tmpCallTime As Date, tmpNotes As String
  476.                             Dim tmpStartTime As Date, tmpEndTime As Date, tmpOutTime As Date, tmpLocDescription As String, tmpPosDescription As String, tmpStDescription As String
  477.                             Dim tmpTypDescription As String, tmpEmpName As String, tmpEmail As String, tmpBody As String, tmpAction As String, tmpStatus As String, tmpType As String
  478.                             Dim smtpStatus As Boolean, smtpMessage As String
  479.                             'Dim tlcsub As New AspNetMaker7_tfpssnet
  480.                             values = ObjForm.GetValue("key_m")
  481.                             arRecKeys = values.Split(",")
  482.                             For Each key In arRecKeys
  483.                                 tblSchedule.schSchID.QueryStringValue = key
  484.                                 intResult = tlcsub.tlcGetEventInfo(key, tmpSchDate, tmpEvtDescription, tmpPrtDescription, tmpCallTime, tmpStartTime, tmpEndTime, tmpOutTime, tmpLocDescription, tmpPosDescription, tmpStDescription, tmpTypDescription, tmpEmpName, tmpEmail, tmpStatus, tmpNotes)
  485.                                 ew_Session("intResult") = intResult
  486.                                 'If tlcsub.tlcGetEmployeeUsernameByName(tmpEmpName) <> ew_Session("tfpssnet_Status_UserName") Then
  487.                                 If intResult = True Then
  488.                                     If tblSchedule.CurrentAction = "mailAdd" Then
  489.                                         tmpAction = "A"
  490.                                         'Select Case tblSchedule.CurrentAction
  491.                                         '    Case "confirm"
  492.                                         '        tmpStatus = "BUSY"
  493.                                         '        tmpType = "C"
  494.                                         '    Case "unconfirm"
  495.                                         '        tmpType = "U"
  496.                                         '    Case "cannotwork"
  497.                                         '        tmpType = "X"
  498.                                         '    Case "tentative"
  499.                                         '        tmpStatus = "TENTATIVE"
  500.                                         '        tmpType = "T"
  501.                                         'End Select
  502.                                     Else
  503.                                         tmpAction = "D"
  504.                                         tmpStatus = ""
  505.                                     End If
  506.                                     'intResult = tlcsub.tlcSendEventInfo(key, tmpSchDate, tmpEvtDescription, tmpPrtDescription, tmpCallTime, tmpStartTime, tmpEndTime, tmpOutTime, tmpLocDescription, tmpPosDescription, tmpStDescription, tmpTypDescription, tmpEmpName, tmpEmail, tmpAction, tmpStatus, tmpType, smtpStatus, smtpMessage)
  507.                                     'Message = smtpMessage
  508.  
  509.                                     If PSSSyncExchangeCalendar = True Or PSSSendEmailConfirmation = True Then
  510.                                         'Add a valid EWS service end point here or user Autodiscover
  511.                                         'service.Url = New Uri("https://server14/ews/exchange.asmx")
  512.                                         service.Url = New Uri("https://outlook.office365.com/EWS/Exchange.asmx")
  513.  
  514.                                         'Add a valid user credentials
  515.                                         'service.Credentials = New WebCredentials("prodservices", "production88", "Business")
  516.                                         service.Credentials = New WebCredentials("productionservices@tfc.org", "production88")
  517.                                         service.AutodiscoverUrl("productionservices@tfc.org", AddressOf RedirectionUrlValaditionCallBack)
  518.  
  519.                                         'To address the SSL challenge
  520.                                         ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidateCertificate)
  521.                                         If tmpEmail <> "kirkmanton@tfc.org" And InStr(tmpEmail, "@tfc.org") > 0 And tlcsub.tlcGetPSSUpdateExchangeCalendar() = True Then
  522.                                             service.ImpersonatedUserId = New ImpersonatedUserId(ConnectingIdType.SmtpAddress, tmpEmail)
  523.                                         End If
  524.                                     End If
  525.  
  526.                                     Try
  527.                                         If InStr(tmpEmail, "@tfc.org") > 0 And PSSSyncExchangeCalendar = True Then
  528.                                             If tblSchedule.CurrentAction = "mailAdd" Then
  529.                                                 'Create appointment object and set properties as required
  530.                                                 Dim appt As Appointment = New Appointment(service)
  531.                                                 appt.Subject = tmpEvtDescription & " - " & tmpPrtDescription
  532.                                                 Select Case tmpType
  533.                                                     Case "C"
  534.                                                         tmpBody = "Status Changed to 'Confirmed' for "
  535.                                                     Case "U"
  536.                                                         tmpBody = "Status Changed to 'Unconfirmed' for "
  537.                                                     Case "X"
  538.                                                         tmpBody = "Status Changed to 'Cannot Work' for "
  539.                                                     Case "T"
  540.                                                         tmpBody = "Status Changed to 'Tentative' for "
  541.                                                 End Select
  542.                                                 'tmpBody += "Event: " & tmpEvtDescription & ", Part: " & tmpPrtDescription & ", Call Time: " & tmpCallTime & _
  543.                                                 '    ", Start Time: " & tmpStartTime & ", End Time: " & tmpEndTime & ", Out Time: " & tmpOutTime & ", Location: " & tmpLocDescription & _
  544.                                                 '    ", Position: " & tmpPosDescription & ", Type: " & tmpTypDescription & ", Status: " & tmpStDescription & ", Notes: " & tmpNotes
  545.                                                 tmpBody += "Position: " & tmpPosDescription & vbCrLf & "Notes: " & tmpNotes
  546.                                                 appt.Body = tmpBody
  547.                                                 appt.Location = tmpLocDescription
  548.                                                 appt.Start = tmpSchDate & " " & tmpCallTime
  549.                                                 If tmpOutTime = Nothing Then
  550.                                                     appt.End = tmpSchDate & " " & tmpStartTime.AddHours(1)
  551.                                                 Else
  552.                                                     appt.End = tmpSchDate & " " & tmpOutTime
  553.                                                 End If
  554.                                                 appt.IsReminderSet = False
  555.                                                 'see if it already exists - if so, delete and re-add
  556.                                                 Dim findResults As FindItemsResults(Of Appointment) = service.FindAppointments(WellKnownFolderName.Calendar, New CalendarView(tmpSchDate, tmpSchDate.AddHours(24)))
  557.                                                 Dim items As New List(Of Item)()
  558.                                                 For Each appointment As Appointment In findResults
  559.                                                     items.Add(appointment)
  560.                                                 Next
  561.                                                 If items.Count <> 0 Then
  562.                                                     service.LoadPropertiesForItems(items, PropertySet.FirstClassProperties)
  563.                                                     For Each Appointment As Appointment In items
  564.                                                         If Not Appointment.IsCancelled Then
  565.                                                             If Appointment.Subject = tmpEvtDescription & " - " & tmpPrtDescription Or Appointment.Subject = tmpEvtDescription Then
  566.                                                                 Appointment.Delete(DeleteMode.HardDelete)
  567.                                                                 Message = "EWS Appointment deleted from Outlook calendar."
  568.                                                             End If
  569.                                                         End If
  570.                                                     Next
  571.                                                 End If
  572.                                                 If tmpStatus = "Tentative" Then
  573.                                                     appt.LegacyFreeBusyStatus = LegacyFreeBusyStatus.Tentative
  574.                                                 End If
  575.                                                 appt.Save(WellKnownFolderName.Calendar, SendInvitationsMode.SendToNone)
  576.                                                 Message = "EWS Appointment added to Outlook calendar."
  577.                                             Else
  578.                                                 Dim findResults As FindItemsResults(Of Appointment) = service.FindAppointments(WellKnownFolderName.Calendar, New CalendarView(tmpSchDate, tmpSchDate.AddHours(24)))
  579.                                                 Dim items As New List(Of Item)()
  580.                                                 For Each appointment As Appointment In findResults
  581.                                                     items.Add(appointment)
  582.                                                 Next
  583.                                                 If items.Count <> 0 Then
  584.                                                     service.LoadPropertiesForItems(items, PropertySet.FirstClassProperties)
  585.                                                     For Each Appointment As Appointment In items
  586.                                                         If Not Appointment.IsCancelled Then
  587.                                                             If Appointment.Subject = tmpEvtDescription & " - " & tmpPrtDescription Or Appointment.Subject = tmpEvtDescription Then
  588.                                                                 Appointment.Delete(DeleteMode.HardDelete)
  589.                                                                 Message = "EWS Appointment deleted from Outlook calendar."
  590.                                                             End If
  591.                                                         End If
  592.                                                     Next
  593.                                                 End If
  594.                                             End If
  595.                                         End If
  596.                                     Catch ex As Exception
  597.                                         Message = ex.Message
  598.                                     End Try
  599.  
  600.  
  601.                                 End If
  602.                                 'End If
  603.                             Next
  604.                             Page_Terminate("tblScheduleList.aspx")
  605.                         End If
  606.  
  607.                     End If
  608.                 Else
  609.                     tblSchedule.CurrentAction = ObjForm.GetValue("a_list") ' Get action
  610.                 End If
  611.  
  612.                 ' Get advanced search criteria
  613.                 LoadSearchValues()
  614.  
  615.                 If ValidateSearch() Then
  616.                     sSrchAdvanced = AdvancedSearchWhere()
  617.                 Else
  618.                     Message = ParentPage.gsSearchError
  619.                 End If
  620.  
  621.                 ' Set Up Sorting Order
  622.                 SetUpSortOrder()
  623.             End If
  624.  
  625.             ' Restore display records
  626.             If (tblSchedule.RecordsPerPage = -1 OrElse tblSchedule.RecordsPerPage > 0) Then
  627.                 lDisplayRecs = tblSchedule.RecordsPerPage ' Restore from Session
  628.             Else
  629.                 lDisplayRecs = 20 ' Load default
  630.             End If
  631.  
  632.             ' Load Sorting Order
  633.             LoadSortOrder()
  634.  
  635.             ' Build search criteria
  636.             If sSrchAdvanced <> "" Then
  637.                 If sSrchWhere <> "" Then
  638.                     sSrchWhere = "(" & sSrchWhere & ") AND (" & sSrchAdvanced & ")"
  639.                 Else
  640.                     sSrchWhere = sSrchAdvanced
  641.                 End If
  642.             End If
  643.             If sSrchBasic <> "" Then
  644.                 If sSrchWhere <> "" Then
  645.                     sSrchWhere = "(" & sSrchWhere & ") AND (" & sSrchBasic & ")"
  646.                 Else
  647.                     sSrchWhere = sSrchBasic
  648.                 End If
  649.             End If
  650.  
  651.             ' Recordset Searching event
  652.             tblSchedule.Recordset_Searching(sSrchWhere)
  653.  
  654.             ' Save search criteria
  655.             If sSrchWhere <> "" Then
  656.                 If sSrchAdvanced = "" Then ResetAdvancedSearchParms()
  657.                 tblSchedule.SearchWhere = sSrchWhere ' Save to Session
  658.                 lStartRec = 1 ' Reset start record counter
  659.                 tblSchedule.StartRecordNumber = lStartRec
  660.             Else
  661.                 RestoreSearchParms()
  662.             End If
  663.  
  664.             ' Build filter
  665.             sFilter = ""
  666.             If Not Security.CanList Then
  667.                 sFilter = "(0=1)" ' Filter all records
  668.             End If
  669.             If sDbDetailFilter <> "" Then
  670.                 If sFilter <> "" Then
  671.                     sFilter = "(" & sFilter & ") AND (" & sDbDetailFilter & ")"
  672.                 Else
  673.                     sFilter = sDbDetailFilter
  674.                 End If
  675.             End If
  676.             If sSrchWhere <> "" Then
  677.                 If sFilter <> "" Then
  678.                     sFilter = "(" & sFilter & ") AND (" & sSrchWhere & ")"
  679.                 Else
  680.                     sFilter = sSrchWhere
  681.                 End If
  682.             End If
  683.  
  684.             ' Set up filter in Session
  685.             tblSchedule.SessionWhere = sFilter
  686.             tblSchedule.CurrentFilter = ""
  687.         End Sub
  688.  
  689.         Private Function ValidateCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As SslPolicyErrors) As Boolean
  690.             'Return True to force the certificate to be accepted.
  691.             Return True
  692.         End Function
  693.  
  694.         Private Shared Function RedirectionUrlValaditionCallBack(ByVal redirectionURL As String) As Boolean
  695.             Dim result As Boolean = False
  696.             Dim redirectionuri As New Uri(redirectionURL)
  697.             If redirectionuri.Scheme = "https" Then
  698.                 result = True
  699.             End If
  700.             Return result
  701.         End Function
  702.  
  703.         '
  704.         ' Set up number of records displayed per page
  705.         '
  706.     Sub SetUpDisplayRecs()
  707.         Dim sWrk As String
  708.         sWrk = ew_Get(EW_TABLE_REC_PER_PAGE)
  709.         If sWrk <> "" Then
  710.             If IsNumeric(sWrk) Then
  711.                 lDisplayRecs = ew_ConvertToInt(sWrk)
  712.             Else
  713.                 If ew_SameText(sWrk, "all") Then ' Display all records
  714.                     lDisplayRecs = -1
  715.                 Else
  716.                     lDisplayRecs = 20 ' Non-numeric, load default
  717.                 End If
  718.             End If
  719.             tblSchedule.RecordsPerPage = lDisplayRecs ' Save to Session
  720.  
  721.             ' Reset start position
  722.             lStartRec = 1
  723.             tblSchedule.StartRecordNumber = lStartRec
  724.         End If
  725.     End Sub
  726.  
  727.     '
  728.     ' Return Advanced Search WHERE based on QueryString parameters
  729.     '
  730.     Function AdvancedSearchWhere() As String        
  731.         If Not Security.CanSearch Then Return ""
  732.         Dim sWhere As String = ""
  733.         BuildSearchSql(sWhere, tblSchedule.schDate, False) ' schDate
  734.         BuildSearchSql(sWhere, tblSchedule.schEvtID, False) ' schEvtID
  735.         BuildSearchSql(sWhere, tblSchedule.schPartsID, False) ' schPartsID
  736.         BuildSearchSql(sWhere, tblSchedule.schCallTime, False) ' schCallTime
  737.         BuildSearchSql(sWhere, tblSchedule.schStartTime, False) ' schStartTime
  738.         BuildSearchSql(sWhere, tblSchedule.schEndTime, False) ' schEndTime
  739.         BuildSearchSql(sWhere, tblSchedule.schOutTime, False) ' schOutTime
  740.         BuildSearchSql(sWhere, tblSchedule.schLocID, False) ' schLocID
  741.         BuildSearchSql(sWhere, tblSchedule.schEmpID, False) ' schEmpID
  742.         BuildSearchSql(sWhere, tblSchedule.schPosID, False) ' schPosID
  743.         BuildSearchSql(sWhere, tblSchedule.schTypID, False) ' schTypID
  744.         BuildSearchSql(sWhere, tblSchedule.schDepID, False) ' schDepID
  745.         BuildSearchSql(sWhere, tblSchedule.schNotes, False) ' schNotes
  746.         BuildSearchSql(sWhere, tblSchedule.schRate, False) ' schRate
  747.         BuildSearchSql(sWhere, tblSchedule.schActualStart, False) ' schActualStart
  748.         BuildSearchSql(sWhere, tblSchedule.schActualEnd, False) ' schActualEnd
  749.         BuildSearchSql(sWhere, tblSchedule.schDateCreated, False) ' schDateCreated
  750.             '        BuildSearchSql(sWhere, tblSchedule.schDoubleBooked, False) ' schDoubleBooked
  751.             BuildSearchSql(sWhere, tblSchedule.schStatus, False) ' schStatus
  752.             BuildSearchSql(sWhere, tblSchedule.schDayOfWeek, False) ' schDayOfWeek
  753.  
  754.         ' Set up search parm
  755.         If sWhere <> "" Then
  756.             SetSearchParm(tblSchedule.schDate) ' schDate
  757.             SetSearchParm(tblSchedule.schEvtID) ' schEvtID
  758.             SetSearchParm(tblSchedule.schPartsID) ' schPartsID
  759.             SetSearchParm(tblSchedule.schCallTime) ' schCallTime
  760.             SetSearchParm(tblSchedule.schStartTime) ' schStartTime
  761.             SetSearchParm(tblSchedule.schEndTime) ' schEndTime
  762.             SetSearchParm(tblSchedule.schOutTime) ' schOutTime
  763.             SetSearchParm(tblSchedule.schLocID) ' schLocID
  764.             SetSearchParm(tblSchedule.schEmpID) ' schEmpID
  765.             SetSearchParm(tblSchedule.schPosID) ' schPosID
  766.             SetSearchParm(tblSchedule.schTypID) ' schTypID
  767.             SetSearchParm(tblSchedule.schDepID) ' schDepID
  768.             SetSearchParm(tblSchedule.schNotes) ' schNotes
  769.             SetSearchParm(tblSchedule.schRate) ' schRate
  770.             SetSearchParm(tblSchedule.schActualStart) ' schActualStart
  771.             SetSearchParm(tblSchedule.schActualEnd) ' schActualEnd
  772.             SetSearchParm(tblSchedule.schDateCreated) ' schDateCreated
  773.                 '            SetSearchParm(tblSchedule.schDoubleBooked) ' schDoubleBooked
  774.                 SetSearchParm(tblSchedule.schStatus) ' schStatus
  775.                 SetSearchParm(tblSchedule.schDayOfWeek) ' schDayOfWeek
  776.             End If
  777.         Return sWhere
  778.     End Function
  779.  
  780.     '
  781.     ' Build search SQL
  782.     '
  783.     Sub BuildSearchSql(ByRef Where As String, ByRef Fld As Object, MultiValue As Boolean)
  784.         Dim FldParm As String = Fld.FldVar.Substring(2)
  785.         Dim FldVal As String = Fld.AdvancedSearch.SearchValue
  786.         Dim FldOpr As String = Fld.AdvancedSearch.SearchOperator
  787.         Dim FldCond As String = Fld.AdvancedSearch.SearchCondition
  788.         Dim FldVal2 As String = Fld.AdvancedSearch.SearchValue2
  789.         Dim FldOpr2 As String = Fld.AdvancedSearch.SearchOperator2
  790.         Dim sWrk As String = ""
  791.         FldOpr = FldOpr.Trim().ToUpper()
  792.         If (FldOpr = "") Then FldOpr = "="
  793.         FldOpr2 = FldOpr2.Trim().ToUpper()
  794.         If FldOpr2 = "" Then FldOpr2 = "="
  795.         If EW_SEARCH_MULTI_VALUE_OPTION = 1 Then MultiValue = False
  796.         If FldOpr <> "LIKE" Then MultiValue = False
  797.         If FldOpr2 <> "LIKE" AndAlso FldVal2 <> "" Then MultiValue = False
  798.         If MultiValue Then
  799.             Dim sWrk1 As String, sWrk2 As String
  800.  
  801.             ' Field value 1
  802.             If FldVal <> "" Then
  803.                 sWrk1 = ew_GetMultiSearchSql(Fld, FldVal)
  804.             Else
  805.                 sWrk1 = ""
  806.             End If
  807.  
  808.             ' Field value 2
  809.             If FldVal2 <> "" AndAlso FldCond <> "" Then
  810.                 sWrk2 = ew_GetMultiSearchSql(Fld, FldVal2)
  811.             Else
  812.                 sWrk2 = ""
  813.             End If
  814.  
  815.             ' Build final SQL
  816.             sWrk = sWrk1
  817.             If sWrk2 <> "" Then
  818.                 If sWrk <> "" Then
  819.                     sWrk = "(" & sWrk & ") " & FldCond & " (" & sWrk2 & ")"
  820.                 Else
  821.                     sWrk = sWrk2
  822.                 End If
  823.             End If
  824.         Else
  825.             FldVal = ConvertSearchValue(Fld, FldVal)
  826.             FldVal2 = ConvertSearchValue(Fld, FldVal2)
  827.             sWrk = ew_GetSearchSql(Fld, FldVal, FldOpr, FldCond, FldVal2, FldOpr2)
  828.         End If
  829.         If sWrk <> "" Then
  830.             If Where <> "" Then Where = Where & " AND "
  831.             Where = Where & "(" & sWrk & ")"
  832.         End If
  833.     End Sub
  834.  
  835.     '
  836.     ' Set search parm
  837.     '
  838.     Sub SetSearchParm(ByRef Fld As Object)
  839.         Dim FldParm As String = Fld.FldVar.Substring(2)
  840.         tblSchedule.SetAdvancedSearch("x_" & FldParm, Fld.AdvancedSearch.SearchValue)
  841.         tblSchedule.SetAdvancedSearch("z_" & FldParm, Fld.AdvancedSearch.SearchOperator)
  842.         tblSchedule.SetAdvancedSearch("v_" & FldParm, Fld.AdvancedSearch.SearchCondition)
  843.         tblSchedule.SetAdvancedSearch("y_" & FldParm, Fld.AdvancedSearch.SearchValue2)
  844.         tblSchedule.SetAdvancedSearch("w_" & FldParm, Fld.AdvancedSearch.SearchOperator2)
  845.     End Sub
  846.  
  847.     '
  848.     ' Convert search value
  849.     '
  850.     Function ConvertSearchValue(ByRef Fld As cField, FldVal As Object) As Object
  851.         If Fld.FldDataType = EW_DATATYPE_BOOLEAN Then
  852.             If ew_NotEmpty(FldVal) Then Return IIf(FldVal="1", "True", "False")
  853.         ElseIf Fld.FldDataType = EW_DATATYPE_DATE Then
  854.             If ew_NotEmpty(FldVal) Then Return ew_UnFormatDateTime(FldVal, Fld.FldDateTimeFormat)
  855.         End If
  856.         Return FldVal
  857.     End Function
  858.  
  859.     '
  860.     ' Clear all search parameters
  861.     '
  862.     Sub ResetSearchParms()
  863.  
  864.         ' Clear search where
  865.         sSrchWhere = ""
  866.         tblSchedule.SearchWhere = sSrchWhere
  867.  
  868.         ' Clear advanced search parameters
  869.         ResetAdvancedSearchParms()
  870.     End Sub
  871.  
  872.     '
  873.     ' Clear all advanced search parameters
  874.     '
  875.     Sub ResetAdvancedSearchParms()
  876.         tblSchedule.SetAdvancedSearch("x_schDate", "")
  877.         tblSchedule.SetAdvancedSearch("v_schDate", "AND")
  878.         tblSchedule.SetAdvancedSearch("y_schDate", "")
  879.         tblSchedule.SetAdvancedSearch("x_schEvtID", "")
  880.         tblSchedule.SetAdvancedSearch("x_schPartsID", "")
  881.         tblSchedule.SetAdvancedSearch("x_schCallTime", "")
  882.         tblSchedule.SetAdvancedSearch("x_schStartTime", "")
  883.         tblSchedule.SetAdvancedSearch("x_schEndTime", "")
  884.         tblSchedule.SetAdvancedSearch("x_schOutTime", "")
  885.         tblSchedule.SetAdvancedSearch("x_schLocID", "")
  886.         tblSchedule.SetAdvancedSearch("x_schEmpID", "")
  887.         tblSchedule.SetAdvancedSearch("x_schPosID", "")
  888.         tblSchedule.SetAdvancedSearch("x_schTypID", "")
  889.         tblSchedule.SetAdvancedSearch("x_schDepID", "")
  890.         tblSchedule.SetAdvancedSearch("x_schNotes", "")
  891.         tblSchedule.SetAdvancedSearch("x_schRate", "")
  892.         tblSchedule.SetAdvancedSearch("x_schActualStart", "")
  893.         tblSchedule.SetAdvancedSearch("x_schActualEnd", "")
  894.         tblSchedule.SetAdvancedSearch("x_schDateCreated", "")
  895.             '        tblSchedule.SetAdvancedSearch("x_schDoubleBooked", "")
  896.             tblSchedule.SetAdvancedSearch("x_schStatus", "")
  897.             tblSchedule.SetAdvancedSearch("x_schDayOfWeek", "")
  898.         End Sub
  899.  
  900.     '
  901.     ' Restore all search parameters
  902.     '
  903.     Sub RestoreSearchParms()
  904.         sSrchWhere = tblSchedule.SearchWhere
  905.  
  906.         ' Restore advanced search settings
  907.         If ParentPage.gsSearchError = "" Then
  908.             RestoreAdvancedSearchParms()
  909.         End If
  910.     End Sub
  911.  
  912.     '
  913.     ' Restore all advanced search parameters
  914.     '
  915.     Sub RestoreAdvancedSearchParms()
  916.         tblSchedule.schDate.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schDate")
  917.         tblSchedule.schDate.AdvancedSearch.SearchCondition = tblSchedule.GetAdvancedSearch("v_schDate")
  918.         tblSchedule.schDate.AdvancedSearch.SearchValue2 = tblSchedule.GetAdvancedSearch("y_schDate")
  919.         tblSchedule.schEvtID.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schEvtID")
  920.         tblSchedule.schPartsID.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schPartsID")
  921.         tblSchedule.schCallTime.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schCallTime")
  922.         tblSchedule.schStartTime.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schStartTime")
  923.         tblSchedule.schEndTime.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schEndTime")
  924.         tblSchedule.schOutTime.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schOutTime")
  925.         tblSchedule.schLocID.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schLocID")
  926.         tblSchedule.schEmpID.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schEmpID")
  927.         tblSchedule.schPosID.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schPosID")
  928.         tblSchedule.schTypID.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schTypID")
  929.         tblSchedule.schDepID.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schDepID")
  930.         tblSchedule.schNotes.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schNotes")
  931.         tblSchedule.schRate.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schRate")
  932.         tblSchedule.schActualStart.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schActualStart")
  933.         tblSchedule.schActualEnd.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schActualEnd")
  934.         tblSchedule.schDateCreated.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schDateCreated")
  935.             '        tblSchedule.schDoubleBooked.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schDoubleBooked")
  936.             tblSchedule.schStatus.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schStatus")
  937.             tblSchedule.schDayOfWeek.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schDayOfWeek")
  938.         End Sub
  939.  
  940.     '
  941.     ' Set up Sort parameters based on Sort Links clicked
  942.     '
  943.     Sub SetUpSortOrder()
  944.         Dim sOrderBy As String
  945.         Dim sSortField As String, sLastSort As String, sThisSort As String
  946.         Dim bCtrl As Boolean
  947.  
  948.         ' Check for Ctrl pressed
  949.         bCtrl = (ew_Get("ctrl") <> "")
  950.  
  951.         ' Check for an Order parameter
  952.         If ew_Get("order") <> "" Then
  953.             tblSchedule.CurrentOrder = ew_Get("order")
  954.             tblSchedule.CurrentOrderType = ew_Get("ordertype")
  955.             tblSchedule.UpdateSort(tblSchedule.schDate, bCtrl) ' schDate
  956.             tblSchedule.UpdateSort(tblSchedule.schEvtID, bCtrl) ' schEvtID
  957.             tblSchedule.UpdateSort(tblSchedule.schPartsID, bCtrl) ' schPartsID
  958.             tblSchedule.UpdateSort(tblSchedule.schCallTime, bCtrl) ' schCallTime
  959.             tblSchedule.UpdateSort(tblSchedule.schStartTime, bCtrl) ' schStartTime
  960.             tblSchedule.UpdateSort(tblSchedule.schEndTime, bCtrl) ' schEndTime
  961.             tblSchedule.UpdateSort(tblSchedule.schOutTime, bCtrl) ' schOutTime
  962.             tblSchedule.UpdateSort(tblSchedule.schLocID, bCtrl) ' schLocID
  963.             tblSchedule.UpdateSort(tblSchedule.schEmpID, bCtrl) ' schEmpID
  964.             tblSchedule.UpdateSort(tblSchedule.schPosID, bCtrl) ' schPosID
  965.                 tblSchedule.UpdateSort(tblSchedule.schTypID, bCtrl) ' schTypID
  966.                 tblSchedule.UpdateSort(tblSchedule.schDepID, bCtrl) ' schDepID
  967.                 tblSchedule.UpdateSort(tblSchedule.schActualStart, bCtrl) ' schActualStart
  968.             tblSchedule.UpdateSort(tblSchedule.schActualEnd, bCtrl) ' schActualEnd
  969.                 '            tblSchedule.UpdateSort(tblSchedule.schDoubleBooked, bCtrl) ' schDoubleBooked
  970.                 tblSchedule.UpdateSort(tblSchedule.schStatus, bCtrl) ' schStatus
  971.                 tblSchedule.UpdateSort(tblSchedule.schDayOfWeek, bCtrl) ' schDayOfWeek
  972.                 tblSchedule.StartRecordNumber = 1 ' Reset start position
  973.         End If
  974.     End Sub
  975.  
  976.     '
  977.     ' Load Sort Order parameters
  978.     '
  979.     Sub LoadSortOrder()
  980.         Dim sOrderBy As String
  981.         sOrderBy = tblSchedule.SessionOrderBy ' Get order by from Session
  982.         If sOrderBy = "" Then
  983.             If tblSchedule.SqlOrderBy <> "" Then
  984.                 sOrderBy = tblSchedule.SqlOrderBy
  985.                 tblSchedule.SessionOrderBy = sOrderBy
  986.                 tblSchedule.schDate.Sort = "ASC"
  987.                 tblSchedule.schStartTime.Sort = "ASC"
  988.                 tblSchedule.schCallTime.Sort = "ASC"
  989.             End If
  990.         End If
  991.     End Sub
  992.  
  993.     '
  994.     ' Reset command based on querystring parameter "cmd"
  995.     ' - reset: reset search parameters
  996.     ' - resetall: reset search and master/detail parameters
  997.     ' - resetsort: reset sort parameters
  998.     '
  999.     Sub ResetCmd()
  1000.         Dim sCmd As String
  1001.  
  1002.         ' Get reset cmd
  1003.         If ew_Get("cmd") <> "" Then
  1004.             sCmd = ew_Get("cmd")
  1005.  
  1006.             ' Reset search criteria
  1007.             If ew_SameText(sCmd, "reset") OrElse ew_SameText(sCmd, "resetall") Then
  1008.                 ResetSearchParms()
  1009.             End If
  1010.  
  1011.             ' Reset sort criteria
  1012.             If ew_SameText(sCmd, "resetsort") Then
  1013.                 Dim sOrderBy As String = ""
  1014.                 tblSchedule.SessionOrderBy = sOrderBy
  1015.                 tblSchedule.schDate.Sort = ""
  1016.                 tblSchedule.schEvtID.Sort = ""
  1017.                 tblSchedule.schPartsID.Sort = ""
  1018.                     tblSchedule.schCallTime.Sort = ""
  1019.                     tblSchedule.schNotes.Sort = ""
  1020.                 tblSchedule.schStartTime.Sort = ""
  1021.                 tblSchedule.schEndTime.Sort = ""
  1022.                 tblSchedule.schOutTime.Sort = ""
  1023.                 tblSchedule.schLocID.Sort = ""
  1024.                 tblSchedule.schEmpID.Sort = ""
  1025.                 tblSchedule.schPosID.Sort = ""
  1026.                     tblSchedule.schTypID.Sort = ""
  1027.                     tblSchedule.schDepID.Sort = ""
  1028.                     tblSchedule.schActualStart.Sort = ""
  1029.                 tblSchedule.schActualEnd.Sort = ""
  1030.                     '                tblSchedule.schDoubleBooked.Sort = ""
  1031.                     tblSchedule.schStatus.Sort = ""
  1032.                     tblSchedule.schDayOfWeek.Sort = ""
  1033.                 End If
  1034.  
  1035.             ' Reset start position
  1036.             lStartRec = 1
  1037.             tblSchedule.StartRecordNumber = lStartRec
  1038.         End If
  1039.     End Sub
  1040.  
  1041.     Public Pager As Object
  1042.  
  1043.     '
  1044.     ' Set up Starting Record parameters
  1045.     '
  1046.     Sub SetUpStartRec()
  1047.         Dim nPageNo As Integer
  1048.  
  1049.         ' Exit if lDisplayRecs = 0
  1050.         If lDisplayRecs = 0 Then Exit Sub
  1051.         If IsPageRequest Then ' Validate request
  1052.  
  1053.             ' Check for a "start" parameter
  1054.             If ew_Get(EW_TABLE_START_REC) <> "" AndAlso IsNumeric(ew_Get(EW_TABLE_START_REC)) Then
  1055.                 lStartRec = ew_ConvertToInt(ew_Get(EW_TABLE_START_REC))
  1056.                 tblSchedule.StartRecordNumber = lStartRec
  1057.             ElseIf ew_Get(EW_TABLE_PAGE_NO) <> "" AndAlso IsNumeric(ew_Get(EW_TABLE_PAGE_NO)) Then
  1058.                 nPageNo = ew_ConvertToInt(ew_Get(EW_TABLE_PAGE_NO))
  1059.                 lStartRec = (nPageNo-1)*lDisplayRecs+1
  1060.                 If lStartRec <= 0 Then
  1061.                     lStartRec = 1
  1062.                 ElseIf lStartRec >= ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1 Then
  1063.                     lStartRec = ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1
  1064.                 End If
  1065.                 tblSchedule.StartRecordNumber = lStartRec
  1066.             End If
  1067.         End If
  1068.         lStartRec = tblSchedule.StartRecordNumber
  1069.  
  1070.         ' Check if correct start record counter
  1071.         If lStartRec <= 0 Then ' Avoid invalid start record counter
  1072.             lStartRec = 1 ' Reset start record counter
  1073.             tblSchedule.StartRecordNumber = lStartRec
  1074.         ElseIf lStartRec > lTotalRecs Then ' Avoid starting record > total records
  1075.             lStartRec = ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1 ' Point to last page first record
  1076.             tblSchedule.StartRecordNumber = lStartRec
  1077.         ElseIf (lStartRec-1) Mod lDisplayRecs <> 0 Then
  1078.             lStartRec = ((lStartRec-1)\lDisplayRecs)*lDisplayRecs+1 ' Point to page boundary
  1079.             tblSchedule.StartRecordNumber = lStartRec
  1080.         End If
  1081.     End Sub
  1082.  
  1083.     '
  1084.     ' Load default values
  1085.     '
  1086.     Sub LoadDefaultValues()
  1087.             '        tblSchedule.schDoubleBooked.CurrentValue = 0
  1088.         End Sub
  1089.  
  1090.     '
  1091.     '  Load search values for validation
  1092.     '
  1093.     Sub LoadSearchValues()
  1094.         tblSchedule.schDate.AdvancedSearch.SearchValue = ew_Get("x_schDate")
  1095.         tblSchedule.schDate.AdvancedSearch.SearchOperator = ew_Get("z_schDate")
  1096.         tblSchedule.schDate.AdvancedSearch.SearchCondition = ew_Get("v_schDate")
  1097.         tblSchedule.schDate.AdvancedSearch.SearchValue2 = ew_Get("y_schDate")
  1098.         tblSchedule.schDate.AdvancedSearch.SearchOperator2 = ew_Get("w_schDate")
  1099.         tblSchedule.schEvtID.AdvancedSearch.SearchValue = ew_Get("x_schEvtID")
  1100.         tblSchedule.schEvtID.AdvancedSearch.SearchOperator = ew_Get("z_schEvtID")
  1101.         tblSchedule.schPartsID.AdvancedSearch.SearchValue = ew_Get("x_schPartsID")
  1102.         tblSchedule.schPartsID.AdvancedSearch.SearchOperator = ew_Get("z_schPartsID")
  1103.         tblSchedule.schCallTime.AdvancedSearch.SearchValue = ew_Get("x_schCallTime")
  1104.         tblSchedule.schCallTime.AdvancedSearch.SearchOperator = ew_Get("z_schCallTime")
  1105.         tblSchedule.schStartTime.AdvancedSearch.SearchValue = ew_Get("x_schStartTime")
  1106.         tblSchedule.schStartTime.AdvancedSearch.SearchOperator = ew_Get("z_schStartTime")
  1107.         tblSchedule.schEndTime.AdvancedSearch.SearchValue = ew_Get("x_schEndTime")
  1108.         tblSchedule.schEndTime.AdvancedSearch.SearchOperator = ew_Get("z_schEndTime")
  1109.         tblSchedule.schOutTime.AdvancedSearch.SearchValue = ew_Get("x_schOutTime")
  1110.         tblSchedule.schOutTime.AdvancedSearch.SearchOperator = ew_Get("z_schOutTime")
  1111.         tblSchedule.schLocID.AdvancedSearch.SearchValue = ew_Get("x_schLocID")
  1112.         tblSchedule.schLocID.AdvancedSearch.SearchOperator = ew_Get("z_schLocID")
  1113.         tblSchedule.schEmpID.AdvancedSearch.SearchValue = ew_Get("x_schEmpID")
  1114.         tblSchedule.schEmpID.AdvancedSearch.SearchOperator = ew_Get("z_schEmpID")
  1115.         tblSchedule.schPosID.AdvancedSearch.SearchValue = ew_Get("x_schPosID")
  1116.         tblSchedule.schPosID.AdvancedSearch.SearchOperator = ew_Get("z_schPosID")
  1117.         tblSchedule.schTypID.AdvancedSearch.SearchValue = ew_Get("x_schTypID")
  1118.         tblSchedule.schTypID.AdvancedSearch.SearchOperator = ew_Get("z_schTypID")
  1119.         tblSchedule.schDepID.AdvancedSearch.SearchValue = ew_Get("x_schDepID")
  1120.         tblSchedule.schDepID.AdvancedSearch.SearchOperator = ew_Get("z_schDepID")
  1121.         tblSchedule.schNotes.AdvancedSearch.SearchValue = ew_Get("x_schNotes")
  1122.         tblSchedule.schNotes.AdvancedSearch.SearchOperator = ew_Get("z_schNotes")
  1123.         tblSchedule.schRate.AdvancedSearch.SearchValue = ew_Get("x_schRate")
  1124.         tblSchedule.schRate.AdvancedSearch.SearchOperator = ew_Get("z_schRate")
  1125.         tblSchedule.schActualStart.AdvancedSearch.SearchValue = ew_Get("x_schActualStart")
  1126.         tblSchedule.schActualStart.AdvancedSearch.SearchOperator = ew_Get("z_schActualStart")
  1127.         tblSchedule.schActualEnd.AdvancedSearch.SearchValue = ew_Get("x_schActualEnd")
  1128.         tblSchedule.schActualEnd.AdvancedSearch.SearchOperator = ew_Get("z_schActualEnd")
  1129.         tblSchedule.schDateCreated.AdvancedSearch.SearchValue = ew_Get("x_schDateCreated")
  1130.         tblSchedule.schDateCreated.AdvancedSearch.SearchOperator = ew_Get("z_schDateCreated")
  1131.             '        tblSchedule.schDoubleBooked.AdvancedSearch.SearchValue = ew_Get("x_schDoubleBooked")
  1132.             '        tblSchedule.schDoubleBooked.AdvancedSearch.SearchOperator = ew_Get("z_schDoubleBooked")
  1133.             tblSchedule.schStatus.AdvancedSearch.SearchValue = ew_Get("x_schStatus")
  1134.             tblSchedule.schStatus.AdvancedSearch.SearchOperator = ew_Get("z_schStatus")
  1135.             tblSchedule.schDayOfWeek.AdvancedSearch.SearchValue = ew_Get("x_schDayOfWeek")
  1136.             tblSchedule.schDayOfWeek.AdvancedSearch.SearchOperator = ew_Get("z_schDayOfWeek")
  1137.         End Sub
  1138.  
  1139.     '
  1140.     ' Load recordset
  1141.     '
  1142.     Function LoadRecordset() As OleDbDataReader
  1143.  
  1144.         ' Recordset Selecting event
  1145.         tblSchedule.Recordset_Selecting(tblSchedule.CurrentFilter)
  1146.  
  1147.         ' Load list page SQL
  1148.         Dim sSql As String = tblSchedule.ListSQL
  1149.  
  1150.         ' Write SQL for debug
  1151.         If EW_DEBUG_ENABLED Then ew_Write(sSql)
  1152.  
  1153.         ' Count
  1154.         lTotalRecs = -1        
  1155.         Try            
  1156.             If sSql.StartsWith("SELECT * FROM ", StringComparison.InvariantCultureIgnoreCase) AndAlso _                
  1157.                 ew_Empty(tblSchedule.SqlGroupBy) AndAlso _
  1158.                 ew_Empty(tblSchedule.SqlHaving) Then
  1159.                 Dim sCntSql As String = tblSchedule.SelectCountSQL
  1160.  
  1161.                 ' Write SQL for debug
  1162.                 If EW_DEBUG_ENABLED Then ew_Write("<br>" & sCntSql)
  1163.                 lTotalRecs = Conn.ExecuteScalar(sCntSql)
  1164.             End If            
  1165.         Catch
  1166.         End Try
  1167.  
  1168.         ' Load recordset
  1169.         Dim Rs As OleDbDataReader = Conn.GetDataReader(sSql)
  1170.         If lTotalRecs < 0 AndAlso Rs.HasRows Then
  1171.             lTotalRecs = 0
  1172.             While Rs.Read()
  1173.                 lTotalRecs = lTotalRecs + 1
  1174.             End While
  1175.             Rs.Close()        
  1176.             Rs = Conn.GetDataReader(sSql)
  1177.         End If
  1178.  
  1179.         ' Recordset Selected event
  1180.         tblSchedule.Recordset_Selected(Rs)
  1181.         Return Rs
  1182.     End Function
  1183.  
  1184.     '
  1185.     ' Load row based on key values
  1186.     '
  1187.     Function LoadRow() As Boolean
  1188.         Dim RsRow As OleDbDataReader
  1189.         Dim sFilter As String = tblSchedule.KeyFilter
  1190.  
  1191.         ' Row Selecting event
  1192.         tblSchedule.Row_Selecting(sFilter)
  1193.  
  1194.         ' Load SQL based on filter
  1195.         tblSchedule.CurrentFilter = sFilter
  1196.         Dim sSql As String = tblSchedule.SQL
  1197.  
  1198.         ' Write SQL for debug
  1199.         If EW_DEBUG_ENABLED Then ew_Write(sSql)
  1200.         Try
  1201.             RsRow = Conn.GetTempDataReader(sSql)    
  1202.             If Not RsRow.Read() Then
  1203.                 Return False
  1204.             Else                
  1205.                 LoadRowValues(RsRow) ' Load row values
  1206.  
  1207.                 ' Row Selected event
  1208.                 tblSchedule.Row_Selected(RsRow)
  1209.                 Return True    
  1210.             End If
  1211.         Catch
  1212.             If EW_DEBUG_ENABLED Then Throw
  1213.             Return False
  1214.         Finally
  1215.             Conn.CloseTempDataReader()
  1216.         End Try
  1217.     End Function
  1218.  
  1219.     '
  1220.     ' Load row values from recordset
  1221.     '
  1222.     Sub LoadRowValues(ByRef RsRow As OleDbDataReader)
  1223.         tblSchedule.schSchID.DbValue = RsRow("schSchID")
  1224.         tblSchedule.schDate.DbValue = RsRow("schDate")
  1225.         tblSchedule.schEvtID.DbValue = RsRow("schEvtID")
  1226.         tblSchedule.schPartsID.DbValue = RsRow("schPartsID")
  1227.         tblSchedule.schCallTime.DbValue = RsRow("schCallTime")
  1228.         tblSchedule.schStartTime.DbValue = RsRow("schStartTime")
  1229.         tblSchedule.schEndTime.DbValue = RsRow("schEndTime")
  1230.         tblSchedule.schOutTime.DbValue = RsRow("schOutTime")
  1231.         tblSchedule.schLocID.DbValue = RsRow("schLocID")
  1232.         tblSchedule.schEmpID.DbValue = RsRow("schEmpID")
  1233.         tblSchedule.schPosID.DbValue = RsRow("schPosID")
  1234.         tblSchedule.schTypID.DbValue = RsRow("schTypID")
  1235.         tblSchedule.schDepID.DbValue = RsRow("schDepID")
  1236.         tblSchedule.schNotes.DbValue = RsRow("schNotes")
  1237.         tblSchedule.schRate.DbValue = RsRow("schRate")
  1238.         tblSchedule.schActualStart.DbValue = RsRow("schActualStart")
  1239.         tblSchedule.schActualEnd.DbValue = RsRow("schActualEnd")
  1240.         tblSchedule.schDateCreated.DbValue = RsRow("schDateCreated")
  1241.             '        tblSchedule.schDoubleBooked.DbValue = IIf(ew_ConvertToBool(RsRow("schDoubleBooked")), "1", "0")
  1242.             tblSchedule.schStatus.DbValue = RsRow("schStatus")
  1243.             tblSchedule.schDayOfWeek.DbValue = RsRow("schDayOfWeek")
  1244.         End Sub
  1245.  
  1246.     '
  1247.     ' Render row values based on field settings
  1248.     '
  1249.     Sub RenderRow()
  1250.  
  1251.         ' Row Rendering event
  1252.         tblSchedule.Row_Rendering()
  1253.  
  1254.         '
  1255.         '  Common render codes for all row types
  1256.         '
  1257.         ' schDate
  1258.  
  1259.         tblSchedule.schDate.CellCssStyle = ""
  1260.         tblSchedule.schDate.CellCssClass = ""
  1261.  
  1262.         ' schEvtID
  1263.         tblSchedule.schEvtID.CellCssStyle = ""
  1264.         tblSchedule.schEvtID.CellCssClass = ""
  1265.  
  1266.         ' schPartsID
  1267.         tblSchedule.schPartsID.CellCssStyle = ""
  1268.         tblSchedule.schPartsID.CellCssClass = ""
  1269.  
  1270.             ' schCallTime
  1271.             tblSchedule.schCallTime.CellCssStyle = ""
  1272.             tblSchedule.schCallTime.CellCssClass = ""
  1273.  
  1274.             ' schNotes
  1275.             tblSchedule.schNotes.CellCssStyle = ""
  1276.             tblSchedule.schNotes.CellCssClass = ""
  1277.  
  1278.             ' schStartTime
  1279.         tblSchedule.schStartTime.CellCssStyle = ""
  1280.         tblSchedule.schStartTime.CellCssClass = ""
  1281.  
  1282.         ' schEndTime
  1283.         tblSchedule.schEndTime.CellCssStyle = ""
  1284.         tblSchedule.schEndTime.CellCssClass = ""
  1285.  
  1286.         ' schOutTime
  1287.         tblSchedule.schOutTime.CellCssStyle = ""
  1288.         tblSchedule.schOutTime.CellCssClass = ""
  1289.  
  1290.         ' schLocID
  1291.         tblSchedule.schLocID.CellCssStyle = ""
  1292.         tblSchedule.schLocID.CellCssClass = ""
  1293.  
  1294.         ' schEmpID
  1295.         tblSchedule.schEmpID.CellCssStyle = ""
  1296.         tblSchedule.schEmpID.CellCssClass = ""
  1297.  
  1298.         ' schPosID
  1299.         tblSchedule.schPosID.CellCssStyle = ""
  1300.         tblSchedule.schPosID.CellCssClass = ""
  1301.  
  1302.             ' schTypID
  1303.             tblSchedule.schTypID.CellCssStyle = ""
  1304.             tblSchedule.schTypID.CellCssClass = ""
  1305.  
  1306.             ' schTypID
  1307.             tblSchedule.schDepID.CellCssStyle = ""
  1308.             tblSchedule.schDepID.CellCssClass = ""
  1309.  
  1310.             ' schActualStart
  1311.         tblSchedule.schActualStart.CellCssStyle = ""
  1312.         tblSchedule.schActualStart.CellCssClass = ""
  1313.  
  1314.         ' schActualEnd
  1315.         tblSchedule.schActualEnd.CellCssStyle = ""
  1316.         tblSchedule.schActualEnd.CellCssClass = ""
  1317.  
  1318.         ' schDoubleBooked
  1319.             '        tblSchedule.schDoubleBooked.CellCssStyle = ""
  1320.             '        tblSchedule.schDoubleBooked.CellCssClass = ""
  1321.  
  1322.             ' schStatus
  1323.             tblSchedule.schStatus.CellCssStyle = ""
  1324.             tblSchedule.schStatus.CellCssClass = ""
  1325.  
  1326.             ' schDayOfWeek
  1327.             tblSchedule.schDayOfWeek.CellCssStyle = ""
  1328.             tblSchedule.schDayOfWeek.CellCssClass = ""
  1329.  
  1330.             '
  1331.         '  View  Row
  1332.         '
  1333.  
  1334.         If tblSchedule.RowType = EW_ROWTYPE_VIEW Then ' View row
  1335.  
  1336.             ' schDate
  1337.             tblSchedule.schDate.ViewValue = tblSchedule.schDate.CurrentValue
  1338.             tblSchedule.schDate.ViewValue = ew_FormatDateTime(tblSchedule.schDate.ViewValue, 6)
  1339.             tblSchedule.schDate.CssStyle = ""
  1340.             tblSchedule.schDate.CssClass = ""
  1341.             tblSchedule.schDate.ViewCustomAttributes = ""
  1342.  
  1343.             ' schEvtID
  1344.             If ew_NotEmpty(tblSchedule.schEvtID.CurrentValue) Then
  1345.                     sSqlWrk = "SELECT [evtDescription] FROM [tblEvents] WHERE [evtID] = " & ew_AdjustSql(tblSchedule.schEvtID.CurrentValue) & " AND [evtIsActive]=True"
  1346.                 sSqlWrk = sSqlWrk & " ORDER BY [evtDescription] "
  1347.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  1348.                 If RsWrk.Read() Then
  1349.                     tblSchedule.schEvtID.ViewValue = RsWrk("evtDescription")
  1350.                 Else
  1351.                     tblSchedule.schEvtID.ViewValue = tblSchedule.schEvtID.CurrentValue
  1352.                 End If
  1353.                 Conn.CloseTempDataReader()
  1354.             Else
  1355.                 tblSchedule.schEvtID.ViewValue = System.DBNull.Value
  1356.             End If
  1357.             tblSchedule.schEvtID.CssStyle = ""
  1358.             tblSchedule.schEvtID.CssClass = ""
  1359.             tblSchedule.schEvtID.ViewCustomAttributes = ""
  1360.  
  1361.             ' schPartsID
  1362.             If ew_NotEmpty(tblSchedule.schPartsID.CurrentValue) Then
  1363.                     sSqlWrk = "SELECT [prtDescription] FROM [tblParts] WHERE [prtID] = " & ew_AdjustSql(tblSchedule.schPartsID.CurrentValue) & " AND [prtIsActive]=True"
  1364.                 sSqlWrk = sSqlWrk & " ORDER BY [prtDescription] "
  1365.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  1366.                 If RsWrk.Read() Then
  1367.                     tblSchedule.schPartsID.ViewValue = RsWrk("prtDescription")
  1368.                 Else
  1369.                     tblSchedule.schPartsID.ViewValue = tblSchedule.schPartsID.CurrentValue
  1370.                 End If
  1371.                 Conn.CloseTempDataReader()
  1372.             Else
  1373.                 tblSchedule.schPartsID.ViewValue = System.DBNull.Value
  1374.             End If
  1375.             tblSchedule.schPartsID.CssStyle = ""
  1376.             tblSchedule.schPartsID.CssClass = ""
  1377.             tblSchedule.schPartsID.ViewCustomAttributes = ""
  1378.  
  1379.             ' schCallTime
  1380.             tblSchedule.schCallTime.ViewValue = tblSchedule.schCallTime.CurrentValue
  1381.             tblSchedule.schCallTime.ViewValue = ew_FormatDateTime(tblSchedule.schCallTime.ViewValue, 14)
  1382.             tblSchedule.schCallTime.CssStyle = ""
  1383.             tblSchedule.schCallTime.CssClass = ""
  1384.             tblSchedule.schCallTime.ViewCustomAttributes = ""
  1385.  
  1386.             ' schStartTime
  1387.             tblSchedule.schStartTime.ViewValue = tblSchedule.schStartTime.CurrentValue
  1388.             tblSchedule.schStartTime.ViewValue = ew_FormatDateTime(tblSchedule.schStartTime.ViewValue, 14)
  1389.             tblSchedule.schStartTime.CssStyle = ""
  1390.             tblSchedule.schStartTime.CssClass = ""
  1391.             tblSchedule.schStartTime.ViewCustomAttributes = ""
  1392.  
  1393.             ' schEndTime
  1394.             tblSchedule.schEndTime.ViewValue = tblSchedule.schEndTime.CurrentValue
  1395.             tblSchedule.schEndTime.ViewValue = ew_FormatDateTime(tblSchedule.schEndTime.ViewValue, 14)
  1396.             tblSchedule.schEndTime.CssStyle = ""
  1397.             tblSchedule.schEndTime.CssClass = ""
  1398.             tblSchedule.schEndTime.ViewCustomAttributes = ""
  1399.  
  1400.             ' schOutTime
  1401.             tblSchedule.schOutTime.ViewValue = tblSchedule.schOutTime.CurrentValue
  1402.             tblSchedule.schOutTime.ViewValue = ew_FormatDateTime(tblSchedule.schOutTime.ViewValue, 14)
  1403.             tblSchedule.schOutTime.CssStyle = ""
  1404.             tblSchedule.schOutTime.CssClass = ""
  1405.             tblSchedule.schOutTime.ViewCustomAttributes = ""
  1406.  
  1407.             ' schLocID
  1408.             If ew_NotEmpty(tblSchedule.schLocID.CurrentValue) Then
  1409.                     sSqlWrk = "SELECT [locDescription] FROM [tblLocations] WHERE [locID] = " & ew_AdjustSql(tblSchedule.schLocID.CurrentValue) & " AND [locIsActive]=True"
  1410.                 sSqlWrk = sSqlWrk & " ORDER BY [locDescription] "
  1411.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  1412.                 If RsWrk.Read() Then
  1413.                     tblSchedule.schLocID.ViewValue = RsWrk("locDescription")
  1414.                 Else
  1415.                     tblSchedule.schLocID.ViewValue = tblSchedule.schLocID.CurrentValue
  1416.                 End If
  1417.                 Conn.CloseTempDataReader()
  1418.             Else
  1419.                 tblSchedule.schLocID.ViewValue = System.DBNull.Value
  1420.             End If
  1421.             tblSchedule.schLocID.CssStyle = ""
  1422.             tblSchedule.schLocID.CssClass = ""
  1423.             tblSchedule.schLocID.ViewCustomAttributes = ""
  1424.  
  1425.             ' schEmpID
  1426.             If ew_NotEmpty(tblSchedule.schEmpID.CurrentValue) Then
  1427.                     sSqlWrk = "SELECT [empName] FROM [tblEmployees] WHERE [empID] = " & ew_AdjustSql(tblSchedule.schEmpID.CurrentValue) & " AND [empIsActive]=True"
  1428.                 sSqlWrk = sSqlWrk & " ORDER BY [empFirstName] "
  1429.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  1430.                 If RsWrk.Read() Then
  1431.                     tblSchedule.schEmpID.ViewValue = RsWrk("empName")
  1432.                 Else
  1433.                     tblSchedule.schEmpID.ViewValue = tblSchedule.schEmpID.CurrentValue
  1434.                 End If
  1435.                 Conn.CloseTempDataReader()
  1436.             Else
  1437.                 tblSchedule.schEmpID.ViewValue = System.DBNull.Value
  1438.             End If
  1439.             tblSchedule.schEmpID.CssStyle = ""
  1440.             tblSchedule.schEmpID.CssClass = ""
  1441.             tblSchedule.schEmpID.ViewCustomAttributes = ""
  1442.  
  1443.             ' schPosID
  1444.             If ew_NotEmpty(tblSchedule.schPosID.CurrentValue) Then
  1445.                     sSqlWrk = "SELECT [posDescription] FROM [tblPositions] WHERE [posID] = " & ew_AdjustSql(tblSchedule.schPosID.CurrentValue) & " AND [posIsActive]=True"
  1446.                 sSqlWrk = sSqlWrk & " ORDER BY [posDescription] "
  1447.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  1448.                 If RsWrk.Read() Then
  1449.                     tblSchedule.schPosID.ViewValue = RsWrk("posDescription")
  1450.                 Else
  1451.                     tblSchedule.schPosID.ViewValue = tblSchedule.schPosID.CurrentValue
  1452.                 End If
  1453.                 Conn.CloseTempDataReader()
  1454.             Else
  1455.                 tblSchedule.schPosID.ViewValue = System.DBNull.Value
  1456.             End If
  1457.             tblSchedule.schPosID.CssStyle = ""
  1458.             tblSchedule.schPosID.CssClass = ""
  1459.             tblSchedule.schPosID.ViewCustomAttributes = ""
  1460.  
  1461.                 ' schTypID
  1462.                 If ew_NotEmpty(tblSchedule.schTypID.CurrentValue) Then
  1463.                     sSqlWrk = "SELECT [typDescription] FROM [tblTypes] WHERE [typID] = " & ew_AdjustSql(tblSchedule.schTypID.CurrentValue) & " AND [typIsActive]=True"
  1464.                     sSqlWrk = sSqlWrk & " ORDER BY [typDescription] "
  1465.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  1466.                     If RsWrk.Read() Then
  1467.                         tblSchedule.schTypID.ViewValue = RsWrk("typDescription")
  1468.                     Else
  1469.                         tblSchedule.schTypID.ViewValue = tblSchedule.schTypID.CurrentValue
  1470.                     End If
  1471.                     Conn.CloseTempDataReader()
  1472.                 Else
  1473.                     tblSchedule.schTypID.ViewValue = System.DBNull.Value
  1474.                 End If
  1475.                 tblSchedule.schTypID.CssStyle = ""
  1476.                 tblSchedule.schTypID.CssClass = ""
  1477.                 tblSchedule.schTypID.ViewCustomAttributes = ""
  1478.  
  1479.                 ' schDepID
  1480.                 If ew_NotEmpty(tblSchedule.schDepID.CurrentValue) Then
  1481.                     sSqlWrk = "SELECT [depAcctCode] FROM [tblDepartments] WHERE [depID] = " & ew_AdjustSql(tblSchedule.schDepID.CurrentValue) & " AND [depIsActive]=True"
  1482.                     sSqlWrk = sSqlWrk & " ORDER BY [depAcctCode] "
  1483.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  1484.                     If RsWrk.Read() Then
  1485.                         tblSchedule.schDepID.ViewValue = RsWrk("depAcctCode")
  1486.                     Else
  1487.                         tblSchedule.schDepID.ViewValue = tblSchedule.schDepID.CurrentValue
  1488.                     End If
  1489.                     Conn.CloseTempDataReader()
  1490.                 Else
  1491.                     tblSchedule.schDepID.ViewValue = System.DBNull.Value
  1492.                 End If
  1493.                 tblSchedule.schDepID.CssStyle = ""
  1494.                 tblSchedule.schDepID.CssClass = ""
  1495.                 tblSchedule.schDepID.ViewCustomAttributes = ""
  1496.  
  1497.                 ' schActualStart
  1498.             tblSchedule.schActualStart.ViewValue = tblSchedule.schActualStart.CurrentValue
  1499.             tblSchedule.schActualStart.ViewValue = ew_FormatDateTime(tblSchedule.schActualStart.ViewValue, 14)
  1500.             tblSchedule.schActualStart.CssStyle = ""
  1501.             tblSchedule.schActualStart.CssClass = ""
  1502.             tblSchedule.schActualStart.ViewCustomAttributes = ""
  1503.  
  1504.             ' schActualEnd
  1505.             tblSchedule.schActualEnd.ViewValue = tblSchedule.schActualEnd.CurrentValue
  1506.             tblSchedule.schActualEnd.ViewValue = ew_FormatDateTime(tblSchedule.schActualEnd.ViewValue, 14)
  1507.             tblSchedule.schActualEnd.CssStyle = ""
  1508.             tblSchedule.schActualEnd.CssClass = ""
  1509.             tblSchedule.schActualEnd.ViewCustomAttributes = ""
  1510.  
  1511.                 '' schDoubleBooked
  1512.                 'If Convert.ToString(tblSchedule.schDoubleBooked.CurrentValue) = "1" Then
  1513.                 '    tblSchedule.schDoubleBooked.ViewValue = "Yes"
  1514.                 'Else
  1515.                 '    tblSchedule.schDoubleBooked.ViewValue = "No"
  1516.                 'End If
  1517.                 'tblSchedule.schDoubleBooked.CssStyle = ""
  1518.                 'tblSchedule.schDoubleBooked.CssClass = ""
  1519.                 'tblSchedule.schDoubleBooked.ViewCustomAttributes = ""
  1520.  
  1521.             ' schStatus
  1522.             If ew_NotEmpty(tblSchedule.schStatus.CurrentValue) Then
  1523.                 sSqlWrk = "SELECT [stDescription] FROM [tblScheduleStatus] WHERE [stID] = " & ew_AdjustSql(tblSchedule.schStatus.CurrentValue) & ""
  1524.                 sSqlWrk = sSqlWrk & " ORDER BY [stDescription] "
  1525.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  1526.                 If RsWrk.Read() Then
  1527.                     tblSchedule.schStatus.ViewValue = RsWrk("stDescription")
  1528.                 Else
  1529.                     tblSchedule.schStatus.ViewValue = tblSchedule.schStatus.CurrentValue
  1530.                 End If
  1531.                 Conn.CloseTempDataReader()
  1532.             Else
  1533.                 tblSchedule.schStatus.ViewValue = System.DBNull.Value
  1534.             End If
  1535.             tblSchedule.schStatus.CssStyle = ""
  1536.             tblSchedule.schStatus.CssClass = ""
  1537.             tblSchedule.schStatus.ViewCustomAttributes = ""
  1538.  
  1539.                 ' schDayOfWeek
  1540.                 If ew_NotEmpty(tblSchedule.schDayOfWeek.CurrentValue) Then
  1541.                     Select Case tblSchedule.schDayOfWeek.CurrentValue
  1542.                         Case "1"
  1543.                             tblSchedule.schDayOfWeek.ViewValue = "Sun"
  1544.                         Case "2"
  1545.                             tblSchedule.schDayOfWeek.ViewValue = "Mon"
  1546.                         Case "3"
  1547.                             tblSchedule.schDayOfWeek.ViewValue = "Tue"
  1548.                         Case "4"
  1549.                             tblSchedule.schDayOfWeek.ViewValue = "Wed"
  1550.                         Case "5"
  1551.                             tblSchedule.schDayOfWeek.ViewValue = "Thu"
  1552.                         Case "6"
  1553.                             tblSchedule.schDayOfWeek.ViewValue = "Fri"
  1554.                         Case "7"
  1555.                             tblSchedule.schDayOfWeek.ViewValue = "Sat"
  1556.                     End Select
  1557.                 Else
  1558.                     tblSchedule.schDayOfWeek.ViewValue = System.DBNull.Value
  1559.                 End If
  1560.                 tblSchedule.schDayOfWeek.CssStyle = ""
  1561.                 tblSchedule.schDayOfWeek.CssClass = ""
  1562.                 tblSchedule.schDayOfWeek.ViewCustomAttributes = ""
  1563.  
  1564.                 ' schNotes
  1565.                 tblSchedule.schNotes.ViewValue = tblSchedule.schNotes.CurrentValue
  1566.                 tblSchedule.schNotes.CssStyle = ""
  1567.                 tblSchedule.schNotes.CssClass = ""
  1568.                 tblSchedule.schNotes.ViewCustomAttributes = ""
  1569.  
  1570.                 ' View refer script
  1571.             ' schDate
  1572.  
  1573.             tblSchedule.schDate.HrefValue = ""
  1574.  
  1575.             ' schEvtID
  1576.             tblSchedule.schEvtID.HrefValue = ""
  1577.  
  1578.             ' schPartsID
  1579.             tblSchedule.schPartsID.HrefValue = ""
  1580.  
  1581.             ' schCallTime
  1582.             tblSchedule.schCallTime.HrefValue = ""
  1583.  
  1584.             ' schStartTime
  1585.             tblSchedule.schStartTime.HrefValue = ""
  1586.  
  1587.             ' schEndTime
  1588.             tblSchedule.schEndTime.HrefValue = ""
  1589.  
  1590.             ' schOutTime
  1591.             tblSchedule.schOutTime.HrefValue = ""
  1592.  
  1593.             ' schLocID
  1594.             tblSchedule.schLocID.HrefValue = ""
  1595.  
  1596.             ' schEmpID
  1597.             tblSchedule.schEmpID.HrefValue = ""
  1598.  
  1599.             ' schPosID
  1600.             tblSchedule.schPosID.HrefValue = ""
  1601.  
  1602.                 ' schTypID
  1603.                 tblSchedule.schTypID.HrefValue = ""
  1604.  
  1605.                 ' schDepID
  1606.                 tblSchedule.schDepID.HrefValue = ""
  1607.  
  1608.                 ' schActualStart
  1609.             tblSchedule.schActualStart.HrefValue = ""
  1610.  
  1611.             ' schActualEnd
  1612.             tblSchedule.schActualEnd.HrefValue = ""
  1613.  
  1614.             ' schDoubleBooked
  1615.                 '            tblSchedule.schDoubleBooked.HrefValue = ""
  1616.  
  1617.                 ' schStatus
  1618.                 tblSchedule.schStatus.HrefValue = ""
  1619.  
  1620.                 ' schDayOfWeek
  1621.                 tblSchedule.schDayOfWeek.HrefValue = ""
  1622.  
  1623.                 ' schNotes
  1624.                 tblSchedule.schNotes.HrefValue = ""
  1625.  
  1626.                 '
  1627.         '  Search Row
  1628.         '
  1629.  
  1630.         ElseIf tblSchedule.RowType = EW_ROWTYPE_SEARCH Then ' Search row
  1631.  
  1632.             ' schDate
  1633.             tblSchedule.schDate.EditCustomAttributes = ""
  1634.             tblSchedule.schDate.EditValue = tblSchedule.schDate.AdvancedSearch.SearchValue
  1635.             tblSchedule.schDate.EditCustomAttributes = ""
  1636.             tblSchedule.schDate.EditValue2 = tblSchedule.schDate.AdvancedSearch.SearchValue2
  1637.  
  1638.                 ' schEvtID
  1639.                 tblSchedule.schEvtID.EditCustomAttributes = ""
  1640.                 sSqlWrk = "SELECT [evtID], [evtDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblEvents]"
  1641.                 sWhereWrk = "[evtIsActive]=True"
  1642.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1643.                 sSqlWrk = sSqlWrk & " ORDER BY [evtDescription] "
  1644.                 arwrk = Conn.GetRows(sSqlWrk)
  1645.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  1646.                 tblSchedule.schEvtID.EditValue = arwrk
  1647.  
  1648.                 ' schTypID
  1649.                 tblSchedule.schTypID.EditCustomAttributes = ""
  1650.                 sSqlWrk = "SELECT [typID], [typDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblTypes]"
  1651.                 sWhereWrk = "[typIsActive]=True"
  1652.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1653.                 sSqlWrk = sSqlWrk & " ORDER BY [typDescription] "
  1654.                 arwrk = Conn.GetRows(sSqlWrk)
  1655.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  1656.                 tblSchedule.schTypID.EditValue = arwrk
  1657.  
  1658.                 ' schDepID
  1659.                 tblSchedule.schDepID.EditCustomAttributes = ""
  1660.                 sSqlWrk = "SELECT [depID], [depAcctCode] + ' ' + [depDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblDepartments]"
  1661.                 sWhereWrk = "[depIsActive]=True"
  1662.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1663.                 sSqlWrk = sSqlWrk & " ORDER BY [depID] "
  1664.                 arwrk = Conn.GetRows(sSqlWrk)
  1665.                 arwrk.Insert(0, New Object() {"", "Please Select", ""})
  1666.                 tblSchedule.schDepID.EditValue = arwrk
  1667.                 ew_Session("sSqlWrk=") = sSqlWrk
  1668.  
  1669.                 ' schPosID
  1670.                 tblSchedule.schPosID.EditCustomAttributes = ""
  1671.                 sSqlWrk = "SELECT [posID], [posDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblPositions]"
  1672.                 sWhereWrk = "[posIsActive]=True"
  1673.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1674.                 sSqlWrk = sSqlWrk & " ORDER BY [posDescription] "
  1675.                 arwrk = Conn.GetRows(sSqlWrk)
  1676.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  1677.                 tblSchedule.schPosID.EditValue = arwrk
  1678.  
  1679.                 ' schPartsID
  1680.             tblSchedule.schPartsID.EditCustomAttributes = ""
  1681.             sSqlWrk = "SELECT [prtID], [prtDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblParts]"
  1682.                 sWhereWrk = "[prtIsActive]=True"
  1683.             If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1684.             sSqlWrk = sSqlWrk & " ORDER BY [prtDescription] "
  1685.             arwrk = Conn.GetRows(sSqlWrk)
  1686.             arwrk.Insert(0, New Object(){"", "Please Select"}) 
  1687.             tblSchedule.schPartsID.EditValue = arwrk
  1688.  
  1689.             ' schCallTime
  1690.             tblSchedule.schCallTime.EditCustomAttributes = ""
  1691.             tblSchedule.schCallTime.EditValue = tblSchedule.schCallTime.AdvancedSearch.SearchValue
  1692.  
  1693.             ' schStartTime
  1694.             tblSchedule.schStartTime.EditCustomAttributes = ""
  1695.             tblSchedule.schStartTime.EditValue = tblSchedule.schStartTime.AdvancedSearch.SearchValue
  1696.  
  1697.             ' schEndTime
  1698.             tblSchedule.schEndTime.EditCustomAttributes = ""
  1699.             tblSchedule.schEndTime.EditValue = tblSchedule.schEndTime.AdvancedSearch.SearchValue
  1700.  
  1701.             ' schOutTime
  1702.             tblSchedule.schOutTime.EditCustomAttributes = ""
  1703.             tblSchedule.schOutTime.EditValue = tblSchedule.schOutTime.AdvancedSearch.SearchValue
  1704.  
  1705.             ' schLocID
  1706.             tblSchedule.schLocID.EditCustomAttributes = ""
  1707.             sSqlWrk = "SELECT [locID], [locDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblLocations]"
  1708.                 sWhereWrk = "[locIsActive]=True"
  1709.             If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1710.             sSqlWrk = sSqlWrk & " ORDER BY [locDescription] "
  1711.             arwrk = Conn.GetRows(sSqlWrk)
  1712.             arwrk.Insert(0, New Object(){"", "Please Select"}) 
  1713.             tblSchedule.schLocID.EditValue = arwrk
  1714.  
  1715.             ' schEmpID
  1716.             tblSchedule.schEmpID.EditCustomAttributes = ""
  1717.                 If Not Security.IsAdmin And Security.IsLoggedIn() And ew_Session("tfpssnet_Status_UserLevel") <> 4 Then ' Non system admin
  1718.                     tblSchedule.schEmpID.AdvancedSearch.SearchValue = Security.CurrentUserID
  1719.                     If ew_NotEmpty(tblSchedule.schEmpID.AdvancedSearch.SearchValue) Then
  1720.                         sSqlWrk = "SELECT [empName] FROM [tblEmployees] WHERE [empID] = " & ew_AdjustSql(tblSchedule.schEmpID.AdvancedSearch.SearchValue) & " AND [empIsActive]=True"
  1721.                         sSqlWrk = sSqlWrk & " ORDER BY [empFirstName] "
  1722.                         RsWrk = Conn.GetTempDataReader(sSqlWrk)
  1723.                         If RsWrk.Read() Then
  1724.                             tblSchedule.schEmpID.EditValue = RsWrk("empName")
  1725.                         Else
  1726.                             tblSchedule.schEmpID.EditValue = tblSchedule.schEmpID.AdvancedSearch.SearchValue
  1727.                         End If
  1728.                         Conn.CloseTempDataReader()
  1729.                     Else
  1730.                         tblSchedule.schEmpID.EditValue = System.DBNull.Value
  1731.                     End If
  1732.                     tblSchedule.schEmpID.CssStyle = ""
  1733.                     tblSchedule.schEmpID.CssClass = ""
  1734.                     tblSchedule.schEmpID.ViewCustomAttributes = ""
  1735.                 Else
  1736.                     sSqlWrk = "SELECT [empID], [empName], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblEmployees]"
  1737.                     sWhereWrk = "[empIsActive]=True"
  1738.                     If ew_Session("tfpssnet_Status_UserLevel") <> 4 Then
  1739.                         sWhereWrk = tblEmployees.AddUserIDFilter(sWhereWrk)
  1740.                     End If
  1741.                     If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1742.                     sSqlWrk = sSqlWrk & " ORDER BY [empFirstName] "
  1743.                     arwrk = Conn.GetRows(sSqlWrk)
  1744.                     arwrk.Insert(0, New Object() {"", "Please Select"})
  1745.                     tblSchedule.schEmpID.EditValue = arwrk
  1746.                     End If
  1747.  
  1748.                 ' schPosID
  1749.                 tblSchedule.schPosID.EditCustomAttributes = ""
  1750.                 sSqlWrk = "SELECT [posID], [posDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblPositions]"
  1751.                 sWhereWrk = "[posIsActive]=True"
  1752.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1753.                 sSqlWrk = sSqlWrk & " ORDER BY [posDescription] "
  1754.                 arwrk = Conn.GetRows(sSqlWrk)
  1755.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  1756.                 tblSchedule.schPosID.EditValue = arwrk
  1757.  
  1758.                 ' schTypID
  1759.                 tblSchedule.schTypID.EditCustomAttributes = ""
  1760.                 sSqlWrk = "SELECT [typID], [typDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblTypes]"
  1761.                 sWhereWrk = "[typIsActive]=True"
  1762.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1763.                 sSqlWrk = sSqlWrk & " ORDER BY [typDescription] "
  1764.                 arwrk = Conn.GetRows(sSqlWrk)
  1765.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  1766.                 tblSchedule.schTypID.EditValue = arwrk
  1767.  
  1768.                 ' schDepID
  1769.                 tblSchedule.schDepID.EditCustomAttributes = ""
  1770.                 sSqlWrk = "SELECT [depID], [depAcctCode] + ', ' + [depDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblDepartments]"
  1771.                 sWhereWrk = "[depIsActive]=True"
  1772.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1773.                 sSqlWrk = sSqlWrk & " ORDER BY [depID] "
  1774.                 arwrk = Conn.GetRows(sSqlWrk)
  1775.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  1776.                 tblSchedule.schDepID.EditValue = arwrk
  1777.  
  1778.                 ' schActualStart
  1779.                     tblSchedule.schActualStart.EditCustomAttributes = ""
  1780.                     tblSchedule.schActualStart.EditValue = tblSchedule.schActualStart.AdvancedSearch.SearchValue
  1781.  
  1782.                     ' schActualEnd
  1783.                     tblSchedule.schActualEnd.EditCustomAttributes = ""
  1784.                     tblSchedule.schActualEnd.EditValue = tblSchedule.schActualEnd.AdvancedSearch.SearchValue
  1785.  
  1786.                     ' schDoubleBooked
  1787.                     '            tblSchedule.schDoubleBooked.EditCustomAttributes = ""
  1788.  
  1789.                     ' schStatus
  1790.                     tblSchedule.schStatus.EditCustomAttributes = ""
  1791.                     sSqlWrk = "SELECT [stID], [stDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblScheduleStatus]"
  1792.                     sWhereWrk = "[stIsActive]=True"
  1793.                     If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  1794.                     sSqlWrk = sSqlWrk & " ORDER BY [stDescription] "
  1795.                     arwrk = Conn.GetRows(sSqlWrk)
  1796.                     arwrk.Insert(0, New Object() {"", "Please Select"})
  1797.                     tblSchedule.schStatus.EditValue = arwrk
  1798.  
  1799.                 ' schDayOfWeek
  1800.                 tblSchedule.schDayOfWeek.EditCustomAttributes = ""
  1801.                 arwrk = New ArrayList
  1802.                 arwrk.Add(New String() {"1", "Sun"})
  1803.                 arwrk.Add(New String() {"2", "Mon"})
  1804.                 arwrk.Add(New String() {"3", "Tue"})
  1805.                 arwrk.Add(New String() {"4", "Wed"})
  1806.                 arwrk.Add(New String() {"5", "Thu"})
  1807.                 arwrk.Add(New String() {"6", "Fri"})
  1808.                 arwrk.Add(New String() {"7", "Sat"})
  1809.                 arwrk.Insert(0, New String() {"", "Please Select"})
  1810.                 tblSchedule.schDayOfWeek.EditValue = arwrk
  1811.  
  1812.             End If
  1813.  
  1814.         ' Row Rendered event
  1815.         tblSchedule.Row_Rendered()
  1816.     End Sub
  1817.  
  1818.     '
  1819.     ' Validate search
  1820.     '
  1821.     Function ValidateSearch() As Boolean
  1822.  
  1823.         ' Initialize
  1824.         ParentPage.gsSearchError = ""
  1825.  
  1826.         ' Check if validation required
  1827.         If Not EW_SERVER_VALIDATE Then Return True ' Skip
  1828.         If Not ew_CheckUSDate(tblSchedule.schDate.AdvancedSearch.SearchValue) Then
  1829.             If ParentPage.gsSearchError <> "" Then ParentPage.gsSearchError = ParentPage.gsSearchError & "<br />"
  1830.             ParentPage.gsSearchError = ParentPage.gsSearchError & "Incorrect date, format = mm/dd/yyyy - Date"
  1831.         End If
  1832.         If Not ew_CheckUSDate(tblSchedule.schDate.AdvancedSearch.SearchValue2) Then
  1833.             If ParentPage.gsSearchError <> "" Then ParentPage.gsSearchError = ParentPage.gsSearchError & "<br />"
  1834.             ParentPage.gsSearchError = ParentPage.gsSearchError & "Incorrect date, format = mm/dd/yyyy - Date"
  1835.         End If
  1836.  
  1837.         ' Return validate result    
  1838.         Dim Valid As Boolean = (ParentPage.gsSearchError = "")
  1839.  
  1840.         ' Form_CustomValidate event
  1841.         Dim sFormCustomError As String = ""
  1842.         Valid = Valid And Form_CustomValidate(sFormCustomError)
  1843.         If sFormCustomError <> "" Then
  1844.             If ParentPage.gsSearchError <> "" Then ParentPage.gsSearchError = ParentPage.gsSearchError & "<br />"
  1845.             ParentPage.gsSearchError = ParentPage.gsSearchError & sFormCustomError
  1846.         End If
  1847.         Return Valid
  1848.     End Function
  1849.  
  1850.     '
  1851.     ' Load advanced search
  1852.     '
  1853.     Sub LoadAdvancedSearch()
  1854.         tblSchedule.schDate.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schDate")
  1855.         tblSchedule.schDate.AdvancedSearch.SearchCondition = tblSchedule.GetAdvancedSearch("v_schDate")
  1856.         tblSchedule.schDate.AdvancedSearch.SearchValue2 = tblSchedule.GetAdvancedSearch("y_schDate")
  1857.         tblSchedule.schEvtID.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schEvtID")
  1858.         tblSchedule.schPartsID.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schPartsID")
  1859.         tblSchedule.schCallTime.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schCallTime")
  1860.         tblSchedule.schStartTime.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schStartTime")
  1861.         tblSchedule.schEndTime.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schEndTime")
  1862.         tblSchedule.schOutTime.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schOutTime")
  1863.         tblSchedule.schLocID.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schLocID")
  1864.         tblSchedule.schEmpID.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schEmpID")
  1865.         tblSchedule.schPosID.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schPosID")
  1866.         tblSchedule.schTypID.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schTypID")
  1867.         tblSchedule.schDepID.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schDepID")
  1868.         tblSchedule.schNotes.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schNotes")
  1869.         tblSchedule.schRate.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schRate")
  1870.         tblSchedule.schActualStart.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schActualStart")
  1871.         tblSchedule.schActualEnd.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schActualEnd")
  1872.         tblSchedule.schDateCreated.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schDateCreated")
  1873.             '        tblSchedule.schDoubleBooked.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schDoubleBooked")
  1874.             tblSchedule.schStatus.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schStatus")
  1875.             tblSchedule.schDayOfWeek.AdvancedSearch.SearchValue = tblSchedule.GetAdvancedSearch("x_schDayOfWeek")
  1876.         End Sub
  1877.  
  1878.     '
  1879.     ' Show link optionally based on user ID
  1880.     '
  1881.     Function ShowOptionLink() As Boolean        
  1882.         If Security.IsLoggedIn() AndAlso Not Security.IsAdmin() Then
  1883.             Return Security.IsValidUserID(tblSchedule.schEmpID.CurrentValue)
  1884.         End If
  1885.         Return True
  1886.     End Function
  1887.  
  1888.         ' Page Load event
  1889.         Public Sub Page_Load()
  1890.             'HttpContext.Current.Response.Write("Page Load")
  1891.         End Sub
  1892.  
  1893.         ' Page Unload event
  1894.         Public Sub Page_Unload()
  1895.  
  1896.             'HttpContext.Current.Response.Write("Page Unload")
  1897.         End Sub
  1898.  
  1899.     ' Form Custom Validate event
  1900.     Public Function Form_CustomValidate(ByRef CustomError As String) As Boolean
  1901.  
  1902.         'Return error message in CustomError
  1903.         Return True
  1904.     End Function
  1905.     End Class
  1906.  
  1907.     '
  1908.     ' ASP.NET Page_Load event
  1909.     '
  1910.  
  1911.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  1912.         Response.Buffer = EW_RESPONSE_BUFFER
  1913.         Response.Cache.SetCacheability(HttpCacheability.NoCache)
  1914.  
  1915.         ' Page init
  1916.         tblSchedule_list = New ctblSchedule_list(Me)        
  1917.         tblSchedule_list.Page_Init()
  1918.  
  1919.         ' Page main processing
  1920.         tblSchedule_list.Page_Main()
  1921.     End Sub
  1922.  
  1923.     '
  1924.     ' ASP.NET Page_Unload event
  1925.     '
  1926.  
  1927.     Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
  1928.  
  1929.         ' Dispose page object
  1930.         If tblSchedule_list IsNot Nothing Then tblSchedule_list.Dispose()
  1931.     End Sub
  1932. End Class
  1933.