home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / ltgFixtureNoteadd.aspx.vb < prev    next >
Text File  |  2014-01-25  |  25KB  |  788 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 ltgFixtureNoteadd
  12.     Inherits AspNetMaker7_tfpssnet
  13.  
  14.     ' Page object
  15.     Public ltgFixtureNote_add As cltgFixtureNote_add
  16.  
  17.     '
  18.     ' Page Class
  19.     '
  20.     Class cltgFixtureNote_add
  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 = "add"
  95.             m_PageObjName = "ltgFixtureNote_add"
  96.             m_PageObjTypeName = "cltgFixtureNote_add"
  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.CanAdd 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.     Public x_ewPriv As Integer
  187.  
  188.     '
  189.     ' Page main processing
  190.     '
  191.     Sub Page_Main()
  192.  
  193.         ' Load key values from QueryString
  194.         Dim bCopy As Boolean = True
  195.         If ew_Get("notID") <> "" Then
  196.             ltgFixtureNote.notID.QueryStringValue = ew_Get("notID")
  197.         Else
  198.             bCopy = False
  199.         End If
  200.  
  201.         ' Create form object
  202.         ObjForm = New cFormObj
  203.  
  204.         ' Process form if post back
  205.         If ObjForm.GetValue("a_add") <> "" Then
  206.             ltgFixtureNote.CurrentAction = ObjForm.GetValue("a_add") ' Get form action
  207.             LoadFormValues() ' Load form values
  208.  
  209.             ' Validate Form
  210.             If Not ValidateForm() Then
  211.                 ltgFixtureNote.CurrentAction = "I" ' Form error, reset action
  212.                 Message = ParentPage.gsFormError
  213.             End If
  214.  
  215.         ' Not post back
  216.         Else
  217.             If bCopy Then
  218.                 ltgFixtureNote.CurrentAction = "C" ' Copy Record
  219.             Else
  220.                 ltgFixtureNote.CurrentAction = "I" ' Display Blank Record
  221.                 LoadDefaultValues() ' Load default values
  222.             End If
  223.         End If
  224.  
  225.         ' Perform action based on action code
  226.         Select Case ltgFixtureNote.CurrentAction
  227.             Case "I" ' Blank record, no action required
  228.             Case "C" ' Copy an existing record
  229.                 If Not LoadRow() Then ' Load record based on key
  230.                     Message = "No records found" ' No record found
  231.                     Page_Terminate("ltgFixtureNotelist.aspx") ' No matching record, return to list
  232.                 End If
  233.             Case "A" ' Add new record
  234.                 ltgFixtureNote.SendEmail = True ' Send email on add success
  235.                 If AddRow() Then ' Add successful
  236.                     Message = "Add succeeded" ' Set up success message
  237.                     Dim sReturnUrl As String = ltgFixtureNote.ReturnUrl
  238.                     Page_Terminate(sReturnUrl) ' Clean up and return
  239.                 Else
  240.                     RestoreFormValues() ' Add failed, restore form values
  241.                 End If
  242.         End Select
  243.  
  244.         ' Render row based on row type
  245.         ltgFixtureNote.RowType = EW_ROWTYPE_ADD ' Render add type
  246.  
  247.         ' Render row
  248.         RenderRow()
  249.     End Sub
  250.  
  251.     '
  252.     ' Get upload file
  253.     '
  254.     Sub GetUploadFiles()
  255.  
  256.         ' Get upload data
  257.     End Sub
  258.  
  259.     '
  260.     ' Load default values
  261.     '
  262.     Sub LoadDefaultValues()
  263.         ltgFixtureNote.notIsActive.CurrentValue = 1
  264.     End Sub
  265.  
  266.     '
  267.     ' Load form values
  268.     '
  269.     Sub LoadFormValues()
  270.         ltgFixtureNote.notFixID.FormValue = ObjForm.GetValue("x_notFixID")
  271.         ltgFixtureNote.notFixID.OldValue = ObjForm.GetValue("o_notFixID")
  272.         ltgFixtureNote.notTypeID.FormValue = ObjForm.GetValue("x_notTypeID")
  273.         ltgFixtureNote.notTypeID.OldValue = ObjForm.GetValue("o_notTypeID")
  274.         ltgFixtureNote.notDate.FormValue = ObjForm.GetValue("x_notDate")
  275.         ltgFixtureNote.notDate.CurrentValue = ew_UnFormatDateTime(ltgFixtureNote.notDate.CurrentValue, 6)
  276.         ltgFixtureNote.notDate.OldValue = ObjForm.GetValue("o_notDate")
  277.         ltgFixtureNote.notShortDesc.FormValue = ObjForm.GetValue("x_notShortDesc")
  278.         ltgFixtureNote.notShortDesc.OldValue = ObjForm.GetValue("o_notShortDesc")
  279.         ltgFixtureNote.notNote.FormValue = ObjForm.GetValue("x_notNote")
  280.         ltgFixtureNote.notNote.OldValue = ObjForm.GetValue("o_notNote")
  281.         ltgFixtureNote.notLPRStatusID.FormValue = ObjForm.GetValue("x_notLPRStatusID")
  282.         ltgFixtureNote.notLPRStatusID.OldValue = ObjForm.GetValue("o_notLPRStatusID")
  283.         ltgFixtureNote.notPriority.FormValue = ObjForm.GetValue("x_notPriority")
  284.         ltgFixtureNote.notPriority.OldValue = ObjForm.GetValue("o_notPriority")
  285.         ltgFixtureNote.notIsActive.FormValue = ObjForm.GetValue("x_notIsActive")
  286.         ltgFixtureNote.notIsActive.OldValue = ObjForm.GetValue("o_notIsActive")
  287.         ltgFixtureNote.notID.FormValue = ObjForm.GetValue("x_notID")
  288.     End Sub
  289.  
  290.     '
  291.     ' Restore form values
  292.     '
  293.     Sub RestoreFormValues()
  294.         ltgFixtureNote.notFixID.CurrentValue = ltgFixtureNote.notFixID.FormValue
  295.         ltgFixtureNote.notTypeID.CurrentValue = ltgFixtureNote.notTypeID.FormValue
  296.         ltgFixtureNote.notDate.CurrentValue = ltgFixtureNote.notDate.FormValue
  297.         ltgFixtureNote.notDate.CurrentValue = ew_UnFormatDateTime(ltgFixtureNote.notDate.CurrentValue, 6)
  298.         ltgFixtureNote.notShortDesc.CurrentValue = ltgFixtureNote.notShortDesc.FormValue
  299.         ltgFixtureNote.notNote.CurrentValue = ltgFixtureNote.notNote.FormValue
  300.         ltgFixtureNote.notLPRStatusID.CurrentValue = ltgFixtureNote.notLPRStatusID.FormValue
  301.         ltgFixtureNote.notPriority.CurrentValue = ltgFixtureNote.notPriority.FormValue
  302.         ltgFixtureNote.notIsActive.CurrentValue = ltgFixtureNote.notIsActive.FormValue
  303.         ltgFixtureNote.notID.CurrentValue = ltgFixtureNote.notID.FormValue
  304.     End Sub
  305.  
  306.     '
  307.     ' Load row based on key values
  308.     '
  309.     Function LoadRow() As Boolean
  310.         Dim RsRow As OleDbDataReader
  311.         Dim sFilter As String = ltgFixtureNote.KeyFilter
  312.  
  313.         ' Row Selecting event
  314.         ltgFixtureNote.Row_Selecting(sFilter)
  315.  
  316.         ' Load SQL based on filter
  317.         ltgFixtureNote.CurrentFilter = sFilter
  318.         Dim sSql As String = ltgFixtureNote.SQL
  319.  
  320.         ' Write SQL for debug
  321.         If EW_DEBUG_ENABLED Then ew_Write(sSql)
  322.         Try
  323.             RsRow = Conn.GetTempDataReader(sSql)    
  324.             If Not RsRow.Read() Then
  325.                 Return False
  326.             Else                
  327.                 LoadRowValues(RsRow) ' Load row values
  328.  
  329.                 ' Row Selected event
  330.                 ltgFixtureNote.Row_Selected(RsRow)
  331.                 Return True    
  332.             End If
  333.         Catch
  334.             If EW_DEBUG_ENABLED Then Throw
  335.             Return False
  336.         Finally
  337.             Conn.CloseTempDataReader()
  338.         End Try
  339.     End Function
  340.  
  341.     '
  342.     ' Load row values from recordset
  343.     '
  344.     Sub LoadRowValues(ByRef RsRow As OleDbDataReader)
  345.         ltgFixtureNote.notID.DbValue = RsRow("notID")
  346.         ltgFixtureNote.notFixID.DbValue = RsRow("notFixID")
  347.         ltgFixtureNote.notTypeID.DbValue = RsRow("notTypeID")
  348.         ltgFixtureNote.notDate.DbValue = RsRow("notDate")
  349.         ltgFixtureNote.notShortDesc.DbValue = RsRow("notShortDesc")
  350.         ltgFixtureNote.notNote.DbValue = RsRow("notNote")
  351.         ltgFixtureNote.notLPRStatusID.DbValue = RsRow("notLPRStatusID")
  352.         ltgFixtureNote.notPriority.DbValue = RsRow("notPriority")
  353.         ltgFixtureNote.notIsActive.DbValue = IIf(ew_ConvertToBool(RsRow("notIsActive")), "1", "0")
  354.         ltgFixtureNote.notCreatedBy.DbValue = RsRow("notCreatedBy")
  355.         ltgFixtureNote.notCreatedOn.DbValue = RsRow("notCreatedOn")
  356.         ltgFixtureNote.notModifiedBy.DbValue = RsRow("notModifiedBy")
  357.         ltgFixtureNote.notModifiedOn.DbValue = RsRow("notModifiedOn")
  358.     End Sub
  359.  
  360.     '
  361.     ' Render row values based on field settings
  362.     '
  363.     Sub RenderRow()
  364.  
  365.         ' Row Rendering event
  366.         ltgFixtureNote.Row_Rendering()
  367.  
  368.         '
  369.         '  Common render codes for all row types
  370.         '
  371.         ' notFixID
  372.  
  373.         ltgFixtureNote.notFixID.CellCssStyle = ""
  374.         ltgFixtureNote.notFixID.CellCssClass = ""
  375.  
  376.         ' notTypeID
  377.         ltgFixtureNote.notTypeID.CellCssStyle = ""
  378.         ltgFixtureNote.notTypeID.CellCssClass = ""
  379.  
  380.         ' notDate
  381.         ltgFixtureNote.notDate.CellCssStyle = ""
  382.         ltgFixtureNote.notDate.CellCssClass = ""
  383.  
  384.         ' notShortDesc
  385.         ltgFixtureNote.notShortDesc.CellCssStyle = ""
  386.         ltgFixtureNote.notShortDesc.CellCssClass = ""
  387.  
  388.         ' notNote
  389.         ltgFixtureNote.notNote.CellCssStyle = ""
  390.         ltgFixtureNote.notNote.CellCssClass = ""
  391.  
  392.         ' notLPRStatusID
  393.         ltgFixtureNote.notLPRStatusID.CellCssStyle = ""
  394.         ltgFixtureNote.notLPRStatusID.CellCssClass = ""
  395.  
  396.         ' notPriority
  397.         ltgFixtureNote.notPriority.CellCssStyle = ""
  398.         ltgFixtureNote.notPriority.CellCssClass = ""
  399.  
  400.         ' notIsActive
  401.         ltgFixtureNote.notIsActive.CellCssStyle = ""
  402.         ltgFixtureNote.notIsActive.CellCssClass = ""
  403.  
  404.         '
  405.         '  View  Row
  406.         '
  407.  
  408.         If ltgFixtureNote.RowType = EW_ROWTYPE_VIEW Then ' View row
  409.  
  410.             ' notID
  411.             ltgFixtureNote.notID.ViewValue = ltgFixtureNote.notID.CurrentValue
  412.             ltgFixtureNote.notID.CssStyle = ""
  413.             ltgFixtureNote.notID.CssClass = ""
  414.             ltgFixtureNote.notID.ViewCustomAttributes = ""
  415.  
  416.             ' notFixID
  417.             ltgFixtureNote.notFixID.ViewValue = ltgFixtureNote.notFixID.CurrentValue
  418.             ltgFixtureNote.notFixID.CssStyle = ""
  419.             ltgFixtureNote.notFixID.CssClass = ""
  420.             ltgFixtureNote.notFixID.ViewCustomAttributes = ""
  421.  
  422.             ' notTypeID
  423.             If ew_NotEmpty(ltgFixtureNote.notTypeID.CurrentValue) Then
  424.                 sSqlWrk = "SELECT [ntyDescription] FROM [ltgFixtureNoteType] WHERE [ntyID] = " & ew_AdjustSql(ltgFixtureNote.notTypeID.CurrentValue) & ""
  425.                 sSqlWrk = sSqlWrk & " AND (" & "[ntyIsActive]=True" & ")"
  426.                 sSqlWrk = sSqlWrk & " ORDER BY [ntyDescription] "
  427.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  428.                 If RsWrk.Read() Then
  429.                     ltgFixtureNote.notTypeID.ViewValue = RsWrk("ntyDescription")
  430.                 Else
  431.                     ltgFixtureNote.notTypeID.ViewValue = ltgFixtureNote.notTypeID.CurrentValue
  432.                 End If
  433.                 Conn.CloseTempDataReader()
  434.             Else
  435.                 ltgFixtureNote.notTypeID.ViewValue = System.DBNull.Value
  436.             End If
  437.             ltgFixtureNote.notTypeID.CssStyle = ""
  438.             ltgFixtureNote.notTypeID.CssClass = ""
  439.             ltgFixtureNote.notTypeID.ViewCustomAttributes = ""
  440.  
  441.             ' notDate
  442.             ltgFixtureNote.notDate.ViewValue = ltgFixtureNote.notDate.CurrentValue
  443.             ltgFixtureNote.notDate.ViewValue = ew_FormatDateTime(ltgFixtureNote.notDate.ViewValue, 6)
  444.             ltgFixtureNote.notDate.CssStyle = ""
  445.             ltgFixtureNote.notDate.CssClass = ""
  446.             ltgFixtureNote.notDate.ViewCustomAttributes = ""
  447.  
  448.             ' notShortDesc
  449.             ltgFixtureNote.notShortDesc.ViewValue = ltgFixtureNote.notShortDesc.CurrentValue
  450.             ltgFixtureNote.notShortDesc.CssStyle = ""
  451.             ltgFixtureNote.notShortDesc.CssClass = ""
  452.             ltgFixtureNote.notShortDesc.ViewCustomAttributes = ""
  453.  
  454.             ' notNote
  455.             ltgFixtureNote.notNote.ViewValue = ltgFixtureNote.notNote.CurrentValue
  456.             ltgFixtureNote.notNote.CssStyle = ""
  457.             ltgFixtureNote.notNote.CssClass = ""
  458.             ltgFixtureNote.notNote.ViewCustomAttributes = ""
  459.  
  460.             ' notLPRStatusID
  461.             If ew_NotEmpty(ltgFixtureNote.notLPRStatusID.CurrentValue) Then
  462.                 sSqlWrk = "SELECT [lstDescription] FROM [tblLPRStatus] WHERE [lstID] = " & ew_AdjustSql(ltgFixtureNote.notLPRStatusID.CurrentValue) & ""
  463.                 sSqlWrk = sSqlWrk & " AND (" & "[lstIsActive]=True" & ")"
  464.                 sSqlWrk = sSqlWrk & " ORDER BY [lstDescription] "
  465.                 RsWrk = Conn.GetTempDataReader(sSqlWrk)
  466.                 If RsWrk.Read() Then
  467.                     ltgFixtureNote.notLPRStatusID.ViewValue = RsWrk("lstDescription")
  468.                 Else
  469.                     ltgFixtureNote.notLPRStatusID.ViewValue = ltgFixtureNote.notLPRStatusID.CurrentValue
  470.                 End If
  471.                 Conn.CloseTempDataReader()
  472.             Else
  473.                 ltgFixtureNote.notLPRStatusID.ViewValue = System.DBNull.Value
  474.             End If
  475.             ltgFixtureNote.notLPRStatusID.CssStyle = ""
  476.             ltgFixtureNote.notLPRStatusID.CssClass = ""
  477.             ltgFixtureNote.notLPRStatusID.ViewCustomAttributes = ""
  478.  
  479.             ' notPriority
  480.             If Not IsDBNull(ltgFixtureNote.notPriority.CurrentValue) Then
  481.                 Select Case ltgFixtureNote.notPriority.CurrentValue
  482.                     Case "1"
  483.                         ltgFixtureNote.notPriority.ViewValue = "High"
  484.                     Case "2"
  485.                         ltgFixtureNote.notPriority.ViewValue = "Medium"
  486.                     Case "3"
  487.                         ltgFixtureNote.notPriority.ViewValue = "Low"
  488.                     Case Else
  489.                         ltgFixtureNote.notPriority.ViewValue = ltgFixtureNote.notPriority.CurrentValue
  490.                 End Select
  491.             Else
  492.                 ltgFixtureNote.notPriority.ViewValue = System.DBNull.Value
  493.             End If
  494.             ltgFixtureNote.notPriority.CssStyle = ""
  495.             ltgFixtureNote.notPriority.CssClass = ""
  496.             ltgFixtureNote.notPriority.ViewCustomAttributes = ""
  497.  
  498.             ' notIsActive
  499.             If Convert.ToString(ltgFixtureNote.notIsActive.CurrentValue) = "1" Then
  500.                 ltgFixtureNote.notIsActive.ViewValue = "Yes"
  501.             Else
  502.                 ltgFixtureNote.notIsActive.ViewValue = "No"
  503.             End If
  504.             ltgFixtureNote.notIsActive.CssStyle = ""
  505.             ltgFixtureNote.notIsActive.CssClass = ""
  506.             ltgFixtureNote.notIsActive.ViewCustomAttributes = ""
  507.  
  508.             ' notCreatedBy
  509.             ltgFixtureNote.notCreatedBy.ViewValue = ltgFixtureNote.notCreatedBy.CurrentValue
  510.             ltgFixtureNote.notCreatedBy.CssStyle = ""
  511.             ltgFixtureNote.notCreatedBy.CssClass = ""
  512.             ltgFixtureNote.notCreatedBy.ViewCustomAttributes = ""
  513.  
  514.             ' notCreatedOn
  515.             ltgFixtureNote.notCreatedOn.ViewValue = ltgFixtureNote.notCreatedOn.CurrentValue
  516.             ltgFixtureNote.notCreatedOn.ViewValue = ew_FormatDateTime(ltgFixtureNote.notCreatedOn.ViewValue, 6)
  517.             ltgFixtureNote.notCreatedOn.CssStyle = ""
  518.             ltgFixtureNote.notCreatedOn.CssClass = ""
  519.             ltgFixtureNote.notCreatedOn.ViewCustomAttributes = ""
  520.  
  521.             ' notModifiedBy
  522.             ltgFixtureNote.notModifiedBy.ViewValue = ltgFixtureNote.notModifiedBy.CurrentValue
  523.             ltgFixtureNote.notModifiedBy.CssStyle = ""
  524.             ltgFixtureNote.notModifiedBy.CssClass = ""
  525.             ltgFixtureNote.notModifiedBy.ViewCustomAttributes = ""
  526.  
  527.             ' notModifiedOn
  528.             ltgFixtureNote.notModifiedOn.ViewValue = ltgFixtureNote.notModifiedOn.CurrentValue
  529.             ltgFixtureNote.notModifiedOn.ViewValue = ew_FormatDateTime(ltgFixtureNote.notModifiedOn.ViewValue, 6)
  530.             ltgFixtureNote.notModifiedOn.CssStyle = ""
  531.             ltgFixtureNote.notModifiedOn.CssClass = ""
  532.             ltgFixtureNote.notModifiedOn.ViewCustomAttributes = ""
  533.  
  534.             ' View refer script
  535.             ' notFixID
  536.  
  537.             ltgFixtureNote.notFixID.HrefValue = ""
  538.  
  539.             ' notTypeID
  540.             ltgFixtureNote.notTypeID.HrefValue = ""
  541.  
  542.             ' notDate
  543.             ltgFixtureNote.notDate.HrefValue = ""
  544.  
  545.             ' notShortDesc
  546.             ltgFixtureNote.notShortDesc.HrefValue = ""
  547.  
  548.             ' notNote
  549.             ltgFixtureNote.notNote.HrefValue = ""
  550.  
  551.             ' notLPRStatusID
  552.             ltgFixtureNote.notLPRStatusID.HrefValue = ""
  553.  
  554.             ' notPriority
  555.             ltgFixtureNote.notPriority.HrefValue = ""
  556.  
  557.             ' notIsActive
  558.             ltgFixtureNote.notIsActive.HrefValue = ""
  559.  
  560.         '
  561.         '  Add Row
  562.         '
  563.  
  564.         ElseIf ltgFixtureNote.RowType = EW_ROWTYPE_ADD Then ' Add row
  565.  
  566.             ' notFixID
  567.             ltgFixtureNote.notFixID.EditCustomAttributes = ""
  568.             If ltgFixtureNote.notFixID.SessionValue <> "" Then
  569.                 ltgFixtureNote.notFixID.CurrentValue = ltgFixtureNote.notFixID.SessionValue
  570.             ltgFixtureNote.notFixID.ViewValue = ltgFixtureNote.notFixID.CurrentValue
  571.             ltgFixtureNote.notFixID.CssStyle = ""
  572.             ltgFixtureNote.notFixID.CssClass = ""
  573.             ltgFixtureNote.notFixID.ViewCustomAttributes = ""
  574.             Else
  575.             ltgFixtureNote.notFixID.EditValue = ew_HtmlEncode(ltgFixtureNote.notFixID.CurrentValue)
  576.             End If
  577.  
  578.             ' notTypeID
  579.             ltgFixtureNote.notTypeID.EditCustomAttributes = ""
  580.             sSqlWrk = "SELECT [ntyID], [ntyDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [ltgFixtureNoteType]"
  581.             sWhereWrk = ""
  582.             If sWhereWrk <> "" Then sWhereWrk = "(" & sWhereWrk & ") AND "
  583.             sWhereWrk = sWhereWrk & "(" & "[ntyIsActive]=True" & ")"
  584.             If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  585.             sSqlWrk = sSqlWrk & " ORDER BY [ntyDescription] "
  586.             arwrk = Conn.GetRows(sSqlWrk)
  587.             arwrk.Insert(0, New Object(){"", "Please Select"}) 
  588.             ltgFixtureNote.notTypeID.EditValue = arwrk
  589.  
  590.             ' notDate
  591.             ' notShortDesc
  592.  
  593.             ltgFixtureNote.notShortDesc.EditCustomAttributes = ""
  594.             ltgFixtureNote.notShortDesc.EditValue = ew_HtmlEncode(ltgFixtureNote.notShortDesc.CurrentValue)
  595.  
  596.             ' notNote
  597.             ltgFixtureNote.notNote.EditCustomAttributes = ""
  598.             ltgFixtureNote.notNote.EditValue = ew_HtmlEncode(ltgFixtureNote.notNote.CurrentValue)
  599.  
  600.             ' notLPRStatusID
  601.             ltgFixtureNote.notLPRStatusID.EditCustomAttributes = ""
  602.             sSqlWrk = "SELECT [lstID], [lstDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblLPRStatus]"
  603.             sWhereWrk = ""
  604.             If sWhereWrk <> "" Then sWhereWrk = "(" & sWhereWrk & ") AND "
  605.             sWhereWrk = sWhereWrk & "(" & "[lstIsActive]=True" & ")"
  606.             If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
  607.             sSqlWrk = sSqlWrk & " ORDER BY [lstDescription] "
  608.             arwrk = Conn.GetRows(sSqlWrk)
  609.             arwrk.Insert(0, New Object(){"", "Please Select"}) 
  610.             ltgFixtureNote.notLPRStatusID.EditValue = arwrk
  611.  
  612.             ' notPriority
  613.             ltgFixtureNote.notPriority.EditCustomAttributes = ""
  614.             arwrk = New ArrayList
  615.             arwrk.Add(New String() {"1", "High"})
  616.             arwrk.Add(New String() {"2", "Medium"})
  617.             arwrk.Add(New String() {"3", "Low"})
  618.             arwrk.Insert(0, New String() {"", "Please Select"})
  619.             ltgFixtureNote.notPriority.EditValue = arwrk
  620.  
  621.             ' notIsActive
  622.             ltgFixtureNote.notIsActive.EditCustomAttributes = ""
  623.         End If
  624.  
  625.         ' Row Rendered event
  626.         ltgFixtureNote.Row_Rendered()
  627.     End Sub
  628.  
  629.     '
  630.     ' Validate form
  631.     '
  632.     Function ValidateForm() As Boolean
  633.  
  634.         ' Initialize
  635.         ParentPage.gsFormError = ""
  636.  
  637.         ' Check if validation required
  638.         If Not EW_SERVER_VALIDATE Then Return (ParentPage.gsFormError = "")
  639.         If ew_Empty(ltgFixtureNote.notFixID.FormValue) Then
  640.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  641.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Fixture"
  642.         End If
  643.         If Not ew_CheckInteger(ltgFixtureNote.notFixID.FormValue) Then
  644.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  645.             ParentPage.gsFormError = ParentPage.gsFormError & "Incorrect integer - Fixture"
  646.         End If
  647.         If ew_Empty(ltgFixtureNote.notTypeID.FormValue) Then
  648.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  649.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Note Type"
  650.         End If
  651.         If ew_Empty(ltgFixtureNote.notShortDesc.FormValue) Then
  652.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  653.             ParentPage.gsFormError = ParentPage.gsFormError & "Please enter required field - Short Desc"
  654.         End If
  655.  
  656.         ' Return validate result
  657.         Dim Valid As Boolean = (ParentPage.gsFormError = "")
  658.  
  659.         ' Form_CustomValidate event
  660.         Dim sFormCustomError As String = ""
  661.         Valid = Valid And Form_CustomValidate(sFormCustomError)
  662.         If sFormCustomError <> "" Then
  663.             If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
  664.             ParentPage.gsFormError = ParentPage.gsFormError & sFormCustomError
  665.         End If
  666.         Return Valid
  667.     End Function
  668.  
  669.     '
  670.     ' Add record
  671.     '
  672.     Function AddRow() As Boolean
  673.         Dim Rs As New OrderedDictionary
  674.         Dim sSql As String, sFilter As String
  675.         Dim bInsertRow As Boolean
  676.         Dim RsChk As OleDbDataReader
  677.         Dim sIdxErrMsg As String
  678.         Dim LastInsertId As Object
  679.  
  680.         ' notFixID
  681.         ltgFixtureNote.notFixID.SetDbValue(ltgFixtureNote.notFixID.CurrentValue, System.DBNull.Value)
  682.         Rs("notFixID") = ltgFixtureNote.notFixID.DbValue
  683.  
  684.         ' notTypeID
  685.         ltgFixtureNote.notTypeID.SetDbValue(ltgFixtureNote.notTypeID.CurrentValue, System.DBNull.Value)
  686.         Rs("notTypeID") = ltgFixtureNote.notTypeID.DbValue
  687.  
  688.         ' notDate
  689.         ltgFixtureNote.notDate.DbValue = ew_CurrentDate()
  690.         Rs("notDate") = ltgFixtureNote.notDate.DbValue
  691.  
  692.         ' notShortDesc
  693.         ltgFixtureNote.notShortDesc.SetDbValue(ltgFixtureNote.notShortDesc.CurrentValue, System.DBNull.Value)
  694.         Rs("notShortDesc") = ltgFixtureNote.notShortDesc.DbValue
  695.  
  696.         ' notNote
  697.         ltgFixtureNote.notNote.SetDbValue(ltgFixtureNote.notNote.CurrentValue, System.DBNull.Value)
  698.         Rs("notNote") = ltgFixtureNote.notNote.DbValue
  699.  
  700.         ' notLPRStatusID
  701.         ltgFixtureNote.notLPRStatusID.SetDbValue(ltgFixtureNote.notLPRStatusID.CurrentValue, System.DBNull.Value)
  702.         Rs("notLPRStatusID") = ltgFixtureNote.notLPRStatusID.DbValue
  703.  
  704.         ' notPriority
  705.         ltgFixtureNote.notPriority.SetDbValue(ltgFixtureNote.notPriority.CurrentValue, System.DBNull.Value)
  706.         Rs("notPriority") = ltgFixtureNote.notPriority.DbValue
  707.  
  708.         ' notIsActive
  709.         ltgFixtureNote.notIsActive.SetDbValue((ltgFixtureNote.notIsActive.CurrentValue <> "" And Not IsDBNull(ltgFixtureNote.notIsActive.CurrentValue)), System.DBNull.Value)
  710.         Rs("notIsActive") = ltgFixtureNote.notIsActive.DbValue
  711.  
  712.         ' Row Inserting event
  713.         bInsertRow = ltgFixtureNote.Row_Inserting(Rs)
  714.         If bInsertRow Then
  715.             Try    
  716.                 ltgFixtureNote.Insert(Rs)
  717.                 AddRow = True
  718.             Catch e As Exception
  719.                 If EW_DEBUG_ENABLED Then Throw
  720.                 Message = e.Message                
  721.                 AddRow = False
  722.             End Try
  723.         Else
  724.             If ltgFixtureNote.CancelMessage <> "" Then
  725.                 Message = ltgFixtureNote.CancelMessage
  726.                 ltgFixtureNote.CancelMessage = ""
  727.             Else
  728.                 Message = "Insert cancelled"
  729.             End If
  730.             AddRow = False
  731.         End If
  732.         If AddRow Then
  733.             LastInsertId = Conn.GetLastInsertId()
  734.             ltgFixtureNote.notID.DbValue = LastInsertId
  735.             Rs("notID") = ltgFixtureNote.notID.DbValue        
  736.  
  737.             ' Row Inserted event
  738.             ltgFixtureNote.Row_Inserted(Rs)
  739.         End If
  740.     End Function
  741.  
  742.         ' Page Load event
  743.         Public Sub Page_Load()
  744.  
  745.             'HttpContext.Current.Response.Write("Page Load")
  746.         End Sub
  747.  
  748.         ' Page Unload event
  749.         Public Sub Page_Unload()
  750.  
  751.             'HttpContext.Current.Response.Write("Page Unload")
  752.         End Sub
  753.  
  754.     ' Form Custom Validate event
  755.     Public Function Form_CustomValidate(ByRef CustomError As String) As Boolean
  756.  
  757.         'Return error message in CustomError
  758.         Return True
  759.     End Function
  760.     End Class
  761.  
  762.     '
  763.     ' ASP.NET Page_Load event
  764.     '
  765.  
  766.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  767.         Response.Buffer = EW_RESPONSE_BUFFER
  768.         Response.Cache.SetCacheability(HttpCacheability.NoCache)
  769.  
  770.         ' Page init
  771.         ltgFixtureNote_add = New cltgFixtureNote_add(Me)        
  772.         ltgFixtureNote_add.Page_Init()
  773.  
  774.         ' Page main processing
  775.         ltgFixtureNote_add.Page_Main()
  776.     End Sub
  777.  
  778.     '
  779.     ' ASP.NET Page_Unload event
  780.     '
  781.  
  782.     Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
  783.  
  784.         ' Dispose page object
  785.         If ltgFixtureNote_add IsNot Nothing Then ltgFixtureNote_add.Dispose()
  786.     End Sub
  787. End Class
  788.