home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
66.142.0.142
/
66.142.0.142.tar
/
66.142.0.142
/
tblFixtureMastersrch.aspx.vb
< prev
next >
Wrap
Text File
|
2010-08-24
|
20KB
|
577 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 tblFixtureMastersrch
Inherits AspNetMaker7_tfpssnet
' Page object
Public tblFixtureMaster_search As ctblFixtureMaster_search
'
' Page Class
'
Class ctblFixtureMaster_search
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 tblFixtureMaster.UseTokenInUrl Then Url = Url & "t=" & tblFixtureMaster.TableVar & "&" ' Add page token
Return Url
End Get
End Property
' Validate page request
Public Function IsPageRequest() As Boolean
Dim Result As Boolean
If tblFixtureMaster.UseTokenInUrl Then
Result = False
If ObjForm IsNot Nothing Then
Result = (tblFixtureMaster.TableVar = ObjForm.GetValue("t"))
End If
If ew_Get("t") <> "" Then
Result = (tblFixtureMaster.TableVar = ew_Get("t"))
End If
Return Result
End If
Return True
End Function
' tblFixtureMaster
Public Property tblFixtureMaster() As ctblFixtureMaster
Get
Return ParentPage.tblFixtureMaster
End Get
Set(ByVal v As ctblFixtureMaster)
ParentPage.tblFixtureMaster = v
End Set
End Property
' tblFixtureMaster
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 = "search"
m_PageObjName = "tblFixtureMaster_search"
m_PageObjTypeName = "ctblFixtureMaster_search"
' Table Name
m_TableName = "tblFixtureMaster"
' Initialize table object
tblFixtureMaster = New ctblFixtureMaster(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.CanSearch Then
Security.SaveLastUrl()
Page_Terminate("tblFixtureMasterlist.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
tblFixtureMaster.Dispose()
tblEmployees.Dispose()
' Go to URL if specified
If url <> "" Then
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.Redirect(url)
End If
End Sub
'
' Page main processing
'
Sub Page_Main()
ObjForm = New cFormObj
If IsPageRequest Then ' Validate request
' Get action
tblFixtureMaster.CurrentAction = ObjForm.GetValue("a_search")
Select Case tblFixtureMaster.CurrentAction
Case "S" ' Get Search Criteria
' Build search string for advanced search, remove blank field
Dim sSrchStr As String
LoadSearchValues() ' Get search values
If ValidateSearch() Then
sSrchStr = BuildAdvancedSearch()
Else
sSrchStr = ""
Message = ParentPage.gsSearchError
End If
If sSrchStr <> "" Then
sSrchStr = tblFixtureMaster.UrlParm(sSrchStr)
Page_Terminate("tblFixtureMasterlist.aspx" & "?" & sSrchStr) ' Go to list page
End If
End Select
End If
' Restore search settings from Session
If ParentPage.gsSearchError = "" Then
LoadAdvancedSearch()
End If
' Render row for search
tblFixtureMaster.RowType = EW_ROWTYPE_SEARCH
RenderRow()
End Sub
'
' Build advanced search
'
Function BuildAdvancedSearch() As String
Dim sSrchUrl As String = ""
BuildSearchUrl(sSrchUrl, tblFixtureMaster.lfxMFG) ' lfxMFG
BuildSearchUrl(sSrchUrl, tblFixtureMaster.lfxModelType) ' lfxModelType
BuildSearchUrl(sSrchUrl, tblFixtureMaster.lfxSerialNumber) ' lfxSerialNumber
BuildSearchUrl(sSrchUrl, tblFixtureMaster.lfxLamp) ' lfxLamp
BuildSearchUrl(sSrchUrl, tblFixtureMaster.lfxLocationID) ' lfxLocationID
BuildSearchUrl(sSrchUrl, tblFixtureMaster.lfxHangPos) ' lfxHangPos
BuildSearchUrl(sSrchUrl, tblFixtureMaster.lfxChannel) ' lfxChannel
BuildSearchUrl(sSrchUrl, tblFixtureMaster.lfxNotes) ' lfxNotes
Return sSrchUrl
End Function
'
' Build search URL
'
Sub BuildSearchUrl(ByRef Url As String, ByRef Fld As Object)
Dim FldVal As String, FldOpr As String, FldCond As String, FldVal2 As String, FldOpr2 As String
Dim FldParm As String
Dim IsValidValue As Boolean, sWrk As String = ""
FldParm = Fld.FldVar.Substring(2)
FldVal = ObjForm.GetValue("x_" & FldParm)
FldOpr = ObjForm.GetValue("z_" & FldParm)
FldCond = ObjForm.GetValue("v_" & FldParm)
FldVal2 = ObjForm.GetValue("y_" & FldParm)
FldOpr2 = ObjForm.GetValue("w_" & FldParm)
If ew_SameText(FldOpr, "BETWEEN") Then
IsValidValue = (Fld.FldDataType <> EW_DATATYPE_NUMBER) OrElse _
(Fld.FldDataType = EW_DATATYPE_NUMBER AndAlso IsNumeric(FldVal) AndAlso IsNumeric(FldVal2))
If ew_NotEmpty(FldVal) AndAlso ew_NotEmpty(FldVal2) AndAlso IsValidValue Then
sWrk = "x_" & FldParm & "=" & HttpContext.Current.Server.UrlEncode(FldVal) & _
"&y_" & FldParm & "=" & HttpContext.Current.Server.UrlEncode(FldVal2) & _
"&z_" & FldParm & "=" & HttpContext.Current.Server.UrlEncode(FldOpr)
End If
ElseIf ew_SameText(FldOpr, "IS NULL") OrElse ew_SameText(FldOpr, "IS NOT NULL") Then
sWrk = "x_" & FldParm & "=" & HttpContext.Current.Server.UrlEncode(FldVal) & _
"&z_" & FldParm & "=" & HttpContext.Current.Server.UrlEncode(FldOpr)
Else
IsValidValue = (Fld.FldDataType <> EW_DATATYPE_NUMBER) OrElse _
(Fld.FldDataType = EW_DATATYPE_NUMBER AndAlso IsNumeric(FldVal))
If ew_NotEmpty(FldVal) AndAlso IsValidValue AndAlso ew_IsValidOpr(FldOpr, Fld.FldDataType) Then
sWrk = "x_" & FldParm & "=" & HttpContext.Current.Server.UrlEncode(FldVal) & _
"&z_" & FldParm & "=" & HttpContext.Current.Server.UrlEncode(FldOpr)
End If
IsValidValue = (Fld.FldDataType <> EW_DATATYPE_NUMBER) OrElse _
(Fld.FldDataType = EW_DATATYPE_NUMBER AndAlso IsNumeric(FldVal2))
If ew_NotEmpty(FldVal2) AndAlso IsValidValue AndAlso ew_IsValidOpr(FldOpr2, Fld.FldDataType) Then
If sWrk <> "" Then sWrk = sWrk & "&v_" & FldParm & "=" & FldCond & "&"
sWrk = sWrk & "y_" & FldParm & "=" & HttpContext.Current.Server.UrlEncode(FldVal2) & _
"&w_" & FldParm & "=" & HttpContext.Current.Server.UrlEncode(FldOpr2)
End If
End If
If sWrk <> "" Then
If Url <> "" Then Url = Url & "&"
Url = Url & sWrk
End If
End Sub
'
' Load default values
'
Sub LoadDefaultValues()
End Sub
'
' Load search values for validation
'
Sub LoadSearchValues()
tblFixtureMaster.lfxMFG.AdvancedSearch.SearchValue = ObjForm.GetValue("x_lfxMFG")
tblFixtureMaster.lfxMFG.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_lfxMFG")
tblFixtureMaster.lfxModelType.AdvancedSearch.SearchValue = ObjForm.GetValue("x_lfxModelType")
tblFixtureMaster.lfxModelType.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_lfxModelType")
tblFixtureMaster.lfxSerialNumber.AdvancedSearch.SearchValue = ObjForm.GetValue("x_lfxSerialNumber")
tblFixtureMaster.lfxSerialNumber.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_lfxSerialNumber")
tblFixtureMaster.lfxLamp.AdvancedSearch.SearchValue = ObjForm.GetValue("x_lfxLamp")
tblFixtureMaster.lfxLamp.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_lfxLamp")
tblFixtureMaster.lfxLocationID.AdvancedSearch.SearchValue = ObjForm.GetValue("x_lfxLocationID")
tblFixtureMaster.lfxLocationID.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_lfxLocationID")
tblFixtureMaster.lfxHangPos.AdvancedSearch.SearchValue = ObjForm.GetValue("x_lfxHangPos")
tblFixtureMaster.lfxHangPos.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_lfxHangPos")
tblFixtureMaster.lfxChannel.AdvancedSearch.SearchValue = ObjForm.GetValue("x_lfxChannel")
tblFixtureMaster.lfxChannel.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_lfxChannel")
tblFixtureMaster.lfxNotes.AdvancedSearch.SearchValue = ObjForm.GetValue("x_lfxNotes")
tblFixtureMaster.lfxNotes.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_lfxNotes")
End Sub
'
' Render row values based on field settings
'
Sub RenderRow()
' Row Rendering event
tblFixtureMaster.Row_Rendering()
'
' Common render codes for all row types
'
' lfxMFG
tblFixtureMaster.lfxMFG.CellCssStyle = ""
tblFixtureMaster.lfxMFG.CellCssClass = ""
' lfxModelType
tblFixtureMaster.lfxModelType.CellCssStyle = ""
tblFixtureMaster.lfxModelType.CellCssClass = ""
' lfxSerialNumber
tblFixtureMaster.lfxSerialNumber.CellCssStyle = ""
tblFixtureMaster.lfxSerialNumber.CellCssClass = ""
' lfxLamp
tblFixtureMaster.lfxLamp.CellCssStyle = ""
tblFixtureMaster.lfxLamp.CellCssClass = ""
' lfxLocationID
tblFixtureMaster.lfxLocationID.CellCssStyle = ""
tblFixtureMaster.lfxLocationID.CellCssClass = ""
' lfxHangPos
tblFixtureMaster.lfxHangPos.CellCssStyle = ""
tblFixtureMaster.lfxHangPos.CellCssClass = ""
' lfxChannel
tblFixtureMaster.lfxChannel.CellCssStyle = ""
tblFixtureMaster.lfxChannel.CellCssClass = ""
' lfxNotes
tblFixtureMaster.lfxNotes.CellCssStyle = ""
tblFixtureMaster.lfxNotes.CellCssClass = ""
'
' View Row
'
If tblFixtureMaster.RowType = EW_ROWTYPE_VIEW Then ' View row
' lfxMFG
tblFixtureMaster.lfxMFG.ViewValue = tblFixtureMaster.lfxMFG.CurrentValue
tblFixtureMaster.lfxMFG.CssStyle = ""
tblFixtureMaster.lfxMFG.CssClass = ""
tblFixtureMaster.lfxMFG.ViewCustomAttributes = ""
' lfxModelType
tblFixtureMaster.lfxModelType.ViewValue = tblFixtureMaster.lfxModelType.CurrentValue
tblFixtureMaster.lfxModelType.CssStyle = ""
tblFixtureMaster.lfxModelType.CssClass = ""
tblFixtureMaster.lfxModelType.ViewCustomAttributes = ""
' lfxSerialNumber
tblFixtureMaster.lfxSerialNumber.ViewValue = tblFixtureMaster.lfxSerialNumber.CurrentValue
tblFixtureMaster.lfxSerialNumber.CssStyle = ""
tblFixtureMaster.lfxSerialNumber.CssClass = ""
tblFixtureMaster.lfxSerialNumber.ViewCustomAttributes = ""
' lfxLamp
tblFixtureMaster.lfxLamp.ViewValue = tblFixtureMaster.lfxLamp.CurrentValue
tblFixtureMaster.lfxLamp.CssStyle = ""
tblFixtureMaster.lfxLamp.CssClass = ""
tblFixtureMaster.lfxLamp.ViewCustomAttributes = ""
' lfxLocationID
If ew_NotEmpty(tblFixtureMaster.lfxLocationID.CurrentValue) Then
sSqlWrk = "SELECT [locDescription] FROM [tblLocations] WHERE [locID] = " & ew_AdjustSql(tblFixtureMaster.lfxLocationID.CurrentValue) & ""
sSqlWrk = sSqlWrk & " AND (" & "[locLighting]=True" & ")"
sSqlWrk = sSqlWrk & " ORDER BY [locDescription] "
RsWrk = Conn.GetTempDataReader(sSqlWrk)
If RsWrk.Read() Then
tblFixtureMaster.lfxLocationID.ViewValue = RsWrk("locDescription")
Else
tblFixtureMaster.lfxLocationID.ViewValue = tblFixtureMaster.lfxLocationID.CurrentValue
End If
Conn.CloseTempDataReader()
Else
tblFixtureMaster.lfxLocationID.ViewValue = System.DBNull.Value
End If
tblFixtureMaster.lfxLocationID.CssStyle = ""
tblFixtureMaster.lfxLocationID.CssClass = ""
tblFixtureMaster.lfxLocationID.ViewCustomAttributes = ""
' lfxHangPos
tblFixtureMaster.lfxHangPos.ViewValue = tblFixtureMaster.lfxHangPos.CurrentValue
tblFixtureMaster.lfxHangPos.CssStyle = ""
tblFixtureMaster.lfxHangPos.CssClass = ""
tblFixtureMaster.lfxHangPos.ViewCustomAttributes = ""
' lfxChannel
tblFixtureMaster.lfxChannel.ViewValue = tblFixtureMaster.lfxChannel.CurrentValue
tblFixtureMaster.lfxChannel.CssStyle = ""
tblFixtureMaster.lfxChannel.CssClass = ""
tblFixtureMaster.lfxChannel.ViewCustomAttributes = ""
' lfxNotes
tblFixtureMaster.lfxNotes.ViewValue = tblFixtureMaster.lfxNotes.CurrentValue
tblFixtureMaster.lfxNotes.CssStyle = ""
tblFixtureMaster.lfxNotes.CssClass = ""
tblFixtureMaster.lfxNotes.ViewCustomAttributes = ""
' View refer script
' lfxMFG
tblFixtureMaster.lfxMFG.HrefValue = ""
' lfxModelType
tblFixtureMaster.lfxModelType.HrefValue = ""
' lfxSerialNumber
tblFixtureMaster.lfxSerialNumber.HrefValue = ""
' lfxLamp
tblFixtureMaster.lfxLamp.HrefValue = ""
' lfxLocationID
tblFixtureMaster.lfxLocationID.HrefValue = ""
' lfxHangPos
tblFixtureMaster.lfxHangPos.HrefValue = ""
' lfxChannel
tblFixtureMaster.lfxChannel.HrefValue = ""
' lfxNotes
tblFixtureMaster.lfxNotes.HrefValue = ""
'
' Search Row
'
ElseIf tblFixtureMaster.RowType = EW_ROWTYPE_SEARCH Then ' Search row
' lfxMFG
tblFixtureMaster.lfxMFG.EditCustomAttributes = ""
tblFixtureMaster.lfxMFG.EditValue = ew_HtmlEncode(tblFixtureMaster.lfxMFG.AdvancedSearch.SearchValue)
' lfxModelType
tblFixtureMaster.lfxModelType.EditCustomAttributes = ""
tblFixtureMaster.lfxModelType.EditValue = ew_HtmlEncode(tblFixtureMaster.lfxModelType.AdvancedSearch.SearchValue)
' lfxSerialNumber
tblFixtureMaster.lfxSerialNumber.EditCustomAttributes = ""
tblFixtureMaster.lfxSerialNumber.EditValue = ew_HtmlEncode(tblFixtureMaster.lfxSerialNumber.AdvancedSearch.SearchValue)
' lfxLamp
tblFixtureMaster.lfxLamp.EditCustomAttributes = ""
tblFixtureMaster.lfxLamp.EditValue = ew_HtmlEncode(tblFixtureMaster.lfxLamp.AdvancedSearch.SearchValue)
' lfxLocationID
tblFixtureMaster.lfxLocationID.EditCustomAttributes = ""
sSqlWrk = "SELECT [locID], [locDescription], '' AS Disp2Fld, '' AS SelectFilterFld FROM [tblLocations]"
sWhereWrk = ""
If sWhereWrk <> "" Then sWhereWrk = "(" & sWhereWrk & ") AND "
sWhereWrk = sWhereWrk & "(" & "[locLighting]=True" & ")"
If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
sSqlWrk = sSqlWrk & " ORDER BY [locDescription] "
arwrk = Conn.GetRows(sSqlWrk)
arwrk.Insert(0, New Object(){"", "Please Select"})
tblFixtureMaster.lfxLocationID.EditValue = arwrk
' lfxHangPos
tblFixtureMaster.lfxHangPos.EditCustomAttributes = ""
tblFixtureMaster.lfxHangPos.EditValue = ew_HtmlEncode(tblFixtureMaster.lfxHangPos.AdvancedSearch.SearchValue)
' lfxChannel
tblFixtureMaster.lfxChannel.EditCustomAttributes = ""
tblFixtureMaster.lfxChannel.EditValue = ew_HtmlEncode(tblFixtureMaster.lfxChannel.AdvancedSearch.SearchValue)
' lfxNotes
tblFixtureMaster.lfxNotes.EditCustomAttributes = ""
tblFixtureMaster.lfxNotes.EditValue = ew_HtmlEncode(tblFixtureMaster.lfxNotes.AdvancedSearch.SearchValue)
End If
' Row Rendered event
tblFixtureMaster.Row_Rendered()
End Sub
'
' Validate search
'
Function ValidateSearch() As Boolean
' Initialize
ParentPage.gsSearchError = ""
' Check if validation required
If Not EW_SERVER_VALIDATE Then Return True ' Skip
If Not ew_CheckInteger(tblFixtureMaster.lfxChannel.AdvancedSearch.SearchValue) Then
If ParentPage.gsSearchError <> "" Then ParentPage.gsSearchError = ParentPage.gsSearchError & "<br />"
ParentPage.gsSearchError = ParentPage.gsSearchError & "Incorrect integer - Channel"
End If
' Return validate result
Dim Valid As Boolean = (ParentPage.gsSearchError = "")
' Form_CustomValidate event
Dim sFormCustomError As String = ""
Valid = Valid And Form_CustomValidate(sFormCustomError)
If sFormCustomError <> "" Then
If ParentPage.gsSearchError <> "" Then ParentPage.gsSearchError = ParentPage.gsSearchError & "<br />"
ParentPage.gsSearchError = ParentPage.gsSearchError & sFormCustomError
End If
Return Valid
End Function
'
' Load advanced search
'
Sub LoadAdvancedSearch()
tblFixtureMaster.lfxMFG.AdvancedSearch.SearchValue = tblFixtureMaster.GetAdvancedSearch("x_lfxMFG")
tblFixtureMaster.lfxModelType.AdvancedSearch.SearchValue = tblFixtureMaster.GetAdvancedSearch("x_lfxModelType")
tblFixtureMaster.lfxSerialNumber.AdvancedSearch.SearchValue = tblFixtureMaster.GetAdvancedSearch("x_lfxSerialNumber")
tblFixtureMaster.lfxLamp.AdvancedSearch.SearchValue = tblFixtureMaster.GetAdvancedSearch("x_lfxLamp")
tblFixtureMaster.lfxLocationID.AdvancedSearch.SearchValue = tblFixtureMaster.GetAdvancedSearch("x_lfxLocationID")
tblFixtureMaster.lfxHangPos.AdvancedSearch.SearchValue = tblFixtureMaster.GetAdvancedSearch("x_lfxHangPos")
tblFixtureMaster.lfxChannel.AdvancedSearch.SearchValue = tblFixtureMaster.GetAdvancedSearch("x_lfxChannel")
tblFixtureMaster.lfxNotes.AdvancedSearch.SearchValue = tblFixtureMaster.GetAdvancedSearch("x_lfxNotes")
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
' 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
tblFixtureMaster_search = New ctblFixtureMaster_search(Me)
tblFixtureMaster_search.Page_Init()
' Page main processing
tblFixtureMaster_search.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 tblFixtureMaster_search IsNot Nothing Then tblFixtureMaster_search.Dispose()
End Sub
End Class