home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / ltgFixtureNotelist.aspx.vb < prev    next >
Text File  |  2014-01-25  |  29KB  |  966 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 ltgFixtureNotelist
  12.     Inherits AspNetMaker7_tfpssnet
  13.  
  14.     ' Page object
  15.     Public ltgFixtureNote_list As cltgFixtureNote_list
  16.  
  17.     '
  18.     ' Page Class
  19.     '
  20.     Class cltgFixtureNote_list
  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 ltgFixtureNote.UseTokenInUrl Then Url = Url & "t=" & ltgFixtureNote.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 ltgFixtureNote.UseTokenInUrl Then
  44.                 Result = False
  45.                 If ObjForm IsNot Nothing Then
  46.                     Result = (ltgFixtureNote.TableVar = ObjForm.GetValue("t"))
  47.                 End If
  48.                 If ew_Get("t") <> "" Then
  49.                     Result = (ltgFixtureNote.TableVar = ew_Get("t"))
  50.                 End If
  51.                 Return Result
  52.             End If
  53.             Return True            
  54.         End Function    
  55.  
  56.         ' ltgFixtureNote
  57.         Public Property ltgFixtureNote() As cltgFixtureNote
  58.             Get                
  59.                 Return ParentPage.ltgFixtureNote
  60.             End Get
  61.             Set(ByVal v As cltgFixtureNote)
  62.                 ParentPage.ltgFixtureNote = v    
  63.             End Set    
  64.         End Property
  65.  
  66.         ' ltgFixtureNote
  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.         ' ltgFixtureNote
  77.         Public Property ltgFixtureMaster() As cltgFixtureMaster
  78.             Get                
  79.                 Return ParentPage.ltgFixtureMaster
  80.             End Get
  81.             Set(ByVal v As cltgFixtureMaster)
  82.                 ParentPage.ltgFixtureMaster = v    
  83.             End Set    
  84.         End Property
  85.  
  86.         '
  87.         '  Constructor
  88.         '  - init objects
  89.         '  - open connection
  90.         '
  91.         Public Sub New(ByRef APage As AspNetMaker7_tfpssnet)                
  92.             m_ParentPage = APage
  93.             m_Page = Me    
  94.             m_PageID = "list"
  95.             m_PageObjName = "ltgFixtureNote_list"
  96.             m_PageObjTypeName = "cltgFixtureNote_list"
  97.  
  98.             ' Table Name
  99.             m_TableName = "ltgFixtureNote"
  100.  
  101.             ' Initialize table object
  102.             ltgFixtureNote = New cltgFixtureNote(Me)
  103.             tblEmployees = New ctblEmployees(Me)
  104.             ltgFixtureMaster = New cltgFixtureMaster(Me)
  105.  
  106.             ' Connect to database
  107.             Conn = New cConnection()
  108.  
  109.             ' Initialize list options
  110.             ListOptions = New cListOptions
  111.         End Sub
  112.  
  113.         '
  114.         '  Subroutine Page_Init
  115.         '  - called before page main
  116.         '  - check Security
  117.         '  - set up response header
  118.         '  - call page load events
  119.         '
  120.         Public Sub Page_Init()
  121.             Security = New cAdvancedSecurity(Me)
  122.             If Not Security.IsLoggedIn() Then Security.AutoLogin()
  123.             If Not Security.IsLoggedIn() Then
  124.                 Security.SaveLastUrl()
  125.                 Page_Terminate("login.aspx")
  126.             End If
  127.  
  128.             ' Table Permission loading event
  129.             Security.TablePermission_Loading()
  130.             Security.LoadCurrentUserLevel(TableName)
  131.  
  132.             ' Table Permission loaded event
  133.             Security.TablePermission_Loaded()
  134.             If Not Security.CanList Then
  135.                 Security.SaveLastUrl()
  136.                 Page_Terminate("login.aspx")
  137.             End If
  138.  
  139.             ' User ID loading event
  140.             Security.UserID_Loading()
  141.             If Security.IsLoggedIn() Then Call Security.LoadUserID()
  142.  
  143.             ' User ID loaded event
  144.             Security.UserID_Loaded()
  145.             ltgFixtureNote.Export = ew_Get("export") ' Get export parameter
  146.             ParentPage.gsExport = ltgFixtureNote.Export ' Get export parameter, used in header
  147.             ParentPage.gsExportFile = ltgFixtureNote.TableVar ' Get export file, used in header
  148.  
  149.             ' Global page loading event (in ewglobal*.vb)
  150.             ParentPage.Page_Loading()
  151.  
  152.             ' Page load event, used in current page
  153.             Page_Load()
  154.         End Sub
  155.  
  156.         '
  157.         '  Class terminate
  158.         '  - clean up page object
  159.         '
  160.         Public Sub Dispose() Implements IDisposable.Dispose
  161.             Page_Terminate("")
  162.         End Sub
  163.  
  164.         '
  165.         '  Sub Page_Terminate
  166.         '  - called when exit page
  167.         '  - clean up connection and objects
  168.         '  - if URL specified, redirect to URL
  169.         '
  170.         Sub Page_Terminate(url As String)
  171.  
  172.             ' Page unload event, used in current page
  173.             Page_Unload()
  174.  
  175.             ' Global page unloaded event (in ewglobal*.vb)
  176.             ParentPage.Page_Unloaded()
  177.  
  178.             ' Close connection
  179.             Conn.Dispose()
  180.             Security = Nothing
  181.             ltgFixtureNote.Dispose()
  182.             tblEmployees.Dispose()
  183.             ltgFixtureMaster.Dispose()
  184.             ListOptions = Nothing
  185.  
  186.             ' Go to URL if specified
  187.             If url <> "" Then
  188.                 HttpContext.Current.Response.Clear()
  189.                 HttpContext.Current.Response.Redirect(url)
  190.             End If
  191.         End Sub
  192.  
  193.     Public lDisplayRecs As Integer ' Number of display records
  194.  
  195.     Public lStartRec As Integer, lStopRec As Integer, lTotalRecs As Integer, lRecRange As Integer
  196.  
  197.     Public sSrchWhere As String
  198.  
  199.     Public lRecCnt As Integer
  200.  
  201.     Public lEditRowCnt As Integer
  202.  
  203.     Public lRowCnt As Integer, lRowIndex As Integer
  204.  
  205.     Public lOptionCnt As Integer
  206.  
  207.     Public lRecPerRow As Integer, lColCnt As Integer
  208.  
  209.     Public sDeleteConfirmMsg As String ' Delete confirm message
  210.  
  211.     Public sDbMasterFilter As String, sDbDetailFilter As String
  212.  
  213.     Public bMasterRecordExists As Boolean
  214.  
  215.     Public ListOptions As Object
  216.  
  217.     Public sMultiSelectKey As String
  218.  
  219.     Public x_ewPriv As Integer
  220.  
  221.     '
  222.     ' Page main processing
  223.     '
  224.     Public Sub Page_Main()
  225.         lDisplayRecs = 20
  226.         lRecRange = EW_PAGER_RANGE
  227.         lRecCnt = 0 ' Record count
  228.  
  229.         ' Search filters        
  230.         Dim sSrchAdvanced As String = "" ' Advanced search filter
  231.         Dim sSrchBasic As String = "" ' Basic search filter
  232.         Dim sFilter As String = ""
  233.         sSrchWhere = "" ' Search WHERE clause        
  234.  
  235.         ' Master/Detail
  236.         sDbMasterFilter = "" ' Master filter
  237.         sDbDetailFilter = "" ' Detail filter
  238.         If IsPageRequest Then ' Validate request
  239.  
  240.             ' Set up records per page dynamically
  241.             SetUpDisplayRecs()
  242.  
  243.             ' Handle reset command
  244.             ResetCmd()
  245.  
  246.             ' Set up master detail parameters
  247.             SetUpMasterDetail()
  248.  
  249.             ' Get basic search criteria
  250.             If ParentPage.gsSearchError = "" Then
  251.                 sSrchBasic = BasicSearchWhere()
  252.             End If
  253.  
  254.             ' Set Up Sorting Order
  255.             SetUpSortOrder()
  256.         End If
  257.  
  258.         ' Restore display records
  259.         If (ltgFixtureNote.RecordsPerPage = -1 OrElse ltgFixtureNote.RecordsPerPage > 0) Then
  260.             lDisplayRecs = ltgFixtureNote.RecordsPerPage ' Restore from Session
  261.         Else
  262.             lDisplayRecs = 20 ' Load default
  263.         End If
  264.  
  265.         ' Load Sorting Order
  266.         LoadSortOrder()
  267.  
  268.         ' Build search criteria
  269.         If sSrchAdvanced <> "" Then
  270.             If sSrchWhere <> "" Then
  271.                 sSrchWhere = "(" & sSrchWhere & ") AND (" & sSrchAdvanced & ")"
  272.             Else
  273.                 sSrchWhere = sSrchAdvanced
  274.             End If
  275.         End If
  276.         If sSrchBasic <> "" Then
  277.             If sSrchWhere <> "" Then
  278.                 sSrchWhere = "(" & sSrchWhere & ") AND (" & sSrchBasic & ")"
  279.             Else
  280.                 sSrchWhere = sSrchBasic
  281.             End If
  282.         End If
  283.  
  284.         ' Recordset Searching event
  285.         ltgFixtureNote.Recordset_Searching(sSrchWhere)
  286.  
  287.         ' Save search criteria
  288.         If sSrchWhere <> "" Then
  289.             If sSrchBasic = "" Then ResetBasicSearchParms()
  290.             ltgFixtureNote.SearchWhere = sSrchWhere ' Save to Session
  291.             lStartRec = 1 ' Reset start record counter
  292.             ltgFixtureNote.StartRecordNumber = lStartRec
  293.         Else
  294.             RestoreSearchParms()
  295.         End If
  296.  
  297.         ' Build filter
  298.         sFilter = ""
  299.         If Not Security.CanList Then
  300.             sFilter = "(0=1)" ' Filter all records
  301.         End If
  302.  
  303.         ' Restore master/detail filter
  304.         sDbMasterFilter = ltgFixtureNote.MasterFilter ' Restore master filter
  305.         sDbDetailFilter = ltgFixtureNote.DetailFilter ' Restore detail filter
  306.         If sDbDetailFilter <> "" Then
  307.             If sFilter <> "" Then
  308.                 sFilter = "(" & sFilter & ") AND (" & sDbDetailFilter & ")"
  309.             Else
  310.                 sFilter = sDbDetailFilter
  311.             End If
  312.         End If
  313.         If sSrchWhere <> "" Then
  314.             If sFilter <> "" Then
  315.                 sFilter = "(" & sFilter & ") AND (" & sSrchWhere & ")"
  316.             Else
  317.                 sFilter = sSrchWhere
  318.             End If
  319.         End If
  320.         Dim RsMaster As OleDbDataReader
  321.  
  322.         ' Load master record
  323.         If ltgFixtureNote.MasterFilter <> "" AndAlso ltgFixtureNote.CurrentMasterTable = "ltgFixtureMaster" Then
  324.             RsMaster = ltgFixtureMaster.LoadRs(sDbMasterFilter)
  325.             bMasterRecordExists = RsMaster IsNot Nothing
  326.             If Not bMasterRecordExists Then
  327.                 ltgFixtureNote.MasterFilter = "" ' Clear master filter
  328.                 ltgFixtureNote.DetailFilter = "" ' Clear detail filter
  329.                 Message = "No records found" ' Set no record found
  330.             Page_Terminate(ltgFixtureNote.ReturnUrl) ' Return to caller
  331.             Else
  332.                 RsMaster.Read()
  333.                 ltgFixtureMaster.LoadListRowValues(RsMaster)
  334.                 ltgFixtureMaster.RowType = EW_ROWTYPE_MASTER ' Master row
  335.                 ltgFixtureMaster.RenderListRow()
  336.                 RsMaster.Close()
  337.                 RsMaster.Dispose()
  338.             End If
  339.         End If
  340.  
  341.         ' Set up filter in Session
  342.         ltgFixtureNote.SessionWhere = sFilter
  343.         ltgFixtureNote.CurrentFilter = ""
  344.     End Sub
  345.  
  346.     '
  347.     ' Set up number of records displayed per page
  348.     '
  349.     Sub SetUpDisplayRecs()
  350.         Dim sWrk As String
  351.         sWrk = ew_Get(EW_TABLE_REC_PER_PAGE)
  352.         If sWrk <> "" Then
  353.             If IsNumeric(sWrk) Then
  354.                 lDisplayRecs = ew_ConvertToInt(sWrk)
  355.             Else
  356.                 If ew_SameText(sWrk, "all") Then ' Display all records
  357.                     lDisplayRecs = -1
  358.                 Else
  359.                     lDisplayRecs = 20 ' Non-numeric, load default
  360.                 End If
  361.             End If
  362.             ltgFixtureNote.RecordsPerPage = lDisplayRecs ' Save to Session
  363.  
  364.             ' Reset start position
  365.             lStartRec = 1
  366.             ltgFixtureNote.StartRecordNumber = lStartRec
  367.         End If
  368.     End Sub
  369.  
  370.     '
  371.     ' Return Basic Search SQL
  372.     '
  373.     Function BasicSearchSQL(Keyword As String) As String
  374.         Dim sKeyword As String, sSql As String = ""
  375.         sKeyword = ew_AdjustSql(Keyword)        
  376.         sSql = sSql & "[notShortDesc] LIKE '%" & sKeyword & "%' OR "
  377.         sSql = sSql & "[notNote] LIKE '%" & sKeyword & "%' OR "
  378.         sSql = sSql & "[notCreatedBy] LIKE '%" & sKeyword & "%' OR "
  379.         sSql = sSql & "[notModifiedBy] LIKE '%" & sKeyword & "%' OR "
  380.         If sSql.EndsWith(" OR ") Then sSql = sSql.SubString(0, sSql.Length-4)
  381.         Return sSql
  382.     End Function
  383.  
  384.     '
  385.     ' Return Basic Search WHERE based on search keyword and type
  386.     '
  387.     Function BasicSearchWhere() As String
  388.         Dim sSearchStr As String = "", sSearchKeyword As String, sSearchType As String
  389.         Dim sSearch As String, arKeyword() As String, sKeyword As String
  390.         If Not Security.CanSearch Then Return ""
  391.         sSearchKeyword = ew_Get(EW_TABLE_BASIC_SEARCH)
  392.         sSearchType = ew_Get(EW_TABLE_BASIC_SEARCH_TYPE)
  393.         If sSearchKeyword <> "" Then
  394.             sSearch = sSearchKeyword.Trim()
  395.             If sSearchType <> "" Then
  396.                 While InStr(sSearch, "  ") > 0
  397.                     sSearch = sSearch.Replace("  ", " ")
  398.                 End While
  399.                 arKeyword = sSearch.Trim().Split(New Char() {" "c})
  400.                 For Each sKeyword In arKeyword
  401.                     If sSearchStr <> "" Then sSearchStr = sSearchStr & " " & sSearchType & " "
  402.                     sSearchStr = sSearchStr & "(" & BasicSearchSQL(sKeyword) & ")"
  403.                 Next
  404.             Else
  405.                 sSearchStr = BasicSearchSQL(sSearch)
  406.             End If
  407.         End If
  408.         If sSearchKeyword <> "" then
  409.             ltgFixtureNote.BasicSearchKeyword = sSearchKeyword
  410.             ltgFixtureNote.BasicSearchType = sSearchType
  411.         End If
  412.         Return sSearchStr
  413.     End Function
  414.  
  415.     '
  416.     ' Clear all search parameters
  417.     '
  418.     Sub ResetSearchParms()
  419.  
  420.         ' Clear search where
  421.         sSrchWhere = ""
  422.         ltgFixtureNote.SearchWhere = sSrchWhere
  423.  
  424.         ' Clear basic search parameters
  425.         ResetBasicSearchParms()
  426.     End Sub
  427.  
  428.     '
  429.     ' Clear all basic search parameters
  430.     '
  431.     Sub ResetBasicSearchParms()
  432.  
  433.         ' Clear basic search parameters
  434.         ltgFixtureNote.BasicSearchKeyword = ""
  435.         ltgFixtureNote.BasicSearchType = ""
  436.     End Sub
  437.  
  438.     '
  439.     ' Restore all search parameters
  440.     '
  441.     Sub RestoreSearchParms()
  442.         sSrchWhere = ltgFixtureNote.SearchWhere
  443.     End Sub
  444.  
  445.     '
  446.     ' Set up Sort parameters based on Sort Links clicked
  447.     '
  448.     Sub SetUpSortOrder()
  449.         Dim sOrderBy As String
  450.         Dim sSortField As String, sLastSort As String, sThisSort As String
  451.         Dim bCtrl As Boolean
  452.  
  453.         ' Check for Ctrl pressed
  454.         bCtrl = (ew_Get("ctrl") <> "")
  455.  
  456.         ' Check for an Order parameter
  457.         If ew_Get("order") <> "" Then
  458.             ltgFixtureNote.CurrentOrder = ew_Get("order")
  459.             ltgFixtureNote.CurrentOrderType = ew_Get("ordertype")
  460.             ltgFixtureNote.UpdateSort(ltgFixtureNote.notFixID, bCtrl) ' notFixID
  461.             ltgFixtureNote.UpdateSort(ltgFixtureNote.notTypeID, bCtrl) ' notTypeID
  462.             ltgFixtureNote.UpdateSort(ltgFixtureNote.notDate, bCtrl) ' notDate
  463.             ltgFixtureNote.UpdateSort(ltgFixtureNote.notShortDesc, bCtrl) ' notShortDesc
  464.             ltgFixtureNote.UpdateSort(ltgFixtureNote.notLPRStatusID, bCtrl) ' notLPRStatusID
  465.             ltgFixtureNote.UpdateSort(ltgFixtureNote.notPriority, bCtrl) ' notPriority
  466.             ltgFixtureNote.UpdateSort(ltgFixtureNote.notIsActive, bCtrl) ' notIsActive
  467.             ltgFixtureNote.StartRecordNumber = 1 ' Reset start position
  468.         End If
  469.     End Sub
  470.  
  471.     '
  472.     ' Load Sort Order parameters
  473.     '
  474.     Sub LoadSortOrder()
  475.         Dim sOrderBy As String
  476.         sOrderBy = ltgFixtureNote.SessionOrderBy ' Get order by from Session
  477.         If sOrderBy = "" Then
  478.             If ltgFixtureNote.SqlOrderBy <> "" Then
  479.                 sOrderBy = ltgFixtureNote.SqlOrderBy
  480.                 ltgFixtureNote.SessionOrderBy = sOrderBy
  481.             End If
  482.         End If
  483.     End Sub
  484.  
  485.     '
  486.     ' Reset command based on querystring parameter "cmd"
  487.     ' - reset: reset search parameters
  488.     ' - resetall: reset search and master/detail parameters
  489.     ' - resetsort: reset sort parameters
  490.     '
  491.     Sub ResetCmd()
  492.         Dim sCmd As String
  493.  
  494.         ' Get reset cmd
  495.         If ew_Get("cmd") <> "" Then
  496.             sCmd = ew_Get("cmd")
  497.  
  498.             ' Reset search criteria
  499.             If ew_SameText(sCmd, "reset") OrElse ew_SameText(sCmd, "resetall") Then
  500.                 ResetSearchParms()
  501.             End If
  502.  
  503.             ' Reset master/detail keys
  504.             If ew_SameText(sCmd, "resetall") Then
  505.                 ltgFixtureNote.CurrentMasterTable = "" ' Clear master table
  506.                 ltgFixtureNote.MasterFilter = "" ' Clear master filter
  507.                 sDbMasterFilter = ""
  508.                 ltgFixtureNote.DetailFilter = "" ' Clear detail filter
  509.                 sDbDetailFilter = ""
  510.                 ltgFixtureNote.notFixID.SessionValue = ""
  511.             End If
  512.  
  513.             ' Reset sort criteria
  514.             If ew_SameText(sCmd, "resetsort") Then
  515.                 Dim sOrderBy As String = ""
  516.                 ltgFixtureNote.SessionOrderBy = sOrderBy
  517.                 ltgFixtureNote.notFixID.Sort = ""
  518.                 ltgFixtureNote.notTypeID.Sort = ""
  519.                 ltgFixtureNote.notDate.Sort = ""
  520.                 ltgFixtureNote.notShortDesc.Sort = ""
  521.                 ltgFixtureNote.notLPRStatusID.Sort = ""
  522.                 ltgFixtureNote.notPriority.Sort = ""
  523.                 ltgFixtureNote.notIsActive.Sort = ""
  524.             End If
  525.  
  526.             ' Reset start position
  527.             lStartRec = 1
  528.             ltgFixtureNote.StartRecordNumber = lStartRec
  529.         End If
  530.     End Sub
  531.  
  532.     Public Pager As Object
  533.  
  534.     '
  535.     ' Set up Starting Record parameters
  536.     '
  537.     Sub SetUpStartRec()
  538.         Dim nPageNo As Integer
  539.  
  540.         ' Exit if lDisplayRecs = 0
  541.         If lDisplayRecs = 0 Then Exit Sub
  542.         If IsPageRequest Then ' Validate request
  543.  
  544.             ' Check for a "start" parameter
  545.             If ew_Get(EW_TABLE_START_REC) <> "" AndAlso IsNumeric(ew_Get(EW_TABLE_START_REC)) Then
  546.                 lStartRec = ew_ConvertToInt(ew_Get(EW_TABLE_START_REC))
  547.                 ltgFixtureNote.StartRecordNumber = lStartRec
  548.             ElseIf ew_Get(EW_TABLE_PAGE_NO) <> "" AndAlso IsNumeric(ew_Get(EW_TABLE_PAGE_NO)) Then
  549.                 nPageNo = ew_ConvertToInt(ew_Get(EW_TABLE_PAGE_NO))
  550.                 lStartRec = (nPageNo-1)*lDisplayRecs+1
  551.                 If lStartRec <= 0 Then
  552.                     lStartRec = 1
  553.                 ElseIf lStartRec >= ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1 Then
  554.                     lStartRec = ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1
  555.                 End If
  556.                 ltgFixtureNote.StartRecordNumber = lStartRec
  557.             End If
  558.         End If
  559.         lStartRec = ltgFixtureNote.StartRecordNumber
  560.  
  561.         ' Check if correct start record counter
  562.         If lStartRec <= 0 Then ' Avoid invalid start record counter
  563.             lStartRec = 1 ' Reset start record counter
  564.             ltgFixtureNote.StartRecordNumber = lStartRec
  565.         ElseIf lStartRec > lTotalRecs Then ' Avoid starting record > total records
  566.             lStartRec = ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1 ' Point to last page first record
  567.             ltgFixtureNote.StartRecordNumber = lStartRec
  568.         ElseIf (lStartRec-1) Mod lDisplayRecs <> 0 Then
  569.             lStartRec = ((lStartRec-1)\lDisplayRecs)*lDisplayRecs+1 ' Point to page boundary
  570.             ltgFixtureNote.StartRecordNumber = lStartRec
  571.         End If
  572.     End Sub
  573.  
  574.     '
  575.     ' Load default values
  576.     '
  577.     Sub LoadDefaultValues()
  578.         ltgFixtureNote.notIsActive.CurrentValue = 1
  579.     End Sub
  580.  
  581.     '
  582.     ' Load recordset
  583.     '
  584.     Function LoadRecordset() As OleDbDataReader
  585.  
  586.         ' Recordset Selecting event
  587.         ltgFixtureNote.Recordset_Selecting(ltgFixtureNote.CurrentFilter)
  588.  
  589.         ' Load list page SQL
  590.         Dim sSql As String = ltgFixtureNote.ListSQL
  591.  
  592.         ' Write SQL for debug
  593.         If EW_DEBUG_ENABLED Then ew_Write(sSql)
  594.  
  595.         ' Count
  596.         lTotalRecs = -1        
  597.         Try            
  598.             If sSql.StartsWith("SELECT * FROM ", StringComparison.InvariantCultureIgnoreCase) AndAlso _                
  599.                 ew_Empty(ltgFixtureNote.SqlGroupBy) AndAlso _
  600.                 ew_Empty(ltgFixtureNote.SqlHaving) Then
  601.                 Dim sCntSql As String = ltgFixtureNote.SelectCountSQL
  602.  
  603.                 ' Write SQL for debug
  604.                 If EW_DEBUG_ENABLED Then ew_Write("<br>" & sCntSql)
  605.                 lTotalRecs = Conn.ExecuteScalar(sCntSql)
  606.             End If            
  607.         Catch
  608.         End Try
  609.  
  610.         ' Load recordset
  611.         Dim Rs As OleDbDataReader = Conn.GetDataReader(sSql)
  612.         If lTotalRecs < 0 AndAlso Rs.HasRows Then
  613.             lTotalRecs = 0
  614.             While Rs.Read()
  615.                 lTotalRecs = lTotalRecs + 1
  616.             End While
  617.             Rs.Close()        
  618.             Rs = Conn.GetDataReader(sSql)
  619.         End If
  620.  
  621.         ' Recordset Selected event
  622.         ltgFixtureNote.Recordset_Selected(Rs)
  623.         Return Rs
  624.     End Function
  625.  
  626.     '
  627.     ' Load row based on key values
  628.     '
  629.     Function LoadRow() As Boolean
  630.         Dim RsRow As OleDbDataReader
  631.         Dim sFilter As String = ltgFixtureNote.KeyFilter
  632.  
  633.         ' Row Selecting event
  634.         ltgFixtureNote.Row_Selecting(sFilter)
  635.  
  636.         ' Load SQL based on filter
  637.         ltgFixtureNote.CurrentFilter = sFilter
  638.         Dim sSql As String = ltgFixtureNote.SQL
  639.  
  640.         ' Write SQL for debug
  641.         If EW_DEBUG_ENABLED Then ew_Write(sSql)
  642.         Try
  643.             RsRow = Conn.GetTempDataReader(sSql)    
  644.             If Not RsRow.Read() Then
  645.                 Return False
  646.             Else                
  647.                 LoadRowValues(RsRow) ' Load row values
  648.  
  649.                 ' Row Selected event
  650.                 ltgFixtureNote.Row_Selected(RsRow)
  651.                 Return True    
  652.             End If
  653.         Catch
  654.             If EW_DEBUG_ENABLED Then Throw
  655.             Return False
  656.         Finally
  657.             Conn.CloseTempDataReader()
  658.         End Try
  659.     End Function
  660.  
  661.     '
  662.     ' Load row values from recordset
  663.     '
  664.     Sub LoadRowValues(ByRef RsRow As OleDbDataReader)
  665.         ltgFixtureNote.notID.DbValue = RsRow("notID")
  666.         ltgFixtureNote.notFixID.DbValue = RsRow("notFixID")
  667.         ltgFixtureNote.notTypeID.DbValue = RsRow("notTypeID")
  668.         ltgFixtureNote.notDate.DbValue = RsRow("notDate")
  669.         ltgFixtureNote.notShortDesc.DbValue = RsRow("notShortDesc")
  670.         ltgFixtureNote.notNote.DbValue = RsRow("notNote")
  671.         ltgFixtureNote.notLPRStatusID.DbValue = RsRow("notLPRStatusID")
  672.         ltgFixtureNote.notPriority.DbValue = RsRow("notPriority")
  673.         ltgFixtureNote.notIsActive.DbValue = IIf(ew_ConvertToBool(RsRow("notIsActive")), "1", "0")
  674.         ltgFixtureNote.notCreatedBy.DbValue = RsRow("notCreatedBy")
  675.         ltgFixtureNote.notCreatedOn.DbValue = RsRow("notCreatedOn")
  676.         ltgFixtureNote.notModifiedBy.DbValue = RsRow("notModifiedBy")
  677.         ltgFixtureNote.notModifiedOn.DbValue = RsRow("notModifiedOn")
  678.     End Sub
  679.  
  680.     '
  681.     ' Render row values based on field settings
  682.     '
  683.     Sub RenderRow()
  684.  
  685.         ' Row Rendering event
  686.         ltgFixtureNote.Row_Rendering()
  687.  
  688.         '
  689.         '  Common render codes for all row types
  690.         '
  691.         ' notFixID
  692.  
  693.         ltgFixtureNote.notFixID.CellCssStyle = ""
  694.         ltgFixtureNote.notFixID.CellCssClass = ""
  695.  
  696.         ' notTypeID
  697.         ltgFixtureNote.notTypeID.CellCssStyle = ""
  698.         ltgFixtureNote.notTypeID.CellCssClass = ""
  699.  
  700.         ' notDate
  701.         ltgFixtureNote.notDate.CellCssStyle = ""
  702.         ltgFixtureNote.notDate.CellCssClass = ""
  703.  
  704.         ' notShortDesc
  705.         ltgFixtureNote.notShortDesc.CellCssStyle = ""
  706.         ltgFixtureNote.notShortDesc.CellCssClass = ""
  707.  
  708.         ' notLPRStatusID
  709.         ltgFixtureNote.notLPRStatusID.CellCssStyle = ""
  710.         ltgFixtureNote.notLPRStatusID.CellCssClass = ""
  711.  
  712.         ' notPriority
  713.         ltgFixtureNote.notPriority.CellCssStyle = ""
  714.         ltgFixtureNote.notPriority.CellCssClass = ""
  715.  
  716.         ' notIsActive
  717.         ltgFixtureNote.notIsActive.CellCssStyle = ""
  718.         ltgFixtureNote.notIsActive.CellCssClass = ""
  719.  
  720.         '
  721.         '  View  Row
  722.         '
  723.  
  724.         If ltgFixtureNote.RowType = EW_ROWTYPE_VIEW Then ' View row
  725.  
  726.             ' notID
  727.             ltgFixtureNote.notID.ViewValue = ltgFixtureNote.notID.CurrentValue
  728.             ltgFixtureNote.notID.CssStyle = ""
  729.             ltgFixtureNote.notID.CssClass = ""
  730.             ltgFixtureNote.notID.ViewCustomAttributes = ""
  731.  
  732.             ' notFixID
  733.             ltgFixtureNote.notFixID.ViewValue = ltgFixtureNote.notFixID.CurrentValue
  734.             ltgFixtureNote.notFixID.CssStyle = ""
  735.             ltgFixtureNote.notFixID.CssClass = ""
  736.             ltgFixtureNote.notFixID.ViewCustomAttributes = ""
  737.  
  738.             ' notTypeID
  739.             If ew_NotEmpty(ltgFixtureNote.notTypeID.CurrentValue) Then
  740.                 sSqlWrk = "SELECT [ntyDescription] FROM [ltgFixtureNoteType] WHERE [ntyID] = " & ew_AdjustSql(ltgFixtureNote.notTypeID.CurrentValue) & ""
  741.                 sSqlWrk = sSqlWrk & " AND (" & "[ntyIsActive]=True" & ")"
  742.                 sSqlWrk = sSqlWrk & " ORDER BY [ntyDescription] "
  743.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  744.                 If RsWrk.Read() Then
  745.                     ltgFixtureNote.notTypeID.ViewValue = RsWrk("ntyDescription")
  746.                 Else
  747.                     ltgFixtureNote.notTypeID.ViewValue = ltgFixtureNote.notTypeID.CurrentValue
  748.                 End If
  749.                 Conn.CloseTempDataReader()
  750.             Else
  751.                 ltgFixtureNote.notTypeID.ViewValue = System.DBNull.Value
  752.             End If
  753.             ltgFixtureNote.notTypeID.CssStyle = ""
  754.             ltgFixtureNote.notTypeID.CssClass = ""
  755.             ltgFixtureNote.notTypeID.ViewCustomAttributes = ""
  756.  
  757.             ' notDate
  758.             ltgFixtureNote.notDate.ViewValue = ltgFixtureNote.notDate.CurrentValue
  759.             ltgFixtureNote.notDate.ViewValue = ew_FormatDateTime(ltgFixtureNote.notDate.ViewValue, 6)
  760.             ltgFixtureNote.notDate.CssStyle = ""
  761.             ltgFixtureNote.notDate.CssClass = ""
  762.             ltgFixtureNote.notDate.ViewCustomAttributes = ""
  763.  
  764.             ' notShortDesc
  765.             ltgFixtureNote.notShortDesc.ViewValue = ltgFixtureNote.notShortDesc.CurrentValue
  766.             ltgFixtureNote.notShortDesc.CssStyle = ""
  767.             ltgFixtureNote.notShortDesc.CssClass = ""
  768.             ltgFixtureNote.notShortDesc.ViewCustomAttributes = ""
  769.  
  770.             ' notLPRStatusID
  771.             If ew_NotEmpty(ltgFixtureNote.notLPRStatusID.CurrentValue) Then
  772.                 sSqlWrk = "SELECT [lstDescription] FROM [tblLPRStatus] WHERE [lstID] = " & ew_AdjustSql(ltgFixtureNote.notLPRStatusID.CurrentValue) & ""
  773.                 sSqlWrk = sSqlWrk & " AND (" & "[lstIsActive]=True" & ")"
  774.                 sSqlWrk = sSqlWrk & " ORDER BY [lstDescription] "
  775.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  776.                 If RsWrk.Read() Then
  777.                     ltgFixtureNote.notLPRStatusID.ViewValue = RsWrk("lstDescription")
  778.                 Else
  779.                     ltgFixtureNote.notLPRStatusID.ViewValue = ltgFixtureNote.notLPRStatusID.CurrentValue
  780.                 End If
  781.                 Conn.CloseTempDataReader()
  782.             Else
  783.                 ltgFixtureNote.notLPRStatusID.ViewValue = System.DBNull.Value
  784.             End If
  785.             ltgFixtureNote.notLPRStatusID.CssStyle = ""
  786.             ltgFixtureNote.notLPRStatusID.CssClass = ""
  787.             ltgFixtureNote.notLPRStatusID.ViewCustomAttributes = ""
  788.  
  789.             ' notPriority
  790.             If Not IsDBNull(ltgFixtureNote.notPriority.CurrentValue) Then
  791.                 Select Case ltgFixtureNote.notPriority.CurrentValue
  792.                     Case "1"
  793.                         ltgFixtureNote.notPriority.ViewValue = "High"
  794.                     Case "2"
  795.                         ltgFixtureNote.notPriority.ViewValue = "Medium"
  796.                     Case "3"
  797.                         ltgFixtureNote.notPriority.ViewValue = "Low"
  798.                     Case Else
  799.                         ltgFixtureNote.notPriority.ViewValue = ltgFixtureNote.notPriority.CurrentValue
  800.                 End Select
  801.             Else
  802.                 ltgFixtureNote.notPriority.ViewValue = System.DBNull.Value
  803.             End If
  804.             ltgFixtureNote.notPriority.CssStyle = ""
  805.             ltgFixtureNote.notPriority.CssClass = ""
  806.             ltgFixtureNote.notPriority.ViewCustomAttributes = ""
  807.  
  808.             ' notIsActive
  809.             If Convert.ToString(ltgFixtureNote.notIsActive.CurrentValue) = "1" Then
  810.                 ltgFixtureNote.notIsActive.ViewValue = "Yes"
  811.             Else
  812.                 ltgFixtureNote.notIsActive.ViewValue = "No"
  813.             End If
  814.             ltgFixtureNote.notIsActive.CssStyle = ""
  815.             ltgFixtureNote.notIsActive.CssClass = ""
  816.             ltgFixtureNote.notIsActive.ViewCustomAttributes = ""
  817.  
  818.             ' notCreatedBy
  819.             ltgFixtureNote.notCreatedBy.ViewValue = ltgFixtureNote.notCreatedBy.CurrentValue
  820.             ltgFixtureNote.notCreatedBy.CssStyle = ""
  821.             ltgFixtureNote.notCreatedBy.CssClass = ""
  822.             ltgFixtureNote.notCreatedBy.ViewCustomAttributes = ""
  823.  
  824.             ' notCreatedOn
  825.             ltgFixtureNote.notCreatedOn.ViewValue = ltgFixtureNote.notCreatedOn.CurrentValue
  826.             ltgFixtureNote.notCreatedOn.ViewValue = ew_FormatDateTime(ltgFixtureNote.notCreatedOn.ViewValue, 6)
  827.             ltgFixtureNote.notCreatedOn.CssStyle = ""
  828.             ltgFixtureNote.notCreatedOn.CssClass = ""
  829.             ltgFixtureNote.notCreatedOn.ViewCustomAttributes = ""
  830.  
  831.             ' notModifiedBy
  832.             ltgFixtureNote.notModifiedBy.ViewValue = ltgFixtureNote.notModifiedBy.CurrentValue
  833.             ltgFixtureNote.notModifiedBy.CssStyle = ""
  834.             ltgFixtureNote.notModifiedBy.CssClass = ""
  835.             ltgFixtureNote.notModifiedBy.ViewCustomAttributes = ""
  836.  
  837.             ' notModifiedOn
  838.             ltgFixtureNote.notModifiedOn.ViewValue = ltgFixtureNote.notModifiedOn.CurrentValue
  839.             ltgFixtureNote.notModifiedOn.ViewValue = ew_FormatDateTime(ltgFixtureNote.notModifiedOn.ViewValue, 6)
  840.             ltgFixtureNote.notModifiedOn.CssStyle = ""
  841.             ltgFixtureNote.notModifiedOn.CssClass = ""
  842.             ltgFixtureNote.notModifiedOn.ViewCustomAttributes = ""
  843.  
  844.             ' View refer script
  845.             ' notFixID
  846.  
  847.             ltgFixtureNote.notFixID.HrefValue = ""
  848.  
  849.             ' notTypeID
  850.             ltgFixtureNote.notTypeID.HrefValue = ""
  851.  
  852.             ' notDate
  853.             ltgFixtureNote.notDate.HrefValue = ""
  854.  
  855.             ' notShortDesc
  856.             ltgFixtureNote.notShortDesc.HrefValue = ""
  857.  
  858.             ' notLPRStatusID
  859.             ltgFixtureNote.notLPRStatusID.HrefValue = ""
  860.  
  861.             ' notPriority
  862.             ltgFixtureNote.notPriority.HrefValue = ""
  863.  
  864.             ' notIsActive
  865.             ltgFixtureNote.notIsActive.HrefValue = ""
  866.         End If
  867.  
  868.         ' Row Rendered event
  869.         ltgFixtureNote.Row_Rendered()
  870.     End Sub
  871.  
  872.     '
  873.     ' Set up Master Detail based on querystring parameter
  874.     '
  875.     Sub SetUpMasterDetail()
  876.         Dim bValidMaster As Boolean = False, sMasterTblVar As String
  877.  
  878.         ' Get the keys for master table
  879.         If ew_Get(EW_TABLE_SHOW_MASTER) <> "" Then
  880.             sMasterTblVar = ew_Get(EW_TABLE_SHOW_MASTER)
  881.             If sMasterTblVar = "" Then
  882.                 bValidMaster = True
  883.                 sDbMasterFilter = ""
  884.                 sDbDetailFilter = ""
  885.             End If
  886.             If sMasterTblVar = "ltgFixtureMaster" Then
  887.                 bValidMaster = True
  888.                 sDbMasterFilter = ltgFixtureNote.SqlMasterFilter_ltgFixtureMaster
  889.                 sDbDetailFilter = ltgFixtureNote.SqlDetailFilter_ltgFixtureMaster
  890.                 If ew_Get("lfxID") <> "" Then
  891.                     ltgFixtureMaster.lfxID.QueryStringValue = ew_Get("lfxID")
  892.                     ltgFixtureNote.notFixID.QueryStringValue = ltgFixtureMaster.lfxID.QueryStringValue
  893.                     ltgFixtureNote.notFixID.SessionValue = ltgFixtureNote.notFixID.QueryStringValue
  894.                     If Not IsNumeric(ltgFixtureMaster.lfxID.QueryStringValue) Then bValidMaster = False
  895.                     sDbMasterFilter = sDbMasterFilter.Replace("@lfxID@", ew_AdjustSql(ltgFixtureMaster.lfxID.QueryStringValue))
  896.                     sDbDetailFilter = sDbDetailFilter.Replace("@notFixID@", ew_AdjustSql(ltgFixtureMaster.lfxID.QueryStringValue))
  897.                 Else
  898.                     bValidMaster = False
  899.                 End If
  900.             End If
  901.         End If
  902.         If bValidMaster Then
  903.  
  904.             ' Save current master table
  905.             ltgFixtureNote.CurrentMasterTable = sMasterTblVar
  906.  
  907.             ' Reset start record counter (new master key)
  908.             lStartRec = 1
  909.             ltgFixtureNote.StartRecordNumber = lStartRec
  910.             ltgFixtureNote.MasterFilter = sDbMasterFilter ' Set up master filter
  911.             ltgFixtureNote.DetailFilter = sDbDetailFilter ' Set up detail filter
  912.  
  913.             ' Clear previous master session values
  914.             If sMasterTblVar <> "ltgFixtureMaster" Then
  915.                 If ltgFixtureNote.notFixID.QueryStringValue = "" Then ltgFixtureNote.notFixID.SessionValue = ""
  916.             End If
  917.         End If
  918.     End Sub
  919.  
  920.         ' Page Load event
  921.         Public Sub Page_Load()
  922.  
  923.             'HttpContext.Current.Response.Write("Page Load")
  924.         End Sub
  925.  
  926.         ' Page Unload event
  927.         Public Sub Page_Unload()
  928.  
  929.             'HttpContext.Current.Response.Write("Page Unload")
  930.         End Sub
  931.  
  932.     ' Form Custom Validate event
  933.     Public Function Form_CustomValidate(ByRef CustomError As String) As Boolean
  934.  
  935.         'Return error message in CustomError
  936.         Return True
  937.     End Function
  938.     End Class
  939.  
  940.     '
  941.     ' ASP.NET Page_Load event
  942.     '
  943.  
  944.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  945.         Response.Buffer = EW_RESPONSE_BUFFER
  946.         Response.Cache.SetCacheability(HttpCacheability.NoCache)
  947.  
  948.         ' Page init
  949.         ltgFixtureNote_list = New cltgFixtureNote_list(Me)        
  950.         ltgFixtureNote_list.Page_Init()
  951.  
  952.         ' Page main processing
  953.         ltgFixtureNote_list.Page_Main()
  954.     End Sub
  955.  
  956.     '
  957.     ' ASP.NET Page_Unload event
  958.     '
  959.  
  960.     Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
  961.  
  962.         ' Dispose page object
  963.         If ltgFixtureNote_list IsNot Nothing Then ltgFixtureNote_list.Dispose()
  964.     End Sub
  965. End Class
  966.