home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
66.142.0.142
/
66.142.0.142.tar
/
66.142.0.142
/
ltgFixtureLocationadd.aspx.vb
< prev
next >
Wrap
Text File
|
2014-01-25
|
14KB
|
511 lines
Imports System.Data
Imports System.Data.Common
Imports System.Xml
Imports System.IO
Imports System.Data.OleDb
'
' ASP.NET code-behind class (Page)
'
Partial Class ltgFixtureLocationadd
Inherits AspNetMaker7_tfpssnet
' Page object
Public ltgFixtureLocation_add As cltgFixtureLocation_add
'
' Page Class
'
Class cltgFixtureLocation_add
Inherits AspNetMakerPage
Implements IDisposable
' Used by system generated functions
Private RsWrk As Object, sSqlWrk As String, sWhereWrk As String
Private arwrk As Object
Private armultiwrk() As String
' Page URL
Public ReadOnly Property PageUrl() As String
Get
Dim Url As String = ew_CurrentPage() & "?"
If ltgFixtureLocation.UseTokenInUrl Then Url = Url & "t=" & ltgFixtureLocation.TableVar & "&" ' Add page token
Return Url
End Get
End Property
' Validate page request
Public Function IsPageRequest() As Boolean
Dim Result As Boolean
If ltgFixtureLocation.UseTokenInUrl Then
Result = False
If ObjForm IsNot Nothing Then
Result = (ltgFixtureLocation.TableVar = ObjForm.GetValue("t"))
End If
If ew_Get("t") <> "" Then
Result = (ltgFixtureLocation.TableVar = ew_Get("t"))
End If
Return Result
End If
Return True
End Function
' ltgFixtureLocation
Public Property ltgFixtureLocation() As cltgFixtureLocation
Get
Return ParentPage.ltgFixtureLocation
End Get
Set(ByVal v As cltgFixtureLocation)
ParentPage.ltgFixtureLocation = v
End Set
End Property
' ltgFixtureLocation
Public Property tblEmployees() As ctblEmployees
Get
Return ParentPage.tblEmployees
End Get
Set(ByVal v As ctblEmployees)
ParentPage.tblEmployees = v
End Set
End Property
'
' Constructor
' - init objects
' - open connection
'
Public Sub New(ByRef APage As AspNetMaker7_tfpssnet)
m_ParentPage = APage
m_Page = Me
m_PageID = "add"
m_PageObjName = "ltgFixtureLocation_add"
m_PageObjTypeName = "cltgFixtureLocation_add"
' Table Name
m_TableName = "ltgFixtureLocation"
' Initialize table object
ltgFixtureLocation = New cltgFixtureLocation(Me)
tblEmployees = New ctblEmployees(Me)
' Connect to database
Conn = New cConnection()
End Sub
'
' Subroutine Page_Init
' - called before page main
' - check Security
' - set up response header
' - call page load events
'
Public Sub Page_Init()
Security = New cAdvancedSecurity(Me)
If Not Security.IsLoggedIn() Then Security.AutoLogin()
If Not Security.IsLoggedIn() Then
Security.SaveLastUrl()
Page_Terminate("login.aspx")
End If
' Table Permission loading event
Security.TablePermission_Loading()
Security.LoadCurrentUserLevel(TableName)
' Table Permission loaded event
Security.TablePermission_Loaded()
If Not Security.CanAdd Then
Security.SaveLastUrl()
Page_Terminate("ltgFixtureLocationlist.aspx")
End If
' User ID loading event
Security.UserID_Loading()
If Security.IsLoggedIn() Then Call Security.LoadUserID()
' User ID loaded event
Security.UserID_Loaded()
' Global page loading event (in ewglobal*.vb)
ParentPage.Page_Loading()
' Page load event, used in current page
Page_Load()
End Sub
'
' Class terminate
' - clean up page object
'
Public Sub Dispose() Implements IDisposable.Dispose
Page_Terminate("")
End Sub
'
' Sub Page_Terminate
' - called when exit page
' - clean up connection and objects
' - if URL specified, redirect to URL
'
Sub Page_Terminate(url As String)
' Page unload event, used in current page
Page_Unload()
' Global page unloaded event (in ewglobal*.vb)
ParentPage.Page_Unloaded()
' Close connection
Conn.Dispose()
Security = Nothing
ltgFixtureLocation.Dispose()
tblEmployees.Dispose()
' Go to URL if specified
If url <> "" Then
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.Redirect(url)
End If
End Sub
Public x_ewPriv As Integer
'
' Page main processing
'
Sub Page_Main()
' Load key values from QueryString
Dim bCopy As Boolean = True
If ew_Get("floID") <> "" Then
ltgFixtureLocation.floID.QueryStringValue = ew_Get("floID")
Else
bCopy = False
End If
' Create form object
ObjForm = New cFormObj
' Process form if post back
If ObjForm.GetValue("a_add") <> "" Then
ltgFixtureLocation.CurrentAction = ObjForm.GetValue("a_add") ' Get form action
LoadFormValues() ' Load form values
' Validate Form
If Not ValidateForm() Then
ltgFixtureLocation.CurrentAction = "I" ' Form error, reset action
Message = ParentPage.gsFormError
End If
' Not post back
Else
If bCopy Then
ltgFixtureLocation.CurrentAction = "C" ' Copy Record
Else
ltgFixtureLocation.CurrentAction = "I" ' Display Blank Record
LoadDefaultValues() ' Load default values
End If
End If
' Perform action based on action code
Select Case ltgFixtureLocation.CurrentAction
Case "I" ' Blank record, no action required
Case "C" ' Copy an existing record
If Not LoadRow() Then ' Load record based on key
Message = "No records found" ' No record found
Page_Terminate("ltgFixtureLocationlist.aspx") ' No matching record, return to list
End If
Case "A" ' Add new record
ltgFixtureLocation.SendEmail = True ' Send email on add success
If AddRow() Then ' Add successful
Message = "Add succeeded" ' Set up success message
Dim sReturnUrl As String = ltgFixtureLocation.ReturnUrl
Page_Terminate(sReturnUrl) ' Clean up and return
Else
RestoreFormValues() ' Add failed, restore form values
End If
End Select
' Render row based on row type
ltgFixtureLocation.RowType = EW_ROWTYPE_ADD ' Render add type
' Render row
RenderRow()
End Sub
'
' Get upload file
'
Sub GetUploadFiles()
' Get upload data
End Sub
'
' Load default values
'
Sub LoadDefaultValues()
ltgFixtureLocation.floIsActive.CurrentValue = 1
End Sub
'
' Load form values
'
Sub LoadFormValues()
ltgFixtureLocation.floDescription.FormValue = ObjForm.GetValue("x_floDescription")
ltgFixtureLocation.floDescription.OldValue = ObjForm.GetValue("o_floDescription")
ltgFixtureLocation.floIsActive.FormValue = ObjForm.GetValue("x_floIsActive")
ltgFixtureLocation.floIsActive.OldValue = ObjForm.GetValue("o_floIsActive")
ltgFixtureLocation.floID.FormValue = ObjForm.GetValue("x_floID")
End Sub
'
' Restore form values
'
Sub RestoreFormValues()
ltgFixtureLocation.floDescription.CurrentValue = ltgFixtureLocation.floDescription.FormValue
ltgFixtureLocation.floIsActive.CurrentValue = ltgFixtureLocation.floIsActive.FormValue
ltgFixtureLocation.floID.CurrentValue = ltgFixtureLocation.floID.FormValue
End Sub
'
' Load row based on key values
'
Function LoadRow() As Boolean
Dim RsRow As OleDbDataReader
Dim sFilter As String = ltgFixtureLocation.KeyFilter
' Row Selecting event
ltgFixtureLocation.Row_Selecting(sFilter)
' Load SQL based on filter
ltgFixtureLocation.CurrentFilter = sFilter
Dim sSql As String = ltgFixtureLocation.SQL
' Write SQL for debug
If EW_DEBUG_ENABLED Then ew_Write(sSql)
Try
RsRow = Conn.GetTempDataReader(sSql)
If Not RsRow.Read() Then
Return False
Else
LoadRowValues(RsRow) ' Load row values
' Row Selected event
ltgFixtureLocation.Row_Selected(RsRow)
Return True
End If
Catch
If EW_DEBUG_ENABLED Then Throw
Return False
Finally
Conn.CloseTempDataReader()
End Try
End Function
'
' Load row values from recordset
'
Sub LoadRowValues(ByRef RsRow As OleDbDataReader)
ltgFixtureLocation.floID.DbValue = RsRow("floID")
ltgFixtureLocation.floDescription.DbValue = RsRow("floDescription")
ltgFixtureLocation.floIsActive.DbValue = IIf(ew_ConvertToBool(RsRow("floIsActive")), "1", "0")
End Sub
'
' Render row values based on field settings
'
Sub RenderRow()
' Row Rendering event
ltgFixtureLocation.Row_Rendering()
'
' Common render codes for all row types
'
' floDescription
ltgFixtureLocation.floDescription.CellCssStyle = ""
ltgFixtureLocation.floDescription.CellCssClass = ""
' floIsActive
ltgFixtureLocation.floIsActive.CellCssStyle = ""
ltgFixtureLocation.floIsActive.CellCssClass = ""
'
' View Row
'
If ltgFixtureLocation.RowType = EW_ROWTYPE_VIEW Then ' View row
' floID
ltgFixtureLocation.floID.ViewValue = ltgFixtureLocation.floID.CurrentValue
ltgFixtureLocation.floID.CssStyle = ""
ltgFixtureLocation.floID.CssClass = ""
ltgFixtureLocation.floID.ViewCustomAttributes = ""
' floDescription
ltgFixtureLocation.floDescription.ViewValue = ltgFixtureLocation.floDescription.CurrentValue
ltgFixtureLocation.floDescription.CssStyle = ""
ltgFixtureLocation.floDescription.CssClass = ""
ltgFixtureLocation.floDescription.ViewCustomAttributes = ""
' floIsActive
If Convert.ToString(ltgFixtureLocation.floIsActive.CurrentValue) = "1" Then
ltgFixtureLocation.floIsActive.ViewValue = "Yes"
Else
ltgFixtureLocation.floIsActive.ViewValue = "No"
End If
ltgFixtureLocation.floIsActive.CssStyle = ""
ltgFixtureLocation.floIsActive.CssClass = ""
ltgFixtureLocation.floIsActive.ViewCustomAttributes = ""
' View refer script
' floDescription
ltgFixtureLocation.floDescription.HrefValue = ""
' floIsActive
ltgFixtureLocation.floIsActive.HrefValue = ""
'
' Add Row
'
ElseIf ltgFixtureLocation.RowType = EW_ROWTYPE_ADD Then ' Add row
' floDescription
ltgFixtureLocation.floDescription.EditCustomAttributes = ""
ltgFixtureLocation.floDescription.EditValue = ew_HtmlEncode(ltgFixtureLocation.floDescription.CurrentValue)
' floIsActive
ltgFixtureLocation.floIsActive.EditCustomAttributes = ""
End If
' Row Rendered event
ltgFixtureLocation.Row_Rendered()
End Sub
'
' Validate form
'
Function ValidateForm() As Boolean
' Initialize
ParentPage.gsFormError = ""
' Check if validation required
If Not EW_SERVER_VALIDATE Then Return (ParentPage.gsFormError = "")
' Return validate result
Dim Valid As Boolean = (ParentPage.gsFormError = "")
' Form_CustomValidate event
Dim sFormCustomError As String = ""
Valid = Valid And Form_CustomValidate(sFormCustomError)
If sFormCustomError <> "" Then
If ParentPage.gsFormError <> "" Then ParentPage.gsFormError = ParentPage.gsFormError & "<br />"
ParentPage.gsFormError = ParentPage.gsFormError & sFormCustomError
End If
Return Valid
End Function
'
' Add record
'
Function AddRow() As Boolean
Dim Rs As New OrderedDictionary
Dim sSql As String, sFilter As String
Dim bInsertRow As Boolean
Dim RsChk As OleDbDataReader
Dim sIdxErrMsg As String
Dim LastInsertId As Object
' floDescription
ltgFixtureLocation.floDescription.SetDbValue(ltgFixtureLocation.floDescription.CurrentValue, System.DBNull.Value)
Rs("floDescription") = ltgFixtureLocation.floDescription.DbValue
' floIsActive
ltgFixtureLocation.floIsActive.SetDbValue((ltgFixtureLocation.floIsActive.CurrentValue <> "" And Not IsDBNull(ltgFixtureLocation.floIsActive.CurrentValue)), System.DBNull.Value)
Rs("floIsActive") = ltgFixtureLocation.floIsActive.DbValue
' Row Inserting event
bInsertRow = ltgFixtureLocation.Row_Inserting(Rs)
If bInsertRow Then
Try
ltgFixtureLocation.Insert(Rs)
AddRow = True
Catch e As Exception
If EW_DEBUG_ENABLED Then Throw
Message = e.Message
AddRow = False
End Try
Else
If ltgFixtureLocation.CancelMessage <> "" Then
Message = ltgFixtureLocation.CancelMessage
ltgFixtureLocation.CancelMessage = ""
Else
Message = "Insert cancelled"
End If
AddRow = False
End If
If AddRow Then
LastInsertId = Conn.GetLastInsertId()
ltgFixtureLocation.floID.DbValue = LastInsertId
Rs("floID") = ltgFixtureLocation.floID.DbValue
' Row Inserted event
ltgFixtureLocation.Row_Inserted(Rs)
End If
End Function
' Page Load event
Public Sub Page_Load()
'HttpContext.Current.Response.Write("Page Load")
End Sub
' Page Unload event
Public Sub Page_Unload()
'HttpContext.Current.Response.Write("Page Unload")
End Sub
' Form Custom Validate event
Public Function Form_CustomValidate(ByRef CustomError As String) As Boolean
'Return error message in CustomError
Return True
End Function
End Class
'
' ASP.NET Page_Load event
'
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.Buffer = EW_RESPONSE_BUFFER
Response.Cache.SetCacheability(HttpCacheability.NoCache)
' Page init
ltgFixtureLocation_add = New cltgFixtureLocation_add(Me)
ltgFixtureLocation_add.Page_Init()
' Page main processing
ltgFixtureLocation_add.Page_Main()
End Sub
'
' ASP.NET Page_Unload event
'
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
' Dispose page object
If ltgFixtureLocation_add IsNot Nothing Then ltgFixtureLocation_add.Dispose()
End Sub
End Class