home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / tblFixtureMasteredit.aspx.vb < prev    next >
Text File  |  2010-08-24  |  23KB  |  727 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 tblFixtureMasteredit
  12.     Inherits AspNetMaker7_tfpssnet
  13.  
  14.     ' Page object
  15.     Public tblFixtureMaster_edit As ctblFixtureMaster_edit
  16.  
  17.     '
  18.     ' Page Class
  19.     '
  20.     Class ctblFixtureMaster_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 tblFixtureMaster.UseTokenInUrl Then Url = Url & "t=" & tblFixtureMaster.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 tblFixtureMaster.UseTokenInUrl Then
  44.                 Result = False
  45.                 If ObjForm IsNot Nothing Then
  46.                     Result = (tblFixtureMaster.TableVar = ObjForm.GetValue("t"))
  47.                 End If
  48.                 If ew_Get("t") <> "" Then
  49.                     Result = (tblFixtureMaster.TableVar = ew_Get("t"))
  50.                 End If
  51.                 Return Result
  52.             End If
  53.             Return True            
  54.         End Function    
  55.  
  56.         ' tblFixtureMaster
  57.         Public Property tblFixtureMaster() As ctblFixtureMaster
  58.             Get                
  59.                 Return ParentPage.tblFixtureMaster
  60.             End Get
  61.             Set(ByVal v As ctblFixtureMaster)
  62.                 ParentPage.tblFixtureMaster = v    
  63.             End Set    
  64.         End Property
  65.  
  66.         ' tblFixtureMaster
  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 = "tblFixtureMaster_edit"
  86.             m_PageObjTypeName = "ctblFixtureMaster_edit"
  87.  
  88.             ' Table Name
  89.             m_TableName = "tblFixtureMaster"
  90.  
  91.             ' Initialize table object
  92.             tblFixtureMaster = New ctblFixtureMaster(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("tblFixtureMasterlist.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.  
  132.             ' Global page loading event (in ewglobal*.vb)
  133.             ParentPage.Page_Loading()
  134.  
  135.             ' Page load event, used in current page
  136.             Page_Load()
  137.         End Sub
  138.  
  139.         '
  140.         '  Class terminate
  141.         '  - clean up page object
  142.         '
  143.         Public Sub Dispose() Implements IDisposable.Dispose
  144.             Page_Terminate("")
  145.         End Sub
  146.  
  147.         '
  148.         '  Sub Page_Terminate
  149.         '  - called when exit page
  150.         '  - clean up connection and objects
  151.         '  - if URL specified, redirect to URL
  152.         '
  153.         Sub Page_Terminate(url As String)
  154.  
  155.             ' Page unload event, used in current page
  156.             Page_Unload()
  157.  
  158.             ' Global page unloaded event (in ewglobal*.vb)
  159.             ParentPage.Page_Unloaded()
  160.  
  161.             ' Close connection
  162.             Conn.Dispose()
  163.             Security = Nothing
  164.             tblFixtureMaster.Dispose()
  165.             tblEmployees.Dispose()
  166.  
  167.             ' Go to URL if specified
  168.             If url <> "" Then
  169.                 HttpContext.Current.Response.Clear()
  170.                 HttpContext.Current.Response.Redirect(url)
  171.             End If
  172.         End Sub
  173.  
  174.     '
  175.     ' Page main processing
  176.     '
  177.     Sub Page_Main()
  178.  
  179.         ' Load key from QueryString
  180.         If ew_Get("lfxID") <> "" Then
  181.             tblFixtureMaster.lfxID.QueryStringValue = ew_Get("lfxID")
  182.         End If
  183.  
  184.         ' Create form object
  185.         ObjForm = New cFormObj
  186.         If ObjForm.GetValue("a_edit") <> "" Then
  187.             tblFixtureMaster.CurrentAction = ObjForm.GetValue("a_edit") ' Get action code
  188.             LoadFormValues() ' Get form values
  189.  
  190.             ' Validate Form
  191.             If Not ValidateForm() Then
  192.                 tblFixtureMaster.CurrentAction = "" ' Form error, reset action
  193.                 Message = ParentPage.gsFormError
  194.                 LoadRow() ' Restore row
  195.                 RestoreFormValues() ' Restore form values if validate failed
  196.             End If
  197.         Else
  198.             tblFixtureMaster.CurrentAction = "I" ' Default action is display
  199.         End If
  200.  
  201.         ' Check if valid key
  202.         If ew_Empty(tblFixtureMaster.lfxID.CurrentValue) Then Page_Terminate("tblFixtureMasterlist.aspx") ' Invalid key, return to list
  203.         Select Case tblFixtureMaster.CurrentAction
  204.             Case "I" ' Get a record to display
  205.                 If Not LoadRow() Then ' Load Record based on key
  206.                     Message = "No records found" ' No record found
  207.                     Page_Terminate("tblFixtureMasterlist.aspx") ' No matching record, return to list
  208.                 End If
  209.             Case "U" ' Update
  210.                 tblFixtureMaster.SendEmail = True ' Send email on update success
  211.                 If EditRow() Then ' Update Record based on key
  212.                     Message = "Update succeeded" ' Update success
  213.                     Dim sReturnUrl As String = tblFixtureMaster.ReturnUrl
  214.                     Page_Terminate(sReturnUrl) ' Return to caller
  215.                 Else
  216.                     LoadRow() ' Restore row
  217.                     RestoreFormValues() ' Restore form values if update failed
  218.                 End If
  219.         End Select
  220.  
  221.         ' Render the record
  222.         tblFixtureMaster.RowType = EW_ROWTYPE_EDIT ' Render as edit
  223.  
  224.         ' Render row
  225.         RenderRow()
  226.     End Sub
  227.  
  228.     '
  229.     ' Get upload file
  230.     '
  231.     Sub GetUploadFiles()
  232.  
  233.         ' Get upload data
  234.     End Sub
  235.  
  236.     '
  237.     ' Load default values
  238.     '
  239.     Sub LoadDefaultValues()
  240.     End Sub
  241.  
  242.     '
  243.     ' Load form values
  244.     '
  245.     Sub LoadFormValues()
  246.         tblFixtureMaster.lfxMFG.FormValue = ObjForm.GetValue("x_lfxMFG")
  247.         tblFixtureMaster.lfxMFG.OldValue = ObjForm.GetValue("o_lfxMFG")
  248.         tblFixtureMaster.lfxModelType.FormValue = ObjForm.GetValue("x_lfxModelType")
  249.         tblFixtureMaster.lfxModelType.OldValue = ObjForm.GetValue("o_lfxModelType")
  250.         tblFixtureMaster.lfxSerialNumber.FormValue = ObjForm.GetValue("x_lfxSerialNumber")
  251.         tblFixtureMaster.lfxSerialNumber.OldValue = ObjForm.GetValue("o_lfxSerialNumber")
  252.         tblFixtureMaster.lfxLamp.FormValue = ObjForm.GetValue("x_lfxLamp")
  253.         tblFixtureMaster.lfxLamp.OldValue = ObjForm.GetValue("o_lfxLamp")
  254.         tblFixtureMaster.lfxLocationID.FormValue = ObjForm.GetValue("x_lfxLocationID")
  255.         tblFixtureMaster.lfxLocationID.OldValue = ObjForm.GetValue("o_lfxLocationID")
  256.         tblFixtureMaster.lfxHangPos.FormValue = ObjForm.GetValue("x_lfxHangPos")
  257.         tblFixtureMaster.lfxHangPos.OldValue = ObjForm.GetValue("o_lfxHangPos")
  258.         tblFixtureMaster.lfxChannel.FormValue = ObjForm.GetValue("x_lfxChannel")
  259.         tblFixtureMaster.lfxChannel.OldValue = ObjForm.GetValue("o_lfxChannel")
  260.         tblFixtureMaster.lfxNotes.FormValue = ObjForm.GetValue("x_lfxNotes")
  261.         tblFixtureMaster.lfxNotes.OldValue = ObjForm.GetValue("o_lfxNotes")
  262.         tblFixtureMaster.lfxID.FormValue = ObjForm.GetValue("x_lfxID")
  263.     End Sub
  264.  
  265.     '
  266.     ' Restore form values
  267.     '
  268.     Sub RestoreFormValues()
  269.         tblFixtureMaster.lfxMFG.CurrentValue = tblFixtureMaster.lfxMFG.FormValue
  270.         tblFixtureMaster.lfxModelType.CurrentValue = tblFixtureMaster.lfxModelType.FormValue
  271.         tblFixtureMaster.lfxSerialNumber.CurrentValue = tblFixtureMaster.lfxSerialNumber.FormValue
  272.         tblFixtureMaster.lfxLamp.CurrentValue = tblFixtureMaster.lfxLamp.FormValue
  273.         tblFixtureMaster.lfxLocationID.CurrentValue = tblFixtureMaster.lfxLocationID.FormValue
  274.         tblFixtureMaster.lfxHangPos.CurrentValue = tblFixtureMaster.lfxHangPos.FormValue
  275.         tblFixtureMaster.lfxChannel.CurrentValue = tblFixtureMaster.lfxChannel.FormValue
  276.         tblFixtureMaster.lfxNotes.CurrentValue = tblFixtureMaster.lfxNotes.FormValue
  277.         tblFixtureMaster.lfxID.CurrentValue = tblFixtureMaster.lfxID.FormValue
  278.     End Sub
  279.  
  280.     '
  281.     ' Load row based on key values
  282.     '
  283.     Function LoadRow() As Boolean
  284.         Dim RsRow As OleDbDataReader
  285.         Dim sFilter As String = tblFixtureMaster.KeyFilter
  286.  
  287.         ' Row Selecting event
  288.         tblFixtureMaster.Row_Selecting(sFilter)
  289.  
  290.         ' Load SQL based on filter
  291.         tblFixtureMaster.CurrentFilter = sFilter
  292.         Dim sSql As String = tblFixtureMaster.SQL
  293.  
  294.         ' Write SQL for debug
  295.         If EW_DEBUG_ENABLED Then ew_Write(sSql)
  296.         Try
  297.             RsRow = Conn.GetTempDataReader(sSql)    
  298.             If Not RsRow.Read() Then
  299.                 Return False
  300.             Else                
  301.                 LoadRowValues(RsRow) ' Load row values
  302.  
  303.                 ' Row Selected event
  304.                 tblFixtureMaster.Row_Selected(RsRow)
  305.                 Return True    
  306.             End If
  307.         Catch
  308.             If EW_DEBUG_ENABLED Then Throw
  309.             Return False
  310.         Finally
  311.             Conn.CloseTempDataReader()
  312.         End Try
  313.     End Function
  314.  
  315.     '
  316.     ' Load row values from recordset
  317.     '
  318.     Sub LoadRowValues(ByRef RsRow As OleDbDataReader)
  319.         tblFixtureMaster.lfxID.DbValue = RsRow("lfxID")
  320.         tblFixtureMaster.lfxMFG.DbValue = RsRow("lfxMFG")
  321.         tblFixtureMaster.lfxModelType.DbValue = RsRow("lfxModelType")
  322.         tblFixtureMaster.lfxSerialNumber.DbValue = RsRow("lfxSerialNumber")
  323.         tblFixtureMaster.lfxLamp.DbValue = RsRow("lfxLamp")
  324.         tblFixtureMaster.lfxLocationID.DbValue = RsRow("lfxLocationID")
  325.         tblFixtureMaster.lfxHangPos.DbValue = RsRow("lfxHangPos")
  326.         tblFixtureMaster.lfxChannel.DbValue = RsRow("lfxChannel")
  327.         tblFixtureMaster.lfxNotes.DbValue = RsRow("lfxNotes")
  328.     End Sub
  329.  
  330.     '
  331.     ' Render row values based on field settings
  332.     '
  333.     Sub RenderRow()
  334.  
  335.         ' Row Rendering event
  336.         tblFixtureMaster.Row_Rendering()
  337.  
  338.         '
  339.         '  Common render codes for all row types
  340.         '
  341.         ' lfxMFG
  342.  
  343.         tblFixtureMaster.lfxMFG.CellCssStyle = ""
  344.         tblFixtureMaster.lfxMFG.CellCssClass = ""
  345.  
  346.         ' lfxModelType
  347.         tblFixtureMaster.lfxModelType.CellCssStyle = ""
  348.         tblFixtureMaster.lfxModelType.CellCssClass = ""
  349.  
  350.         ' lfxSerialNumber
  351.         tblFixtureMaster.lfxSerialNumber.CellCssStyle = ""
  352.         tblFixtureMaster.lfxSerialNumber.CellCssClass = ""
  353.  
  354.         ' lfxLamp
  355.         tblFixtureMaster.lfxLamp.CellCssStyle = ""
  356.         tblFixtureMaster.lfxLamp.CellCssClass = ""
  357.  
  358.         ' lfxLocationID
  359.         tblFixtureMaster.lfxLocationID.CellCssStyle = ""
  360.         tblFixtureMaster.lfxLocationID.CellCssClass = ""
  361.  
  362.         ' lfxHangPos
  363.         tblFixtureMaster.lfxHangPos.CellCssStyle = ""
  364.         tblFixtureMaster.lfxHangPos.CellCssClass = ""
  365.  
  366.         ' lfxChannel
  367.         tblFixtureMaster.lfxChannel.CellCssStyle = ""
  368.         tblFixtureMaster.lfxChannel.CellCssClass = ""
  369.  
  370.         ' lfxNotes
  371.         tblFixtureMaster.lfxNotes.CellCssStyle = ""
  372.         tblFixtureMaster.lfxNotes.CellCssClass = ""
  373.  
  374.         '
  375.         '  View  Row
  376.         '
  377.  
  378.         If tblFixtureMaster.RowType = EW_ROWTYPE_VIEW Then ' View row
  379.  
  380.             ' lfxMFG
  381.             tblFixtureMaster.lfxMFG.ViewValue = tblFixtureMaster.lfxMFG.CurrentValue
  382.             tblFixtureMaster.lfxMFG.CssStyle = ""
  383.             tblFixtureMaster.lfxMFG.CssClass = ""
  384.             tblFixtureMaster.lfxMFG.ViewCustomAttributes = ""
  385.  
  386.             ' lfxModelType
  387.             tblFixtureMaster.lfxModelType.ViewValue = tblFixtureMaster.lfxModelType.CurrentValue
  388.             tblFixtureMaster.lfxModelType.CssStyle = ""
  389.             tblFixtureMaster.lfxModelType.CssClass = ""
  390.             tblFixtureMaster.lfxModelType.ViewCustomAttributes = ""
  391.  
  392.             ' lfxSerialNumber
  393.             tblFixtureMaster.lfxSerialNumber.ViewValue = tblFixtureMaster.lfxSerialNumber.CurrentValue
  394.             tblFixtureMaster.lfxSerialNumber.CssStyle = ""
  395.             tblFixtureMaster.lfxSerialNumber.CssClass = ""
  396.             tblFixtureMaster.lfxSerialNumber.ViewCustomAttributes = ""
  397.  
  398.             ' lfxLamp
  399.             tblFixtureMaster.lfxLamp.ViewValue = tblFixtureMaster.lfxLamp.CurrentValue
  400.             tblFixtureMaster.lfxLamp.CssStyle = ""
  401.             tblFixtureMaster.lfxLamp.CssClass = ""
  402.             tblFixtureMaster.lfxLamp.ViewCustomAttributes = ""
  403.  
  404.             ' lfxLocationID
  405.             If ew_NotEmpty(tblFixtureMaster.lfxLocationID.CurrentValue) Then
  406.                 sSqlWrk = "SELECT [locDescription] FROM [tblLocations] WHERE [locID] = " & ew_AdjustSql(tblFixtureMaster.lfxLocationID.CurrentValue) & ""
  407.                 sSqlWrk = sSqlWrk & " AND (" & "[locLighting]=True" & ")"
  408.                 sSqlWrk = sSqlWrk & " ORDER BY [locDescription] "
  409.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  410.                 If RsWrk.Read() Then
  411.                     tblFixtureMaster.lfxLocationID.ViewValue = RsWrk("locDescription")
  412.                 Else
  413.                     tblFixtureMaster.lfxLocationID.ViewValue = tblFixtureMaster.lfxLocationID.CurrentValue
  414.                 End If
  415.                 Conn.CloseTempDataReader()
  416.             Else
  417.                 tblFixtureMaster.lfxLocationID.ViewValue = System.DBNull.Value
  418.             End If
  419.             tblFixtureMaster.lfxLocationID.CssStyle = ""
  420.             tblFixtureMaster.lfxLocationID.CssClass = ""
  421.             tblFixtureMaster.lfxLocationID.ViewCustomAttributes = ""
  422.  
  423.             ' lfxHangPos
  424.             tblFixtureMaster.lfxHangPos.ViewValue = tblFixtureMaster.lfxHangPos.CurrentValue
  425.             tblFixtureMaster.lfxHangPos.CssStyle = ""
  426.             tblFixtureMaster.lfxHangPos.CssClass = ""
  427.             tblFixtureMaster.lfxHangPos.ViewCustomAttributes = ""
  428.  
  429.             ' lfxChannel
  430.             tblFixtureMaster.lfxChannel.ViewValue = tblFixtureMaster.lfxChannel.CurrentValue
  431.             tblFixtureMaster.lfxChannel.CssStyle = ""
  432.             tblFixtureMaster.lfxChannel.CssClass = ""
  433.             tblFixtureMaster.lfxChannel.ViewCustomAttributes = ""
  434.  
  435.             ' lfxNotes
  436.             tblFixtureMaster.lfxNotes.ViewValue = tblFixtureMaster.lfxNotes.CurrentValue
  437.             tblFixtureMaster.lfxNotes.CssStyle = ""
  438.             tblFixtureMaster.lfxNotes.CssClass = ""
  439.             tblFixtureMaster.lfxNotes.ViewCustomAttributes = ""
  440.  
  441.             ' View refer script
  442.             ' lfxMFG
  443.  
  444.             tblFixtureMaster.lfxMFG.HrefValue = ""
  445.  
  446.             ' lfxModelType
  447.             tblFixtureMaster.lfxModelType.HrefValue = ""
  448.  
  449.             ' lfxSerialNumber
  450.             tblFixtureMaster.lfxSerialNumber.HrefValue = ""
  451.  
  452.             ' lfxLamp
  453.             tblFixtureMaster.lfxLamp.HrefValue = ""
  454.  
  455.             ' lfxLocationID
  456.             tblFixtureMaster.lfxLocationID.HrefValue = ""
  457.  
  458.             ' lfxHangPos
  459.             tblFixtureMaster.lfxHangPos.HrefValue = ""
  460.  
  461.             ' lfxChannel
  462.             tblFixtureMaster.lfxChannel.HrefValue = ""
  463.  
  464.             ' lfxNotes
  465.             tblFixtureMaster.lfxNotes.HrefValue = ""
  466.  
  467.         '
  468.         '  Edit Row
  469.         '
  470.  
  471.         ElseIf tblFixtureMaster.RowType = EW_ROWTYPE_EDIT Then ' Edit row
  472.  
  473.             ' lfxMFG
  474.             tblFixtureMaster.lfxMFG.EditCustomAttributes = ""
  475.             tblFixtureMaster.lfxMFG.EditValue = ew_HtmlEncode(tblFixtureMaster.lfxMFG.CurrentValue)
  476.  
  477.             ' lfxModelType
  478.             tblFixtureMaster.lfxModelType.EditCustomAttributes = ""
  479.             tblFixtureMaster.lfxModelType.EditValue = ew_HtmlEncode(tblFixtureMaster.lfxModelType.CurrentValue)
  480.  
  481.             ' lfxSerialNumber
  482.             tblFixtureMaster.lfxSerialNumber.EditCustomAttributes = ""
  483.             tblFixtureMaster.lfxSerialNumber.EditValue = ew_HtmlEncode(tblFixtureMaster.lfxSerialNumber.CurrentValue)
  484.  
  485.             ' lfxLamp
  486.             tblFixtureMaster.lfxLamp.EditCustomAttributes = ""
  487.             tblFixtureMaster.lfxLamp.EditValue = ew_HtmlEncode(tblFixtureMaster.lfxLamp.CurrentValue)
  488.  
  489.             ' lfxLocationID
  490.             tblFixtureMaster.lfxLocationID.EditCustomAttributes = ""
  491.             sSqlWrk = "SELECT [locID], [locDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblLocations]"
  492.             sWhereWrk = ""
  493.             If sWhereWrk <> "" Then sWhereWrk = "(" & sWhereWrk & ") AND "
  494.             sWhereWrk = sWhereWrk & "(" & "[locLighting]=True" & ")"
  495.             If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  496.             sSqlWrk = sSqlWrk & " ORDER BY [locDescription] "
  497.             arwrk = Conn.GetRows(sSqlWrk)
  498.             arwrk.Insert(0, New Object(){"", "Please Select"}) 
  499.             tblFixtureMaster.lfxLocationID.EditValue = arwrk
  500.  
  501.             ' lfxHangPos
  502.             tblFixtureMaster.lfxHangPos.EditCustomAttributes = ""
  503.             tblFixtureMaster.lfxHangPos.EditValue = ew_HtmlEncode(tblFixtureMaster.lfxHangPos.CurrentValue)
  504.  
  505.             ' lfxChannel
  506.             tblFixtureMaster.lfxChannel.EditCustomAttributes = ""
  507.             tblFixtureMaster.lfxChannel.EditValue = ew_HtmlEncode(tblFixtureMaster.lfxChannel.CurrentValue)
  508.  
  509.             ' lfxNotes
  510.             tblFixtureMaster.lfxNotes.EditCustomAttributes = ""
  511.             tblFixtureMaster.lfxNotes.EditValue = ew_HtmlEncode(tblFixtureMaster.lfxNotes.CurrentValue)
  512.  
  513.             ' Edit refer script
  514.             ' lfxMFG
  515.  
  516.             tblFixtureMaster.lfxMFG.HrefValue = ""
  517.  
  518.             ' lfxModelType
  519.             tblFixtureMaster.lfxModelType.HrefValue = ""
  520.  
  521.             ' lfxSerialNumber
  522.             tblFixtureMaster.lfxSerialNumber.HrefValue = ""
  523.  
  524.             ' lfxLamp
  525.             tblFixtureMaster.lfxLamp.HrefValue = ""
  526.  
  527.             ' lfxLocationID
  528.             tblFixtureMaster.lfxLocationID.HrefValue = ""
  529.  
  530.             ' lfxHangPos
  531.             tblFixtureMaster.lfxHangPos.HrefValue = ""
  532.  
  533.             ' lfxChannel
  534.             tblFixtureMaster.lfxChannel.HrefValue = ""
  535.  
  536.             ' lfxNotes
  537.             tblFixtureMaster.lfxNotes.HrefValue = ""
  538.         End If
  539.  
  540.         ' Row Rendered event
  541.         tblFixtureMaster.Row_Rendered()
  542.     End Sub
  543.  
  544.     '
  545.     ' Validate form
  546.     '
  547.     Function ValidateForm() As Boolean
  548.  
  549.         ' Initialize
  550.         ParentPage.gsFormError = ""
  551.  
  552.         ' Check if validation required
  553.         If Not EW_SERVER_VALIDATE Then Return (ParentPage.gsFormError = "")
  554.         If ew_Empty(tblFixtureMaster.lfxMFG.FormValue) Then
  555.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  556.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Manufacturer"
  557.         End If
  558.         If ew_Empty(tblFixtureMaster.lfxModelType.FormValue) Then
  559.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  560.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Model / Type"
  561.         End If
  562.         If ew_Empty(tblFixtureMaster.lfxLocationID.FormValue) Then
  563.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  564.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Location"
  565.         End If
  566.         If ew_Empty(tblFixtureMaster.lfxHangPos.FormValue) Then
  567.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  568.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Hang Pos"
  569.         End If
  570.         If ew_Empty(tblFixtureMaster.lfxChannel.FormValue) Then
  571.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  572.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Channel"
  573.         End If
  574.         If Not ew_CheckInteger(tblFixtureMaster.lfxChannel.FormValue) Then
  575.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  576.             ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect integer - Channel"
  577.         End If
  578.  
  579.         ' Return validate result
  580.         Dim Valid As Boolean = (ParentPage.gsFormError = "")
  581.  
  582.         ' Form_CustomValidate event
  583.         Dim sFormCustomError As String = ""
  584.         Valid = Valid And Form_CustomValidate(sFormCustomError)
  585.         If sFormCustomError <> "" Then
  586.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  587.             ParentPage.gsFormError = ParentPage.gsFormError & sFormCustomError
  588.         End If
  589.         Return Valid
  590.     End Function
  591.  
  592.     '
  593.     ' Update record based on key values
  594.     '
  595.     Function EditRow() As Boolean
  596.         Dim RsEdit As OleDbDataReader, RsChk As OleDbDataReader
  597.         Dim sSql As String, sFilter As String
  598.         Dim sSqlChk As String, sFilterChk As String
  599.         Dim bUpdateRow As Boolean
  600.         Dim RsOld As OrderedDictionary
  601.         Dim sIdxErrMsg As String
  602.         Dim Rs As New OrderedDictionary
  603.         sFilter = tblFixtureMaster.KeyFilter
  604.         tblFixtureMaster.CurrentFilter  = sFilter
  605.         sSql = tblFixtureMaster.SQL
  606.         Try
  607.             RsEdit = Conn.GetDataReader(sSql) 
  608.         Catch e As Exception
  609.             If EW_DEBUG_ENABLED Then Throw
  610.             Message = e.Message
  611.             RsEdit.Close()
  612.             EditRow = False
  613.         End Try
  614.         If Not RsEdit.Read() Then
  615.             RsEdit.Close()
  616.             EditRow = False ' Update Failed
  617.         Else
  618.             RsOld = Conn.GetRow(RsEdit)
  619.             RsEdit.Close()
  620.  
  621.             ' lfxMFG
  622.             tblFixtureMaster.lfxMFG.SetDbValue(tblFixtureMaster.lfxMFG.CurrentValue, System.DBNull.Value)
  623.             Rs("lfxMFG") = tblFixtureMaster.lfxMFG.DbValue
  624.  
  625.             ' lfxModelType
  626.             tblFixtureMaster.lfxModelType.SetDbValue(tblFixtureMaster.lfxModelType.CurrentValue, System.DBNull.Value)
  627.             Rs("lfxModelType") = tblFixtureMaster.lfxModelType.DbValue
  628.  
  629.             ' lfxSerialNumber
  630.             tblFixtureMaster.lfxSerialNumber.SetDbValue(tblFixtureMaster.lfxSerialNumber.CurrentValue, System.DBNull.Value)
  631.             Rs("lfxSerialNumber") = tblFixtureMaster.lfxSerialNumber.DbValue
  632.  
  633.             ' lfxLamp
  634.             tblFixtureMaster.lfxLamp.SetDbValue(tblFixtureMaster.lfxLamp.CurrentValue, System.DBNull.Value)
  635.             Rs("lfxLamp") = tblFixtureMaster.lfxLamp.DbValue
  636.  
  637.             ' lfxLocationID
  638.             tblFixtureMaster.lfxLocationID.SetDbValue(tblFixtureMaster.lfxLocationID.CurrentValue, System.DBNull.Value)
  639.             Rs("lfxLocationID") = tblFixtureMaster.lfxLocationID.DbValue
  640.  
  641.             ' lfxHangPos
  642.             tblFixtureMaster.lfxHangPos.SetDbValue(tblFixtureMaster.lfxHangPos.CurrentValue, System.DBNull.Value)
  643.             Rs("lfxHangPos") = tblFixtureMaster.lfxHangPos.DbValue
  644.  
  645.             ' lfxChannel
  646.             tblFixtureMaster.lfxChannel.SetDbValue(tblFixtureMaster.lfxChannel.CurrentValue, System.DBNull.Value)
  647.             Rs("lfxChannel") = tblFixtureMaster.lfxChannel.DbValue
  648.  
  649.             ' lfxNotes
  650.             tblFixtureMaster.lfxNotes.SetDbValue(tblFixtureMaster.lfxNotes.CurrentValue, System.DBNull.Value)
  651.             Rs("lfxNotes") = tblFixtureMaster.lfxNotes.DbValue
  652.  
  653.             ' Row Updating event
  654.             bUpdateRow = tblFixtureMaster.Row_Updating(RsOld, Rs)
  655.             If bUpdateRow Then
  656.                 Try
  657.                     tblFixtureMaster.Update(Rs)
  658.                     EditRow = True
  659.                 Catch e As Exception
  660.                     If EW_DEBUG_ENABLED Then Throw
  661.                     Message = e.Message
  662.                     EditRow = False
  663.                 End Try
  664.             Else
  665.                 If tblFixtureMaster.CancelMessage <> "" Then
  666.                     Message = tblFixtureMaster.CancelMessage
  667.                     tblFixtureMaster.CancelMessage = ""
  668.                 Else
  669.                     Message = "Update cancelled"
  670.                 End If
  671.                 EditRow = False
  672.             End If
  673.         End If
  674.  
  675.         ' Row Updated event
  676.         If EditRow Then
  677.             tblFixtureMaster.Row_Updated(RsOld, Rs)
  678.         End If
  679.     End Function
  680.  
  681.         ' Page Load event
  682.         Public Sub Page_Load()
  683.  
  684.             'HttpContext.Current.Response.Write("Page Load")
  685.         End Sub
  686.  
  687.         ' Page Unload event
  688.         Public Sub Page_Unload()
  689.  
  690.             'HttpContext.Current.Response.Write("Page Unload")
  691.         End Sub
  692.  
  693.     ' Form Custom Validate event
  694.     Public Function Form_CustomValidate(ByRef CustomError As String) As Boolean
  695.  
  696.         'Return error message in CustomError
  697.         Return True
  698.     End Function
  699.     End Class
  700.  
  701.     '
  702.     ' ASP.NET Page_Load event
  703.     '
  704.  
  705.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  706.         Response.Buffer = EW_RESPONSE_BUFFER
  707.         Response.Cache.SetCacheability(HttpCacheability.NoCache)
  708.  
  709.         ' Page init
  710.         tblFixtureMaster_edit = New ctblFixtureMaster_edit(Me)        
  711.         tblFixtureMaster_edit.Page_Init()
  712.  
  713.         ' Page main processing
  714.         tblFixtureMaster_edit.Page_Main()
  715.     End Sub
  716.  
  717.     '
  718.     ' ASP.NET Page_Unload event
  719.     '
  720.  
  721.     Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
  722.  
  723.         ' Dispose page object
  724.         If tblFixtureMaster_edit IsNot Nothing Then tblFixtureMaster_edit.Dispose()
  725.     End Sub
  726. End Class
  727.