home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / tblLPRFixtureTypeview.aspx.vb < prev    next >
Text File  |  2010-08-24  |  10KB  |  382 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 tblLPRFixtureTypeview
  12.     Inherits AspNetMaker7_tfpssnet
  13.  
  14.     ' Page object
  15.     Public tblLPRFixtureType_view As ctblLPRFixtureType_view
  16.  
  17.     '
  18.     ' Page Class
  19.     '
  20.     Class ctblLPRFixtureType_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 tblLPRFixtureType.UseTokenInUrl Then Url = Url & "t=" & tblLPRFixtureType.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 tblLPRFixtureType.UseTokenInUrl Then
  44.                 Result = False
  45.                 If ObjForm IsNot Nothing Then
  46.                     Result = (tblLPRFixtureType.TableVar = ObjForm.GetValue("t"))
  47.                 End If
  48.                 If ew_Get("t") <> "" Then
  49.                     Result = (tblLPRFixtureType.TableVar = ew_Get("t"))
  50.                 End If
  51.                 Return Result
  52.             End If
  53.             Return True            
  54.         End Function    
  55.  
  56.         ' tblLPRFixtureType
  57.         Public Property tblLPRFixtureType() As ctblLPRFixtureType
  58.             Get                
  59.                 Return ParentPage.tblLPRFixtureType
  60.             End Get
  61.             Set(ByVal v As ctblLPRFixtureType)
  62.                 ParentPage.tblLPRFixtureType = v    
  63.             End Set    
  64.         End Property
  65.  
  66.         ' tblLPRFixtureType
  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 = "tblLPRFixtureType_view"
  86.             m_PageObjTypeName = "ctblLPRFixtureType_view"
  87.  
  88.             ' Table Name
  89.             m_TableName = "tblLPRFixtureType"
  90.  
  91.             ' Initialize table object
  92.             tblLPRFixtureType = New ctblLPRFixtureType(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("tblLPRFixtureTypelist.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.             tblLPRFixtureType.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("ftyID") <> "" Then
  190.                 tblLPRFixtureType.ftyID.QueryStringValue = ew_Get("ftyID")
  191.             Else
  192.                 sReturnUrl = "tblLPRFixtureTypelist.aspx" ' Return to list
  193.             End If
  194.  
  195.             ' Get action
  196.             tblLPRFixtureType.CurrentAction = "I" ' Display form
  197.             Select Case tblLPRFixtureType.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 = "tblLPRFixtureTypelist.aspx" ' No matching record, return to list
  202.                     End If
  203.             End Select
  204.         Else
  205.             sReturnUrl = "tblLPRFixtureTypelist.aspx" ' Not page request, return to list
  206.         End If
  207.         If sReturnUrl <> "" Then Page_Terminate(sReturnUrl)
  208.  
  209.         ' Render row
  210.         tblLPRFixtureType.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.                 tblLPRFixtureType.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.                 tblLPRFixtureType.StartRecordNumber = lStartRec
  239.             End If
  240.         End If
  241.         lStartRec = tblLPRFixtureType.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.             tblLPRFixtureType.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.             tblLPRFixtureType.StartRecordNumber = lStartRec
  250.         ElseIf (lStartRec-1) Mod lDisplayRecs <> 0 Then
  251.             lStartRec = ((lStartRec-1)\lDisplayRecs)*lDisplayRecs+1 ' Point to page boundary
  252.             tblLPRFixtureType.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 = tblLPRFixtureType.KeyFilter
  268.  
  269.         ' Row Selecting event
  270.         tblLPRFixtureType.Row_Selecting(sFilter)
  271.  
  272.         ' Load SQL based on filter
  273.         tblLPRFixtureType.CurrentFilter = sFilter
  274.         Dim sSql As String = tblLPRFixtureType.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.                 tblLPRFixtureType.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.         tblLPRFixtureType.ftyID.DbValue = RsRow("ftyID")
  302.         tblLPRFixtureType.ftyDescription.DbValue = RsRow("ftyDescription")
  303.     End Sub
  304.  
  305.     '
  306.     ' Render row values based on field settings
  307.     '
  308.     Sub RenderRow()
  309.  
  310.         ' Row Rendering event
  311.         tblLPRFixtureType.Row_Rendering()
  312.  
  313.         '
  314.         '  Common render codes for all row types
  315.         '
  316.         ' ftyDescription
  317.  
  318.         tblLPRFixtureType.ftyDescription.CellCssStyle = ""
  319.         tblLPRFixtureType.ftyDescription.CellCssClass = ""
  320.  
  321.         '
  322.         '  View  Row
  323.         '
  324.  
  325.         If tblLPRFixtureType.RowType = EW_ROWTYPE_VIEW Then ' View row
  326.  
  327.             ' ftyDescription
  328.             tblLPRFixtureType.ftyDescription.ViewValue = tblLPRFixtureType.ftyDescription.CurrentValue
  329.             tblLPRFixtureType.ftyDescription.CssStyle = ""
  330.             tblLPRFixtureType.ftyDescription.CssClass = ""
  331.             tblLPRFixtureType.ftyDescription.ViewCustomAttributes = ""
  332.  
  333.             ' View refer script
  334.             ' ftyDescription
  335.  
  336.             tblLPRFixtureType.ftyDescription.HrefValue = ""
  337.         End If
  338.  
  339.         ' Row Rendered event
  340.         tblLPRFixtureType.Row_Rendered()
  341.     End Sub
  342.  
  343.         ' Page Load event
  344.         Public Sub Page_Load()
  345.  
  346.             'HttpContext.Current.Response.Write("Page Load")
  347.         End Sub
  348.  
  349.         ' Page Unload event
  350.         Public Sub Page_Unload()
  351.  
  352.             'HttpContext.Current.Response.Write("Page Unload")
  353.         End Sub
  354.     End Class
  355.  
  356.     '
  357.     ' ASP.NET Page_Load event
  358.     '
  359.  
  360.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  361.         Response.Buffer = EW_RESPONSE_BUFFER
  362.         Response.Cache.SetCacheability(HttpCacheability.NoCache)
  363.  
  364.         ' Page init
  365.         tblLPRFixtureType_view = New ctblLPRFixtureType_view(Me)        
  366.         tblLPRFixtureType_view.Page_Init()
  367.  
  368.         ' Page main processing
  369.         tblLPRFixtureType_view.Page_Main()
  370.     End Sub
  371.  
  372.     '
  373.     ' ASP.NET Page_Unload event
  374.     '
  375.  
  376.     Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
  377.  
  378.         ' Dispose page object
  379.         If tblLPRFixtureType_view IsNot Nothing Then tblLPRFixtureType_view.Dispose()
  380.     End Sub
  381. End Class
  382.