home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / App_Code / ltgFixtureMasterinfo.vb < prev    next >
Text File  |  2014-01-25  |  30KB  |  942 lines

  1. Imports System.Data
  2. Imports System.Data.Common
  3. Imports System.Data.OleDb
  4.  
  5. '
  6. ' ASP.NET Maker 7 Project Class (Table)
  7. '
  8. Public Partial Class AspNetMaker7_tfpssnet
  9.     Inherits System.Web.UI.Page
  10.  
  11.     Public ltgFixtureMaster As cltgFixtureMaster
  12.  
  13.     ' Define table class
  14.     Class cltgFixtureMaster
  15.         Inherits AspNetMakerBase
  16.         Implements IDisposable
  17.  
  18.         ' Used by system generated functions
  19.         Private RsWrk As Object, sSqlWrk As String, sWhereWrk As String
  20.  
  21.         Private arwrk As Object
  22.  
  23.         Private armultiwrk() As String
  24.  
  25.         ' Constructor
  26.         Public Sub New(ByRef APage As AspNetMakerPage)
  27.             m_Page = APage
  28.             m_ParentPage = APage.ParentPage            
  29.         End Sub
  30.  
  31.         ' Define table level constants    
  32.         Public UseTokenInUrl As Boolean = EW_USE_TOKEN_IN_URL
  33.  
  34.         ' Table variable
  35.         Public ReadOnly Property TableVar() As String
  36.             Get
  37.                 Return "ltgFixtureMaster"
  38.             End Get
  39.         End Property
  40.  
  41.         ' Table name
  42.         Public ReadOnly Property TableName() As String
  43.             Get
  44.                 Return "ltgFixtureMaster"
  45.             End Get
  46.         End Property
  47.  
  48.         ' Records per page        
  49.         Public Property RecordsPerPage() As Integer
  50.             Get                
  51.                 Return ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_REC_PER_PAGE)
  52.             End Get
  53.             Set(ByVal Value As Integer)                
  54.                 ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_REC_PER_PAGE) = Value
  55.             End Set
  56.         End Property
  57.  
  58.         ' Start record number        
  59.         Public Property StartRecordNumber() As Integer
  60.             Get                
  61.                 Return ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_START_REC)
  62.             End Get
  63.             Set(ByVal Value As Integer)                
  64.                 ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_START_REC) = Value
  65.             End Set
  66.         End Property
  67.  
  68.         ' Search Highlight Name
  69.         Public ReadOnly Property HighlightName() As String
  70.             Get
  71.                 Return "ltgFixtureMaster_Highlight"
  72.             End Get
  73.         End Property
  74.  
  75.         ' Advanced search
  76.         Public Function GetAdvancedSearch(ByRef fld As Object) As String            
  77.             Return Convert.ToString(ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_ADVANCED_SEARCH & "_" & fld))
  78.         End Function
  79.  
  80.         Public Sub SetAdvancedSearch(ByRef fld As Object, v As Object)            
  81.             If ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_ADVANCED_SEARCH & "_" & fld) <> v Then
  82.                 ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_ADVANCED_SEARCH & "_" & fld) = v
  83.             End If
  84.         End Sub
  85.  
  86.         ' Basic search keyword        
  87.         Public Property BasicSearchKeyword() As String
  88.             Get                
  89.                 Return ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_BASIC_SEARCH)
  90.             End Get
  91.             Set(ByVal Value As String)                
  92.                 ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_BASIC_SEARCH) = Value
  93.             End Set
  94.         End Property
  95.  
  96.         ' Basic Search Type        
  97.         Public Property BasicSearchType() As String
  98.             Get
  99.                 Return ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_BASIC_SEARCH_TYPE)
  100.             End Get
  101.             Set(ByVal Value As String)
  102.                 ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_BASIC_SEARCH_TYPE) = Value
  103.             End Set
  104.         End Property
  105.  
  106.         ' Search WHERE clause        
  107.         Public Property SearchWhere() As String
  108.             Get
  109.                 Return ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_SEARCH_WHERE)
  110.             End Get
  111.             Set(ByVal Value As String)
  112.                 ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_SEARCH_WHERE) = Value
  113.             End Set
  114.         End Property
  115.  
  116.         ' Multiple column sort
  117.         Public Sub UpdateSort(ofld, ctrl)
  118.             Dim sSortField As String, sLastSort As String, sThisSort As String, sOrderBy As String
  119.             If CurrentOrder = ofld.FldName Then
  120.                 sSortField = ofld.FldExpression
  121.                 sLastSort = ofld.Sort
  122.                 If CurrentOrderType = "ASC" OrElse CurrentOrderType = "DESC" Then
  123.                     sThisSort = CurrentOrderType
  124.                 Else
  125.                     If sLastSort = "ASC" Then sThisSort = "DESC" Else sThisSort = "ASC"
  126.                 End If
  127.                 ofld.Sort = sThisSort
  128.                 If ctrl Then
  129.                     sOrderBy = SessionOrderBy
  130.                     If sOrderBy.Contains(sSortField & " " & sLastSort) Then
  131.                         sOrderBy = sOrderBy.Replace(sSortField & " " & sLastSort, sSortField & " " & sThisSort)
  132.                     Else
  133.                         If sOrderBy <> "" Then sOrderBy = sOrderBy & ", "
  134.                         sOrderBy = sOrderBy & sSortField & " " & sThisSort
  135.                     End If
  136.                     SessionOrderBy = sOrderBy ' Save to Session
  137.                 Else
  138.                     SessionOrderBy = sSortField & " " & sThisSort ' Save to Session
  139.                 End If
  140.             Else
  141.                 If Not ctrl Then ofld.Sort = ""
  142.             End If
  143.         End Sub
  144.  
  145.         ' Session WHERE Clause        
  146.         Public Property SessionWhere() As String
  147.             Get                
  148.                 Return ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_WHERE)
  149.             End Get
  150.             Set(ByVal Value As String)                
  151.                 ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_WHERE) = Value
  152.             End Set
  153.         End Property
  154.  
  155.         ' Session ORDER BY        
  156.         Public Property SessionOrderBy() As String
  157.             Get                
  158.                 Return ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_ORDER_BY)
  159.             End Get
  160.             Set(ByVal Value As String)                
  161.                 ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_ORDER_BY) = Value
  162.             End Set
  163.         End Property
  164.  
  165.         ' Session key
  166.         Public Function GetKey(ByRef fld As Object) As Object
  167.             Return ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_KEY & "_" & fld)
  168.         End Function
  169.  
  170.         Public Sub SetKey(ByRef fld As Object, ByRef v As Object)
  171.             ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_KEY & "_" & fld) = v
  172.         End Sub
  173.  
  174.         ' Table level SQL
  175.         Public ReadOnly Property SqlSelect() As String
  176.             Get ' Select
  177.                 Return "SELECT * FROM [ltgFixtureMaster]"
  178.             End Get
  179.         End Property
  180.  
  181.         Public ReadOnly Property SqlWhere() As String
  182.             Get ' Where
  183.                 Return ""
  184.             End Get
  185.         End Property
  186.  
  187.         Public ReadOnly Property SqlGroupBy() As String
  188.             Get ' Group By
  189.                 Return ""
  190.             End Get
  191.         End Property
  192.  
  193.         Public ReadOnly Property SqlHaving() As String
  194.             Get ' Having
  195.                 Return ""
  196.             End Get
  197.         End Property
  198.  
  199.         Public ReadOnly Property SqlOrderBy() As String
  200.             Get ' Order By
  201.                 Return ""
  202.             End Get
  203.         End Property
  204.  
  205.         ' SQL variables
  206.         Public CurrentFilter As String ' Current filter
  207.  
  208.         Public CurrentOrder As String ' Current order
  209.  
  210.         Public CurrentOrderType As String ' Current order type
  211.  
  212.         ' Get SQL
  213.         Public Function GetSQL(where As String, orderby As String) As String
  214.             Return ew_BuildSelectSql(SqlSelect, SqlWhere, SqlGroupBy, SqlHaving, SqlOrderBy, where, orderby)
  215.         End Function
  216.  
  217.         ' Table SQL
  218.         Public ReadOnly Property SQL() As String
  219.             Get
  220.                 Dim sFilter As String, sSort As String
  221.                 sFilter = CurrentFilter
  222.                 sSort = SessionOrderBy
  223.                 Return ew_BuildSelectSql(SqlSelect, SqlWhere, SqlGroupBy, SqlHaving, SqlOrderBy, sFilter, sSort)
  224.             End Get
  225.         End Property
  226.  
  227.         ' Return table SQL with list page filter
  228.         Public ReadOnly Property ListSQL() As String
  229.             Get
  230.                 Dim sFilter As String, sSort As String
  231.                 sFilter = SessionWhere
  232.                 If CurrentFilter <> "" Then
  233.                     If sFilter <> "" Then
  234.                         sFilter = "(" & sFilter & ") AND (" & CurrentFilter & ")"
  235.                     Else
  236.                         sFilter = CurrentFilter
  237.                     End If
  238.                 End If
  239.                 sSort = SessionOrderBy
  240.                 Return ew_BuildSelectSql(SqlSelect, SqlWhere, SqlGroupBy, SqlHaving, SqlOrderBy, sFilter, sSort)
  241.             End Get
  242.         End Property
  243.  
  244.         ' Return SQL for record count
  245.         Public ReadOnly Property SelectCountSQL() As String
  246.             Get
  247.                 Dim sFilter As String = SessionWhere
  248.                 If CurrentFilter <> "" Then
  249.                     If sFilter <> "" Then
  250.                         sFilter = "(" & sFilter & ") AND (" & CurrentFilter & ")"
  251.                     Else
  252.                         sFilter = CurrentFilter
  253.                     End If
  254.                 End If
  255.                 Return ew_BuildSelectSql("SELECT COUNT(*) FROM " & SqlSelect.Substring(14), SqlWhere, "", "", "", sFilter, "")
  256.             End Get
  257.         End Property        
  258.  
  259.         ' Insert
  260.         Public Function Insert(ByRef Rs As OrderedDictionary) As Integer
  261.             Dim Sql As String = ""            
  262.             Dim names As String = ""
  263.             Dim values As String = ""            
  264.             Dim value As Object
  265.             Dim fld As cField        
  266.             For Each f As DictionaryEntry In Rs
  267.                 fld = FieldByName(f.Key)
  268.                 If fld IsNot Nothing Then
  269.                     names = names & fld.FldExpression & ","
  270.                     values = values & EW_DB_SQLPARAM_SYMBOL
  271.                     If EW_DB_SQLPARAM_SYMBOL <> "?" Then values = values & fld.FldVar
  272.                     values = values & ","
  273.                 End If
  274.             Next f
  275.             If names.EndsWith(",") Then names = names.Remove(names.Length - 1)
  276.             If values.EndsWith(",") Then values = values.Remove(values.Length - 1)
  277.             If names = "" Then Return -1
  278.             Sql = "INSERT INTO [ltgFixtureMaster] (" & names & ") VALUES (" & values & ")"
  279.             Dim command As OleDbCommand = Conn.GetCommand(Sql)
  280.             For Each f As DictionaryEntry In Rs
  281.                 fld = FieldByName(f.Key)
  282.                 If fld IsNot Nothing Then
  283.                     value = f.Value    
  284.                     command.Parameters.Add(fld.FldVar, fld.FldDbType).Value = value    
  285.                 End If
  286.             Next
  287.             Return command.ExecuteNonQuery()            
  288.         End Function
  289.  
  290.         ' Update
  291.         Public Function Update(ByRef Rs As OrderedDictionary) As Integer
  292.             Dim Sql As String = ""            
  293.             Dim values As String = ""            
  294.             Dim value As Object
  295.             Dim fld As cField
  296.             For Each f As DictionaryEntry In Rs
  297.                 fld = FieldByName(f.Key)
  298.                 If fld IsNot Nothing Then
  299.                     values = values & fld.FldExpression & "=" & EW_DB_SQLPARAM_SYMBOL
  300.                     If EW_DB_SQLPARAM_SYMBOL <> "?" Then values = values & fld.FldVar
  301.                     values = values & ","
  302.                 End If
  303.             Next f
  304.             If values.EndsWith(",") Then values = values.Remove(values.Length - 1)
  305.             If values = "" Then Return -1
  306.             Sql = "UPDATE [ltgFixtureMaster] SET " & values
  307.             If CurrentFilter <> "" Then Sql = Sql & " WHERE " & CurrentFilter
  308.             Dim command As OleDbCommand = Conn.GetCommand(Sql)
  309.             For Each f As DictionaryEntry In Rs
  310.                 fld = FieldByName(f.Key)
  311.                 If fld IsNot Nothing Then
  312.                     value = f.Value    
  313.                     command.Parameters.Add(fld.FldVar, fld.FldDbType).Value = value
  314.                 End If
  315.             Next
  316.             Return command.ExecuteNonQuery()
  317.         End Function
  318.  
  319.         ' Delete
  320.         Public Function Delete(ByRef Rs As OrderedDictionary) As Integer
  321.             Dim Sql As String
  322.             Dim fld As cField            
  323.             Sql = "DELETE FROM [ltgFixtureMaster] WHERE "
  324.             fld = FieldByName("lfxID")
  325.             Sql = Sql & fld.FldExpression & "=" & ew_QuotedValue(Rs("lfxID"), EW_DATATYPE_NUMBER) & " AND "
  326.             If Sql.EndsWith(" AND ") Then Sql = Sql.Remove(Sql.Length - 5)
  327.             If CurrentFilter <> "" Then    Sql = Sql & " AND " & CurrentFilter
  328.             Return Conn.Execute(Sql)
  329.         End Function
  330.  
  331.         ' Key filter for table
  332.         Private ReadOnly Property SqlKeyFilter() As String
  333.             Get
  334.                 Return "[lfxID] = @lfxID@"
  335.             End Get
  336.         End Property
  337.  
  338.         ' Return Key filter for table
  339.         Public ReadOnly Property KeyFilter() As String
  340.             Get
  341.                 Dim sKeyFilter As String
  342.                 sKeyFilter = SqlKeyFilter
  343.                 If Not IsNumeric(lfxID.CurrentValue) Then
  344.                     sKeyFilter = "0=1" ' Invalid key
  345.                 End If
  346.                 sKeyFilter = sKeyFilter.Replace("@lfxID@", ew_AdjustSql(lfxID.CurrentValue)) ' Replace key value
  347.                 Return sKeyFilter
  348.             End Get
  349.         End Property
  350.  
  351.         ' Return URL
  352.         Public ReadOnly Property ReturnUrl() As String
  353.             Get ' Get referer URL automatically
  354.                 If HttpContext.Current.Request.ServerVariables("HTTP_REFERER") IsNot Nothing Then
  355.                     If ew_ReferPage() <> ew_CurrentPage() AndAlso ew_ReferPage() <> "login.aspx" Then ' Referer not same page or login page
  356.                         Dim url As String = HttpContext.Current.Request.ServerVariables("HTTP_REFERER")
  357.                         If url.Contains("?a=") Then ' Remove action
  358.                             Dim p1 As Integer = url.LastIndexOf("?a=")                            
  359.                             Dim p2 As Integer = url.IndexOf("&", p1)                            
  360.                             If p2 > -1 Then
  361.                                 url = url.Substring(0, p1 + 1) & url.Substring(p2 + 1)
  362.                             Else
  363.                                 url = url.Substring(0, p1)                                 
  364.                             End If
  365.                         End If
  366.                         ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_RETURN_URL) = url ' Save to Session
  367.                     End If
  368.                 End If
  369.                 If ew_NotEmpty(ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_RETURN_URL)) Then
  370.                     Return ew_Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_RETURN_URL)
  371.                 Else
  372.                     Return "ltgFixtureMasterlist.aspx"
  373.                 End If
  374.             End Get
  375.         End Property
  376.  
  377.         ' View URL
  378.         Public Function ViewUrl() As String
  379.             Return KeyUrl("ltgFixtureMasterview.aspx", UrlParm(""))
  380.         End Function
  381.  
  382.         ' Add URL
  383.         Public Function AddUrl() As String
  384.             AddUrl = "ltgFixtureMasteradd.aspx"
  385.             Dim sUrlParm As String
  386.             sUrlParm = UrlParm("")
  387.             If sUrlParm <> "" Then AddUrl = AddUrl & "?" & sUrlParm
  388.         End Function
  389.  
  390.         ' Edit URL
  391.         Public Function EditUrl() As String
  392.             Return KeyUrl("ltgFixtureMasteredit.aspx", UrlParm(""))
  393.         End Function
  394.  
  395.         ' Inline edit URL
  396.         Public Function InlineEditUrl() As String
  397.             Return KeyUrl(ew_CurrentPage(), UrlParm("a=edit"))
  398.         End Function
  399.  
  400.         ' Copy URL
  401.         Public Function CopyUrl() As String
  402.             Return KeyUrl("ltgFixtureMasteradd.aspx", UrlParm(""))
  403.         End Function
  404.  
  405.         ' Inline copy URL
  406.         Public Function InlineCopyUrl() As String
  407.             Return KeyUrl(ew_CurrentPage(), UrlParm("a=copy"))
  408.         End Function
  409.  
  410.         ' Delete URL
  411.         Public Function DeleteUrl() As String
  412.             Return KeyUrl("ltgFixtureMasterdelete.aspx", UrlParm(""))
  413.         End Function
  414.  
  415.         ' Key URL
  416.         Public Function KeyUrl(url As String, parm As String) As String
  417.             Dim sUrl As String
  418.             sUrl = url & "?"
  419.             If parm <> "" Then sUrl = sUrl & parm & "&"
  420.             If Not IsDbNull(lfxID.CurrentValue) Then
  421.                 sUrl = sUrl & "lfxID=" & lfxID.CurrentValue
  422.             Else
  423.                 Return "javascript:alert('Invalid Record! Key is null');"
  424.             End If
  425.             Return sUrl
  426.         End Function
  427.  
  428.         ' URL parm
  429.         Function UrlParm(parm As String) As String
  430.             Dim OutStr As String = ""
  431.             If UseTokenInUrl Then
  432.                 OutStr = "t=ltgFixtureMaster"
  433.             End If
  434.             If parm <> "" Then
  435.                 If OutStr <> "" Then OutStr = OutStr & "&"
  436.                 OutStr = OutStr & parm
  437.             End If
  438.             Return OutStr
  439.         End Function
  440.  
  441.         ' Sort URL
  442.         Public Function SortUrl(ByRef fld As cField) As String
  443.             Dim OutStr As String = ""
  444.             If CurrentAction <> "" OrElse Export <> "" OrElse (fld.FldType = 201 OrElse fld.FldType = 203 OrElse fld.FldType = 205) Then
  445.                 OutStr = ""
  446.             Else
  447.                 OutStr = ew_CurrentPage()
  448.                 Dim sUrlParm As String
  449.                 sUrlParm = UrlParm("order=" & HttpContext.Current.Server.UrlEncode(fld.FldName) & "&ordertype=" & fld.ReverseSort)
  450.                 OutStr = OutStr & "?" & sUrlParm
  451.             End If
  452.             Return OutStr
  453.         End Function        
  454.  
  455.         ' Load rows based on filter
  456.         Public Function LoadRs(sFilter As String) As OleDbDataReader
  457.             Dim RsRows As OleDbDataReader
  458.  
  459.             ' Set up filter (SQL WHERE clause)
  460.             CurrentFilter = sFilter
  461.             Dim sSql As String = SQL()
  462.             Try
  463.                 RsRows = Conn.GetDataReader(sSql)
  464.                 If RsRows.HasRows Then
  465.                     Return RsRows
  466.                 Else
  467.                     RsRows.Close()
  468.                     RsRows.Dispose()
  469.                 End If
  470.             Catch
  471.             End Try
  472.             Return Nothing
  473.         End Function
  474.  
  475.         ' Load row values from recordset
  476.         Public Sub LoadListRowValues(ByRef RsRow As OleDbDataReader)            
  477.             lfxID.DbValue = RsRow("lfxID")
  478.             lfxCode.DbValue = RsRow("lfxCode")
  479.             lfxDescription.DbValue = RsRow("lfxDescription")
  480.             lfxMFG.DbValue = RsRow("lfxMFG")
  481.             lfxModel.DbValue = RsRow("lfxModel")
  482.             lfxSerialNumber.DbValue = RsRow("lfxSerialNumber")
  483.             lfxLamp.DbValue = RsRow("lfxLamp")
  484.             lfxFixtureTypeID.DbValue = RsRow("lfxFixtureTypeID")
  485.             lfxLocationID.DbValue = RsRow("lfxLocationID")
  486.             lfxChannel.DbValue = RsRow("lfxChannel")
  487.             lfxIsActive.DbValue = IIf(ew_ConvertToBool(RsRow("lfxIsActive")), "1", "0")
  488.             lfxCreatedBy.DbValue = RsRow("lfxCreatedBy")
  489.             lfxCreatedOn.DbValue = RsRow("lfxCreatedOn")
  490.             lfxModifiedBy.DbValue = RsRow("lfxModifiedBy")
  491.             lfxModifiedOn.DbValue = RsRow("lfxModifiedOn")
  492.         End Sub
  493.  
  494.         ' Render list row values
  495.         Public Sub RenderListRow()
  496.  
  497.             ' Row Rendering event
  498.             Row_Rendering()
  499.  
  500.             ' lfxCode
  501.             lfxCode.ViewValue = lfxCode.CurrentValue
  502.             lfxCode.CssStyle = ""
  503.             lfxCode.CssClass = ""
  504.             lfxCode.ViewCustomAttributes = ""
  505.  
  506.             ' lfxDescription
  507.             lfxDescription.ViewValue = lfxDescription.CurrentValue
  508.             lfxDescription.CssStyle = ""
  509.             lfxDescription.CssClass = ""
  510.             lfxDescription.ViewCustomAttributes = ""
  511.  
  512.             ' lfxMFG
  513.             lfxMFG.ViewValue = lfxMFG.CurrentValue
  514.             lfxMFG.CssStyle = ""
  515.             lfxMFG.CssClass = ""
  516.             lfxMFG.ViewCustomAttributes = ""
  517.  
  518.             ' lfxModel
  519.             lfxModel.ViewValue = lfxModel.CurrentValue
  520.             lfxModel.CssStyle = ""
  521.             lfxModel.CssClass = ""
  522.             lfxModel.ViewCustomAttributes = ""
  523.  
  524.             ' lfxSerialNumber
  525.             lfxSerialNumber.ViewValue = lfxSerialNumber.CurrentValue
  526.             lfxSerialNumber.CssStyle = ""
  527.             lfxSerialNumber.CssClass = ""
  528.             lfxSerialNumber.ViewCustomAttributes = ""
  529.  
  530.             ' lfxFixtureTypeID
  531.             If ew_NotEmpty(lfxFixtureTypeID.CurrentValue) Then
  532.                 sSqlWrk = "SELECT [ftyDescription] FROM [ltgFixtureType] WHERE [ftyID] = " & ew_AdjustSql(lfxFixtureTypeID.CurrentValue) & ""
  533.                 sSqlWrk = sSqlWrk & " AND (" & "[ftyIsActive] = 1" & ")"
  534.                 sSqlWrk = sSqlWrk & " ORDER BY [ftyDescription] "
  535.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  536.                 If RsWrk.Read() Then
  537.                     lfxFixtureTypeID.ViewValue = RsWrk("ftyDescription")
  538.                 Else
  539.                     lfxFixtureTypeID.ViewValue = lfxFixtureTypeID.CurrentValue
  540.                 End If
  541.                 Conn.CloseTempDataReader()
  542.             Else
  543.                 lfxFixtureTypeID.ViewValue = System.DBNull.Value
  544.             End If
  545.             lfxFixtureTypeID.CssStyle = ""
  546.             lfxFixtureTypeID.CssClass = ""
  547.             lfxFixtureTypeID.ViewCustomAttributes = ""
  548.  
  549.             ' lfxLocationID
  550.             If ew_NotEmpty(lfxLocationID.CurrentValue) Then
  551.                 sSqlWrk = "SELECT [floDescription] FROM [ltgFixtureLocation] WHERE [floID] = " & ew_AdjustSql(lfxLocationID.CurrentValue) & ""
  552.                 sSqlWrk = sSqlWrk & " AND (" & "[floIsActive]=1" & ")"
  553.                 sSqlWrk = sSqlWrk & " ORDER BY [floDescription] "
  554.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  555.                 If RsWrk.Read() Then
  556.                     lfxLocationID.ViewValue = RsWrk("floDescription")
  557.                 Else
  558.                     lfxLocationID.ViewValue = lfxLocationID.CurrentValue
  559.                 End If
  560.                 Conn.CloseTempDataReader()
  561.             Else
  562.                 lfxLocationID.ViewValue = System.DBNull.Value
  563.             End If
  564.             lfxLocationID.CssStyle = ""
  565.             lfxLocationID.CssClass = ""
  566.             lfxLocationID.ViewCustomAttributes = ""
  567.  
  568.             ' lfxCode
  569.             lfxCode.HrefValue = ""
  570.  
  571.             ' lfxDescription
  572.             lfxDescription.HrefValue = ""
  573.  
  574.             ' lfxMFG
  575.             lfxMFG.HrefValue = ""
  576.  
  577.             ' lfxModel
  578.             lfxModel.HrefValue = ""
  579.  
  580.             ' lfxSerialNumber
  581.             lfxSerialNumber.HrefValue = ""
  582.  
  583.             ' lfxFixtureTypeID
  584.             lfxFixtureTypeID.HrefValue = ""
  585.  
  586.             ' lfxLocationID
  587.             lfxLocationID.HrefValue = ""
  588.  
  589.             ' Row Rendered event
  590.             Row_Rendered()
  591.         End Sub
  592.  
  593.         Public CurrentAction As String ' Current action
  594.  
  595.         Public EventCancelled As Boolean ' Event cancelled
  596.  
  597.         Public CancelMessage As String ' Cancel message
  598.  
  599.         ' Row Type
  600.         Public RowType As Integer    
  601.  
  602.         Public CssClass As String = "" ' CSS class
  603.  
  604.         Public CssStyle As String = "" ' CSS style
  605.  
  606.         Public RowClientEvents As String = "" ' Row client events
  607.  
  608.         ' Row Attribute
  609.         Public ReadOnly Property RowAttributes() As String
  610.             Get
  611.                 Dim sAtt As String = ""
  612.                 If ew_NotEmpty(CssStyle) Then
  613.                     sAtt = sAtt & " style=""" & CssStyle.Trim() & """"
  614.                 End If
  615.                 If ew_NotEmpty(CssClass) Then
  616.                     sAtt = sAtt & " class=""" & CssClass.Trim() & """"
  617.                 End If
  618.                 If m_Export = "" Then
  619.                     If ew_NotEmpty(RowClientEvents) Then
  620.                         sAtt = sAtt & " " & RowClientEvents.Trim()
  621.                     End If
  622.                 End If
  623.                 Return sAtt
  624.             End Get
  625.         End Property
  626.  
  627.         ' Export
  628.         Private m_Export As String
  629.  
  630.         Public Property Export() As String
  631.             Get
  632.                 Return m_Export
  633.             End Get
  634.             Set(ByVal Value As String)
  635.                 m_Export = Value
  636.             End Set
  637.         End Property
  638.  
  639.         ' Export Original Value
  640.         Public ExportOriginalValue As Boolean = EW_EXPORT_ORIGINAL_VALUE
  641.  
  642.         ' Export All
  643.         Public ExportAll As Boolean = EW_EXPORT_ALL
  644.  
  645.         ' Send Email
  646.         Public SendEmail As Boolean
  647.  
  648.         ' Custom Inner Html
  649.         Public TableCustomInnerHtml As Object
  650.  
  651.         '
  652.         '  Field objects
  653.         '        
  654.         Public Function FieldByName(Name As String) As Object
  655.             If Name = "lfxID" Then Return lfxID
  656.             If Name = "lfxCode" Then Return lfxCode
  657.             If Name = "lfxDescription" Then Return lfxDescription
  658.             If Name = "lfxMFG" Then Return lfxMFG
  659.             If Name = "lfxModel" Then Return lfxModel
  660.             If Name = "lfxSerialNumber" Then Return lfxSerialNumber
  661.             If Name = "lfxLamp" Then Return lfxLamp
  662.             If Name = "lfxFixtureTypeID" Then Return lfxFixtureTypeID
  663.             If Name = "lfxLocationID" Then Return lfxLocationID
  664.             If Name = "lfxChannel" Then Return lfxChannel
  665.             If Name = "lfxIsActive" Then Return lfxIsActive
  666.             If Name = "lfxCreatedBy" Then Return lfxCreatedBy
  667.             If Name = "lfxCreatedOn" Then Return lfxCreatedOn
  668.             If Name = "lfxModifiedBy" Then Return lfxModifiedBy
  669.             If Name = "lfxModifiedOn" Then Return lfxModifiedOn
  670.             Return Nothing        
  671.         End Function
  672.  
  673.         ' lfxID
  674.         Private m_lfxID As cField
  675.  
  676.         Public ReadOnly Property lfxID() As cField
  677.             Get
  678.                 If m_lfxID Is Nothing Then m_lfxID = New cField("ltgFixtureMaster", "x_lfxID", "lfxID", "[lfxID]", 3, OleDbType.Integer, EW_DATATYPE_NUMBER,  0)
  679.                 Return m_lfxID
  680.             End Get
  681.         End Property
  682.  
  683.         ' lfxCode
  684.         Private m_lfxCode As cField
  685.  
  686.         Public ReadOnly Property lfxCode() As cField
  687.             Get
  688.                 If m_lfxCode Is Nothing Then m_lfxCode = New cField("ltgFixtureMaster", "x_lfxCode", "lfxCode", "[lfxCode]", 202, OleDbType.VarWChar, EW_DATATYPE_STRING,  0)
  689.                 Return m_lfxCode
  690.             End Get
  691.         End Property
  692.  
  693.         ' lfxDescription
  694.         Private m_lfxDescription As cField
  695.  
  696.         Public ReadOnly Property lfxDescription() As cField
  697.             Get
  698.                 If m_lfxDescription Is Nothing Then m_lfxDescription = New cField("ltgFixtureMaster", "x_lfxDescription", "lfxDescription", "[lfxDescription]", 202, OleDbType.VarWChar, EW_DATATYPE_STRING,  0)
  699.                 Return m_lfxDescription
  700.             End Get
  701.         End Property
  702.  
  703.         ' lfxMFG
  704.         Private m_lfxMFG As cField
  705.  
  706.         Public ReadOnly Property lfxMFG() As cField
  707.             Get
  708.                 If m_lfxMFG Is Nothing Then m_lfxMFG = New cField("ltgFixtureMaster", "x_lfxMFG", "lfxMFG", "[lfxMFG]", 202, OleDbType.VarWChar, EW_DATATYPE_STRING,  0)
  709.                 Return m_lfxMFG
  710.             End Get
  711.         End Property
  712.  
  713.         ' lfxModel
  714.         Private m_lfxModel As cField
  715.  
  716.         Public ReadOnly Property lfxModel() As cField
  717.             Get
  718.                 If m_lfxModel Is Nothing Then m_lfxModel = New cField("ltgFixtureMaster", "x_lfxModel", "lfxModel", "[lfxModel]", 202, OleDbType.VarWChar, EW_DATATYPE_STRING,  0)
  719.                 Return m_lfxModel
  720.             End Get
  721.         End Property
  722.  
  723.         ' lfxSerialNumber
  724.         Private m_lfxSerialNumber As cField
  725.  
  726.         Public ReadOnly Property lfxSerialNumber() As cField
  727.             Get
  728.                 If m_lfxSerialNumber Is Nothing Then m_lfxSerialNumber = New cField("ltgFixtureMaster", "x_lfxSerialNumber", "lfxSerialNumber", "[lfxSerialNumber]", 202, OleDbType.VarWChar, EW_DATATYPE_STRING,  0)
  729.                 Return m_lfxSerialNumber
  730.             End Get
  731.         End Property
  732.  
  733.         ' lfxLamp
  734.         Private m_lfxLamp As cField
  735.  
  736.         Public ReadOnly Property lfxLamp() As cField
  737.             Get
  738.                 If m_lfxLamp Is Nothing Then m_lfxLamp = New cField("ltgFixtureMaster", "x_lfxLamp", "lfxLamp", "[lfxLamp]", 202, OleDbType.VarWChar, EW_DATATYPE_STRING,  0)
  739.                 Return m_lfxLamp
  740.             End Get
  741.         End Property
  742.  
  743.         ' lfxFixtureTypeID
  744.         Private m_lfxFixtureTypeID As cField
  745.  
  746.         Public ReadOnly Property lfxFixtureTypeID() As cField
  747.             Get
  748.                 If m_lfxFixtureTypeID Is Nothing Then m_lfxFixtureTypeID = New cField("ltgFixtureMaster", "x_lfxFixtureTypeID", "lfxFixtureTypeID", "[lfxFixtureTypeID]", 3, OleDbType.Integer, EW_DATATYPE_NUMBER,  0)
  749.                 Return m_lfxFixtureTypeID
  750.             End Get
  751.         End Property
  752.  
  753.         ' lfxLocationID
  754.         Private m_lfxLocationID As cField
  755.  
  756.         Public ReadOnly Property lfxLocationID() As cField
  757.             Get
  758.                 If m_lfxLocationID Is Nothing Then m_lfxLocationID = New cField("ltgFixtureMaster", "x_lfxLocationID", "lfxLocationID", "[lfxLocationID]", 3, OleDbType.Integer, EW_DATATYPE_NUMBER,  0)
  759.                 Return m_lfxLocationID
  760.             End Get
  761.         End Property
  762.  
  763.         ' lfxChannel
  764.         Private m_lfxChannel As cField
  765.  
  766.         Public ReadOnly Property lfxChannel() As cField
  767.             Get
  768.                 If m_lfxChannel Is Nothing Then m_lfxChannel = New cField("ltgFixtureMaster", "x_lfxChannel", "lfxChannel", "[lfxChannel]", 202, OleDbType.VarWChar, EW_DATATYPE_STRING,  0)
  769.                 Return m_lfxChannel
  770.             End Get
  771.         End Property
  772.  
  773.         ' lfxIsActive
  774.         Private m_lfxIsActive As cField
  775.  
  776.         Public ReadOnly Property lfxIsActive() As cField
  777.             Get
  778.                 If m_lfxIsActive Is Nothing Then m_lfxIsActive = New cField("ltgFixtureMaster", "x_lfxIsActive", "lfxIsActive", "[lfxIsActive]", 11, OleDbType.Boolean, EW_DATATYPE_BOOLEAN,  0)
  779.                 Return m_lfxIsActive
  780.             End Get
  781.         End Property
  782.  
  783.         ' lfxCreatedBy
  784.         Private m_lfxCreatedBy As cField
  785.  
  786.         Public ReadOnly Property lfxCreatedBy() As cField
  787.             Get
  788.                 If m_lfxCreatedBy Is Nothing Then m_lfxCreatedBy = New cField("ltgFixtureMaster", "x_lfxCreatedBy", "lfxCreatedBy", "[lfxCreatedBy]", 202, OleDbType.VarWChar, EW_DATATYPE_STRING,  0)
  789.                 Return m_lfxCreatedBy
  790.             End Get
  791.         End Property
  792.  
  793.         ' lfxCreatedOn
  794.         Private m_lfxCreatedOn As cField
  795.  
  796.         Public ReadOnly Property lfxCreatedOn() As cField
  797.             Get
  798.                 If m_lfxCreatedOn Is Nothing Then m_lfxCreatedOn = New cField("ltgFixtureMaster", "x_lfxCreatedOn", "lfxCreatedOn", "[lfxCreatedOn]", 135, OleDbType.DBTimeStamp, EW_DATATYPE_DATE,  6)
  799.                 Return m_lfxCreatedOn
  800.             End Get
  801.         End Property
  802.  
  803.         ' lfxModifiedBy
  804.         Private m_lfxModifiedBy As cField
  805.  
  806.         Public ReadOnly Property lfxModifiedBy() As cField
  807.             Get
  808.                 If m_lfxModifiedBy Is Nothing Then m_lfxModifiedBy = New cField("ltgFixtureMaster", "x_lfxModifiedBy", "lfxModifiedBy", "[lfxModifiedBy]", 202, OleDbType.VarWChar, EW_DATATYPE_STRING,  0)
  809.                 Return m_lfxModifiedBy
  810.             End Get
  811.         End Property
  812.  
  813.         ' lfxModifiedOn
  814.         Private m_lfxModifiedOn As cField
  815.  
  816.         Public ReadOnly Property lfxModifiedOn() As cField
  817.             Get
  818.                 If m_lfxModifiedOn Is Nothing Then m_lfxModifiedOn = New cField("ltgFixtureMaster", "x_lfxModifiedOn", "lfxModifiedOn", "[lfxModifiedOn]", 135, OleDbType.DBTimeStamp, EW_DATATYPE_DATE,  6)
  819.                 Return m_lfxModifiedOn
  820.             End Get
  821.         End Property
  822.  
  823.         ' Table level events
  824.         ' Recordset Selecting event
  825.         Public Sub Recordset_Selecting(ByRef filter As String) 
  826.  
  827.             ' Enter your code here    
  828.         End Sub
  829.  
  830.         ' Recordset Selected event
  831.         Public Sub Recordset_Selected(rs As DbDataReader)
  832.  
  833.             'HttpContext.Current.Response.Write("Recordset Selected")
  834.         End Sub
  835.  
  836.         ' Recordset Searching event
  837.         Public Sub Recordset_Searching(ByRef filter As String)
  838.  
  839.             ' Enter your code here
  840.         End Sub
  841.  
  842.         ' Row_Selecting event
  843.         Public Sub Row_Selecting(ByRef filter As String)
  844.  
  845.             ' Enter your code here    
  846.         End Sub
  847.  
  848.         ' Row Selected event
  849.         Public Sub Row_Selected(rs As DbDataReader)
  850.  
  851.             'HttpContext.Current.Response.Write("Row Selected")
  852.         End Sub
  853.  
  854.         ' Row Rendering event
  855.         Public Sub Row_Rendering()
  856.  
  857.             ' Enter your code here    
  858.         End Sub
  859.  
  860.         ' Row Rendered event
  861.         Public Sub Row_Rendered()
  862.  
  863.             ' To view properties of field class, use:
  864.             ' HttpContext.Current.Response.Write(<FieldName>.AsString())
  865.  
  866.         End Sub
  867.  
  868.         ' Row Inserting event
  869.         Public Function Row_Inserting(ByRef rs As OrderedDictionary) As Boolean
  870.  
  871.             ' Enter your code here
  872.             ' To cancel, set return value to False and error message to CancelMessage
  873.  
  874.             Return True
  875.         End Function
  876.  
  877.         ' Row Inserted event
  878.         Public Sub Row_Inserted(rs As OrderedDictionary)
  879.  
  880.             'HttpContext.Current.Response.Write("Row Inserted")
  881.         End Sub
  882.  
  883.         ' Row Updating event
  884.         Public Function Row_Updating(rsold As OrderedDictionary, ByRef rsnew As OrderedDictionary) As Boolean
  885.  
  886.             ' Enter your code here
  887.             ' To cancel, set return value to False and error message to CancelMessage
  888.  
  889.             Return True
  890.         End Function
  891.  
  892.         ' Row Updated event
  893.         Public Sub Row_Updated(rsold As OrderedDictionary, rsnew As OrderedDictionary)
  894.  
  895.             'HttpContext.Current.Response.Write("Row Updated")
  896.         End Sub
  897.  
  898.         ' Recordset Deleting event
  899.         Public Function Row_Deleting(rs As OrderedDictionary) As Boolean
  900.  
  901.             ' Enter your code here
  902.             ' To cancel, set return value to False and error message to CancelMessage
  903.  
  904.             Return True
  905.         End Function
  906.  
  907.         ' Recordset Deleted event
  908.         Public Sub Row_Deleted(rs As OrderedDictionary)
  909.  
  910.             'HttpContext.Current.Response.Write("Row Deleted")
  911.         End Sub
  912.  
  913.         ' Email Sending event
  914.         Public Function Email_Sending(ByRef Email As cEmail, Args As Hashtable) As Boolean
  915.  
  916.             'HttpContext.Current.Response.Write(Email.AsString())
  917.             'HttpContext.Current.Response.End()
  918.  
  919.             Return True
  920.         End Function
  921.  
  922.         ' Class terminate
  923.         Public Sub Dispose() Implements IDisposable.Dispose
  924.             If m_lfxID IsNot Nothing Then m_lfxID.Dispose()
  925.             If m_lfxCode IsNot Nothing Then m_lfxCode.Dispose()
  926.             If m_lfxDescription IsNot Nothing Then m_lfxDescription.Dispose()
  927.             If m_lfxMFG IsNot Nothing Then m_lfxMFG.Dispose()
  928.             If m_lfxModel IsNot Nothing Then m_lfxModel.Dispose()
  929.             If m_lfxSerialNumber IsNot Nothing Then m_lfxSerialNumber.Dispose()
  930.             If m_lfxLamp IsNot Nothing Then m_lfxLamp.Dispose()
  931.             If m_lfxFixtureTypeID IsNot Nothing Then m_lfxFixtureTypeID.Dispose()
  932.             If m_lfxLocationID IsNot Nothing Then m_lfxLocationID.Dispose()
  933.             If m_lfxChannel IsNot Nothing Then m_lfxChannel.Dispose()
  934.             If m_lfxIsActive IsNot Nothing Then m_lfxIsActive.Dispose()
  935.             If m_lfxCreatedBy IsNot Nothing Then m_lfxCreatedBy.Dispose()
  936.             If m_lfxCreatedOn IsNot Nothing Then m_lfxCreatedOn.Dispose()
  937.             If m_lfxModifiedBy IsNot Nothing Then m_lfxModifiedBy.Dispose()
  938.             If m_lfxModifiedOn IsNot Nothing Then m_lfxModifiedOn.Dispose()
  939.         End Sub
  940.     End Class
  941. End Class
  942.