home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
66.142.0.142
/
66.142.0.142.tar
/
66.142.0.142
/
tblLPRStatusdelete.aspx.vb
< prev
next >
Wrap
Text File
|
2010-08-24
|
15KB
|
507 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 tblLPRStatusdelete
Inherits AspNetMaker7_tfpssnet
' Page object
Public tblLPRStatus_delete As ctblLPRStatus_delete
'
' Page Class
'
Class ctblLPRStatus_delete
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 tblLPRStatus.UseTokenInUrl Then Url = Url & "t=" & tblLPRStatus.TableVar & "&" ' Add page token
Return Url
End Get
End Property
' Validate page request
Public Function IsPageRequest() As Boolean
Dim Result As Boolean
If tblLPRStatus.UseTokenInUrl Then
Result = False
If ObjForm IsNot Nothing Then
Result = (tblLPRStatus.TableVar = ObjForm.GetValue("t"))
End If
If ew_Get("t") <> "" Then
Result = (tblLPRStatus.TableVar = ew_Get("t"))
End If
Return Result
End If
Return True
End Function
' tblLPRStatus
Public Property tblLPRStatus() As ctblLPRStatus
Get
Return ParentPage.tblLPRStatus
End Get
Set(ByVal v As ctblLPRStatus)
ParentPage.tblLPRStatus = v
End Set
End Property
' tblLPRStatus
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 = "delete"
m_PageObjName = "tblLPRStatus_delete"
m_PageObjTypeName = "ctblLPRStatus_delete"
' Table Name
m_TableName = "tblLPRStatus"
' Initialize table object
tblLPRStatus = New ctblLPRStatus(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.CanDelete Then
Security.SaveLastUrl()
Page_Terminate("tblLPRStatuslist.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
tblLPRStatus.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 lTotalRecs As Integer
Public lRecCnt As Integer
Public arRecKeys() As String
'
' Page main processing
'
Sub Page_Main()
Dim sKey As String = ""
Dim bSingleDelete As Boolean = True ' Initialize as single delete
Dim nKeySelected As Integer = 0 ' Initialize selected key count
Dim sKeyFld As String, arKeyFlds() As String
Dim sFilter As String
' Load Key Parameters
If ew_Get("lstID") <> "" Then
tblLPRStatus.lstID.QueryStringValue = ew_Get("lstID")
If Not IsNumeric(tblLPRStatus.lstID.QueryStringValue) Then
Page_Terminate("tblLPRStatuslist.aspx") ' Prevent SQL injection, return to list
End If
sKey = sKey & tblLPRStatus.lstID.QueryStringValue
Else
bSingleDelete = False
End If
If bSingleDelete Then
nKeySelected = 1 ' Set up key selected count
Array.Resize(arRecKeys, 1) ' Set up key
arRecKeys(0) = sKey
Else
If HttpContext.Current.Request.Form("key_m") IsNot Nothing Then ' Key in form
arRecKeys = HttpContext.Current.Request.Form.GetValues("key_m")
nKeySelected = arRecKeys.Length
End If
End If
If nKeySelected <= 0 Then Page_Terminate("tblLPRStatuslist.aspx") ' No key specified, return to list
' Build filter
For i As Integer = 0 to arRecKeys.GetUpperBound(0)
sKey = arRecKeys(i).Trim()
sFilter = sFilter & "("
' Set up key field
sKeyFld = sKey
If Not IsNumeric(sKeyFld) Then Page_Terminate("tblLPRStatuslist.aspx") ' Prevent SQL injection, return to list
sFilter = sFilter & "[lstID]=" & ew_AdjustSql(sKeyFld) & " AND "
If sFilter.EndsWith(" AND ") Then sFilter = sFilter.Substring(0, sFilter.Length-5) & ") OR "
Next
If sFilter.EndsWith(" OR ") Then sFilter = sFilter.Substring(0, sFilter.Length-4)
' Set up filter (SQL WHERE clause)
' SQL constructor in tblLPRStatus class, tblLPRStatusinfo.aspx
tblLPRStatus.CurrentFilter = sFilter
' Get action
If ew_Post("a_delete") <> "" Then
tblLPRStatus.CurrentAction = ew_Post("a_delete")
Else
tblLPRStatus.CurrentAction = "I" ' Display record
End If
Select Case tblLPRStatus.CurrentAction
Case "D" ' Delete
tblLPRStatus.SendEmail = True ' Send email on delete success
If DeleteRows() Then ' delete rows
Message = "Delete succeeded" ' Set up success message
Page_Terminate(tblLPRStatus.ReturnUrl) ' Return to caller
End If
End Select
End Sub
'
' Function DeleteRows
' - Delete Records based on current filter
'
Function DeleteRows() As Boolean
'Dim sKey As String, sThisKey As String, sKeyFld As String
'Dim arKeyFlds() As String
'Dim RsDelete As OleDbDataReader = Nothing
'Dim sSql As String, sWrkFilter As String
'Dim RsOld As ArrayList
'DeleteRows = True
'sWrkFilter = tblLPRStatus.CurrentFilter
'' Set up filter (SQL WHERE Clause)
'' SQL constructor in tblLPRStatus class, tblLPRStatusinfo.aspx
'tblLPRStatus.CurrentFilter = sWrkFilter
'sSql = tblLPRStatus.SQL
'Conn.BeginTrans() ' Begin transaction
'Try
' RsDelete = Conn.GetDataReader(sSql)
' If Not RsDelete.HasRows Then
' Message = "No records found" ' No record found
' RsDelete.Close()
' RsDelete.Dispose()
' Return False
' End If
'Catch e As Exception
' If EW_DEBUG_ENABLED Then Throw
' Message = e.Message
' Return False
'End Try
'' Clone old rows
'RsOld = Conn.GetRows(RsDelete)
'RsDelete.Close()
'RsDelete.Dispose()
'' Call Row_Deleting event
'If DeleteRows Then
' For Each Row As OrderedDictionary in RsOld
' DeleteRows = tblLPRStatus.Row_Deleting(Row)
' If Not DeleteRows Then Exit For
' Next Row
'End If
'If DeleteRows Then
' sKey = ""
' For Each Row As OrderedDictionary in RsOld
' sThisKey = ""
' If sThisKey <> "" Then sThisKey = sThisKey & EW_COMPOSITE_KEY_SEPARATOR
' sThisKey = sThisKey & Convert.ToString(Row("lstID"))
' Try
' tblLPRStatus.Delete(Row)
' Catch e As Exception
' If EW_DEBUG_ENABLED Then Throw
' Message = e.Message ' Set up error message
' DeleteRows = False
' Exit For
' End Try
' If sKey <> "" Then sKey = sKey & ", "
' sKey = sKey & sThisKey
' Next Row
'Else
' ' Set up error message
' If tblLPRStatus.CancelMessage <> "" Then
' Message = tblLPRStatus.CancelMessage
' tblLPRStatus.CancelMessage = ""
' Else
' Message = "Delete cancelled"
' End If
'End If
'If DeleteRows Then
' ' Commit the changes
' Conn.CommitTrans()
' ' Row deleted event
' For Each Row As OrderedDictionary in RsOld
' tblLPRStatus.Row_Deleted(Row)
' Next
'Else
' Conn.RollbackTrans() ' Rollback transaction
'End If
Dim tlcsub As New AspNetMaker7_tfpssnet
If tlcsub.tlcUpdateIsActive("tblLPRStatus", "lstID", "lstIsActive", tblLPRStatus.lstID.CurrentValue, False) Then
Message = "Delete succeeded"
End If
End Function
'
' Load default values
''
Sub LoadDefaultValues()
End Sub
'
' Load recordset
'
Function LoadRecordset() As OleDbDataReader
' Recordset Selecting event
tblLPRStatus.Recordset_Selecting(tblLPRStatus.CurrentFilter)
' Load list page SQL
Dim sSql As String = tblLPRStatus.ListSQL
' Write SQL for debug
If EW_DEBUG_ENABLED Then ew_Write(sSql)
' Count
lTotalRecs = -1
Try
If sSql.StartsWith("SELECT * FROM ", StringComparison.InvariantCultureIgnoreCase) AndAlso _
ew_Empty(tblLPRStatus.SqlGroupBy) AndAlso _
ew_Empty(tblLPRStatus.SqlHaving) Then
Dim sCntSql As String = tblLPRStatus.SelectCountSQL
' Write SQL for debug
If EW_DEBUG_ENABLED Then ew_Write("<br>" & sCntSql)
lTotalRecs = Conn.ExecuteScalar(sCntSql)
End If
Catch
End Try
' Load recordset
Dim Rs As OleDbDataReader = Conn.GetDataReader(sSql)
If lTotalRecs < 0 AndAlso Rs.HasRows Then
lTotalRecs = 0
While Rs.Read()
lTotalRecs = lTotalRecs + 1
End While
Rs.Close()
Rs = Conn.GetDataReader(sSql)
End If
' Recordset Selected event
tblLPRStatus.Recordset_Selected(Rs)
Return Rs
End Function
'
' Load row based on key values
'
Function LoadRow() As Boolean
Dim RsRow As OleDbDataReader
Dim sFilter As String = tblLPRStatus.KeyFilter
' Row Selecting event
tblLPRStatus.Row_Selecting(sFilter)
' Load SQL based on filter
tblLPRStatus.CurrentFilter = sFilter
Dim sSql As String = tblLPRStatus.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
tblLPRStatus.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)
tblLPRStatus.lstID.DbValue = RsRow("lstID")
tblLPRStatus.lstDescription.DbValue = RsRow("lstDescription")
End Sub
'
' Render row values based on field settings
'
Sub RenderRow()
' Row Rendering event
tblLPRStatus.Row_Rendering()
'
' Common render codes for all row types
'
' lstDescription
tblLPRStatus.lstDescription.CellCssStyle = ""
tblLPRStatus.lstDescription.CellCssClass = ""
'
' View Row
'
If tblLPRStatus.RowType = EW_ROWTYPE_VIEW Then ' View row
' lstDescription
tblLPRStatus.lstDescription.ViewValue = tblLPRStatus.lstDescription.CurrentValue
tblLPRStatus.lstDescription.CssStyle = ""
tblLPRStatus.lstDescription.CssClass = ""
tblLPRStatus.lstDescription.ViewCustomAttributes = ""
' View refer script
' lstDescription
tblLPRStatus.lstDescription.HrefValue = ""
End If
' Row Rendered event
tblLPRStatus.Row_Rendered()
End Sub
' 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
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
tblLPRStatus_delete = New ctblLPRStatus_delete(Me)
tblLPRStatus_delete.Page_Init()
' Page main processing
tblLPRStatus_delete.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 tblLPRStatus_delete IsNot Nothing Then tblLPRStatus_delete.Dispose()
End Sub
End Class