home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
66.142.0.142
/
66.142.0.142.tar
/
66.142.0.142
/
tblLPRFixtureLocationadd.aspx.vb
< prev
next >
Wrap
Text File
|
2010-08-24
|
14KB
|
504 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 tblLPRFixtureLocationadd
Inherits AspNetMaker7_tfpssnet
' Page object
Public tblLPRFixtureLocation_add As ctblLPRFixtureLocation_add
'
' Page Class
'
Class ctblLPRFixtureLocation_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 tblLPRFixtureLocation.UseTokenInUrl Then Url = Url & "t=" & tblLPRFixtureLocation.TableVar & "&" ' Add page token
Return Url
End Get
End Property
' Validate page request
Public Function IsPageRequest() As Boolean
Dim Result As Boolean
If tblLPRFixtureLocation.UseTokenInUrl Then
Result = False
If ObjForm IsNot Nothing Then
Result = (tblLPRFixtureLocation.TableVar = ObjForm.GetValue("t"))
End If
If ew_Get("t") <> "" Then
Result = (tblLPRFixtureLocation.TableVar = ew_Get("t"))
End If
Return Result
End If
Return True
End Function
' tblLPRFixtureLocation
Public Property tblLPRFixtureLocation() As ctblLPRFixtureLocation
Get
Return ParentPage.tblLPRFixtureLocation
End Get
Set(ByVal v As ctblLPRFixtureLocation)
ParentPage.tblLPRFixtureLocation = v
End Set
End Property
' tblLPRFixtureLocation
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 = "tblLPRFixtureLocation_add"
m_PageObjTypeName = "ctblLPRFixtureLocation_add"
' Table Name
m_TableName = "tblLPRFixtureLocation"
' Initialize table object
tblLPRFixtureLocation = New ctblLPRFixtureLocation(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("tblLPRFixtureLocationlist.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
tblLPRFixtureLocation.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
tblLPRFixtureLocation.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
tblLPRFixtureLocation.CurrentAction = ObjForm.GetValue("a_add") ' Get form action
LoadFormValues() ' Load form values
' Validate Form
If Not ValidateForm() Then
tblLPRFixtureLocation.CurrentAction = "I" ' Form error, reset action
Message = ParentPage.gsFormError
End If
' Not post back
Else
If bCopy Then
tblLPRFixtureLocation.CurrentAction = "C" ' Copy Record
Else
tblLPRFixtureLocation.CurrentAction = "I" ' Display Blank Record
LoadDefaultValues() ' Load default values
End If
End If
' Perform action based on action code
Select Case tblLPRFixtureLocation.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("tblLPRFixtureLocationlist.aspx") ' No matching record, return to list
End If
Case "A" ' Add new record
tblLPRFixtureLocation.SendEmail = True ' Send email on add success
If AddRow() Then ' Add successful
Message = "Add succeeded" ' Set up success message
Dim sReturnUrl As String = tblLPRFixtureLocation.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
tblLPRFixtureLocation.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()
End Sub
'
' Load form values
'
Sub LoadFormValues()
tblLPRFixtureLocation.floDescription.FormValue = ObjForm.GetValue("x_floDescription")
tblLPRFixtureLocation.floDescription.OldValue = ObjForm.GetValue("o_floDescription")
tblLPRFixtureLocation.floIsActive.FormValue = ObjForm.GetValue("x_floIsActive")
tblLPRFixtureLocation.floIsActive.OldValue = ObjForm.GetValue("o_floIsActive")
tblLPRFixtureLocation.floID.FormValue = ObjForm.GetValue("x_floID")
End Sub
'
' Restore form values
'
Sub RestoreFormValues()
tblLPRFixtureLocation.floDescription.CurrentValue = tblLPRFixtureLocation.floDescription.FormValue
tblLPRFixtureLocation.floIsActive.CurrentValue = tblLPRFixtureLocation.floIsActive.FormValue
tblLPRFixtureLocation.floID.CurrentValue = tblLPRFixtureLocation.floID.FormValue
End Sub
'
' Load row based on key values
'
Function LoadRow() As Boolean
Dim RsRow As OleDbDataReader
Dim sFilter As String = tblLPRFixtureLocation.KeyFilter
' Row Selecting event
tblLPRFixtureLocation.Row_Selecting(sFilter)
' Load SQL based on filter
tblLPRFixtureLocation.CurrentFilter = sFilter
Dim sSql As String = tblLPRFixtureLocation.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
tblLPRFixtureLocation.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)
tblLPRFixtureLocation.floID.DbValue = RsRow("floID")
tblLPRFixtureLocation.floDescription.DbValue = RsRow("floDescription")
tblLPRFixtureLocation.floIsActive.DbValue = IIf(ew_ConvertToBool(RsRow("floIsActive")), "1", "0")
End Sub
'
' Render row values based on field settings
'
Sub RenderRow()
' Row Rendering event
tblLPRFixtureLocation.Row_Rendering()
'
' Common render codes for all row types
'
' floDescription
tblLPRFixtureLocation.floDescription.CellCssStyle = ""
tblLPRFixtureLocation.floDescription.CellCssClass = ""
' locIsActive
tblLPRFixtureLocation.floIsActive.CellCssStyle = ""
tblLPRFixtureLocation.floIsActive.CellCssClass = ""
'
' View Row
'
If tblLPRFixtureLocation.RowType = EW_ROWTYPE_VIEW Then ' View row
' floDescription
tblLPRFixtureLocation.floDescription.ViewValue = tblLPRFixtureLocation.floDescription.CurrentValue
tblLPRFixtureLocation.floDescription.CssStyle = ""
tblLPRFixtureLocation.floDescription.CssClass = ""
tblLPRFixtureLocation.floDescription.ViewCustomAttributes = ""
' locIsActive
If Convert.ToString(tblLPRFixtureLocation.floIsActive.CurrentValue) = "1" Then
tblLPRFixtureLocation.floIsActive.ViewValue = "Yes"
Else
tblLPRFixtureLocation.floIsActive.ViewValue = "No"
End If
tblLPRFixtureLocation.floIsActive.CssStyle = ""
tblLPRFixtureLocation.floIsActive.CssClass = ""
tblLPRFixtureLocation.floIsActive.ViewCustomAttributes = ""
' View refer script
' floDescription
tblLPRFixtureLocation.floDescription.HrefValue = ""
' locIsActive
tblLPRFixtureLocation.floIsActive.HrefValue = ""
'
' Add Row
'
ElseIf tblLPRFixtureLocation.RowType = EW_ROWTYPE_ADD Then ' Add row
' floDescription
tblLPRFixtureLocation.floDescription.EditCustomAttributes = ""
tblLPRFixtureLocation.floDescription.EditValue = ew_HtmlEncode(tblLPRFixtureLocation.floDescription.CurrentValue)
' locIsActive
tblLPRFixtureLocation.floIsActive.EditCustomAttributes = ""
End If
' Row Rendered event
tblLPRFixtureLocation.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
tblLPRFixtureLocation.floDescription.SetDbValue(tblLPRFixtureLocation.floDescription.CurrentValue, System.DBNull.Value)
Rs("floDescription") = tblLPRFixtureLocation.floDescription.DbValue
' floIsActive
Rs("floIsActive") = True
' Row Inserting event
bInsertRow = tblLPRFixtureLocation.Row_Inserting(Rs)
If bInsertRow Then
Try
tblLPRFixtureLocation.Insert(Rs)
AddRow = True
Catch e As Exception
If EW_DEBUG_ENABLED Then Throw
Message = e.Message
AddRow = False
End Try
Else
If tblLPRFixtureLocation.CancelMessage <> "" Then
Message = tblLPRFixtureLocation.CancelMessage
tblLPRFixtureLocation.CancelMessage = ""
Else
Message = "Insert cancelled"
End If
AddRow = False
End If
If AddRow Then
LastInsertId = Conn.GetLastInsertId()
tblLPRFixtureLocation.floID.DbValue = LastInsertId
Rs("floID") = tblLPRFixtureLocation.floID.DbValue
' Row Inserted event
tblLPRFixtureLocation.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
tblLPRFixtureLocation_add = New ctblLPRFixtureLocation_add(Me)
tblLPRFixtureLocation_add.Page_Init()
' Page main processing
tblLPRFixtureLocation_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 tblLPRFixtureLocation_add IsNot Nothing Then tblLPRFixtureLocation_add.Dispose()
End Sub
End Class