home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / tblLPRadd.aspx.vb < prev    next >
Text File  |  2012-02-19  |  43KB  |  1,012 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 tblLPRadd
  12.     Inherits AspNetMaker7_tfpssnet
  13.  
  14.     ' Page object
  15.     Public tblLPR_add As ctblLPR_add
  16.  
  17.     '
  18.     ' Page Class
  19.     '
  20.     Class ctblLPR_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 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 = "add"
  85.             m_PageObjName = "tblLPR_add"
  86.             m_PageObjTypeName = "ctblLPR_add"
  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.CanAdd 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.     Public x_ewPriv As Integer
  179.  
  180.     '
  181.     ' Page main processing
  182.     '
  183.     Sub Page_Main()
  184.  
  185.         ' Load key values from QueryString
  186.         Dim bCopy As Boolean = True
  187.         If ew_Get("lprID") <> "" Then
  188.             tblLPR.lprID.QueryStringValue = ew_Get("lprID")
  189.         Else
  190.             bCopy = False
  191.         End If
  192.  
  193.         ' Create form object
  194.         ObjForm = New cFormObj
  195.  
  196.         ' Process form if post back
  197.         If ObjForm.GetValue("a_add") <> "" Then
  198.             tblLPR.CurrentAction = ObjForm.GetValue("a_add") ' Get form action
  199.             LoadFormValues() ' Load form values
  200.  
  201.             ' Validate Form
  202.             If Not ValidateForm() Then
  203.                 tblLPR.CurrentAction = "I" ' Form error, reset action
  204.                 Message = ParentPage.gsFormError
  205.             End If
  206.  
  207.         ' Not post back
  208.         Else
  209.             If bCopy Then
  210.                 tblLPR.CurrentAction = "C" ' Copy Record
  211.             Else
  212.                 tblLPR.CurrentAction = "I" ' Display Blank Record
  213.                 LoadDefaultValues() ' Load default values
  214.             End If
  215.         End If
  216.  
  217.         ' Perform action based on action code
  218.         Select Case tblLPR.CurrentAction
  219.             Case "I" ' Blank record, no action required
  220.             Case "C" ' Copy an existing record
  221.                 If Not LoadRow() Then ' Load record based on key
  222.                     Message = "No records found" ' No record found
  223.                     Page_Terminate("tblLPRlist.aspx") ' No matching record, return to list
  224.                 End If
  225.             Case "A" ' Add new record
  226.                 tblLPR.SendEmail = True ' Send email on add success
  227.                 If AddRow() Then ' Add successful
  228.                     Message = "Add succeeded" ' Set up success message
  229.                     Dim sReturnUrl As String = tblLPR.ReturnUrl
  230.                     Page_Terminate(sReturnUrl) ' Clean up and return
  231.                 Else
  232.                     RestoreFormValues() ' Add failed, restore form values
  233.                 End If
  234.         End Select
  235.  
  236.         ' Render row based on row type
  237.         tblLPR.RowType = EW_ROWTYPE_ADD ' Render add type
  238.  
  239.         ' Render row
  240.         RenderRow()
  241.     End Sub
  242.  
  243.     '
  244.     ' Get upload file
  245.     '
  246.     Sub GetUploadFiles()
  247.  
  248.         ' Get upload data
  249.     End Sub
  250.  
  251.     '
  252.     ' Load default values
  253.     '
  254.     Sub LoadDefaultValues()
  255.             tblLPR.lprDate.CurrentValue = ew_CurrentDate()
  256.             tblLPR.lprPriority.CurrentValue = 0
  257.         End Sub
  258.  
  259.     '
  260.     ' Load form values
  261.     '
  262.     Sub LoadFormValues()
  263.         tblLPR.lprEmpID.FormValue = ObjForm.GetValue("x_lprEmpID")
  264.         tblLPR.lprEmpID.OldValue = ObjForm.GetValue("o_lprEmpID")
  265.         tblLPR.lprDate.FormValue = ObjForm.GetValue("x_lprDate")
  266.         tblLPR.lprDate.CurrentValue = ew_UnFormatDateTime(tblLPR.lprDate.CurrentValue, 6)
  267.         tblLPR.lprDate.OldValue = ObjForm.GetValue("o_lprDate")
  268.         tblLPR.lprLocationID.FormValue = ObjForm.GetValue("x_lprLocationID")
  269.         tblLPR.lprLocationID.OldValue = ObjForm.GetValue("o_lprLocationID")
  270.         tblLPR.lprFixtureLocationID.FormValue = ObjForm.GetValue("x_lprFixtureLocationID")
  271.         tblLPR.lprFixtureLocationID.OldValue = ObjForm.GetValue("o_lprFixtureLocationID")
  272.         tblLPR.lprFixtureTypeID.FormValue = ObjForm.GetValue("x_lprFixtureTypeID")
  273.         tblLPR.lprFixtureTypeID.OldValue = ObjForm.GetValue("o_lprFixtureTypeID")
  274.         tblLPR.lprFixtureNumber.FormValue = ObjForm.GetValue("x_lprFixtureNumber")
  275.         tblLPR.lprFixtureNumber.OldValue = ObjForm.GetValue("o_lprFixtureNumber")
  276.         tblLPR.lprChannelNumber.FormValue = ObjForm.GetValue("x_lprChannelNumber")
  277.         tblLPR.lprChannelNumber.OldValue = ObjForm.GetValue("o_lprChannelNumber")
  278.             If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  279.                 tblLPR.lprPriority.FormValue = ObjForm.GetValue("x_lprPriority")
  280.                 tblLPR.lprPriority.OldValue = ObjForm.GetValue("o_lprPriority")
  281.                 tblLPR.lprSTID.FormValue = ObjForm.GetValue("x_lprSTID")
  282.                 tblLPR.lprSTID.OldValue = ObjForm.GetValue("o_lprSTID")
  283.             End If
  284.             tblLPR.lprShortDesc.FormValue = ObjForm.GetValue("x_lprShortDesc")
  285.             tblLPR.lprShortDesc.OldValue = ObjForm.GetValue("o_lprShortDesc")
  286.             tblLPR.lprDesc.FormValue = ObjForm.GetValue("x_lprDesc")
  287.             tblLPR.lprDesc.OldValue = ObjForm.GetValue("o_lprDesc")
  288.             tblLPR.lprID.FormValue = ObjForm.GetValue("x_lprID")
  289.         End Sub
  290.  
  291.         '
  292.         ' Restore form values
  293.         '
  294.         Sub RestoreFormValues()
  295.             tblLPR.lprEmpID.CurrentValue = tblLPR.lprEmpID.FormValue
  296.             tblLPR.lprDate.CurrentValue = tblLPR.lprDate.FormValue
  297.             tblLPR.lprDate.CurrentValue = ew_UnFormatDateTime(tblLPR.lprDate.CurrentValue, 6)
  298.             tblLPR.lprLocationID.CurrentValue = tblLPR.lprLocationID.FormValue
  299.             tblLPR.lprFixtureLocationID.CurrentValue = tblLPR.lprFixtureLocationID.FormValue
  300.             tblLPR.lprFixtureTypeID.CurrentValue = tblLPR.lprFixtureTypeID.FormValue
  301.             tblLPR.lprFixtureNumber.CurrentValue = tblLPR.lprFixtureNumber.FormValue
  302.             tblLPR.lprChannelNumber.CurrentValue = tblLPR.lprChannelNumber.FormValue
  303.             If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  304.                 tblLPR.lprPriority.CurrentValue = tblLPR.lprPriority.FormValue
  305.                 tblLPR.lprSTID.CurrentValue = tblLPR.lprSTID.FormValue
  306.             End If
  307.             tblLPR.lprShortDesc.CurrentValue = tblLPR.lprShortDesc.FormValue
  308.             tblLPR.lprDesc.CurrentValue = tblLPR.lprDesc.FormValue
  309.             tblLPR.lprID.CurrentValue = tblLPR.lprID.FormValue
  310.         End Sub
  311.  
  312.         '
  313.         ' Load row based on key values
  314.         '
  315.         Function LoadRow() As Boolean
  316.             Dim RsRow As OleDbDataReader
  317.             Dim sFilter As String = tblLPR.KeyFilter
  318.  
  319.             ' Row Selecting event
  320.             tblLPR.Row_Selecting(sFilter)
  321.  
  322.             ' Load SQL based on filter
  323.             tblLPR.CurrentFilter = sFilter
  324.             Dim sSql As String = tblLPR.SQL
  325.  
  326.             ' Write SQL for debug
  327.             If EW_DEBUG_ENABLED Then ew_Write(sSql)
  328.             Try
  329.                 RsRow = Conn.GetTempDataReader(sSql)
  330.                 If Not RsRow.Read() Then
  331.                     Return False
  332.                 Else
  333.                     LoadRowValues(RsRow) ' Load row values
  334.  
  335.                     ' Row Selected event
  336.                     tblLPR.Row_Selected(RsRow)
  337.                     Return True
  338.                 End If
  339.             Catch
  340.                 If EW_DEBUG_ENABLED Then Throw
  341.                 Return False
  342.             Finally
  343.                 Conn.CloseTempDataReader()
  344.             End Try
  345.         End Function
  346.  
  347.         '
  348.         ' Load row values from recordset
  349.         '
  350.         Sub LoadRowValues(ByRef RsRow As OleDbDataReader)
  351.             tblLPR.lprID.DbValue = RsRow("lprID")
  352.             tblLPR.lprEmpID.DbValue = RsRow("lprEmpID")
  353.             tblLPR.lprDate.DbValue = RsRow("lprDate")
  354.             tblLPR.lprLocationID.DbValue = RsRow("lprLocationID")
  355.             tblLPR.lprFixtureLocationID.DbValue = RsRow("lprFixtureLocationID")
  356.             tblLPR.lprFixtureTypeID.DbValue = RsRow("lprFixtureTypeID")
  357.             tblLPR.lprFixtureNumber.DbValue = RsRow("lprFixtureNumber")
  358.             tblLPR.lprChannelNumber.DbValue = RsRow("lprChannelNumber")
  359.             If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  360.                 tblLPR.lprPriority.DbValue = RsRow("lprPriority")
  361.                 tblLPR.lprSTID.DbValue = RsRow("lprSTID")
  362.             End If
  363.             tblLPR.lprShortDesc.DbValue = RsRow("lprShortDesc")
  364.             tblLPR.lprSTChangedBy.DbValue = RsRow("lprSTChangedBy")
  365.             tblLPR.lprDesc.DbValue = RsRow("lprDesc")
  366.             tblLPR.lprCreatedBy.DbValue = RsRow("lprCreatedBy")
  367.             tblLPR.lprCreatedOn.DbValue = RsRow("lprCreatedOn")
  368.             tblLPR.lprModifiedBy.DbValue = RsRow("lprModifiedBy")
  369.             tblLPR.lprModifiedOn.DbValue = RsRow("lprModifiedOn")
  370.         End Sub
  371.  
  372.         '
  373.         ' Render row values based on field settings
  374.         '
  375.         Sub RenderRow()
  376.  
  377.             ' Row Rendering event
  378.             tblLPR.Row_Rendering()
  379.  
  380.             '
  381.             '  Common render codes for all row types
  382.             '
  383.             ' lprEmpID
  384.  
  385.             tblLPR.lprEmpID.CellCssStyle = ""
  386.             tblLPR.lprEmpID.CellCssClass = ""
  387.  
  388.             ' lprDate
  389.             tblLPR.lprDate.CellCssStyle = ""
  390.             tblLPR.lprDate.CellCssClass = ""
  391.  
  392.             ' lprLocationID
  393.             tblLPR.lprLocationID.CellCssStyle = ""
  394.             tblLPR.lprLocationID.CellCssClass = ""
  395.  
  396.             ' lprFixtureLocationID
  397.             tblLPR.lprFixtureLocationID.CellCssStyle = ""
  398.             tblLPR.lprFixtureLocationID.CellCssClass = ""
  399.  
  400.             ' lprFixtureTypeID
  401.             tblLPR.lprFixtureTypeID.CellCssStyle = ""
  402.             tblLPR.lprFixtureTypeID.CellCssClass = ""
  403.  
  404.             ' lprFixtureNumber
  405.             tblLPR.lprFixtureNumber.CellCssStyle = ""
  406.             tblLPR.lprFixtureNumber.CellCssClass = ""
  407.  
  408.             ' lprChannelNumber
  409.             tblLPR.lprChannelNumber.CellCssStyle = ""
  410.             tblLPR.lprChannelNumber.CellCssClass = ""
  411.  
  412.             If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  413.                 ' lprPriority
  414.                 tblLPR.lprPriority.CellCssStyle = ""
  415.                 tblLPR.lprPriority.CellCssClass = ""
  416.  
  417.                 ' lprSTID
  418.                 tblLPR.lprSTID.CellCssStyle = ""
  419.                 tblLPR.lprSTID.CellCssClass = ""
  420.             End If
  421.  
  422.             ' lprShortDesc
  423.             tblLPR.lprShortDesc.CellCssStyle = ""
  424.             tblLPR.lprShortDesc.CellCssClass = ""
  425.  
  426.             ' lprDesc
  427.             tblLPR.lprDesc.CellCssStyle = ""
  428.             tblLPR.lprDesc.CellCssClass = ""
  429.  
  430.             '
  431.             '  View  Row
  432.             '
  433.  
  434.             If tblLPR.RowType = EW_ROWTYPE_VIEW Then ' View row
  435.  
  436.                 ' lprEmpID
  437.                 If ew_NotEmpty(tblLPR.lprEmpID.CurrentValue) Then
  438.                     sSqlWrk = "SELECT [empName] FROM [tblEmployees] WHERE [empID] = " & ew_AdjustSql(tblLPR.lprEmpID.CurrentValue) & " AND [emp[IsActive]=True"
  439.                     sSqlWrk = sSqlWrk & " ORDER BY [empFirstName] "
  440.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  441.                     If RsWrk.Read() Then
  442.                         tblLPR.lprEmpID.ViewValue = RsWrk("empName")
  443.                     Else
  444.                         tblLPR.lprEmpID.ViewValue = tblLPR.lprEmpID.CurrentValue
  445.                     End If
  446.                     Conn.CloseTempDataReader()
  447.                 Else
  448.                     tblLPR.lprEmpID.ViewValue = System.DBNull.Value
  449.                 End If
  450.                 tblLPR.lprEmpID.CssStyle = ""
  451.                 tblLPR.lprEmpID.CssClass = ""
  452.                 tblLPR.lprEmpID.ViewCustomAttributes = ""
  453.  
  454.                 ' lprDate
  455.                 tblLPR.lprDate.ViewValue = tblLPR.lprDate.CurrentValue
  456.                 tblLPR.lprDate.ViewValue = ew_FormatDateTime(tblLPR.lprDate.ViewValue, 6)
  457.                 tblLPR.lprDate.CssStyle = ""
  458.                 tblLPR.lprDate.CssClass = ""
  459.                 tblLPR.lprDate.ViewCustomAttributes = ""
  460.  
  461.                 ' lprLocationID
  462.                 If ew_NotEmpty(tblLPR.lprLocationID.CurrentValue) Then
  463.                     sSqlWrk = "SELECT [locDescription] FROM [tblLocations] WHERE [locID] = " & ew_AdjustSql(tblLPR.lprLocationID.CurrentValue) & " AND [locIsActive]=True"
  464.                     sSqlWrk = sSqlWrk & " AND (" & "[locLighting]=True" & ")"
  465.                     sSqlWrk = sSqlWrk & " ORDER BY [locDescription] "
  466.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  467.                     If RsWrk.Read() Then
  468.                         tblLPR.lprLocationID.ViewValue = RsWrk("locDescription")
  469.                     Else
  470.                         tblLPR.lprLocationID.ViewValue = tblLPR.lprLocationID.CurrentValue
  471.                     End If
  472.                     Conn.CloseTempDataReader()
  473.                 Else
  474.                     tblLPR.lprLocationID.ViewValue = System.DBNull.Value
  475.                 End If
  476.                 tblLPR.lprLocationID.CssStyle = ""
  477.                 tblLPR.lprLocationID.CssClass = ""
  478.                 tblLPR.lprLocationID.ViewCustomAttributes = ""
  479.  
  480.                 ' lprFixtureLocationID
  481.                 If ew_NotEmpty(tblLPR.lprFixtureLocationID.CurrentValue) Then
  482.                     sSqlWrk = "SELECT [floDescription] FROM [tblLPRFixtureLocation] WHERE [floID] = " & ew_AdjustSql(tblLPR.lprFixtureLocationID.CurrentValue) & " AND [floIsActive]=True"
  483.                     sSqlWrk = sSqlWrk & " ORDER BY [floDescription] "
  484.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  485.                     If RsWrk.Read() Then
  486.                         tblLPR.lprFixtureLocationID.ViewValue = RsWrk("floDescription")
  487.                     Else
  488.                         tblLPR.lprFixtureLocationID.ViewValue = tblLPR.lprFixtureLocationID.CurrentValue
  489.                     End If
  490.                     Conn.CloseTempDataReader()
  491.                 Else
  492.                     tblLPR.lprFixtureLocationID.ViewValue = System.DBNull.Value
  493.                 End If
  494.                 tblLPR.lprFixtureLocationID.CssStyle = ""
  495.                 tblLPR.lprFixtureLocationID.CssClass = ""
  496.                 tblLPR.lprFixtureLocationID.ViewCustomAttributes = ""
  497.  
  498.                 ' lprFixtureTypeID
  499.                 If ew_NotEmpty(tblLPR.lprFixtureTypeID.CurrentValue) Then
  500.                     sSqlWrk = "SELECT [ftyDescription] FROM [tblLPRFixtureType] WHERE [ftyID] = " & ew_AdjustSql(tblLPR.lprFixtureTypeID.CurrentValue) & " AND [ftyIsActive]=True"
  501.                     RsWrk = Conn.GetTempDataReader(sSqlWrk)
  502.                     If RsWrk.Read() Then
  503.                         tblLPR.lprFixtureTypeID.ViewValue = RsWrk("ftyDescription")
  504.                     Else
  505.                         tblLPR.lprFixtureTypeID.ViewValue = tblLPR.lprFixtureTypeID.CurrentValue
  506.                     End If
  507.                     Conn.CloseTempDataReader()
  508.                 Else
  509.                     tblLPR.lprFixtureTypeID.ViewValue = System.DBNull.Value
  510.                 End If
  511.                 tblLPR.lprFixtureTypeID.CssStyle = ""
  512.                 tblLPR.lprFixtureTypeID.CssClass = ""
  513.                 tblLPR.lprFixtureTypeID.ViewCustomAttributes = ""
  514.  
  515.                 ' lprFixtureNumber
  516.                 tblLPR.lprFixtureNumber.ViewValue = tblLPR.lprFixtureNumber.CurrentValue
  517.                 tblLPR.lprFixtureNumber.CssStyle = ""
  518.                 tblLPR.lprFixtureNumber.CssClass = ""
  519.                 tblLPR.lprFixtureNumber.ViewCustomAttributes = ""
  520.  
  521.                 ' lprChannelNumber
  522.                 tblLPR.lprChannelNumber.ViewValue = tblLPR.lprChannelNumber.CurrentValue
  523.                 tblLPR.lprChannelNumber.CssStyle = ""
  524.                 tblLPR.lprChannelNumber.CssClass = ""
  525.                 tblLPR.lprChannelNumber.ViewCustomAttributes = ""
  526.  
  527.                 If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  528.                     ' lprPriority
  529.                     If Not IsDBNull(tblLPR.lprPriority.CurrentValue) Then
  530.                         Select Case tblLPR.lprPriority.CurrentValue
  531.                             Case "0"
  532.                                 tblLPR.lprPriority.ViewValue = "Not Specified"
  533.                             Case "1"
  534.                                 tblLPR.lprPriority.ViewValue = "Low"
  535.                             Case "2"
  536.                                 tblLPR.lprPriority.ViewValue = "Medium"
  537.                             Case "3"
  538.                                 tblLPR.lprPriority.ViewValue = "High"
  539.                             Case Else
  540.                                 tblLPR.lprPriority.ViewValue = tblLPR.lprPriority.CurrentValue
  541.                         End Select
  542.                     Else
  543.                         tblLPR.lprPriority.ViewValue = System.DBNull.Value
  544.                     End If
  545.                     tblLPR.lprPriority.CssStyle = ""
  546.                     tblLPR.lprPriority.CssClass = ""
  547.                     tblLPR.lprPriority.ViewCustomAttributes = ""
  548.  
  549.                     ' lprSTID
  550.                     If ew_NotEmpty(tblLPR.lprSTID.CurrentValue) Then
  551.                         sSqlWrk = "SELECT [lstDescription] FROM [tblLPRStatus] WHERE [lstID] = " & ew_AdjustSql(tblLPR.lprSTID.CurrentValue) & " AND [lstIsActive]=True"
  552.                         sSqlWrk = sSqlWrk & " ORDER BY [lstDescription] "
  553.                         RsWrk = Conn.GetTempDataReader(sSqlWrk)
  554.                         If RsWrk.Read() Then
  555.                             tblLPR.lprSTID.ViewValue = RsWrk("lstDescription")
  556.                         Else
  557.                             tblLPR.lprSTID.ViewValue = tblLPR.lprSTID.CurrentValue
  558.                         End If
  559.                         Conn.CloseTempDataReader()
  560.                     Else
  561.                         tblLPR.lprSTID.ViewValue = System.DBNull.Value
  562.                     End If
  563.                     tblLPR.lprSTID.CssStyle = ""
  564.                     tblLPR.lprSTID.CssClass = ""
  565.                     tblLPR.lprSTID.ViewCustomAttributes = ""
  566.                 End If
  567.  
  568.                 ' lprShortDesc
  569.                 tblLPR.lprShortDesc.ViewValue = tblLPR.lprShortDesc.CurrentValue
  570.                 tblLPR.lprShortDesc.CssStyle = ""
  571.                 tblLPR.lprShortDesc.CssClass = ""
  572.                 tblLPR.lprShortDesc.ViewCustomAttributes = ""
  573.  
  574.                 ' lprSTChangedBy
  575.                 tblLPR.lprSTChangedBy.ViewValue = tblLPR.lprSTChangedBy.CurrentValue
  576.                 tblLPR.lprSTChangedBy.CssStyle = ""
  577.                 tblLPR.lprSTChangedBy.CssClass = ""
  578.                 tblLPR.lprSTChangedBy.ViewCustomAttributes = ""
  579.  
  580.                 ' lprDesc
  581.                 tblLPR.lprDesc.ViewValue = tblLPR.lprDesc.CurrentValue
  582.                 tblLPR.lprDesc.CssStyle = ""
  583.                 tblLPR.lprDesc.CssClass = ""
  584.                 tblLPR.lprDesc.ViewCustomAttributes = ""
  585.  
  586.                 ' lprCreatedBy
  587.                 tblLPR.lprCreatedBy.ViewValue = tblLPR.lprCreatedBy.CurrentValue
  588.                 tblLPR.lprCreatedBy.CssStyle = ""
  589.                 tblLPR.lprCreatedBy.CssClass = ""
  590.                 tblLPR.lprCreatedBy.ViewCustomAttributes = ""
  591.  
  592.                 ' lprCreatedOn
  593.                 tblLPR.lprCreatedOn.ViewValue = tblLPR.lprCreatedOn.CurrentValue
  594.                 tblLPR.lprCreatedOn.ViewValue = ew_FormatDateTime(tblLPR.lprCreatedOn.ViewValue, 6)
  595.                 tblLPR.lprCreatedOn.CssStyle = ""
  596.                 tblLPR.lprCreatedOn.CssClass = ""
  597.                 tblLPR.lprCreatedOn.ViewCustomAttributes = ""
  598.  
  599.                 ' lprModifiedBy
  600.                 tblLPR.lprModifiedBy.ViewValue = tblLPR.lprModifiedBy.CurrentValue
  601.                 tblLPR.lprModifiedBy.CssStyle = ""
  602.                 tblLPR.lprModifiedBy.CssClass = ""
  603.                 tblLPR.lprModifiedBy.ViewCustomAttributes = ""
  604.  
  605.                 ' lprModifiedOn
  606.                 tblLPR.lprModifiedOn.ViewValue = tblLPR.lprModifiedOn.CurrentValue
  607.                 tblLPR.lprModifiedOn.ViewValue = ew_FormatDateTime(tblLPR.lprModifiedOn.ViewValue, 6)
  608.                 tblLPR.lprModifiedOn.CssStyle = ""
  609.                 tblLPR.lprModifiedOn.CssClass = ""
  610.                 tblLPR.lprModifiedOn.ViewCustomAttributes = ""
  611.  
  612.                 ' View refer script
  613.                 ' lprEmpID
  614.  
  615.                 tblLPR.lprEmpID.HrefValue = ""
  616.  
  617.                 ' lprDate
  618.                 tblLPR.lprDate.HrefValue = ""
  619.  
  620.                 ' lprLocationID
  621.                 tblLPR.lprLocationID.HrefValue = ""
  622.  
  623.                 ' lprFixtureLocationID
  624.                 tblLPR.lprFixtureLocationID.HrefValue = ""
  625.  
  626.                 ' lprFixtureTypeID
  627.                 tblLPR.lprFixtureTypeID.HrefValue = ""
  628.  
  629.                 ' lprFixtureNumber
  630.                 tblLPR.lprFixtureNumber.HrefValue = ""
  631.  
  632.                 ' lprChannelNumber
  633.                 tblLPR.lprChannelNumber.HrefValue = ""
  634.  
  635.                 If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  636.                     ' lprPriority
  637.                     tblLPR.lprPriority.HrefValue = ""
  638.  
  639.                     ' lprSTID
  640.                     tblLPR.lprSTID.HrefValue = ""
  641.                 End If
  642.  
  643.                 ' lprShortDesc
  644.                 tblLPR.lprShortDesc.HrefValue = ""
  645.  
  646.                 ' lprDesc
  647.                 tblLPR.lprDesc.HrefValue = ""
  648.  
  649.                 '
  650.                 '  Add Row
  651.                 '
  652.  
  653.             ElseIf tblLPR.RowType = EW_ROWTYPE_ADD Then ' Add row
  654.  
  655.                 ' lprEmpID
  656.                 tblLPR.lprEmpID.EditCustomAttributes = ""
  657.                 If Not Security.IsAdmin And Security.IsLoggedIn() Then ' Non system admin
  658.                     tblLPR.lprEmpID.CurrentValue = Security.CurrentUserID
  659.                     If ew_NotEmpty(tblLPR.lprEmpID.CurrentValue) Then
  660.                         sSqlWrk = "SELECT [empName] FROM [tblEmployees] WHERE [empID] = " & ew_AdjustSql(tblLPR.lprEmpID.CurrentValue) & " AND [empIsActive]=True"
  661.                         sSqlWrk = sSqlWrk & " ORDER BY [empFirstName] "
  662.                         RsWrk = Conn.GetTempDataReader(sSqlWrk)
  663.                         If RsWrk.Read() Then
  664.                             tblLPR.lprEmpID.EditValue = RsWrk("empName")
  665.                         Else
  666.                             tblLPR.lprEmpID.EditValue = tblLPR.lprEmpID.CurrentValue
  667.                         End If
  668.                         Conn.CloseTempDataReader()
  669.                     Else
  670.                         tblLPR.lprEmpID.EditValue = System.DBNull.Value
  671.                     End If
  672.                     tblLPR.lprEmpID.CssStyle = ""
  673.                     tblLPR.lprEmpID.CssClass = ""
  674.                     tblLPR.lprEmpID.ViewCustomAttributes = ""
  675.                 Else
  676.                     sSqlWrk = "SELECT [empID], [empName], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblEmployees]"
  677.                     sWhereWrk = "[empIsActive]=True"
  678.                     sWhereWrk = tblEmployees.AddUserIDFilter(sWhereWrk)
  679.                     If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  680.                     sSqlWrk = sSqlWrk & " ORDER BY [empFirstName] "
  681.                     arwrk = Conn.GetRows(sSqlWrk)
  682.                     arwrk.Insert(0, New Object() {"", "Please Select"})
  683.                     tblLPR.lprEmpID.EditValue = arwrk
  684.                 End If
  685.  
  686.                 ' lprDate
  687.                 tblLPR.lprDate.EditCustomAttributes = ""
  688.                 tblLPR.lprDate.EditValue = ew_FormatDateTime(tblLPR.lprDate.CurrentValue, 6)
  689.  
  690.                 ' lprLocationID
  691.                 tblLPR.lprLocationID.EditCustomAttributes = ""
  692.                 sSqlWrk = "SELECT [locID], [locDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblLocations]"
  693.                 sWhereWrk = "[locIsActive]=True"
  694.                 If sWhereWrk <> "" Then sWhereWrk = "(" & sWhereWrk & ") AND "
  695.                 sWhereWrk = sWhereWrk & "(" & "[locLighting]=True" & ")"
  696.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  697.                 sSqlWrk = sSqlWrk & " ORDER BY [locDescription] "
  698.                 arwrk = Conn.GetRows(sSqlWrk)
  699.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  700.                 tblLPR.lprLocationID.EditValue = arwrk
  701.  
  702.                 ' lprFixtureLocationID
  703.                 tblLPR.lprFixtureLocationID.EditCustomAttributes = ""
  704.                 sSqlWrk = "SELECT [floID], [floDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblLPRFixtureLocation]"
  705.                 sWhereWrk = "[floIsActive]=True"
  706.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  707.                 sSqlWrk = sSqlWrk & " ORDER BY [floDescription] "
  708.                 arwrk = Conn.GetRows(sSqlWrk)
  709.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  710.                 tblLPR.lprFixtureLocationID.EditValue = arwrk
  711.  
  712.                 ' lprFixtureTypeID
  713.                 tblLPR.lprFixtureTypeID.EditCustomAttributes = ""
  714.                 sSqlWrk = "SELECT [ftyID], [ftyDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblLPRFixtureType]"
  715.                 sWhereWrk = "[ftyIsActive]=True"
  716.                 If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  717.                 arwrk = Conn.GetRows(sSqlWrk)
  718.                 arwrk.Insert(0, New Object() {"", "Please Select"})
  719.                 tblLPR.lprFixtureTypeID.EditValue = arwrk
  720.  
  721.                 ' lprFixtureNumber
  722.                 tblLPR.lprFixtureNumber.EditCustomAttributes = ""
  723.                 tblLPR.lprFixtureNumber.EditValue = ew_HtmlEncode(tblLPR.lprFixtureNumber.CurrentValue)
  724.  
  725.                 ' lprChannelNumber
  726.                 tblLPR.lprChannelNumber.EditCustomAttributes = ""
  727.                 tblLPR.lprChannelNumber.EditValue = ew_HtmlEncode(tblLPR.lprChannelNumber.CurrentValue)
  728.  
  729.                 If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  730.                     ' lprPriority
  731.                     tblLPR.lprPriority.EditCustomAttributes = ""
  732.                     arwrk = New ArrayList
  733.                     arwrk.Add(New String() {"0", "Not Specified"})
  734.                     arwrk.Add(New String() {"1", "Low"})
  735.                     arwrk.Add(New String() {"2", "Medium"})
  736.                     arwrk.Add(New String() {"3", "High"})
  737.                     arwrk.Insert(0, New String() {"", "Please Select"})
  738.                     tblLPR.lprPriority.EditValue = arwrk
  739.  
  740.                     ' lprSTID
  741.                     tblLPR.lprSTID.EditCustomAttributes = ""
  742.                     sSqlWrk = "SELECT [lstID], [lstDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblLPRStatus]"
  743.                     sWhereWrk = "[lstIsActive]=True"
  744.                     If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  745.                     sSqlWrk = sSqlWrk & " ORDER BY [lstDescription] "
  746.                     arwrk = Conn.GetRows(sSqlWrk)
  747.                     arwrk.Insert(0, New Object() {"", "Please Select"})
  748.                     tblLPR.lprSTID.EditValue = arwrk
  749.                 End If
  750.  
  751.                 ' lprShortDesc
  752.                 tblLPR.lprShortDesc.EditCustomAttributes = ""
  753.                 tblLPR.lprShortDesc.EditValue = ew_HtmlEncode(tblLPR.lprShortDesc.CurrentValue)
  754.  
  755.  
  756.                 ' lprDesc
  757.                 tblLPR.lprDesc.EditCustomAttributes = ""
  758.                 tblLPR.lprDesc.EditValue = ew_HtmlEncode(tblLPR.lprDesc.CurrentValue)
  759.             End If
  760.  
  761.             ' Row Rendered event
  762.             tblLPR.Row_Rendered()
  763.         End Sub
  764.  
  765.         '
  766.         ' Validate form
  767.         '
  768.         Function ValidateForm() As Boolean
  769.  
  770.             ' Initialize
  771.             ParentPage.gsFormError = ""
  772.  
  773.             ' Check if validation required
  774.             If Not EW_SERVER_VALIDATE Then Return (ParentPage.gsFormError = "")
  775.             If ew_Empty(tblLPR.lprEmpID.FormValue) Then
  776.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  777.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Employee"
  778.             End If
  779.             If ew_Empty(tblLPR.lprDate.FormValue) Then
  780.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  781.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Date"
  782.             End If
  783.             If Not ew_CheckUSDate(tblLPR.lprDate.FormValue) Then
  784.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  785.                 ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect date, format = mm/dd/yyyy - Date"
  786.             End If
  787.             If ew_Empty(tblLPR.lprLocationID.FormValue) Then
  788.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  789.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Location"
  790.             End If
  791.             If ew_Empty(tblLPR.lprFixtureLocationID.FormValue) Then
  792.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  793.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Fixture Location"
  794.             End If
  795.             If ew_Empty(tblLPR.lprFixtureTypeID.FormValue) Then
  796.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  797.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Fixture Type"
  798.             End If
  799.             If Not ew_CheckInteger(tblLPR.lprFixtureNumber.FormValue) Then
  800.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  801.                 ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect integer - Fixture Number"
  802.             End If
  803.             If ew_Empty(tblLPR.lprChannelNumber.FormValue) Then
  804.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  805.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Channel Number"
  806.             End If
  807.             If Not ew_CheckInteger(tblLPR.lprChannelNumber.FormValue) Then
  808.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  809.                 ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect integer - Channel Number"
  810.             End If
  811.             If ew_Empty(tblLPR.lprPriority.FormValue) Then
  812.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  813.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Priority"
  814.             End If
  815.             If ew_Empty(tblLPR.lprShortDesc.FormValue) Then
  816.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  817.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Short Desc"
  818.             End If
  819.             If ew_Empty(tblLPR.lprSTID.FormValue) Then
  820.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  821.                 ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Status"
  822.             End If
  823.  
  824.             ' Return validate result
  825.             Dim Valid As Boolean = (ParentPage.gsFormError = "")
  826.  
  827.             ' Form_CustomValidate event
  828.             Dim sFormCustomError As String = ""
  829.             Valid = Valid And Form_CustomValidate(sFormCustomError)
  830.             If sFormCustomError <> "" Then
  831.                 If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  832.                 ParentPage.gsFormError = ParentPage.gsFormError & sFormCustomError
  833.             End If
  834.             Return Valid
  835.         End Function
  836.  
  837.         '
  838.         ' Add record
  839.         '
  840.         Function AddRow() As Boolean
  841.             Dim Rs As New OrderedDictionary
  842.             Dim sSql As String, sFilter As String
  843.             Dim bInsertRow As Boolean
  844.             Dim RsChk As OleDbDataReader
  845.             Dim sIdxErrMsg As String
  846.             Dim LastInsertId As Object
  847.  
  848.             ' Check if valid user ID
  849.             Dim bValidUser As Boolean = False, sUserIdMsg As String
  850.             If ew_NotEmpty(Security.CurrentUserID) AndAlso Not Security.IsAdmin() Then ' Non system admin
  851.                 bValidUser = Security.IsValidUserID(tblLPR.lprEmpID.CurrentValue)
  852.                 If Not bValidUser Then
  853.                     sUserIdMsg = "The current user (%c) is not authorized to assign the user ID (%u).".Replace("%c", Security.CurrentUserID)
  854.                     sUserIdMsg = sUserIdMsg.Replace("%u", tblLPR.lprEmpID.CurrentValue)
  855.                     Message = sUserIdMsg
  856.                     Return False
  857.                 End If
  858.             End If
  859.             'If ew_NotEmpty(tblLPR.lprDesc.CurrentValue) Then ' Check field with unique index
  860.             '    sFilter = "([lprDesc] = '" & ew_AdjustSql(tblLPR.lprDesc.CurrentValue) & "')"
  861.             '    RsChk = tblLPR.LoadRs(sFilter)
  862.             '    If RsChk IsNot Nothing Then
  863.             '        sIdxErrMsg = "Duplicate value '%v' for unique index '%f'".Replace("%f", "lprDesc")
  864.             '        sIdxErrMsg = sIdxErrMsg.Replace("%v", tblLPR.lprDesc.CurrentValue)
  865.             '        Message = sIdxErrMsg
  866.             '        RsChk.Close()
  867.             '        RsChk.Dispose()
  868.             '        Return False
  869.             '    End If
  870.             'End If
  871.  
  872.             ' lprEmpID
  873.             tblLPR.lprEmpID.SetDbValue(tblLPR.lprEmpID.CurrentValue, System.DBNull.Value)
  874.             Rs("lprEmpID") = tblLPR.lprEmpID.DbValue
  875.  
  876.             ' lprDate
  877.             tblLPR.lprDate.SetDbValue(ew_UnFormatDateTime(tblLPR.lprDate.CurrentValue, 6), System.DBNull.Value)
  878.             Rs("lprDate") = tblLPR.lprDate.DbValue
  879.  
  880.             ' lprLocationID
  881.             tblLPR.lprLocationID.SetDbValue(tblLPR.lprLocationID.CurrentValue, System.DBNull.Value)
  882.             Rs("lprLocationID") = tblLPR.lprLocationID.DbValue
  883.  
  884.             ' lprFixtureLocationID
  885.             tblLPR.lprFixtureLocationID.SetDbValue(tblLPR.lprFixtureLocationID.CurrentValue, System.DBNull.Value)
  886.             Rs("lprFixtureLocationID") = tblLPR.lprFixtureLocationID.DbValue
  887.  
  888.             ' lprFixtureTypeID
  889.             tblLPR.lprFixtureTypeID.SetDbValue(tblLPR.lprFixtureTypeID.CurrentValue, System.DBNull.Value)
  890.             Rs("lprFixtureTypeID") = tblLPR.lprFixtureTypeID.DbValue
  891.  
  892.             ' lprFixtureNumber
  893.             tblLPR.lprFixtureNumber.SetDbValue(tblLPR.lprFixtureNumber.CurrentValue, System.DBNull.Value)
  894.             Rs("lprFixtureNumber") = tblLPR.lprFixtureNumber.DbValue
  895.  
  896.             ' lprChannelNumber
  897.             tblLPR.lprChannelNumber.SetDbValue(tblLPR.lprChannelNumber.CurrentValue, System.DBNull.Value)
  898.             Rs("lprChannelNumber") = tblLPR.lprChannelNumber.DbValue
  899.  
  900.             If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  901.                 ' lprPriority
  902.                 tblLPR.lprPriority.SetDbValue(tblLPR.lprPriority.CurrentValue, System.DBNull.Value)
  903.                 If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  904.                     Rs("lprPriority") = tblLPR.lprPriority.DbValue
  905.                 Else
  906.                     Rs("lprPriority") = 0
  907.                 End If
  908.             Else
  909.                 Rs("lprPriority") = 0
  910.             End If
  911.  
  912.             If ew_Session("tfpssnet_Status_Userlevel") = -1 Or ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  913.                 ' lprSTID
  914.                 tblLPR.lprSTID.SetDbValue(tblLPR.lprSTID.CurrentValue, System.DBNull.Value)
  915.                 If ew_Session("tfpssnet_Status_UserLevel") = 3 Or ew_Session("tfpssnet_Status_Userlevel") = 4 Then
  916.                     Rs("lprSTChangedBy") = "Admin"
  917.                 Else
  918.                     Rs("lprSTChangedBy") = ew_Session("tfpssnet_Status_UserName")
  919.                 End If
  920.                 Rs("lprSTID") = tblLPR.lprSTID.DbValue
  921.             Else
  922.                 Rs("lprSTID") = 1
  923.             End If
  924.  
  925.             ' lprShortDesc
  926.             tblLPR.lprShortDesc.SetDbValue(tblLPR.lprShortDesc.CurrentValue, System.DBNull.Value)
  927.             Rs("lprShortDesc") = tblLPR.lprShortDesc.DbValue
  928.  
  929.             ' lprDesc
  930.             tblLPR.lprDesc.SetDbValue(tblLPR.lprDesc.CurrentValue, System.DBNull.Value)
  931.             Rs("lprDesc") = tblLPR.lprDesc.DbValue
  932.  
  933.             Rs("lprCreatedBy") = ew_Session("tfpssnet_Status_UserName")
  934.             Rs("lprCreatedOn") = ew_CurrentDate()
  935.  
  936.             ' Row Inserting event
  937.             bInsertRow = tblLPR.Row_Inserting(Rs)
  938.             If bInsertRow Then
  939.                 Try
  940.                     tblLPR.Insert(Rs)
  941.                     AddRow = True
  942.                 Catch e As Exception
  943.                     If EW_DEBUG_ENABLED Then Throw
  944.                     Message = e.Message
  945.                     AddRow = False
  946.                 End Try
  947.             Else
  948.                 If tblLPR.CancelMessage <> "" Then
  949.                     Message = tblLPR.CancelMessage
  950.                     tblLPR.CancelMessage = ""
  951.                 Else
  952.                     Message = "Insert cancelled"
  953.                 End If
  954.                 AddRow = False
  955.             End If
  956.             If AddRow Then
  957.                 LastInsertId = Conn.GetLastInsertId()
  958.                 tblLPR.lprID.DbValue = LastInsertId
  959.                 Rs("lprID") = tblLPR.lprID.DbValue
  960.  
  961.                 ' Row Inserted event
  962.                 tblLPR.Row_Inserted(Rs)
  963.             End If
  964.         End Function
  965.  
  966.         ' Page Load event
  967.         Public Sub Page_Load()
  968.  
  969.             'HttpContext.Current.Response.Write("Page Load")
  970.         End Sub
  971.  
  972.         ' Page Unload event
  973.         Public Sub Page_Unload()
  974.  
  975.             'HttpContext.Current.Response.Write("Page Unload")
  976.         End Sub
  977.  
  978.     ' Form Custom Validate event
  979.     Public Function Form_CustomValidate(ByRef CustomError As String) As Boolean
  980.  
  981.         'Return error message in CustomError
  982.         Return True
  983.     End Function
  984.     End Class
  985.  
  986.     '
  987.     ' ASP.NET Page_Load event
  988.     '
  989.  
  990.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  991.         Response.Buffer = EW_RESPONSE_BUFFER
  992.         Response.Cache.SetCacheability(HttpCacheability.NoCache)
  993.  
  994.         ' Page init
  995.         tblLPR_add = New ctblLPR_add(Me)        
  996.         tblLPR_add.Page_Init()
  997.  
  998.         ' Page main processing
  999.         tblLPR_add.Page_Main()
  1000.     End Sub
  1001.  
  1002.     '
  1003.     ' ASP.NET Page_Unload event
  1004.     '
  1005.  
  1006.     Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
  1007.  
  1008.         ' Dispose page object
  1009.         If tblLPR_add IsNot Nothing Then tblLPR_add.Dispose()
  1010.     End Sub
  1011. End Class
  1012.