home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
66.142.0.142
/
66.142.0.142.tar
/
66.142.0.142
/
tblEmployeeStatusdelete.aspx.vb
< prev
next >
Wrap
Text File
|
2010-08-24
|
16KB
|
513 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 tblEmployeeStatusdelete
Inherits AspNetMaker7_tfpssnet
' Page object
Public tblEmployeeStatus_delete As ctblEmployeeStatus_delete
'
' Page Class
'
Class ctblEmployeeStatus_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 tblEmployeeStatus.UseTokenInUrl Then Url = Url & "t=" & tblEmployeeStatus.TableVar & "&" ' Add page token
Return Url
End Get
End Property
' Validate page request
Public Function IsPageRequest() As Boolean
Dim Result As Boolean
If tblEmployeeStatus.UseTokenInUrl Then
Result = False
If ObjForm IsNot Nothing Then
Result = (tblEmployeeStatus.TableVar = ObjForm.GetValue("t"))
End If
If ew_Get("t") <> "" Then
Result = (tblEmployeeStatus.TableVar = ew_Get("t"))
End If
Return Result
End If
Return True
End Function
' tblEmployeeStatus
Public Property tblEmployeeStatus() As ctblEmployeeStatus
Get
Return ParentPage.tblEmployeeStatus
End Get
Set(ByVal v As ctblEmployeeStatus)
ParentPage.tblEmployeeStatus = v
End Set
End Property
' tblEmployeeStatus
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 = "tblEmployeeStatus_delete"
m_PageObjTypeName = "ctblEmployeeStatus_delete"
' Table Name
m_TableName = "tblEmployeeStatus"
' Initialize table object
tblEmployeeStatus = New ctblEmployeeStatus(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("tblEmployeeStatuslist.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
tblEmployeeStatus.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("ID") <> "" Then
tblEmployeeStatus.ID.QueryStringValue = ew_Get("ID")
If Not IsNumeric(tblEmployeeStatus.ID.QueryStringValue) Then
Page_Terminate("tblEmployeeStatuslist.aspx") ' Prevent SQL injection, return to list
End If
sKey = sKey & tblEmployeeStatus.ID.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("tblEmployeeStatuslist.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("tblEmployeeStatuslist.aspx") ' Prevent SQL injection, return to list
sFilter = sFilter & "[ID]=" & 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 tblEmployeeStatus class, tblEmployeeStatusinfo.aspx
tblEmployeeStatus.CurrentFilter = sFilter
' Get action
If ew_Post("a_delete") <> "" Then
tblEmployeeStatus.CurrentAction = ew_Post("a_delete")
Else
tblEmployeeStatus.CurrentAction = "I" ' Display record
End If
Select Case tblEmployeeStatus.CurrentAction
Case "D" ' Delete
tblEmployeeStatus.SendEmail = True ' Send email on delete success
If DeleteRows() Then ' delete rows
Message = "Delete succeeded" ' Set up success message
Page_Terminate(tblEmployeeStatus.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 = tblEmployeeStatus.CurrentFilter
'' Set up filter (SQL WHERE Clause)
'' SQL constructor in tblEmployeeStatus class, tblEmployeeStatusinfo.aspx
'tblEmployeeStatus.CurrentFilter = sWrkFilter
'sSql = tblEmployeeStatus.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 = tblEmployeeStatus.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("ID"))
' Try
' tblEmployeeStatus.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 tblEmployeeStatus.CancelMessage <> "" Then
' Message = tblEmployeeStatus.CancelMessage
' tblEmployeeStatus.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
' tblEmployeeStatus.Row_Deleted(Row)
' Next
'Else
' Conn.RollbackTrans() ' Rollback transaction
'End If
Dim tlcsub As New AspNetMaker7_tfpssnet
If tlcsub.tlcUpdateIsActive("tblEmployeeStatus", "ID", "tscIsActive", tblEmployeeStatus.ID.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
tblEmployeeStatus.Recordset_Selecting(tblEmployeeStatus.CurrentFilter)
' Load list page SQL
Dim sSql As String = tblEmployeeStatus.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(tblEmployeeStatus.SqlGroupBy) AndAlso _
ew_Empty(tblEmployeeStatus.SqlHaving) Then
Dim sCntSql As String = tblEmployeeStatus.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
tblEmployeeStatus.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 = tblEmployeeStatus.KeyFilter
' Row Selecting event
tblEmployeeStatus.Row_Selecting(sFilter)
' Load SQL based on filter
tblEmployeeStatus.CurrentFilter = sFilter
Dim sSql As String = tblEmployeeStatus.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
tblEmployeeStatus.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)
tblEmployeeStatus.ID.DbValue = RsRow("ID")
tblEmployeeStatus.tscStatus.DbValue = RsRow("tscStatus")
End Sub
'
' Render row values based on field settings
'
Sub RenderRow()
' Row Rendering event
tblEmployeeStatus.Row_Rendering()
'
' Common render codes for all row types
'
' tscStatus
tblEmployeeStatus.tscStatus.CellCssStyle = ""
tblEmployeeStatus.tscStatus.CellCssClass = ""
'
' View Row
'
If tblEmployeeStatus.RowType = EW_ROWTYPE_VIEW Then ' View row
' ID
tblEmployeeStatus.ID.ViewValue = tblEmployeeStatus.ID.CurrentValue
tblEmployeeStatus.ID.CssStyle = ""
tblEmployeeStatus.ID.CssClass = ""
tblEmployeeStatus.ID.ViewCustomAttributes = ""
' tscStatus
tblEmployeeStatus.tscStatus.ViewValue = tblEmployeeStatus.tscStatus.CurrentValue
tblEmployeeStatus.tscStatus.CssStyle = ""
tblEmployeeStatus.tscStatus.CssClass = ""
tblEmployeeStatus.tscStatus.ViewCustomAttributes = ""
' View refer script
' tscStatus
tblEmployeeStatus.tscStatus.HrefValue = ""
End If
' Row Rendered event
tblEmployeeStatus.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
tblEmployeeStatus_delete = New ctblEmployeeStatus_delete(Me)
tblEmployeeStatus_delete.Page_Init()
' Page main processing
tblEmployeeStatus_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 tblEmployeeStatus_delete IsNot Nothing Then tblEmployeeStatus_delete.Dispose()
End Sub
End Class