home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / tblFixtureMasterview.aspx.vb < prev    next >
Text File  |  2010-08-24  |  14KB  |  493 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 tblFixtureMasterview
  12.     Inherits AspNetMaker7_tfpssnet
  13.  
  14.     ' Page object
  15.     Public tblFixtureMaster_view As ctblFixtureMaster_view
  16.  
  17.     '
  18.     ' Page Class
  19.     '
  20.     Class ctblFixtureMaster_view
  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 = "view"
  85.             m_PageObjName = "tblFixtureMaster_view"
  86.             m_PageObjTypeName = "ctblFixtureMaster_view"
  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.CanView 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.     Public lDisplayRecs As Integer ' Number of display records
  175.  
  176.     Public lStartRec As Integer, lStopRec As Integer, lTotalRecs As Integer, lRecRange As Integer
  177.  
  178.     Public lRecCnt As Integer
  179.  
  180.     Public sSrchWhere As String
  181.  
  182.     '
  183.     ' Page main processing
  184.     '
  185.     Sub Page_Main()
  186.         Dim sReturnUrl As String = ""
  187.         Dim bMatchRecord As Boolean = False
  188.         If IsPageRequest Then ' Validate request
  189.             If ew_Get("lfxID") <> "" Then
  190.                 tblFixtureMaster.lfxID.QueryStringValue = ew_Get("lfxID")
  191.             Else
  192.                 sReturnUrl = "tblFixtureMasterlist.aspx" ' Return to list
  193.             End If
  194.  
  195.             ' Get action
  196.             tblFixtureMaster.CurrentAction = "I" ' Display form
  197.             Select Case tblFixtureMaster.CurrentAction
  198.                 Case "I" ' Get a record to display
  199.                     If Not LoadRow() Then ' Load record based on key
  200.                         Message = "No records found" ' Set no record message
  201.                         sReturnUrl = "tblFixtureMasterlist.aspx" ' No matching record, return to list
  202.                     End If
  203.             End Select
  204.         Else
  205.             sReturnUrl = "tblFixtureMasterlist.aspx" ' Not page request, return to list
  206.         End If
  207.         If sReturnUrl <> "" Then Page_Terminate(sReturnUrl)
  208.  
  209.         ' Render row
  210.         tblFixtureMaster.RowType = EW_ROWTYPE_VIEW
  211.         RenderRow()
  212.     End Sub
  213.  
  214.     Public Pager As Object
  215.  
  216.     '
  217.     ' Set up Starting Record parameters
  218.     '
  219.     Sub SetUpStartRec()
  220.         Dim nPageNo As Integer
  221.  
  222.         ' Exit if lDisplayRecs = 0
  223.         If lDisplayRecs = 0 Then Exit Sub
  224.         If IsPageRequest Then ' Validate request
  225.  
  226.             ' Check for a "start" parameter
  227.             If ew_Get(EW_TABLE_START_REC) <> "" AndAlso IsNumeric(ew_Get(EW_TABLE_START_REC)) Then
  228.                 lStartRec = ew_ConvertToInt(ew_Get(EW_TABLE_START_REC))
  229.                 tblFixtureMaster.StartRecordNumber = lStartRec
  230.             ElseIf ew_Get(EW_TABLE_PAGE_NO) <> "" AndAlso IsNumeric(ew_Get(EW_TABLE_PAGE_NO)) Then
  231.                 nPageNo = ew_ConvertToInt(ew_Get(EW_TABLE_PAGE_NO))
  232.                 lStartRec = (nPageNo-1)*lDisplayRecs+1
  233.                 If lStartRec <= 0 Then
  234.                     lStartRec = 1
  235.                 ElseIf lStartRec >= ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1 Then
  236.                     lStartRec = ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1
  237.                 End If
  238.                 tblFixtureMaster.StartRecordNumber = lStartRec
  239.             End If
  240.         End If
  241.         lStartRec = tblFixtureMaster.StartRecordNumber
  242.  
  243.         ' Check if correct start record counter
  244.         If lStartRec <= 0 Then ' Avoid invalid start record counter
  245.             lStartRec = 1 ' Reset start record counter
  246.             tblFixtureMaster.StartRecordNumber = lStartRec
  247.         ElseIf lStartRec > lTotalRecs Then ' Avoid starting record > total records
  248.             lStartRec = ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1 ' Point to last page first record
  249.             tblFixtureMaster.StartRecordNumber = lStartRec
  250.         ElseIf (lStartRec-1) Mod lDisplayRecs <> 0 Then
  251.             lStartRec = ((lStartRec-1)\lDisplayRecs)*lDisplayRecs+1 ' Point to page boundary
  252.             tblFixtureMaster.StartRecordNumber = lStartRec
  253.         End If
  254.     End Sub
  255.  
  256.     '
  257.     ' Load default values
  258.     '
  259.     Sub LoadDefaultValues()
  260.     End Sub
  261.  
  262.     '
  263.     ' Load row based on key values
  264.     '
  265.     Function LoadRow() As Boolean
  266.         Dim RsRow As OleDbDataReader
  267.         Dim sFilter As String = tblFixtureMaster.KeyFilter
  268.  
  269.         ' Row Selecting event
  270.         tblFixtureMaster.Row_Selecting(sFilter)
  271.  
  272.         ' Load SQL based on filter
  273.         tblFixtureMaster.CurrentFilter = sFilter
  274.         Dim sSql As String = tblFixtureMaster.SQL
  275.  
  276.         ' Write SQL for debug
  277.         If EW_DEBUG_ENABLED Then ew_Write(sSql)
  278.         Try
  279.             RsRow = Conn.GetTempDataReader(sSql)    
  280.             If Not RsRow.Read() Then
  281.                 Return False
  282.             Else                
  283.                 LoadRowValues(RsRow) ' Load row values
  284.  
  285.                 ' Row Selected event
  286.                 tblFixtureMaster.Row_Selected(RsRow)
  287.                 Return True    
  288.             End If
  289.         Catch
  290.             If EW_DEBUG_ENABLED Then Throw
  291.             Return False
  292.         Finally
  293.             Conn.CloseTempDataReader()
  294.         End Try
  295.     End Function
  296.  
  297.     '
  298.     ' Load row values from recordset
  299.     '
  300.     Sub LoadRowValues(ByRef RsRow As OleDbDataReader)
  301.         tblFixtureMaster.lfxID.DbValue = RsRow("lfxID")
  302.         tblFixtureMaster.lfxMFG.DbValue = RsRow("lfxMFG")
  303.         tblFixtureMaster.lfxModelType.DbValue = RsRow("lfxModelType")
  304.         tblFixtureMaster.lfxSerialNumber.DbValue = RsRow("lfxSerialNumber")
  305.         tblFixtureMaster.lfxLamp.DbValue = RsRow("lfxLamp")
  306.         tblFixtureMaster.lfxLocationID.DbValue = RsRow("lfxLocationID")
  307.         tblFixtureMaster.lfxHangPos.DbValue = RsRow("lfxHangPos")
  308.         tblFixtureMaster.lfxChannel.DbValue = RsRow("lfxChannel")
  309.         tblFixtureMaster.lfxNotes.DbValue = RsRow("lfxNotes")
  310.     End Sub
  311.  
  312.     '
  313.     ' Render row values based on field settings
  314.     '
  315.     Sub RenderRow()
  316.  
  317.         ' Row Rendering event
  318.         tblFixtureMaster.Row_Rendering()
  319.  
  320.         '
  321.         '  Common render codes for all row types
  322.         '
  323.         ' lfxMFG
  324.  
  325.         tblFixtureMaster.lfxMFG.CellCssStyle = ""
  326.         tblFixtureMaster.lfxMFG.CellCssClass = ""
  327.  
  328.         ' lfxModelType
  329.         tblFixtureMaster.lfxModelType.CellCssStyle = ""
  330.         tblFixtureMaster.lfxModelType.CellCssClass = ""
  331.  
  332.         ' lfxSerialNumber
  333.         tblFixtureMaster.lfxSerialNumber.CellCssStyle = ""
  334.         tblFixtureMaster.lfxSerialNumber.CellCssClass = ""
  335.  
  336.         ' lfxLamp
  337.         tblFixtureMaster.lfxLamp.CellCssStyle = ""
  338.         tblFixtureMaster.lfxLamp.CellCssClass = ""
  339.  
  340.         ' lfxLocationID
  341.         tblFixtureMaster.lfxLocationID.CellCssStyle = ""
  342.         tblFixtureMaster.lfxLocationID.CellCssClass = ""
  343.  
  344.         ' lfxHangPos
  345.         tblFixtureMaster.lfxHangPos.CellCssStyle = ""
  346.         tblFixtureMaster.lfxHangPos.CellCssClass = ""
  347.  
  348.         ' lfxChannel
  349.         tblFixtureMaster.lfxChannel.CellCssStyle = ""
  350.         tblFixtureMaster.lfxChannel.CellCssClass = ""
  351.  
  352.         ' lfxNotes
  353.         tblFixtureMaster.lfxNotes.CellCssStyle = ""
  354.         tblFixtureMaster.lfxNotes.CellCssClass = ""
  355.  
  356.         '
  357.         '  View  Row
  358.         '
  359.  
  360.         If tblFixtureMaster.RowType = EW_ROWTYPE_VIEW Then ' View row
  361.  
  362.             ' lfxMFG
  363.             tblFixtureMaster.lfxMFG.ViewValue = tblFixtureMaster.lfxMFG.CurrentValue
  364.             tblFixtureMaster.lfxMFG.CssStyle = ""
  365.             tblFixtureMaster.lfxMFG.CssClass = ""
  366.             tblFixtureMaster.lfxMFG.ViewCustomAttributes = ""
  367.  
  368.             ' lfxModelType
  369.             tblFixtureMaster.lfxModelType.ViewValue = tblFixtureMaster.lfxModelType.CurrentValue
  370.             tblFixtureMaster.lfxModelType.CssStyle = ""
  371.             tblFixtureMaster.lfxModelType.CssClass = ""
  372.             tblFixtureMaster.lfxModelType.ViewCustomAttributes = ""
  373.  
  374.             ' lfxSerialNumber
  375.             tblFixtureMaster.lfxSerialNumber.ViewValue = tblFixtureMaster.lfxSerialNumber.CurrentValue
  376.             tblFixtureMaster.lfxSerialNumber.CssStyle = ""
  377.             tblFixtureMaster.lfxSerialNumber.CssClass = ""
  378.             tblFixtureMaster.lfxSerialNumber.ViewCustomAttributes = ""
  379.  
  380.             ' lfxLamp
  381.             tblFixtureMaster.lfxLamp.ViewValue = tblFixtureMaster.lfxLamp.CurrentValue
  382.             tblFixtureMaster.lfxLamp.CssStyle = ""
  383.             tblFixtureMaster.lfxLamp.CssClass = ""
  384.             tblFixtureMaster.lfxLamp.ViewCustomAttributes = ""
  385.  
  386.             ' lfxLocationID
  387.             If ew_NotEmpty(tblFixtureMaster.lfxLocationID.CurrentValue) Then
  388.                 sSqlWrk = "SELECT [locDescription] FROM [tblLocations] WHERE [locID] = " & ew_AdjustSql(tblFixtureMaster.lfxLocationID.CurrentValue) & ""
  389.                 sSqlWrk = sSqlWrk & " AND (" & "[locLighting]=True" & ")"
  390.                 sSqlWrk = sSqlWrk & " ORDER BY [locDescription] "
  391.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  392.                 If RsWrk.Read() Then
  393.                     tblFixtureMaster.lfxLocationID.ViewValue = RsWrk("locDescription")
  394.                 Else
  395.                     tblFixtureMaster.lfxLocationID.ViewValue = tblFixtureMaster.lfxLocationID.CurrentValue
  396.                 End If
  397.                 Conn.CloseTempDataReader()
  398.             Else
  399.                 tblFixtureMaster.lfxLocationID.ViewValue = System.DBNull.Value
  400.             End If
  401.             tblFixtureMaster.lfxLocationID.CssStyle = ""
  402.             tblFixtureMaster.lfxLocationID.CssClass = ""
  403.             tblFixtureMaster.lfxLocationID.ViewCustomAttributes = ""
  404.  
  405.             ' lfxHangPos
  406.             tblFixtureMaster.lfxHangPos.ViewValue = tblFixtureMaster.lfxHangPos.CurrentValue
  407.             tblFixtureMaster.lfxHangPos.CssStyle = ""
  408.             tblFixtureMaster.lfxHangPos.CssClass = ""
  409.             tblFixtureMaster.lfxHangPos.ViewCustomAttributes = ""
  410.  
  411.             ' lfxChannel
  412.             tblFixtureMaster.lfxChannel.ViewValue = tblFixtureMaster.lfxChannel.CurrentValue
  413.             tblFixtureMaster.lfxChannel.CssStyle = ""
  414.             tblFixtureMaster.lfxChannel.CssClass = ""
  415.             tblFixtureMaster.lfxChannel.ViewCustomAttributes = ""
  416.  
  417.             ' lfxNotes
  418.             tblFixtureMaster.lfxNotes.ViewValue = tblFixtureMaster.lfxNotes.CurrentValue
  419.             tblFixtureMaster.lfxNotes.CssStyle = ""
  420.             tblFixtureMaster.lfxNotes.CssClass = ""
  421.             tblFixtureMaster.lfxNotes.ViewCustomAttributes = ""
  422.  
  423.             ' View refer script
  424.             ' lfxMFG
  425.  
  426.             tblFixtureMaster.lfxMFG.HrefValue = ""
  427.  
  428.             ' lfxModelType
  429.             tblFixtureMaster.lfxModelType.HrefValue = ""
  430.  
  431.             ' lfxSerialNumber
  432.             tblFixtureMaster.lfxSerialNumber.HrefValue = ""
  433.  
  434.             ' lfxLamp
  435.             tblFixtureMaster.lfxLamp.HrefValue = ""
  436.  
  437.             ' lfxLocationID
  438.             tblFixtureMaster.lfxLocationID.HrefValue = ""
  439.  
  440.             ' lfxHangPos
  441.             tblFixtureMaster.lfxHangPos.HrefValue = ""
  442.  
  443.             ' lfxChannel
  444.             tblFixtureMaster.lfxChannel.HrefValue = ""
  445.  
  446.             ' lfxNotes
  447.             tblFixtureMaster.lfxNotes.HrefValue = ""
  448.         End If
  449.  
  450.         ' Row Rendered event
  451.         tblFixtureMaster.Row_Rendered()
  452.     End Sub
  453.  
  454.         ' Page Load event
  455.         Public Sub Page_Load()
  456.  
  457.             'HttpContext.Current.Response.Write("Page Load")
  458.         End Sub
  459.  
  460.         ' Page Unload event
  461.         Public Sub Page_Unload()
  462.  
  463.             'HttpContext.Current.Response.Write("Page Unload")
  464.         End Sub
  465.     End Class
  466.  
  467.     '
  468.     ' ASP.NET Page_Load event
  469.     '
  470.  
  471.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  472.         Response.Buffer = EW_RESPONSE_BUFFER
  473.         Response.Cache.SetCacheability(HttpCacheability.NoCache)
  474.  
  475.         ' Page init
  476.         tblFixtureMaster_view = New ctblFixtureMaster_view(Me)        
  477.         tblFixtureMaster_view.Page_Init()
  478.  
  479.         ' Page main processing
  480.         tblFixtureMaster_view.Page_Main()
  481.     End Sub
  482.  
  483.     '
  484.     ' ASP.NET Page_Unload event
  485.     '
  486.  
  487.     Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
  488.  
  489.         ' Dispose page object
  490.         If tblFixtureMaster_view IsNot Nothing Then tblFixtureMaster_view.Dispose()
  491.     End Sub
  492. End Class
  493.