home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / tblLPRedit.aspx.vb < prev    next >
Text File  |  2012-02-19  |  47KB  |  1,100 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 tblLPRedit
  12.     Inherits AspNetMaker7_tfpssnet
  13.  
  14.     ' Page object
  15.     Public tblLPR_edit As ctblLPR_edit
  16.  
  17.     '
  18.     ' Page Class
  19.     '
  20.     Class ctblLPR_edit
  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 tblLPR.UseTokenInUrl Then Url = Url & "t=" & tblLPR.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 tblLPR.UseTokenInUrl Then
  44.                 Result = False
  45.                 If ObjForm IsNot Nothing Then
  46.                     Result = (tblLPR.TableVar = ObjForm.GetValue("t"))
  47.                 End If
  48.                 If ew_Get("t") <> "" Then
  49.                     Result = (tblLPR.TableVar = ew_Get("t"))
  50.                 End If
  51.                 Return Result
  52.             End If
  53.             Return True            
  54.         End Function    
  55.  
  56.         ' tblLPR
  57.         Public Property tblLPR() As ctblLPR
  58.             Get                
  59.                 Return ParentPage.tblLPR
  60.             End Get
  61.             Set(ByVal v As ctblLPR)
  62.                 ParentPage.tblLPR = v    
  63.             End Set    
  64.         End Property
  65.  
  66.         ' tblLPR
  67.         Public Property tblEmployees() As ctblEmployees
  68.             Get                
  69.                 Return ParentPage.tblEmployees
  70.             End Get
  71.             Set(ByVal v As ctblEmployees)
  72.                 ParentPage.tblEmployees = v    
  73.             End Set    
  74.         End Property
  75.  
  76.         '
  77.         '  Constructor
  78.         '  - init objects
  79.         '  - open connection
  80.         '
  81.         Public Sub New(ByRef APage As AspNetMaker7_tfpssnet)                
  82.             m_ParentPage = APage
  83.             m_Page = Me    
  84.             m_PageID = "edit"
  85.             m_PageObjName = "tblLPR_edit"
  86.             m_PageObjTypeName = "ctblLPR_edit"
  87.  
  88.             ' Table Name
  89.             m_TableName = "tblLPR"
  90.  
  91.             ' Initialize table object
  92.             tblLPR = New ctblLPR(Me)
  93.             tblEmployees = New ctblEmployees(Me)
  94.  
  95.             ' Connect to database
  96.             Conn = New cConnection()
  97.         End Sub
  98.  
  99.         '
  100.         '  Subroutine Page_Init
  101.         '  - called before page main
  102.         '  - check Security
  103.         '  - set up response header
  104.         '  - call page load events
  105.         '
  106.         Public Sub Page_Init()
  107.             Security = New cAdvancedSecurity(Me)
  108.             If Not Security.IsLoggedIn() Then Security.AutoLogin()
  109.             If Not Security.IsLoggedIn() Then
  110.                 Security.SaveLastUrl()
  111.                 Page_Terminate("login.aspx")
  112.             End If
  113.  
  114.             ' Table Permission loading event
  115.             Security.TablePermission_Loading()
  116.             Security.LoadCurrentUserLevel(TableName)
  117.  
  118.             ' Table Permission loaded event
  119.             Security.TablePermission_Loaded()
  120.             If Not Security.CanEdit Then
  121.                 Security.SaveLastUrl()
  122.                 Page_Terminate("tblLPRlist.aspx")
  123.             End If
  124.  
  125.             ' User ID loading event
  126.             Security.UserID_Loading()
  127.             If Security.IsLoggedIn() Then Call Security.LoadUserID()
  128.  
  129.             ' User ID loaded event
  130.             Security.UserID_Loaded()
  131.             If Security.IsLoggedIn() And ew_Empty(Security.CurrentUserID) Then
  132.                 Message = "You do not have the right permission to view the page"
  133.                 Page_Terminate("tblLPRlist.aspx")
  134.             End If
  135.  
  136.             ' Global page loading event (in ewglobal*.vb)
  137.             ParentPage.Page_Loading()
  138.  
  139.             ' Page load event, used in current page
  140.             Page_Load()
  141.         End Sub
  142.  
  143.         '
  144.         '  Class terminate
  145.         '  - clean up page object
  146.         '
  147.         Public Sub Dispose() Implements IDisposable.Dispose
  148.             Page_Terminate("")
  149.         End Sub
  150.  
  151.         '
  152.         '  Sub Page_Terminate
  153.         '  - called when exit page
  154.         '  - clean up connection and objects
  155.         '  - if URL specified, redirect to URL
  156.         '
  157.         Sub Page_Terminate(url As String)
  158.  
  159.             ' Page unload event, used in current page
  160.             Page_Unload()
  161.  
  162.             ' Global page unloaded event (in ewglobal*.vb)
  163.             ParentPage.Page_Unloaded()
  164.  
  165.             ' Close connection
  166.             Conn.Dispose()
  167.             Security = Nothing
  168.             tblLPR.Dispose()
  169.             tblEmployees.Dispose()
  170.  
  171.             ' Go to URL if specified
  172.             If url <> "" Then
  173.                 HttpContext.Current.Response.Clear()
  174.                 HttpContext.Current.Response.Redirect(url)
  175.             End If
  176.         End Sub
  177.  
  178.     '
  179.     ' Page main processing
  180.     '
  181.     Sub Page_Main()
  182.  
  183.         ' Load key from QueryString
  184.         If ew_Get("lprID") <> "" Then
  185.             tblLPR.lprID.QueryStringValue = ew_Get("lprID")
  186.         End If
  187.  
  188.         ' Create form object
  189.         ObjForm = New cFormObj
  190.         If ObjForm.GetValue("a_edit") <> "" Then
  191.             tblLPR.CurrentAction = ObjForm.GetValue("a_edit") ' Get action code
  192.             LoadFormValues() ' Get form values
  193.  
  194.             ' Validate Form
  195.             If Not ValidateForm() Then
  196.                 tblLPR.CurrentAction = "" ' Form error, reset action
  197.                 Message = ParentPage.gsFormError
  198.                 LoadRow() ' Restore row
  199.                 RestoreFormValues() ' Restore form values if validate failed
  200.             End If
  201.         Else
  202.             tblLPR.CurrentAction = "I" ' Default action is display
  203.         End If
  204.  
  205.         ' Check if valid key
  206.         If ew_Empty(tblLPR.lprID.CurrentValue) Then Page_Terminate("tblLPRlist.aspx") ' Invalid key, return to list
  207.         Select Case tblLPR.CurrentAction
  208.             Case "I" ' Get a record to display
  209.                 If Not LoadRow() Then ' Load Record based on key
  210.                     Message = "No records found" ' No record found
  211.                     Page_Terminate("tblLPRlist.aspx") ' No matching record, return to list
  212.                 End If
  213.             Case "U" ' Update
  214.                 tblLPR.SendEmail = True ' Send email on update success
  215.                 If EditRow() Then ' Update Record based on key
  216.                     Message = "Update succeeded" ' Update success
  217.                     Dim sReturnUrl As String = tblLPR.ReturnUrl
  218.                     Page_Terminate(sReturnUrl) ' Return to caller
  219.                 Else
  220.                     LoadRow() ' Restore row
  221.                     RestoreFormValues() ' Restore form values if update failed
  222.                 End If
  223.         End Select
  224.  
  225.         ' Render the record
  226.         tblLPR.RowType = EW_ROWTYPE_EDIT ' Render as edit
  227.  
  228.         ' Render row
  229.         RenderRow()
  230.     End Sub
  231.  
  232.     '
  233.     ' Get upload file
  234.     '
  235.     Sub GetUploadFiles()
  236.  
  237.         ' Get upload data
  238.     End Sub
  239.  
  240.     '
  241.     ' Load default values
  242.     '
  243.     Sub LoadDefaultValues()
  244.     End Sub
  245.  
  246.     '
  247.     ' Load form values
  248.     '
  249.     Sub LoadFormValues()
  250.         tblLPR.lprEmpID.FormValue = ObjForm.GetValue("x_lprEmpID")
  251.         tblLPR.lprEmpID.OldValue = ObjForm.GetValue("o_lprEmpID")
  252.         tblLPR.lprDate.FormValue = ObjForm.GetValue("x_lprDate")
  253.         tblLPR.lprDate.CurrentValue = ew_UnFormatDateTime(tblLPR.lprDate.CurrentValue, 6)
  254.         tblLPR.lprDate.OldValue = ObjForm.GetValue("o_lprDate")
  255.         tblLPR.lprLocationID.FormValue = ObjForm.GetValue("x_lprLocationID")
  256.         tblLPR.lprLocationID.OldValue = ObjForm.GetValue("o_lprLocationID")
  257.         tblLPR.lprFixtureLocationID.FormValue = ObjForm.GetValue("x_lprFixtureLocationID")
  258.         tblLPR.lprFixtureLocationID.OldValue = ObjForm.GetValue("o_lprFixtureLocationID")
  259.         tblLPR.lprFixtureTypeID.FormValue = ObjForm.GetValue("x_lprFixtureTypeID")
  260.         tblLPR.lprFixtureTypeID.OldValue = ObjForm.GetValue("o_lprFixtureTypeID")
  261.         tblLPR.lprFixtureNumber.FormValue = ObjForm.GetValue("x_lprFixtureNumber")
  262.         tblLPR.lprFixtureNumber.OldValue = ObjForm.GetValue("o_lprFixtureNumber")
  263.         tblLPR.lprChannelNumber.FormValue = ObjForm.GetValue("x_lprChannelNumber")
  264.         tblLPR.lprChannelNumber.OldValue = ObjForm.GetValue("o_lprChannelNumber")
  265.             If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  266.                 tblLPR.lprPriority.FormValue = ObjForm.GetValue("x_lprPriority")
  267.                 tblLPR.lprPriority.OldValue = ObjForm.GetValue("o_lprPriority")
  268.                 tblLPR.lprSTID.FormValue = ObjForm.GetValue("x_lprSTID")
  269.                 tblLPR.lprSTID.OldValue = ObjForm.GetValue("o_lprSTID")
  270.             End If
  271.             tblLPR.lprShortDesc.FormValue = ObjForm.GetValue("x_lprShortDesc")
  272.             tblLPR.lprShortDesc.OldValue = ObjForm.GetValue("o_lprShortDesc")
  273.             tblLPR.lprSTChangedBy.FormValue = ObjForm.GetValue("x_lprSTChangedBy")
  274.             tblLPR.lprSTChangedBy.OldValue = ObjForm.GetValue("o_lprSTChangedBy")
  275.             tblLPR.lprDesc.FormValue = ObjForm.GetValue("x_lprDesc")
  276.             tblLPR.lprDesc.OldValue = ObjForm.GetValue("o_lprDesc")
  277.             tblLPR.lprModifiedBy.FormValue = ObjForm.GetValue("x_lprModifiedBy")
  278.             tblLPR.lprModifiedBy.OldValue = ObjForm.GetValue("o_lprModifiedBy")
  279.             tblLPR.lprModifiedOn.FormValue = ObjForm.GetValue("x_lprModifiedOn")
  280.             tblLPR.lprModifiedOn.CurrentValue = ew_UnFormatDateTime(tblLPR.lprModifiedOn.CurrentValue, 6)
  281.             tblLPR.lprModifiedOn.OldValue = ObjForm.GetValue("o_lprModifiedOn")
  282.             tblLPR.lprID.FormValue = ObjForm.GetValue("x_lprID")
  283.         End Sub
  284.  
  285.     '
  286.     ' Restore form values
  287.     '
  288.     Sub RestoreFormValues()
  289.         tblLPR.lprEmpID.CurrentValue = tblLPR.lprEmpID.FormValue
  290.         tblLPR.lprDate.CurrentValue = tblLPR.lprDate.FormValue
  291.         tblLPR.lprDate.CurrentValue = ew_UnFormatDateTime(tblLPR.lprDate.CurrentValue, 6)
  292.         tblLPR.lprLocationID.CurrentValue = tblLPR.lprLocationID.FormValue
  293.         tblLPR.lprFixtureLocationID.CurrentValue = tblLPR.lprFixtureLocationID.FormValue
  294.         tblLPR.lprFixtureTypeID.CurrentValue = tblLPR.lprFixtureTypeID.FormValue
  295.         tblLPR.lprFixtureNumber.CurrentValue = tblLPR.lprFixtureNumber.FormValue
  296.         tblLPR.lprChannelNumber.CurrentValue = tblLPR.lprChannelNumber.FormValue
  297.             If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  298.                 tblLPR.lprPriority.CurrentValue = tblLPR.lprPriority.FormValue
  299.                 tblLPR.lprSTID.CurrentValue = tblLPR.lprSTID.FormValue
  300.             End If
  301.             tblLPR.lprShortDesc.CurrentValue = tblLPR.lprShortDesc.FormValue
  302.             tblLPR.lprSTID.CurrentValue = tblLPR.lprSTID.FormValue
  303.             tblLPR.lprSTChangedBy.CurrentValue = tblLPR.lprSTChangedBy.FormValue
  304.             tblLPR.lprDesc.CurrentValue = tblLPR.lprDesc.FormValue
  305.             tblLPR.lprModifiedBy.CurrentValue = tblLPR.lprModifiedBy.FormValue
  306.             tblLPR.lprModifiedOn.CurrentValue = tblLPR.lprModifiedOn.FormValue
  307.             tblLPR.lprModifiedOn.CurrentValue = ew_UnFormatDateTime(tblLPR.lprModifiedOn.CurrentValue, 6)
  308.             tblLPR.lprID.CurrentValue = tblLPR.lprID.FormValue
  309.         End Sub
  310.  
  311.         '
  312.         ' Load row based on key values
  313.         '
  314.         Function LoadRow() As Boolean
  315.             Dim RsRow As OleDbDataReader
  316.             Dim sFilter As String = tblLPR.KeyFilter
  317.  
  318.             ' Row Selecting event
  319.             tblLPR.Row_Selecting(sFilter)
  320.  
  321.             ' Load SQL based on filter
  322.             tblLPR.CurrentFilter = sFilter
  323.             Dim sSql As String = tblLPR.SQL
  324.  
  325.             ' Write SQL for debug
  326.             If EW_DEBUG_ENABLED Then ew_Write(sSql)
  327.             Try
  328.                 RsRow = Conn.GetTempDataReader(sSql)
  329.                 If Not RsRow.Read() Then
  330.                     Return False
  331.                 Else
  332.                     LoadRowValues(RsRow) ' Load row values
  333.  
  334.                     ' Row Selected event
  335.                     tblLPR.Row_Selected(RsRow)
  336.                     Return True
  337.                 End If
  338.             Catch
  339.                 If EW_DEBUG_ENABLED Then Throw
  340.                 Return False
  341.             Finally
  342.                 Conn.CloseTempDataReader()
  343.             End Try
  344.         End Function
  345.  
  346.         '
  347.         ' Load row values from recordset
  348.         '
  349.         Sub LoadRowValues(ByRef RsRow As OleDbDataReader)
  350.             tblLPR.lprID.DbValue = RsRow("lprID")
  351.             tblLPR.lprEmpID.DbValue = RsRow("lprEmpID")
  352.             tblLPR.lprDate.DbValue = RsRow("lprDate")
  353.             tblLPR.lprLocationID.DbValue = RsRow("lprLocationID")
  354.             tblLPR.lprFixtureLocationID.DbValue = RsRow("lprFixtureLocationID")
  355.             tblLPR.lprFixtureTypeID.DbValue = RsRow("lprFixtureTypeID")
  356.             tblLPR.lprFixtureNumber.DbValue = RsRow("lprFixtureNumber")
  357.             tblLPR.lprChannelNumber.DbValue = RsRow("lprChannelNumber")
  358.             If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  359.                 tblLPR.lprPriority.DbValue = RsRow("lprPriority")
  360.                 tblLPR.lprSTID.DbValue = RsRow("lprSTID")
  361.             End If
  362.             tblLPR.lprShortDesc.DbValue = RsRow("lprShortDesc")
  363.             tblLPR.lprSTChangedBy.DbValue = RsRow("lprSTChangedBy")
  364.             tblLPR.lprDesc.DbValue = RsRow("lprDesc")
  365.             tblLPR.lprCreatedBy.DbValue = RsRow("lprCreatedBy")
  366.             tblLPR.lprCreatedOn.DbValue = RsRow("lprCreatedOn")
  367.             tblLPR.lprModifiedBy.DbValue = RsRow("lprModifiedBy")
  368.             tblLPR.lprModifiedOn.DbValue = RsRow("lprModifiedOn")
  369.         End Sub
  370.  
  371.         '
  372.         ' Render row values based on field settings
  373.         '
  374.         Sub RenderRow()
  375.  
  376.             ' Row Rendering event
  377.             tblLPR.Row_Rendering()
  378.  
  379.             '
  380.             '  Common render codes for all row types
  381.             '
  382.             ' lprEmpID
  383.  
  384.             tblLPR.lprEmpID.CellCssStyle = ""
  385.             tblLPR.lprEmpID.CellCssClass = ""
  386.  
  387.             ' lprDate
  388.             tblLPR.lprDate.CellCssStyle = ""
  389.             tblLPR.lprDate.CellCssClass = ""
  390.  
  391.             ' lprLocationID
  392.             tblLPR.lprLocationID.CellCssStyle = ""
  393.             tblLPR.lprLocationID.CellCssClass = ""
  394.  
  395.             ' lprFixtureLocationID
  396.             tblLPR.lprFixtureLocationID.CellCssStyle = ""
  397.             tblLPR.lprFixtureLocationID.CellCssClass = ""
  398.  
  399.             ' lprFixtureTypeID
  400.             tblLPR.lprFixtureTypeID.CellCssStyle = ""
  401.             tblLPR.lprFixtureTypeID.CellCssClass = ""
  402.  
  403.             ' lprFixtureNumber
  404.             tblLPR.lprFixtureNumber.CellCssStyle = ""
  405.             tblLPR.lprFixtureNumber.CellCssClass = ""
  406.  
  407.             ' lprChannelNumber
  408.             tblLPR.lprChannelNumber.CellCssStyle = ""
  409.             tblLPR.lprChannelNumber.CellCssClass = ""
  410.  
  411.             If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  412.                 ' lprPriority
  413.                 tblLPR.lprPriority.CellCssStyle = ""
  414.                 tblLPR.lprPriority.CellCssClass = ""
  415.  
  416.                 ' lprSTID
  417.                 tblLPR.lprSTID.CellCssStyle = ""
  418.                 tblLPR.lprSTID.CellCssClass = ""
  419.             End If
  420.  
  421.             ' lprShortDesc
  422.             tblLPR.lprShortDesc.CellCssStyle = ""
  423.             tblLPR.lprShortDesc.CellCssClass = ""
  424.  
  425.             ' lprSTChangedBy
  426.             tblLPR.lprSTChangedBy.CellCssStyle = ""
  427.             tblLPR.lprSTChangedBy.CellCssClass = ""
  428.  
  429.             ' lprDesc
  430.             tblLPR.lprDesc.CellCssStyle = ""
  431.             tblLPR.lprDesc.CellCssClass = ""
  432.  
  433.             ' lprModifiedBy
  434.             tblLPR.lprModifiedBy.CellCssStyle = ""
  435.             tblLPR.lprModifiedBy.CellCssClass = ""
  436.  
  437.             ' lprModifiedOn
  438.             tblLPR.lprModifiedOn.CellCssStyle = ""
  439.             tblLPR.lprModifiedOn.CellCssClass = ""
  440.  
  441.             '
  442.             '  View  Row
  443.             '
  444.  
  445.             If tblLPR.RowType = EW_ROWTYPE_VIEW Then ' View row
  446.  
  447.                 ' lprEmpID
  448.                 If ew_NotEmpty(tblLPR.lprEmpID.CurrentValue) Then
  449.                     sSqlWrk = "SELECT [empName] FROM [tblEmployees] WHERE [empID] = " & ew_AdjustSql(tblLPR.lprEmpID.CurrentValue) & " AND [empIsActive]=True"
  450.                     sSqlWrk = sSqlWrk & " ORDER BY [empFirstName] "
  451.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  452.                     If RsWrk.Read() Then
  453.                         tblLPR.lprEmpID.ViewValue = RsWrk("empName")
  454.                     Else
  455.                         tblLPR.lprEmpID.ViewValue = tblLPR.lprEmpID.CurrentValue
  456.                     End If
  457.                     Conn.CloseTempDataReader()
  458.                 Else
  459.                     tblLPR.lprEmpID.ViewValue = System.DBNull.Value
  460.                 End If
  461.                 tblLPR.lprEmpID.CssStyle = ""
  462.                 tblLPR.lprEmpID.CssClass = ""
  463.                 tblLPR.lprEmpID.ViewCustomAttributes = ""
  464.  
  465.                 ' lprDate
  466.                 tblLPR.lprDate.ViewValue = tblLPR.lprDate.CurrentValue
  467.                 tblLPR.lprDate.ViewValue = ew_FormatDateTime(tblLPR.lprDate.ViewValue, 6)
  468.                 tblLPR.lprDate.CssStyle = ""
  469.                 tblLPR.lprDate.CssClass = ""
  470.                 tblLPR.lprDate.ViewCustomAttributes = ""
  471.  
  472.                 ' lprLocationID
  473.                 If ew_NotEmpty(tblLPR.lprLocationID.CurrentValue) Then
  474.                     sSqlWrk = "SELECT [locDescription] FROM [tblLocations] WHERE [locID] = " & ew_AdjustSql(tblLPR.lprLocationID.CurrentValue) & " AND [locIsActive]=True"
  475.                     sSqlWrk = sSqlWrk & " AND (" & "[locLighting]=True" & ")"
  476.                     sSqlWrk = sSqlWrk & " ORDER BY [locDescription] "
  477.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  478.                     If RsWrk.Read() Then
  479.                         tblLPR.lprLocationID.ViewValue = RsWrk("locDescription")
  480.                     Else
  481.                         tblLPR.lprLocationID.ViewValue = tblLPR.lprLocationID.CurrentValue
  482.                     End If
  483.                     Conn.CloseTempDataReader()
  484.                 Else
  485.                     tblLPR.lprLocationID.ViewValue = System.DBNull.Value
  486.                 End If
  487.                 tblLPR.lprLocationID.CssStyle = ""
  488.                 tblLPR.lprLocationID.CssClass = ""
  489.                 tblLPR.lprLocationID.ViewCustomAttributes = ""
  490.  
  491.                 ' lprFixtureLocationID
  492.                 If ew_NotEmpty(tblLPR.lprFixtureLocationID.CurrentValue) Then
  493.                     sSqlWrk = "SELECT [floDescription] FROM [tblLPRFixtureLocation] WHERE [floID] = " & ew_AdjustSql(tblLPR.lprFixtureLocationID.CurrentValue) & " AND [floIsActive]=True"
  494.                     sSqlWrk = sSqlWrk & " ORDER BY [floDescription] "
  495.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  496.                     If RsWrk.Read() Then
  497.                         tblLPR.lprFixtureLocationID.ViewValue = RsWrk("floDescription")
  498.                     Else
  499.                         tblLPR.lprFixtureLocationID.ViewValue = tblLPR.lprFixtureLocationID.CurrentValue
  500.                     End If
  501.                     Conn.CloseTempDataReader()
  502.                 Else
  503.                     tblLPR.lprFixtureLocationID.ViewValue = System.DBNull.Value
  504.                 End If
  505.                 tblLPR.lprFixtureLocationID.CssStyle = ""
  506.                 tblLPR.lprFixtureLocationID.CssClass = ""
  507.                 tblLPR.lprFixtureLocationID.ViewCustomAttributes = ""
  508.  
  509.                 ' lprFixtureTypeID
  510.                 If ew_NotEmpty(tblLPR.lprFixtureTypeID.CurrentValue) Then
  511.                     sSqlWrk = "SELECT [ftyDescription] FROM [tblLPRFixtureType] WHERE [ftyID] = " & ew_AdjustSql(tblLPR.lprFixtureTypeID.CurrentValue) & " AND [ftyIsActive]=True"
  512.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  513.                     If RsWrk.Read() Then
  514.                         tblLPR.lprFixtureTypeID.ViewValue = RsWrk("ftyDescription")
  515.                     Else
  516.                         tblLPR.lprFixtureTypeID.ViewValue = tblLPR.lprFixtureTypeID.CurrentValue
  517.                     End If
  518.                     Conn.CloseTempDataReader()
  519.                 Else
  520.                     tblLPR.lprFixtureTypeID.ViewValue = System.DBNull.Value
  521.                 End If
  522.                 tblLPR.lprFixtureTypeID.CssStyle = ""
  523.                 tblLPR.lprFixtureTypeID.CssClass = ""
  524.                 tblLPR.lprFixtureTypeID.ViewCustomAttributes = ""
  525.  
  526.                 ' lprFixtureNumber
  527.                 tblLPR.lprFixtureNumber.ViewValue = tblLPR.lprFixtureNumber.CurrentValue
  528.                 tblLPR.lprFixtureNumber.CssStyle = ""
  529.                 tblLPR.lprFixtureNumber.CssClass = ""
  530.                 tblLPR.lprFixtureNumber.ViewCustomAttributes = ""
  531.  
  532.                 ' lprChannelNumber
  533.                 tblLPR.lprChannelNumber.ViewValue = tblLPR.lprChannelNumber.CurrentValue
  534.                 tblLPR.lprChannelNumber.CssStyle = ""
  535.                 tblLPR.lprChannelNumber.CssClass = ""
  536.                 tblLPR.lprChannelNumber.ViewCustomAttributes = ""
  537.  
  538.                 If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  539.                     ' lprPriority
  540.                     If Not IsDBNull(tblLPR.lprPriority.CurrentValue) Then
  541.                         Select Case tblLPR.lprPriority.CurrentValue
  542.                             Case "0"
  543.                                 tblLPR.lprPriority.ViewValue = "Not Specified"
  544.                             Case "1"
  545.                                 tblLPR.lprPriority.ViewValue = "Low"
  546.                             Case "2"
  547.                                 tblLPR.lprPriority.ViewValue = "Medium"
  548.                             Case "3"
  549.                                 tblLPR.lprPriority.ViewValue = "High"
  550.                             Case Else
  551.                                 tblLPR.lprPriority.ViewValue = tblLPR.lprPriority.CurrentValue
  552.                         End Select
  553.                     Else
  554.                         tblLPR.lprPriority.ViewValue = System.DBNull.Value
  555.                     End If
  556.                     tblLPR.lprPriority.CssStyle = ""
  557.                     tblLPR.lprPriority.CssClass = ""
  558.                     tblLPR.lprPriority.ViewCustomAttributes = ""
  559.  
  560.                     ' lprSTID
  561.                     If ew_NotEmpty(tblLPR.lprSTID.CurrentValue) Then
  562.                         sSqlWrk = "SELECT [lstDescription] FROM [tblLPRStatus] WHERE [lstID] = " & ew_AdjustSql(tblLPR.lprSTID.CurrentValue) & " AND [lstIsActive]=True"
  563.                         sSqlWrk = sSqlWrk & " ORDER BY [lstDescription] "
  564.                         RsWrk = Conn.GetTempDataReader(sSqlWrk)
  565.                         If RsWrk.Read() Then
  566.                             tblLPR.lprSTID.ViewValue = RsWrk("lstDescription")
  567.                         Else
  568.                             tblLPR.lprSTID.ViewValue = tblLPR.lprSTID.CurrentValue
  569.                         End If
  570.                         Conn.CloseTempDataReader()
  571.                     Else
  572.                         tblLPR.lprSTID.ViewValue = System.DBNull.Value
  573.                     End If
  574.                     tblLPR.lprSTID.CssStyle = ""
  575.                     tblLPR.lprSTID.CssClass = ""
  576.                     tblLPR.lprSTID.ViewCustomAttributes = ""
  577.                 End If
  578.  
  579.                 ' lprShortDesc
  580.                 tblLPR.lprShortDesc.ViewValue = tblLPR.lprShortDesc.CurrentValue
  581.                 tblLPR.lprShortDesc.CssStyle = ""
  582.                 tblLPR.lprShortDesc.CssClass = ""
  583.                 tblLPR.lprShortDesc.ViewCustomAttributes = ""
  584.  
  585.                 ' lprSTChangedBy
  586.                 tblLPR.lprSTChangedBy.ViewValue = tblLPR.lprSTChangedBy.CurrentValue
  587.                 tblLPR.lprSTChangedBy.CssStyle = ""
  588.                 tblLPR.lprSTChangedBy.CssClass = ""
  589.                 tblLPR.lprSTChangedBy.ViewCustomAttributes = ""
  590.  
  591.                 ' lprDesc
  592.                 tblLPR.lprDesc.ViewValue = tblLPR.lprDesc.CurrentValue
  593.                 tblLPR.lprDesc.CssStyle = ""
  594.                 tblLPR.lprDesc.CssClass = ""
  595.                 tblLPR.lprDesc.ViewCustomAttributes = ""
  596.  
  597.                 ' lprCreatedBy
  598.                 tblLPR.lprCreatedBy.ViewValue = tblLPR.lprCreatedBy.CurrentValue
  599.                 tblLPR.lprCreatedBy.CssStyle = ""
  600.                 tblLPR.lprCreatedBy.CssClass = ""
  601.                 tblLPR.lprCreatedBy.ViewCustomAttributes = ""
  602.  
  603.                 ' lprCreatedOn
  604.                 tblLPR.lprCreatedOn.ViewValue = tblLPR.lprCreatedOn.CurrentValue
  605.                 tblLPR.lprCreatedOn.ViewValue = ew_FormatDateTime(tblLPR.lprCreatedOn.ViewValue, 6)
  606.                 tblLPR.lprCreatedOn.CssStyle = ""
  607.                 tblLPR.lprCreatedOn.CssClass = ""
  608.                 tblLPR.lprCreatedOn.ViewCustomAttributes = ""
  609.  
  610.                 ' lprModifiedBy
  611.                 tblLPR.lprModifiedBy.ViewValue = tblLPR.lprModifiedBy.CurrentValue
  612.                 tblLPR.lprModifiedBy.CssStyle = ""
  613.                 tblLPR.lprModifiedBy.CssClass = ""
  614.                 tblLPR.lprModifiedBy.ViewCustomAttributes = ""
  615.  
  616.                 ' lprModifiedOn
  617.                 tblLPR.lprModifiedOn.ViewValue = tblLPR.lprModifiedOn.CurrentValue
  618.                 tblLPR.lprModifiedOn.ViewValue = ew_FormatDateTime(tblLPR.lprModifiedOn.ViewValue, 6)
  619.                 tblLPR.lprModifiedOn.CssStyle = ""
  620.                 tblLPR.lprModifiedOn.CssClass = ""
  621.                 tblLPR.lprModifiedOn.ViewCustomAttributes = ""
  622.  
  623.                 ' View refer script
  624.                 ' lprEmpID
  625.  
  626.                 tblLPR.lprEmpID.HrefValue = ""
  627.  
  628.                 ' lprDate
  629.                 tblLPR.lprDate.HrefValue = ""
  630.  
  631.                 ' lprLocationID
  632.                 tblLPR.lprLocationID.HrefValue = ""
  633.  
  634.                 ' lprFixtureLocationID
  635.                 tblLPR.lprFixtureLocationID.HrefValue = ""
  636.  
  637.                 ' lprFixtureTypeID
  638.                 tblLPR.lprFixtureTypeID.HrefValue = ""
  639.  
  640.                 ' lprFixtureNumber
  641.                 tblLPR.lprFixtureNumber.HrefValue = ""
  642.  
  643.                 ' lprChannelNumber
  644.                 tblLPR.lprChannelNumber.HrefValue = ""
  645.  
  646.                 If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  647.                     ' lprPriority
  648.                     tblLPR.lprPriority.HrefValue = ""
  649.  
  650.                     ' lprSTID
  651.                     tblLPR.lprSTID.HrefValue = ""
  652.                 End If
  653.  
  654.                 ' lprShortDesc
  655.                 tblLPR.lprShortDesc.HrefValue = ""
  656.  
  657.                 ' lprSTChangedBy
  658.                 tblLPR.lprSTChangedBy.HrefValue = ""
  659.  
  660.                 ' lprDesc
  661.                 tblLPR.lprDesc.HrefValue = ""
  662.  
  663.                 ' lprModifiedBy
  664.                 tblLPR.lprModifiedBy.HrefValue = ""
  665.  
  666.                 ' lprModifiedOn
  667.                 tblLPR.lprModifiedOn.HrefValue = ""
  668.  
  669.                 '
  670.                 '  Edit Row
  671.                 '
  672.  
  673.             ElseIf tblLPR.RowType = EW_ROWTYPE_EDIT Then ' Edit row
  674.  
  675.                 ' lprEmpID
  676.                 tblLPR.lprEmpID.EditCustomAttributes = ""
  677.                 If Not Security.IsAdmin And Security.IsLoggedIn() And ew_Session("tfpssnet_Status_UserLevel") <> 3 Then ' Non system admin
  678.                     tblLPR.lprEmpID.CurrentValue = Security.CurrentUserID
  679.                     If ew_NotEmpty(tblLPR.lprEmpID.CurrentValue) Then
  680.                         sSqlWrk = "SELECT [empName] FROM [tblEmployees] WHERE [empID] = " & ew_AdjustSql(tblLPR.lprEmpID.CurrentValue) & " AND [empIsActive]=True"
  681.                         sSqlWrk = sSqlWrk & " ORDER BY [empFirstName] "
  682.                         RsWrk = Conn.GetTempDataReader(sSqlWrk)
  683.                         If RsWrk.Read() Then
  684.                             tblLPR.lprEmpID.EditValue = RsWrk("empName")
  685.                         Else
  686.                             tblLPR.lprEmpID.EditValue = tblLPR.lprEmpID.CurrentValue
  687.                         End If
  688.                         Conn.CloseTempDataReader()
  689.                     Else
  690.                         tblLPR.lprEmpID.EditValue = System.DBNull.Value
  691.                     End If
  692.                     tblLPR.lprEmpID.CssStyle = ""
  693.                     tblLPR.lprEmpID.CssClass = ""
  694.                     tblLPR.lprEmpID.ViewCustomAttributes = ""
  695.                 Else
  696.                     sSqlWrk = "SELECT [empID], [empName], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblEmployees]"
  697.                     sWhereWrk = "[empIsActive]=True"
  698.                     sWhereWrk = tblEmployees.AddUserIDFilter(sWhereWrk)
  699.                     If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  700.                     sSqlWrk = sSqlWrk & " ORDER BY [empFirstName] "
  701.                     arwrk = Conn.GetRows(sSqlWrk)
  702.                     arwrk.Insert(0, New Object() {"", "Please Select"})
  703.                     tblLPR.lprEmpID.EditValue = arwrk
  704.                 End If
  705.  
  706.                 ' lprDate
  707.                 tblLPR.lprDate.EditCustomAttributes = ""
  708.                 tblLPR.lprDate.EditValue = ew_FormatDateTime(tblLPR.lprDate.CurrentValue, 6)
  709.  
  710.                 ' lprLocationID
  711.                 tblLPR.lprLocationID.EditCustomAttributes = ""
  712.                 sSqlWrk = "SELECT [locID], [locDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblLocations]"
  713.                 sWhereWrk = "[locIsActive]=True"
  714.                 If sWhereWrk <> "" Then sWhereWrk = "(" & sWhereWrk & ") AND "
  715.                 sWhereWrk = sWhereWrk & "(" & "[locLighting]=True" & ")"
  716.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  717.                 sSqlWrk = sSqlWrk & " ORDER BY [locDescription] "
  718.                 arwrk = Conn.GetRows(sSqlWrk)
  719.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  720.                 tblLPR.lprLocationID.EditValue = arwrk
  721.  
  722.                 ' lprFixtureLocationID
  723.                 tblLPR.lprFixtureLocationID.EditCustomAttributes = ""
  724.                 sSqlWrk = "SELECT [floID], [floDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblLPRFixtureLocation]"
  725.                 sWhereWrk = "[floIsActive]=True"
  726.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  727.                 sSqlWrk = sSqlWrk & " ORDER BY [floDescription] "
  728.                 arwrk = Conn.GetRows(sSqlWrk)
  729.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  730.                 tblLPR.lprFixtureLocationID.EditValue = arwrk
  731.  
  732.                 ' lprFixtureTypeID
  733.                 tblLPR.lprFixtureTypeID.EditCustomAttributes = ""
  734.                 sSqlWrk = "SELECT [ftyID], [ftyDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblLPRFixtureType]"
  735.                 sWhereWrk = "[ftyIsActive]=True"
  736.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  737.                 arwrk = Conn.GetRows(sSqlWrk)
  738.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  739.                 tblLPR.lprFixtureTypeID.EditValue = arwrk
  740.  
  741.                 ' lprFixtureNumber
  742.                 tblLPR.lprFixtureNumber.EditCustomAttributes = ""
  743.                 tblLPR.lprFixtureNumber.EditValue = ew_HtmlEncode(tblLPR.lprFixtureNumber.CurrentValue)
  744.  
  745.                 ' lprChannelNumber
  746.                 tblLPR.lprChannelNumber.EditCustomAttributes = ""
  747.                 tblLPR.lprChannelNumber.EditValue = ew_HtmlEncode(tblLPR.lprChannelNumber.CurrentValue)
  748.  
  749.                 If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  750.                     ' lprPriority
  751.                     tblLPR.lprPriority.EditCustomAttributes = ""
  752.                     arwrk = New ArrayList
  753.                     arwrk.Add(New String() {"0", "Not Specified"})
  754.                     arwrk.Add(New String() {"1", "Low"})
  755.                     arwrk.Add(New String() {"2", "Medium"})
  756.                     arwrk.Add(New String() {"3", "High"})
  757.                     arwrk.Insert(0, New String() {"", "Please Select"})
  758.                     tblLPR.lprPriority.EditValue = arwrk
  759.  
  760.                     ' lprSTID
  761.                     tblLPR.lprSTID.EditCustomAttributes = ""
  762.                     sSqlWrk = "SELECT [lstID], [lstDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblLPRStatus]"
  763.                     sWhereWrk = "[lstIsActive]=True"
  764.                     If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  765.                     sSqlWrk = sSqlWrk & " ORDER BY [lstDescription] "
  766.                     arwrk = Conn.GetRows(sSqlWrk)
  767.                     arwrk.Insert(0, New Object() {"", "Please Select"})
  768.                     tblLPR.lprSTID.EditValue = arwrk
  769.  
  770.                 End If
  771.  
  772.                 ' lprShortDesc
  773.                 tblLPR.lprShortDesc.EditCustomAttributes = ""
  774.                 tblLPR.lprShortDesc.EditValue = ew_HtmlEncode(tblLPR.lprShortDesc.CurrentValue)
  775.  
  776.                 ' lprSTChangedBy
  777.                 ' lprDesc
  778.  
  779.                 tblLPR.lprDesc.EditCustomAttributes = ""
  780.                 tblLPR.lprDesc.EditValue = ew_HtmlEncode(tblLPR.lprDesc.CurrentValue)
  781.  
  782.                 ' lprModifiedBy
  783.                 ' lprModifiedOn
  784.                 ' Edit refer script
  785.                 ' lprEmpID
  786.  
  787.                 tblLPR.lprEmpID.HrefValue = ""
  788.  
  789.                 ' lprDate
  790.                 tblLPR.lprDate.HrefValue = ""
  791.  
  792.                 ' lprLocationID
  793.                 tblLPR.lprLocationID.HrefValue = ""
  794.  
  795.                 ' lprFixtureLocationID
  796.                 tblLPR.lprFixtureLocationID.HrefValue = ""
  797.  
  798.                 ' lprFixtureTypeID
  799.                 tblLPR.lprFixtureTypeID.HrefValue = ""
  800.  
  801.                 ' lprFixtureNumber
  802.                 tblLPR.lprFixtureNumber.HrefValue = ""
  803.  
  804.                 ' lprChannelNumber
  805.                 tblLPR.lprChannelNumber.HrefValue = ""
  806.  
  807.                 If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  808.                     ' lprPriority
  809.                     tblLPR.lprPriority.HrefValue = ""
  810.  
  811.                     ' lprSTID
  812.                     tblLPR.lprSTID.HrefValue = ""
  813.                 End If
  814.  
  815.                 ' lprShortDesc
  816.                 tblLPR.lprShortDesc.HrefValue = ""
  817.  
  818.                 ' lprSTChangedBy
  819.                 tblLPR.lprSTChangedBy.HrefValue = ""
  820.  
  821.                 ' lprDesc
  822.                 tblLPR.lprDesc.HrefValue = ""
  823.  
  824.                 ' lprModifiedBy
  825.                 tblLPR.lprModifiedBy.HrefValue = ""
  826.  
  827.                 ' lprModifiedOn
  828.                 tblLPR.lprModifiedOn.HrefValue = ""
  829.             End If
  830.  
  831.             ' Row Rendered event
  832.             tblLPR.Row_Rendered()
  833.         End Sub
  834.  
  835.         '
  836.         ' Validate form
  837.         '
  838.         Function ValidateForm() As Boolean
  839.  
  840.             ' Initialize
  841.             ParentPage.gsFormError = ""
  842.  
  843.             ' Check if validation required
  844.             If Not EW_SERVER_VALIDATE Then Return (ParentPage.gsFormError = "")
  845.             If ew_Empty(tblLPR.lprEmpID.FormValue) Then
  846.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  847.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Employee"
  848.             End If
  849.             If ew_Empty(tblLPR.lprDate.FormValue) Then
  850.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  851.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Date"
  852.             End If
  853.             If Not ew_CheckUSDate(tblLPR.lprDate.FormValue) Then
  854.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  855.                 ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect date, format = mm/dd/yyyy - Date"
  856.             End If
  857.             If ew_Empty(tblLPR.lprLocationID.FormValue) Then
  858.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  859.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Location"
  860.             End If
  861.             If ew_Empty(tblLPR.lprFixtureLocationID.FormValue) Then
  862.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  863.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Fixture Location"
  864.             End If
  865.             If ew_Empty(tblLPR.lprFixtureTypeID.FormValue) Then
  866.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  867.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Fixture Type"
  868.             End If
  869.             If Not ew_CheckInteger(tblLPR.lprFixtureNumber.FormValue) Then
  870.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  871.                 ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect integer - Fixture Number"
  872.             End If
  873.             If ew_Empty(tblLPR.lprChannelNumber.FormValue) Then
  874.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  875.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Channel Number"
  876.             End If
  877.             If Not ew_CheckInteger(tblLPR.lprChannelNumber.FormValue) Then
  878.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  879.                 ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect integer - Channel Number"
  880.             End If
  881.             If ew_Empty(tblLPR.lprPriority.FormValue) Then
  882.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  883.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Priority"
  884.             End If
  885.             If ew_Empty(tblLPR.lprShortDesc.FormValue) Then
  886.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  887.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Short Desc"
  888.             End If
  889.             If ew_Empty(tblLPR.lprSTID.FormValue) Then
  890.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  891.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Status"
  892.             End If
  893.  
  894.             ' Return validate result
  895.             Dim Valid As Boolean = (ParentPage.gsFormError = "")
  896.  
  897.             ' Form_CustomValidate event
  898.             Dim sFormCustomError As String = ""
  899.             Valid = Valid And Form_CustomValidate(sFormCustomError)
  900.             If sFormCustomError <> "" Then
  901.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  902.                 ParentPage.gsFormError = ParentPage.gsFormError & sFormCustomError
  903.             End If
  904.             Return Valid
  905.         End Function
  906.  
  907.         '
  908.         ' Update record based on key values
  909.         '
  910.         Function EditRow() As Boolean
  911.             Dim RsEdit As OleDbDataReader, RsChk As OleDbDataReader
  912.             Dim sSql As String, sFilter As String
  913.             Dim sSqlChk As String, sFilterChk As String
  914.             Dim bUpdateRow As Boolean
  915.             Dim RsOld As OrderedDictionary
  916.             Dim sIdxErrMsg As String
  917.             Dim Rs As New OrderedDictionary
  918.             sFilter = tblLPR.KeyFilter
  919.             'If tblLPR.lprDesc.CurrentValue <> "" Then ' Check field with unique index
  920.             '    sFilterChk = "(lprDesc = '" & ew_AdjustSql(tblLPR.lprDesc.CurrentValue) & "')"
  921.             '    sFilterChk = sFilterChk & " AND NOT (" & sFilter & ")"
  922.             '    tblLPR.CurrentFilter = sFilterChk
  923.             '    sSqlChk = tblLPR.SQL
  924.             '    Try
  925.             '        RsChk = Conn.GetDataReader(sSqlChk)
  926.             '        If RsChk.Read() Then
  927.             '            sIdxErrMsg = "Duplicate value '%v' for unique index '%f'".Replace("%f", "lprDesc")
  928.             '            sIdxErrMsg = sIdxErrMsg.Replace("%v", tblLPR.lprDesc.CurrentValue)
  929.             '            Message = sIdxErrMsg
  930.             '            Return False
  931.             '        End If
  932.             '    Catch e As Exception
  933.             '        If EW_DEBUG_ENABLED Then Throw
  934.             '        Message = e.Message
  935.             '        Return False
  936.             '    Finally
  937.             '        RsChk.Close()
  938.             '        RsChk.Dispose()
  939.             '    End Try
  940.             'End If
  941.             tblLPR.CurrentFilter = sFilter
  942.             sSql = tblLPR.SQL
  943.             Try
  944.                 RsEdit = Conn.GetDataReader(sSql)
  945.             Catch e As Exception
  946.                 If EW_DEBUG_ENABLED Then Throw
  947.                 Message = e.Message
  948.                 RsEdit.Close()
  949.                 EditRow = False
  950.             End Try
  951.             If Not RsEdit.Read() Then
  952.                 RsEdit.Close()
  953.                 EditRow = False ' Update Failed
  954.             Else
  955.                 RsOld = Conn.GetRow(RsEdit)
  956.                 RsEdit.Close()
  957.  
  958.                 ' lprEmpID
  959.                 tblLPR.lprEmpID.SetDbValue(tblLPR.lprEmpID.CurrentValue, System.DBNull.Value)
  960.                 Rs("lprEmpID") = tblLPR.lprEmpID.DbValue
  961.  
  962.                 ' lprDate
  963.                 tblLPR.lprDate.SetDbValue(ew_UnFormatDateTime(tblLPR.lprDate.CurrentValue, 6), System.DBNull.Value)
  964.                 Rs("lprDate") = tblLPR.lprDate.DbValue
  965.  
  966.                 ' lprLocationID
  967.                 tblLPR.lprLocationID.SetDbValue(tblLPR.lprLocationID.CurrentValue, System.DBNull.Value)
  968.                 Rs("lprLocationID") = tblLPR.lprLocationID.DbValue
  969.  
  970.                 ' lprFixtureLocationID
  971.                 tblLPR.lprFixtureLocationID.SetDbValue(tblLPR.lprFixtureLocationID.CurrentValue, System.DBNull.Value)
  972.                 Rs("lprFixtureLocationID") = tblLPR.lprFixtureLocationID.DbValue
  973.  
  974.                 ' lprFixtureTypeID
  975.                 tblLPR.lprFixtureTypeID.SetDbValue(tblLPR.lprFixtureTypeID.CurrentValue, System.DBNull.Value)
  976.                 Rs("lprFixtureTypeID") = tblLPR.lprFixtureTypeID.DbValue
  977.  
  978.                 ' lprFixtureNumber
  979.                 tblLPR.lprFixtureNumber.SetDbValue(tblLPR.lprFixtureNumber.CurrentValue, System.DBNull.Value)
  980.                 Rs("lprFixtureNumber") = tblLPR.lprFixtureNumber.DbValue
  981.  
  982.                 ' lprChannelNumber
  983.                 tblLPR.lprChannelNumber.SetDbValue(tblLPR.lprChannelNumber.CurrentValue, System.DBNull.Value)
  984.                 Rs("lprChannelNumber") = tblLPR.lprChannelNumber.DbValue
  985.  
  986.                 If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  987.                     ' lprPriority
  988.                     tblLPR.lprPriority.SetDbValue(tblLPR.lprPriority.CurrentValue, System.DBNull.Value)
  989.                     Rs("lprPriority") = tblLPR.lprPriority.DbValue
  990.                 End If
  991.  
  992.                 ' lprShortDesc
  993.                 tblLPR.lprShortDesc.SetDbValue(tblLPR.lprShortDesc.CurrentValue, System.DBNull.Value)
  994.                 Rs("lprShortDesc") = tblLPR.lprShortDesc.DbValue
  995.  
  996.                 If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  997.                     ' lprSTID
  998.                     tblLPR.lprSTID.SetDbValue(tblLPR.lprSTID.CurrentValue, System.DBNull.Value)
  999.                     If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  1000.                         If tblLPR.lprSTID.DbValue <> Rs("lprSTID") Then
  1001.                             Rs("lprSTID") = tblLPR.lprSTID.DbValue
  1002.                             If ew_Session("tfpssnet_Status_UserLevel") = -1 Then
  1003.                                 Rs("lprSTChangedBy") = "Admin"
  1004.                             Else
  1005.                                 Rs("lprSTChangedBy") = ew_Session("tfpssnet_Status_UserName")
  1006.                             End If
  1007.                         End If
  1008.                     Else
  1009.                         Rs("lprSTID") = 1
  1010.                         Rs("lprSTChangedBy") = ew_Session("tfpssnet_Status_UserName")
  1011.                     End If
  1012.                 End If
  1013.  
  1014.                 ' lprDesc
  1015.                 tblLPR.lprDesc.SetDbValue(tblLPR.lprDesc.CurrentValue, System.DBNull.Value)
  1016.                 Rs("lprDesc") = tblLPR.lprDesc.DbValue
  1017.  
  1018.                 ' lprModifiedBy
  1019.                 tblLPR.lprModifiedBy.DbValue = CurrentUserName()
  1020.                 Rs("lprModifiedBy") = tblLPR.lprModifiedBy.DbValue
  1021.  
  1022.                 ' lprModifiedOn
  1023.                 tblLPR.lprModifiedOn.DbValue = ew_CurrentDate()
  1024.                 Rs("lprModifiedOn") = tblLPR.lprModifiedOn.DbValue
  1025.  
  1026.                 ' Row Updating event
  1027.                 bUpdateRow = tblLPR.Row_Updating(RsOld, Rs)
  1028.                 If bUpdateRow Then
  1029.                     Try
  1030.                         tblLPR.Update(Rs)
  1031.                         EditRow = True
  1032.                     Catch e As Exception
  1033.                         If EW_DEBUG_ENABLED Then Throw
  1034.                         Message = e.Message
  1035.                         EditRow = False
  1036.                     End Try
  1037.                 Else
  1038.                     If tblLPR.CancelMessage <> "" Then
  1039.                         Message = tblLPR.CancelMessage
  1040.                         tblLPR.CancelMessage = ""
  1041.                     Else
  1042.                         Message = "Update cancelled"
  1043.                     End If
  1044.                     EditRow = False
  1045.                 End If
  1046.             End If
  1047.  
  1048.             ' Row Updated event
  1049.             If EditRow Then
  1050.                 tblLPR.Row_Updated(RsOld, Rs)
  1051.             End If
  1052.         End Function
  1053.  
  1054.         ' Page Load event
  1055.         Public Sub Page_Load()
  1056.  
  1057.             'HttpContext.Current.Response.Write("Page Load")
  1058.         End Sub
  1059.  
  1060.         ' Page Unload event
  1061.         Public Sub Page_Unload()
  1062.  
  1063.             'HttpContext.Current.Response.Write("Page Unload")
  1064.         End Sub
  1065.  
  1066.     ' Form Custom Validate event
  1067.     Public Function Form_CustomValidate(ByRef CustomError As String) As Boolean
  1068.  
  1069.         'Return error message in CustomError
  1070.         Return True
  1071.     End Function
  1072.     End Class
  1073.  
  1074.     '
  1075.     ' ASP.NET Page_Load event
  1076.     '
  1077.  
  1078.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  1079.         Response.Buffer = EW_RESPONSE_BUFFER
  1080.         Response.Cache.SetCacheability(HttpCacheability.NoCache)
  1081.  
  1082.         ' Page init
  1083.         tblLPR_edit = New ctblLPR_edit(Me)        
  1084.         tblLPR_edit.Page_Init()
  1085.  
  1086.         ' Page main processing
  1087.         tblLPR_edit.Page_Main()
  1088.     End Sub
  1089.  
  1090.     '
  1091.     ' ASP.NET Page_Unload event
  1092.     '
  1093.  
  1094.     Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
  1095.  
  1096.         ' Dispose page object
  1097.         If tblLPR_edit IsNot Nothing Then tblLPR_edit.Dispose()
  1098.     End Sub
  1099. End Class
  1100.