home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / ltgFixtureNoteedit.aspx.vb < prev    next >
Text File  |  2014-01-25  |  29KB  |  894 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 ltgFixtureNoteedit
  12.     Inherits AspNetMaker7_tfpssnet
  13.  
  14.     ' Page object
  15.     Public ltgFixtureNote_edit As cltgFixtureNote_edit
  16.  
  17.     '
  18.     ' Page Class
  19.     '
  20.     Class cltgFixtureNote_edit
  21.         Inherits AspNetMakerPage
  22.         Implements IDisposable        
  23.  
  24.         ' Used by system generated functions
  25.         Private RsWrk As Object, sSqlWrk As String, sWhereWrk As String
  26.  
  27.         Private arwrk As Object
  28.  
  29.         Private armultiwrk() As String        
  30.  
  31.         ' Page URL
  32.         Public ReadOnly Property PageUrl() As String
  33.             Get
  34.                 Dim Url As String = ew_CurrentPage() & "?"
  35.                 If 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 = "edit"
  95.             m_PageObjName = "ltgFixtureNote_edit"
  96.             m_PageObjTypeName = "cltgFixtureNote_edit"
  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.         End Sub
  109.  
  110.         '
  111.         '  Subroutine Page_Init
  112.         '  - called before page main
  113.         '  - check Security
  114.         '  - set up response header
  115.         '  - call page load events
  116.         '
  117.         Public Sub Page_Init()
  118.             Security = New cAdvancedSecurity(Me)
  119.             If Not Security.IsLoggedIn() Then Security.AutoLogin()
  120.             If Not Security.IsLoggedIn() Then
  121.                 Security.SaveLastUrl()
  122.                 Page_Terminate("login.aspx")
  123.             End If
  124.  
  125.             ' Table Permission loading event
  126.             Security.TablePermission_Loading()
  127.             Security.LoadCurrentUserLevel(TableName)
  128.  
  129.             ' Table Permission loaded event
  130.             Security.TablePermission_Loaded()
  131.             If Not Security.CanEdit Then
  132.                 Security.SaveLastUrl()
  133.                 Page_Terminate("ltgFixtureNotelist.aspx")
  134.             End If
  135.  
  136.             ' User ID loading event
  137.             Security.UserID_Loading()
  138.             If Security.IsLoggedIn() Then Call Security.LoadUserID()
  139.  
  140.             ' User ID loaded event
  141.             Security.UserID_Loaded()
  142.  
  143.             ' Global page loading event (in ewglobal*.vb)
  144.             ParentPage.Page_Loading()
  145.  
  146.             ' Page load event, used in current page
  147.             Page_Load()
  148.         End Sub
  149.  
  150.         '
  151.         '  Class terminate
  152.         '  - clean up page object
  153.         '
  154.         Public Sub Dispose() Implements IDisposable.Dispose
  155.             Page_Terminate("")
  156.         End Sub
  157.  
  158.         '
  159.         '  Sub Page_Terminate
  160.         '  - called when exit page
  161.         '  - clean up connection and objects
  162.         '  - if URL specified, redirect to URL
  163.         '
  164.         Sub Page_Terminate(url As String)
  165.  
  166.             ' Page unload event, used in current page
  167.             Page_Unload()
  168.  
  169.             ' Global page unloaded event (in ewglobal*.vb)
  170.             ParentPage.Page_Unloaded()
  171.  
  172.             ' Close connection
  173.             Conn.Dispose()
  174.             Security = Nothing
  175.             ltgFixtureNote.Dispose()
  176.             tblEmployees.Dispose()
  177.             ltgFixtureMaster.Dispose()
  178.  
  179.             ' Go to URL if specified
  180.             If url <> "" Then
  181.                 HttpContext.Current.Response.Clear()
  182.                 HttpContext.Current.Response.Redirect(url)
  183.             End If
  184.         End Sub
  185.  
  186.     '
  187.     ' Page main processing
  188.     '
  189.     Sub Page_Main()
  190.  
  191.         ' Load key from QueryString
  192.         If ew_Get("notID") <> "" Then
  193.             ltgFixtureNote.notID.QueryStringValue = ew_Get("notID")
  194.         End If
  195.  
  196.         ' Create form object
  197.         ObjForm = New cFormObj
  198.         If ObjForm.GetValue("a_edit") <> "" Then
  199.             ltgFixtureNote.CurrentAction = ObjForm.GetValue("a_edit") ' Get action code
  200.             LoadFormValues() ' Get form values
  201.  
  202.             ' Validate Form
  203.             If Not ValidateForm() Then
  204.                 ltgFixtureNote.CurrentAction = "" ' Form error, reset action
  205.                 Message = ParentPage.gsFormError
  206.                 LoadRow() ' Restore row
  207.                 RestoreFormValues() ' Restore form values if validate failed
  208.             End If
  209.         Else
  210.             ltgFixtureNote.CurrentAction = "I" ' Default action is display
  211.         End If
  212.  
  213.         ' Check if valid key
  214.         If ew_Empty(ltgFixtureNote.notID.CurrentValue) Then Page_Terminate("ltgFixtureNotelist.aspx") ' Invalid key, return to list
  215.         Select Case ltgFixtureNote.CurrentAction
  216.             Case "I" ' Get a record to display
  217.                 If Not LoadRow() Then ' Load Record based on key
  218.                     Message = "No records found" ' No record found
  219.                     Page_Terminate("ltgFixtureNotelist.aspx") ' No matching record, return to list
  220.                 End If
  221.             Case "U" ' Update
  222.                 ltgFixtureNote.SendEmail = True ' Send email on update success
  223.                 If EditRow() Then ' Update Record based on key
  224.                     Message = "Update succeeded" ' Update success
  225.                     Dim sReturnUrl As String = ltgFixtureNote.ReturnUrl
  226.                     Page_Terminate(sReturnUrl) ' Return to caller
  227.                 Else
  228.                     LoadRow() ' Restore row
  229.                     RestoreFormValues() ' Restore form values if update failed
  230.                 End If
  231.         End Select
  232.  
  233.         ' Render the record
  234.         ltgFixtureNote.RowType = EW_ROWTYPE_EDIT ' Render as edit
  235.  
  236.         ' Render row
  237.         RenderRow()
  238.     End Sub
  239.  
  240.     '
  241.     ' Get upload file
  242.     '
  243.     Sub GetUploadFiles()
  244.  
  245.         ' Get upload data
  246.     End Sub
  247.  
  248.     '
  249.     ' Load default values
  250.     '
  251.     Sub LoadDefaultValues()
  252.     End Sub
  253.  
  254.     '
  255.     ' Load form values
  256.     '
  257.     Sub LoadFormValues()
  258.         ltgFixtureNote.notFixID.FormValue = ObjForm.GetValue("x_notFixID")
  259.         ltgFixtureNote.notFixID.OldValue = ObjForm.GetValue("o_notFixID")
  260.         ltgFixtureNote.notTypeID.FormValue = ObjForm.GetValue("x_notTypeID")
  261.         ltgFixtureNote.notTypeID.OldValue = ObjForm.GetValue("o_notTypeID")
  262.         ltgFixtureNote.notDate.FormValue = ObjForm.GetValue("x_notDate")
  263.         ltgFixtureNote.notDate.CurrentValue = ew_UnFormatDateTime(ltgFixtureNote.notDate.CurrentValue, 6)
  264.         ltgFixtureNote.notDate.OldValue = ObjForm.GetValue("o_notDate")
  265.         ltgFixtureNote.notShortDesc.FormValue = ObjForm.GetValue("x_notShortDesc")
  266.         ltgFixtureNote.notShortDesc.OldValue = ObjForm.GetValue("o_notShortDesc")
  267.         ltgFixtureNote.notNote.FormValue = ObjForm.GetValue("x_notNote")
  268.         ltgFixtureNote.notNote.OldValue = ObjForm.GetValue("o_notNote")
  269.         ltgFixtureNote.notLPRStatusID.FormValue = ObjForm.GetValue("x_notLPRStatusID")
  270.         ltgFixtureNote.notLPRStatusID.OldValue = ObjForm.GetValue("o_notLPRStatusID")
  271.         ltgFixtureNote.notPriority.FormValue = ObjForm.GetValue("x_notPriority")
  272.         ltgFixtureNote.notPriority.OldValue = ObjForm.GetValue("o_notPriority")
  273.         ltgFixtureNote.notIsActive.FormValue = ObjForm.GetValue("x_notIsActive")
  274.         ltgFixtureNote.notIsActive.OldValue = ObjForm.GetValue("o_notIsActive")
  275.         ltgFixtureNote.notCreatedBy.FormValue = ObjForm.GetValue("x_notCreatedBy")
  276.         ltgFixtureNote.notCreatedBy.OldValue = ObjForm.GetValue("o_notCreatedBy")
  277.         ltgFixtureNote.notCreatedOn.FormValue = ObjForm.GetValue("x_notCreatedOn")
  278.         ltgFixtureNote.notCreatedOn.CurrentValue = ew_UnFormatDateTime(ltgFixtureNote.notCreatedOn.CurrentValue, 6)
  279.         ltgFixtureNote.notCreatedOn.OldValue = ObjForm.GetValue("o_notCreatedOn")
  280.         ltgFixtureNote.notModifiedBy.FormValue = ObjForm.GetValue("x_notModifiedBy")
  281.         ltgFixtureNote.notModifiedBy.OldValue = ObjForm.GetValue("o_notModifiedBy")
  282.         ltgFixtureNote.notModifiedOn.FormValue = ObjForm.GetValue("x_notModifiedOn")
  283.         ltgFixtureNote.notModifiedOn.CurrentValue = ew_UnFormatDateTime(ltgFixtureNote.notModifiedOn.CurrentValue, 6)
  284.         ltgFixtureNote.notModifiedOn.OldValue = ObjForm.GetValue("o_notModifiedOn")
  285.         ltgFixtureNote.notID.FormValue = ObjForm.GetValue("x_notID")
  286.     End Sub
  287.  
  288.     '
  289.     ' Restore form values
  290.     '
  291.     Sub RestoreFormValues()
  292.         ltgFixtureNote.notFixID.CurrentValue = ltgFixtureNote.notFixID.FormValue
  293.         ltgFixtureNote.notTypeID.CurrentValue = ltgFixtureNote.notTypeID.FormValue
  294.         ltgFixtureNote.notDate.CurrentValue = ltgFixtureNote.notDate.FormValue
  295.         ltgFixtureNote.notDate.CurrentValue = ew_UnFormatDateTime(ltgFixtureNote.notDate.CurrentValue, 6)
  296.         ltgFixtureNote.notShortDesc.CurrentValue = ltgFixtureNote.notShortDesc.FormValue
  297.         ltgFixtureNote.notNote.CurrentValue = ltgFixtureNote.notNote.FormValue
  298.         ltgFixtureNote.notLPRStatusID.CurrentValue = ltgFixtureNote.notLPRStatusID.FormValue
  299.         ltgFixtureNote.notPriority.CurrentValue = ltgFixtureNote.notPriority.FormValue
  300.         ltgFixtureNote.notIsActive.CurrentValue = ltgFixtureNote.notIsActive.FormValue
  301.         ltgFixtureNote.notCreatedBy.CurrentValue = ltgFixtureNote.notCreatedBy.FormValue
  302.         ltgFixtureNote.notCreatedOn.CurrentValue = ltgFixtureNote.notCreatedOn.FormValue
  303.         ltgFixtureNote.notCreatedOn.CurrentValue = ew_UnFormatDateTime(ltgFixtureNote.notCreatedOn.CurrentValue, 6)
  304.         ltgFixtureNote.notModifiedBy.CurrentValue = ltgFixtureNote.notModifiedBy.FormValue
  305.         ltgFixtureNote.notModifiedOn.CurrentValue = ltgFixtureNote.notModifiedOn.FormValue
  306.         ltgFixtureNote.notModifiedOn.CurrentValue = ew_UnFormatDateTime(ltgFixtureNote.notModifiedOn.CurrentValue, 6)
  307.         ltgFixtureNote.notID.CurrentValue = ltgFixtureNote.notID.FormValue
  308.     End Sub
  309.  
  310.     '
  311.     ' Load row based on key values
  312.     '
  313.     Function LoadRow() As Boolean
  314.         Dim RsRow As OleDbDataReader
  315.         Dim sFilter As String = ltgFixtureNote.KeyFilter
  316.  
  317.         ' Row Selecting event
  318.         ltgFixtureNote.Row_Selecting(sFilter)
  319.  
  320.         ' Load SQL based on filter
  321.         ltgFixtureNote.CurrentFilter = sFilter
  322.         Dim sSql As String = ltgFixtureNote.SQL
  323.  
  324.         ' Write SQL for debug
  325.         If EW_DEBUG_ENABLED Then ew_Write(sSql)
  326.         Try
  327.             RsRow = Conn.GetTempDataReader(sSql)    
  328.             If Not RsRow.Read() Then
  329.                 Return False
  330.             Else                
  331.                 LoadRowValues(RsRow) ' Load row values
  332.  
  333.                 ' Row Selected event
  334.                 ltgFixtureNote.Row_Selected(RsRow)
  335.                 Return True    
  336.             End If
  337.         Catch
  338.             If EW_DEBUG_ENABLED Then Throw
  339.             Return False
  340.         Finally
  341.             Conn.CloseTempDataReader()
  342.         End Try
  343.     End Function
  344.  
  345.     '
  346.     ' Load row values from recordset
  347.     '
  348.     Sub LoadRowValues(ByRef RsRow As OleDbDataReader)
  349.         ltgFixtureNote.notID.DbValue = RsRow("notID")
  350.         ltgFixtureNote.notFixID.DbValue = RsRow("notFixID")
  351.         ltgFixtureNote.notTypeID.DbValue = RsRow("notTypeID")
  352.         ltgFixtureNote.notDate.DbValue = RsRow("notDate")
  353.         ltgFixtureNote.notShortDesc.DbValue = RsRow("notShortDesc")
  354.         ltgFixtureNote.notNote.DbValue = RsRow("notNote")
  355.         ltgFixtureNote.notLPRStatusID.DbValue = RsRow("notLPRStatusID")
  356.         ltgFixtureNote.notPriority.DbValue = RsRow("notPriority")
  357.         ltgFixtureNote.notIsActive.DbValue = IIf(ew_ConvertToBool(RsRow("notIsActive")), "1", "0")
  358.         ltgFixtureNote.notCreatedBy.DbValue = RsRow("notCreatedBy")
  359.         ltgFixtureNote.notCreatedOn.DbValue = RsRow("notCreatedOn")
  360.         ltgFixtureNote.notModifiedBy.DbValue = RsRow("notModifiedBy")
  361.         ltgFixtureNote.notModifiedOn.DbValue = RsRow("notModifiedOn")
  362.     End Sub
  363.  
  364.     '
  365.     ' Render row values based on field settings
  366.     '
  367.     Sub RenderRow()
  368.  
  369.         ' Row Rendering event
  370.         ltgFixtureNote.Row_Rendering()
  371.  
  372.         '
  373.         '  Common render codes for all row types
  374.         '
  375.         ' notFixID
  376.  
  377.         ltgFixtureNote.notFixID.CellCssStyle = ""
  378.         ltgFixtureNote.notFixID.CellCssClass = ""
  379.  
  380.         ' notTypeID
  381.         ltgFixtureNote.notTypeID.CellCssStyle = ""
  382.         ltgFixtureNote.notTypeID.CellCssClass = ""
  383.  
  384.         ' notDate
  385.         ltgFixtureNote.notDate.CellCssStyle = ""
  386.         ltgFixtureNote.notDate.CellCssClass = ""
  387.  
  388.         ' notShortDesc
  389.         ltgFixtureNote.notShortDesc.CellCssStyle = ""
  390.         ltgFixtureNote.notShortDesc.CellCssClass = ""
  391.  
  392.         ' notNote
  393.         ltgFixtureNote.notNote.CellCssStyle = ""
  394.         ltgFixtureNote.notNote.CellCssClass = ""
  395.  
  396.         ' notLPRStatusID
  397.         ltgFixtureNote.notLPRStatusID.CellCssStyle = ""
  398.         ltgFixtureNote.notLPRStatusID.CellCssClass = ""
  399.  
  400.         ' notPriority
  401.         ltgFixtureNote.notPriority.CellCssStyle = ""
  402.         ltgFixtureNote.notPriority.CellCssClass = ""
  403.  
  404.         ' notIsActive
  405.         ltgFixtureNote.notIsActive.CellCssStyle = ""
  406.         ltgFixtureNote.notIsActive.CellCssClass = ""
  407.  
  408.         ' notCreatedBy
  409.         ltgFixtureNote.notCreatedBy.CellCssStyle = ""
  410.         ltgFixtureNote.notCreatedBy.CellCssClass = ""
  411.  
  412.         ' notCreatedOn
  413.         ltgFixtureNote.notCreatedOn.CellCssStyle = ""
  414.         ltgFixtureNote.notCreatedOn.CellCssClass = ""
  415.  
  416.         ' notModifiedBy
  417.         ltgFixtureNote.notModifiedBy.CellCssStyle = ""
  418.         ltgFixtureNote.notModifiedBy.CellCssClass = ""
  419.  
  420.         ' notModifiedOn
  421.         ltgFixtureNote.notModifiedOn.CellCssStyle = ""
  422.         ltgFixtureNote.notModifiedOn.CellCssClass = ""
  423.  
  424.         '
  425.         '  View  Row
  426.         '
  427.  
  428.         If ltgFixtureNote.RowType = EW_ROWTYPE_VIEW Then ' View row
  429.  
  430.             ' notID
  431.             ltgFixtureNote.notID.ViewValue = ltgFixtureNote.notID.CurrentValue
  432.             ltgFixtureNote.notID.CssStyle = ""
  433.             ltgFixtureNote.notID.CssClass = ""
  434.             ltgFixtureNote.notID.ViewCustomAttributes = ""
  435.  
  436.             ' notFixID
  437.             ltgFixtureNote.notFixID.ViewValue = ltgFixtureNote.notFixID.CurrentValue
  438.             ltgFixtureNote.notFixID.CssStyle = ""
  439.             ltgFixtureNote.notFixID.CssClass = ""
  440.             ltgFixtureNote.notFixID.ViewCustomAttributes = ""
  441.  
  442.             ' notTypeID
  443.             If ew_NotEmpty(ltgFixtureNote.notTypeID.CurrentValue) Then
  444.                 sSqlWrk = "SELECT [ntyDescription] FROM [ltgFixtureNoteType] WHERE [ntyID] = " & ew_AdjustSql(ltgFixtureNote.notTypeID.CurrentValue) & ""
  445.                 sSqlWrk = sSqlWrk & " AND (" & "[ntyIsActive]=True" & ")"
  446.                 sSqlWrk = sSqlWrk & " ORDER BY [ntyDescription] "
  447.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  448.                 If RsWrk.Read() Then
  449.                     ltgFixtureNote.notTypeID.ViewValue = RsWrk("ntyDescription")
  450.                 Else
  451.                     ltgFixtureNote.notTypeID.ViewValue = ltgFixtureNote.notTypeID.CurrentValue
  452.                 End If
  453.                 Conn.CloseTempDataReader()
  454.             Else
  455.                 ltgFixtureNote.notTypeID.ViewValue = System.DBNull.Value
  456.             End If
  457.             ltgFixtureNote.notTypeID.CssStyle = ""
  458.             ltgFixtureNote.notTypeID.CssClass = ""
  459.             ltgFixtureNote.notTypeID.ViewCustomAttributes = ""
  460.  
  461.             ' notDate
  462.             ltgFixtureNote.notDate.ViewValue = ltgFixtureNote.notDate.CurrentValue
  463.             ltgFixtureNote.notDate.ViewValue = ew_FormatDateTime(ltgFixtureNote.notDate.ViewValue, 6)
  464.             ltgFixtureNote.notDate.CssStyle = ""
  465.             ltgFixtureNote.notDate.CssClass = ""
  466.             ltgFixtureNote.notDate.ViewCustomAttributes = ""
  467.  
  468.             ' notShortDesc
  469.             ltgFixtureNote.notShortDesc.ViewValue = ltgFixtureNote.notShortDesc.CurrentValue
  470.             ltgFixtureNote.notShortDesc.CssStyle = ""
  471.             ltgFixtureNote.notShortDesc.CssClass = ""
  472.             ltgFixtureNote.notShortDesc.ViewCustomAttributes = ""
  473.  
  474.             ' notNote
  475.             ltgFixtureNote.notNote.ViewValue = ltgFixtureNote.notNote.CurrentValue
  476.             ltgFixtureNote.notNote.CssStyle = ""
  477.             ltgFixtureNote.notNote.CssClass = ""
  478.             ltgFixtureNote.notNote.ViewCustomAttributes = ""
  479.  
  480.             ' notLPRStatusID
  481.             If ew_NotEmpty(ltgFixtureNote.notLPRStatusID.CurrentValue) Then
  482.                 sSqlWrk = "SELECT [lstDescription] FROM [tblLPRStatus] WHERE [lstID] = " & ew_AdjustSql(ltgFixtureNote.notLPRStatusID.CurrentValue) & ""
  483.                 sSqlWrk = sSqlWrk & " AND (" & "[lstIsActive]=True" & ")"
  484.                 sSqlWrk = sSqlWrk & " ORDER BY [lstDescription] "
  485.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  486.                 If RsWrk.Read() Then
  487.                     ltgFixtureNote.notLPRStatusID.ViewValue = RsWrk("lstDescription")
  488.                 Else
  489.                     ltgFixtureNote.notLPRStatusID.ViewValue = ltgFixtureNote.notLPRStatusID.CurrentValue
  490.                 End If
  491.                 Conn.CloseTempDataReader()
  492.             Else
  493.                 ltgFixtureNote.notLPRStatusID.ViewValue = System.DBNull.Value
  494.             End If
  495.             ltgFixtureNote.notLPRStatusID.CssStyle = ""
  496.             ltgFixtureNote.notLPRStatusID.CssClass = ""
  497.             ltgFixtureNote.notLPRStatusID.ViewCustomAttributes = ""
  498.  
  499.             ' notPriority
  500.             If Not IsDBNull(ltgFixtureNote.notPriority.CurrentValue) Then
  501.                 Select Case ltgFixtureNote.notPriority.CurrentValue
  502.                     Case "1"
  503.                         ltgFixtureNote.notPriority.ViewValue = "High"
  504.                     Case "2"
  505.                         ltgFixtureNote.notPriority.ViewValue = "Medium"
  506.                     Case "3"
  507.                         ltgFixtureNote.notPriority.ViewValue = "Low"
  508.                     Case Else
  509.                         ltgFixtureNote.notPriority.ViewValue = ltgFixtureNote.notPriority.CurrentValue
  510.                 End Select
  511.             Else
  512.                 ltgFixtureNote.notPriority.ViewValue = System.DBNull.Value
  513.             End If
  514.             ltgFixtureNote.notPriority.CssStyle = ""
  515.             ltgFixtureNote.notPriority.CssClass = ""
  516.             ltgFixtureNote.notPriority.ViewCustomAttributes = ""
  517.  
  518.             ' notIsActive
  519.             If Convert.ToString(ltgFixtureNote.notIsActive.CurrentValue) = "1" Then
  520.                 ltgFixtureNote.notIsActive.ViewValue = "Yes"
  521.             Else
  522.                 ltgFixtureNote.notIsActive.ViewValue = "No"
  523.             End If
  524.             ltgFixtureNote.notIsActive.CssStyle = ""
  525.             ltgFixtureNote.notIsActive.CssClass = ""
  526.             ltgFixtureNote.notIsActive.ViewCustomAttributes = ""
  527.  
  528.             ' notCreatedBy
  529.             ltgFixtureNote.notCreatedBy.ViewValue = ltgFixtureNote.notCreatedBy.CurrentValue
  530.             ltgFixtureNote.notCreatedBy.CssStyle = ""
  531.             ltgFixtureNote.notCreatedBy.CssClass = ""
  532.             ltgFixtureNote.notCreatedBy.ViewCustomAttributes = ""
  533.  
  534.             ' notCreatedOn
  535.             ltgFixtureNote.notCreatedOn.ViewValue = ltgFixtureNote.notCreatedOn.CurrentValue
  536.             ltgFixtureNote.notCreatedOn.ViewValue = ew_FormatDateTime(ltgFixtureNote.notCreatedOn.ViewValue, 6)
  537.             ltgFixtureNote.notCreatedOn.CssStyle = ""
  538.             ltgFixtureNote.notCreatedOn.CssClass = ""
  539.             ltgFixtureNote.notCreatedOn.ViewCustomAttributes = ""
  540.  
  541.             ' notModifiedBy
  542.             ltgFixtureNote.notModifiedBy.ViewValue = ltgFixtureNote.notModifiedBy.CurrentValue
  543.             ltgFixtureNote.notModifiedBy.CssStyle = ""
  544.             ltgFixtureNote.notModifiedBy.CssClass = ""
  545.             ltgFixtureNote.notModifiedBy.ViewCustomAttributes = ""
  546.  
  547.             ' notModifiedOn
  548.             ltgFixtureNote.notModifiedOn.ViewValue = ltgFixtureNote.notModifiedOn.CurrentValue
  549.             ltgFixtureNote.notModifiedOn.ViewValue = ew_FormatDateTime(ltgFixtureNote.notModifiedOn.ViewValue, 6)
  550.             ltgFixtureNote.notModifiedOn.CssStyle = ""
  551.             ltgFixtureNote.notModifiedOn.CssClass = ""
  552.             ltgFixtureNote.notModifiedOn.ViewCustomAttributes = ""
  553.  
  554.             ' View refer script
  555.             ' notFixID
  556.  
  557.             ltgFixtureNote.notFixID.HrefValue = ""
  558.  
  559.             ' notTypeID
  560.             ltgFixtureNote.notTypeID.HrefValue = ""
  561.  
  562.             ' notDate
  563.             ltgFixtureNote.notDate.HrefValue = ""
  564.  
  565.             ' notShortDesc
  566.             ltgFixtureNote.notShortDesc.HrefValue = ""
  567.  
  568.             ' notNote
  569.             ltgFixtureNote.notNote.HrefValue = ""
  570.  
  571.             ' notLPRStatusID
  572.             ltgFixtureNote.notLPRStatusID.HrefValue = ""
  573.  
  574.             ' notPriority
  575.             ltgFixtureNote.notPriority.HrefValue = ""
  576.  
  577.             ' notIsActive
  578.             ltgFixtureNote.notIsActive.HrefValue = ""
  579.  
  580.             ' notCreatedBy
  581.             ltgFixtureNote.notCreatedBy.HrefValue = ""
  582.  
  583.             ' notCreatedOn
  584.             ltgFixtureNote.notCreatedOn.HrefValue = ""
  585.  
  586.             ' notModifiedBy
  587.             ltgFixtureNote.notModifiedBy.HrefValue = ""
  588.  
  589.             ' notModifiedOn
  590.             ltgFixtureNote.notModifiedOn.HrefValue = ""
  591.  
  592.         '
  593.         '  Edit Row
  594.         '
  595.  
  596.         ElseIf ltgFixtureNote.RowType = EW_ROWTYPE_EDIT Then ' Edit row
  597.  
  598.             ' notFixID
  599.             ltgFixtureNote.notFixID.EditCustomAttributes = ""
  600.             If ltgFixtureNote.notFixID.SessionValue <> "" Then
  601.                 ltgFixtureNote.notFixID.CurrentValue = ltgFixtureNote.notFixID.SessionValue
  602.             ltgFixtureNote.notFixID.ViewValue = ltgFixtureNote.notFixID.CurrentValue
  603.             ltgFixtureNote.notFixID.CssStyle = ""
  604.             ltgFixtureNote.notFixID.CssClass = ""
  605.             ltgFixtureNote.notFixID.ViewCustomAttributes = ""
  606.             Else
  607.             ltgFixtureNote.notFixID.EditValue = ew_HtmlEncode(ltgFixtureNote.notFixID.CurrentValue)
  608.             End If
  609.  
  610.             ' notTypeID
  611.             ltgFixtureNote.notTypeID.EditCustomAttributes = ""
  612.             sSqlWrk = "SELECT [ntyID], [ntyDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [ltgFixtureNoteType]"
  613.             sWhereWrk = ""
  614.             If sWhereWrk <> "" Then sWhereWrk = "(" & sWhereWrk & ") AND "
  615.             sWhereWrk = sWhereWrk & "(" & "[ntyIsActive]=True" & ")"
  616.             If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  617.             sSqlWrk = sSqlWrk & " ORDER BY [ntyDescription] "
  618.             arwrk = Conn.GetRows(sSqlWrk)
  619.             arwrk.Insert(0, New Object(){"", "Please Select"}) 
  620.             ltgFixtureNote.notTypeID.EditValue = arwrk
  621.  
  622.             ' notDate
  623.             ' notShortDesc
  624.  
  625.             ltgFixtureNote.notShortDesc.EditCustomAttributes = ""
  626.             ltgFixtureNote.notShortDesc.EditValue = ew_HtmlEncode(ltgFixtureNote.notShortDesc.CurrentValue)
  627.  
  628.             ' notNote
  629.             ltgFixtureNote.notNote.EditCustomAttributes = ""
  630.             ltgFixtureNote.notNote.EditValue = ew_HtmlEncode(ltgFixtureNote.notNote.CurrentValue)
  631.  
  632.             ' notLPRStatusID
  633.             ltgFixtureNote.notLPRStatusID.EditCustomAttributes = ""
  634.             sSqlWrk = "SELECT [lstID], [lstDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblLPRStatus]"
  635.             sWhereWrk = ""
  636.             If sWhereWrk <> "" Then sWhereWrk = "(" & sWhereWrk & ") AND "
  637.             sWhereWrk = sWhereWrk & "(" & "[lstIsActive]=True" & ")"
  638.             If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  639.             sSqlWrk = sSqlWrk & " ORDER BY [lstDescription] "
  640.             arwrk = Conn.GetRows(sSqlWrk)
  641.             arwrk.Insert(0, New Object(){"", "Please Select"}) 
  642.             ltgFixtureNote.notLPRStatusID.EditValue = arwrk
  643.  
  644.             ' notPriority
  645.             ltgFixtureNote.notPriority.EditCustomAttributes = ""
  646.             arwrk = New ArrayList
  647.             arwrk.Add(New String() {"1", "High"})
  648.             arwrk.Add(New String() {"2", "Medium"})
  649.             arwrk.Add(New String() {"3", "Low"})
  650.             arwrk.Insert(0, New String() {"", "Please Select"})
  651.             ltgFixtureNote.notPriority.EditValue = arwrk
  652.  
  653.             ' notIsActive
  654.             ltgFixtureNote.notIsActive.EditCustomAttributes = ""
  655.  
  656.             ' notCreatedBy
  657.             ' notCreatedOn
  658.             ' notModifiedBy
  659.             ' notModifiedOn
  660.             ' Edit refer script
  661.             ' notFixID
  662.  
  663.             ltgFixtureNote.notFixID.HrefValue = ""
  664.  
  665.             ' notTypeID
  666.             ltgFixtureNote.notTypeID.HrefValue = ""
  667.  
  668.             ' notDate
  669.             ltgFixtureNote.notDate.HrefValue = ""
  670.  
  671.             ' notShortDesc
  672.             ltgFixtureNote.notShortDesc.HrefValue = ""
  673.  
  674.             ' notNote
  675.             ltgFixtureNote.notNote.HrefValue = ""
  676.  
  677.             ' notLPRStatusID
  678.             ltgFixtureNote.notLPRStatusID.HrefValue = ""
  679.  
  680.             ' notPriority
  681.             ltgFixtureNote.notPriority.HrefValue = ""
  682.  
  683.             ' notIsActive
  684.             ltgFixtureNote.notIsActive.HrefValue = ""
  685.  
  686.             ' notCreatedBy
  687.             ltgFixtureNote.notCreatedBy.HrefValue = ""
  688.  
  689.             ' notCreatedOn
  690.             ltgFixtureNote.notCreatedOn.HrefValue = ""
  691.  
  692.             ' notModifiedBy
  693.             ltgFixtureNote.notModifiedBy.HrefValue = ""
  694.  
  695.             ' notModifiedOn
  696.             ltgFixtureNote.notModifiedOn.HrefValue = ""
  697.         End If
  698.  
  699.         ' Row Rendered event
  700.         ltgFixtureNote.Row_Rendered()
  701.     End Sub
  702.  
  703.     '
  704.     ' Validate form
  705.     '
  706.     Function ValidateForm() As Boolean
  707.  
  708.         ' Initialize
  709.         ParentPage.gsFormError = ""
  710.  
  711.         ' Check if validation required
  712.         If Not EW_SERVER_VALIDATE Then Return (ParentPage.gsFormError = "")
  713.         If ew_Empty(ltgFixtureNote.notFixID.FormValue) Then
  714.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  715.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Fixture"
  716.         End If
  717.         If Not ew_CheckInteger(ltgFixtureNote.notFixID.FormValue) Then
  718.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  719.             ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect integer - Fixture"
  720.         End If
  721.         If ew_Empty(ltgFixtureNote.notTypeID.FormValue) Then
  722.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  723.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Note Type"
  724.         End If
  725.         If ew_Empty(ltgFixtureNote.notShortDesc.FormValue) Then
  726.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  727.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Short Desc"
  728.         End If
  729.  
  730.         ' Return validate result
  731.         Dim Valid As Boolean = (ParentPage.gsFormError = "")
  732.  
  733.         ' Form_CustomValidate event
  734.         Dim sFormCustomError As String = ""
  735.         Valid = Valid And Form_CustomValidate(sFormCustomError)
  736.         If sFormCustomError <> "" Then
  737.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  738.             ParentPage.gsFormError = ParentPage.gsFormError & sFormCustomError
  739.         End If
  740.         Return Valid
  741.     End Function
  742.  
  743.     '
  744.     ' Update record based on key values
  745.     '
  746.     Function EditRow() As Boolean
  747.         Dim RsEdit As OleDbDataReader, RsChk As OleDbDataReader
  748.         Dim sSql As String, sFilter As String
  749.         Dim sSqlChk As String, sFilterChk As String
  750.         Dim bUpdateRow As Boolean
  751.         Dim RsOld As OrderedDictionary
  752.         Dim sIdxErrMsg As String
  753.         Dim Rs As New OrderedDictionary
  754.         sFilter = ltgFixtureNote.KeyFilter
  755.         ltgFixtureNote.CurrentFilter  = sFilter
  756.         sSql = ltgFixtureNote.SQL
  757.         Try
  758.             RsEdit = Conn.GetDataReader(sSql) 
  759.         Catch e As Exception
  760.             If EW_DEBUG_ENABLED Then Throw
  761.             Message = e.Message
  762.             RsEdit.Close()
  763.             EditRow = False
  764.         End Try
  765.         If Not RsEdit.Read() Then
  766.             RsEdit.Close()
  767.             EditRow = False ' Update Failed
  768.         Else
  769.             RsOld = Conn.GetRow(RsEdit)
  770.             RsEdit.Close()
  771.  
  772.             ' notFixID
  773.             ltgFixtureNote.notFixID.SetDbValue(ltgFixtureNote.notFixID.CurrentValue, System.DBNull.Value)
  774.             Rs("notFixID") = ltgFixtureNote.notFixID.DbValue
  775.  
  776.             ' notTypeID
  777.             ltgFixtureNote.notTypeID.SetDbValue(ltgFixtureNote.notTypeID.CurrentValue, System.DBNull.Value)
  778.             Rs("notTypeID") = ltgFixtureNote.notTypeID.DbValue
  779.  
  780.             ' notDate
  781.             ltgFixtureNote.notDate.DbValue = ew_CurrentDate()
  782.             Rs("notDate") = ltgFixtureNote.notDate.DbValue
  783.  
  784.             ' notShortDesc
  785.             ltgFixtureNote.notShortDesc.SetDbValue(ltgFixtureNote.notShortDesc.CurrentValue, System.DBNull.Value)
  786.             Rs("notShortDesc") = ltgFixtureNote.notShortDesc.DbValue
  787.  
  788.             ' notNote
  789.             ltgFixtureNote.notNote.SetDbValue(ltgFixtureNote.notNote.CurrentValue, System.DBNull.Value)
  790.             Rs("notNote") = ltgFixtureNote.notNote.DbValue
  791.  
  792.             ' notLPRStatusID
  793.             ltgFixtureNote.notLPRStatusID.SetDbValue(ltgFixtureNote.notLPRStatusID.CurrentValue, System.DBNull.Value)
  794.             Rs("notLPRStatusID") = ltgFixtureNote.notLPRStatusID.DbValue
  795.  
  796.             ' notPriority
  797.             ltgFixtureNote.notPriority.SetDbValue(ltgFixtureNote.notPriority.CurrentValue, System.DBNull.Value)
  798.             Rs("notPriority") = ltgFixtureNote.notPriority.DbValue
  799.  
  800.             ' notIsActive
  801.             ltgFixtureNote.notIsActive.SetDbValue((ltgFixtureNote.notIsActive.CurrentValue <> "" And Not IsDBNull(ltgFixtureNote.notIsActive.CurrentValue)), System.DBNull.Value)
  802.             Rs("notIsActive") = ltgFixtureNote.notIsActive.DbValue
  803.  
  804.             ' notCreatedBy
  805.             ltgFixtureNote.notCreatedBy.DbValue = CurrentUserName()
  806.             Rs("notCreatedBy") = ltgFixtureNote.notCreatedBy.DbValue
  807.  
  808.             ' notCreatedOn
  809.             ltgFixtureNote.notCreatedOn.DbValue = ew_CurrentDate()
  810.             Rs("notCreatedOn") = ltgFixtureNote.notCreatedOn.DbValue
  811.  
  812.             ' notModifiedBy
  813.             ltgFixtureNote.notModifiedBy.DbValue = CurrentUserName()
  814.             Rs("notModifiedBy") = ltgFixtureNote.notModifiedBy.DbValue
  815.  
  816.             ' notModifiedOn
  817.             ltgFixtureNote.notModifiedOn.DbValue = ew_CurrentDate()
  818.             Rs("notModifiedOn") = ltgFixtureNote.notModifiedOn.DbValue
  819.  
  820.             ' Row Updating event
  821.             bUpdateRow = ltgFixtureNote.Row_Updating(RsOld, Rs)
  822.             If bUpdateRow Then
  823.                 Try
  824.                     ltgFixtureNote.Update(Rs)
  825.                     EditRow = True
  826.                 Catch e As Exception
  827.                     If EW_DEBUG_ENABLED Then Throw
  828.                     Message = e.Message
  829.                     EditRow = False
  830.                 End Try
  831.             Else
  832.                 If ltgFixtureNote.CancelMessage <> "" Then
  833.                     Message = ltgFixtureNote.CancelMessage
  834.                     ltgFixtureNote.CancelMessage = ""
  835.                 Else
  836.                     Message = "Update cancelled"
  837.                 End If
  838.                 EditRow = False
  839.             End If
  840.         End If
  841.  
  842.         ' Row Updated event
  843.         If EditRow Then
  844.             ltgFixtureNote.Row_Updated(RsOld, Rs)
  845.         End If
  846.     End Function
  847.  
  848.         ' Page Load event
  849.         Public Sub Page_Load()
  850.  
  851.             'HttpContext.Current.Response.Write("Page Load")
  852.         End Sub
  853.  
  854.         ' Page Unload event
  855.         Public Sub Page_Unload()
  856.  
  857.             'HttpContext.Current.Response.Write("Page Unload")
  858.         End Sub
  859.  
  860.     ' Form Custom Validate event
  861.     Public Function Form_CustomValidate(ByRef CustomError As String) As Boolean
  862.  
  863.         'Return error message in CustomError
  864.         Return True
  865.     End Function
  866.     End Class
  867.  
  868.     '
  869.     ' ASP.NET Page_Load event
  870.     '
  871.  
  872.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  873.         Response.Buffer = EW_RESPONSE_BUFFER
  874.         Response.Cache.SetCacheability(HttpCacheability.NoCache)
  875.  
  876.         ' Page init
  877.         ltgFixtureNote_edit = New cltgFixtureNote_edit(Me)        
  878.         ltgFixtureNote_edit.Page_Init()
  879.  
  880.         ' Page main processing
  881.         ltgFixtureNote_edit.Page_Main()
  882.     End Sub
  883.  
  884.     '
  885.     ' ASP.NET Page_Unload event
  886.     '
  887.  
  888.     Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
  889.  
  890.         ' Dispose page object
  891.         If ltgFixtureNote_edit IsNot Nothing Then ltgFixtureNote_edit.Dispose()
  892.     End Sub
  893. End Class
  894.