home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / App_Code / tlccustomsubs.vb < prev    next >
Text File  |  2014-12-14  |  32KB  |  721 lines

  1. ∩╗┐Imports Microsoft.VisualBasic
  2. Imports System.Data.OleDb
  3. Imports System.Web
  4.  
  5. Partial Public Class AspNetMaker7_tfpssnet
  6.  
  7.     Public Function tlcSendEventInfo(ByVal tmpSchID As Long, ByRef tmpSchDate As Date, ByRef tmpEvtDescription As String, ByRef tmpPrtDescription As String, ByRef tmpCallTime As Date, _
  8.             ByRef tmpStartTime As Date, ByRef tmpEndTime As Date, ByRef tmpOutTime As Date, ByRef tmpLocDescription As String, ByRef tmpPosDescription As String, ByRef tmpStDescription As String, _
  9.             ByRef tmpTypDescription As String, ByRef tmpEmpName As String, ByRef tmpEmail As String, ByVal tmpAction As String, ByVal tmpStatus As String, ByVal tmpType As String, ByRef smtpStatus As Boolean, _
  10.             ByRef smtpMessage As String) As Integer
  11.         Dim tmpBody As String = "", strResult As String = ""
  12.  
  13.         If tmpEndTime = "12:00:00 AM" Then
  14.             tmpEndTime = DateAdd(DateInterval.Hour, 1, tmpStartTime)
  15.         End If
  16.         If tmpOutTime = "12:00:00 AM" Then
  17.             tmpOutTime = DateAdd(DateInterval.Hour, 1, tmpCallTime)
  18.         End If
  19.         Select Case tmpType
  20.             Case "C"
  21.                 tmpBody = "Status Changed to 'Confirmed' for "
  22.             Case "U"
  23.                 tmpBody = "Status Changed to 'Unconfirmed' for "
  24.             Case "X"
  25.                 tmpBody = "Status Changed to 'Cannot Work' for "
  26.             Case "T"
  27.                 tmpBody = "Status Changed to 'Tentative' for "
  28.         End Select
  29.         If InStr(tmpEmail, "@tfc.org") = 0 And tlcGetPSSUpdateExchangeCalendar() = False Then
  30.             tmpBody += "Event: " & tmpEvtDescription & ", Part: " & tmpPrtDescription & ", Call Time: " & tmpCallTime & _
  31.                 ", Start Time: " & tmpStartTime & ", End Time: " & tmpEndTime & ", Out Time: " & tmpOutTime & ", Location: " & tmpLocDescription & _
  32.                 ", Position: " & tmpPosDescription & ", Type: " & tmpTypDescription & ", Status: " & tmpStDescription
  33.             tmpBody = HttpUtility.HtmlEncode(tmpBody)
  34.             If tmpAction = "mailAdd" Or tmpAction = "A" Then
  35.                 'Dim vcal As New AppointmentVCAL(tmpSchDate & " " & tmpCallTime, tmpSchDate & " " & tmpOutTime, tmpLocDescription, tmpBody, tmpLocDescription, Left(tmpEmail, InStr(tmpEmail, "@") - 1), tmpEmail, "Production Services", "prodservices@tfchurch.org", "REQUEST")
  36.                 'vcal.EmailAppointment()
  37.                 Dim bll As New AppointmentBLL(tmpSchDate & " " & tmpCallTime, tmpSchDate & " " & tmpOutTime, tmpLocDescription, tmpBody, tmpLocDescription, Left(tmpEmail, InStr(tmpEmail, "@") - 1), tmpEmail, "Production Services", "productionservices@tfc.org", "REQUEST")
  38.                 bll.EmailAppointment(smtpStatus, smtpMessage)
  39.             Else
  40.                 'Dim vcal As New AppointmentVCAL(tmpSchDate & " " & tmpCallTime, tmpSchDate & " " & tmpOutTime, tmpLocDescription, tmpBody, tmpLocDescription, Left(tmpEmail, InStr(tmpEmail, "@") - 1), tmpEmail, "Production Services", "prodservices@tfchurch.org", "CANCEL")
  41.                 'vcal.EmailAppointment()
  42.                 Dim bll As New AppointmentBLL(tmpSchDate & " " & tmpCallTime, tmpSchDate & " " & tmpOutTime, tmpLocDescription, tmpBody, tmpLocDescription, Left(tmpEmail, InStr(tmpEmail, "@") - 1), tmpEmail, "Production Services", "productionservices@tfc.org", "CANCEL")
  43.                 bll.EmailAppointment(smtpStatus, smtpMessage)
  44.             End If
  45.         Else
  46.             tmpBody += "<html><body>Event: " & tmpEvtDescription & "<br />Part: " & tmpPrtDescription & "<br />Call Time: " & tmpCallTime & _
  47.                 "<br />Start Time: " & tmpStartTime & "<br />End Time: " & tmpEndTime & "<br />Out Time: " & tmpOutTime & "<br />Location: " & tmpLocDescription & _
  48.                 "<br />Position: " & tmpPosDescription & "<br />Type: " & tmpTypDescription & "<br />Status: " & tmpStDescription & "</body></html>"
  49.             tmpBody = HttpUtility.HtmlEncode(tmpBody)
  50.             ew_Session("tmpBody") = tmpBody
  51.             ew_Session("tmpEmail") = tmpEmail
  52.             If tmpAction = "mailAdd" Or tmpAction = "A" Then
  53.                 Dim appt As New AppointmentWebDav(tmpSchDate & " " & tmpCallTime, tmpSchDate & " " & tmpOutTime, tmpLocDescription, tmpBody, tmpLocDescription, Left(tmpEmail, InStr(tmpEmail, "@") - 1), tmpSchID, tmpAction, tmpStatus)
  54.                 appt.SemdAppointment(strResult)
  55.                 ew_Session("strResult") = strResult
  56.                 smtpMessage = strResult
  57.             Else
  58.                 Dim appt As New AppointmentWebDav(tmpSchDate & " " & tmpCallTime, tmpSchDate & " " & tmpOutTime, tmpLocDescription, tmpBody, tmpLocDescription, Left(tmpEmail, InStr(tmpEmail, "@") - 1), tmpSchID, tmpAction, "")
  59.                 appt.SemdAppointment(strResult)
  60.                 ew_Session("strResult") = strResult
  61.                 smtpMessage = strResult
  62.             End If
  63.             ew_Session("strResult") = strResult
  64.             smtpMessage = strResult
  65.         End If
  66.         Return True
  67.     End Function
  68.  
  69.     Public Function tlcGetEventInfo(ByVal tmpSchID As Long, ByRef tmpSchDate As Date, ByRef tmpEvtDescription As String, ByRef tmpPrtDescription As String, ByRef tmpCallTime As Date, _
  70.             ByRef tmpStartTime As Date, ByRef tmpEndTime As Date, ByRef tmpOutTime As Date, ByRef tmpLocDescription As String, ByRef tmpPosDescription As String, ByRef tmpStDescription As String, _
  71.             ByRef tmpTypDescription As String, ByRef tmpEmpName As String, ByRef tmpEmail As String, ByRef tmpStatus As String, ByRef tmpNotes As String) As Integer
  72.         Dim RsRow As OleDbDataReader
  73.         Dim sSql As String = "SELECT tblSchedule.schSchID, tblSchedule.schDate, tblEvents.evtDescription, tblParts.prtDescription, tblSchedule.schCallTime, tblSchedule.schStartTime, tblSchedule.schEndTime, " _
  74. & "tblSchedule.schOutTime, tblSchedule.schNotes, tblLocations.locDescription, tblPositions.posDescription, tblScheduleStatus.stDescription, tblTypes.typDescription, tblEmployees.empName, tblEmployees.empEmail " _
  75. & "FROM tblTypes INNER JOIN (tblScheduleStatus INNER JOIN (tblPositions INNER JOIN (tblParts INNER JOIN (tblLocations INNER JOIN (tblEmployees INNER JOIN (tblEvents INNER JOIN tblSchedule ON " _
  76. & "tblEvents.evtID = tblSchedule.schEvtID) ON tblEmployees.empID = tblSchedule.schEmpID) ON tblLocations.locID = tblSchedule.schLocID) ON tblParts.prtID = tblSchedule.schPartsID) ON " _
  77. & "tblPositions.posID = tblSchedule.schPosID) ON tblScheduleStatus.stID = tblSchedule.schStatus) ON tblTypes.typID = tblSchedule.schTypID " _
  78. & "WHERE tblSchedule.schSchID = " & tmpSchID
  79.         Session("sSql") = sSql
  80.         ' Write SQL for debug
  81.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  82.         Try
  83.             Conn = New cConnection()
  84.             RsRow = Conn.GetTempDataReader(sSql)
  85.             If Not RsRow.Read() Then
  86.                 Return False
  87.             Else
  88.                 tmpSchDate = FormatDateTime(RsRow("schDate"), DateFormat.ShortDate)
  89.                 tmpEvtDescription = RsRow("evtDescription")
  90.                 tmpEvtDescription = Replace(tmpEvtDescription, """", "")
  91.                 tmpPrtDescription = RsRow("prtDescription")
  92.                 If Not IsDBNull(RsRow("schCallTime")) Then
  93.                     tmpCallTime = Format(RsRow("schCallTime"), "hh:mm:ss tt")
  94.                 Else
  95.                     tmpCallTime = "12:00:00 AM"
  96.                 End If
  97.                 If Not IsDBNull(RsRow("schStartTime")) Then
  98.                     tmpStartTime = Format(RsRow("schStartTime"), "hh:mm:ss tt")
  99.                 Else
  100.                     tmpStartTime = "12:00:00 AM"
  101.                 End If
  102.                 If Not IsDBNull(RsRow("schEndTime")) Then
  103.                     tmpEndTime = Format(RsRow("schEndTime"), "hh:mm:ss tt")
  104.                 Else
  105.                     tmpEndTime = "12:00:00 AM"
  106.                 End If
  107.                 If Not IsDBNull(RsRow("schOutTime")) Then
  108.                     tmpOutTime = Format(RsRow("schOutTime"), "hh:mm:ss tt")
  109.                 Else
  110.                     tmpOutTime = "12:00:00 AM"
  111.                 End If
  112.                 tmpLocDescription = RsRow("locDescription")
  113.                 tmpPosDescription = RsRow("posDescription")
  114.                 tmpStDescription = RsRow("stDescription")
  115.                 tmpTypDescription = RsRow("typDescription")
  116.                 tmpEmpName = RsRow("empName")
  117.                 If Not IsDBNull(RsRow("empEmail")) Then
  118.                     tmpEmail = RsRow("empEmail")
  119.                 End If
  120.                 tmpStatus = RsRow("stDescription")
  121.                 tmpNotes = RsRow("schNotes")
  122.                 Return True
  123.                 End If
  124.         Catch
  125.             Return False
  126.         Finally
  127.             Conn.CloseTempDataReader()
  128.             Conn.Dispose()
  129.         End Try
  130.     End Function
  131.  
  132.     Public Function tlcGetEmployeeID(ByVal tmpEmpUserName As String) As Long
  133.         Dim RsRow As OleDbDataReader
  134.         Dim sSql As String = "Select empID, empUserName from tblEmployees Where empUsername='" & tmpEmpUserName & "'"
  135.         ' Write SQL for debug
  136.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  137.         Try
  138.             Conn = New cConnection()
  139.             RsRow = Conn.GetTempDataReader(sSql)
  140.             If Not RsRow.Read() Then
  141.                 Return False
  142.             Else
  143.                 '                Return True
  144.                 Return RsRow("empID")
  145.             End If
  146.         Catch
  147.             '            If EW_DEBUG_ENABLED Then Throw
  148.             Return False
  149.         Finally
  150.             Conn.CloseTempDataReader()
  151.             Conn.Dispose()
  152.         End Try
  153.     End Function
  154.  
  155.     Public Function tlcGetUnRecCount(ByVal tmpEmpUserName As String) As Long
  156.         Dim RsRow As OleDbDataReader
  157.         Dim sSql As String = "SELECT Count([schSchID]) AS RecCount " _
  158. & "FROM tblEmployees INNER JOIN tblSchedule ON tblEmployees.empID = tblSchedule.schEmpID " _
  159. & "WHERE (((tblSchedule.schDate)>=DateValue(Now())) AND ((tblSchedule.schStatus)=2)) AND ((tblEmployees.empUsername)='" & tmpEmpUserName & "')"
  160.         ' Write SQL for debug
  161.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  162.         Try
  163.             Conn = New cConnection()
  164.             RsRow = Conn.GetTempDataReader(sSql)
  165.             If Not RsRow.Read() Then
  166.                 Return False
  167.             Else
  168.                 '                Return True
  169.                 Return RsRow("RecCount")
  170.             End If
  171.         Catch
  172.             '            If EW_DEBUG_ENABLED Then Throw
  173.             Return False
  174.         Finally
  175.             Conn.CloseTempDataReader()
  176.             Conn.Dispose()
  177.         End Try
  178.     End Function
  179.  
  180.     Public Function tlcGetEventDesc(ByVal tmpEvtID As Long) As String
  181.         Dim RsRow As OleDbDataReader
  182.         Dim sSql As String = "Select evtID, evtDescription from tblEvents Where evtID=" & tmpEvtID
  183.         ' Write SQL for debug
  184.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  185.         Try
  186.             Conn = New cConnection()
  187.             RsRow = Conn.GetTempDataReader(sSql)
  188.             If Not RsRow.Read() Then
  189.                 Return False
  190.             Else
  191.                 '                Return True
  192.                 Return RsRow("evtDescription")
  193.             End If
  194.         Catch
  195.             '            If EW_DEBUG_ENABLED Then Throw
  196.             Return False
  197.         Finally
  198.             Conn.CloseTempDataReader()
  199.             Conn.Dispose()
  200.         End Try
  201.     End Function
  202.  
  203.     Public Function tlcGetPartDesc(ByVal tmpPrtID As Long) As String
  204.         Dim RsRow As OleDbDataReader
  205.         Dim sSql As String = "Select prtID, prtDescription from tblParts Where prtID=" & tmpPrtID
  206.         ' Write SQL for debug
  207.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  208.         Try
  209.             Conn = New cConnection()
  210.             RsRow = Conn.GetTempDataReader(sSql)
  211.             If Not RsRow.Read() Then
  212.                 Return False
  213.             Else
  214.                 '                Return True
  215.                 Return RsRow("prtDescription")
  216.             End If
  217.         Catch
  218.             '            If EW_DEBUG_ENABLED Then Throw
  219.             Return False
  220.         Finally
  221.             Conn.CloseTempDataReader()
  222.             Conn.Dispose()
  223.         End Try
  224.     End Function
  225.  
  226.     Public Function tlcGetTypeDesc(ByVal tmpTypID As Long) As String
  227.         Dim RsRow As OleDbDataReader
  228.         Dim sSql As String = "Select typID, typDescription from tblTypes Where typID=" & tmpTypID
  229.         ' Write SQL for debug
  230.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  231.         Try
  232.             Conn = New cConnection()
  233.             RsRow = Conn.GetTempDataReader(sSql)
  234.             If Not RsRow.Read() Then
  235.                 Return False
  236.             Else
  237.                 '                Return True
  238.                 Return RsRow("typDescription")
  239.             End If
  240.         Catch
  241.             '            If EW_DEBUG_ENABLED Then Throw
  242.             Return False
  243.         Finally
  244.             Conn.CloseTempDataReader()
  245.             Conn.Dispose()
  246.         End Try
  247.     End Function
  248.  
  249.     Public Function tlcGetEmployeeUsername(ByVal tmpEmpID As Long) As String
  250.         Dim RsRow As OleDbDataReader
  251.         Dim sSql As String = "Select empID, empUserName from tblEmployees Where empPayrollNumber=" & tmpEmpID
  252.         ' Write SQL for debug
  253.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  254.         Try
  255.             Conn = New cConnection()
  256.             RsRow = Conn.GetTempDataReader(sSql)
  257.             If Not RsRow.Read() Then
  258.                 Return False
  259.             Else
  260.                 '                Return True
  261.                 Return RsRow("empUserName")
  262.             End If
  263.         Catch
  264.             '            If EW_DEBUG_ENABLED Then Throw
  265.             Return False
  266.         Finally
  267.             Conn.CloseTempDataReader()
  268.             Conn.Dispose()
  269.         End Try
  270.     End Function
  271.  
  272.     Public Function tlcGetEmployeeUsernameByName(ByVal tmpEmpName As String) As String
  273.         Dim RsRow As OleDbDataReader
  274.         Dim sSql As String = "Select empID, empUserName from tblEmployees Where empName='" & tmpEmpName & "'"
  275.         ' Write SQL for debug
  276.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  277.         Try
  278.             Conn = New cConnection()
  279.             RsRow = Conn.GetTempDataReader(sSql)
  280.             If Not RsRow.Read() Then
  281.                 Return False
  282.             Else
  283.                 '                Return True
  284.                 Return RsRow("empUserName")
  285.             End If
  286.         Catch
  287.             '            If EW_DEBUG_ENABLED Then Throw
  288.             Return False
  289.         Finally
  290.             Conn.CloseTempDataReader()
  291.             Conn.Dispose()
  292.         End Try
  293.     End Function
  294.  
  295.     Public Function tlcGetEmployeeLogin(ByVal tmpUsrName As String, ByVal tmpPwd As String, ByRef tmpEmpName As String, ByRef tmpEmpID As Long) As Integer
  296.         If IsDBNull(tmpUsrName) Or IsDBNull(tmpPwd) Then
  297.             tmpEmpName = ""
  298.             tmpEmpID = ""
  299.             Return False
  300.             Exit Function
  301.         End If
  302.         Dim RsRow As OleDbDataReader
  303.         Dim sSql As String
  304.         If IsNumeric(tmpUsrName) Then
  305.             sSql = "SELECT empID, empName, empUserName, empUserPass FROM tblEmployees WHERE (empPayrollNumber=" & tmpUsrName & ")"
  306.         Else
  307.             sSql = "SELECT empID, empName, empUserName, empUserPass FROM tblEmployees WHERE (empUserName='" & tmpUsrName & "')"
  308.         End If
  309.         ' Write SQL for debug
  310.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  311.         Try
  312.             Conn = New cConnection()
  313.             RsRow = Conn.GetTempDataReader(sSql)
  314.             If Not RsRow.Read() Then
  315.                 tmpEmpName = ""
  316.                 tmpEmpID = ""
  317.                 Return False
  318.             Else
  319.                 If tmpPwd = RsRow("empUserPass") Then
  320.                     tmpEmpName = RsRow("empName")
  321.                     tmpEmpID = RsRow("empID")
  322.                     Return True
  323.                 Else
  324.                     tmpEmpName = ""
  325.                     tmpEmpID = ""
  326.                     Return False
  327.                 End If
  328.             End If
  329.         Catch
  330.             '            If EW_DEBUG_ENABLED Then Throw
  331.             Return False
  332.         Finally
  333.             Conn.CloseTempDataReader()
  334.             Conn.Dispose()
  335.         End Try
  336.     End Function
  337.  
  338.     Public Function tlcGetEmployeeName(ByVal tmpEmpID As Long) As String
  339.         Dim RsRow As OleDbDataReader
  340.         Dim sSql As String = "Select empID, empName from tblEmployees Where empID=" & tmpEmpID
  341.         ' Write SQL for debug
  342.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  343.         Try
  344.             Conn = New cConnection()
  345.             RsRow = Conn.GetTempDataReader(sSql)
  346.             If Not RsRow.Read() Then
  347.                 Return False
  348.             Else
  349.                 '                Return True
  350.                 Return RsRow("empName")
  351.             End If
  352.         Catch
  353.             '            If EW_DEBUG_ENABLED Then Throw
  354.             Return False
  355.         Finally
  356.             Conn.CloseTempDataReader()
  357.             Conn.Dispose()
  358.         End Try
  359.     End Function
  360.  
  361.     Public Function tlcGetEmployeeEmail(ByVal tmpEmpID As Long) As String
  362.         Dim RsRow As OleDbDataReader
  363.         Dim sSql As String = "Select empID, empEmail from tblEmployees Where empID=" & tmpEmpID
  364.         ' Write SQL for debug
  365.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  366.         Try
  367.             Conn = New cConnection()
  368.             RsRow = Conn.GetTempDataReader(sSql)
  369.             If Not RsRow.Read() Then
  370.                 Return False
  371.             Else
  372.                 '                Return True
  373.                 Return RsRow("empEmail")
  374.             End If
  375.         Catch
  376.             '            If EW_DEBUG_ENABLED Then Throw
  377.             Return False
  378.         Finally
  379.             Conn.CloseTempDataReader()
  380.             Conn.Dispose()
  381.         End Try
  382.     End Function
  383.  
  384.     Public Function tlcGetLocationName(ByVal tmpLocID As Long) As String
  385.         Dim RsRow As OleDbDataReader
  386.         Dim sSql As String = "Select locID, locDescription from tblLocations Where locID=" & tmpLocID
  387.         ' Write SQL for debug
  388.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  389.         Try
  390.             Conn = New cConnection()
  391.             RsRow = Conn.GetTempDataReader(sSql)
  392.             If Not RsRow.Read() Then
  393.                 Return False
  394.             Else
  395.                 '                Return True
  396.                 Return RsRow("locDescription")
  397.             End If
  398.         Catch
  399.             '            If EW_DEBUG_ENABLED Then Throw
  400.             Return False
  401.         Finally
  402.             Conn.CloseTempDataReader()
  403.             Conn.Dispose()
  404.         End Try
  405.     End Function
  406.  
  407.     Public Function tlcGetPositionName(ByVal tmpPosID As Long) As String
  408.         Dim RsRow As OleDbDataReader
  409.         Dim sSql As String = "Select posID, posDescription from tblPositions Where posID=" & tmpPosID
  410.         ' Write SQL for debug
  411.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  412.         Try
  413.             Conn = New cConnection()
  414.             RsRow = Conn.GetTempDataReader(sSql)
  415.             If Not RsRow.Read() Then
  416.                 Return False
  417.             Else
  418.                 '                Return True
  419.                 Return RsRow("posDescription")
  420.             End If
  421.         Catch
  422.             '            If EW_DEBUG_ENABLED Then Throw
  423.             Return False
  424.         Finally
  425.             Conn.CloseTempDataReader()
  426.             Conn.Dispose()
  427.         End Try
  428.     End Function
  429.  
  430.     Public Function tlcGetEmployeeRate(ByVal tmpEmpID As Long) As Double
  431.         Dim RsRow As OleDbDataReader
  432.         Dim sSql As String = "Select empID, empRate from tblEmployees Where empID=" & tmpEmpID
  433.         ' Write SQL for debug
  434.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  435.         Try
  436.             Conn = New cConnection()
  437.             RsRow = Conn.GetTempDataReader(sSql)
  438.             If Not RsRow.Read() Then
  439.                 Return False
  440.             Else
  441.                 '                Return True
  442.                 Return RsRow("empRate")
  443.             End If
  444.         Catch
  445.             '            If EW_DEBUG_ENABLED Then Throw
  446.             Return False
  447.         Finally
  448.             Conn.CloseTempDataReader()
  449.             Conn.Dispose()
  450.         End Try
  451.     End Function
  452.  
  453.     Public Function tlcGetPSSMessage(ByRef tmpMessage As String) As Long
  454.         Dim RsRow As OleDbDataReader
  455.         Dim sSql As String = "Select tblMessage.msgText, tblMessage.msgStartDate, tblMessage.msgEndDate from tblMessage"
  456.         ' Write SQL for debug
  457.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  458.         Try
  459.             Conn = New cConnection()
  460.             RsRow = Conn.GetTempDataReader(sSql)
  461.             If Not RsRow.Read() Then
  462.                 Return False
  463.             Else
  464.                 If Not IsDBNull(RsRow("msgStartDate")) And Not IsDBNull(RsRow("msgEndDate")) Then
  465.                     If DateValue(RsRow("msgStartDate")) <= Now() And DateAdd(DateInterval.Day, 1, DateValue(RsRow("msgEndDate"))) >= Now() Then
  466.                         tmpMessage = RsRow("msgText")
  467.                     End If
  468.                 End If
  469.                 If Not IsDBNull(RsRow("msgStartDate")) And IsDBNull(RsRow("msgEndDate")) Then
  470.                     If DateValue(RsRow("msgStartDate")) <= Now() Then
  471.                         tmpMessage = RsRow("msgText")
  472.                     End If
  473.                 End If
  474.                 If IsDBNull(RsRow("msgStartDate")) And Not IsDBNull(RsRow("msgEndDate")) Then
  475.                     If DateAdd(DateInterval.Day, 1, DateValue(RsRow("msgEndDate"))) >= Now() Then
  476.                         tmpMessage = RsRow("msgText")
  477.                     End If
  478.                 End If
  479.                 If IsDBNull(RsRow("msgStartDate")) And IsDBNull(RsRow("msgEndDate")) Then
  480.                     tmpMessage = RsRow("msgText")
  481.                 End If
  482.                 Return True
  483.             End If
  484.         Catch
  485.             '            If EW_DEBUG_ENABLED Then Throw
  486.             Return False
  487.         Finally
  488.             Conn.CloseTempDataReader()
  489.             Conn.Dispose()
  490.         End Try
  491.     End Function
  492.  
  493.     Public Function tlcGetPSSEmailConfirmation() As Boolean
  494.         Dim RsRow As OleDbDataReader
  495.         Dim sSql As String = "Select tblSystemControl.ctlStatusChangeEmailConfirmation from tblSystemControl where ID = 1"
  496.         ' Write SQL for debug
  497.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  498.         Try
  499.             Conn = New cConnection()
  500.             RsRow = Conn.GetTempDataReader(sSql)
  501.             If Not RsRow.Read() Then
  502.                 Return False
  503.             Else
  504.                 If RsRow("ctlStatusChangeEmailConfirmation") = True Then
  505.                     Return True
  506.                 Else
  507.                     Return False
  508.                 End If
  509.             End If
  510.         Catch
  511.             '            If EW_DEBUG_ENABLED Then Throw
  512.             Return False
  513.         Finally
  514.             Conn.CloseTempDataReader()
  515.             Conn.Dispose()
  516.         End Try
  517.     End Function
  518.  
  519.     Public Function tlcGetPSSUpdateExchangeCalendar() As Boolean
  520.         Dim RsRow As OleDbDataReader
  521.         Dim sSql As String = "Select tblSystemControl.ctlStatusUpdateExchangeCalendar from tblSystemControl where ID = 1"
  522.         ' Write SQL for debug
  523.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  524.         Try
  525.             Conn = New cConnection()
  526.             RsRow = Conn.GetTempDataReader(sSql)
  527.             If Not RsRow.Read() Then
  528.                 Return False
  529.             Else
  530.                 If RsRow("ctlStatusUpdateExchangeCalendar") = True Then
  531.                     Return True
  532.                 Else
  533.                     Return False
  534.                 End If
  535.             End If
  536.         Catch
  537.             '            If EW_DEBUG_ENABLED Then Throw
  538.             Return False
  539.         Finally
  540.             Conn.CloseTempDataReader()
  541.             Conn.Dispose()
  542.         End Try
  543.     End Function
  544.  
  545.     Public Function tlcActionUpdate(ByVal tmpAction As String, ByVal tmpKey As Long) As Integer
  546.         Dim Sql As String = ""
  547.  
  548.         Select Case tmpAction
  549.             Case "In"
  550.                 Sql = "UPDATE [tblSchedule] SET [schActualStart] = " & Now()
  551.             Case "Out"
  552.                 Sql = "UPDATE [tblSchedule] SET [schActualEnd] = " & Now()
  553.             Case "OutU"
  554.                 Sql = "UPDATE [tblSchedule] SET [schActualEnd] = " & Now() & ", [schEndTime] = " & Now() & ", [schOutTime] = " & Now()
  555.                 Rs("schEndTime") = Now()
  556.                 Rs("schOutTime") = Now()
  557.         End Select
  558.         Sql = Sql & " WHERE schSchID = " & tmpKey
  559.  
  560.         Dim command As OleDbCommand = Conn.GetCommand(Sql)
  561.         Return command.ExecuteNonQuery()
  562.  
  563.     End Function
  564.  
  565.     Public Function tlcUpdateIsActive(ByVal tmpTableName As String, ByVal tmpKeyName As String, ByVal tmpColumnName As String, ByVal tmpKey As Long, ByVal tmpValue As Boolean) As Integer
  566.         Dim Sql As String = "", tmpFlag As Long
  567.         Try
  568.             Conn = New cConnection()
  569.             Sql = "UPDATE [" & tmpTableName & "] SET [" & tmpColumnName & "] = " & tmpValue
  570.             Sql = Sql & " WHERE " & tmpKeyName & " = " & tmpKey
  571.             Session("sql") = Sql
  572.             Dim command As OleDbCommand = Conn.GetCommand(Sql)
  573.             tmpFlag = command.ExecuteNonQuery()
  574.             Return True
  575.         Catch
  576.             Conn.Dispose()
  577.             Return tmpFlag
  578.         Finally
  579.             Conn.Dispose()
  580.         End Try
  581.     End Function
  582.  
  583.     Public Function tlcFirstDayOfMonth(ByVal tmpDate As Date) As Date
  584.         Return DateAdd("D", -1.0 * DatePart("D", Today) + 1, Today)
  585.     End Function
  586.  
  587.     Public Function tlcLastDayOfMonth(ByVal tmpDate As Date) As Date
  588.         Return DateAdd(DateInterval.Day, (Day(DateAdd(DateInterval.Month, 1, tmpDate))) * -1, DateAdd(DateInterval.Month, 1, tmpDate))
  589.     End Function
  590.  
  591.     Public Function tlcGetXDay(ByVal DOW As Integer, ByVal X As Integer, ByVal M As Integer, ByVal Y As Integer) As Integer
  592.         'Enter the day of week (DOW) you are wanting (0 = Sunday through 6 = Saturday).
  593.         'Enter X (an integer from 1 to N). First = 1, Second = 2, Third = 3, Fourth = 4, Fifth = 5... and so on. If the number is too high, it will just return the last DOW. 
  594.         'M and Y are month and year respectively.
  595.         'For example, if you are looking for the last Tuesday of July 2009, you can do get_Xth_DOW(2,6,7,2009).
  596.  
  597.         Dim numDays = tlcGetDaysInMonth(M, Y)
  598.         Dim add = 7 * (X - 1)
  599.         Dim firstDOW = Weekday(M & "/" & Y) - 1
  600.         Dim diff = firstDOW - DOW
  601.         Dim d = 1
  602.         If diff > 0 Then
  603.             d = d + (7 - diff)
  604.         End If
  605.         If diff < 0 Then
  606.             d = d + -1 * diff
  607.         End If
  608.         d = d + add
  609.         Do While d > numDays
  610.             d = d - 7
  611.         Loop
  612.         tlcGetXDay = d
  613.     End Function
  614.  
  615.     Public Function tlcGetDaysInMonth(ByVal strMonth As Integer, ByVal strYear As Integer) As Integer
  616.         Dim strDays As Integer
  617.         Select Case CInt(strMonth)
  618.             Case 1, 3, 5, 7, 8, 10, 12
  619.                 strDays = 31
  620.             Case 4, 6, 9, 11
  621.                 strDays = 30
  622.             Case 2
  623.                 If ((CInt(strYear) Mod 4 = 0 And _
  624.                 CInt(strYear) Mod 100 <> 0) _
  625.                 Or (CInt(strYear) Mod 400 = 0)) Then
  626.                     strDays = 29
  627.                 Else
  628.                     strDays = 28
  629.                 End If
  630.         End Select
  631.         tlcGetDaysInMonth = strDays
  632.     End Function
  633.  
  634.     Public Function tlcCheckTime(ByRef strTime As String) As Integer
  635.         Dim pos As Integer, pos2 As Integer, AMPM As String
  636.         strTime = UCase(strTime)
  637.         If Right(strTime, 1) = "p" Or Right(strTime, 1) = "P" Or Right(strTime, 1) = "a" Or Right(strTime, 1) = "A" Then
  638.             strTime = strTime & "M"
  639.         End If
  640.         strTime = Replace(strTime, ".", ":")
  641.         pos = InStr(strTime, ":")
  642.         If pos <= 0 Then
  643.             If Right(strTime, 2) = "AM" Or Right(strTime, 2) = "PM" Then
  644.                 pos2 = Len(strTime) - 2
  645.                 If Mid(strTime, pos2, 1) = " " Then pos2 = pos2 - 1
  646.                 strTime = Left(strTime, pos2) & ":00 " & Right(strTime, 2)
  647.             Else
  648.                 strTime = strTime & ":00"
  649.             End If
  650.         Else
  651.             If Right(strTime, 2) = "AM" Or Right(strTime, 2) = "PM" Then
  652.                 AMPM = Right(strTime, 2)
  653.                 pos2 = Len(strTime) - 2
  654.                 strTime = Left(strTime, pos2)
  655.                 If Mid(strTime, pos2, 1) = " " Then
  656.                     pos2 = pos2 - 1
  657.                     strTime = Left(strTime, pos2)
  658.                 End If
  659.                 If pos2 = pos Then strTime = strTime & "00"
  660.                 If pos2 = pos + 1 Then strTime = strTime & "0"
  661.                 strTime = strTime & " " & AMPM
  662.             Else
  663.                 pos2 = Len(strTime)
  664.                 If pos2 = pos Then strTime = strTime & "00"
  665.                 If pos2 = pos + 1 Then strTime = strTime & "0"
  666.             End If
  667.         End If
  668.     End Function
  669.  
  670.     Public Function tlcFirstDayOfWeek(ByVal tmpDate As Date) As Date
  671.         Dim nowdayofweek As Integer = tmpDate.DayOfWeek
  672.         Dim weekStartDate As DateTime
  673.         weekStartDate = DateAdd("d", 0 - tmpDate.DayOfWeek, tmpDate)
  674.         Return weekStartDate
  675.     End Function
  676.  
  677.     Public Function tlcLastDayOfWeek(ByVal tmpDate As Date) As Date
  678.         Dim nowdayofweek As Integer = tmpDate.DayOfWeek
  679.         Dim weekEndDate As DateTime
  680.         weekEndDate = DateAdd("d", 6 - tmpDate.DayOfWeek, tmpDate)
  681.         Return weekEndDate
  682.     End Function
  683.  
  684.     Function SafeDBNull(ByVal Field)
  685.         'Returns an empty string if the Field value is Null
  686.         If IsDBNull(Field) Then
  687.             SafeDBNull = ""
  688.         Else
  689.             SafeDBNull = Field
  690.         End If
  691.     End Function
  692.  
  693.     Public Function tlcGetWeekTotal(ByVal tmpEmpID As Long, ByVal tmpStartDate As String, ByVal tmpEndDate As String) As Long
  694.         Dim RsRow As OleDbDataReader
  695.         Dim sSql As String = "SELECT tblSchedule.schEmpID, Sum(DateDiff('n',[schActualStart],[schActualEnd])) AS TotalTime " _
  696. & "FROM tblSchedule " _
  697. & "WHERE (tblSchedule.schDate >=#" & tmpStartDate & "# AND tblSchedule.schDate <= #" & tmpEndDate & "#) AND (tblSchedule.schEmpID=" & tmpEmpID & ") " _
  698. & "GROUP BY tblSchedule.schEmpID " _
  699. & "HAVING (((tblSchedule.schEmpID)=" & tmpEmpID & ")) "
  700.         ' Write SQL for debug
  701.         If EW_DEBUG_ENABLED Then ew_Write(sSql & "<br>")
  702.         Try
  703.             Conn = New cConnection()
  704.             RsRow = Conn.GetTempDataReader(sSql)
  705.             If Not RsRow.Read() Then
  706.                 Return False
  707.             Else
  708.                 '                Return True
  709.                 Return RsRow("TotalTime")
  710.             End If
  711.         Catch
  712.             '            If EW_DEBUG_ENABLED Then Throw
  713.             Return False
  714.         Finally
  715.             Conn.CloseTempDataReader()
  716.             Conn.Dispose()
  717.         End Try
  718.     End Function
  719.  
  720. End Class
  721.