home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / tblScheduledelete.aspx.vb < prev    next >
Text File  |  2014-12-14  |  32KB  |  924 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 tblScheduledelete
  17.     Inherits AspNetMaker7_tfpssnet
  18.  
  19.     ' Page object
  20.     Public tblSchedule_delete As ctblSchedule_delete
  21.  
  22.     '
  23.     ' Page Class
  24.     '
  25.     Class ctblSchedule_delete
  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 = "delete"
  90.             m_PageObjName = "tblSchedule_delete"
  91.             m_PageObjTypeName = "ctblSchedule_delete"
  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.         End Sub
  103.  
  104.         '
  105.         '  Subroutine Page_Init
  106.         '  - called before page main
  107.         '  - check Security
  108.         '  - set up response header
  109.         '  - call page load events
  110.         '
  111.         Public Sub Page_Init()
  112.             Security = New cAdvancedSecurity(Me)
  113.             If Not Security.IsLoggedIn() Then Security.AutoLogin()
  114.             If Not Security.IsLoggedIn() Then
  115.                 Security.SaveLastUrl()
  116.                 Page_Terminate("login.aspx")
  117.             End If
  118.  
  119.             ' Table Permission loading event
  120.             Security.TablePermission_Loading()
  121.             Security.LoadCurrentUserLevel(TableName)
  122.  
  123.             ' Table Permission loaded event
  124.             Security.TablePermission_Loaded()
  125.             If Not Security.CanDelete Then
  126.                 Security.SaveLastUrl()
  127.                 Page_Terminate("tblSchedulelist.aspx")
  128.             End If
  129.  
  130.             ' User ID loading event
  131.             Security.UserID_Loading()
  132.             If Security.IsLoggedIn() Then Call Security.LoadUserID()
  133.  
  134.             ' User ID loaded event
  135.             Security.UserID_Loaded()
  136.             If Security.IsLoggedIn() And ew_Empty(Security.CurrentUserID) Then
  137.                 Message = "You do not have the right permission to view the page"
  138.                 Page_Terminate("tblSchedulelist.aspx")
  139.             End If
  140.  
  141.             ' Global page loading event (in ewglobal*.vb)
  142.             ParentPage.Page_Loading()
  143.  
  144.             ' Page load event, used in current page
  145.             Page_Load()
  146.         End Sub
  147.  
  148.         '
  149.         '  Class terminate
  150.         '  - clean up page object
  151.         '
  152.         Public Sub Dispose() Implements IDisposable.Dispose
  153.             Page_Terminate("")
  154.         End Sub
  155.  
  156.         '
  157.         '  Sub Page_Terminate
  158.         '  - called when exit page
  159.         '  - clean up connection and objects
  160.         '  - if URL specified, redirect to URL
  161.         '
  162.         Sub Page_Terminate(url As String)
  163.  
  164.             ' Page unload event, used in current page
  165.             Page_Unload()
  166.  
  167.             ' Global page unloaded event (in ewglobal*.vb)
  168.             ParentPage.Page_Unloaded()
  169.  
  170.             ' Close connection
  171.             Conn.Dispose()
  172.             Security = Nothing
  173.             tblSchedule.Dispose()
  174.             tblEmployees.Dispose()
  175.  
  176.             ' Go to URL if specified
  177.             If url <> "" Then
  178.                 HttpContext.Current.Response.Clear()
  179.                 HttpContext.Current.Response.Redirect(url)
  180.             End If
  181.         End Sub
  182.  
  183.     Public lTotalRecs As Integer
  184.  
  185.     Public lRecCnt As Integer
  186.  
  187.     Public arRecKeys() As String
  188.  
  189.     '
  190.     ' Page main processing
  191.         '
  192.         Public PSSSendEmailConfirmation As Boolean
  193.  
  194.         Public PSSSyncExchangeCalendar As Boolean
  195.  
  196.         Sub Page_Main()
  197.             Dim tlcsub As New AspNetMaker7_tfpssnet
  198.             PSSSendEmailConfirmation = tlcsub.tlcGetPSSEmailConfirmation()
  199.             PSSSyncExchangeCalendar = tlcsub.tlcGetPSSUpdateExchangeCalendar()
  200.  
  201.             Dim sKey As String = ""
  202.             Dim bSingleDelete As Boolean = True ' Initialize as single delete
  203.             Dim nKeySelected As Integer = 0 ' Initialize selected key count
  204.             Dim sKeyFld As String, arKeyFlds() As String
  205.             Dim sFilter As String
  206.  
  207.             ' Load Key Parameters
  208.             If ew_Get("schSchID") <> "" Then
  209.                 tblSchedule.schSchID.QueryStringValue = ew_Get("schSchID")
  210.                 If Not IsNumeric(tblSchedule.schSchID.QueryStringValue) Then
  211.                     Page_Terminate("tblSchedulelist.aspx") ' Prevent SQL injection, return to list
  212.                 End If
  213.                 sKey = sKey & tblSchedule.schSchID.QueryStringValue
  214.             Else
  215.                 bSingleDelete = False
  216.             End If
  217.             If bSingleDelete Then
  218.                 nKeySelected = 1 ' Set up key selected count
  219.                 Array.Resize(arRecKeys, 1) ' Set up key
  220.                 arRecKeys(0) = sKey
  221.             Else
  222.                 If HttpContext.Current.Request.Form("key_m") IsNot Nothing Then ' Key in form
  223.                     arRecKeys = HttpContext.Current.Request.Form.GetValues("key_m")
  224.                     nKeySelected = arRecKeys.Length
  225.                 End If
  226.             End If
  227.             If nKeySelected <= 0 Then Page_Terminate("tblSchedulelist.aspx") ' No key specified, return to list
  228.  
  229.             ' Build filter
  230.             For i As Integer = 0 To arRecKeys.GetUpperBound(0)
  231.                 sKey = arRecKeys(i).Trim()
  232.                 sFilter = sFilter & "("
  233.  
  234.                 ' Set up key field
  235.                 sKeyFld = sKey
  236.                 If Not IsNumeric(sKeyFld) Then Page_Terminate("tblSchedulelist.aspx") ' Prevent SQL injection, return to list
  237.                 sFilter = sFilter & "[schSchID]=" & ew_AdjustSql(sKeyFld) & " AND "
  238.                 If sFilter.EndsWith(" AND ") Then sFilter = sFilter.Substring(0, sFilter.Length - 5) & ") OR "
  239.             Next
  240.             If sFilter.EndsWith(" OR ") Then sFilter = sFilter.Substring(0, sFilter.Length - 4)
  241.  
  242.             ' Set up filter (SQL WHERE clause)
  243.             ' SQL constructor in tblSchedule class, tblScheduleinfo.aspx
  244.  
  245.             tblSchedule.CurrentFilter = sFilter
  246.  
  247.             ' Get action
  248.             If ew_Post("a_delete") <> "" Then
  249.                 tblSchedule.CurrentAction = ew_Post("a_delete")
  250.             Else
  251.                 tblSchedule.CurrentAction = "I" ' Display record
  252.             End If
  253.             Select Case tblSchedule.CurrentAction
  254.                 Case "D" ' Delete
  255.                     tblSchedule.SendEmail = False ' Send email on delete success
  256.                     UpdateCalendarEntry()
  257.                     If DeleteRows() Then ' delete rows
  258.                         Message = "Delete succeeded" ' Set up success message
  259.                         Page_Terminate(tblSchedule.ReturnUrl) ' Return to caller
  260.                     End If
  261.             End Select
  262.         End Sub
  263.  
  264.         Sub UpdateCalendarEntry()
  265.             'Dim service As New ExchangeService(requestedServerVersion:=ExchangeVersion.Exchange2010)
  266.             Dim service As New ExchangeService(ExchangeVersion.Exchange2010_SP1)
  267.             Dim tmpSchDate As Date, tmpEvtDescription As String, tmpPrtDescription As String, tmpCallTime As Date
  268.             Dim tmpStartTime As Date, tmpEndTime As Date, tmpOutTime As Date, tmpLocDescription As String, tmpPosDescription As String, tmpStDescription As String
  269.             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
  270.             Dim intResult As Integer, tmpMessage As String, tmpNewStatus As String, smtpStatus As Boolean, smtpMessage As String
  271.             Dim tlcsub As New AspNetMaker7_tfpssnet
  272.             intResult = tlcsub.tlcGetEventInfo(tblSchedule.schSchID.CurrentValue, tmpSchDate, tmpEvtDescription, tmpPrtDescription, tmpCallTime, tmpStartTime, tmpEndTime, tmpOutTime, tmpLocDescription, tmpPosDescription, tmpStDescription, tmpTypDescription, tmpEmpName, tmpEmail, tmpStatus, tmpNotes)
  273.             Select Case tmpStatus
  274.                 Case "Confirmed"
  275.                     tmpAction = "A"
  276.                     tmpStatus = "BUSY"
  277.                     tmpType = "C"
  278.                     tmpNewStatus = "Confirmed"
  279.                     tmpStDescription = "Confirmed"
  280.                 Case "Unconfirmed"
  281.                     tmpAction = "D"
  282.                     tmpType = "U"
  283.                     tmpNewStatus = "Unconfirmed"
  284.                     tmpStDescription = "Unconfirmed"
  285.                 Case "Cannot Work"
  286.                     tmpAction = "D"
  287.                     tmpType = "X"
  288.                     tmpNewStatus = "Cannot Work"
  289.                     tmpStDescription = "Cannot Work"
  290.                 Case "Tentative"
  291.                     tmpAction = "A"
  292.                     tmpStatus = "TENTATIVE"
  293.                     tmpType = "T"
  294.                     tmpNewStatus = "Tentative"
  295.                     tmpStDescription = "Tentative"
  296.             End Select
  297.  
  298.             If InStr(tmpEmail, "@tfc.org") > 0 Then
  299.                 If PSSSendEmailConfirmation = True Or PSSSyncExchangeCalendar = True Then
  300.                     'Add a valid EWS service end point here or user Autodiscover
  301.                     'service.Url = New Uri("https://server14/ews/exchange.asmx")
  302.                     service.Url = New Uri("https://outlook.office365.com/EWS/Exchange.asmx")
  303.  
  304.                     'Add a valid user credentials
  305.                     'service.Credentials = New WebCredentials("prodservices", "production88", "Business")
  306.                     service.Credentials = New WebCredentials("productionservices@tfc.org", "production88")
  307.                     service.AutodiscoverUrl("productionservices@tfc.org", AddressOf RedirectionUrlValaditionCallBack)
  308.                     'To address the SSL challenge
  309.                     ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidateCertificate)
  310.  
  311.                     service.ImpersonatedUserId = New ImpersonatedUserId(ConnectingIdType.SmtpAddress, tmpEmail)
  312.                 End If
  313.             End If
  314.  
  315.             Try
  316.                 If InStr(tmpEmail, "@tfc.org") > 0 And PSSSyncExchangeCalendar = True Then
  317.                     'Create appointment object and set properties as required
  318.                     Dim appt As Appointment = New Appointment(service)
  319.                     appt.Subject = tmpEvtDescription & " - " & tmpPrtDescription
  320.                     'tmpBody = "Event: " & tmpEvtDescription & ", Part: " & tmpPrtDescription & ", Call Time: " & tmpCallTime & _
  321.                     '            ", Start Time: " & tmpStartTime & ", End Time: " & tmpEndTime & ", Out Time: " & tmpOutTime & ", Location: " & tmpLocDescription & _
  322.                     '            ", Position: " & tmpPosDescription & ", Type: " & tmpTypDescription & ", Status: " & tmpStDescription & ", Notes: " & tmpNotes
  323.                     tmpBody = "Position: " & tmpPosDescription & vbCrLf & "Notes: " & tmpNotes
  324.                     appt.Body = tmpBody
  325.                     appt.Location = tmpLocDescription
  326.                     appt.Start = tmpSchDate & " " & tmpCallTime
  327.                     If tmpOutTime = Nothing Then
  328.                         appt.End = tmpSchDate & " " & tmpStartTime.AddHours(1)
  329.                     Else
  330.                         appt.End = tmpSchDate & " " & tmpOutTime
  331.                     End If
  332.                     appt.IsReminderSet = False
  333.                     'find and delete entry
  334.                     Dim findResults As FindItemsResults(Of Appointment) = service.FindAppointments(WellKnownFolderName.Calendar, New CalendarView(tmpSchDate, tmpSchDate.AddHours(24)))
  335.                     Dim items As New List(Of Item)()
  336.                     For Each appointment As Appointment In findResults
  337.                         items.Add(appointment)
  338.                     Next
  339.                     If items.Count <> 0 Then
  340.                         service.LoadPropertiesForItems(items, PropertySet.FirstClassProperties)
  341.                         For Each Appointment As Appointment In items
  342.                             If Not Appointment.IsCancelled Then
  343.                                 If Appointment.Subject = tmpEvtDescription & " - " & tmpPrtDescription Or Appointment.Subject = tmpEvtDescription Then
  344.                                     Appointment.Delete(DeleteMode.HardDelete)
  345.                                     Message = "Old EWS Appointment deleted from Outlook calendar."
  346.                                 End If
  347.                             End If
  348.                         Next
  349.                     End If
  350.                 End If
  351.             Catch ex As Exception
  352.                 Message = ex.Message
  353.             End Try
  354.  
  355.         End Sub
  356.  
  357.         Private Function ValidateCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As SslPolicyErrors) As Boolean
  358.             'Return True to force the certificate to be accepted.
  359.             Return True
  360.         End Function
  361.  
  362.         Private Shared Function RedirectionUrlValaditionCallBack(ByVal redirectionURL As String) As Boolean
  363.             Dim result As Boolean = False
  364.             Dim redirectionuri As New Uri(redirectionURL)
  365.             If redirectionuri.Scheme = "https" Then
  366.                 result = True
  367.             End If
  368.             Return result
  369.         End Function
  370.  
  371.  
  372.         '
  373.         '  Function DeleteRows
  374.         '  - Delete Records based on current filter
  375.         '
  376.     Function DeleteRows() As Boolean
  377.         Dim sKey As String, sThisKey As String, sKeyFld As String
  378.         Dim arKeyFlds() As String
  379.         Dim RsDelete As OleDbDataReader = Nothing
  380.         Dim sSql As String, sWrkFilter As String 
  381.         Dim RsOld As ArrayList
  382.         DeleteRows = True
  383.         sWrkFilter = tblSchedule.CurrentFilter
  384.  
  385.         ' Set up filter (SQL WHERE Clause)
  386.         ' SQL constructor in tblSchedule class, tblScheduleinfo.aspx
  387.  
  388.         tblSchedule.CurrentFilter = sWrkFilter
  389.         sSql = tblSchedule.SQL
  390.         Conn.BeginTrans() ' Begin transaction
  391.         Try
  392.             RsDelete = Conn.GetDataReader(sSql)
  393.             If Not RsDelete.HasRows Then
  394.                 Message = "No records found" ' No record found
  395.                 RsDelete.Close()
  396.                 RsDelete.Dispose()                    
  397.                 Return False
  398.             End If
  399.         Catch e As Exception
  400.             If EW_DEBUG_ENABLED Then Throw
  401.             Message = e.Message
  402.             Return False
  403.         End Try
  404.  
  405.         ' Clone old rows
  406.         RsOld = Conn.GetRows(RsDelete)
  407.         RsDelete.Close()
  408.         RsDelete.Dispose()
  409.  
  410.         ' Call Row_Deleting event
  411.         If DeleteRows Then
  412.             For Each Row As OrderedDictionary in RsOld
  413.                 DeleteRows = tblSchedule.Row_Deleting(Row)
  414.                 If Not DeleteRows Then Exit For
  415.             Next Row
  416.         End If
  417.         If DeleteRows Then
  418.             sKey = ""
  419.             For Each Row As OrderedDictionary in RsOld
  420.                 sThisKey = ""
  421.                 If sThisKey <> "" Then sThisKey = sThisKey & EW_COMPOSITE_KEY_SEPARATOR
  422.                 sThisKey = sThisKey & Convert.ToString(Row("schSchID"))
  423.                 Try
  424.                     tblSchedule.Delete(Row)
  425.                 Catch e As Exception
  426.                     If EW_DEBUG_ENABLED Then Throw            
  427.                     Message = e.Message ' Set up error message
  428.                     DeleteRows = False
  429.                     Exit For
  430.                 End Try
  431.                 If sKey <> "" Then sKey = sKey & ", "
  432.                 sKey = sKey & sThisKey
  433.             Next Row
  434.         Else
  435.  
  436.             ' Set up error message
  437.             If tblSchedule.CancelMessage <> "" Then
  438.                 Message = tblSchedule.CancelMessage
  439.                 tblSchedule.CancelMessage = ""
  440.             Else
  441.                 Message = "Delete cancelled"
  442.             End If
  443.         End If
  444.         If DeleteRows Then
  445.  
  446.             ' Commit the changes
  447.             Conn.CommitTrans()                
  448.  
  449.             ' Row deleted event
  450.             For Each Row As OrderedDictionary in RsOld
  451.                 tblSchedule.Row_Deleted(Row)
  452.             Next
  453.         Else
  454.             Conn.RollbackTrans() ' Rollback transaction            
  455.         End If
  456.     End Function
  457.  
  458.     '
  459.     ' Load default values
  460.     '
  461.     Sub LoadDefaultValues()
  462.     End Sub
  463.  
  464.     '
  465.     ' Load recordset
  466.     '
  467.     Function LoadRecordset() As OleDbDataReader
  468.  
  469.         ' Recordset Selecting event
  470.         tblSchedule.Recordset_Selecting(tblSchedule.CurrentFilter)
  471.  
  472.         ' Load list page SQL
  473.         Dim sSql As String = tblSchedule.ListSQL
  474.  
  475.         ' Write SQL for debug
  476.         If EW_DEBUG_ENABLED Then ew_Write(sSql)
  477.  
  478.         ' Count
  479.         lTotalRecs = -1        
  480.         Try            
  481.             If sSql.StartsWith("SELECT * FROM ", StringComparison.InvariantCultureIgnoreCase) AndAlso _                
  482.                 ew_Empty(tblSchedule.SqlGroupBy) AndAlso _
  483.                 ew_Empty(tblSchedule.SqlHaving) Then
  484.                 Dim sCntSql As String = tblSchedule.SelectCountSQL
  485.  
  486.                 ' Write SQL for debug
  487.                 If EW_DEBUG_ENABLED Then ew_Write("<br>" & sCntSql)
  488.                 lTotalRecs = Conn.ExecuteScalar(sCntSql)
  489.             End If            
  490.         Catch
  491.         End Try
  492.  
  493.         ' Load recordset
  494.         Dim Rs As OleDbDataReader = Conn.GetDataReader(sSql)
  495.         If lTotalRecs < 0 AndAlso Rs.HasRows Then
  496.             lTotalRecs = 0
  497.             While Rs.Read()
  498.                 lTotalRecs = lTotalRecs + 1
  499.             End While
  500.             Rs.Close()        
  501.             Rs = Conn.GetDataReader(sSql)
  502.         End If
  503.  
  504.         ' Recordset Selected event
  505.         tblSchedule.Recordset_Selected(Rs)
  506.         Return Rs
  507.     End Function
  508.  
  509.     '
  510.     ' Load row based on key values
  511.     '
  512.     Function LoadRow() As Boolean
  513.         Dim RsRow As OleDbDataReader
  514.         Dim sFilter As String = tblSchedule.KeyFilter
  515.  
  516.         ' Row Selecting event
  517.         tblSchedule.Row_Selecting(sFilter)
  518.  
  519.         ' Load SQL based on filter
  520.         tblSchedule.CurrentFilter = sFilter
  521.         Dim sSql As String = tblSchedule.SQL
  522.  
  523.         ' Write SQL for debug
  524.         If EW_DEBUG_ENABLED Then ew_Write(sSql)
  525.         Try
  526.             RsRow = Conn.GetTempDataReader(sSql)    
  527.             If Not RsRow.Read() Then
  528.                 Return False
  529.             Else                
  530.                 LoadRowValues(RsRow) ' Load row values
  531.  
  532.                 ' Row Selected event
  533.                 tblSchedule.Row_Selected(RsRow)
  534.                 Return True    
  535.             End If
  536.         Catch
  537.             If EW_DEBUG_ENABLED Then Throw
  538.             Return False
  539.         Finally
  540.             Conn.CloseTempDataReader()
  541.         End Try
  542.     End Function
  543.  
  544.     '
  545.     ' Load row values from recordset
  546.     '
  547.     Sub LoadRowValues(ByRef RsRow As OleDbDataReader)
  548.         tblSchedule.schSchID.DbValue = RsRow("schSchID")
  549.         tblSchedule.schDate.DbValue = RsRow("schDate")
  550.         tblSchedule.schEvtID.DbValue = RsRow("schEvtID")
  551.         tblSchedule.schPartsID.DbValue = RsRow("schPartsID")
  552.         tblSchedule.schCallTime.DbValue = RsRow("schCallTime")
  553.         tblSchedule.schStartTime.DbValue = RsRow("schStartTime")
  554.         tblSchedule.schEndTime.DbValue = RsRow("schEndTime")
  555.         tblSchedule.schOutTime.DbValue = RsRow("schOutTime")
  556.         tblSchedule.schLocID.DbValue = RsRow("schLocID")
  557.         tblSchedule.schEmpID.DbValue = RsRow("schEmpID")
  558.         tblSchedule.schPosID.DbValue = RsRow("schPosID")
  559.         tblSchedule.schTypID.DbValue = RsRow("schTypID")
  560.         tblSchedule.schDepID.DbValue = RsRow("schDepID")
  561.         tblSchedule.schNotes.DbValue = RsRow("schNotes")
  562.         tblSchedule.schRate.DbValue = RsRow("schRate")
  563.         tblSchedule.schActualStart.DbValue = RsRow("schActualStart")
  564.         tblSchedule.schActualEnd.DbValue = RsRow("schActualEnd")
  565.         tblSchedule.schDateCreated.DbValue = RsRow("schDateCreated")
  566.         tblSchedule.schDoubleBooked.DbValue = IIf(ew_ConvertToBool(RsRow("schDoubleBooked")), "1", "0")
  567.         tblSchedule.schStatus.DbValue = RsRow("schStatus")
  568.     End Sub
  569.  
  570.     '
  571.     ' Render row values based on field settings
  572.     '
  573.     Sub RenderRow()
  574.  
  575.         ' Row Rendering event
  576.         tblSchedule.Row_Rendering()
  577.  
  578.         '
  579.         '  Common render codes for all row types
  580.         '
  581.         ' schDate
  582.  
  583.         tblSchedule.schDate.CellCssStyle = ""
  584.         tblSchedule.schDate.CellCssClass = ""
  585.  
  586.         ' schEvtID
  587.         tblSchedule.schEvtID.CellCssStyle = ""
  588.         tblSchedule.schEvtID.CellCssClass = ""
  589.  
  590.         ' schPartsID
  591.         tblSchedule.schPartsID.CellCssStyle = ""
  592.         tblSchedule.schPartsID.CellCssClass = ""
  593.  
  594.         ' schCallTime
  595.         tblSchedule.schCallTime.CellCssStyle = ""
  596.         tblSchedule.schCallTime.CellCssClass = ""
  597.  
  598.         ' schStartTime
  599.         tblSchedule.schStartTime.CellCssStyle = ""
  600.         tblSchedule.schStartTime.CellCssClass = ""
  601.  
  602.         ' schEndTime
  603.         tblSchedule.schEndTime.CellCssStyle = ""
  604.         tblSchedule.schEndTime.CellCssClass = ""
  605.  
  606.         ' schOutTime
  607.         tblSchedule.schOutTime.CellCssStyle = ""
  608.         tblSchedule.schOutTime.CellCssClass = ""
  609.  
  610.         ' schLocID
  611.         tblSchedule.schLocID.CellCssStyle = ""
  612.         tblSchedule.schLocID.CellCssClass = ""
  613.  
  614.         ' schEmpID
  615.         tblSchedule.schEmpID.CellCssStyle = ""
  616.         tblSchedule.schEmpID.CellCssClass = ""
  617.  
  618.         ' schPosID
  619.         tblSchedule.schPosID.CellCssStyle = ""
  620.         tblSchedule.schPosID.CellCssClass = ""
  621.  
  622.         ' schTypID
  623.         tblSchedule.schTypID.CellCssStyle = ""
  624.         tblSchedule.schTypID.CellCssClass = ""
  625.  
  626.         ' schActualStart
  627.         tblSchedule.schActualStart.CellCssStyle = ""
  628.         tblSchedule.schActualStart.CellCssClass = ""
  629.  
  630.         ' schActualEnd
  631.         tblSchedule.schActualEnd.CellCssStyle = ""
  632.         tblSchedule.schActualEnd.CellCssClass = ""
  633.  
  634.         ' schDoubleBooked
  635.         tblSchedule.schDoubleBooked.CellCssStyle = ""
  636.         tblSchedule.schDoubleBooked.CellCssClass = ""
  637.  
  638.         ' schStatus
  639.         tblSchedule.schStatus.CellCssStyle = ""
  640.         tblSchedule.schStatus.CellCssClass = ""
  641.  
  642.         '
  643.         '  View  Row
  644.         '
  645.  
  646.         If tblSchedule.RowType = EW_ROWTYPE_VIEW Then ' View row
  647.  
  648.             ' schDate
  649.             tblSchedule.schDate.ViewValue = tblSchedule.schDate.CurrentValue
  650.             tblSchedule.schDate.ViewValue = ew_FormatDateTime(tblSchedule.schDate.ViewValue, 6)
  651.             tblSchedule.schDate.CssStyle = ""
  652.             tblSchedule.schDate.CssClass = ""
  653.             tblSchedule.schDate.ViewCustomAttributes = ""
  654.  
  655.             ' schEvtID
  656.             If ew_NotEmpty(tblSchedule.schEvtID.CurrentValue) Then
  657.                 sSqlWrk = "SELECT [evtDescription] FROM [tblEvents] WHERE [evtID] = " & ew_AdjustSql(tblSchedule.schEvtID.CurrentValue) & ""
  658.                 sSqlWrk = sSqlWrk & " ORDER BY [evtDescription] "
  659.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  660.                 If RsWrk.Read() Then
  661.                     tblSchedule.schEvtID.ViewValue = RsWrk("evtDescription")
  662.                 Else
  663.                     tblSchedule.schEvtID.ViewValue = tblSchedule.schEvtID.CurrentValue
  664.                 End If
  665.                 Conn.CloseTempDataReader()
  666.             Else
  667.                 tblSchedule.schEvtID.ViewValue = System.DBNull.Value
  668.             End If
  669.             tblSchedule.schEvtID.CssStyle = ""
  670.             tblSchedule.schEvtID.CssClass = ""
  671.             tblSchedule.schEvtID.ViewCustomAttributes = ""
  672.  
  673.             ' schPartsID
  674.             If ew_NotEmpty(tblSchedule.schPartsID.CurrentValue) Then
  675.                 sSqlWrk = "SELECT [prtDescription] FROM [tblParts] WHERE [prtID] = " & ew_AdjustSql(tblSchedule.schPartsID.CurrentValue) & ""
  676.                 sSqlWrk = sSqlWrk & " ORDER BY [prtDescription] "
  677.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  678.                 If RsWrk.Read() Then
  679.                     tblSchedule.schPartsID.ViewValue = RsWrk("prtDescription")
  680.                 Else
  681.                     tblSchedule.schPartsID.ViewValue = tblSchedule.schPartsID.CurrentValue
  682.                 End If
  683.                 Conn.CloseTempDataReader()
  684.             Else
  685.                 tblSchedule.schPartsID.ViewValue = System.DBNull.Value
  686.             End If
  687.             tblSchedule.schPartsID.CssStyle = ""
  688.             tblSchedule.schPartsID.CssClass = ""
  689.             tblSchedule.schPartsID.ViewCustomAttributes = ""
  690.  
  691.             ' schCallTime
  692.             tblSchedule.schCallTime.ViewValue = tblSchedule.schCallTime.CurrentValue
  693.                 tblSchedule.schCallTime.ViewValue = ew_FormatDateTime(tblSchedule.schCallTime.ViewValue, 14)
  694.             tblSchedule.schCallTime.CssStyle = ""
  695.             tblSchedule.schCallTime.CssClass = ""
  696.             tblSchedule.schCallTime.ViewCustomAttributes = ""
  697.  
  698.             ' schStartTime
  699.             tblSchedule.schStartTime.ViewValue = tblSchedule.schStartTime.CurrentValue
  700.                 tblSchedule.schStartTime.ViewValue = ew_FormatDateTime(tblSchedule.schStartTime.ViewValue, 14)
  701.             tblSchedule.schStartTime.CssStyle = ""
  702.             tblSchedule.schStartTime.CssClass = ""
  703.             tblSchedule.schStartTime.ViewCustomAttributes = ""
  704.  
  705.             ' schEndTime
  706.             tblSchedule.schEndTime.ViewValue = tblSchedule.schEndTime.CurrentValue
  707.                 tblSchedule.schEndTime.ViewValue = ew_FormatDateTime(tblSchedule.schEndTime.ViewValue, 14)
  708.             tblSchedule.schEndTime.CssStyle = ""
  709.             tblSchedule.schEndTime.CssClass = ""
  710.             tblSchedule.schEndTime.ViewCustomAttributes = ""
  711.  
  712.             ' schOutTime
  713.             tblSchedule.schOutTime.ViewValue = tblSchedule.schOutTime.CurrentValue
  714.                 tblSchedule.schOutTime.ViewValue = ew_FormatDateTime(tblSchedule.schOutTime.ViewValue, 14)
  715.             tblSchedule.schOutTime.CssStyle = ""
  716.             tblSchedule.schOutTime.CssClass = ""
  717.             tblSchedule.schOutTime.ViewCustomAttributes = ""
  718.  
  719.             ' schLocID
  720.             If ew_NotEmpty(tblSchedule.schLocID.CurrentValue) Then
  721.                 sSqlWrk = "SELECT [locDescription] FROM [tblLocations] WHERE [locID] = " & ew_AdjustSql(tblSchedule.schLocID.CurrentValue) & ""
  722.                 sSqlWrk = sSqlWrk & " ORDER BY [locDescription] "
  723.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  724.                 If RsWrk.Read() Then
  725.                     tblSchedule.schLocID.ViewValue = RsWrk("locDescription")
  726.                 Else
  727.                     tblSchedule.schLocID.ViewValue = tblSchedule.schLocID.CurrentValue
  728.                 End If
  729.                 Conn.CloseTempDataReader()
  730.             Else
  731.                 tblSchedule.schLocID.ViewValue = System.DBNull.Value
  732.             End If
  733.             tblSchedule.schLocID.CssStyle = ""
  734.             tblSchedule.schLocID.CssClass = ""
  735.             tblSchedule.schLocID.ViewCustomAttributes = ""
  736.  
  737.             ' schEmpID
  738.             If ew_NotEmpty(tblSchedule.schEmpID.CurrentValue) Then
  739.                 sSqlWrk = "SELECT [empName] FROM [tblEmployees] WHERE [empID] = " & ew_AdjustSql(tblSchedule.schEmpID.CurrentValue) & ""
  740.                     sSqlWrk = sSqlWrk & " ORDER BY [empFirstName] "
  741.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  742.                 If RsWrk.Read() Then
  743.                     tblSchedule.schEmpID.ViewValue = RsWrk("empName")
  744.                 Else
  745.                     tblSchedule.schEmpID.ViewValue = tblSchedule.schEmpID.CurrentValue
  746.                 End If
  747.                 Conn.CloseTempDataReader()
  748.             Else
  749.                 tblSchedule.schEmpID.ViewValue = System.DBNull.Value
  750.             End If
  751.             tblSchedule.schEmpID.CssStyle = ""
  752.             tblSchedule.schEmpID.CssClass = ""
  753.             tblSchedule.schEmpID.ViewCustomAttributes = ""
  754.  
  755.             ' schPosID
  756.             If ew_NotEmpty(tblSchedule.schPosID.CurrentValue) Then
  757.                 sSqlWrk = "SELECT [posDescription] FROM [tblPositions] WHERE [posID] = " & ew_AdjustSql(tblSchedule.schPosID.CurrentValue) & ""
  758.                 sSqlWrk = sSqlWrk & " ORDER BY [posDescription] "
  759.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  760.                 If RsWrk.Read() Then
  761.                     tblSchedule.schPosID.ViewValue = RsWrk("posDescription")
  762.                 Else
  763.                     tblSchedule.schPosID.ViewValue = tblSchedule.schPosID.CurrentValue
  764.                 End If
  765.                 Conn.CloseTempDataReader()
  766.             Else
  767.                 tblSchedule.schPosID.ViewValue = System.DBNull.Value
  768.             End If
  769.             tblSchedule.schPosID.CssStyle = ""
  770.             tblSchedule.schPosID.CssClass = ""
  771.             tblSchedule.schPosID.ViewCustomAttributes = ""
  772.  
  773.             ' schTypID
  774.             If ew_NotEmpty(tblSchedule.schTypID.CurrentValue) Then
  775.                 sSqlWrk = "SELECT [typDescription] FROM [tblTypes] WHERE [typID] = " & ew_AdjustSql(tblSchedule.schTypID.CurrentValue) & ""
  776.                 sSqlWrk = sSqlWrk & " ORDER BY [typDescription] "
  777.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  778.                 If RsWrk.Read() Then
  779.                     tblSchedule.schTypID.ViewValue = RsWrk("typDescription")
  780.                 Else
  781.                     tblSchedule.schTypID.ViewValue = tblSchedule.schTypID.CurrentValue
  782.                 End If
  783.                 Conn.CloseTempDataReader()
  784.             Else
  785.                 tblSchedule.schTypID.ViewValue = System.DBNull.Value
  786.             End If
  787.             tblSchedule.schTypID.CssStyle = ""
  788.             tblSchedule.schTypID.CssClass = ""
  789.             tblSchedule.schTypID.ViewCustomAttributes = ""
  790.  
  791.             ' schActualStart
  792.             tblSchedule.schActualStart.ViewValue = tblSchedule.schActualStart.CurrentValue
  793.                 tblSchedule.schActualStart.ViewValue = ew_FormatDateTime(tblSchedule.schActualStart.ViewValue, 14)
  794.             tblSchedule.schActualStart.CssStyle = ""
  795.             tblSchedule.schActualStart.CssClass = ""
  796.             tblSchedule.schActualStart.ViewCustomAttributes = ""
  797.  
  798.             ' schActualEnd
  799.             tblSchedule.schActualEnd.ViewValue = tblSchedule.schActualEnd.CurrentValue
  800.                 tblSchedule.schActualEnd.ViewValue = ew_FormatDateTime(tblSchedule.schActualEnd.ViewValue, 14)
  801.             tblSchedule.schActualEnd.CssStyle = ""
  802.             tblSchedule.schActualEnd.CssClass = ""
  803.             tblSchedule.schActualEnd.ViewCustomAttributes = ""
  804.  
  805.             ' schDoubleBooked
  806.             If Convert.ToString(tblSchedule.schDoubleBooked.CurrentValue) = "1" Then
  807.                 tblSchedule.schDoubleBooked.ViewValue = "Yes"
  808.             Else
  809.                 tblSchedule.schDoubleBooked.ViewValue = "No"
  810.             End If
  811.             tblSchedule.schDoubleBooked.CssStyle = ""
  812.             tblSchedule.schDoubleBooked.CssClass = ""
  813.             tblSchedule.schDoubleBooked.ViewCustomAttributes = ""
  814.  
  815.             ' schStatus
  816.             If ew_NotEmpty(tblSchedule.schStatus.CurrentValue) Then
  817.                 sSqlWrk = "SELECT [stDescription] FROM [tblScheduleStatus] WHERE [stID] = " & ew_AdjustSql(tblSchedule.schStatus.CurrentValue) & ""
  818.                 sSqlWrk = sSqlWrk & " ORDER BY [stDescription] "
  819.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  820.                 If RsWrk.Read() Then
  821.                     tblSchedule.schStatus.ViewValue = RsWrk("stDescription")
  822.                 Else
  823.                     tblSchedule.schStatus.ViewValue = tblSchedule.schStatus.CurrentValue
  824.                 End If
  825.                 Conn.CloseTempDataReader()
  826.             Else
  827.                 tblSchedule.schStatus.ViewValue = System.DBNull.Value
  828.             End If
  829.             tblSchedule.schStatus.CssStyle = ""
  830.             tblSchedule.schStatus.CssClass = ""
  831.             tblSchedule.schStatus.ViewCustomAttributes = ""
  832.  
  833.             ' View refer script
  834.             ' schDate
  835.  
  836.             tblSchedule.schDate.HrefValue = ""
  837.  
  838.             ' schEvtID
  839.             tblSchedule.schEvtID.HrefValue = ""
  840.  
  841.             ' schPartsID
  842.             tblSchedule.schPartsID.HrefValue = ""
  843.  
  844.             ' schCallTime
  845.             tblSchedule.schCallTime.HrefValue = ""
  846.  
  847.             ' schStartTime
  848.             tblSchedule.schStartTime.HrefValue = ""
  849.  
  850.             ' schEndTime
  851.             tblSchedule.schEndTime.HrefValue = ""
  852.  
  853.             ' schOutTime
  854.             tblSchedule.schOutTime.HrefValue = ""
  855.  
  856.             ' schLocID
  857.             tblSchedule.schLocID.HrefValue = ""
  858.  
  859.             ' schEmpID
  860.             tblSchedule.schEmpID.HrefValue = ""
  861.  
  862.             ' schPosID
  863.             tblSchedule.schPosID.HrefValue = ""
  864.  
  865.             ' schTypID
  866.             tblSchedule.schTypID.HrefValue = ""
  867.  
  868.             ' schActualStart
  869.             tblSchedule.schActualStart.HrefValue = ""
  870.  
  871.             ' schActualEnd
  872.             tblSchedule.schActualEnd.HrefValue = ""
  873.  
  874.             ' schDoubleBooked
  875.             tblSchedule.schDoubleBooked.HrefValue = ""
  876.  
  877.             ' schStatus
  878.             tblSchedule.schStatus.HrefValue = ""
  879.         End If
  880.  
  881.         ' Row Rendered event
  882.         tblSchedule.Row_Rendered()
  883.     End Sub
  884.  
  885.         ' Page Load event
  886.         Public Sub Page_Load()
  887.  
  888.             'HttpContext.Current.Response.Write("Page Load")
  889.         End Sub
  890.  
  891.         ' Page Unload event
  892.         Public Sub Page_Unload()
  893.  
  894.             'HttpContext.Current.Response.Write("Page Unload")
  895.         End Sub
  896.     End Class
  897.  
  898.     '
  899.     ' ASP.NET Page_Load event
  900.     '
  901.  
  902.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  903.         Response.Buffer = EW_RESPONSE_BUFFER
  904.         Response.Cache.SetCacheability(HttpCacheability.NoCache)
  905.  
  906.         ' Page init
  907.         tblSchedule_delete = New ctblSchedule_delete(Me)        
  908.         tblSchedule_delete.Page_Init()
  909.  
  910.         ' Page main processing
  911.         tblSchedule_delete.Page_Main()
  912.     End Sub
  913.  
  914.     '
  915.     ' ASP.NET Page_Unload event
  916.     '
  917.  
  918.     Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
  919.  
  920.         ' Dispose page object
  921.         If tblSchedule_delete IsNot Nothing Then tblSchedule_delete.Dispose()
  922.     End Sub
  923. End Class
  924.