home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / tblEmployeesadd.aspx.vb < prev    next >
Text File  |  2012-01-28  |  48KB  |  1,262 lines

  1. Imports System.Data
  2. Imports System.Data.Common
  3. Imports System.Xml
  4. Imports System.IO
  5. Imports System.Data.OleDb
  6.  
  7. '
  8. ' ASP.NET code-behind class (Page)
  9. '
  10.  
  11. Partial Class tblEmployeesadd
  12.     Inherits AspNetMaker7_tfpssnet
  13.  
  14.     ' Page object
  15.     Public tblEmployees_add As ctblEmployees_add
  16.  
  17.     '
  18.     ' Page Class
  19.     '
  20.     Class ctblEmployees_add
  21.         Inherits AspNetMakerPage
  22.         Implements IDisposable        
  23.  
  24.         ' Used by system generated functions
  25.         Private RsWrk As Object, sSqlWrk As String, sWhereWrk As String
  26.  
  27.         Private arwrk As Object
  28.  
  29.         Private armultiwrk() As String        
  30.  
  31.         ' Page URL
  32.         Public ReadOnly Property PageUrl() As String
  33.             Get
  34.                 Dim Url As String = ew_CurrentPage() & "?"
  35.                 If tblEmployees.UseTokenInUrl Then Url = Url & "t=" & tblEmployees.TableVar & "&" ' Add page token
  36.                 Return Url    
  37.             End Get
  38.         End Property
  39.  
  40.         ' Validate page request
  41.         Public Function IsPageRequest() As Boolean
  42.             Dim Result As Boolean
  43.             If tblEmployees.UseTokenInUrl Then
  44.                 Result = False
  45.                 If ObjForm IsNot Nothing Then
  46.                     Result = (tblEmployees.TableVar = ObjForm.GetValue("t"))
  47.                 End If
  48.                 If ew_Get("t") <> "" Then
  49.                     Result = (tblEmployees.TableVar = ew_Get("t"))
  50.                 End If
  51.                 Return Result
  52.             End If
  53.             Return True            
  54.         End Function    
  55.  
  56.         ' tblEmployees
  57.         Public Property tblEmployees() As ctblEmployees
  58.             Get                
  59.                 Return ParentPage.tblEmployees
  60.             End Get
  61.             Set(ByVal v As ctblEmployees)
  62.                 ParentPage.tblEmployees = v    
  63.             End Set    
  64.         End Property
  65.  
  66.         '
  67.         '  Constructor
  68.         '  - init objects
  69.         '  - open connection
  70.         '
  71.         Public Sub New(ByRef APage As AspNetMaker7_tfpssnet)                
  72.             m_ParentPage = APage
  73.             m_Page = Me    
  74.             m_PageID = "add"
  75.             m_PageObjName = "tblEmployees_add"
  76.             m_PageObjTypeName = "ctblEmployees_add"
  77.  
  78.             ' Table Name
  79.             m_TableName = "tblEmployees"
  80.  
  81.             ' Initialize table object
  82.             tblEmployees = New ctblEmployees(Me)
  83.  
  84.             ' Connect to database
  85.             Conn = New cConnection()
  86.         End Sub
  87.  
  88.         '
  89.         '  Subroutine Page_Init
  90.         '  - called before page main
  91.         '  - check Security
  92.         '  - set up response header
  93.         '  - call page load events
  94.         '
  95.         Public Sub Page_Init()
  96.             Security = New cAdvancedSecurity(Me)
  97.             If Not Security.IsLoggedIn() Then Security.AutoLogin()
  98.             If Not Security.IsLoggedIn() Then
  99.                 Security.SaveLastUrl()
  100.                 Page_Terminate("login.aspx")
  101.             End If
  102.  
  103.             ' Table Permission loading event
  104.             Security.TablePermission_Loading()
  105.             Security.LoadCurrentUserLevel(TableName)
  106.  
  107.             ' Table Permission loaded event
  108.             Security.TablePermission_Loaded()
  109.             If Not Security.CanAdd Then
  110.                 Security.SaveLastUrl()
  111.                 Page_Terminate("tblEmployeeslist.aspx")
  112.             End If
  113.  
  114.             ' User ID loading event
  115.             Security.UserID_Loading()
  116.             If Security.IsLoggedIn() Then Call Security.LoadUserID()
  117.  
  118.             ' User ID loaded event
  119.             Security.UserID_Loaded()
  120.             If Security.IsLoggedIn() And ew_Empty(Security.CurrentUserID) Then
  121.                 Message = "You do not have the right permission to view the page"
  122.                 Page_Terminate("tblEmployeeslist.aspx")
  123.             End If
  124.  
  125.             ' Global page loading event (in ewglobal*.vb)
  126.             ParentPage.Page_Loading()
  127.  
  128.             ' Page load event, used in current page
  129.             Page_Load()
  130.         End Sub
  131.  
  132.         '
  133.         '  Class terminate
  134.         '  - clean up page object
  135.         '
  136.         Public Sub Dispose() Implements IDisposable.Dispose
  137.             Page_Terminate("")
  138.         End Sub
  139.  
  140.         '
  141.         '  Sub Page_Terminate
  142.         '  - called when exit page
  143.         '  - clean up connection and objects
  144.         '  - if URL specified, redirect to URL
  145.         '
  146.         Sub Page_Terminate(url As String)
  147.  
  148.             ' Page unload event, used in current page
  149.             Page_Unload()
  150.  
  151.             ' Global page unloaded event (in ewglobal*.vb)
  152.             ParentPage.Page_Unloaded()
  153.  
  154.             ' Close connection
  155.             Conn.Dispose()
  156.             Security = Nothing
  157.             tblEmployees.Dispose()
  158.  
  159.             ' Go to URL if specified
  160.             If url <> "" Then
  161.                 HttpContext.Current.Response.Clear()
  162.                 HttpContext.Current.Response.Redirect(url)
  163.             End If
  164.         End Sub
  165.  
  166.     Public x_ewPriv As Integer
  167.  
  168.     '
  169.     ' Page main processing
  170.     '
  171.     Sub Page_Main()
  172.  
  173.         ' Load key values from QueryString
  174.         Dim bCopy As Boolean = True
  175.         If ew_Get("empID") <> "" Then
  176.             tblEmployees.empID.QueryStringValue = ew_Get("empID")
  177.         Else
  178.             bCopy = False
  179.         End If
  180.  
  181.         ' Create form object
  182.         ObjForm = New cFormObj
  183.  
  184.         ' Process form if post back
  185.         If ObjForm.GetValue("a_add") <> "" Then
  186.             tblEmployees.CurrentAction = ObjForm.GetValue("a_add") ' Get form action
  187.             LoadFormValues() ' Load form values
  188.  
  189.             ' Validate Form
  190.             If Not ValidateForm() Then
  191.                 tblEmployees.CurrentAction = "I" ' Form error, reset action
  192.                 Message = ParentPage.gsFormError
  193.             End If
  194.  
  195.         ' Not post back
  196.         Else
  197.             If bCopy Then
  198.                 tblEmployees.CurrentAction = "C" ' Copy Record
  199.             Else
  200.                 tblEmployees.CurrentAction = "I" ' Display Blank Record
  201.                 LoadDefaultValues() ' Load default values
  202.             End If
  203.         End If
  204.  
  205.         ' Perform action based on action code
  206.         Select Case tblEmployees.CurrentAction
  207.             Case "I" ' Blank record, no action required
  208.             Case "C" ' Copy an existing record
  209.                 If Not LoadRow() Then ' Load record based on key
  210.                     Message = "No records found" ' No record found
  211.                     Page_Terminate("tblEmployeeslist.aspx") ' No matching record, return to list
  212.                 End If
  213.             Case "A" ' Add new record
  214.                 tblEmployees.SendEmail = True ' Send email on add success
  215.                 If AddRow() Then ' Add successful
  216.                     Message = "Add succeeded" ' Set up success message
  217.                     Dim sReturnUrl As String = tblEmployees.ReturnUrl
  218.                     Page_Terminate(sReturnUrl) ' Clean up and return
  219.                 Else
  220.                     RestoreFormValues() ' Add failed, restore form values
  221.                 End If
  222.         End Select
  223.  
  224.         ' Render row based on row type
  225.         tblEmployees.RowType = EW_ROWTYPE_ADD ' Render add type
  226.  
  227.         ' Render row
  228.         RenderRow()
  229.     End Sub
  230.  
  231.     '
  232.     ' Get upload file
  233.     '
  234.     Sub GetUploadFiles()
  235.  
  236.         ' Get upload data
  237.     End Sub
  238.  
  239.     '
  240.     ' Load default values
  241.     '
  242.     Sub LoadDefaultValues()
  243.         tblEmployees.empRate.CurrentValue = 0
  244.         tblEmployees.empLastRaiseAmount.CurrentValue = 0
  245.     End Sub
  246.  
  247.     '
  248.     ' Load form values
  249.     '
  250.     Sub LoadFormValues()
  251.         tblEmployees.empID.FormValue = ObjForm.GetValue("x_empID")
  252.         tblEmployees.empID.OldValue = ObjForm.GetValue("o_empID")
  253.             tblEmployees.empPayrollNumber.FormValue = ObjForm.GetValue("x_empPayrollNumber")
  254.             tblEmployees.empPayrollNumber.OldValue = ObjForm.GetValue("o_empPayrollNumber")
  255.             tblEmployees.empUsername.FormValue = ObjForm.GetValue("x_empUsername")
  256.             tblEmployees.empUsername.OldValue = ObjForm.GetValue("o_empUsername")
  257.             tblEmployees.empName.FormValue = ObjForm.GetValue("x_empName")
  258.         tblEmployees.empName.OldValue = ObjForm.GetValue("o_empName")
  259.             tblEmployees.empFirstName.FormValue = ObjForm.GetValue("x_empFirstName")
  260.             tblEmployees.empFirstName.OldValue = ObjForm.GetValue("o_empFirstNamr")
  261.             tblEmployees.empLastName.FormValue = ObjForm.GetValue("x_empLastName")
  262.             tblEmployees.empLastName.OldValue = ObjForm.GetValue("o_empLastName")
  263.             tblEmployees.empAddress.FormValue = ObjForm.GetValue("x_empAddress")
  264.         tblEmployees.empAddress.OldValue = ObjForm.GetValue("o_empAddress")
  265.         tblEmployees.empCity.FormValue = ObjForm.GetValue("x_empCity")
  266.         tblEmployees.empCity.OldValue = ObjForm.GetValue("o_empCity")
  267.         tblEmployees.empState.FormValue = ObjForm.GetValue("x_empState")
  268.         tblEmployees.empState.OldValue = ObjForm.GetValue("o_empState")
  269.         tblEmployees.empZIP.FormValue = ObjForm.GetValue("x_empZIP")
  270.         tblEmployees.empZIP.OldValue = ObjForm.GetValue("o_empZIP")
  271.         tblEmployees.empPhone.FormValue = ObjForm.GetValue("x_empPhone")
  272.         tblEmployees.empPhone.OldValue = ObjForm.GetValue("o_empPhone")
  273.         tblEmployees.empStatusID.FormValue = ObjForm.GetValue("x_empStatusID")
  274.         tblEmployees.empStatusID.OldValue = ObjForm.GetValue("o_empStatusID")
  275.         tblEmployees.empStartDate.FormValue = ObjForm.GetValue("x_empStartDate")
  276.         tblEmployees.empStartDate.CurrentValue = ew_UnFormatDateTime(tblEmployees.empStartDate.CurrentValue, 6)
  277.         tblEmployees.empStartDate.OldValue = ObjForm.GetValue("o_empStartDate")
  278.         tblEmployees.empPositionID.FormValue = ObjForm.GetValue("x_empPositionID")
  279.         tblEmployees.empPositionID.OldValue = ObjForm.GetValue("o_empPositionID")
  280.         tblEmployees.empRate.FormValue = ObjForm.GetValue("x_empRate")
  281.         tblEmployees.empRate.OldValue = ObjForm.GetValue("o_empRate")
  282.         tblEmployees.empLastRaiseDate.FormValue = ObjForm.GetValue("x_empLastRaiseDate")
  283.         tblEmployees.empLastRaiseDate.CurrentValue = ew_UnFormatDateTime(tblEmployees.empLastRaiseDate.CurrentValue, 6)
  284.         tblEmployees.empLastRaiseDate.OldValue = ObjForm.GetValue("o_empLastRaiseDate")
  285.         tblEmployees.empLastRaiseAmount.FormValue = ObjForm.GetValue("x_empLastRaiseAmount")
  286.         tblEmployees.empLastRaiseAmount.OldValue = ObjForm.GetValue("o_empLastRaiseAmount")
  287.         tblEmployees.empEmail.FormValue = ObjForm.GetValue("x_empEmail")
  288.         tblEmployees.empEmail.OldValue = ObjForm.GetValue("o_empEmail")
  289.         tblEmployees.empLiftCert.FormValue = ObjForm.GetValue("x_empLiftCert")
  290.         tblEmployees.empLiftCert.OldValue = ObjForm.GetValue("o_empLiftCert")
  291.         tblEmployees.empForkCert.FormValue = ObjForm.GetValue("x_empForkCert")
  292.         tblEmployees.empForkCert.OldValue = ObjForm.GetValue("o_empForkCert")
  293.             tblEmployees.empDriveAuth.FormValue = ObjForm.GetValue("x_empDriveAuth")
  294.             tblEmployees.empDriveAuth.OldValue = ObjForm.GetValue("o_empDriveAuth")
  295.             tblEmployees.empTimeClock.FormValue = ObjForm.GetValue("x_empTimeClock")
  296.             tblEmployees.empTimeClock.OldValue = ObjForm.GetValue("o_empTimeClock")
  297.             tblEmployees.empIsActive.FormValue = ObjForm.GetValue("x_empIsActive")
  298.             tblEmployees.empIsActive.OldValue = ObjForm.GetValue("o_empIsActive")
  299.             tblEmployees.empUserPass.FormValue = ObjForm.GetValue("x_empUserPass")
  300.         tblEmployees.empUserPass.OldValue = ObjForm.GetValue("o_empUserPass")
  301.         tblEmployees.empUserLevel.FormValue = ObjForm.GetValue("x_empUserLevel")
  302.         tblEmployees.empUserLevel.OldValue = ObjForm.GetValue("o_empUserLevel")
  303.     End Sub
  304.  
  305.     '
  306.     ' Restore form values
  307.     '
  308.     Sub RestoreFormValues()
  309.         tblEmployees.empID.CurrentValue = tblEmployees.empID.FormValue
  310.             tblEmployees.empPayrollNumber.CurrentValue = tblEmployees.empPayrollNumber.FormValue
  311.             tblEmployees.empUsername.CurrentValue = tblEmployees.empUsername.FormValue
  312.             tblEmployees.empName.CurrentValue = tblEmployees.empName.FormValue
  313.             tblEmployees.empFirstName.CurrentValue = tblEmployees.empFirstName.FormValue
  314.             tblEmployees.empLastName.CurrentValue = tblEmployees.empLastName.FormValue
  315.             tblEmployees.empAddress.CurrentValue = tblEmployees.empAddress.FormValue
  316.         tblEmployees.empCity.CurrentValue = tblEmployees.empCity.FormValue
  317.         tblEmployees.empState.CurrentValue = tblEmployees.empState.FormValue
  318.         tblEmployees.empZIP.CurrentValue = tblEmployees.empZIP.FormValue
  319.         tblEmployees.empPhone.CurrentValue = tblEmployees.empPhone.FormValue
  320.         tblEmployees.empStatusID.CurrentValue = tblEmployees.empStatusID.FormValue
  321.         tblEmployees.empStartDate.CurrentValue = tblEmployees.empStartDate.FormValue
  322.         tblEmployees.empStartDate.CurrentValue = ew_UnFormatDateTime(tblEmployees.empStartDate.CurrentValue, 6)
  323.         tblEmployees.empPositionID.CurrentValue = tblEmployees.empPositionID.FormValue
  324.         tblEmployees.empRate.CurrentValue = tblEmployees.empRate.FormValue
  325.         tblEmployees.empLastRaiseDate.CurrentValue = tblEmployees.empLastRaiseDate.FormValue
  326.         tblEmployees.empLastRaiseDate.CurrentValue = ew_UnFormatDateTime(tblEmployees.empLastRaiseDate.CurrentValue, 6)
  327.         tblEmployees.empLastRaiseAmount.CurrentValue = tblEmployees.empLastRaiseAmount.FormValue
  328.         tblEmployees.empEmail.CurrentValue = tblEmployees.empEmail.FormValue
  329.         tblEmployees.empLiftCert.CurrentValue = tblEmployees.empLiftCert.FormValue
  330.         tblEmployees.empForkCert.CurrentValue = tblEmployees.empForkCert.FormValue
  331.             tblEmployees.empDriveAuth.CurrentValue = tblEmployees.empDriveAuth.FormValue
  332.             tblEmployees.empTimeClock.CurrentValue = tblEmployees.empTimeClock.FormValue
  333.             tblEmployees.empIsActive.CurrentValue = tblEmployees.empIsActive.FormValue
  334.             tblEmployees.empUserPass.CurrentValue = tblEmployees.empUserPass.FormValue
  335.         tblEmployees.empUserLevel.CurrentValue = tblEmployees.empUserLevel.FormValue
  336.     End Sub
  337.  
  338.     '
  339.     ' Load row based on key values
  340.     '
  341.     Function LoadRow() As Boolean
  342.         Dim RsRow As OleDbDataReader
  343.         Dim sFilter As String = tblEmployees.KeyFilter
  344.  
  345.         ' Row Selecting event
  346.         tblEmployees.Row_Selecting(sFilter)
  347.  
  348.         ' Load SQL based on filter
  349.         tblEmployees.CurrentFilter = sFilter
  350.         Dim sSql As String = tblEmployees.SQL
  351.  
  352.         ' Write SQL for debug
  353.         If EW_DEBUG_ENABLED Then ew_Write(sSql)
  354.         Try
  355.             RsRow = Conn.GetTempDataReader(sSql)    
  356.             If Not RsRow.Read() Then
  357.                 Return False
  358.             Else                
  359.                 LoadRowValues(RsRow) ' Load row values
  360.  
  361.                 ' Row Selected event
  362.                 tblEmployees.Row_Selected(RsRow)
  363.                 Return True    
  364.             End If
  365.         Catch
  366.             If EW_DEBUG_ENABLED Then Throw
  367.             Return False
  368.         Finally
  369.             Conn.CloseTempDataReader()
  370.         End Try
  371.     End Function
  372.  
  373.     '
  374.     ' Load row values from recordset
  375.     '
  376.     Sub LoadRowValues(ByRef RsRow As OleDbDataReader)
  377.         tblEmployees.empID.DbValue = RsRow("empID")
  378.             tblEmployees.empPayrollNumber.DbValue = RsRow("empPayrollNumber")
  379.             tblEmployees.empUsername.DbValue = RsRow("empUsername")
  380.             tblEmployees.empName.DbValue = RsRow("empName")
  381.         tblEmployees.empFirstName.DbValue = RsRow("empFirstName")
  382.         tblEmployees.empLastName.DbValue = RsRow("empLastName")
  383.         tblEmployees.empAddress.DbValue = RsRow("empAddress")
  384.         tblEmployees.empCity.DbValue = RsRow("empCity")
  385.         tblEmployees.empState.DbValue = RsRow("empState")
  386.         tblEmployees.empZIP.DbValue = RsRow("empZIP")
  387.         tblEmployees.empPhone.DbValue = RsRow("empPhone")
  388.         tblEmployees.empStatusID.DbValue = RsRow("empStatusID")
  389.         tblEmployees.empStartDate.DbValue = RsRow("empStartDate")
  390.         tblEmployees.empPositionID.DbValue = RsRow("empPositionID")
  391.         tblEmployees.empRate.DbValue = RsRow("empRate")
  392.         tblEmployees.empLastRaiseDate.DbValue = RsRow("empLastRaiseDate")
  393.         tblEmployees.empLastRaiseAmount.DbValue = RsRow("empLastRaiseAmount")
  394.         tblEmployees.empEmail.DbValue = RsRow("empEmail")
  395.         tblEmployees.empLiftCert.DbValue = IIf(ew_ConvertToBool(RsRow("empLiftCert")), "1", "0")
  396.         tblEmployees.empForkCert.DbValue = IIf(ew_ConvertToBool(RsRow("empForkCert")), "1", "0")
  397.             tblEmployees.empDriveAuth.DbValue = IIf(ew_ConvertToBool(RsRow("empDriveAuth")), "1", "0")
  398.             tblEmployees.empTimeClock.DbValue = IIf(ew_ConvertToBool(RsRow("empTimeClock")), "1", "0")
  399.             tblEmployees.empIsActive.DbValue = IIf(ew_ConvertToBool(RsRow("empIsActive")), "1", "0")
  400.             tblEmployees.empUserPass.DbValue = RsRow("empUserPass")
  401.         tblEmployees.empUserLevel.DbValue = RsRow("empUserLevel")
  402.     End Sub
  403.  
  404.     '
  405.     ' Render row values based on field settings
  406.     '
  407.     Sub RenderRow()
  408.  
  409.         ' Row Rendering event
  410.         tblEmployees.Row_Rendering()
  411.  
  412.         '
  413.         '  Common render codes for all row types
  414.         '
  415.         ' empID
  416.  
  417.         tblEmployees.empID.CellCssStyle = ""
  418.         tblEmployees.empID.CellCssClass = ""
  419.  
  420.             ' empPayrollNumber
  421.             tblEmployees.empPayrollNumber.CellCssStyle = ""
  422.             tblEmployees.empPayrollNumber.CellCssClass = ""
  423.  
  424.             ' empUsername
  425.             tblEmployees.empUsername.CellCssStyle = ""
  426.             tblEmployees.empUsername.CellCssClass = ""
  427.  
  428.             ' empName
  429.         tblEmployees.empName.CellCssStyle = ""
  430.         tblEmployees.empName.CellCssClass = ""
  431.  
  432.             ' empFirstName
  433.             tblEmployees.empFirstName.CellCssStyle = ""
  434.             tblEmployees.empFirstName.CellCssClass = ""
  435.  
  436.             ' empLastName
  437.             tblEmployees.empLastName.CellCssStyle = ""
  438.             tblEmployees.empLastName.CellCssClass = ""
  439.  
  440.             ' empAddress
  441.         tblEmployees.empAddress.CellCssStyle = ""
  442.         tblEmployees.empAddress.CellCssClass = ""
  443.  
  444.         ' empCity
  445.         tblEmployees.empCity.CellCssStyle = ""
  446.         tblEmployees.empCity.CellCssClass = ""
  447.  
  448.         ' empState
  449.         tblEmployees.empState.CellCssStyle = ""
  450.         tblEmployees.empState.CellCssClass = ""
  451.  
  452.         ' empZIP
  453.         tblEmployees.empZIP.CellCssStyle = ""
  454.         tblEmployees.empZIP.CellCssClass = ""
  455.  
  456.         ' empPhone
  457.         tblEmployees.empPhone.CellCssStyle = ""
  458.         tblEmployees.empPhone.CellCssClass = ""
  459.  
  460.         ' empStatusID
  461.         tblEmployees.empStatusID.CellCssStyle = ""
  462.         tblEmployees.empStatusID.CellCssClass = ""
  463.  
  464.         ' empStartDate
  465.         tblEmployees.empStartDate.CellCssStyle = ""
  466.         tblEmployees.empStartDate.CellCssClass = ""
  467.  
  468.         ' empPositionID
  469.         tblEmployees.empPositionID.CellCssStyle = ""
  470.         tblEmployees.empPositionID.CellCssClass = ""
  471.  
  472.         ' empRate
  473.         tblEmployees.empRate.CellCssStyle = ""
  474.         tblEmployees.empRate.CellCssClass = ""
  475.  
  476.         ' empLastRaiseDate
  477.         tblEmployees.empLastRaiseDate.CellCssStyle = ""
  478.         tblEmployees.empLastRaiseDate.CellCssClass = ""
  479.  
  480.         ' empLastRaiseAmount
  481.         tblEmployees.empLastRaiseAmount.CellCssStyle = ""
  482.         tblEmployees.empLastRaiseAmount.CellCssClass = ""
  483.  
  484.         ' empEmail
  485.         tblEmployees.empEmail.CellCssStyle = ""
  486.         tblEmployees.empEmail.CellCssClass = ""
  487.  
  488.         ' empLiftCert
  489.         tblEmployees.empLiftCert.CellCssStyle = ""
  490.         tblEmployees.empLiftCert.CellCssClass = ""
  491.  
  492.         ' empForkCert
  493.         tblEmployees.empForkCert.CellCssStyle = ""
  494.         tblEmployees.empForkCert.CellCssClass = ""
  495.  
  496.             ' empDriveAuth
  497.             tblEmployees.empDriveAuth.CellCssStyle = ""
  498.             tblEmployees.empDriveAuth.CellCssClass = ""
  499.  
  500.             ' empTimeClock
  501.             tblEmployees.empTimeClock.CellCssStyle = ""
  502.             tblEmployees.empTimeClock.CellCssClass = ""
  503.  
  504.             ' empIsActive
  505.             tblEmployees.empIsActive.CellCssStyle = ""
  506.             tblEmployees.empIsActive.CellCssClass = ""
  507.  
  508.             ' empUserPass
  509.         tblEmployees.empUserPass.CellCssStyle = ""
  510.         tblEmployees.empUserPass.CellCssClass = ""
  511.  
  512.         ' empUserLevel
  513.         tblEmployees.empUserLevel.CellCssStyle = ""
  514.         tblEmployees.empUserLevel.CellCssClass = ""
  515.  
  516.         '
  517.         '  View  Row
  518.         '
  519.  
  520.         If tblEmployees.RowType = EW_ROWTYPE_VIEW Then ' View row
  521.  
  522.             ' empID
  523.             tblEmployees.empID.ViewValue = tblEmployees.empID.CurrentValue
  524.             tblEmployees.empID.CssStyle = ""
  525.             tblEmployees.empID.CssClass = ""
  526.             tblEmployees.empID.ViewCustomAttributes = ""
  527.  
  528.                 ' empPayrollNumber
  529.                 tblEmployees.empPayrollNumber.ViewValue = tblEmployees.empPayrollNumber.CurrentValue
  530.                 tblEmployees.empPayrollNumber.CssStyle = ""
  531.                 tblEmployees.empPayrollNumber.CssClass = ""
  532.                 tblEmployees.empPayrollNumber.ViewCustomAttributes = ""
  533.  
  534.                 ' empUsername
  535.                 tblEmployees.empUsername.ViewValue = tblEmployees.empUsername.CurrentValue
  536.                 tblEmployees.empUsername.CssStyle = ""
  537.                 tblEmployees.empUsername.CssClass = ""
  538.                 tblEmployees.empUsername.ViewCustomAttributes = ""
  539.  
  540.             ' empName
  541.             tblEmployees.empName.ViewValue = tblEmployees.empName.CurrentValue
  542.             tblEmployees.empName.CssStyle = ""
  543.             tblEmployees.empName.CssClass = ""
  544.             tblEmployees.empName.ViewCustomAttributes = ""
  545.  
  546.                 ' empFirstName
  547.                 tblEmployees.empFirstName.ViewValue = tblEmployees.empFirstName.CurrentValue
  548.                 tblEmployees.empFirstName.CssStyle = ""
  549.                 tblEmployees.empFirstName.CssClass = ""
  550.                 tblEmployees.empFirstName.ViewCustomAttributes = ""
  551.  
  552.                 ' empLastName
  553.                 tblEmployees.empLastName.ViewValue = tblEmployees.empLastName.CurrentValue
  554.                 tblEmployees.empLastName.CssStyle = ""
  555.                 tblEmployees.empLastName.CssClass = ""
  556.                 tblEmployees.empLastName.ViewCustomAttributes = ""
  557.  
  558.                 ' empAddress
  559.             tblEmployees.empAddress.ViewValue = tblEmployees.empAddress.CurrentValue
  560.             tblEmployees.empAddress.CssStyle = ""
  561.             tblEmployees.empAddress.CssClass = ""
  562.             tblEmployees.empAddress.ViewCustomAttributes = ""
  563.  
  564.             ' empCity
  565.             tblEmployees.empCity.ViewValue = tblEmployees.empCity.CurrentValue
  566.             tblEmployees.empCity.CssStyle = ""
  567.             tblEmployees.empCity.CssClass = ""
  568.             tblEmployees.empCity.ViewCustomAttributes = ""
  569.  
  570.             ' empState
  571.             tblEmployees.empState.ViewValue = tblEmployees.empState.CurrentValue
  572.             tblEmployees.empState.CssStyle = ""
  573.             tblEmployees.empState.CssClass = ""
  574.             tblEmployees.empState.ViewCustomAttributes = ""
  575.  
  576.             ' empZIP
  577.             tblEmployees.empZIP.ViewValue = tblEmployees.empZIP.CurrentValue
  578.             tblEmployees.empZIP.CssStyle = ""
  579.             tblEmployees.empZIP.CssClass = ""
  580.             tblEmployees.empZIP.ViewCustomAttributes = ""
  581.  
  582.             ' empPhone
  583.             tblEmployees.empPhone.ViewValue = tblEmployees.empPhone.CurrentValue
  584.             tblEmployees.empPhone.CssStyle = ""
  585.             tblEmployees.empPhone.CssClass = ""
  586.             tblEmployees.empPhone.ViewCustomAttributes = ""
  587.  
  588.             ' empStatusID
  589.             If ew_NotEmpty(tblEmployees.empStatusID.CurrentValue) Then
  590.                 sSqlWrk = "SELECT [tscStatus] FROM [tblEmployeeStatus] WHERE [ID] = " & ew_AdjustSql(tblEmployees.empStatusID.CurrentValue) & ""
  591.                 sSqlWrk = sSqlWrk & " ORDER BY [tscStatus] "
  592.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  593.                 If RsWrk.Read() Then
  594.                     tblEmployees.empStatusID.ViewValue = RsWrk("tscStatus")
  595.                 Else
  596.                     tblEmployees.empStatusID.ViewValue = tblEmployees.empStatusID.CurrentValue
  597.                 End If
  598.                 Conn.CloseTempDataReader()
  599.             Else
  600.                 tblEmployees.empStatusID.ViewValue = System.DBNull.Value
  601.             End If
  602.             tblEmployees.empStatusID.CssStyle = ""
  603.             tblEmployees.empStatusID.CssClass = ""
  604.             tblEmployees.empStatusID.ViewCustomAttributes = ""
  605.  
  606.             ' empStartDate
  607.             tblEmployees.empStartDate.ViewValue = tblEmployees.empStartDate.CurrentValue
  608.             tblEmployees.empStartDate.ViewValue = ew_FormatDateTime(tblEmployees.empStartDate.ViewValue, 6)
  609.             tblEmployees.empStartDate.CssStyle = ""
  610.             tblEmployees.empStartDate.CssClass = ""
  611.             tblEmployees.empStartDate.ViewCustomAttributes = ""
  612.  
  613.             ' empPositionID
  614.             If ew_NotEmpty(tblEmployees.empPositionID.CurrentValue) Then
  615.                 sSqlWrk = "SELECT [posDescription] FROM [tblPositions] WHERE [posID] = " & ew_AdjustSql(tblEmployees.empPositionID.CurrentValue) & ""
  616.                 sSqlWrk = sSqlWrk & " ORDER BY [posDescription] "
  617.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  618.                 If RsWrk.Read() Then
  619.                     tblEmployees.empPositionID.ViewValue = RsWrk("posDescription")
  620.                 Else
  621.                     tblEmployees.empPositionID.ViewValue = tblEmployees.empPositionID.CurrentValue
  622.                 End If
  623.                 Conn.CloseTempDataReader()
  624.             Else
  625.                 tblEmployees.empPositionID.ViewValue = System.DBNull.Value
  626.             End If
  627.             tblEmployees.empPositionID.CssStyle = ""
  628.             tblEmployees.empPositionID.CssClass = ""
  629.             tblEmployees.empPositionID.ViewCustomAttributes = ""
  630.  
  631.             ' empRate
  632.             tblEmployees.empRate.ViewValue = tblEmployees.empRate.CurrentValue
  633.             tblEmployees.empRate.CssStyle = ""
  634.             tblEmployees.empRate.CssClass = ""
  635.             tblEmployees.empRate.ViewCustomAttributes = ""
  636.  
  637.             ' empLastRaiseDate
  638.             tblEmployees.empLastRaiseDate.ViewValue = tblEmployees.empLastRaiseDate.CurrentValue
  639.             tblEmployees.empLastRaiseDate.ViewValue = ew_FormatDateTime(tblEmployees.empLastRaiseDate.ViewValue, 6)
  640.             tblEmployees.empLastRaiseDate.CssStyle = ""
  641.             tblEmployees.empLastRaiseDate.CssClass = ""
  642.             tblEmployees.empLastRaiseDate.ViewCustomAttributes = ""
  643.  
  644.             ' empLastRaiseAmount
  645.             tblEmployees.empLastRaiseAmount.ViewValue = tblEmployees.empLastRaiseAmount.CurrentValue
  646.             tblEmployees.empLastRaiseAmount.CssStyle = ""
  647.             tblEmployees.empLastRaiseAmount.CssClass = ""
  648.             tblEmployees.empLastRaiseAmount.ViewCustomAttributes = ""
  649.  
  650.             ' empEmail
  651.             tblEmployees.empEmail.ViewValue = tblEmployees.empEmail.CurrentValue
  652.             tblEmployees.empEmail.CssStyle = ""
  653.             tblEmployees.empEmail.CssClass = ""
  654.             tblEmployees.empEmail.ViewCustomAttributes = ""
  655.  
  656.             ' empLiftCert
  657.             If Convert.ToString(tblEmployees.empLiftCert.CurrentValue) = "1" Then
  658.                 tblEmployees.empLiftCert.ViewValue = "Yes"
  659.             Else
  660.                 tblEmployees.empLiftCert.ViewValue = "No"
  661.             End If
  662.             tblEmployees.empLiftCert.CssStyle = ""
  663.             tblEmployees.empLiftCert.CssClass = ""
  664.             tblEmployees.empLiftCert.ViewCustomAttributes = ""
  665.  
  666.             ' empForkCert
  667.             If Convert.ToString(tblEmployees.empForkCert.CurrentValue) = "1" Then
  668.                 tblEmployees.empForkCert.ViewValue = "Yes"
  669.             Else
  670.                 tblEmployees.empForkCert.ViewValue = "No"
  671.             End If
  672.             tblEmployees.empForkCert.CssStyle = ""
  673.             tblEmployees.empForkCert.CssClass = ""
  674.             tblEmployees.empForkCert.ViewCustomAttributes = ""
  675.  
  676.                 ' empDriveAuth
  677.                 If Convert.ToString(tblEmployees.empDriveAuth.CurrentValue) = "1" Then
  678.                     tblEmployees.empDriveAuth.ViewValue = "Yes"
  679.                 Else
  680.                     tblEmployees.empDriveAuth.ViewValue = "No"
  681.                 End If
  682.                 tblEmployees.empDriveAuth.CssStyle = ""
  683.                 tblEmployees.empDriveAuth.CssClass = ""
  684.                 tblEmployees.empDriveAuth.ViewCustomAttributes = ""
  685.  
  686.                 ' empTimeClock
  687.                 If Convert.ToString(tblEmployees.empTimeClock.CurrentValue) = "1" Then
  688.                     tblEmployees.empTimeClock.ViewValue = "Yes"
  689.                 Else
  690.                     tblEmployees.empTimeClock.ViewValue = "No"
  691.                 End If
  692.                 tblEmployees.empTimeClock.CssStyle = ""
  693.                 tblEmployees.empTimeClock.CssClass = ""
  694.                 tblEmployees.empTimeClock.ViewCustomAttributes = ""
  695.  
  696.                 ' empIsActive
  697.                 If Convert.ToString(tblEmployees.empIsActive.CurrentValue) = "1" Then
  698.                     tblEmployees.empIsActive.ViewValue = "Yes"
  699.                 Else
  700.                     tblEmployees.empIsActive.ViewValue = "No"
  701.                 End If
  702.                 tblEmployees.empIsActive.CssStyle = ""
  703.                 tblEmployees.empIsActive.CssClass = ""
  704.                 tblEmployees.empIsActive.ViewCustomAttributes = ""
  705.  
  706.                 ' empUserPass
  707.             tblEmployees.empUserPass.ViewValue = "********"
  708.             tblEmployees.empUserPass.CssStyle = ""
  709.             tblEmployees.empUserPass.CssClass = ""
  710.             tblEmployees.empUserPass.ViewCustomAttributes = ""
  711.  
  712.             ' empUserLevel
  713.             If (Security.CurrentUserLevel And EW_ALLOW_ADMIN) = EW_ALLOW_ADMIN Then ' System admin
  714.             If Not IsDBNull(tblEmployees.empUserLevel.CurrentValue) Then
  715.                 Select Case tblEmployees.empUserLevel.CurrentValue
  716.                     Case "-1"
  717.                         tblEmployees.empUserLevel.ViewValue = "Administrator"
  718.                     Case "0"
  719.                         tblEmployees.empUserLevel.ViewValue = "Default"
  720.                     Case "1"
  721.                                 tblEmployees.empUserLevel.ViewValue = "Part Time"
  722.                     Case "2"
  723.                         tblEmployees.empUserLevel.ViewValue = "Standard Lighting"
  724.                             Case "3"
  725.                                 tblEmployees.empUserLevel.ViewValue = "Admin Lighting"
  726.                             Case "4"
  727.                                 tblEmployees.empUserLevel.ViewValue = "Full Time"
  728.                             Case Else
  729.                                 tblEmployees.empUserLevel.ViewValue = tblEmployees.empUserLevel.CurrentValue
  730.                         End Select
  731.             Else
  732.                 tblEmployees.empUserLevel.ViewValue = System.DBNull.Value
  733.             End If
  734.             Else
  735.                 tblEmployees.empUserLevel.ViewValue = "********"
  736.             End If
  737.             tblEmployees.empUserLevel.CssStyle = ""
  738.             tblEmployees.empUserLevel.CssClass = ""
  739.             tblEmployees.empUserLevel.ViewCustomAttributes = ""
  740.  
  741.             ' View refer script
  742.             ' empID
  743.  
  744.             tblEmployees.empID.HrefValue = ""
  745.  
  746.                 ' empUsername
  747.                 tblEmployees.empUsername.HrefValue = ""
  748.  
  749.                 ' empPayrollNumber
  750.                 tblEmployees.empPayrollNumber.HrefValue = ""
  751.  
  752.                 ' empName
  753.             tblEmployees.empName.HrefValue = ""
  754.  
  755.                 ' empFirstName
  756.                 tblEmployees.empFirstName.HrefValue = ""
  757.  
  758.                 ' empLastName
  759.                 tblEmployees.empLastName.HrefValue = ""
  760.  
  761.                 ' empAddress
  762.             tblEmployees.empAddress.HrefValue = ""
  763.  
  764.             ' empCity
  765.             tblEmployees.empCity.HrefValue = ""
  766.  
  767.             ' empState
  768.             tblEmployees.empState.HrefValue = ""
  769.  
  770.             ' empZIP
  771.             tblEmployees.empZIP.HrefValue = ""
  772.  
  773.             ' empPhone
  774.             tblEmployees.empPhone.HrefValue = ""
  775.  
  776.             ' empStatusID
  777.             tblEmployees.empStatusID.HrefValue = ""
  778.  
  779.             ' empStartDate
  780.             tblEmployees.empStartDate.HrefValue = ""
  781.  
  782.             ' empPositionID
  783.             tblEmployees.empPositionID.HrefValue = ""
  784.  
  785.             ' empRate
  786.             tblEmployees.empRate.HrefValue = ""
  787.  
  788.             ' empLastRaiseDate
  789.             tblEmployees.empLastRaiseDate.HrefValue = ""
  790.  
  791.             ' empLastRaiseAmount
  792.             tblEmployees.empLastRaiseAmount.HrefValue = ""
  793.  
  794.             ' empEmail
  795.             tblEmployees.empEmail.HrefValue = ""
  796.  
  797.             ' empLiftCert
  798.             tblEmployees.empLiftCert.HrefValue = ""
  799.  
  800.             ' empForkCert
  801.             tblEmployees.empForkCert.HrefValue = ""
  802.  
  803.                 ' empDriveAuth
  804.                 tblEmployees.empDriveAuth.HrefValue = ""
  805.  
  806.                 ' empTimeClock
  807.                 tblEmployees.empTimeClock.HrefValue = ""
  808.  
  809.                 ' empIsActive
  810.                 tblEmployees.empIsActive.HrefValue = ""
  811.  
  812.                 ' empUserPass
  813.             tblEmployees.empUserPass.HrefValue = ""
  814.  
  815.             ' empUserLevel
  816.             tblEmployees.empUserLevel.HrefValue = ""
  817.  
  818.         '
  819.         '  Add Row
  820.         '
  821.  
  822.         ElseIf tblEmployees.RowType = EW_ROWTYPE_ADD Then ' Add row
  823.  
  824.             ' empID
  825.             tblEmployees.empID.EditCustomAttributes = ""
  826.             If Not Security.IsAdmin And Security.IsLoggedIn() Then ' Non system admin
  827.                 tblEmployees.empID.CurrentValue = Security.CurrentUserID
  828.             tblEmployees.empID.EditValue = tblEmployees.empID.CurrentValue
  829.             tblEmployees.empID.CssStyle = ""
  830.             tblEmployees.empID.CssClass = ""
  831.             tblEmployees.empID.ViewCustomAttributes = ""
  832.             Else
  833.             tblEmployees.empID.EditValue = ew_HtmlEncode(tblEmployees.empID.CurrentValue)
  834.             End If
  835.  
  836.                 ' empPayrollNumber
  837.                 tblEmployees.empPayrollNumber.EditCustomAttributes = ""
  838.                 tblEmployees.empPayrollNumber.EditValue = ew_HtmlEncode(tblEmployees.empPayrollNumber.CurrentValue)
  839.  
  840.                 ' empUsername
  841.                 tblEmployees.empUsername.EditCustomAttributes = ""
  842.                 tblEmployees.empUsername.EditValue = ew_HtmlEncode(tblEmployees.empUsername.CurrentValue)
  843.  
  844.                 ' empName
  845.             tblEmployees.empName.EditCustomAttributes = ""
  846.             tblEmployees.empName.EditValue = ew_HtmlEncode(tblEmployees.empName.CurrentValue)
  847.  
  848.                 ' empFirstName
  849.                 tblEmployees.empFirstName.EditCustomAttributes = ""
  850.                 tblEmployees.empFirstName.EditValue = ew_HtmlEncode(tblEmployees.empFirstName.CurrentValue)
  851.  
  852.                 ' empLastName
  853.                 tblEmployees.empLastName.EditCustomAttributes = ""
  854.                 tblEmployees.empLastName.EditValue = ew_HtmlEncode(tblEmployees.empLastName.CurrentValue)
  855.  
  856.                 ' empAddress
  857.             tblEmployees.empAddress.EditCustomAttributes = ""
  858.             tblEmployees.empAddress.EditValue = ew_HtmlEncode(tblEmployees.empAddress.CurrentValue)
  859.  
  860.             ' empCity
  861.             tblEmployees.empCity.EditCustomAttributes = ""
  862.             tblEmployees.empCity.EditValue = ew_HtmlEncode(tblEmployees.empCity.CurrentValue)
  863.  
  864.             ' empState
  865.             tblEmployees.empState.EditCustomAttributes = ""
  866.             tblEmployees.empState.EditValue = ew_HtmlEncode(tblEmployees.empState.CurrentValue)
  867.  
  868.             ' empZIP
  869.             tblEmployees.empZIP.EditCustomAttributes = ""
  870.             tblEmployees.empZIP.EditValue = ew_HtmlEncode(tblEmployees.empZIP.CurrentValue)
  871.  
  872.             ' empPhone
  873.             tblEmployees.empPhone.EditCustomAttributes = ""
  874.             tblEmployees.empPhone.EditValue = ew_HtmlEncode(tblEmployees.empPhone.CurrentValue)
  875.  
  876.             ' empStatusID
  877.             tblEmployees.empStatusID.EditCustomAttributes = ""
  878.             sSqlWrk = "SELECT [ID], [tscStatus], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblEmployeeStatus]"
  879.             sWhereWrk = ""
  880.             If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  881.             sSqlWrk = sSqlWrk & " ORDER BY [tscStatus] "
  882.             arwrk = Conn.GetRows(sSqlWrk)
  883.             arwrk.Insert(0, New Object(){"", "Please Select"}) 
  884.             tblEmployees.empStatusID.EditValue = arwrk
  885.  
  886.             ' empStartDate
  887.             tblEmployees.empStartDate.EditCustomAttributes = ""
  888.             tblEmployees.empStartDate.EditValue = ew_FormatDateTime(tblEmployees.empStartDate.CurrentValue, 6)
  889.  
  890.             ' empPositionID
  891.             tblEmployees.empPositionID.EditCustomAttributes = ""
  892.             sSqlWrk = "SELECT [posID], [posDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblPositions]"
  893.             sWhereWrk = ""
  894.             If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  895.             sSqlWrk = sSqlWrk & " ORDER BY [posDescription] "
  896.             arwrk = Conn.GetRows(sSqlWrk)
  897.             arwrk.Insert(0, New Object(){"", "Please Select"}) 
  898.             tblEmployees.empPositionID.EditValue = arwrk
  899.  
  900.             ' empRate
  901.             tblEmployees.empRate.EditCustomAttributes = ""
  902.             tblEmployees.empRate.EditValue = ew_HtmlEncode(tblEmployees.empRate.CurrentValue)
  903.  
  904.             ' empLastRaiseDate
  905.             tblEmployees.empLastRaiseDate.EditCustomAttributes = ""
  906.             tblEmployees.empLastRaiseDate.EditValue = ew_FormatDateTime(tblEmployees.empLastRaiseDate.CurrentValue, 6)
  907.  
  908.             ' empLastRaiseAmount
  909.             tblEmployees.empLastRaiseAmount.EditCustomAttributes = ""
  910.             tblEmployees.empLastRaiseAmount.EditValue = ew_HtmlEncode(tblEmployees.empLastRaiseAmount.CurrentValue)
  911.  
  912.             ' empEmail
  913.             tblEmployees.empEmail.EditCustomAttributes = ""
  914.             tblEmployees.empEmail.EditValue = ew_HtmlEncode(tblEmployees.empEmail.CurrentValue)
  915.  
  916.             ' empLiftCert
  917.             tblEmployees.empLiftCert.EditCustomAttributes = ""
  918.  
  919.             ' empForkCert
  920.             tblEmployees.empForkCert.EditCustomAttributes = ""
  921.  
  922.                 ' empDriveAuth
  923.                 tblEmployees.empDriveAuth.EditCustomAttributes = ""
  924.  
  925.                 ' empTimeClock
  926.                 tblEmployees.empTimeClock.EditCustomAttributes = ""
  927.  
  928.                 ' empIsActive   
  929.                 tblEmployees.empIsActive.EditCustomAttributes = ""
  930.  
  931.                 ' empUserPass
  932.             tblEmployees.empUserPass.EditCustomAttributes = ""
  933.             tblEmployees.empUserPass.EditValue = ew_HtmlEncode(tblEmployees.empUserPass.CurrentValue)
  934.  
  935.             ' empUserLevel
  936.             tblEmployees.empUserLevel.EditCustomAttributes = ""
  937.             If Not Security.CanAdmin Then ' System admin
  938.                 tblEmployees.empUserLevel.EditValue = "********"
  939.             Else
  940.             arwrk = New ArrayList
  941.             arwrk.Add(New String() {"-1", "Administrator"})
  942.             arwrk.Add(New String() {"0", "Default"})
  943.                     arwrk.Add(New String() {"1", "Part Time"})
  944.             arwrk.Add(New String() {"2", "Standard Lighting"})
  945.                     arwrk.Add(New String() {"3", "Admin Lighting"})
  946.                     arwrk.Add(New String() {"4", "Full Time"})
  947.                     arwrk.Insert(0, New String() {"", "Please Select"})
  948.             tblEmployees.empUserLevel.EditValue = arwrk
  949.             End If
  950.         End If
  951.  
  952.         ' Row Rendered event
  953.         tblEmployees.Row_Rendered()
  954.     End Sub
  955.  
  956.     '
  957.     ' Validate form
  958.     '
  959.     Function ValidateForm() As Boolean
  960.  
  961.         ' Initialize
  962.         ParentPage.gsFormError = ""
  963.  
  964.         ' Check if validation required
  965.         If Not EW_SERVER_VALIDATE Then Return (ParentPage.gsFormError = "")
  966.             If Not ew_CheckInteger(tblEmployees.empPayrollNumber.FormValue) Then
  967.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  968.                 ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect integer - Payroll Number"
  969.             End If
  970.         If ew_Empty(tblEmployees.empUsername.FormValue) Then
  971.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  972.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Username"
  973.         End If
  974.         If ew_Empty(tblEmployees.empName.FormValue) Then
  975.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  976.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Full Name"
  977.         End If
  978.             If ew_Empty(tblEmployees.empFirstName.FormValue) Then
  979.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  980.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - First Name"
  981.             End If
  982.             If ew_Empty(tblEmployees.empLastName.FormValue) Then
  983.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  984.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Last Name"
  985.             End If
  986.             If Not ew_CheckZip(tblEmployees.empZIP.FormValue) Then
  987.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  988.                 ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect ZIP code - ZIP"
  989.             End If
  990.         If Not ew_CheckPhone(tblEmployees.empPhone.FormValue) Then
  991.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  992.             ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect phone number - Phone Number (xxx-xxx-xxxx)"
  993.         End If
  994.         If ew_Empty(tblEmployees.empStatusID.FormValue) Then
  995.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  996.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Status"
  997.         End If
  998.         If Not ew_CheckUSDate(tblEmployees.empStartDate.FormValue) Then
  999.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1000.             ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect date, format = mm/dd/yyyy - Start Date"
  1001.         End If
  1002.         If ew_Empty(tblEmployees.empPositionID.FormValue) Then
  1003.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1004.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Position"
  1005.         End If
  1006.         If Not ew_CheckNumber(tblEmployees.empRate.FormValue) Then
  1007.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1008.             ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect floating point number - Rate"
  1009.         End If
  1010.         If Not ew_CheckUSDate(tblEmployees.empLastRaiseDate.FormValue) Then
  1011.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1012.             ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect date, format = mm/dd/yyyy - Last Raise Date"
  1013.         End If
  1014.         If Not ew_CheckNumber(tblEmployees.empLastRaiseAmount.FormValue) Then
  1015.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1016.             ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect floating point number - Last Raise Amount"
  1017.         End If
  1018.         If Not ew_CheckEmail(tblEmployees.empEmail.FormValue) Then
  1019.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1020.             ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect email - Email"
  1021.         End If
  1022.         If ew_Empty(tblEmployees.empUserPass.FormValue) Then
  1023.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1024.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Password"
  1025.         End If
  1026.         If ew_Empty(tblEmployees.empUserLevel.FormValue) Then
  1027.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1028.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - User Level"
  1029.         End If
  1030.  
  1031.         ' Return validate result
  1032.         Dim Valid As Boolean = (ParentPage.gsFormError = "")
  1033.  
  1034.         ' Form_CustomValidate event
  1035.         Dim sFormCustomError As String = ""
  1036.         Valid = Valid And Form_CustomValidate(sFormCustomError)
  1037.         If sFormCustomError <> "" Then
  1038.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  1039.             ParentPage.gsFormError = ParentPage.gsFormError & sFormCustomError
  1040.         End If
  1041.         Return Valid
  1042.     End Function
  1043.  
  1044.     '
  1045.     ' Add record
  1046.     '
  1047.     Function AddRow() As Boolean
  1048.         Dim Rs As New OrderedDictionary
  1049.         Dim sSql As String, sFilter As String
  1050.         Dim bInsertRow As Boolean
  1051.         Dim RsChk As OleDbDataReader
  1052.         Dim sIdxErrMsg As String
  1053.         Dim LastInsertId As Object
  1054.  
  1055.         ' Check if valid user ID
  1056.         Dim bValidUser As Boolean = False, sUserIdMsg As String
  1057.         If ew_NotEmpty(Security.CurrentUserID) AndAlso Not Security.IsAdmin() Then ' Non system admin
  1058.             bValidUser = Security.IsValidUserID(tblEmployees.empID.CurrentValue)
  1059.             If Not bValidUser Then
  1060.                 sUserIdMsg = "The current user (%c) is not authorized to assign the user ID (%u).".Replace("%c", Security.CurrentUserID)
  1061.                 sUserIdMsg = sUserIdMsg.Replace("%u", tblEmployees.empID.CurrentValue)
  1062.                 Message = sUserIdMsg
  1063.                 Return False
  1064.             End If
  1065.         End If
  1066.  
  1067.         ' Check if key value entered
  1068.             'If ew_Empty(tblEmployees.empID.CurrentValue) Then
  1069.             '    Message = "Invalid key value"
  1070.             '    Return False
  1071.             'End If
  1072.  
  1073.         ' Check for duplicate key
  1074.         Dim bCheckKey As Boolean = True
  1075.         sFilter = tblEmployees.KeyFilter
  1076.         If bCheckKey Then
  1077.             RsChk = tblEmployees.LoadRs(sFilter)
  1078.             If RsChk IsNot Nothing Then
  1079.                 Dim sKeyErrMsg As String = "Duplicate primary key: '%f'".Replace("%f", sFilter)
  1080.                 Message = sKeyErrMsg
  1081.                 RsChk.Close()
  1082.                 RsChk.Dispose()
  1083.                 Return False
  1084.             End If
  1085.         End If
  1086.  
  1087.         ' empID
  1088.             '            tblEmployees.empID.SetDbValue(tblEmployees.empID.CurrentValue, System.DBNull.Value)
  1089.             '            Rs("empID") = tblEmployees.empID.DbValue
  1090.  
  1091.             ' empPayrollNumber
  1092.             tblEmployees.empPayrollNumber.SetDbValue(tblEmployees.empPayrollNumber.CurrentValue, System.DBNull.Value)
  1093.             Rs("empPayrollNumber") = tblEmployees.empPayrollNumber.DbValue
  1094.  
  1095.             ' empUsername
  1096.             tblEmployees.empUsername.SetDbValue(tblEmployees.empUsername.CurrentValue, System.DBNull.Value)
  1097.             Rs("empUsername") = tblEmployees.empUsername.DbValue
  1098.  
  1099.             ' empName
  1100.         tblEmployees.empName.SetDbValue(tblEmployees.empName.CurrentValue, System.DBNull.Value)
  1101.         Rs("empName") = tblEmployees.empName.DbValue
  1102.  
  1103.             ' empFirstName
  1104.             tblEmployees.empFirstName.SetDbValue(tblEmployees.empFirstName.CurrentValue, System.DBNull.Value)
  1105.             Rs("empFirstName") = tblEmployees.empFirstName.DbValue
  1106.  
  1107.             ' empLastName
  1108.         tblEmployees.empLastName.SetDbValue(tblEmployees.empLastName.CurrentValue, System.DBNull.Value)
  1109.         Rs("empLastName") = tblEmployees.empLastName.DbValue
  1110.  
  1111.         ' empAddress
  1112.         tblEmployees.empAddress.SetDbValue(tblEmployees.empAddress.CurrentValue, System.DBNull.Value)
  1113.         Rs("empAddress") = tblEmployees.empAddress.DbValue
  1114.  
  1115.         ' empCity
  1116.         tblEmployees.empCity.SetDbValue(tblEmployees.empCity.CurrentValue, System.DBNull.Value)
  1117.         Rs("empCity") = tblEmployees.empCity.DbValue
  1118.  
  1119.         ' empState
  1120.         tblEmployees.empState.SetDbValue(tblEmployees.empState.CurrentValue, System.DBNull.Value)
  1121.         Rs("empState") = tblEmployees.empState.DbValue
  1122.  
  1123.         ' empZIP
  1124.         tblEmployees.empZIP.SetDbValue(tblEmployees.empZIP.CurrentValue, System.DBNull.Value)
  1125.         Rs("empZIP") = tblEmployees.empZIP.DbValue
  1126.  
  1127.         ' empPhone
  1128.         tblEmployees.empPhone.SetDbValue(tblEmployees.empPhone.CurrentValue, System.DBNull.Value)
  1129.         Rs("empPhone") = tblEmployees.empPhone.DbValue
  1130.  
  1131.         ' empStatusID
  1132.         tblEmployees.empStatusID.SetDbValue(tblEmployees.empStatusID.CurrentValue, System.DBNull.Value)
  1133.         Rs("empStatusID") = tblEmployees.empStatusID.DbValue
  1134.  
  1135.         ' empStartDate
  1136.         tblEmployees.empStartDate.SetDbValue(ew_UnFormatDateTime(tblEmployees.empStartDate.CurrentValue, 6), System.DBNull.Value)
  1137.         Rs("empStartDate") = tblEmployees.empStartDate.DbValue
  1138.  
  1139.         ' empPositionID
  1140.         tblEmployees.empPositionID.SetDbValue(tblEmployees.empPositionID.CurrentValue, System.DBNull.Value)
  1141.         Rs("empPositionID") = tblEmployees.empPositionID.DbValue
  1142.  
  1143.         ' empRate
  1144.         tblEmployees.empRate.SetDbValue(tblEmployees.empRate.CurrentValue, System.DBNull.Value)
  1145.         Rs("empRate") = tblEmployees.empRate.DbValue
  1146.  
  1147.         ' empLastRaiseDate
  1148.         tblEmployees.empLastRaiseDate.SetDbValue(ew_UnFormatDateTime(tblEmployees.empLastRaiseDate.CurrentValue, 6), System.DBNull.Value)
  1149.         Rs("empLastRaiseDate") = tblEmployees.empLastRaiseDate.DbValue
  1150.  
  1151.         ' empLastRaiseAmount
  1152.         tblEmployees.empLastRaiseAmount.SetDbValue(tblEmployees.empLastRaiseAmount.CurrentValue, System.DBNull.Value)
  1153.         Rs("empLastRaiseAmount") = tblEmployees.empLastRaiseAmount.DbValue
  1154.  
  1155.         ' empEmail
  1156.         tblEmployees.empEmail.SetDbValue(tblEmployees.empEmail.CurrentValue, System.DBNull.Value)
  1157.         Rs("empEmail") = tblEmployees.empEmail.DbValue
  1158.  
  1159.         ' empLiftCert
  1160.         tblEmployees.empLiftCert.SetDbValue((tblEmployees.empLiftCert.CurrentValue <> "" And Not IsDBNull(tblEmployees.empLiftCert.CurrentValue)), System.DBNull.Value)
  1161.         Rs("empLiftCert") = tblEmployees.empLiftCert.DbValue
  1162.  
  1163.         ' empForkCert
  1164.         tblEmployees.empForkCert.SetDbValue((tblEmployees.empForkCert.CurrentValue <> "" And Not IsDBNull(tblEmployees.empForkCert.CurrentValue)), System.DBNull.Value)
  1165.         Rs("empForkCert") = tblEmployees.empForkCert.DbValue
  1166.  
  1167.             ' empDriveAuth
  1168.             tblEmployees.empDriveAuth.SetDbValue((tblEmployees.empDriveAuth.CurrentValue <> "" And Not IsDBNull(tblEmployees.empDriveAuth.CurrentValue)), System.DBNull.Value)
  1169.             Rs("empDriveAuth") = tblEmployees.empDriveAuth.DbValue
  1170.  
  1171.             ' empTimeClock
  1172.             tblEmployees.empTimeClock.SetDbValue((tblEmployees.empTimeClock.CurrentValue <> "" And Not IsDBNull(tblEmployees.empTimeClock.CurrentValue)), System.DBNull.Value)
  1173.             Rs("empTimeClock") = tblEmployees.empTimeClock.DbValue
  1174.  
  1175.             ' empIsActive
  1176.             Rs("empIsActive") = True
  1177.  
  1178.             ' empUserPass
  1179.         tblEmployees.empUserPass.SetDbValue(tblEmployees.empUserPass.CurrentValue, System.DBNull.Value)
  1180.         Rs("empUserPass") = tblEmployees.empUserPass.DbValue
  1181.  
  1182.         ' empUserLevel
  1183.                 If Security.CanAdmin Then ' System admin
  1184.         tblEmployees.empUserLevel.SetDbValue(tblEmployees.empUserLevel.CurrentValue, System.DBNull.Value)
  1185.         Rs("empUserLevel") = tblEmployees.empUserLevel.DbValue
  1186.         End If
  1187.  
  1188.         ' Row Inserting event
  1189.         bInsertRow = tblEmployees.Row_Inserting(Rs)
  1190.         If bInsertRow Then
  1191.             Try    
  1192.                 tblEmployees.Insert(Rs)
  1193.                 AddRow = True
  1194.             Catch e As Exception
  1195.                 If EW_DEBUG_ENABLED Then Throw
  1196.                 Message = e.Message                
  1197.                 AddRow = False
  1198.             End Try
  1199.         Else
  1200.             If tblEmployees.CancelMessage <> "" Then
  1201.                 Message = tblEmployees.CancelMessage
  1202.                 tblEmployees.CancelMessage = ""
  1203.             Else
  1204.                 Message = "Insert cancelled"
  1205.             End If
  1206.             AddRow = False
  1207.         End If
  1208.         If AddRow Then
  1209.             LastInsertId = Conn.GetLastInsertId()
  1210.  
  1211.             ' Row Inserted event
  1212.             tblEmployees.Row_Inserted(Rs)
  1213.         End If
  1214.     End Function
  1215.  
  1216.         ' Page Load event
  1217.         Public Sub Page_Load()
  1218.  
  1219.             'HttpContext.Current.Response.Write("Page Load")
  1220.         End Sub
  1221.  
  1222.         ' Page Unload event
  1223.         Public Sub Page_Unload()
  1224.  
  1225.             'HttpContext.Current.Response.Write("Page Unload")
  1226.         End Sub
  1227.  
  1228.     ' Form Custom Validate event
  1229.     Public Function Form_CustomValidate(ByRef CustomError As String) As Boolean
  1230.  
  1231.         'Return error message in CustomError
  1232.         Return True
  1233.     End Function
  1234.     End Class
  1235.  
  1236.     '
  1237.     ' ASP.NET Page_Load event
  1238.     '
  1239.  
  1240.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  1241.         Response.Buffer = EW_RESPONSE_BUFFER
  1242.         Response.Cache.SetCacheability(HttpCacheability.NoCache)
  1243.  
  1244.         ' Page init
  1245.         tblEmployees_add = New ctblEmployees_add(Me)        
  1246.         tblEmployees_add.Page_Init()
  1247.  
  1248.         ' Page main processing
  1249.         tblEmployees_add.Page_Main()
  1250.     End Sub
  1251.  
  1252.     '
  1253.     ' ASP.NET Page_Unload event
  1254.     '
  1255.  
  1256.     Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
  1257.  
  1258.         ' Dispose page object
  1259.         If tblEmployees_add IsNot Nothing Then tblEmployees_add.Dispose()
  1260.     End Sub
  1261. End Class
  1262.