home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / ltgFixtureMasteredit.aspx.vb < prev    next >
Text File  |  2014-01-25  |  30KB  |  895 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 ltgFixtureMasteredit
  12.     Inherits AspNetMaker7_tfpssnet
  13.  
  14.     ' Page object
  15.     Public ltgFixtureMaster_edit As cltgFixtureMaster_edit
  16.  
  17.     '
  18.     ' Page Class
  19.     '
  20.     Class cltgFixtureMaster_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 ltgFixtureMaster.UseTokenInUrl Then Url = Url & "t=" & ltgFixtureMaster.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 ltgFixtureMaster.UseTokenInUrl Then
  44.                 Result = False
  45.                 If ObjForm IsNot Nothing Then
  46.                     Result = (ltgFixtureMaster.TableVar = ObjForm.GetValue("t"))
  47.                 End If
  48.                 If ew_Get("t") <> "" Then
  49.                     Result = (ltgFixtureMaster.TableVar = ew_Get("t"))
  50.                 End If
  51.                 Return Result
  52.             End If
  53.             Return True            
  54.         End Function    
  55.  
  56.         ' ltgFixtureMaster
  57.         Public Property ltgFixtureMaster() As cltgFixtureMaster
  58.             Get                
  59.                 Return ParentPage.ltgFixtureMaster
  60.             End Get
  61.             Set(ByVal v As cltgFixtureMaster)
  62.                 ParentPage.ltgFixtureMaster = v    
  63.             End Set    
  64.         End Property
  65.  
  66.         ' ltgFixtureMaster
  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 = "ltgFixtureMaster_edit"
  86.             m_PageObjTypeName = "cltgFixtureMaster_edit"
  87.  
  88.             ' Table Name
  89.             m_TableName = "ltgFixtureMaster"
  90.  
  91.             ' Initialize table object
  92.             ltgFixtureMaster = New cltgFixtureMaster(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("ltgFixtureMasterlist.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.             ltgFixtureMaster.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.             ltgFixtureMaster.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.             ltgFixtureMaster.CurrentAction = ObjForm.GetValue("a_edit") ' Get action code
  188.             LoadFormValues() ' Get form values
  189.  
  190.             ' Validate Form
  191.             If Not ValidateForm() Then
  192.                 ltgFixtureMaster.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.             ltgFixtureMaster.CurrentAction = "I" ' Default action is display
  199.         End If
  200.  
  201.         ' Check if valid key
  202.         If ew_Empty(ltgFixtureMaster.lfxID.CurrentValue) Then Page_Terminate("ltgFixtureMasterlist.aspx") ' Invalid key, return to list
  203.         Select Case ltgFixtureMaster.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("ltgFixtureMasterlist.aspx") ' No matching record, return to list
  208.                 End If
  209.             Case "U" ' Update
  210.                 ltgFixtureMaster.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 = ltgFixtureMaster.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.         ltgFixtureMaster.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.         ltgFixtureMaster.lfxCode.FormValue = ObjForm.GetValue("x_lfxCode")
  247.         ltgFixtureMaster.lfxCode.OldValue = ObjForm.GetValue("o_lfxCode")
  248.         ltgFixtureMaster.lfxDescription.FormValue = ObjForm.GetValue("x_lfxDescription")
  249.         ltgFixtureMaster.lfxDescription.OldValue = ObjForm.GetValue("o_lfxDescription")
  250.         ltgFixtureMaster.lfxMFG.FormValue = ObjForm.GetValue("x_lfxMFG")
  251.         ltgFixtureMaster.lfxMFG.OldValue = ObjForm.GetValue("o_lfxMFG")
  252.         ltgFixtureMaster.lfxModel.FormValue = ObjForm.GetValue("x_lfxModel")
  253.         ltgFixtureMaster.lfxModel.OldValue = ObjForm.GetValue("o_lfxModel")
  254.         ltgFixtureMaster.lfxSerialNumber.FormValue = ObjForm.GetValue("x_lfxSerialNumber")
  255.         ltgFixtureMaster.lfxSerialNumber.OldValue = ObjForm.GetValue("o_lfxSerialNumber")
  256.         ltgFixtureMaster.lfxLamp.FormValue = ObjForm.GetValue("x_lfxLamp")
  257.         ltgFixtureMaster.lfxLamp.OldValue = ObjForm.GetValue("o_lfxLamp")
  258.         ltgFixtureMaster.lfxFixtureTypeID.FormValue = ObjForm.GetValue("x_lfxFixtureTypeID")
  259.         ltgFixtureMaster.lfxFixtureTypeID.OldValue = ObjForm.GetValue("o_lfxFixtureTypeID")
  260.         ltgFixtureMaster.lfxLocationID.FormValue = ObjForm.GetValue("x_lfxLocationID")
  261.         ltgFixtureMaster.lfxLocationID.OldValue = ObjForm.GetValue("o_lfxLocationID")
  262.         ltgFixtureMaster.lfxChannel.FormValue = ObjForm.GetValue("x_lfxChannel")
  263.         ltgFixtureMaster.lfxChannel.OldValue = ObjForm.GetValue("o_lfxChannel")
  264.         ltgFixtureMaster.lfxIsActive.FormValue = ObjForm.GetValue("x_lfxIsActive")
  265.         ltgFixtureMaster.lfxIsActive.OldValue = ObjForm.GetValue("o_lfxIsActive")
  266.         ltgFixtureMaster.lfxCreatedBy.FormValue = ObjForm.GetValue("x_lfxCreatedBy")
  267.         ltgFixtureMaster.lfxCreatedBy.OldValue = ObjForm.GetValue("o_lfxCreatedBy")
  268.         ltgFixtureMaster.lfxCreatedOn.FormValue = ObjForm.GetValue("x_lfxCreatedOn")
  269.         ltgFixtureMaster.lfxCreatedOn.CurrentValue = ew_UnFormatDateTime(ltgFixtureMaster.lfxCreatedOn.CurrentValue, 6)
  270.         ltgFixtureMaster.lfxCreatedOn.OldValue = ObjForm.GetValue("o_lfxCreatedOn")
  271.         ltgFixtureMaster.lfxModifiedBy.FormValue = ObjForm.GetValue("x_lfxModifiedBy")
  272.         ltgFixtureMaster.lfxModifiedBy.OldValue = ObjForm.GetValue("o_lfxModifiedBy")
  273.         ltgFixtureMaster.lfxModifiedOn.FormValue = ObjForm.GetValue("x_lfxModifiedOn")
  274.         ltgFixtureMaster.lfxModifiedOn.CurrentValue = ew_UnFormatDateTime(ltgFixtureMaster.lfxModifiedOn.CurrentValue, 6)
  275.         ltgFixtureMaster.lfxModifiedOn.OldValue = ObjForm.GetValue("o_lfxModifiedOn")
  276.         ltgFixtureMaster.lfxID.FormValue = ObjForm.GetValue("x_lfxID")
  277.     End Sub
  278.  
  279.     '
  280.     ' Restore form values
  281.     '
  282.     Sub RestoreFormValues()
  283.         ltgFixtureMaster.lfxCode.CurrentValue = ltgFixtureMaster.lfxCode.FormValue
  284.         ltgFixtureMaster.lfxDescription.CurrentValue = ltgFixtureMaster.lfxDescription.FormValue
  285.         ltgFixtureMaster.lfxMFG.CurrentValue = ltgFixtureMaster.lfxMFG.FormValue
  286.         ltgFixtureMaster.lfxModel.CurrentValue = ltgFixtureMaster.lfxModel.FormValue
  287.         ltgFixtureMaster.lfxSerialNumber.CurrentValue = ltgFixtureMaster.lfxSerialNumber.FormValue
  288.         ltgFixtureMaster.lfxLamp.CurrentValue = ltgFixtureMaster.lfxLamp.FormValue
  289.         ltgFixtureMaster.lfxFixtureTypeID.CurrentValue = ltgFixtureMaster.lfxFixtureTypeID.FormValue
  290.         ltgFixtureMaster.lfxLocationID.CurrentValue = ltgFixtureMaster.lfxLocationID.FormValue
  291.         ltgFixtureMaster.lfxChannel.CurrentValue = ltgFixtureMaster.lfxChannel.FormValue
  292.         ltgFixtureMaster.lfxIsActive.CurrentValue = ltgFixtureMaster.lfxIsActive.FormValue
  293.         ltgFixtureMaster.lfxCreatedBy.CurrentValue = ltgFixtureMaster.lfxCreatedBy.FormValue
  294.         ltgFixtureMaster.lfxCreatedOn.CurrentValue = ltgFixtureMaster.lfxCreatedOn.FormValue
  295.         ltgFixtureMaster.lfxCreatedOn.CurrentValue = ew_UnFormatDateTime(ltgFixtureMaster.lfxCreatedOn.CurrentValue, 6)
  296.         ltgFixtureMaster.lfxModifiedBy.CurrentValue = ltgFixtureMaster.lfxModifiedBy.FormValue
  297.         ltgFixtureMaster.lfxModifiedOn.CurrentValue = ltgFixtureMaster.lfxModifiedOn.FormValue
  298.         ltgFixtureMaster.lfxModifiedOn.CurrentValue = ew_UnFormatDateTime(ltgFixtureMaster.lfxModifiedOn.CurrentValue, 6)
  299.         ltgFixtureMaster.lfxID.CurrentValue = ltgFixtureMaster.lfxID.FormValue
  300.     End Sub
  301.  
  302.     '
  303.     ' Load row based on key values
  304.     '
  305.     Function LoadRow() As Boolean
  306.         Dim RsRow As OleDbDataReader
  307.         Dim sFilter As String = ltgFixtureMaster.KeyFilter
  308.  
  309.         ' Row Selecting event
  310.         ltgFixtureMaster.Row_Selecting(sFilter)
  311.  
  312.         ' Load SQL based on filter
  313.         ltgFixtureMaster.CurrentFilter = sFilter
  314.         Dim sSql As String = ltgFixtureMaster.SQL
  315.  
  316.         ' Write SQL for debug
  317.         If EW_DEBUG_ENABLED Then ew_Write(sSql)
  318.         Try
  319.             RsRow = Conn.GetTempDataReader(sSql)    
  320.             If Not RsRow.Read() Then
  321.                 Return False
  322.             Else                
  323.                 LoadRowValues(RsRow) ' Load row values
  324.  
  325.                 ' Row Selected event
  326.                 ltgFixtureMaster.Row_Selected(RsRow)
  327.                 Return True    
  328.             End If
  329.         Catch
  330.             If EW_DEBUG_ENABLED Then Throw
  331.             Return False
  332.         Finally
  333.             Conn.CloseTempDataReader()
  334.         End Try
  335.     End Function
  336.  
  337.     '
  338.     ' Load row values from recordset
  339.     '
  340.     Sub LoadRowValues(ByRef RsRow As OleDbDataReader)
  341.         ltgFixtureMaster.lfxID.DbValue = RsRow("lfxID")
  342.         ltgFixtureMaster.lfxCode.DbValue = RsRow("lfxCode")
  343.         ltgFixtureMaster.lfxDescription.DbValue = RsRow("lfxDescription")
  344.         ltgFixtureMaster.lfxMFG.DbValue = RsRow("lfxMFG")
  345.         ltgFixtureMaster.lfxModel.DbValue = RsRow("lfxModel")
  346.         ltgFixtureMaster.lfxSerialNumber.DbValue = RsRow("lfxSerialNumber")
  347.         ltgFixtureMaster.lfxLamp.DbValue = RsRow("lfxLamp")
  348.         ltgFixtureMaster.lfxFixtureTypeID.DbValue = RsRow("lfxFixtureTypeID")
  349.         ltgFixtureMaster.lfxLocationID.DbValue = RsRow("lfxLocationID")
  350.         ltgFixtureMaster.lfxChannel.DbValue = RsRow("lfxChannel")
  351.         ltgFixtureMaster.lfxIsActive.DbValue = IIf(ew_ConvertToBool(RsRow("lfxIsActive")), "1", "0")
  352.         ltgFixtureMaster.lfxCreatedBy.DbValue = RsRow("lfxCreatedBy")
  353.         ltgFixtureMaster.lfxCreatedOn.DbValue = RsRow("lfxCreatedOn")
  354.         ltgFixtureMaster.lfxModifiedBy.DbValue = RsRow("lfxModifiedBy")
  355.         ltgFixtureMaster.lfxModifiedOn.DbValue = RsRow("lfxModifiedOn")
  356.     End Sub
  357.  
  358.     '
  359.     ' Render row values based on field settings
  360.     '
  361.     Sub RenderRow()
  362.  
  363.         ' Row Rendering event
  364.         ltgFixtureMaster.Row_Rendering()
  365.  
  366.         '
  367.         '  Common render codes for all row types
  368.         '
  369.         ' lfxCode
  370.  
  371.         ltgFixtureMaster.lfxCode.CellCssStyle = ""
  372.         ltgFixtureMaster.lfxCode.CellCssClass = ""
  373.  
  374.         ' lfxDescription
  375.         ltgFixtureMaster.lfxDescription.CellCssStyle = ""
  376.         ltgFixtureMaster.lfxDescription.CellCssClass = ""
  377.  
  378.         ' lfxMFG
  379.         ltgFixtureMaster.lfxMFG.CellCssStyle = ""
  380.         ltgFixtureMaster.lfxMFG.CellCssClass = ""
  381.  
  382.         ' lfxModel
  383.         ltgFixtureMaster.lfxModel.CellCssStyle = ""
  384.         ltgFixtureMaster.lfxModel.CellCssClass = ""
  385.  
  386.         ' lfxSerialNumber
  387.         ltgFixtureMaster.lfxSerialNumber.CellCssStyle = ""
  388.         ltgFixtureMaster.lfxSerialNumber.CellCssClass = ""
  389.  
  390.         ' lfxLamp
  391.         ltgFixtureMaster.lfxLamp.CellCssStyle = ""
  392.         ltgFixtureMaster.lfxLamp.CellCssClass = ""
  393.  
  394.         ' lfxFixtureTypeID
  395.         ltgFixtureMaster.lfxFixtureTypeID.CellCssStyle = ""
  396.         ltgFixtureMaster.lfxFixtureTypeID.CellCssClass = ""
  397.  
  398.         ' lfxLocationID
  399.         ltgFixtureMaster.lfxLocationID.CellCssStyle = ""
  400.         ltgFixtureMaster.lfxLocationID.CellCssClass = ""
  401.  
  402.         ' lfxChannel
  403.         ltgFixtureMaster.lfxChannel.CellCssStyle = ""
  404.         ltgFixtureMaster.lfxChannel.CellCssClass = ""
  405.  
  406.         ' lfxIsActive
  407.         ltgFixtureMaster.lfxIsActive.CellCssStyle = ""
  408.         ltgFixtureMaster.lfxIsActive.CellCssClass = ""
  409.  
  410.         ' lfxCreatedBy
  411.         ltgFixtureMaster.lfxCreatedBy.CellCssStyle = ""
  412.         ltgFixtureMaster.lfxCreatedBy.CellCssClass = ""
  413.  
  414.         ' lfxCreatedOn
  415.         ltgFixtureMaster.lfxCreatedOn.CellCssStyle = ""
  416.         ltgFixtureMaster.lfxCreatedOn.CellCssClass = ""
  417.  
  418.         ' lfxModifiedBy
  419.         ltgFixtureMaster.lfxModifiedBy.CellCssStyle = ""
  420.         ltgFixtureMaster.lfxModifiedBy.CellCssClass = ""
  421.  
  422.         ' lfxModifiedOn
  423.         ltgFixtureMaster.lfxModifiedOn.CellCssStyle = ""
  424.         ltgFixtureMaster.lfxModifiedOn.CellCssClass = ""
  425.  
  426.         '
  427.         '  View  Row
  428.         '
  429.  
  430.         If ltgFixtureMaster.RowType = EW_ROWTYPE_VIEW Then ' View row
  431.  
  432.             ' lfxID
  433.             ltgFixtureMaster.lfxID.ViewValue = ltgFixtureMaster.lfxID.CurrentValue
  434.             ltgFixtureMaster.lfxID.CssStyle = ""
  435.             ltgFixtureMaster.lfxID.CssClass = ""
  436.             ltgFixtureMaster.lfxID.ViewCustomAttributes = ""
  437.  
  438.             ' lfxCode
  439.             ltgFixtureMaster.lfxCode.ViewValue = ltgFixtureMaster.lfxCode.CurrentValue
  440.             ltgFixtureMaster.lfxCode.CssStyle = ""
  441.             ltgFixtureMaster.lfxCode.CssClass = ""
  442.             ltgFixtureMaster.lfxCode.ViewCustomAttributes = ""
  443.  
  444.             ' lfxDescription
  445.             ltgFixtureMaster.lfxDescription.ViewValue = ltgFixtureMaster.lfxDescription.CurrentValue
  446.             ltgFixtureMaster.lfxDescription.CssStyle = ""
  447.             ltgFixtureMaster.lfxDescription.CssClass = ""
  448.             ltgFixtureMaster.lfxDescription.ViewCustomAttributes = ""
  449.  
  450.             ' lfxMFG
  451.             ltgFixtureMaster.lfxMFG.ViewValue = ltgFixtureMaster.lfxMFG.CurrentValue
  452.             ltgFixtureMaster.lfxMFG.CssStyle = ""
  453.             ltgFixtureMaster.lfxMFG.CssClass = ""
  454.             ltgFixtureMaster.lfxMFG.ViewCustomAttributes = ""
  455.  
  456.             ' lfxModel
  457.             ltgFixtureMaster.lfxModel.ViewValue = ltgFixtureMaster.lfxModel.CurrentValue
  458.             ltgFixtureMaster.lfxModel.CssStyle = ""
  459.             ltgFixtureMaster.lfxModel.CssClass = ""
  460.             ltgFixtureMaster.lfxModel.ViewCustomAttributes = ""
  461.  
  462.             ' lfxSerialNumber
  463.             ltgFixtureMaster.lfxSerialNumber.ViewValue = ltgFixtureMaster.lfxSerialNumber.CurrentValue
  464.             ltgFixtureMaster.lfxSerialNumber.CssStyle = ""
  465.             ltgFixtureMaster.lfxSerialNumber.CssClass = ""
  466.             ltgFixtureMaster.lfxSerialNumber.ViewCustomAttributes = ""
  467.  
  468.             ' lfxLamp
  469.             ltgFixtureMaster.lfxLamp.ViewValue = ltgFixtureMaster.lfxLamp.CurrentValue
  470.             ltgFixtureMaster.lfxLamp.CssStyle = ""
  471.             ltgFixtureMaster.lfxLamp.CssClass = ""
  472.             ltgFixtureMaster.lfxLamp.ViewCustomAttributes = ""
  473.  
  474.             ' lfxFixtureTypeID
  475.             If ew_NotEmpty(ltgFixtureMaster.lfxFixtureTypeID.CurrentValue) Then
  476.                 sSqlWrk = "SELECT [ftyDescription] FROM [ltgFixtureType] WHERE [ftyID] = " & ew_AdjustSql(ltgFixtureMaster.lfxFixtureTypeID.CurrentValue) & ""
  477.                 sSqlWrk = sSqlWrk & " AND (" & "[ftyIsActive] = True" & ")"
  478.                 sSqlWrk = sSqlWrk & " ORDER BY [ftyDescription] "
  479.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  480.                 If RsWrk.Read() Then
  481.                     ltgFixtureMaster.lfxFixtureTypeID.ViewValue = RsWrk("ftyDescription")
  482.                 Else
  483.                     ltgFixtureMaster.lfxFixtureTypeID.ViewValue = ltgFixtureMaster.lfxFixtureTypeID.CurrentValue
  484.                 End If
  485.                 Conn.CloseTempDataReader()
  486.             Else
  487.                 ltgFixtureMaster.lfxFixtureTypeID.ViewValue = System.DBNull.Value
  488.             End If
  489.             ltgFixtureMaster.lfxFixtureTypeID.CssStyle = ""
  490.             ltgFixtureMaster.lfxFixtureTypeID.CssClass = ""
  491.             ltgFixtureMaster.lfxFixtureTypeID.ViewCustomAttributes = ""
  492.  
  493.             ' lfxLocationID
  494.             If ew_NotEmpty(ltgFixtureMaster.lfxLocationID.CurrentValue) Then
  495.                 sSqlWrk = "SELECT [floDescription] FROM [ltgFixtureLocation] WHERE [floID] = " & ew_AdjustSql(ltgFixtureMaster.lfxLocationID.CurrentValue) & ""
  496.                 sSqlWrk = sSqlWrk & " AND (" & "[floIsActive]=True" & ")"
  497.                 sSqlWrk = sSqlWrk & " ORDER BY [floDescription] "
  498.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  499.                 If RsWrk.Read() Then
  500.                     ltgFixtureMaster.lfxLocationID.ViewValue = RsWrk("floDescription")
  501.                 Else
  502.                     ltgFixtureMaster.lfxLocationID.ViewValue = ltgFixtureMaster.lfxLocationID.CurrentValue
  503.                 End If
  504.                 Conn.CloseTempDataReader()
  505.             Else
  506.                 ltgFixtureMaster.lfxLocationID.ViewValue = System.DBNull.Value
  507.             End If
  508.             ltgFixtureMaster.lfxLocationID.CssStyle = ""
  509.             ltgFixtureMaster.lfxLocationID.CssClass = ""
  510.             ltgFixtureMaster.lfxLocationID.ViewCustomAttributes = ""
  511.  
  512.             ' lfxChannel
  513.             ltgFixtureMaster.lfxChannel.ViewValue = ltgFixtureMaster.lfxChannel.CurrentValue
  514.             ltgFixtureMaster.lfxChannel.CssStyle = ""
  515.             ltgFixtureMaster.lfxChannel.CssClass = ""
  516.             ltgFixtureMaster.lfxChannel.ViewCustomAttributes = ""
  517.  
  518.             ' lfxIsActive
  519.             If Convert.ToString(ltgFixtureMaster.lfxIsActive.CurrentValue) = "1" Then
  520.                 ltgFixtureMaster.lfxIsActive.ViewValue = "Yes"
  521.             Else
  522.                 ltgFixtureMaster.lfxIsActive.ViewValue = "No"
  523.             End If
  524.             ltgFixtureMaster.lfxIsActive.CssStyle = ""
  525.             ltgFixtureMaster.lfxIsActive.CssClass = ""
  526.             ltgFixtureMaster.lfxIsActive.ViewCustomAttributes = ""
  527.  
  528.             ' lfxCreatedBy
  529.             ltgFixtureMaster.lfxCreatedBy.ViewValue = ltgFixtureMaster.lfxCreatedBy.CurrentValue
  530.             ltgFixtureMaster.lfxCreatedBy.CssStyle = ""
  531.             ltgFixtureMaster.lfxCreatedBy.CssClass = ""
  532.             ltgFixtureMaster.lfxCreatedBy.ViewCustomAttributes = ""
  533.  
  534.             ' lfxCreatedOn
  535.             ltgFixtureMaster.lfxCreatedOn.ViewValue = ltgFixtureMaster.lfxCreatedOn.CurrentValue
  536.             ltgFixtureMaster.lfxCreatedOn.ViewValue = ew_FormatDateTime(ltgFixtureMaster.lfxCreatedOn.ViewValue, 6)
  537.             ltgFixtureMaster.lfxCreatedOn.CssStyle = ""
  538.             ltgFixtureMaster.lfxCreatedOn.CssClass = ""
  539.             ltgFixtureMaster.lfxCreatedOn.ViewCustomAttributes = ""
  540.  
  541.             ' lfxModifiedBy
  542.             ltgFixtureMaster.lfxModifiedBy.ViewValue = ltgFixtureMaster.lfxModifiedBy.CurrentValue
  543.             ltgFixtureMaster.lfxModifiedBy.CssStyle = ""
  544.             ltgFixtureMaster.lfxModifiedBy.CssClass = ""
  545.             ltgFixtureMaster.lfxModifiedBy.ViewCustomAttributes = ""
  546.  
  547.             ' lfxModifiedOn
  548.             ltgFixtureMaster.lfxModifiedOn.ViewValue = ltgFixtureMaster.lfxModifiedOn.CurrentValue
  549.             ltgFixtureMaster.lfxModifiedOn.ViewValue = ew_FormatDateTime(ltgFixtureMaster.lfxModifiedOn.ViewValue, 6)
  550.             ltgFixtureMaster.lfxModifiedOn.CssStyle = ""
  551.             ltgFixtureMaster.lfxModifiedOn.CssClass = ""
  552.             ltgFixtureMaster.lfxModifiedOn.ViewCustomAttributes = ""
  553.  
  554.             ' View refer script
  555.             ' lfxCode
  556.  
  557.             ltgFixtureMaster.lfxCode.HrefValue = ""
  558.  
  559.             ' lfxDescription
  560.             ltgFixtureMaster.lfxDescription.HrefValue = ""
  561.  
  562.             ' lfxMFG
  563.             ltgFixtureMaster.lfxMFG.HrefValue = ""
  564.  
  565.             ' lfxModel
  566.             ltgFixtureMaster.lfxModel.HrefValue = ""
  567.  
  568.             ' lfxSerialNumber
  569.             ltgFixtureMaster.lfxSerialNumber.HrefValue = ""
  570.  
  571.             ' lfxLamp
  572.             ltgFixtureMaster.lfxLamp.HrefValue = ""
  573.  
  574.             ' lfxFixtureTypeID
  575.             ltgFixtureMaster.lfxFixtureTypeID.HrefValue = ""
  576.  
  577.             ' lfxLocationID
  578.             ltgFixtureMaster.lfxLocationID.HrefValue = ""
  579.  
  580.             ' lfxChannel
  581.             ltgFixtureMaster.lfxChannel.HrefValue = ""
  582.  
  583.             ' lfxIsActive
  584.             ltgFixtureMaster.lfxIsActive.HrefValue = ""
  585.  
  586.             ' lfxCreatedBy
  587.             ltgFixtureMaster.lfxCreatedBy.HrefValue = ""
  588.  
  589.             ' lfxCreatedOn
  590.             ltgFixtureMaster.lfxCreatedOn.HrefValue = ""
  591.  
  592.             ' lfxModifiedBy
  593.             ltgFixtureMaster.lfxModifiedBy.HrefValue = ""
  594.  
  595.             ' lfxModifiedOn
  596.             ltgFixtureMaster.lfxModifiedOn.HrefValue = ""
  597.  
  598.         '
  599.         '  Edit Row
  600.         '
  601.  
  602.         ElseIf ltgFixtureMaster.RowType = EW_ROWTYPE_EDIT Then ' Edit row
  603.  
  604.             ' lfxCode
  605.             ltgFixtureMaster.lfxCode.EditCustomAttributes = ""
  606.             ltgFixtureMaster.lfxCode.EditValue = ew_HtmlEncode(ltgFixtureMaster.lfxCode.CurrentValue)
  607.  
  608.             ' lfxDescription
  609.             ltgFixtureMaster.lfxDescription.EditCustomAttributes = ""
  610.             ltgFixtureMaster.lfxDescription.EditValue = ew_HtmlEncode(ltgFixtureMaster.lfxDescription.CurrentValue)
  611.  
  612.             ' lfxMFG
  613.             ltgFixtureMaster.lfxMFG.EditCustomAttributes = ""
  614.             ltgFixtureMaster.lfxMFG.EditValue = ew_HtmlEncode(ltgFixtureMaster.lfxMFG.CurrentValue)
  615.  
  616.             ' lfxModel
  617.             ltgFixtureMaster.lfxModel.EditCustomAttributes = ""
  618.             ltgFixtureMaster.lfxModel.EditValue = ew_HtmlEncode(ltgFixtureMaster.lfxModel.CurrentValue)
  619.  
  620.             ' lfxSerialNumber
  621.             ltgFixtureMaster.lfxSerialNumber.EditCustomAttributes = ""
  622.             ltgFixtureMaster.lfxSerialNumber.EditValue = ew_HtmlEncode(ltgFixtureMaster.lfxSerialNumber.CurrentValue)
  623.  
  624.             ' lfxLamp
  625.             ltgFixtureMaster.lfxLamp.EditCustomAttributes = ""
  626.             ltgFixtureMaster.lfxLamp.EditValue = ew_HtmlEncode(ltgFixtureMaster.lfxLamp.CurrentValue)
  627.  
  628.             ' lfxFixtureTypeID
  629.             ltgFixtureMaster.lfxFixtureTypeID.EditCustomAttributes = ""
  630.             sSqlWrk = "SELECT [ftyID], [ftyDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [ltgFixtureType]"
  631.             sWhereWrk = ""
  632.             If sWhereWrk <> "" Then sWhereWrk = "(" & sWhereWrk & ") AND "
  633.             sWhereWrk = sWhereWrk & "(" & "[ftyIsActive] = True" & ")"
  634.             If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  635.             sSqlWrk = sSqlWrk & " ORDER BY [ftyDescription] "
  636.             arwrk = Conn.GetRows(sSqlWrk)
  637.             arwrk.Insert(0, New Object(){"", "Please Select"}) 
  638.             ltgFixtureMaster.lfxFixtureTypeID.EditValue = arwrk
  639.  
  640.             ' lfxLocationID
  641.             ltgFixtureMaster.lfxLocationID.EditCustomAttributes = ""
  642.             sSqlWrk = "SELECT [floID], [floDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [ltgFixtureLocation]"
  643.             sWhereWrk = ""
  644.             If sWhereWrk <> "" Then sWhereWrk = "(" & sWhereWrk & ") AND "
  645.             sWhereWrk = sWhereWrk & "(" & "[floIsActive]=True" & ")"
  646.             If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  647.             sSqlWrk = sSqlWrk & " ORDER BY [floDescription] "
  648.             arwrk = Conn.GetRows(sSqlWrk)
  649.             arwrk.Insert(0, New Object(){"", "Please Select"}) 
  650.             ltgFixtureMaster.lfxLocationID.EditValue = arwrk
  651.  
  652.             ' lfxChannel
  653.             ltgFixtureMaster.lfxChannel.EditCustomAttributes = ""
  654.             ltgFixtureMaster.lfxChannel.EditValue = ew_HtmlEncode(ltgFixtureMaster.lfxChannel.CurrentValue)
  655.  
  656.             ' lfxIsActive
  657.             ltgFixtureMaster.lfxIsActive.EditCustomAttributes = ""
  658.  
  659.             ' lfxCreatedBy
  660.             ' lfxCreatedOn
  661.             ' lfxModifiedBy
  662.             ' lfxModifiedOn
  663.             ' Edit refer script
  664.             ' lfxCode
  665.  
  666.             ltgFixtureMaster.lfxCode.HrefValue = ""
  667.  
  668.             ' lfxDescription
  669.             ltgFixtureMaster.lfxDescription.HrefValue = ""
  670.  
  671.             ' lfxMFG
  672.             ltgFixtureMaster.lfxMFG.HrefValue = ""
  673.  
  674.             ' lfxModel
  675.             ltgFixtureMaster.lfxModel.HrefValue = ""
  676.  
  677.             ' lfxSerialNumber
  678.             ltgFixtureMaster.lfxSerialNumber.HrefValue = ""
  679.  
  680.             ' lfxLamp
  681.             ltgFixtureMaster.lfxLamp.HrefValue = ""
  682.  
  683.             ' lfxFixtureTypeID
  684.             ltgFixtureMaster.lfxFixtureTypeID.HrefValue = ""
  685.  
  686.             ' lfxLocationID
  687.             ltgFixtureMaster.lfxLocationID.HrefValue = ""
  688.  
  689.             ' lfxChannel
  690.             ltgFixtureMaster.lfxChannel.HrefValue = ""
  691.  
  692.             ' lfxIsActive
  693.             ltgFixtureMaster.lfxIsActive.HrefValue = ""
  694.  
  695.             ' lfxCreatedBy
  696.             ltgFixtureMaster.lfxCreatedBy.HrefValue = ""
  697.  
  698.             ' lfxCreatedOn
  699.             ltgFixtureMaster.lfxCreatedOn.HrefValue = ""
  700.  
  701.             ' lfxModifiedBy
  702.             ltgFixtureMaster.lfxModifiedBy.HrefValue = ""
  703.  
  704.             ' lfxModifiedOn
  705.             ltgFixtureMaster.lfxModifiedOn.HrefValue = ""
  706.         End If
  707.  
  708.         ' Row Rendered event
  709.         ltgFixtureMaster.Row_Rendered()
  710.     End Sub
  711.  
  712.     '
  713.     ' Validate form
  714.     '
  715.     Function ValidateForm() As Boolean
  716.  
  717.         ' Initialize
  718.         ParentPage.gsFormError = ""
  719.  
  720.         ' Check if validation required
  721.         If Not EW_SERVER_VALIDATE Then Return (ParentPage.gsFormError = "")
  722.  
  723.         ' Return validate result
  724.         Dim Valid As Boolean = (ParentPage.gsFormError = "")
  725.  
  726.         ' Form_CustomValidate event
  727.         Dim sFormCustomError As String = ""
  728.         Valid = Valid And Form_CustomValidate(sFormCustomError)
  729.         If sFormCustomError <> "" Then
  730.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  731.             ParentPage.gsFormError = ParentPage.gsFormError & sFormCustomError
  732.         End If
  733.         Return Valid
  734.     End Function
  735.  
  736.     '
  737.     ' Update record based on key values
  738.     '
  739.     Function EditRow() As Boolean
  740.         Dim RsEdit As OleDbDataReader, RsChk As OleDbDataReader
  741.         Dim sSql As String, sFilter As String
  742.         Dim sSqlChk As String, sFilterChk As String
  743.         Dim bUpdateRow As Boolean
  744.         Dim RsOld As OrderedDictionary
  745.         Dim sIdxErrMsg As String
  746.         Dim Rs As New OrderedDictionary
  747.         sFilter = ltgFixtureMaster.KeyFilter
  748.         ltgFixtureMaster.CurrentFilter  = sFilter
  749.         sSql = ltgFixtureMaster.SQL
  750.         Try
  751.             RsEdit = Conn.GetDataReader(sSql) 
  752.         Catch e As Exception
  753.             If EW_DEBUG_ENABLED Then Throw
  754.             Message = e.Message
  755.             RsEdit.Close()
  756.             EditRow = False
  757.         End Try
  758.         If Not RsEdit.Read() Then
  759.             RsEdit.Close()
  760.             EditRow = False ' Update Failed
  761.         Else
  762.             RsOld = Conn.GetRow(RsEdit)
  763.             RsEdit.Close()
  764.  
  765.             ' lfxCode
  766.             ltgFixtureMaster.lfxCode.SetDbValue(ltgFixtureMaster.lfxCode.CurrentValue, System.DBNull.Value)
  767.             Rs("lfxCode") = ltgFixtureMaster.lfxCode.DbValue
  768.  
  769.             ' lfxDescription
  770.             ltgFixtureMaster.lfxDescription.SetDbValue(ltgFixtureMaster.lfxDescription.CurrentValue, System.DBNull.Value)
  771.             Rs("lfxDescription") = ltgFixtureMaster.lfxDescription.DbValue
  772.  
  773.             ' lfxMFG
  774.             ltgFixtureMaster.lfxMFG.SetDbValue(ltgFixtureMaster.lfxMFG.CurrentValue, System.DBNull.Value)
  775.             Rs("lfxMFG") = ltgFixtureMaster.lfxMFG.DbValue
  776.  
  777.             ' lfxModel
  778.             ltgFixtureMaster.lfxModel.SetDbValue(ltgFixtureMaster.lfxModel.CurrentValue, System.DBNull.Value)
  779.             Rs("lfxModel") = ltgFixtureMaster.lfxModel.DbValue
  780.  
  781.             ' lfxSerialNumber
  782.             ltgFixtureMaster.lfxSerialNumber.SetDbValue(ltgFixtureMaster.lfxSerialNumber.CurrentValue, System.DBNull.Value)
  783.             Rs("lfxSerialNumber") = ltgFixtureMaster.lfxSerialNumber.DbValue
  784.  
  785.             ' lfxLamp
  786.             ltgFixtureMaster.lfxLamp.SetDbValue(ltgFixtureMaster.lfxLamp.CurrentValue, System.DBNull.Value)
  787.             Rs("lfxLamp") = ltgFixtureMaster.lfxLamp.DbValue
  788.  
  789.             ' lfxFixtureTypeID
  790.             ltgFixtureMaster.lfxFixtureTypeID.SetDbValue(ltgFixtureMaster.lfxFixtureTypeID.CurrentValue, System.DBNull.Value)
  791.             Rs("lfxFixtureTypeID") = ltgFixtureMaster.lfxFixtureTypeID.DbValue
  792.  
  793.             ' lfxLocationID
  794.             ltgFixtureMaster.lfxLocationID.SetDbValue(ltgFixtureMaster.lfxLocationID.CurrentValue, System.DBNull.Value)
  795.             Rs("lfxLocationID") = ltgFixtureMaster.lfxLocationID.DbValue
  796.  
  797.             ' lfxChannel
  798.             ltgFixtureMaster.lfxChannel.SetDbValue(ltgFixtureMaster.lfxChannel.CurrentValue, System.DBNull.Value)
  799.             Rs("lfxChannel") = ltgFixtureMaster.lfxChannel.DbValue
  800.  
  801.             ' lfxIsActive
  802.             ltgFixtureMaster.lfxIsActive.SetDbValue((ltgFixtureMaster.lfxIsActive.CurrentValue <> "" And Not IsDBNull(ltgFixtureMaster.lfxIsActive.CurrentValue)), System.DBNull.Value)
  803.             Rs("lfxIsActive") = ltgFixtureMaster.lfxIsActive.DbValue
  804.  
  805.             ' lfxCreatedBy
  806.             ltgFixtureMaster.lfxCreatedBy.DbValue = CurrentUserName()
  807.             Rs("lfxCreatedBy") = ltgFixtureMaster.lfxCreatedBy.DbValue
  808.  
  809.             ' lfxCreatedOn
  810.             ltgFixtureMaster.lfxCreatedOn.DbValue = ew_CurrentDate()
  811.             Rs("lfxCreatedOn") = ltgFixtureMaster.lfxCreatedOn.DbValue
  812.  
  813.             ' lfxModifiedBy
  814.             ltgFixtureMaster.lfxModifiedBy.DbValue = CurrentUserName()
  815.             Rs("lfxModifiedBy") = ltgFixtureMaster.lfxModifiedBy.DbValue
  816.  
  817.             ' lfxModifiedOn
  818.             ltgFixtureMaster.lfxModifiedOn.DbValue = ew_CurrentDate()
  819.             Rs("lfxModifiedOn") = ltgFixtureMaster.lfxModifiedOn.DbValue
  820.  
  821.             ' Row Updating event
  822.             bUpdateRow = ltgFixtureMaster.Row_Updating(RsOld, Rs)
  823.             If bUpdateRow Then
  824.                 Try
  825.                     ltgFixtureMaster.Update(Rs)
  826.                     EditRow = True
  827.                 Catch e As Exception
  828.                     If EW_DEBUG_ENABLED Then Throw
  829.                     Message = e.Message
  830.                     EditRow = False
  831.                 End Try
  832.             Else
  833.                 If ltgFixtureMaster.CancelMessage <> "" Then
  834.                     Message = ltgFixtureMaster.CancelMessage
  835.                     ltgFixtureMaster.CancelMessage = ""
  836.                 Else
  837.                     Message = "Update cancelled"
  838.                 End If
  839.                 EditRow = False
  840.             End If
  841.         End If
  842.  
  843.         ' Row Updated event
  844.         If EditRow Then
  845.             ltgFixtureMaster.Row_Updated(RsOld, Rs)
  846.         End If
  847.     End Function
  848.  
  849.         ' Page Load event
  850.         Public Sub Page_Load()
  851.  
  852.             'HttpContext.Current.Response.Write("Page Load")
  853.         End Sub
  854.  
  855.         ' Page Unload event
  856.         Public Sub Page_Unload()
  857.  
  858.             'HttpContext.Current.Response.Write("Page Unload")
  859.         End Sub
  860.  
  861.     ' Form Custom Validate event
  862.     Public Function Form_CustomValidate(ByRef CustomError As String) As Boolean
  863.  
  864.         'Return error message in CustomError
  865.         Return True
  866.     End Function
  867.     End Class
  868.  
  869.     '
  870.     ' ASP.NET Page_Load event
  871.     '
  872.  
  873.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  874.         Response.Buffer = EW_RESPONSE_BUFFER
  875.         Response.Cache.SetCacheability(HttpCacheability.NoCache)
  876.  
  877.         ' Page init
  878.         ltgFixtureMaster_edit = New cltgFixtureMaster_edit(Me)        
  879.         ltgFixtureMaster_edit.Page_Init()
  880.  
  881.         ' Page main processing
  882.         ltgFixtureMaster_edit.Page_Main()
  883.     End Sub
  884.  
  885.     '
  886.     ' ASP.NET Page_Unload event
  887.     '
  888.  
  889.     Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
  890.  
  891.         ' Dispose page object
  892.         If ltgFixtureMaster_edit IsNot Nothing Then ltgFixtureMaster_edit.Dispose()
  893.     End Sub
  894. End Class
  895.