5246 lines
No EOL
234 KiB
VB.net
5246 lines
No EOL
234 KiB
VB.net
|
|
' This file implements the TableControl, TableControlRow, and RecordControl classes for the
|
|
' ShowViewPersons.aspx page. The Row or RecordControl classes are the
|
|
' ideal place to add code customizations. For example, you can override the LoadData,
|
|
' CreateWhereClause, DataBind, SaveData, GetUIData, and Validate methods.
|
|
|
|
#Region "Imports statements"
|
|
|
|
Option Strict On
|
|
Imports Microsoft.VisualBasic
|
|
Imports BaseClasses.Web.UI.WebControls
|
|
Imports System
|
|
Imports System.Collections
|
|
Imports System.Collections.Generic
|
|
|
|
Imports System.Web
|
|
Imports System.Web.UI
|
|
Imports System.Web.UI.WebControls
|
|
Imports BaseClasses
|
|
Imports BaseClasses.Data
|
|
Imports BaseClasses.Utils
|
|
Imports ReportTools.ReportCreator
|
|
Imports ReportTools.Shared
|
|
|
|
|
|
|
|
Imports Persons.Business
|
|
Imports Persons.Data
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
Namespace Persons.UI.Controls.ShowViewPersons
|
|
|
|
#Region "Section 1: Place your customizations here."
|
|
|
|
|
|
Public Class View_PersonsTableControlRow
|
|
Inherits BaseView_PersonsTableControlRow
|
|
' The BaseView_PersonsTableControlRow implements code for a ROW within the
|
|
' the View_PersonsTableControl table. The BaseView_PersonsTableControlRow implements the DataBind and SaveData methods.
|
|
' The loading of data is actually performed by the LoadData method in the base class of View_PersonsTableControl.
|
|
|
|
' This is the ideal place to add your code customizations. For example, you can override the DataBind,
|
|
' SaveData, GetUIData, and Validate methods.
|
|
|
|
|
|
Private Sub View_PersonsTableControlRow_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
|
|
On Error Resume Next
|
|
Dim Yrs, Mts As Double
|
|
If Me.RankDate1.Text <> "" Then
|
|
Yrs = Fix(DateDiff("m", Me.RankDate1.Text, Now) / 12)
|
|
Mts = CInt(DateDiff("m", Me.RankDate1.Text, Now) Mod 12)
|
|
Me.RankDate1.Text = "<br>" & Yrs & "/" & Mts
|
|
End If
|
|
'If Yrs <> 0 AndAlso Mts <> 0 Then
|
|
'Me.RankDate1.Text = "<br>(" & Yrs & " ปี " & Mts & " เดือน)"
|
|
'ElseIf Yrs <> 0 AndAlso Mts = 0 Then
|
|
'Me.RankDate1.Text = "<br>(" & Yrs & " ปี)"
|
|
'ElseIf Yrs = 0 AndAlso Mts <> 0 Then
|
|
'Me.RankDate1.Text = "<br>" & Mts & " เดือน "
|
|
'End If
|
|
End Sub
|
|
End Class
|
|
|
|
|
|
|
|
Public Class View_PersonsTableControl
|
|
Inherits BaseView_PersonsTableControl
|
|
|
|
' The BaseView_PersonsTableControl class implements the LoadData, DataBind, CreateWhereClause
|
|
' and other methods to load and display the data in a table control.
|
|
|
|
' This is the ideal place to add your code customizations. You can override the LoadData and CreateWhereClause,
|
|
' The View_PersonsTableControlRow class offers another place where you can customize
|
|
' the DataBind, GetUIData, SaveData and Validate methods specific to each row displayed on the table.
|
|
' Public Overrides Function CreateOrderBy() As BaseClasses.Data.OrderBy
|
|
' If Me.InSession(Me, "Order_By") Then
|
|
' Me.CurrentSortOrder = OrderBy.FromXmlString(Me.GetFromSession(Me, "Order_By", Nothing))
|
|
' Else
|
|
' Me.CurrentSortOrder = New OrderBy(True, True)
|
|
' Me.CurrentSortOrder.Add(View_PersonsView.RankId, OrderByItem.OrderDir.Asc)
|
|
' Me.CurrentSortOrder.Add(View_PersonsView.DateRank, OrderByItem.OrderDir.Asc)
|
|
' Me.CurrentSortOrder.Add(View_PersonsView.DatePrevRank, OrderByItem.OrderDir.Asc)
|
|
' Return MyBase.CreateOrderBy()
|
|
' End If
|
|
' End Function
|
|
|
|
Protected Overrides Sub PopulateSectionIdFromFilter(ByVal selectedValue As String, ByVal maxItems As Integer)
|
|
|
|
'Setup the WHERE clause.
|
|
Dim wc As WhereClause = Me.CreateWhereClause_SectionIdFromFilter()
|
|
wc.iAND(SectionTable.SectionId, BaseFilter.ComparisonOperator.Not_Equals, "0")
|
|
Dim orderBy As OrderBy = New OrderBy(False, True)
|
|
orderBy.Add(SectionTable.SectionAbbvrName, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim noValueFormat As String = Page.GetResourceValue("Txt:Other", "Persons")
|
|
|
|
|
|
Me.SectionIdFromFilter.Items.Clear()
|
|
Dim itemValue As SectionRecord
|
|
For Each itemValue In SectionTable.GetRecords(wc, orderBy, 0, maxItems)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = noValueFormat
|
|
If itemValue.SectionIdSpecified Then
|
|
cvalue = itemValue.SectionId.ToString()
|
|
fvalue = itemValue.Format(SectionTable.SectionAbbvrName)
|
|
End If
|
|
|
|
Dim item As ListItem = New ListItem(fvalue, cvalue)
|
|
If Me.SectionIdFromFilter.Items.IndexOf(item) < 0 Then
|
|
Me.SectionIdFromFilter.Items.Add(item)
|
|
End If
|
|
Next
|
|
|
|
' Add the All item.
|
|
Me.SectionIdFromFilter.Items.Insert(0, New ListItem(Page.GetResourceValue("Txt:All", "Persons"), "--ANY--"))
|
|
|
|
' Set the selected value.
|
|
SetSelectedValue(Me.SectionIdFromFilter, selectedValue)
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub PopulateDeptIdFilter(ByVal selectedValue As String, ByVal maxItems As Integer)
|
|
|
|
'Setup the WHERE clause.
|
|
Dim wc As WhereClause = Me.CreateWhereClause_DeptIdFilter()
|
|
If Me.SectionIdFromFilter.SelectedValue = "--ANY--" Or Me.SectionIdFromFilter.SelectedValue = "0" Or Me.SectionIdFromFilter.SelectedValue = "" Then
|
|
Else
|
|
wc.iAND(DeptTable.SectionId, BaseFilter.ComparisonOperator.EqualsTo, Me.SectionIdFromFilter.SelectedValue)
|
|
End If
|
|
Dim orderBy As OrderBy = New OrderBy(False, True)
|
|
orderBy.Add(DeptTable.DeptId, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim noValueFormat As String = Page.GetResourceValue("Txt:Other", "Persons")
|
|
|
|
|
|
Me.DeptIdFilter.Items.Clear()
|
|
Dim itemValue As DeptRecord
|
|
For Each itemValue In DeptTable.GetRecords(wc, orderBy, 0, maxItems)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = noValueFormat
|
|
If itemValue.DeptIdSpecified Then
|
|
cvalue = itemValue.DeptId.ToString()
|
|
If Me.SectionIdFromFilter.SelectedValue = "--ANY--" Or Me.SectionIdFromFilter.SelectedValue = "0" Or Me.SectionIdFromFilter.SelectedValue = "" Then
|
|
fvalue = Ps.GetSectionAbbvrNameByDeptId(itemValue.DeptId) & ": " & itemValue.Format(DeptTable.DeptAbbvr)
|
|
Else
|
|
fvalue = itemValue.Format(DeptTable.DeptAbbvr) '& ": " & Ps.GetSectionAbbvrNameByDeptId(itemValue.DeptId)
|
|
End If
|
|
End If
|
|
Dim item As ListItem = New ListItem(fvalue, cvalue)
|
|
If Me.DeptIdFilter.Items.IndexOf(item) < 0 Then
|
|
Me.DeptIdFilter.Items.Add(item)
|
|
End If
|
|
Next
|
|
|
|
' Add the All item.
|
|
Me.DeptIdFilter.Items.Insert(0, New ListItem(Page.GetResourceValue("Txt:All", "Persons"), "--ANY--"))
|
|
|
|
' Set the selected value.
|
|
SetSelectedValue(Me.DeptIdFilter, selectedValue)
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub PopulateRankLevelFilter(ByVal selectedValue As String, ByVal maxItems As Integer)
|
|
|
|
'Setup the WHERE clause.
|
|
Dim wc As WhereClause = Me.CreateWhereClause_RankLevelFilter()
|
|
wc.iAND(RankTable.RankLevel, BaseFilter.ComparisonOperator.Less_Than, "21")
|
|
wc.iOR(RankTable.RankLevel, BaseFilter.ComparisonOperator.Greater_Than, "27")
|
|
Dim orderBy As OrderBy = New OrderBy(False, True)
|
|
orderBy.Add(RankTable.RankLevel, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim noValueFormat As String = Page.GetResourceValue("Txt:Other", "Persons")
|
|
|
|
|
|
Me.RankLevelFilter.Items.Clear()
|
|
Dim itemValue As RankRecord
|
|
For Each itemValue In RankTable.GetRecords(wc, orderBy, 0, maxItems)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = noValueFormat
|
|
If itemValue.RankLevelSpecified Then
|
|
cvalue = itemValue.RankLevel.ToString()
|
|
fvalue = itemValue.Format(RankTable.RankLevelName)
|
|
End If
|
|
|
|
Dim item As ListItem = New ListItem(fvalue, cvalue)
|
|
If Me.RankLevelFilter.Items.IndexOf(item) < 0 Then
|
|
Me.RankLevelFilter.Items.Add(item)
|
|
End If
|
|
Next
|
|
|
|
' Add the All item.
|
|
Me.RankLevelFilter.Items.Insert(0, New ListItem(Page.GetResourceValue("Txt:All", "Persons"), "--ANY--"))
|
|
|
|
' Set the selected value.
|
|
SetSelectedValue(Me.RankLevelFilter, selectedValue)
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub View_PersonsTableControl_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
|
|
MyBase.Control_Init(sender, e)
|
|
' Me.CurrentSortOrder.Reset()
|
|
' 'Me.CurrentSortOrder = New OrderBy(True, True)
|
|
' Me.CurrentSortOrder.Add(View_PersonsView.RankId, OrderByItem.OrderDir.Asc)
|
|
' Me.CurrentSortOrder.Add(View_PersonsView.DateRank, OrderByItem.OrderDir.Asc)
|
|
' Me.CurrentSortOrder.Add(View_PersonsView.DatePrevRank, OrderByItem.OrderDir.Asc)
|
|
|
|
End Sub
|
|
Public Overrides Sub View_PersonsResetButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
MyBase.View_PersonsResetButton_Click(sender, args)
|
|
' Me.CurrentSortOrder.Reset()
|
|
' 'Me.CurrentSortOrder = New OrderBy(True, True)
|
|
' Me.CurrentSortOrder.Add(View_PersonsView.RankId, OrderByItem.OrderDir.Asc)
|
|
' Me.CurrentSortOrder.Add(View_PersonsView.DateRank, OrderByItem.OrderDir.Asc)
|
|
' Me.CurrentSortOrder.Add(View_PersonsView.DatePrevRank, OrderByItem.OrderDir.Asc)
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
End Class
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
#Region "Section 2: Do not modify this section."
|
|
|
|
|
|
' Base class for the View_PersonsTableControlRow control on the ShowViewPersons page.
|
|
' Do not modify this class. Instead override any method in View_PersonsTableControlRow.
|
|
Public Class BaseView_PersonsTableControlRow
|
|
Inherits Persons.UI.BaseApplicationRecordControl
|
|
|
|
' To customize, override this method in View_PersonsTableControlRow.
|
|
Protected Overridable Sub Control_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Init
|
|
|
|
Me.ClearControlsFromSession()
|
|
End Sub
|
|
|
|
' To customize, override this method in View_PersonsTableControlRow.
|
|
Protected Overridable Sub Control_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
|
|
|
'Call LoadFocusScripts from repeater so that onfocus attribute could be added to elements
|
|
Me.Page.LoadFocusScripts(Me)
|
|
|
|
|
|
' Register the event handlers.
|
|
|
|
AddHandler Me.View_PersonsRowEditButton.Click, AddressOf View_PersonsRowEditButton_Click
|
|
|
|
AddHandler Me.View_PersonsRowViewButton.Click, AddressOf View_PersonsRowViewButton_Click
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Load the data from the database into the DataSource View_Persons record.
|
|
' It is better to make changes to functions called by LoadData such as
|
|
' CreateWhereClause, rather than making changes here.
|
|
|
|
' The RecordUniqueId is set the first time a record is loaded, and is
|
|
' used during a PostBack to load the record.
|
|
|
|
If Me.RecordUniqueId IsNot Nothing AndAlso Me.RecordUniqueId.Trim <> "" Then
|
|
Me.DataSource = View_PersonsView.GetRecord(Me.RecordUniqueId, True)
|
|
|
|
Return
|
|
End If
|
|
|
|
' Since this is a row in the table, the data for this row is loaded by the
|
|
' LoadData method of the BaseView_PersonsTableControl when the data for the entire
|
|
' table is loaded.
|
|
|
|
Me.DataSource = New View_PersonsRecord()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
' Populate the UI controls using the DataSource. To customize, override this method in View_PersonsTableControlRow.
|
|
Public Overrides Sub DataBind()
|
|
' The DataBind method binds the user interface controls to the values
|
|
' from the database record. To do this, it calls the Set methods for
|
|
' each of the field displayed on the webpage. It is better to make
|
|
' changes in the Set methods, rather than making changes here.
|
|
|
|
MyBase.DataBind()
|
|
|
|
' Make sure that the DataSource is initialized.
|
|
If Me.DataSource Is Nothing Then
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
'LoadData for DataSource for chart and report if they exist
|
|
|
|
|
|
|
|
' Call the Set methods for each controls on the panel
|
|
|
|
SetArmSName()
|
|
SetBorn()
|
|
SetBProvince()
|
|
SetCEdu()
|
|
SetCommission()
|
|
SetDeptAbbvr()
|
|
SetMobilePhone()
|
|
Setpicture()
|
|
SetRankAndName()
|
|
SetRankDate()
|
|
SetRankDate1()
|
|
SetRetire()
|
|
SetSAmout()
|
|
SetSectionAbbvrName()
|
|
SetTitle()
|
|
|
|
|
|
|
|
|
|
Me.IsNewRecord = True
|
|
|
|
If Me.DataSource.IsCreated Then
|
|
Me.IsNewRecord = False
|
|
|
|
Me.RecordUniqueId = Me.DataSource.GetID.ToXmlString()
|
|
End If
|
|
|
|
' Now load data for each record and table child UI controls.
|
|
' Ordering is important because child controls get
|
|
' their parent ids from their parent UI controls.
|
|
Dim shouldResetControl As Boolean = False
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub SetArmSName()
|
|
|
|
|
|
' Set the ArmSName Literal on the webpage with value from the
|
|
' View_Persons database record.
|
|
|
|
' Me.DataSource is the View_Persons record retrieved from the database.
|
|
' Me.ArmSName is the ASP:Literal on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetArmSName()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.ArmSNameSpecified Then
|
|
|
|
' If the ArmSName is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(View_PersonsView.ArmSName)
|
|
|
|
formattedValue = HttpUtility.HtmlEncode(formattedValue)
|
|
Me.ArmSName.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' ArmSName is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.ArmSName.Text = View_PersonsView.ArmSName.Format(View_PersonsView.ArmSName.DefaultValue)
|
|
|
|
End If
|
|
|
|
' If the ArmSName is NULL or blank, then use the value specified
|
|
' on Properties.
|
|
If Me.ArmSName.Text Is Nothing _
|
|
OrElse Me.ArmSName.Text.Trim() = "" Then
|
|
' Set the value specified on the Properties.
|
|
Me.ArmSName.Text = " "
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetBorn()
|
|
|
|
|
|
' Set the Born Literal on the webpage with value from the
|
|
' View_Persons database record.
|
|
|
|
' Me.DataSource is the View_Persons record retrieved from the database.
|
|
' Me.Born is the ASP:Literal on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetBorn()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.BornSpecified Then
|
|
|
|
' If the Born is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(View_PersonsView.Born)
|
|
|
|
formattedValue = HttpUtility.HtmlEncode(formattedValue)
|
|
Me.Born.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Born is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Born.Text = View_PersonsView.Born.Format(View_PersonsView.Born.DefaultValue)
|
|
|
|
End If
|
|
|
|
' If the Born is NULL or blank, then use the value specified
|
|
' on Properties.
|
|
If Me.Born.Text Is Nothing _
|
|
OrElse Me.Born.Text.Trim() = "" Then
|
|
' Set the value specified on the Properties.
|
|
Me.Born.Text = " "
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetBProvince()
|
|
|
|
|
|
' Set the BProvince Literal on the webpage with value from the
|
|
' View_Persons database record.
|
|
|
|
' Me.DataSource is the View_Persons record retrieved from the database.
|
|
' Me.BProvince is the ASP:Literal on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetBProvince()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.BProvinceSpecified Then
|
|
|
|
' If the BProvince is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(View_PersonsView.BProvince)
|
|
|
|
formattedValue = HttpUtility.HtmlEncode(formattedValue)
|
|
Me.BProvince.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' BProvince is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.BProvince.Text = View_PersonsView.BProvince.Format(View_PersonsView.BProvince.DefaultValue)
|
|
|
|
End If
|
|
|
|
' If the BProvince is NULL or blank, then use the value specified
|
|
' on Properties.
|
|
If Me.BProvince.Text Is Nothing _
|
|
OrElse Me.BProvince.Text.Trim() = "" Then
|
|
' Set the value specified on the Properties.
|
|
Me.BProvince.Text = " "
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCEdu()
|
|
|
|
|
|
' Set the CEdu Literal on the webpage with value from the
|
|
' View_Persons database record.
|
|
|
|
' Me.DataSource is the View_Persons record retrieved from the database.
|
|
' Me.CEdu is the ASP:Literal on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetCEdu()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.CEduSpecified Then
|
|
|
|
' If the CEdu is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(View_PersonsView.CEdu)
|
|
|
|
formattedValue = HttpUtility.HtmlEncode(formattedValue)
|
|
Me.CEdu.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' CEdu is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.CEdu.Text = View_PersonsView.CEdu.Format(View_PersonsView.CEdu.DefaultValue)
|
|
|
|
End If
|
|
|
|
' If the CEdu is NULL or blank, then use the value specified
|
|
' on Properties.
|
|
If Me.CEdu.Text Is Nothing _
|
|
OrElse Me.CEdu.Text.Trim() = "" Then
|
|
' Set the value specified on the Properties.
|
|
Me.CEdu.Text = " "
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCommission()
|
|
|
|
|
|
' Set the Commission Literal on the webpage with value from the
|
|
' View_Persons database record.
|
|
|
|
' Me.DataSource is the View_Persons record retrieved from the database.
|
|
' Me.Commission is the ASP:Literal on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetCommission()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.CommissionSpecified Then
|
|
|
|
' If the Commission is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(View_PersonsView.Commission)
|
|
|
|
If Not formattedValue is Nothing Then
|
|
Dim popupThreshold as Integer = CType(30, Integer)
|
|
|
|
Dim maxLength as Integer = Len(formattedValue)
|
|
If (maxLength > CType(30, Integer)) Then
|
|
' Truncate based on FieldMaxLength on Properties.
|
|
maxLength = CType(30, Integer)
|
|
|
|
formattedValue = HttpUtility.HtmlEncode(formattedValue)
|
|
|
|
End If
|
|
|
|
' For fields values larger than the PopupTheshold on Properties, display a popup.
|
|
If Len(formattedValue) >= popupThreshold Then
|
|
|
|
Dim name As String = HttpUtility.HtmlEncode(View_PersonsView.Commission.Name)
|
|
|
|
If Not HttpUtility.HtmlEncode("หน้าที่/งานที่ปฏิบัติ").Equals("%ISD_DEFAULT%") Then
|
|
name = HttpUtility.HtmlEncode(Me.Page.GetResourceValue("หน้าที่/งานที่ปฏิบัติ"))
|
|
End If
|
|
|
|
|
|
|
|
formattedValue= "<a onclick='gPersist=true;' class='truncatedText' onmouseout='detailRolloverPopupClose();' " _
|
|
& "onmouseover='SaveMousePosition(event); delayRolloverPopup(""PageMethods.GetRecordFieldValue(\""Persons.Business.View_PersonsView, App_Code\"",\""" _
|
|
& (HttpUtility.UrlEncode(Me.DataSource.GetID.ToString())).Replace("\","\\\\") & "\"", \""Commission\"", \""Commission\"", \""" & NetUtils.EncodeStringForHtmlDisplay(name.Substring(0, name.Length)) &"\"", false, 200," _
|
|
& " 300, true, PopupDisplayWindowCallBackWith20);"", 500);'>" & NetUtils.EncodeStringForHtmlDisplay(formattedValue.Substring(0, maxLength))
|
|
|
|
If (maxLength = CType(30, Integer)) Then
|
|
formattedValue = formattedValue & "..." & "</a>"
|
|
Else
|
|
formattedValue = formattedValue & "</a>"
|
|
|
|
formattedValue = "<table border=""0"" cellpadding=""0"" cellspacing=""0""><tr><td>" & formattedValue & "</td></tr></table>"
|
|
End If
|
|
Else
|
|
If maxLength = CType(30, Integer) Then
|
|
formattedValue= NetUtils.EncodeStringForHtmlDisplay(formattedValue.SubString(0,MaxLength))
|
|
formattedValue = formattedValue & "..."
|
|
|
|
Else
|
|
|
|
formattedValue = "<table border=""0"" cellpadding=""0"" cellspacing=""0""><tr><td>" & formattedValue & "</td></tr></table>"
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Me.Commission.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Commission is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Commission.Text = View_PersonsView.Commission.Format(View_PersonsView.Commission.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetDeptAbbvr()
|
|
|
|
|
|
' Set the DeptAbbvr Literal on the webpage with value from the
|
|
' View_Persons database record.
|
|
|
|
' Me.DataSource is the View_Persons record retrieved from the database.
|
|
' Me.DeptAbbvr is the ASP:Literal on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetDeptAbbvr()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.DeptAbbvrSpecified Then
|
|
|
|
' If the DeptAbbvr is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(View_PersonsView.DeptAbbvr)
|
|
|
|
formattedValue = HttpUtility.HtmlEncode(formattedValue)
|
|
Me.DeptAbbvr.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' DeptAbbvr is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.DeptAbbvr.Text = View_PersonsView.DeptAbbvr.Format(View_PersonsView.DeptAbbvr.DefaultValue)
|
|
|
|
End If
|
|
|
|
' If the DeptAbbvr is NULL or blank, then use the value specified
|
|
' on Properties.
|
|
If Me.DeptAbbvr.Text Is Nothing _
|
|
OrElse Me.DeptAbbvr.Text.Trim() = "" Then
|
|
' Set the value specified on the Properties.
|
|
Me.DeptAbbvr.Text = " "
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetMobilePhone()
|
|
|
|
|
|
' Set the MobilePhone Literal on the webpage with value from the
|
|
' View_Persons database record.
|
|
|
|
' Me.DataSource is the View_Persons record retrieved from the database.
|
|
' Me.MobilePhone is the ASP:Literal on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetMobilePhone()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.MobilePhoneSpecified Then
|
|
|
|
' If the MobilePhone is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(View_PersonsView.MobilePhone)
|
|
|
|
formattedValue = HttpUtility.HtmlEncode(formattedValue)
|
|
Me.MobilePhone.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' MobilePhone is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.MobilePhone.Text = View_PersonsView.MobilePhone.Format(View_PersonsView.MobilePhone.DefaultValue)
|
|
|
|
End If
|
|
|
|
' If the MobilePhone is NULL or blank, then use the value specified
|
|
' on Properties.
|
|
If Me.MobilePhone.Text Is Nothing _
|
|
OrElse Me.MobilePhone.Text.Trim() = "" Then
|
|
' Set the value specified on the Properties.
|
|
Me.MobilePhone.Text = " "
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub Setpicture()
|
|
' Set the picture Image on the webpage with value from the
|
|
' View_Persons database record.
|
|
|
|
' Me.DataSource is the View_Persons record retrieved from the database.
|
|
' Me.picture is the ASP:Image on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.Setpicture()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.pictureSpecified Then
|
|
|
|
' If the picture is non-NULL, then format the value.
|
|
' The Format method will use the Display Format
|
|
Me.picture.Attributes.Add("onclick", "gPersist=true;")
|
|
Me.picture.Attributes.Add("onmouseout","detailRolloverPopupClose();")
|
|
|
|
Dim name As String = HttpUtility.HtmlEncode(View_PersonsView.picture.Name)
|
|
|
|
If Not HttpUtility.HtmlEncode("%ISD_DEFAULT%").Equals("%ISD_DEFAULT%") Then
|
|
name = HttpUtility.HtmlEncode(Me.Page.GetResourceValue("%ISD_DEFAULT%"))
|
|
End If
|
|
|
|
Me.picture.Attributes.Add("onmouseover","SaveMousePosition(event);delayRolloverPopup(""PageMethods.GetImage(\""" & Me.Page.Encrypt("View_Persons") _
|
|
& "\"", \""" & Me.Page.Encrypt(HttpUtility.UrlEncode(Me.DataSource.GetID().ToString())) _
|
|
& "\"", \""" & Me.Page.Encrypt("picture") & "\"", \""" & NetUtils.EncodeStringForHtmlDisplay(name.Substring(0, name.Length)) & "\"", false, 250," _
|
|
& " 200, true, PopupDisplayWindowCallBackWith20);"",500);")
|
|
|
|
' Shrunk image size specified by ImagePercentSize on Properties.
|
|
Me.picture.ImageUrl = Me.DataSource.FormatImageUrl(View_PersonsView.picture, Me.Page.Encrypt("View_Persons"), Me.Page.Encrypt("picture"), Me.Page.Encrypt(Me.DataSource.GetID().ToXmlString()), 20)
|
|
|
|
Me.picture.Visible = True
|
|
Else
|
|
' picture is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
Me.picture.Visible = False
|
|
End If
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRankAndName()
|
|
|
|
|
|
' Set the RankAndName Literal on the webpage with value from the
|
|
' View_Persons database record.
|
|
|
|
' Me.DataSource is the View_Persons record retrieved from the database.
|
|
' Me.RankAndName is the ASP:Literal on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRankAndName()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RankAndNameSpecified Then
|
|
|
|
' If the RankAndName is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(View_PersonsView.RankAndName)
|
|
|
|
formattedValue = HttpUtility.HtmlEncode(formattedValue)
|
|
If Not formattedValue is Nothing Then
|
|
Dim popupThreshold as Integer = CType(100, Integer)
|
|
|
|
Dim maxLength as Integer = Len(formattedValue)
|
|
If (maxLength > CType(100, Integer)) Then
|
|
' Truncate based on FieldMaxLength on Properties.
|
|
maxLength = CType(100, Integer)
|
|
|
|
End If
|
|
|
|
' For fields values larger than the PopupTheshold on Properties, display a popup.
|
|
If Len(formattedValue) >= popupThreshold Then
|
|
|
|
Dim name As String = HttpUtility.HtmlEncode(View_PersonsView.RankAndName.Name)
|
|
|
|
If Not HttpUtility.HtmlEncode("%ISD_DEFAULT%").Equals("%ISD_DEFAULT%") Then
|
|
name = HttpUtility.HtmlEncode(Me.Page.GetResourceValue("%ISD_DEFAULT%"))
|
|
End If
|
|
|
|
|
|
|
|
formattedValue= "<a onclick='gPersist=true;' class='truncatedText' onmouseout='detailRolloverPopupClose();' " _
|
|
& "onmouseover='SaveMousePosition(event); delayRolloverPopup(""PageMethods.GetRecordFieldValue(\""Persons.Business.View_PersonsView, App_Code\"",\""" _
|
|
& (HttpUtility.UrlEncode(Me.DataSource.GetID.ToString())).Replace("\","\\\\") & "\"", \""RankAndName\"", \""RankAndName\"", \""" & NetUtils.EncodeStringForHtmlDisplay(name.Substring(0, name.Length)) &"\"", false, 200," _
|
|
& " 300, true, PopupDisplayWindowCallBackWith20);"", 500);'>" & NetUtils.EncodeStringForHtmlDisplay(formattedValue.Substring(0, maxLength))
|
|
|
|
If (maxLength = CType(100, Integer)) Then
|
|
formattedValue = formattedValue & "..." & "</a>"
|
|
Else
|
|
formattedValue = formattedValue & "</a>"
|
|
|
|
End If
|
|
Else
|
|
If maxLength = CType(100, Integer) Then
|
|
formattedValue= NetUtils.EncodeStringForHtmlDisplay(formattedValue.SubString(0,MaxLength))
|
|
formattedValue = formattedValue & "..."
|
|
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Me.RankAndName.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RankAndName is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RankAndName.Text = View_PersonsView.RankAndName.Format(View_PersonsView.RankAndName.DefaultValue)
|
|
|
|
End If
|
|
|
|
' If the RankAndName is NULL or blank, then use the value specified
|
|
' on Properties.
|
|
If Me.RankAndName.Text Is Nothing _
|
|
OrElse Me.RankAndName.Text.Trim() = "" Then
|
|
' Set the value specified on the Properties.
|
|
Me.RankAndName.Text = " "
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRankDate()
|
|
|
|
|
|
' Set the RankDate Literal on the webpage with value from the
|
|
' View_Persons database record.
|
|
|
|
' Me.DataSource is the View_Persons record retrieved from the database.
|
|
' Me.RankDate is the ASP:Literal on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRankDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RankDateSpecified Then
|
|
|
|
' If the RankDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(View_PersonsView.RankDate, "d MMM yy")
|
|
|
|
formattedValue = HttpUtility.HtmlEncode(formattedValue)
|
|
formattedValue = NetUtils.HtmlEncodeWhiteSpace(formattedValue)
|
|
Me.RankDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RankDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RankDate.Text = View_PersonsView.RankDate.Format(View_PersonsView.RankDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRankDate1()
|
|
|
|
|
|
' Set the RankDate Literal on the webpage with value from the
|
|
' View_Persons database record.
|
|
|
|
' Me.DataSource is the View_Persons record retrieved from the database.
|
|
' Me.RankDate1 is the ASP:Literal on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRankDate1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RankDateSpecified Then
|
|
|
|
' If the RankDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(View_PersonsView.RankDate, "d")
|
|
|
|
formattedValue = NetUtils.HtmlEncodeWhiteSpace(formattedValue)
|
|
Me.RankDate1.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RankDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RankDate1.Text = View_PersonsView.RankDate.Format(View_PersonsView.RankDate.DefaultValue, "d")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRetire()
|
|
|
|
|
|
' Set the Retire Literal on the webpage with value from the
|
|
' View_Persons database record.
|
|
|
|
' Me.DataSource is the View_Persons record retrieved from the database.
|
|
' Me.Retire is the ASP:Literal on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRetire()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RetireSpecified Then
|
|
|
|
' If the Retire is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(View_PersonsView.Retire)
|
|
|
|
formattedValue = HttpUtility.HtmlEncode(formattedValue)
|
|
Me.Retire.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Retire is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Retire.Text = View_PersonsView.Retire.Format(View_PersonsView.Retire.DefaultValue)
|
|
|
|
End If
|
|
|
|
' If the Retire is NULL or blank, then use the value specified
|
|
' on Properties.
|
|
If Me.Retire.Text Is Nothing _
|
|
OrElse Me.Retire.Text.Trim() = "" Then
|
|
' Set the value specified on the Properties.
|
|
Me.Retire.Text = " "
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSAmout()
|
|
|
|
|
|
' Set the SAmout Literal on the webpage with value from the
|
|
' View_Persons database record.
|
|
|
|
' Me.DataSource is the View_Persons record retrieved from the database.
|
|
' Me.SAmout is the ASP:Literal on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetSAmout()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.SAmoutSpecified Then
|
|
|
|
' If the SAmout is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(View_PersonsView.SAmout, "#,###")
|
|
|
|
formattedValue = HttpUtility.HtmlEncode(formattedValue)
|
|
Me.SAmout.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' SAmout is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.SAmout.Text = View_PersonsView.SAmout.Format(View_PersonsView.SAmout.DefaultValue, "#,###")
|
|
|
|
End If
|
|
|
|
' If the SAmout is NULL or blank, then use the value specified
|
|
' on Properties.
|
|
If Me.SAmout.Text Is Nothing _
|
|
OrElse Me.SAmout.Text.Trim() = "" Then
|
|
' Set the value specified on the Properties.
|
|
Me.SAmout.Text = " "
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSectionAbbvrName()
|
|
|
|
|
|
' Set the SectionAbbvrName Literal on the webpage with value from the
|
|
' View_Persons database record.
|
|
|
|
' Me.DataSource is the View_Persons record retrieved from the database.
|
|
' Me.SectionAbbvrName is the ASP:Literal on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetSectionAbbvrName()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.SectionAbbvrNameSpecified Then
|
|
|
|
' If the SectionAbbvrName is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(View_PersonsView.SectionAbbvrName)
|
|
|
|
formattedValue = HttpUtility.HtmlEncode(formattedValue)
|
|
Me.SectionAbbvrName.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' SectionAbbvrName is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.SectionAbbvrName.Text = View_PersonsView.SectionAbbvrName.Format(View_PersonsView.SectionAbbvrName.DefaultValue)
|
|
|
|
End If
|
|
|
|
' If the SectionAbbvrName is NULL or blank, then use the value specified
|
|
' on Properties.
|
|
If Me.SectionAbbvrName.Text Is Nothing _
|
|
OrElse Me.SectionAbbvrName.Text.Trim() = "" Then
|
|
' Set the value specified on the Properties.
|
|
Me.SectionAbbvrName.Text = " "
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetTitle()
|
|
|
|
|
|
' Set the Title Literal on the webpage with value from the
|
|
' View_Persons database record.
|
|
|
|
' Me.DataSource is the View_Persons record retrieved from the database.
|
|
' Me.Title is the ASP:Literal on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetTitle()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.TitleSpecified Then
|
|
|
|
' If the Title is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(View_PersonsView.Title)
|
|
|
|
formattedValue = HttpUtility.HtmlEncode(formattedValue)
|
|
Me.Title.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Title is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Title.Text = View_PersonsView.Title.Format(View_PersonsView.Title.DefaultValue)
|
|
|
|
End If
|
|
|
|
' If the Title is NULL or blank, then use the value specified
|
|
' on Properties.
|
|
If Me.Title.Text Is Nothing _
|
|
OrElse Me.Title.Text.Trim() = "" Then
|
|
' Set the value specified on the Properties.
|
|
Me.Title.Text = " "
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
Public EvaluateFormulaDelegate As BaseClasses.Data.DataSource.EvaluateFormulaDelegate = New BaseClasses.Data.DataSource.EvaluateFormulaDelegate(AddressOf Me.EvaluateFormula)
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord, ByVal format As String, ByVal variables As System.Collections.Generic.IDictionary(Of String, Object), ByVal includeDS As Boolean, ByVal e As FormulaEvaluator) As String
|
|
If e Is Nothing Then
|
|
e = New FormulaEvaluator()
|
|
End If
|
|
|
|
e.Variables.Clear()
|
|
|
|
|
|
' add variables for formula evaluation
|
|
If variables IsNot Nothing Then
|
|
Dim enumerator As System.Collections.Generic.IEnumerator(Of System.Collections.Generic.KeyValuePair(Of String, Object)) = variables.GetEnumerator()
|
|
While enumerator.MoveNext()
|
|
e.Variables.Add(enumerator.Current.Key, enumerator.Current.Value)
|
|
End While
|
|
End If
|
|
|
|
If includeDS
|
|
|
|
End IF
|
|
|
|
|
|
' Other variables referred to in the formula are expected to be
|
|
' properties of the DataSource. For example, referring to
|
|
' UnitPrice as a variable will refer to DataSource.UnitPrice
|
|
If dataSourceForEvaluate Is Nothing Then
|
|
|
|
e.DataSource = Me.DataSource
|
|
|
|
Else
|
|
e.DataSource = dataSourceForEvaluate
|
|
End If
|
|
|
|
' Define the calling control. This is used to add other
|
|
' related table and record controls as variables.
|
|
e.CallingControl = Me
|
|
|
|
Dim resultObj As Object = e.Evaluate(formula)
|
|
If resultObj Is Nothing Then
|
|
Return ""
|
|
End If
|
|
|
|
If Not String.IsNullOrEmpty(format) AndAlso (String.IsNullOrEmpty(formula) OrElse formula.IndexOf("Format(") < 0) Then
|
|
Return FormulaUtils.Format(resultObj, format)
|
|
Else
|
|
Return resultObj.ToString()
|
|
End If
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate as BaseClasses.Data.BaseRecord, ByVal format as String, ByVal variables As System.Collections.Generic.IDictionary(Of String, Object), ByVal includeDS As Boolean) As String
|
|
Return EvaluateFormula(formula, dataSourceForEvaluate, format,variables ,includeDS, Nothing)
|
|
End Function
|
|
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord, ByVal format As String, ByVal variables As System.Collections.Generic.IDictionary(Of String, Object)) As String
|
|
Return EvaluateFormula(formula, dataSourceForEvaluate, format, variables ,True, Nothing)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord, ByVal format As String) As String
|
|
Return Me.EvaluateFormula(formula, dataSourceForEvaluate, format, Nothing, True, Nothing)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord, ByVal variables As System.Collections.Generic.IDictionary(Of String, Object), ByVal e as FormulaEvaluator) As String
|
|
Return Me.EvaluateFormula(formula, dataSourceForEvaluate, Nothing, variables, True, e)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord) As String
|
|
Return Me.EvaluateFormula(formula, dataSourceForEvaluate, Nothing, Nothing, True, Nothing)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal includeDS as Boolean) As String
|
|
Return Me.EvaluateFormula(formula, Nothing, Nothing, Nothing, includeDS, Nothing)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String) As String
|
|
Return Me.EvaluateFormula(formula, Nothing, Nothing, Nothing, True, Nothing)
|
|
End Function
|
|
|
|
|
|
Public Overridable Sub RegisterPostback()
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
' To customize, override this method in View_PersonsTableControlRow.
|
|
Public Overridable Sub SaveData()
|
|
' Saves the associated record in the database.
|
|
' SaveData calls Validate and Get methods - so it may be more appropriate to
|
|
' customize those methods.
|
|
|
|
' 1. Load the existing record from the database. Since we save the entire record, this ensures
|
|
' that fields that are not displayed are also properly initialized.
|
|
Me.LoadData()
|
|
|
|
|
|
' 2. Perform any custom validation.
|
|
Me.Validate()
|
|
|
|
|
|
' 3. Set the values in the record with data from UI controls.
|
|
' This calls the Get() method for each of the user interface controls.
|
|
Me.GetUIData()
|
|
|
|
' 4. Save in the database.
|
|
' We should not save the record if the data did not change. This
|
|
' will save a database hit and avoid triggering any database triggers.
|
|
|
|
If Me.DataSource.IsAnyValueChanged Then
|
|
' Save record to database but do not commit yet.
|
|
' Auto generated ids are available after saving for use by child (dependent) records.
|
|
Me.DataSource.Save()
|
|
|
|
DirectCast(GetParentControlObject(Me, "View_PersonsTableControl"), View_PersonsTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "View_PersonsTableControl"), View_PersonsTableControl).ResetData = True
|
|
End If
|
|
|
|
|
|
' update session or cookie by formula
|
|
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
Me.ResetData = True
|
|
|
|
' For Master-Detail relationships, save data on the Detail table(s)
|
|
|
|
End Sub
|
|
|
|
' To customize, override this method in View_PersonsTableControlRow.
|
|
Public Overridable Sub GetUIData()
|
|
' The GetUIData method retrieves the updated values from the user interface
|
|
' controls into a database record in preparation for saving or updating.
|
|
' To do this, it calls the Get methods for each of the field displayed on
|
|
' the webpage. It is better to make changes in the Get methods, rather
|
|
' than making changes here.
|
|
|
|
' Call the Get methods for each of the user interface controls.
|
|
|
|
GetArmSName()
|
|
GetBorn()
|
|
GetBProvince()
|
|
GetCEdu()
|
|
GetCommission()
|
|
GetDeptAbbvr()
|
|
GetMobilePhone()
|
|
GetRankAndName()
|
|
GetRankDate()
|
|
GetRankDate1()
|
|
GetRetire()
|
|
GetSAmout()
|
|
GetSectionAbbvrName()
|
|
GetTitle()
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub GetArmSName()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetBorn()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetBProvince()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetCEdu()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetCommission()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetDeptAbbvr()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetMobilePhone()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRankAndName()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRankDate()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRankDate1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRetire()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetSAmout()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetSectionAbbvrName()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetTitle()
|
|
|
|
End Sub
|
|
|
|
|
|
' To customize, override this method in View_PersonsTableControlRow.
|
|
|
|
Public Overridable Function CreateWhereClause() As WhereClause
|
|
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
|
|
|
|
' To customize, override this method in View_PersonsTableControlRow.
|
|
Public Overridable Sub Validate()
|
|
' Add custom validation for any control within this panel.
|
|
' Example. If you have a State ASP:Textbox control
|
|
' If Me.State.Text <> "CA" Then
|
|
' Throw New Exception("State must be CA (California).")
|
|
' End If
|
|
|
|
' The Validate method is common across all controls within
|
|
' this panel so you can validate multiple fields, but report
|
|
' one error message.
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub Delete()
|
|
|
|
If Me.IsNewRecord() Then
|
|
Return
|
|
End If
|
|
|
|
Dim pkValue As KeyValue = KeyValue.XmlToKey(Me.RecordUniqueId)
|
|
View_PersonsView.DeleteRecord(pkValue)
|
|
|
|
DirectCast(GetParentControlObject(Me, "View_PersonsTableControl"), View_PersonsTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "View_PersonsTableControl"), View_PersonsTableControl).ResetData = True
|
|
End Sub
|
|
|
|
Protected Overridable Sub Control_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
|
|
' PreRender event is raised just before page is being displayed.
|
|
Try
|
|
DbUtils.StartTransaction()
|
|
Me.RegisterPostback()
|
|
|
|
If Not Me.Page.ErrorOnPage AndAlso (Me.Page.IsPageRefresh OrElse Me.DataChanged OrElse Me.ResetData) Then
|
|
|
|
|
|
' Re-load the data and update the web page if necessary.
|
|
' This is typically done during a postback (filter, search button, sort, pagination button).
|
|
' In each of the other click handlers, simply set DataChanged to True to reload the data.
|
|
Me.LoadData()
|
|
Me.DataBind()
|
|
End If
|
|
|
|
|
|
Me.Page.Authorize(Ctype(View_PersonsRowEditButton, Control), "NO_ACCESS")
|
|
|
|
Me.Page.Authorize(Ctype(View_PersonsRowViewButton, Control), "NO_ACCESS")
|
|
|
|
Catch ex As Exception
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
Finally
|
|
DbUtils.EndTransaction()
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub SaveControlsToSession()
|
|
MyBase.SaveControlsToSession()
|
|
|
|
|
|
'Save pagination state to session.
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Protected Overrides Sub ClearControlsFromSession()
|
|
MyBase.ClearControlsFromSession()
|
|
|
|
|
|
|
|
' Clear pagination state from session.
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub LoadViewState(ByVal savedState As Object)
|
|
MyBase.LoadViewState(savedState)
|
|
Dim isNewRecord As String = CType(ViewState("IsNewRecord"), String)
|
|
If Not isNewRecord Is Nothing AndAlso isNewRecord.Trim <> "" Then
|
|
Me.IsNewRecord = Boolean.Parse(isNewRecord)
|
|
End If
|
|
|
|
Dim myCheckSum As String = CType(ViewState("CheckSum"), String)
|
|
If Not myCheckSum Is Nothing AndAlso myCheckSum.Trim <> "" Then
|
|
Me.CheckSum = myCheckSum
|
|
End If
|
|
|
|
|
|
' Load view state for pagination control.
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Function SaveViewState() As Object
|
|
ViewState("IsNewRecord") = Me.IsNewRecord.ToString()
|
|
ViewState("CheckSum") = Me.CheckSum
|
|
|
|
|
|
' Load view state for pagination control.
|
|
|
|
Return MyBase.SaveViewState()
|
|
End Function
|
|
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub View_PersonsRowEditButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
' The redirect URL is set on the Properties, Custom Properties or Actions.
|
|
' The ModifyRedirectURL call resolves the parameters before the
|
|
' Response.Redirect redirects the page to the URL.
|
|
' Any code after the Response.Redirect call will not be executed, since the page is
|
|
' redirected to the URL.
|
|
|
|
|
|
Dim url As String = "../PersonalId/EditPersonalId.aspx?PersonalId={View_PersonsTableControlRow:PK}"
|
|
|
|
Dim shouldRedirect As Boolean = True
|
|
Dim TargetKey As String = Nothing
|
|
Dim DFKA As String = TargetKey
|
|
Dim id As String = DFKA
|
|
Dim value As String = id
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
url = Me.ModifyRedirectUrl(url, "",False)
|
|
url = Me.Page.ModifyRedirectUrl(url, "",False)
|
|
|
|
Catch ex As Exception
|
|
' Upon error, rollback the transaction
|
|
Me.Page.RollBackTransaction(sender)
|
|
shouldRedirect = False
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
If shouldRedirect Then
|
|
Me.Page.ShouldSaveControlsToSession = True
|
|
Me.Page.Response.Redirect(url)
|
|
ElseIf Not TargetKey Is Nothing AndAlso _
|
|
Not shouldRedirect Then
|
|
Me.Page.ShouldSaveControlsToSession = True
|
|
Me.Page.CloseWindow(True)
|
|
|
|
End If
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub View_PersonsRowViewButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
' The redirect URL is set on the Properties, Custom Properties or Actions.
|
|
' The ModifyRedirectURL call resolves the parameters before the
|
|
' Response.Redirect redirects the page to the URL.
|
|
' Any code after the Response.Redirect call will not be executed, since the page is
|
|
' redirected to the URL.
|
|
|
|
|
|
Dim url As String = "../PersonalId/ShowPersonalId.aspx?PersonalId={View_PersonsTableControlRow:PK}"
|
|
|
|
Dim shouldRedirect As Boolean = True
|
|
Dim TargetKey As String = Nothing
|
|
Dim DFKA As String = TargetKey
|
|
Dim id As String = DFKA
|
|
Dim value As String = id
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
url = Me.ModifyRedirectUrl(url, "",False)
|
|
url = Me.Page.ModifyRedirectUrl(url, "",False)
|
|
|
|
Catch ex As Exception
|
|
' Upon error, rollback the transaction
|
|
Me.Page.RollBackTransaction(sender)
|
|
shouldRedirect = False
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
If shouldRedirect Then
|
|
Me.Page.ShouldSaveControlsToSession = True
|
|
Me.Page.Response.Redirect(url)
|
|
ElseIf Not TargetKey Is Nothing AndAlso _
|
|
Not shouldRedirect Then
|
|
Me.Page.ShouldSaveControlsToSession = True
|
|
Me.Page.CloseWindow(True)
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Private _PreviousUIData As New Hashtable
|
|
Public Overridable Property PreviousUIData() As Hashtable
|
|
Get
|
|
Return _PreviousUIData
|
|
End Get
|
|
Set(ByVal value As Hashtable)
|
|
_PreviousUIData = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _IsNewRecord As Boolean = True
|
|
Public Overridable Property IsNewRecord() As Boolean
|
|
Get
|
|
Return Me._IsNewRecord
|
|
End Get
|
|
Set(ByVal value As Boolean)
|
|
Me._IsNewRecord = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataChanged As Boolean = False
|
|
Public Overridable Property DataChanged() As Boolean
|
|
Get
|
|
Return Me._DataChanged
|
|
End Get
|
|
Set(ByVal Value As Boolean)
|
|
Me._DataChanged = Value
|
|
End Set
|
|
End Property
|
|
|
|
Private _ResetData As Boolean = False
|
|
Public Overridable Property ResetData() As Boolean
|
|
Get
|
|
Return Me._ResetData
|
|
End Get
|
|
Set(ByVal Value As Boolean)
|
|
Me._ResetData = Value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property RecordUniqueId() As String
|
|
Get
|
|
Return CType(Me.ViewState("BaseView_PersonsTableControlRow_Rec"), String)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me.ViewState("BaseView_PersonsTableControlRow_Rec") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataSource As View_PersonsRecord
|
|
Public Property DataSource() As View_PersonsRecord
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
|
|
Set(ByVal value As View_PersonsRecord)
|
|
|
|
Me._DataSource = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
Private _checkSum As String
|
|
Public Overridable Property CheckSum() As String
|
|
Get
|
|
Return Me._checkSum
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me._checkSum = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _TotalPages As Integer
|
|
Public Property TotalPages() As Integer
|
|
Get
|
|
Return Me._TotalPages
|
|
End Get
|
|
Set(ByVal value As Integer)
|
|
Me._TotalPages = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _PageIndex As Integer
|
|
Public Property PageIndex() As Integer
|
|
Get
|
|
' Return the PageIndex
|
|
Return Me._PageIndex
|
|
End Get
|
|
Set(ByVal value As Integer)
|
|
Me._PageIndex = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DisplayLastPage As Boolean
|
|
Public Property DisplayLastPage() As Boolean
|
|
Get
|
|
Return Me._DisplayLastPage
|
|
End Get
|
|
Set(ByVal value As Boolean)
|
|
Me._DisplayLastPage = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
#Region "Helper Properties"
|
|
|
|
Public ReadOnly Property ArmSName() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ArmSName"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Born() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Born"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BProvince() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "BProvince"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CEdu() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CEdu"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Commission() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Commission"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DeptAbbvr() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "DeptAbbvr"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MobilePhone() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "MobilePhone"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property picture() As System.Web.UI.WebControls.Image
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "picture"), System.Web.UI.WebControls.Image)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RankAndName() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RankAndName"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RankDate() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RankDate"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RankDate1() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RankDate1"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Retire() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Retire"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SAmout() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SAmout"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SectionAbbvrName() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SectionAbbvrName"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Title() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Title"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property View_PersonsRowEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsRowEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property View_PersonsRowViewButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsRowViewButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
#Region "Helper Functions"
|
|
|
|
Public Overrides Overloads Function ModifyRedirectUrl(ByVal url As String, ByVal arg As String, ByVal bEncrypt As Boolean) As String
|
|
Return Me.Page.EvaluateExpressions(url, arg, bEncrypt, Me)
|
|
End Function
|
|
|
|
Public Overrides Overloads Function EvaluateExpressions(ByVal url As String, ByVal arg As String, ByVal bEncrypt As Boolean) As String
|
|
|
|
Dim rec As View_PersonsRecord = Nothing
|
|
|
|
|
|
Try
|
|
rec = Me.GetRecord()
|
|
Catch ex As Exception
|
|
' Do nothing
|
|
End Try
|
|
|
|
If rec Is Nothing AndAlso url.IndexOf("{") >= 0 Then
|
|
' Localization.
|
|
|
|
Throw New Exception(Page.GetResourceValue("Err:RecDataSrcNotInitialized", "Persons"))
|
|
|
|
End If
|
|
Return EvaluateExpressions(url, arg, rec, bEncrypt)
|
|
End Function
|
|
|
|
|
|
Public Overridable Function GetRecord() As View_PersonsRecord
|
|
If Not Me.DataSource Is Nothing Then
|
|
Return Me.DataSource
|
|
End If
|
|
|
|
If Not Me.RecordUniqueId Is Nothing Then
|
|
|
|
Return View_PersonsView.GetRecord(Me.RecordUniqueId, True)
|
|
|
|
End If
|
|
|
|
' Localization.
|
|
|
|
Throw New Exception(Page.GetResourceValue("Err:RetrieveRec", "Persons"))
|
|
|
|
End Function
|
|
|
|
Public Shadows ReadOnly Property Page() As BaseApplicationPage
|
|
Get
|
|
Return DirectCast(MyBase.Page, BaseApplicationPage)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
End Class
|
|
|
|
|
|
|
|
' Base class for the View_PersonsTableControl control on the ShowViewPersons page.
|
|
' Do not modify this class. Instead override any method in View_PersonsTableControl.
|
|
Public Class BaseView_PersonsTableControl
|
|
Inherits Persons.UI.BaseApplicationTableControl
|
|
|
|
|
|
|
|
Protected Overridable Sub Control_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Init
|
|
|
|
|
|
|
|
' Setup the filter and search events.
|
|
|
|
AddHandler Me.ArmyIdFromFilter1.SelectedIndexChanged, AddressOf ArmyIdFromFilter1_SelectedIndexChanged
|
|
AddHandler Me.DeptIdFilter.SelectedIndexChanged, AddressOf DeptIdFilter_SelectedIndexChanged
|
|
AddHandler Me.RankLevelFilter.SelectedIndexChanged, AddressOf RankLevelFilter_SelectedIndexChanged
|
|
AddHandler Me.RetireFilter.SelectedIndexChanged, AddressOf RetireFilter_SelectedIndexChanged
|
|
AddHandler Me.SectionIdFromFilter.SelectedIndexChanged, AddressOf SectionIdFromFilter_SelectedIndexChanged
|
|
If Not Me.Page.IsPostBack Then
|
|
Dim initialVal As String = ""
|
|
If Me.InSession(Me.ArmyIdFromFilter1)
|
|
initialVal = Me.GetFromSession(Me.ArmyIdFromFilter1)
|
|
|
|
End If
|
|
|
|
If initialVal <> ""
|
|
|
|
Me.ArmyIdFromFilter1.Items.Add(New ListItem(initialVal, initialVal))
|
|
|
|
Me.ArmyIdFromFilter1.SelectedValue = initialVal
|
|
|
|
End If
|
|
|
|
End If
|
|
If Not Me.Page.IsPostBack Then
|
|
Dim initialVal As String = ""
|
|
If Me.InSession(Me.DeptIdFilter)
|
|
initialVal = Me.GetFromSession(Me.DeptIdFilter)
|
|
|
|
End If
|
|
|
|
If initialVal <> ""
|
|
|
|
Me.DeptIdFilter.Items.Add(New ListItem(initialVal, initialVal))
|
|
|
|
Me.DeptIdFilter.SelectedValue = initialVal
|
|
|
|
End If
|
|
|
|
End If
|
|
If Not Me.Page.IsPostBack Then
|
|
Dim initialVal As String = ""
|
|
If Me.InSession(Me.RankLevelFilter)
|
|
initialVal = Me.GetFromSession(Me.RankLevelFilter)
|
|
|
|
End If
|
|
|
|
If initialVal <> ""
|
|
|
|
Me.RankLevelFilter.Items.Add(New ListItem(initialVal, initialVal))
|
|
|
|
Me.RankLevelFilter.SelectedValue = initialVal
|
|
|
|
End If
|
|
|
|
End If
|
|
If Not Me.Page.IsPostBack Then
|
|
Dim initialVal As String = ""
|
|
If Me.InSession(Me.RetireFilter)
|
|
initialVal = Me.GetFromSession(Me.RetireFilter)
|
|
|
|
End If
|
|
|
|
If initialVal <> ""
|
|
|
|
Me.RetireFilter.Items.Add(New ListItem(initialVal, initialVal))
|
|
|
|
Me.RetireFilter.SelectedValue = initialVal
|
|
|
|
End If
|
|
|
|
End If
|
|
If Not Me.Page.IsPostBack Then
|
|
Dim initialVal As String = ""
|
|
If Me.InSession(Me.SectionIdFromFilter)
|
|
initialVal = Me.GetFromSession(Me.SectionIdFromFilter)
|
|
|
|
End If
|
|
|
|
If initialVal <> ""
|
|
|
|
Me.SectionIdFromFilter.Items.Add(New ListItem(initialVal, initialVal))
|
|
|
|
Me.SectionIdFromFilter.SelectedValue = initialVal
|
|
|
|
End If
|
|
|
|
End If
|
|
If Not Me.Page.IsPostBack Then
|
|
Dim initialVal As String = ""
|
|
If Me.InSession(Me.View_PersonsSearch1)
|
|
initialVal = Me.GetFromSession(Me.View_PersonsSearch1)
|
|
|
|
End If
|
|
|
|
If initialVal <> ""
|
|
|
|
Me.View_PersonsSearch1.Text = initialVal
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
' Control Initializations.
|
|
' Initialize the table's current sort order.
|
|
|
|
If Me.InSession(Me, "Order_By") Then
|
|
Me.CurrentSortOrder = OrderBy.FromXmlString(Me.GetFromSession(Me, "Order_By", Nothing))
|
|
Else
|
|
Me.CurrentSortOrder = New OrderBy(True, False)
|
|
|
|
Me.CurrentSortOrder.Add(View_PersonsView.RankId, OrderByItem.OrderDir.Asc)
|
|
|
|
Me.CurrentSortOrder.Add(View_PersonsView.RankDate, OrderByItem.OrderDir.Asc)
|
|
|
|
Me.CurrentSortOrder.Add(View_PersonsView.DatePrevRank, OrderByItem.OrderDir.Asc)
|
|
|
|
End If
|
|
|
|
|
|
|
|
' Setup default pagination settings.
|
|
|
|
Me.PageSize = CInt(Me.GetFromSession(Me, "Page_Size", "10"))
|
|
Me.PageIndex = CInt(Me.GetFromSession(Me, "Page_Index", "0"))
|
|
|
|
|
|
|
|
Me.ClearControlsFromSession()
|
|
End Sub
|
|
|
|
Protected Overridable Sub Control_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
|
|
|
SaveControlsToSession_Ajax()
|
|
|
|
' Setup the pagination events.
|
|
|
|
AddHandler Me.View_PersonsPagination.FirstPage.Click, AddressOf View_PersonsPagination_FirstPage_Click
|
|
|
|
AddHandler Me.View_PersonsPagination.LastPage.Click, AddressOf View_PersonsPagination_LastPage_Click
|
|
|
|
AddHandler Me.View_PersonsPagination.NextPage.Click, AddressOf View_PersonsPagination_NextPage_Click
|
|
|
|
AddHandler Me.View_PersonsPagination.PageSizeButton.Click, AddressOf View_PersonsPagination_PageSizeButton_Click
|
|
|
|
AddHandler Me.View_PersonsPagination.PreviousPage.Click, AddressOf View_PersonsPagination_PreviousPage_Click
|
|
|
|
|
|
' Setup the sorting events.
|
|
|
|
AddHandler Me.ArmSNameLabel.Click, AddressOf ArmSNameLabel_Click
|
|
|
|
AddHandler Me.BornLabel.Click, AddressOf BornLabel_Click
|
|
|
|
AddHandler Me.BProvinceLabel.Click, AddressOf BProvinceLabel_Click
|
|
|
|
AddHandler Me.CEduLabel.Click, AddressOf CEduLabel_Click
|
|
|
|
AddHandler Me.MobilePhoneLabel.Click, AddressOf MobilePhoneLabel_Click
|
|
|
|
AddHandler Me.PersonalNameLabel.Click, AddressOf PersonalNameLabel_Click
|
|
|
|
AddHandler Me.RankDateLabel.Click, AddressOf RankDateLabel_Click
|
|
|
|
AddHandler Me.RankDateLabel1.Click, AddressOf RankDateLabel1_Click
|
|
|
|
AddHandler Me.RetireLabel.Click, AddressOf RetireLabel_Click
|
|
|
|
AddHandler Me.SAmoutLabel.Click, AddressOf SAmoutLabel_Click
|
|
|
|
AddHandler Me.SectionAbbvrNameLabel.Click, AddressOf SectionAbbvrNameLabel_Click
|
|
|
|
AddHandler Me.TitleLabel.Click, AddressOf TitleLabel_Click
|
|
|
|
' Setup the button events.
|
|
|
|
AddHandler Me.View_PersonsExportCSVButton.Click, AddressOf View_PersonsExportCSVButton_Click
|
|
|
|
AddHandler Me.View_PersonsExportExcelButton.Click, AddressOf View_PersonsExportExcelButton_Click
|
|
|
|
AddHandler Me.View_PersonsPDFButton.Click, AddressOf View_PersonsPDFButton_Click
|
|
|
|
AddHandler Me.View_PersonsRefreshButton.Click, AddressOf View_PersonsRefreshButton_Click
|
|
|
|
AddHandler Me.View_PersonsResetButton.Click, AddressOf View_PersonsResetButton_Click
|
|
|
|
AddHandler Me.View_PersonsWordButton.Click, AddressOf View_PersonsWordButton_Click
|
|
|
|
AddHandler Me.View_PersonsSearchButton1.Button.Click, AddressOf View_PersonsSearchButton1_Click
|
|
|
|
|
|
' Setup events for others
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Read data from database. Returns an array of records that can be assigned
|
|
' to the DataSource table control property.
|
|
Try
|
|
Dim joinFilter As CompoundFilter = CreateCompoundJoinFilter()
|
|
|
|
' The WHERE clause will be empty when displaying all records in table.
|
|
Dim wc As WhereClause = CreateWhereClause()
|
|
If wc IsNot Nothing AndAlso Not wc.RunQuery Then
|
|
' Initialize an empty array of records
|
|
Dim alist As New ArrayList(0)
|
|
Me.DataSource = DirectCast(alist.ToArray(GetType(View_PersonsRecord)), View_PersonsRecord())
|
|
' Add records to the list if needed.
|
|
Me.AddNewRecords()
|
|
Me._TotalRecords = 0
|
|
Me._TotalPages = 0
|
|
Return
|
|
End If
|
|
|
|
' Call OrderBy to determine the order - either use the order defined
|
|
' on the Query Wizard, or specified by user (by clicking on column heading)
|
|
Dim orderBy As OrderBy = CreateOrderBy()
|
|
|
|
' Get the pagesize from the pagesize control.
|
|
Me.GetPageSize()
|
|
|
|
If Me.DisplayLastPage Then
|
|
Dim totalRecords As Integer = If(Me._TotalRecords < 0, View_PersonsView.GetRecordCount(CreateCompoundJoinFilter(), CreateWhereClause()), Me._TotalRecords)
|
|
|
|
Dim totalPages As Integer = CInt(Math.Ceiling(totalRecords / Me.PageSize))
|
|
|
|
Me.PageIndex = totalPages - 1
|
|
End If
|
|
|
|
' Make sure PageIndex (current page) and PageSize are within bounds.
|
|
If Me.PageIndex < 0 Then
|
|
Me.PageIndex = 0
|
|
End If
|
|
If Me.PageSize < 1 Then
|
|
Me.PageSize = 1
|
|
End If
|
|
|
|
' Retrieve the records and set the table DataSource.
|
|
' Only PageSize records are fetched starting at PageIndex (zero based).
|
|
If Me.AddNewRecord > 0 Then
|
|
' Make sure to preserve the previously entered data on new rows.
|
|
Dim postdata As New ArrayList
|
|
For Each rc As View_PersonsTableControlRow In Me.GetRecordControls()
|
|
If Not rc.IsNewRecord Then
|
|
rc.DataSource = rc.GetRecord()
|
|
rc.GetUIData()
|
|
postdata.Add(rc.DataSource)
|
|
UIData.Add(rc.PreservedUIData())
|
|
End If
|
|
Next
|
|
Me.DataSource = DirectCast(postdata.ToArray(GetType(View_PersonsRecord)), View_PersonsRecord())
|
|
Else ' Get the records from the database
|
|
Me.DataSource = View_PersonsView.GetRecords(joinFilter, wc, orderBy, Me.PageIndex, Me.PageSize)
|
|
|
|
End If
|
|
|
|
' if the datasource contains no records contained in database, then load the last page.
|
|
If (DbUtils.GetCreatedRecords(Me.DataSource).Length = 0 AndAlso Not Me.DisplayLastPage) Then
|
|
Me.DisplayLastPage = True
|
|
LoadData()
|
|
Else
|
|
|
|
' Add any new rows desired by the user.
|
|
Me.AddNewRecords()
|
|
|
|
|
|
' Initialize the page and grand totals. now
|
|
|
|
Me.SAmoutGrandTotal.Text = Me.GetSAmoutGrandTotal()
|
|
If Me.SAmoutGrandTotal.Text Is Nothing OrElse _
|
|
Me.SAmoutGrandTotal.Text.Trim() = "" Then
|
|
Me.SAmoutGrandTotal.Text = " "
|
|
End If
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
' Report the error message to the end user
|
|
Dim msg As String = ex.Message
|
|
If ex.InnerException IsNot Nothing Then
|
|
msg = msg & " InnerException: " & ex.InnerException.Message
|
|
End If
|
|
Throw New Exception(msg, ex.InnerException)
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Public Overrides Sub DataBind()
|
|
' The DataBind method binds the user interface controls to the values
|
|
' from the database record for each row in the table. To do this, it calls the
|
|
' DataBind for each of the rows.
|
|
' DataBind also populates any filters above the table, and sets the pagination
|
|
' control to the correct number of records and the current page number.
|
|
|
|
MyBase.DataBind()
|
|
|
|
' Make sure that the DataSource is initialized.
|
|
If Me.DataSource Is Nothing Then
|
|
Return
|
|
End If
|
|
|
|
'LoadData for DataSource for chart and report if they exist
|
|
|
|
' Setup the pagination controls.
|
|
BindPaginationControls()
|
|
|
|
|
|
|
|
' Bind the repeater with the list of records to expand the UI.
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsTableControlRepeater"), System.Web.UI.WebControls.Repeater)
|
|
If rep Is Nothing Then Return
|
|
rep.DataSource = DataSource()
|
|
rep.DataBind()
|
|
|
|
Dim index As Integer = 0
|
|
For Each repItem As System.Web.UI.WebControls.RepeaterItem In rep.Items
|
|
' Loop through all rows in the table, set its DataSource and call DataBind().
|
|
Dim recControl As View_PersonsTableControlRow = DirectCast(repItem.FindControl("View_PersonsTableControlRow"), View_PersonsTableControlRow)
|
|
recControl.DataSource = Me.DataSource(index)
|
|
If Me.UIData.Count > index Then
|
|
recControl.PreviousUIData = Me.UIData(index)
|
|
End If
|
|
recControl.DataBind()
|
|
recControl.Visible = Not Me.InDeletedRecordIds(recControl)
|
|
|
|
index += 1
|
|
Next
|
|
|
|
|
|
|
|
|
|
' Call the Set methods for each controls on the panel
|
|
|
|
SetArmSNameLabel()
|
|
SetArmyIdFromFilter1()
|
|
SetArmyIdLabel2()
|
|
SetBornLabel()
|
|
SetBProvinceLabel()
|
|
SetCEduLabel()
|
|
SetCommissionLabel()
|
|
SetDeptIdFilter()
|
|
SetDeptIdLabel()
|
|
SetMobilePhoneLabel()
|
|
SetPersonalNameLabel()
|
|
SetpictureLabel()
|
|
SetRankDateLabel()
|
|
SetRankDateLabel1()
|
|
SetRankLevelFilter()
|
|
SetRankLevelLabel()
|
|
SetRetireFilter()
|
|
SetRetireLabel()
|
|
SetRetireLabel1()
|
|
|
|
SetSAmoutLabel()
|
|
SetSectionAbbvrNameLabel()
|
|
SetSectionIdFromFilter()
|
|
SetSectionIdLabel()
|
|
SetTitleLabel()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetView_PersonsSearch1()
|
|
|
|
SetView_PersonsTableControlCollapsibleRegion()
|
|
SetView_PersonsTableControlIcon()
|
|
SetView_PersonsTableControlPanelExtender()
|
|
|
|
|
|
' setting the state of expand or collapse alternative rows
|
|
|
|
|
|
' Load data for each record and table UI control.
|
|
' Ordering is important because child controls get
|
|
' their parent ids from their parent UI controls.
|
|
|
|
|
|
' this method calls the set method for controls with special formula like running total, sum, rank, etc
|
|
SetFormulaControls()
|
|
End Sub
|
|
|
|
Public Overridable Sub SetFormulaControls()
|
|
' this method calls Set methods for the control that has special formula
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Public Overridable Sub RegisterPostback()
|
|
|
|
Me.Page.RegisterPostBackTrigger(MiscUtils.FindControlRecursively(Me,"View_PersonsExportCSVButton"))
|
|
|
|
Me.Page.RegisterPostBackTrigger(MiscUtils.FindControlRecursively(Me,"View_PersonsExportExcelButton"))
|
|
|
|
Me.Page.RegisterPostBackTrigger(MiscUtils.FindControlRecursively(Me,"View_PersonsPDFButton"))
|
|
|
|
Me.Page.RegisterPostBackTrigger(MiscUtils.FindControlRecursively(Me,"View_PersonsWordButton"))
|
|
|
|
|
|
End Sub
|
|
|
|
Public EvaluateFormulaDelegate As BaseClasses.Data.DataSource.EvaluateFormulaDelegate = New BaseClasses.Data.DataSource.EvaluateFormulaDelegate(AddressOf Me.EvaluateFormula)
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate as BaseClasses.Data.BaseRecord, ByVal format as String, ByVal variables As System.Collections.Generic.IDictionary(Of String, Object), ByVal includeDS As Boolean, ByVal e as FormulaEvaluator) As String
|
|
If e Is Nothing
|
|
e = New FormulaEvaluator()
|
|
End If
|
|
|
|
e.Variables.Clear()
|
|
|
|
|
|
' add variables for formula evaluation
|
|
If variables IsNot Nothing Then
|
|
Dim enumerator As System.Collections.Generic.IEnumerator(Of System.Collections.Generic.KeyValuePair(Of String, Object)) = variables.GetEnumerator()
|
|
While enumerator.MoveNext()
|
|
e.Variables.Add(enumerator.Current.Key, enumerator.Current.Value)
|
|
End While
|
|
End If
|
|
|
|
If includeDS
|
|
|
|
End If
|
|
|
|
' All variables referred to in the formula are expected to be
|
|
' properties of the DataSource. For example, referring to
|
|
' UnitPrice as a variable will refer to DataSource.UnitPrice
|
|
e.DataSource = dataSourceForEvaluate
|
|
|
|
' Define the calling control. This is used to add other
|
|
' related table and record controls as variables.
|
|
e.CallingControl = Me
|
|
|
|
Dim resultObj As Object = e.Evaluate(formula)
|
|
If resultObj Is Nothing Then
|
|
Return ""
|
|
End If
|
|
|
|
If Not String.IsNullOrEmpty(format) AndAlso (String.IsNullOrEmpty(formula) OrElse formula.IndexOf("Format(") < 0) Then
|
|
Return FormulaUtils.Format(resultObj, format)
|
|
Else
|
|
Return resultObj.ToString()
|
|
End If
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate as BaseClasses.Data.BaseRecord, ByVal format as String, ByVal variables As System.Collections.Generic.IDictionary(Of String, Object), ByVal includeDS As Boolean) As String
|
|
Return EvaluateFormula(formula, dataSourceForEvaluate, format,variables ,includeDS, Nothing)
|
|
End Function
|
|
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord, ByVal format As String, ByVal variables As System.Collections.Generic.IDictionary(Of String, Object)) As String
|
|
Return EvaluateFormula(formula, dataSourceForEvaluate, format, variables ,True, Nothing)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord, ByVal format As String) As String
|
|
Return Me.EvaluateFormula(formula, dataSourceForEvaluate, format, Nothing, True, Nothing)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord, ByVal variables As System.Collections.Generic.IDictionary(Of String, Object), ByVal e as FormulaEvaluator) As String
|
|
Return Me.EvaluateFormula(formula, dataSourceForEvaluate, Nothing, variables, True, e)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord) As String
|
|
Return Me.EvaluateFormula(formula, dataSourceForEvaluate, Nothing, Nothing, True, Nothing)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal includeDS as Boolean) As String
|
|
Return Me.EvaluateFormula(formula, Nothing, Nothing, Nothing, includeDS, Nothing)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String) As String
|
|
Return Me.EvaluateFormula(formula, Nothing, Nothing, Nothing, True, Nothing)
|
|
End Function
|
|
|
|
|
|
|
|
|
|
Public Overridable Sub ResetControl()
|
|
|
|
Me.ArmyIdFromFilter1.ClearSelection()
|
|
|
|
Me.DeptIdFilter.ClearSelection()
|
|
|
|
Me.RankLevelFilter.ClearSelection()
|
|
|
|
Me.RetireFilter.ClearSelection()
|
|
|
|
Me.SectionIdFromFilter.ClearSelection()
|
|
|
|
Me.View_PersonsSearch1.Text = ""
|
|
|
|
Me.CurrentSortOrder.Reset()
|
|
If (Me.InSession(Me, "Order_By")) Then
|
|
Me.CurrentSortOrder = OrderBy.FromXmlString(Me.GetFromSession(Me, "Order_By", Nothing))
|
|
Else
|
|
Me.CurrentSortOrder = New OrderBy(True, False)
|
|
|
|
Me.CurrentSortOrder.Add(View_PersonsView.RankId, OrderByItem.OrderDir.Asc)
|
|
|
|
Me.CurrentSortOrder.Add(View_PersonsView.RankDate, OrderByItem.OrderDir.Asc)
|
|
|
|
Me.CurrentSortOrder.Add(View_PersonsView.DatePrevRank, OrderByItem.OrderDir.Asc)
|
|
|
|
End If
|
|
|
|
Me.PageIndex = 0
|
|
End Sub
|
|
|
|
Protected Overridable Sub BindPaginationControls()
|
|
' Setup the pagination controls.
|
|
|
|
' Bind the pagination labels.
|
|
|
|
If DbUtils.GetCreatedRecords(Me.DataSource).Length > 0 Then
|
|
|
|
Me.View_PersonsPagination.CurrentPage.Text = (Me.PageIndex + 1).ToString()
|
|
Else
|
|
Me.View_PersonsPagination.CurrentPage.Text = "0"
|
|
End If
|
|
Me.View_PersonsPagination.PageSize.Text = Me.PageSize.ToString()
|
|
Me.View_PersonsPagination.TotalItems.Text = Me.TotalRecords.ToString()
|
|
Me.View_PersonsPagination.TotalPages.Text = Me.TotalPages.ToString()
|
|
|
|
' Bind the buttons for View_PersonsTableControl pagination.
|
|
|
|
Me.View_PersonsPagination.FirstPage.Enabled = Not (Me.PageIndex = 0)
|
|
If Me._TotalPages < 0 Then ' if the total pages is not determined yet, enable last and next buttons
|
|
Me.View_PersonsPagination.LastPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.View_PersonsPagination.LastPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.View_PersonsPagination.LastPage.Enabled = Not (Me.PageIndex = Me.TotalPages - 1)
|
|
End If
|
|
|
|
If Me._TotalPages < 0 Then ' if the total pages is not determined yet, enable last and next buttons
|
|
Me.View_PersonsPagination.NextPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.View_PersonsPagination.NextPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.View_PersonsPagination.NextPage.Enabled = Not (Me.PageIndex = Me.TotalPages - 1)
|
|
End If
|
|
|
|
Me.View_PersonsPagination.PreviousPage.Enabled = Not (Me.PageIndex = 0)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SaveData()
|
|
' Save the data from the entire table. Calls each row's Save Data
|
|
' to save their data. This function is called by the Click handler of the
|
|
' Save button. The button handler should Start/Commit/End a transaction.
|
|
|
|
Dim recCtl As View_PersonsTableControlRow
|
|
For Each recCtl In Me.GetRecordControls()
|
|
|
|
If Me.InDeletedRecordIds(recCtl) Then
|
|
' Delete any pending deletes.
|
|
recCtl.Delete()
|
|
Else
|
|
If recCtl.Visible Then
|
|
recCtl.SaveData()
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
Me.ResetData = True
|
|
|
|
' Set IsNewRecord to False for all records - since everything has been saved and is no longer "new"
|
|
For Each recCtl In Me.GetRecordControls()
|
|
recCtl.IsNewRecord = False
|
|
Next
|
|
|
|
|
|
' Set DeletedRecordsIds to Nothing since we have deleted all pending deletes.
|
|
Me.DeletedRecordIds = Nothing
|
|
|
|
End Sub
|
|
|
|
Public Overridable Function CreateCompoundJoinFilter() As CompoundFilter
|
|
Dim jFilter As CompoundFilter = New CompoundFilter()
|
|
|
|
Return jFilter
|
|
|
|
End Function
|
|
|
|
|
|
Public Overridable Function CreateOrderBy() As OrderBy
|
|
' The CurrentSortOrder is initialized to the sort order on the
|
|
' Query Wizard. It may be modified by the Click handler for any of
|
|
' the column heading to sort or reverse sort by that column.
|
|
' You can add your own sort order, or modify it on the Query Wizard.
|
|
Return Me.CurrentSortOrder
|
|
End Function
|
|
|
|
Public Overridable Function CreateWhereClause() As WhereClause
|
|
'This CreateWhereClause is used for loading the data.
|
|
View_PersonsView.Instance.InnerFilter = Nothing
|
|
Dim wc As WhereClause = New WhereClause()
|
|
|
|
' Compose the WHERE clause consiting of:
|
|
' 1. Static clause defined at design time.
|
|
' 2. User selected search criteria.
|
|
' 3. User selected filter criteria.
|
|
|
|
|
|
If IsValueSelected(Me.ArmyIdFromFilter1) Then
|
|
|
|
wc.iAND(View_PersonsView.ArmyId, BaseFilter.ComparisonOperator.EqualsTo, MiscUtils.GetSelectedValue(Me.ArmyIdFromFilter1, Me.GetFromSession(Me.ArmyIdFromFilter1)), False, False)
|
|
|
|
End If
|
|
|
|
|
|
|
|
If IsValueSelected(Me.DeptIdFilter) Then
|
|
|
|
wc.iAND(View_PersonsView.DeptId, BaseFilter.ComparisonOperator.EqualsTo, MiscUtils.GetSelectedValue(Me.DeptIdFilter, Me.GetFromSession(Me.DeptIdFilter)), False, False)
|
|
|
|
End If
|
|
|
|
|
|
|
|
If IsValueSelected(Me.RankLevelFilter) Then
|
|
|
|
wc.iAND(View_PersonsView.RankLevel, BaseFilter.ComparisonOperator.EqualsTo, MiscUtils.GetSelectedValue(Me.RankLevelFilter, Me.GetFromSession(Me.RankLevelFilter)), False, False)
|
|
|
|
End If
|
|
|
|
|
|
|
|
If IsValueSelected(Me.RetireFilter) Then
|
|
|
|
wc.iAND(View_PersonsView.Retire, BaseFilter.ComparisonOperator.EqualsTo, MiscUtils.GetSelectedValue(Me.RetireFilter, Me.GetFromSession(Me.RetireFilter)), False, False)
|
|
|
|
End If
|
|
|
|
|
|
|
|
If IsValueSelected(Me.SectionIdFromFilter) Then
|
|
|
|
wc.iAND(View_PersonsView.SectionId, BaseFilter.ComparisonOperator.EqualsTo, MiscUtils.GetSelectedValue(Me.SectionIdFromFilter, Me.GetFromSession(Me.SectionIdFromFilter)), False, False)
|
|
|
|
End If
|
|
|
|
|
|
|
|
If IsValueSelected(Me.View_PersonsSearch1) Then
|
|
If Me.View_PersonsSearch1.Text = BaseClasses.Resources.AppResources.GetResourceValue("Txt:SearchForEllipsis", Nothing) Then
|
|
Me.View_PersonsSearch1.Text = ""
|
|
Else
|
|
' Strip "..." from begin and ending of the search text, otherwise the search will return 0 values as in database "..." is not stored.
|
|
|
|
If Me.View_PersonsSearch1.Text.StartsWith("...") Then
|
|
Me.View_PersonsSearch1.Text = Me.View_PersonsSearch1.Text.SubString(3,Me.View_PersonsSearch1.Text.Length-3)
|
|
End If
|
|
If Me.View_PersonsSearch1.Text.EndsWith("...") then
|
|
Me.View_PersonsSearch1.Text = Me.View_PersonsSearch1.Text.SubString(0,Me.View_PersonsSearch1.Text.Length-3)
|
|
' Strip the last word as well as it is likely only a partial word
|
|
Dim endindex As Integer = View_PersonsSearch1.Text.Length - 1
|
|
While (Not Char.IsWhiteSpace(View_PersonsSearch1.Text(endindex)) AndAlso endindex > 0)
|
|
endindex -= 1
|
|
End While
|
|
If endindex > 0 Then
|
|
View_PersonsSearch1.Text = View_PersonsSearch1.Text.Substring(0, endindex)
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Dim formatedSearchText As String = MiscUtils.GetSelectedValue(Me.View_PersonsSearch1, Me.GetFromSession(Me.View_PersonsSearch1))
|
|
|
|
' After stripping "..." see if the search text is null or empty.
|
|
If IsValueSelected(Me.View_PersonsSearch1) Then
|
|
' These clauses are added depending on operator and fields selected in Control's property page, bindings tab.
|
|
|
|
Dim search As WhereClause = New WhereClause()
|
|
|
|
search.iOR(View_PersonsView.SectionAbbvrName, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(Me.View_PersonsSearch1, Me.GetFromSession(Me.View_PersonsSearch1)), True, False)
|
|
|
|
search.iOR(View_PersonsView.DeptAbbvr, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(Me.View_PersonsSearch1, Me.GetFromSession(Me.View_PersonsSearch1)), True, False)
|
|
|
|
search.iOR(View_PersonsView.PersonalLastName, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(Me.View_PersonsSearch1, Me.GetFromSession(Me.View_PersonsSearch1)), True, False)
|
|
|
|
search.iOR(View_PersonsView.PersonalName, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(Me.View_PersonsSearch1, Me.GetFromSession(Me.View_PersonsSearch1)), True, False)
|
|
|
|
search.iOR(View_PersonsView.Retire, BaseFilter.ComparisonOperator.Contains, MiscUtils.GetSelectedValue(Me.View_PersonsSearch1, Me.GetFromSession(Me.View_PersonsSearch1)), True, False)
|
|
|
|
wc.iAND(search)
|
|
|
|
End If
|
|
End If
|
|
|
|
Return wc
|
|
End Function
|
|
|
|
|
|
Public Overridable Function CreateWhereClause(ByVal searchText as String, ByVal fromSearchControl as String, ByVal AutoTypeAheadSearch as String, ByVal AutoTypeAheadWordSeparators as String) As WhereClause
|
|
' This CreateWhereClause is used for loading list of suggestions for Auto Type-Ahead feature.
|
|
View_PersonsView.Instance.InnerFilter = Nothing
|
|
Dim wc As WhereClause = New WhereClause()
|
|
|
|
' Compose the WHERE clause consiting of:
|
|
' 1. Static clause defined at design time.
|
|
' 2. User selected search criteria.
|
|
' 3. User selected filter criteria.
|
|
|
|
Dim appRelativeVirtualPath As String = CType(HttpContext.Current.Session("AppRelativeVirtualPath"), String)
|
|
|
|
' Adds clauses if values are selected in Filter controls which are configured in the page.
|
|
|
|
Dim ArmyIdFromFilter1SelectedValue As String = CType(HttpContext.Current.Session()(HttpContext.Current.Session.SessionID & appRelativeVirtualPath & "ArmyIdFromFilter1_Ajax"), String)
|
|
If IsValueSelected(ArmyIdFromFilter1SelectedValue) Then
|
|
|
|
wc.iAND(View_PersonsView.ArmyId, BaseFilter.ComparisonOperator.EqualsTo, ArmyIdFromFilter1SelectedValue, false, False)
|
|
|
|
End If
|
|
|
|
Dim DeptIdFilterSelectedValue As String = CType(HttpContext.Current.Session()(HttpContext.Current.Session.SessionID & appRelativeVirtualPath & "DeptIdFilter_Ajax"), String)
|
|
If IsValueSelected(DeptIdFilterSelectedValue) Then
|
|
|
|
wc.iAND(View_PersonsView.DeptId, BaseFilter.ComparisonOperator.EqualsTo, DeptIdFilterSelectedValue, false, False)
|
|
|
|
End If
|
|
|
|
Dim RankLevelFilterSelectedValue As String = CType(HttpContext.Current.Session()(HttpContext.Current.Session.SessionID & appRelativeVirtualPath & "RankLevelFilter_Ajax"), String)
|
|
If IsValueSelected(RankLevelFilterSelectedValue) Then
|
|
|
|
wc.iAND(View_PersonsView.RankLevel, BaseFilter.ComparisonOperator.EqualsTo, RankLevelFilterSelectedValue, false, False)
|
|
|
|
End If
|
|
|
|
Dim RetireFilterSelectedValue As String = CType(HttpContext.Current.Session()(HttpContext.Current.Session.SessionID & appRelativeVirtualPath & "RetireFilter_Ajax"), String)
|
|
If IsValueSelected(RetireFilterSelectedValue) Then
|
|
|
|
wc.iAND(View_PersonsView.Retire, BaseFilter.ComparisonOperator.EqualsTo, RetireFilterSelectedValue, false, False)
|
|
|
|
End If
|
|
|
|
Dim SectionIdFromFilterSelectedValue As String = CType(HttpContext.Current.Session()(HttpContext.Current.Session.SessionID & appRelativeVirtualPath & "SectionIdFromFilter_Ajax"), String)
|
|
If IsValueSelected(SectionIdFromFilterSelectedValue) Then
|
|
|
|
wc.iAND(View_PersonsView.SectionId, BaseFilter.ComparisonOperator.EqualsTo, SectionIdFromFilterSelectedValue, false, False)
|
|
|
|
End If
|
|
|
|
If IsValueSelected(searchText) and fromSearchControl = "View_PersonsSearch1" Then
|
|
Dim formatedSearchText as String = searchText
|
|
' Strip "..." from begin and ending of the search text, otherwise the search will return 0 values as in database "..." is not stored.
|
|
If searchText.StartsWith("...") Then
|
|
formatedSearchText = searchText.SubString(3,searchText.Length-3)
|
|
End If
|
|
If searchText.EndsWith("...") Then
|
|
formatedSearchText = searchText.SubString(0,searchText.Length-3)
|
|
' Strip the last word as well as it is likely only a partial word
|
|
Dim endindex As Integer = searchText.Length - 1
|
|
While (Not Char.IsWhiteSpace(searchText(endindex)) AndAlso endindex > 0)
|
|
endindex -= 1
|
|
End While
|
|
If endindex > 0 Then
|
|
searchText = searchText.Substring(0, endindex)
|
|
End If
|
|
End If
|
|
'After stripping "...", trim any leading and trailing whitespaces
|
|
formatedSearchText = formatedSearchText.Trim()
|
|
' After stripping "..." see if the search text is null or empty.
|
|
If IsValueSelected(formatedSearchText) Then
|
|
' These clauses are added depending on operator and fields selected in Control's property page, bindings tab.
|
|
|
|
Dim search As WhereClause = New WhereClause()
|
|
|
|
If InvariantLCase(AutoTypeAheadSearch).equals("wordsstartingwithsearchstring") Then
|
|
|
|
search.iOR(View_PersonsView.SectionAbbvrName, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, True, False)
|
|
search.iOR(View_PersonsView.SectionAbbvrName, BaseFilter.ComparisonOperator.Contains, AutoTypeAheadWordSeparators & formatedSearchText, True, False)
|
|
|
|
search.iOR(View_PersonsView.DeptAbbvr, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, True, False)
|
|
search.iOR(View_PersonsView.DeptAbbvr, BaseFilter.ComparisonOperator.Contains, AutoTypeAheadWordSeparators & formatedSearchText, True, False)
|
|
|
|
search.iOR(View_PersonsView.PersonalLastName, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, True, False)
|
|
search.iOR(View_PersonsView.PersonalLastName, BaseFilter.ComparisonOperator.Contains, AutoTypeAheadWordSeparators & formatedSearchText, True, False)
|
|
|
|
search.iOR(View_PersonsView.PersonalName, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, True, False)
|
|
search.iOR(View_PersonsView.PersonalName, BaseFilter.ComparisonOperator.Contains, AutoTypeAheadWordSeparators & formatedSearchText, True, False)
|
|
|
|
search.iOR(View_PersonsView.Retire, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, True, False)
|
|
search.iOR(View_PersonsView.Retire, BaseFilter.ComparisonOperator.Contains, AutoTypeAheadWordSeparators & formatedSearchText, True, False)
|
|
|
|
Else
|
|
|
|
search.iOR(View_PersonsView.SectionAbbvrName, BaseFilter.ComparisonOperator.Contains, formatedSearchText, True, False)
|
|
search.iOR(View_PersonsView.DeptAbbvr, BaseFilter.ComparisonOperator.Contains, formatedSearchText, True, False)
|
|
search.iOR(View_PersonsView.PersonalLastName, BaseFilter.ComparisonOperator.Contains, formatedSearchText, True, False)
|
|
search.iOR(View_PersonsView.PersonalName, BaseFilter.ComparisonOperator.Contains, formatedSearchText, True, False)
|
|
search.iOR(View_PersonsView.Retire, BaseFilter.ComparisonOperator.Contains, formatedSearchText, True, False)
|
|
End If
|
|
wc.iAND(search)
|
|
|
|
End If
|
|
End If
|
|
|
|
|
|
Return wc
|
|
End Function
|
|
|
|
Public Overridable Function GetAutoCompletionList_View_PersonsSearch1(ByVal prefixText As String, ByVal count As Integer) As String()
|
|
Dim resultList As ArrayList = New ArrayList
|
|
Dim wordList As ArrayList = New ArrayList
|
|
Dim iteration As Integer = 0
|
|
|
|
Dim filterJoin As CompoundFilter = CreateCompoundJoinFilter()
|
|
Dim wc As WhereClause = CreateWhereClause(prefixText,"View_PersonsSearch1", "WordsStartingWithSearchString", "[^a-zA-Z0-9]")
|
|
While (resultList.Count < count AndAlso iteration < 5)
|
|
' Fetch 100 records in each iteration
|
|
Dim recordList () As Persons.Business.View_PersonsRecord = View_PersonsView.GetRecords(filterJoin, wc, Nothing, iteration, 100)
|
|
Dim rec As View_PersonsRecord = Nothing
|
|
Dim resultItem As String = ""
|
|
For Each rec In recordList
|
|
' Exit the loop if recordList count has reached AutoTypeAheadListSize.
|
|
If resultList.Count >= count then
|
|
Exit For
|
|
End If
|
|
' If the field is configured to Display as Foreign key, Format() method returns the
|
|
' Display as Forien Key value instead of original field value.
|
|
' Since search had to be done in multiple fields (selected in Control's page property, binding tab) in a record,
|
|
' We need to find relevent field to display which matches the prefixText and is not already present in the result list.
|
|
|
|
resultItem = rec.Format(View_PersonsView.SectionAbbvrName)
|
|
If resultItem IsNot Nothing AndAlso resultItem.ToUpper(System.Threading.Thread.CurrentThread.CurrentCulture).Contains(prefixText.ToUpper(System.Threading.Thread.CurrentThread.CurrentCulture)) Then
|
|
|
|
Dim isAdded As Boolean = FormatSuggestions(prefixText, resultItem, 50, "AtBeginningOfMatchedString", "WordsStartingWithSearchString", "[^a-zA-Z0-9]", resultList)
|
|
If isAdded Then
|
|
Continue For
|
|
End If
|
|
End If
|
|
|
|
resultItem = rec.Format(View_PersonsView.DeptAbbvr)
|
|
If resultItem IsNot Nothing AndAlso resultItem.ToUpper(System.Threading.Thread.CurrentThread.CurrentCulture).Contains(prefixText.ToUpper(System.Threading.Thread.CurrentThread.CurrentCulture)) Then
|
|
|
|
Dim isAdded As Boolean = FormatSuggestions(prefixText, resultItem, 50, "AtBeginningOfMatchedString", "WordsStartingWithSearchString", "[^a-zA-Z0-9]", resultList)
|
|
If isAdded Then
|
|
Continue For
|
|
End If
|
|
End If
|
|
|
|
resultItem = rec.Format(View_PersonsView.PersonalLastName)
|
|
If resultItem IsNot Nothing AndAlso resultItem.ToUpper(System.Threading.Thread.CurrentThread.CurrentCulture).Contains(prefixText.ToUpper(System.Threading.Thread.CurrentThread.CurrentCulture)) Then
|
|
|
|
Dim isAdded As Boolean = FormatSuggestions(prefixText, resultItem, 50, "AtBeginningOfMatchedString", "WordsStartingWithSearchString", "[^a-zA-Z0-9]", resultList)
|
|
If isAdded Then
|
|
Continue For
|
|
End If
|
|
End If
|
|
|
|
resultItem = rec.Format(View_PersonsView.PersonalName)
|
|
If resultItem IsNot Nothing AndAlso resultItem.ToUpper(System.Threading.Thread.CurrentThread.CurrentCulture).Contains(prefixText.ToUpper(System.Threading.Thread.CurrentThread.CurrentCulture)) Then
|
|
|
|
Dim isAdded As Boolean = FormatSuggestions(prefixText, resultItem, 50, "AtBeginningOfMatchedString", "WordsStartingWithSearchString", "[^a-zA-Z0-9]", resultList)
|
|
If isAdded Then
|
|
Continue For
|
|
End If
|
|
End If
|
|
|
|
resultItem = rec.Format(View_PersonsView.Retire)
|
|
If resultItem IsNot Nothing AndAlso resultItem.ToUpper(System.Threading.Thread.CurrentThread.CurrentCulture).Contains(prefixText.ToUpper(System.Threading.Thread.CurrentThread.CurrentCulture)) Then
|
|
|
|
Dim isAdded As Boolean = FormatSuggestions(prefixText, resultItem, 50, "AtBeginningOfMatchedString", "WordsStartingWithSearchString", "[^a-zA-Z0-9]", resultList)
|
|
If isAdded Then
|
|
Continue For
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
' Exit the loop if number of records found is less as further iteration will not return any more records
|
|
If recordList .Length < 100 Then
|
|
Exit While
|
|
End If
|
|
iteration += 1
|
|
End While
|
|
|
|
resultList.Sort()
|
|
Dim result() As String = New String(resultList.Count - 1) {}
|
|
Array.Copy(resultList.ToArray, result, resultList.Count)
|
|
Return result
|
|
End Function
|
|
|
|
|
|
Public Overridable Function FormatSuggestions(ByVal prefixText As String, ByVal resultItem As String, _
|
|
ByVal columnLength As Integer, ByVal AutoTypeAheadDisplayFoundText As String, _
|
|
ByVal autoTypeAheadSearch As String, ByVal AutoTypeAheadWordSeparators As String, _
|
|
ByVal resultList As ArrayList) As Boolean
|
|
|
|
'Formats the resultItem and adds it to the list of suggestions.
|
|
Dim index As Integer = resultItem.ToUpper(System.Threading.Thread.CurrentThread.CurrentCulture).IndexOf(prefixText.ToUpper(System.Threading.Thread.CurrentThread.CurrentCulture))
|
|
Dim itemToAdd As String = ""
|
|
Dim isFound As Boolean = False
|
|
Dim isAdded As Boolean = False
|
|
' Get the index where prfixt is at the beginning of resultItem. If not found then, index of word which begins with prefixText.
|
|
If InvariantLCase(autoTypeAheadSearch).equals("wordsstartingwithsearchstring") And Not index = 0 Then
|
|
' Expression to find word which contains AutoTypeAheadWordSeparators followed by prefixText
|
|
Dim regex1 As System.Text.RegularExpressions.Regex = new System.Text.RegularExpressions.Regex( AutoTypeAheadWordSeparators + prefixText, System.Text.RegularExpressions.RegexOptions.IgnoreCase)
|
|
If regex1.IsMatch(resultItem) Then
|
|
index = regex1.Match(resultItem).Index
|
|
isFound = True
|
|
End If
|
|
' If the prefixText is found immediatly after white space then starting of the word is found so don not search any further
|
|
If not resultItem(index).ToString() = " " Then
|
|
' Expression to find beginning of the word which contains AutoTypeAheadWordSeparators followed by prefixText
|
|
Dim regex As System.Text.RegularExpressions.Regex = new System.Text.RegularExpressions.Regex("\\S*" + AutoTypeAheadWordSeparators + prefixText, System.Text.RegularExpressions.RegexOptions.IgnoreCase)
|
|
If regex.IsMatch(resultItem) Then
|
|
index = regex.Match(resultItem).Index
|
|
isFound = True
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
' If autoTypeAheadSearch value is wordsstartingwithsearchstring then, extract the substring only if the prefixText is found at the
|
|
' beginning of the resultItem (index = 0) or a word in resultItem is found starts with prefixText.
|
|
If index = 0 Or isFound Or InvariantLCase(autoTypeAheadSearch).Equals("anywhereinstring") then
|
|
If InvariantLCase(AutoTypeAheadDisplayFoundText).equals("atbeginningofmatchedstring") Then
|
|
' Expression to find beginning of the word which contains prefixText
|
|
Dim regex1 As System.Text.RegularExpressions.Regex = new System.Text.RegularExpressions.Regex("\\S*" + prefixText, System.Text.RegularExpressions.RegexOptions.IgnoreCase)
|
|
' Find the beginning of the word which contains prefexText
|
|
If (StringUtils.InvariantLCase(autoTypeAheadSearch).Equals("anywhereinstring") AndAlso regex1.IsMatch(resultItem)) Then
|
|
index = regex1.Match(resultItem).Index
|
|
isFound = True
|
|
End If
|
|
' Display string from the index till end of the string if sub string from index till end is less than columnLength value.
|
|
If Len(resultItem) - index <= columnLength Then
|
|
If index = 0 Then
|
|
itemToAdd = resultItem
|
|
Else
|
|
itemToAdd = "..." & resultItem.Substring(index, Len(resultItem) - index)
|
|
End If
|
|
Else
|
|
If index = 0 Then
|
|
itemToAdd = resultItem.Substring(index, (columnLength - 3)) & "..."
|
|
Else
|
|
'Truncate the string to show only columnLength - 6 characters as begining and trailing "..." has to be appended.
|
|
itemToAdd = "..." & resultItem.Substring(index , columnLength - 6) & "..."
|
|
End If
|
|
End If
|
|
ElseIf InvariantLCase(AutoTypeAheadDisplayFoundText).equals("inmiddleofmatchedstring") Then
|
|
Dim subStringBeginIndex As Integer = CType(columnLength/2, Integer)
|
|
If Len(resultItem) <= columnLength Then
|
|
itemToAdd = resultItem
|
|
Else
|
|
' Sanity check at end of the string
|
|
If index + Len(prefixText) = columnLength Then
|
|
itemToAdd = "..." & resultItem.Substring(index-columnLength,index)
|
|
ElseIf Len(resultItem) - index < subStringBeginIndex Then
|
|
' Display string from the end till columnLength value if, index is closer to the end of the string.
|
|
itemToAdd = "..." & resultItem.Substring(Len(resultItem)-columnLength,Len(resultItem))
|
|
ElseIf index <= subStringBeginIndex Then
|
|
' Sanity chet at beginning of the string
|
|
itemToAdd = resultItem.Substring(0, columnLength) & "..."
|
|
Else
|
|
' Display string containing text before the prefixText occures and text after the prefixText
|
|
itemToAdd = "..." & resultItem.Substring(index - subStringBeginIndex, columnLength) & "..."
|
|
End If
|
|
End If
|
|
ElseIf InvariantLCase(AutoTypeAheadDisplayFoundText).equals("atendofmatchedstring") Then
|
|
' Expression to find ending of the word which contains prefexText
|
|
Dim regex1 As System.Text.RegularExpressions.Regex = new System.Text.RegularExpressions.Regex("\s", System.Text.RegularExpressions.RegexOptions.IgnoreCase)
|
|
' Find the ending of the word which contains prefexText
|
|
If regex1.IsMatch(resultItem, index + 1) Then
|
|
index = regex1.Match(resultItem, index + 1).Index
|
|
Else
|
|
' If the word which contains prefexText is the last word in string, regex1.IsMatch returns false.
|
|
index = resultItem.Length
|
|
End If
|
|
If index > Len(resultItem) Then
|
|
index = Len(resultItem)
|
|
End If
|
|
' If text from beginning of the string till index is less than columnLength value then, display string from the beginning till index.
|
|
If index <= columnLength Then
|
|
if index = Len(resultItem) Then 'Make decision to append "..."
|
|
itemToAdd = resultItem.Substring(0,index)
|
|
Else
|
|
itemToAdd = resultItem.Substring(0,index) & "..."
|
|
End If
|
|
Else
|
|
If index = Len(resultItem) Then
|
|
itemToAdd = "..." & resultItem.Substring(index - (columnLength - 3), (columnLength - 3))
|
|
Else
|
|
'Truncate the string to show only columnLength - 6 characters as begining and trailing "..." has to be appended.
|
|
itemToAdd = "..." & resultItem.Substring(index - (columnLength - 6), columnLength - 6) & "..."
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
' Remove newline character from itemToAdd
|
|
Dim prefixTextIndex As Integer = itemToAdd.IndexOf(prefixText, StringComparison.CurrentCultureIgnoreCase)
|
|
' If itemToAdd contains any newline after the search text then show text only till newline
|
|
Dim regex2 As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex("(" & vbCrLf & "|" & vbLf & ")", System.Text.RegularExpressions.RegexOptions.IgnoreCase)
|
|
Dim newLineIndexAfterPrefix As Integer = -1
|
|
If regex2.IsMatch(itemToAdd, prefixTextIndex) Then
|
|
newLineIndexAfterPrefix = regex2.Match(itemToAdd, prefixTextIndex).Index
|
|
End If
|
|
If (newLineIndexAfterPrefix > -1) Then
|
|
If itemToAdd.EndsWith("...") Then
|
|
itemToAdd = (itemToAdd.Substring(0, newLineIndexAfterPrefix) + "...")
|
|
Else
|
|
itemToAdd = itemToAdd.Substring(0, newLineIndexAfterPrefix)
|
|
End If
|
|
End If
|
|
' If itemToAdd contains any newline before search text then show text which comes after newline
|
|
Dim regex3 As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex("(" & vbCrLf & "|" & vbLf & ")", (System.Text.RegularExpressions.RegexOptions.IgnoreCase Or System.Text.RegularExpressions.RegexOptions.RightToLeft))
|
|
Dim newLineIndexBeforePrefix As Integer = -1
|
|
If regex3.IsMatch(itemToAdd, prefixTextIndex) Then
|
|
newLineIndexBeforePrefix = regex3.Match(itemToAdd, prefixTextIndex).Index
|
|
End If
|
|
If (newLineIndexBeforePrefix > -1) Then
|
|
If itemToAdd.StartsWith("...") Then
|
|
itemToAdd = ("..." + itemToAdd.Substring((newLineIndexBeforePrefix + regex3.Match(itemToAdd, prefixTextIndex).Length)))
|
|
Else
|
|
itemToAdd = itemToAdd.Substring((newLineIndexBeforePrefix + regex3.Match(itemToAdd, prefixTextIndex).Length))
|
|
End If
|
|
End If
|
|
|
|
If Not itemToAdd is nothing AndAlso Not resultList.Contains(itemToAdd) Then
|
|
|
|
resultList.Add(itemToAdd)
|
|
|
|
isAdded = true
|
|
End If
|
|
End If
|
|
Return isAdded
|
|
End Function
|
|
|
|
|
|
Protected Overridable Sub GetPageSize()
|
|
|
|
If Me.View_PersonsPagination.PageSize.Text.Trim <> "" Then
|
|
Try
|
|
'Me.PageSize = Integer.Parse(Me.View_PersonsPagination.PageSize.Text)
|
|
Catch ex As Exception
|
|
End Try
|
|
End If
|
|
End Sub
|
|
|
|
Protected Overridable Sub AddNewRecords()
|
|
|
|
Dim newRecordList As ArrayList = New ArrayList()
|
|
|
|
Dim newUIDataList As System.Collections.Generic.List(Of Hashtable) = New System.Collections.Generic.List(Of Hashtable)()
|
|
|
|
' Loop though all the record controls and if the record control
|
|
' does not have a unique record id set, then create a record
|
|
' and add to the list.
|
|
If Not Me.ResetData Then
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsTableControlRepeater"), System.Web.UI.WebControls.Repeater)
|
|
If rep Is Nothing Then Return
|
|
|
|
Dim repItem As System.Web.UI.WebControls.RepeaterItem
|
|
For Each repItem In rep.Items
|
|
' Loop through all rows in the table, set its DataSource and call DataBind().
|
|
|
|
Dim recControl As View_PersonsTableControlRow = DirectCast(repItem.FindControl("View_PersonsTableControlRow"), View_PersonsTableControlRow)
|
|
|
|
If recControl.Visible AndAlso recControl.IsNewRecord() Then
|
|
|
|
Dim rec As View_PersonsRecord = New View_PersonsRecord()
|
|
|
|
If recControl.ArmSName.Text <> "" Then
|
|
rec.Parse(recControl.ArmSName.Text, View_PersonsView.ArmSName)
|
|
End If
|
|
If recControl.Born.Text <> "" Then
|
|
rec.Parse(recControl.Born.Text, View_PersonsView.Born)
|
|
End If
|
|
If recControl.BProvince.Text <> "" Then
|
|
rec.Parse(recControl.BProvince.Text, View_PersonsView.BProvince)
|
|
End If
|
|
If recControl.CEdu.Text <> "" Then
|
|
rec.Parse(recControl.CEdu.Text, View_PersonsView.CEdu)
|
|
End If
|
|
If recControl.Commission.Text <> "" Then
|
|
rec.Parse(recControl.Commission.Text, View_PersonsView.Commission)
|
|
End If
|
|
If recControl.DeptAbbvr.Text <> "" Then
|
|
rec.Parse(recControl.DeptAbbvr.Text, View_PersonsView.DeptAbbvr)
|
|
End If
|
|
If recControl.MobilePhone.Text <> "" Then
|
|
rec.Parse(recControl.MobilePhone.Text, View_PersonsView.MobilePhone)
|
|
End If
|
|
If recControl.RankAndName.Text <> "" Then
|
|
rec.Parse(recControl.RankAndName.Text, View_PersonsView.RankAndName)
|
|
End If
|
|
If recControl.RankDate.Text <> "" Then
|
|
rec.Parse(recControl.RankDate.Text, View_PersonsView.RankDate)
|
|
End If
|
|
If recControl.RankDate1.Text <> "" Then
|
|
rec.Parse(recControl.RankDate1.Text, View_PersonsView.RankDate)
|
|
End If
|
|
If recControl.Retire.Text <> "" Then
|
|
rec.Parse(recControl.Retire.Text, View_PersonsView.Retire)
|
|
End If
|
|
If recControl.SAmout.Text <> "" Then
|
|
rec.Parse(recControl.SAmout.Text, View_PersonsView.SAmout)
|
|
End If
|
|
If recControl.SectionAbbvrName.Text <> "" Then
|
|
rec.Parse(recControl.SectionAbbvrName.Text, View_PersonsView.SectionAbbvrName)
|
|
End If
|
|
If recControl.Title.Text <> "" Then
|
|
rec.Parse(recControl.Title.Text, View_PersonsView.Title)
|
|
End If
|
|
newUIDataList.Add(recControl.PreservedUIData())
|
|
newRecordList.Add(rec)
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
|
|
' Add any new record to the list.
|
|
Dim index As Integer = 0
|
|
For index = 1 To Me.AddNewRecord
|
|
|
|
newRecordList.Insert(0, New View_PersonsRecord())
|
|
newUIDataList.Insert(0, New Hashtable())
|
|
|
|
Next
|
|
Me.AddNewRecord = 0
|
|
|
|
' Finally, add any new records to the DataSource.
|
|
If newRecordList.Count > 0 Then
|
|
|
|
Dim finalList As ArrayList = New ArrayList(Me.DataSource)
|
|
finalList.InsertRange(0, newRecordList)
|
|
|
|
Me.DataSource = DirectCast(finalList.ToArray(GetType(View_PersonsRecord)), View_PersonsRecord())
|
|
|
|
End If
|
|
|
|
' Add the existing UI data to this hash table
|
|
If newUIDataList.Count > 0 Then
|
|
Me.UIData.InsertRange(0, newUIDataList)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
Public Sub AddToDeletedRecordIds(ByVal rec As View_PersonsTableControlRow)
|
|
If rec.IsNewRecord() Then
|
|
Return
|
|
End If
|
|
|
|
If Not Me.DeletedRecordIds Is Nothing AndAlso Me.DeletedRecordIds.Trim <> "" Then
|
|
Me.DeletedRecordIds &= ","
|
|
End If
|
|
|
|
Me.DeletedRecordIds &= "[" & rec.RecordUniqueId & "]"
|
|
End Sub
|
|
|
|
Protected Overridable Function InDeletedRecordIds(ByVal rec As View_PersonsTableControlRow) As Boolean
|
|
If Me.DeletedRecordIds Is Nothing OrElse Me.DeletedRecordIds.Trim = "" Then
|
|
Return False
|
|
End If
|
|
|
|
Return Me.DeletedRecordIds.IndexOf("[" & rec.RecordUniqueId & "]") >= 0
|
|
End Function
|
|
|
|
Private _DeletedRecordIds As String
|
|
Public Property DeletedRecordIds() As String
|
|
Get
|
|
Return Me._DeletedRecordIds
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me._DeletedRecordIds = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
' Create Set, WhereClause, and Populate Methods
|
|
|
|
Public Overridable Sub SetArmSNameLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetArmyIdLabel2()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetBornLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetBProvinceLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCEduLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCommissionLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetDeptIdLabel()
|
|
|
|
'Code for the text property is generated inside the .aspx file.
|
|
'To override this property you can uncomment the following property and add your own value.
|
|
'Me.DeptIdLabel.Text = "Some value"
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetMobilePhoneLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalNameLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetpictureLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRankDateLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRankDateLabel1()
|
|
|
|
'Code for the text property is generated inside the .aspx file.
|
|
'To override this property you can uncomment the following property and add your own value.
|
|
'Me.RankDateLabel1.Text = "Some value"
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRankLevelLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRetireLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRetireLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSAmoutLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSectionAbbvrNameLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSectionIdLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetTitleLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetView_PersonsTableControlCollapsibleRegion()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetView_PersonsTableControlIcon()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetView_PersonsTableControlPanelExtender()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetArmyIdFromFilter1()
|
|
|
|
Me.PopulateArmyIdFromFilter1(GetSelectedValue(Me.ArmyIdFromFilter1, GetFromSession(Me.ArmyIdFromFilter1)), 500)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetDeptIdFilter()
|
|
|
|
Me.PopulateDeptIdFilter(GetSelectedValue(Me.DeptIdFilter, GetFromSession(Me.DeptIdFilter)), 500)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRankLevelFilter()
|
|
|
|
Me.PopulateRankLevelFilter(GetSelectedValue(Me.RankLevelFilter, GetFromSession(Me.RankLevelFilter)), 500)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRetireFilter()
|
|
|
|
Me.PopulateRetireFilter(GetSelectedValue(Me.RetireFilter, GetFromSession(Me.RetireFilter)), 500)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSectionIdFromFilter()
|
|
|
|
Me.PopulateSectionIdFromFilter(GetSelectedValue(Me.SectionIdFromFilter, GetFromSession(Me.SectionIdFromFilter)), 500)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetView_PersonsSearch1()
|
|
|
|
End Sub
|
|
|
|
' Get the filters' data for ArmyIdFromFilter1
|
|
Protected Overridable Sub PopulateArmyIdFromFilter1(ByVal selectedValue As String, ByVal maxItems As Integer)
|
|
|
|
|
|
Me.ArmyIdFromFilter1.Items.Clear()
|
|
|
|
|
|
|
|
' Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_ArmyIdFromFilter1 function.
|
|
' It is better to customize the where clause there.
|
|
|
|
|
|
|
|
'Setup the WHERE clause.
|
|
Dim wc As WhereClause = Me.CreateWhereClause_ArmyIdFromFilter1()
|
|
|
|
' Setup the static list items
|
|
|
|
' Add the All item.
|
|
Me.ArmyIdFromFilter1.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:All", "Persons"), "--ANY--"))
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(ArmyTable.Army, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
|
|
|
|
Dim noValueFormat As String = Page.GetResourceValue("Txt:Other", "Persons")
|
|
|
|
|
|
Dim itemValues() As ArmyRecord = Nothing
|
|
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
Dim evaluator As New FormulaEvaluator
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
|
|
|
|
Do
|
|
|
|
itemValues = ArmyTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
|
|
For each itemValue As ArmyRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.ArmyIdSpecified Then
|
|
cvalue = itemValue.ArmyId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.ArmyIdFromFilter1.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = View_PersonsView.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(View_PersonsView.ArmyId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso View_PersonsView.ArmyId.IsApplyDisplayAs Then
|
|
fvalue = View_PersonsView.GetDFKA(itemValue, View_PersonsView.ArmyId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(ArmyTable.Army)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
|
|
If (IsNothing(fvalue)) Then
|
|
fvalue = ""
|
|
End If
|
|
|
|
fvalue = fvalue.Trim()
|
|
|
|
If ( fvalue.Length > 50 ) Then
|
|
fvalue = fvalue.Substring(0, 50) & "..."
|
|
End If
|
|
|
|
Dim dupItem As ListItem = Me.ArmyIdFromFilter1.Items.FindByText(fvalue)
|
|
|
|
If Not IsNothing(dupItem) Then
|
|
listDuplicates.Add(fvalue)
|
|
dupItem.Text = fvalue & " (ID " & dupItem.Value.Substring(0, Math.Min(dupItem.Value.Length,38)) & ")"
|
|
End If
|
|
|
|
Dim newItem As ListItem = New ListItem(fvalue, cvalue)
|
|
Me.ArmyIdFromFilter1.Items.Add(newItem)
|
|
|
|
If listDuplicates.Contains(fvalue) Then
|
|
newItem.Text = fvalue & " (ID " & cvalue.Substring(0, Math.Min(cvalue.Length,38)) & ")"
|
|
End If
|
|
|
|
counter += 1
|
|
End If
|
|
End If
|
|
Next
|
|
pageNum += 1
|
|
Loop While (itemValues.Length = maxItems AndAlso counter < maxItems)
|
|
End If
|
|
|
|
|
|
|
|
|
|
|
|
|
|
' Set the selected value.
|
|
SetSelectedValue(Me.ArmyIdFromFilter1, selectedValue)
|
|
|
|
|
|
End Sub
|
|
|
|
' Get the filters' data for DeptIdFilter
|
|
Protected Overridable Sub PopulateDeptIdFilter(ByVal selectedValue As String, ByVal maxItems As Integer)
|
|
|
|
|
|
Me.DeptIdFilter.Items.Clear()
|
|
|
|
|
|
|
|
' Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_DeptIdFilter function.
|
|
' It is better to customize the where clause there.
|
|
|
|
' Setup the WHERE clause, including the base table if needed.
|
|
|
|
Dim wc As WhereClause = Me.CreateWhereClause_DeptIdFilter()
|
|
|
|
' Setup the static list items
|
|
|
|
' Add the All item.
|
|
Me.DeptIdFilter.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:All", "Persons"), "--ANY--"))
|
|
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(False, False)
|
|
orderBy.Add(View_PersonsView.DeptId, OrderByItem.OrderDir.Asc)
|
|
|
|
|
|
Dim values() As String = View_PersonsView.GetValues(View_PersonsView.DeptId, wc, orderBy, maxItems)
|
|
|
|
Dim cvalue As String
|
|
|
|
Dim listDuplicates As New ArrayList()
|
|
For Each cvalue In values
|
|
' Create the item and add to the list.
|
|
Dim fvalue As String
|
|
|
|
If ( View_PersonsView.DeptId.IsColumnValueTypeBoolean()) Then
|
|
fvalue = cvalue
|
|
Else
|
|
fvalue = View_PersonsView.DeptId.Format(cvalue)
|
|
End If
|
|
|
|
If (IsNothing(fvalue)) Then
|
|
fvalue = ""
|
|
End If
|
|
|
|
fvalue = fvalue.Trim()
|
|
|
|
If ( fvalue.Length > 50 ) Then
|
|
fvalue = fvalue.Substring(0, 50) & "..."
|
|
End If
|
|
|
|
Dim dupItem As ListItem = Me.DeptIdFilter.Items.FindByText(fvalue)
|
|
|
|
If Not IsNothing(dupItem) Then
|
|
listDuplicates.Add(fvalue)
|
|
dupItem.Text = fvalue & " (ID " & dupItem.Value.Substring(0, Math.Min(dupItem.Value.Length,38)) & ")"
|
|
End If
|
|
|
|
Dim newItem As ListItem = New ListItem(fvalue, cvalue)
|
|
Me.DeptIdFilter.Items.Add(newItem)
|
|
|
|
If listDuplicates.Contains(fvalue) Then
|
|
newItem.Text = fvalue & " (ID " & cvalue.Substring(0, Math.Min(cvalue.Length,38)) & ")"
|
|
End If
|
|
|
|
Next
|
|
|
|
|
|
|
|
' Set the selected value.
|
|
SetSelectedValue(Me.DeptIdFilter, selectedValue)
|
|
|
|
|
|
End Sub
|
|
|
|
' Get the filters' data for RankLevelFilter
|
|
Protected Overridable Sub PopulateRankLevelFilter(ByVal selectedValue As String, ByVal maxItems As Integer)
|
|
|
|
|
|
Me.RankLevelFilter.Items.Clear()
|
|
|
|
|
|
|
|
' Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_RankLevelFilter function.
|
|
' It is better to customize the where clause there.
|
|
|
|
|
|
|
|
'Setup the WHERE clause.
|
|
Dim wc As WhereClause = Me.CreateWhereClause_RankLevelFilter()
|
|
|
|
' Setup the static list items
|
|
|
|
' Add the All item.
|
|
Me.RankLevelFilter.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:All", "Persons"), "--ANY--"))
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(RankTable.RankLevelName, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
|
|
|
|
Dim noValueFormat As String = Page.GetResourceValue("Txt:Other", "Persons")
|
|
|
|
|
|
Dim itemValues() As RankRecord = Nothing
|
|
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
Dim evaluator As New FormulaEvaluator
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
|
|
|
|
Do
|
|
|
|
itemValues = RankTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
|
|
For each itemValue As RankRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.RankLevelSpecified Then
|
|
cvalue = itemValue.RankLevel.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.RankLevelFilter.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = View_PersonsView.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(View_PersonsView.RankLevel)
|
|
If _isExpandableNonCompositeForeignKey AndAlso View_PersonsView.RankLevel.IsApplyDisplayAs Then
|
|
fvalue = View_PersonsView.GetDFKA(itemValue, View_PersonsView.RankLevel)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(RankTable.RankLevelName)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
|
|
If (IsNothing(fvalue)) Then
|
|
fvalue = ""
|
|
End If
|
|
|
|
fvalue = fvalue.Trim()
|
|
|
|
If ( fvalue.Length > 50 ) Then
|
|
fvalue = fvalue.Substring(0, 50) & "..."
|
|
End If
|
|
|
|
Dim dupItem As ListItem = Me.RankLevelFilter.Items.FindByText(fvalue)
|
|
|
|
If Not IsNothing(dupItem) Then
|
|
listDuplicates.Add(fvalue)
|
|
dupItem.Text = fvalue & " (ID " & dupItem.Value.Substring(0, Math.Min(dupItem.Value.Length,38)) & ")"
|
|
End If
|
|
|
|
Dim newItem As ListItem = New ListItem(fvalue, cvalue)
|
|
Me.RankLevelFilter.Items.Add(newItem)
|
|
|
|
If listDuplicates.Contains(fvalue) Then
|
|
newItem.Text = fvalue & " (ID " & cvalue.Substring(0, Math.Min(cvalue.Length,38)) & ")"
|
|
End If
|
|
|
|
counter += 1
|
|
End If
|
|
End If
|
|
Next
|
|
pageNum += 1
|
|
Loop While (itemValues.Length = maxItems AndAlso counter < maxItems)
|
|
End If
|
|
|
|
|
|
|
|
|
|
|
|
|
|
' Set the selected value.
|
|
SetSelectedValue(Me.RankLevelFilter, selectedValue)
|
|
|
|
|
|
End Sub
|
|
|
|
' Get the filters' data for RetireFilter
|
|
Protected Overridable Sub PopulateRetireFilter(ByVal selectedValue As String, ByVal maxItems As Integer)
|
|
|
|
|
|
Me.RetireFilter.Items.Clear()
|
|
|
|
|
|
|
|
' Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_RetireFilter function.
|
|
' It is better to customize the where clause there.
|
|
|
|
' Setup the WHERE clause, including the base table if needed.
|
|
|
|
Dim wc As WhereClause = Me.CreateWhereClause_RetireFilter()
|
|
|
|
' Setup the static list items
|
|
|
|
' Add the All item.
|
|
Me.RetireFilter.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:All", "Persons"), "--ANY--"))
|
|
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(False, False)
|
|
orderBy.Add(View_PersonsView.Retire, OrderByItem.OrderDir.Asc)
|
|
|
|
|
|
Dim values() As String = View_PersonsView.GetValues(View_PersonsView.Retire, wc, orderBy, maxItems)
|
|
|
|
Dim cvalue As String
|
|
|
|
Dim listDuplicates As New ArrayList()
|
|
For Each cvalue In values
|
|
' Create the item and add to the list.
|
|
Dim fvalue As String
|
|
|
|
If ( View_PersonsView.Retire.IsColumnValueTypeBoolean()) Then
|
|
fvalue = cvalue
|
|
Else
|
|
fvalue = View_PersonsView.Retire.Format(cvalue)
|
|
End If
|
|
|
|
If (IsNothing(fvalue)) Then
|
|
fvalue = ""
|
|
End If
|
|
|
|
fvalue = fvalue.Trim()
|
|
|
|
If ( fvalue.Length > 50 ) Then
|
|
fvalue = fvalue.Substring(0, 50) & "..."
|
|
End If
|
|
|
|
Dim dupItem As ListItem = Me.RetireFilter.Items.FindByText(fvalue)
|
|
|
|
If Not IsNothing(dupItem) Then
|
|
listDuplicates.Add(fvalue)
|
|
dupItem.Text = fvalue & " (ID " & dupItem.Value.Substring(0, Math.Min(dupItem.Value.Length,38)) & ")"
|
|
End If
|
|
|
|
Dim newItem As ListItem = New ListItem(fvalue, cvalue)
|
|
Me.RetireFilter.Items.Add(newItem)
|
|
|
|
If listDuplicates.Contains(fvalue) Then
|
|
newItem.Text = fvalue & " (ID " & cvalue.Substring(0, Math.Min(cvalue.Length,38)) & ")"
|
|
End If
|
|
|
|
Next
|
|
|
|
|
|
|
|
' Set the selected value.
|
|
SetSelectedValue(Me.RetireFilter, selectedValue)
|
|
|
|
|
|
End Sub
|
|
|
|
' Get the filters' data for SectionIdFromFilter
|
|
Protected Overridable Sub PopulateSectionIdFromFilter(ByVal selectedValue As String, ByVal maxItems As Integer)
|
|
|
|
|
|
Me.SectionIdFromFilter.Items.Clear()
|
|
|
|
|
|
|
|
' Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_SectionIdFromFilter function.
|
|
' It is better to customize the where clause there.
|
|
|
|
|
|
|
|
'Setup the WHERE clause.
|
|
Dim wc As WhereClause = Me.CreateWhereClause_SectionIdFromFilter()
|
|
|
|
' Setup the static list items
|
|
|
|
' Add the All item.
|
|
Me.SectionIdFromFilter.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:All", "Persons"), "--ANY--"))
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(SectionTable.SectionAbbvrName, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
|
|
|
|
Dim noValueFormat As String = Page.GetResourceValue("Txt:Other", "Persons")
|
|
|
|
|
|
Dim itemValues() As SectionRecord = Nothing
|
|
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
Dim evaluator As New FormulaEvaluator
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
|
|
|
|
Do
|
|
|
|
itemValues = SectionTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
|
|
For each itemValue As SectionRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.SectionIdSpecified Then
|
|
cvalue = itemValue.SectionId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.SectionIdFromFilter.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = View_PersonsView.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(View_PersonsView.SectionId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso View_PersonsView.SectionId.IsApplyDisplayAs Then
|
|
fvalue = View_PersonsView.GetDFKA(itemValue, View_PersonsView.SectionId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(SectionTable.SectionAbbvrName)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
|
|
If (IsNothing(fvalue)) Then
|
|
fvalue = ""
|
|
End If
|
|
|
|
fvalue = fvalue.Trim()
|
|
|
|
If ( fvalue.Length > 50 ) Then
|
|
fvalue = fvalue.Substring(0, 50) & "..."
|
|
End If
|
|
|
|
Dim dupItem As ListItem = Me.SectionIdFromFilter.Items.FindByText(fvalue)
|
|
|
|
If Not IsNothing(dupItem) Then
|
|
listDuplicates.Add(fvalue)
|
|
dupItem.Text = fvalue & " (ID " & dupItem.Value.Substring(0, Math.Min(dupItem.Value.Length,38)) & ")"
|
|
End If
|
|
|
|
Dim newItem As ListItem = New ListItem(fvalue, cvalue)
|
|
Me.SectionIdFromFilter.Items.Add(newItem)
|
|
|
|
If listDuplicates.Contains(fvalue) Then
|
|
newItem.Text = fvalue & " (ID " & cvalue.Substring(0, Math.Min(cvalue.Length,38)) & ")"
|
|
End If
|
|
|
|
counter += 1
|
|
End If
|
|
End If
|
|
Next
|
|
pageNum += 1
|
|
Loop While (itemValues.Length = maxItems AndAlso counter < maxItems)
|
|
End If
|
|
|
|
|
|
|
|
|
|
|
|
|
|
' Set the selected value.
|
|
SetSelectedValue(Me.SectionIdFromFilter, selectedValue)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Function CreateWhereClause_ArmyIdFromFilter1() As WhereClause
|
|
|
|
' Create a where clause for the filter ArmyIdFromFilter1.
|
|
' This function is called by the Populate method to load the items
|
|
' in the ArmyIdFromFilter1DropDownList
|
|
|
|
Dim wc As WhereClause= New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
Public Overridable Function CreateWhereClause_DeptIdFilter() As WhereClause
|
|
|
|
' Create a where clause for the filter DeptIdFilter.
|
|
' This function is called by the Populate method to load the items
|
|
' in the DeptIdFilterDropDownList
|
|
|
|
Dim wc As WhereClause= New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
Public Overridable Function CreateWhereClause_RankLevelFilter() As WhereClause
|
|
|
|
' Create a where clause for the filter RankLevelFilter.
|
|
' This function is called by the Populate method to load the items
|
|
' in the RankLevelFilterDropDownList
|
|
|
|
Dim wc As WhereClause= New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
Public Overridable Function CreateWhereClause_RetireFilter() As WhereClause
|
|
|
|
' Create a where clause for the filter RetireFilter.
|
|
' This function is called by the Populate method to load the items
|
|
' in the RetireFilterDropDownList
|
|
|
|
Dim wc As WhereClause= New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
Public Overridable Function CreateWhereClause_SectionIdFromFilter() As WhereClause
|
|
|
|
' Create a where clause for the filter SectionIdFromFilter.
|
|
' This function is called by the Populate method to load the items
|
|
' in the SectionIdFromFilterDropDownList
|
|
|
|
Dim wc As WhereClause= New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
Protected Overridable Function GetSAmoutGrandTotal() As String
|
|
|
|
Dim wc As WhereClause = Me.CreateWhereClause()
|
|
Dim joinFilter As CompoundFilter = Me.CreateCompoundJoinFilter()
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(True, False)
|
|
Dim SAmoutSum As String = View_PersonsView.GetSum(View_PersonsView.SAmout, joinFilter, wc, orderBy, BaseTable.MIN_PAGE_NUMBER, BaseTable.MAX_BATCH_SIZE)
|
|
|
|
Return View_PersonsView.SAmout.Format(SAmoutSum)
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
Protected Overridable Sub Control_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
|
|
' PreRender event is raised just before page is being displayed.
|
|
Try
|
|
DbUtils.StartTransaction
|
|
Me.RegisterPostback()
|
|
|
|
If Not Me.Page.ErrorOnPage AndAlso (Me.Page.IsPageRefresh OrElse Me.DataChanged OrElse Me.ResetData) Then
|
|
|
|
|
|
' Re-load the data and update the web page if necessary.
|
|
' This is typically done during a postback (filter, search button, sort, pagination button).
|
|
' In each of the other click handlers, simply set DataChanged to True to reload the data.
|
|
|
|
Me.LoadData()
|
|
Me.DataBind()
|
|
|
|
End If
|
|
|
|
|
|
|
|
Catch ex As Exception
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub SaveControlsToSession()
|
|
MyBase.SaveControlsToSession()
|
|
|
|
' Save filter controls to values to session.
|
|
|
|
Me.SaveToSession(Me.ArmyIdFromFilter1, Me.ArmyIdFromFilter1.SelectedValue)
|
|
|
|
Me.SaveToSession(Me.DeptIdFilter, Me.DeptIdFilter.SelectedValue)
|
|
|
|
Me.SaveToSession(Me.RankLevelFilter, Me.RankLevelFilter.SelectedValue)
|
|
|
|
Me.SaveToSession(Me.RetireFilter, Me.RetireFilter.SelectedValue)
|
|
|
|
Me.SaveToSession(Me.SectionIdFromFilter, Me.SectionIdFromFilter.SelectedValue)
|
|
|
|
Me.SaveToSession(Me.View_PersonsSearch1, Me.View_PersonsSearch1.Text)
|
|
|
|
|
|
'Save pagination state to session.
|
|
|
|
|
|
|
|
' Save table control properties to the session.
|
|
If Not Me.CurrentSortOrder Is Nothing Then
|
|
Me.SaveToSession(Me, "Order_By", Me.CurrentSortOrder.ToXmlString())
|
|
End If
|
|
|
|
Me.SaveToSession(Me, "Page_Index", Me.PageIndex.ToString())
|
|
Me.SaveToSession(Me, "Page_Size", Me.PageSize.ToString())
|
|
|
|
Me.SaveToSession(Me, "DeletedRecordIds", Me.DeletedRecordIds)
|
|
|
|
End Sub
|
|
|
|
Protected Sub SaveControlsToSession_Ajax()
|
|
' Save filter controls to values to session.
|
|
|
|
Me.SaveToSession("ArmyIdFromFilter1_Ajax", Me.ArmyIdFromFilter1.SelectedValue)
|
|
|
|
Me.SaveToSession("DeptIdFilter_Ajax", Me.DeptIdFilter.SelectedValue)
|
|
|
|
Me.SaveToSession("RankLevelFilter_Ajax", Me.RankLevelFilter.SelectedValue)
|
|
|
|
Me.SaveToSession("RetireFilter_Ajax", Me.RetireFilter.SelectedValue)
|
|
|
|
Me.SaveToSession("SectionIdFromFilter_Ajax", Me.SectionIdFromFilter.SelectedValue)
|
|
|
|
Me.SaveToSession("View_PersonsSearch1_Ajax", Me.View_PersonsSearch1.Text)
|
|
|
|
HttpContext.Current.Session("AppRelativeVirtualPath") = Me.Page.AppRelativeVirtualPath
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub ClearControlsFromSession()
|
|
MyBase.ClearControlsFromSession()
|
|
|
|
' Clear filter controls values from the session.
|
|
|
|
Me.RemoveFromSession(Me.ArmyIdFromFilter1)
|
|
Me.RemoveFromSession(Me.DeptIdFilter)
|
|
Me.RemoveFromSession(Me.RankLevelFilter)
|
|
Me.RemoveFromSession(Me.RetireFilter)
|
|
Me.RemoveFromSession(Me.SectionIdFromFilter)
|
|
Me.RemoveFromSession(Me.View_PersonsSearch1)
|
|
|
|
' Clear pagination state from session.
|
|
|
|
|
|
|
|
' Clear table properties from the session.
|
|
Me.RemoveFromSession(Me, "Order_By")
|
|
Me.RemoveFromSession(Me, "Page_Index")
|
|
Me.RemoveFromSession(Me, "Page_Size")
|
|
|
|
Me.RemoveFromSession(Me, "DeletedRecordIds")
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub LoadViewState(ByVal savedState As Object)
|
|
MyBase.LoadViewState(savedState)
|
|
|
|
Dim orderByStr As String = CType(ViewState("View_PersonsTableControl_OrderBy"), String)
|
|
|
|
If orderByStr IsNot Nothing AndAlso orderByStr.Trim <> "" Then
|
|
Me.CurrentSortOrder = BaseClasses.Data.OrderBy.FromXmlString(orderByStr)
|
|
Else
|
|
Me.CurrentSortOrder = New OrderBy(True, False)
|
|
End If
|
|
|
|
Dim pageIndex As String = CType(ViewState("Page_Index"), String)
|
|
If pageIndex IsNot Nothing Then
|
|
Me.PageIndex = CInt(pageIndex)
|
|
End If
|
|
|
|
Dim pageSize As String = CType(ViewState("Page_Size"), String)
|
|
If Not pageSize Is Nothing Then
|
|
Me.PageSize = CInt(pageSize)
|
|
End If
|
|
|
|
|
|
|
|
' Load view state for pagination control.
|
|
|
|
Me.DeletedRecordIds = CType(Me.ViewState("DeletedRecordIds"), String)
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Function SaveViewState() As Object
|
|
|
|
If Me.CurrentSortOrder IsNot Nothing Then
|
|
Me.ViewState("View_PersonsTableControl_OrderBy") = Me.CurrentSortOrder.ToXmlString()
|
|
End If
|
|
|
|
Me.ViewState("Page_Index") = Me.PageIndex
|
|
Me.ViewState("Page_Size") = Me.PageSize
|
|
|
|
Me.ViewState("DeletedRecordIds") = Me.DeletedRecordIds
|
|
|
|
|
|
' Load view state for pagination control.
|
|
|
|
|
|
Return MyBase.SaveViewState()
|
|
End Function
|
|
|
|
' Generate the event handling functions for pagination events.
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub View_PersonsPagination_FirstPage_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
Me.PageIndex = 0
|
|
Me.DataChanged = True
|
|
|
|
Catch ex As Exception
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub View_PersonsPagination_LastPage_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
Me.DisplayLastPage = True
|
|
Me.DataChanged = True
|
|
|
|
Catch ex As Exception
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub View_PersonsPagination_NextPage_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
Me.PageIndex += 1
|
|
Me.DataChanged = True
|
|
|
|
Catch ex As Exception
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for LinkButton
|
|
Public Overridable Sub View_PersonsPagination_PageSizeButton_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
Try
|
|
|
|
Me.DataChanged = True
|
|
|
|
Me.PageSize = Integer.Parse(Me.View_PersonsPagination.PageSize.Text)
|
|
|
|
Me.PageIndex = Integer.Parse(Me.View_PersonsPagination.CurrentPage.Text) - 1
|
|
|
|
Catch ex As Exception
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub View_PersonsPagination_PreviousPage_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
If Me.PageIndex > 0 Then
|
|
Me.PageIndex -= 1
|
|
Me.DataChanged = True
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
|
|
' Generate the event handling functions for sorting events.
|
|
|
|
Public Overridable Sub ArmSNameLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by ArmSName when clicked.
|
|
|
|
' Get previous sorting state for ArmSName.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(View_PersonsView.ArmSName)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for ArmSName.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(View_PersonsView.ArmSName, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by ArmSName, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub BornLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Born when clicked.
|
|
|
|
' Get previous sorting state for Born.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(View_PersonsView.Born)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for Born.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(View_PersonsView.Born, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Born, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub BProvinceLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by BProvince when clicked.
|
|
|
|
' Get previous sorting state for BProvince.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(View_PersonsView.BProvince)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for BProvince.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(View_PersonsView.BProvince, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by BProvince, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub CEduLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by CEdu when clicked.
|
|
|
|
' Get previous sorting state for CEdu.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(View_PersonsView.CEdu)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for CEdu.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(View_PersonsView.CEdu, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by CEdu, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub MobilePhoneLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by MobilePhone when clicked.
|
|
|
|
' Get previous sorting state for MobilePhone.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(View_PersonsView.MobilePhone)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for MobilePhone.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(View_PersonsView.MobilePhone, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by MobilePhone, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub PersonalNameLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by PersonalName when clicked.
|
|
|
|
' Get previous sorting state for PersonalName.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(View_PersonsView.PersonalName)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for PersonalName.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(View_PersonsView.PersonalName, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by PersonalName, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub RankDateLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by RankDate when clicked.
|
|
|
|
' Get previous sorting state for RankDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(View_PersonsView.RankDate)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for RankDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(View_PersonsView.RankDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by RankDate, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub RankDateLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by RankDate when clicked.
|
|
|
|
' Get previous sorting state for RankDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(View_PersonsView.RankDate)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for RankDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(View_PersonsView.RankDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by RankDate, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub RetireLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Retire when clicked.
|
|
|
|
' Get previous sorting state for Retire.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(View_PersonsView.Retire)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for Retire.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(View_PersonsView.Retire, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Retire, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SAmoutLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by SAmout when clicked.
|
|
|
|
' Get previous sorting state for SAmout.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(View_PersonsView.SAmout)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for SAmout.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(View_PersonsView.SAmout, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by SAmout, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SectionAbbvrNameLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by SectionAbbvrName when clicked.
|
|
|
|
' Get previous sorting state for SectionAbbvrName.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(View_PersonsView.SectionAbbvrName)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for SectionAbbvrName.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(View_PersonsView.SectionAbbvrName, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by SectionAbbvrName, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub TitleLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Title when clicked.
|
|
|
|
' Get previous sorting state for Title.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(View_PersonsView.Title)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for Title.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(View_PersonsView.Title, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Title, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
|
|
' Generate the event handling functions for button events.
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub View_PersonsExportCSVButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
' Build the where clause based on the current filter and search criteria
|
|
' Create the Order By clause based on the user's current sorting preference.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause
|
|
Dim orderBy As OrderBy = Nothing
|
|
|
|
orderBy = CreateOrderBy
|
|
|
|
' Add each of the columns in order of export.
|
|
Dim columns() as BaseColumn = New BaseColumn() { _
|
|
View_PersonsView.ArmSName, _
|
|
View_PersonsView.SectionAbbvrName, _
|
|
View_PersonsView.DeptAbbvr, _
|
|
View_PersonsView.Retire, _
|
|
View_PersonsView.Commission, _
|
|
View_PersonsView.Born, _
|
|
View_PersonsView.BProvince, _
|
|
View_PersonsView.SAmout, _
|
|
View_PersonsView.CEdu, _
|
|
View_PersonsView.MobilePhone, _
|
|
View_PersonsView.RankDate, _
|
|
View_PersonsView.Title, _
|
|
View_PersonsView.RankAndName, _
|
|
Nothing}
|
|
Dim exportData as ExportDataToCSV = New ExportDataToCSV(View_PersonsView.Instance, wc, orderBy, columns)
|
|
|
|
Dim done As Boolean = False
|
|
|
|
Dim totalRowsReturned As Integer = 0
|
|
Dim join As CompoundFilter = CreateCompoundJoinFilter()
|
|
Dim data As DataForExport = New DataForExport(View_PersonsView.Instance, wc, orderBy, columns, join)
|
|
|
|
'Check for Export Data Threshold
|
|
Dim exportRawValues As Boolean = False
|
|
Me.TotalRecords = View_PersonsView.GetRecordCount(join, wc)
|
|
If Me.TotalRecords > 10000 Then
|
|
exportRawValues = True
|
|
End If
|
|
exportData.StartExport(Me.Page.Response, exportRawValues)
|
|
|
|
' Read pageSize records at a time and write out the CSV file.
|
|
While (Not done)
|
|
Dim recList As ArrayList = data.GetRows(exportData.pageSize)
|
|
If recList Is Nothing Then
|
|
Exit While 'no more records we are done
|
|
End If
|
|
|
|
totalRowsReturned = recList.Count
|
|
For Each rec As BaseRecord In recList
|
|
For Each col As BaseColumn In data.ColumnList
|
|
If col Is Nothing Then
|
|
Continue For
|
|
End If
|
|
|
|
If Not data.IncludeInExport(col) Then
|
|
Continue For
|
|
End If
|
|
|
|
Dim val As String = ""
|
|
|
|
If exportRawValues Then
|
|
val = rec.GetValue(col).ToString()
|
|
Else
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = col.TableDefinition.IsExpandableNonCompositeForeignKey(col)
|
|
If _isExpandableNonCompositeForeignKey AndAlso col.IsApplyDisplayAs Then
|
|
val = View_PersonsView.GetDFKA(rec.GetValue(col).ToString(), col, Nothing)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(val)) Then
|
|
val = exportData.GetDataForExport(col, rec)
|
|
End If
|
|
End If
|
|
exportData.WriteColumnData(val, data.IsString(col))
|
|
|
|
Next col
|
|
exportData.WriteNewRow()
|
|
Next rec
|
|
|
|
' If we already are below the pageSize, then we are done.
|
|
If totalRowsReturned < exportData.pageSize Then
|
|
done = True
|
|
End If
|
|
End While
|
|
exportData.FinishExport(Me.Page.Response)
|
|
|
|
|
|
Catch ex As Exception
|
|
' Upon error, rollback the transaction
|
|
Me.Page.RollBackTransaction(sender)
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub View_PersonsExportExcelButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
' To customize the columns or the format, override this function in Section 1 of the page
|
|
' and modify it to your liking.
|
|
' Build the where clause based on the current filter and search criteria
|
|
' Create the Order By clause based on the user's current sorting preference.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause
|
|
Dim orderBy As OrderBy = Nothing
|
|
|
|
orderBy = CreateOrderBy
|
|
|
|
Dim done As Boolean = False
|
|
Dim val As Object = ""
|
|
' Read pageSize records at a time and write out the Excel file.
|
|
Dim totalRowsReturned As Integer = 0
|
|
|
|
Me.TotalRecords = View_PersonsView.GetRecordCount(wc)
|
|
If Me.TotalRecords > 10000 Then
|
|
|
|
' Add each of the columns in order of export.
|
|
Dim columns() as BaseColumn = New BaseColumn() { _
|
|
View_PersonsView.ArmSName, _
|
|
View_PersonsView.SectionAbbvrName, _
|
|
View_PersonsView.DeptAbbvr, _
|
|
View_PersonsView.Retire, _
|
|
View_PersonsView.Commission, _
|
|
View_PersonsView.Born, _
|
|
View_PersonsView.BProvince, _
|
|
View_PersonsView.SAmout, _
|
|
View_PersonsView.CEdu, _
|
|
View_PersonsView.MobilePhone, _
|
|
View_PersonsView.RankDate, _
|
|
View_PersonsView.Title, _
|
|
View_PersonsView.RankAndName, _
|
|
Nothing}
|
|
Dim exportData as ExportDataToCSV = New ExportDataToCSV(View_PersonsView.Instance, wc, orderBy, columns)
|
|
exportData.StartExport(Me.Page.Response, True)
|
|
|
|
Dim dataForCSV As DataForExport = New DataForExport(View_PersonsView.Instance, wc, orderBy, columns)
|
|
|
|
' Read pageSize records at a time and write out the CSV file.
|
|
While (Not done)
|
|
Dim recList As ArrayList = dataForCSV.GetRows(exportData.pageSize)
|
|
If recList Is Nothing Then
|
|
Exit While 'no more records we are done
|
|
End If
|
|
|
|
totalRowsReturned = recList.Count
|
|
For Each rec As BaseRecord In recList
|
|
For Each col As BaseColumn In dataForCSV.ColumnList
|
|
If col Is Nothing Then
|
|
Continue For
|
|
End If
|
|
|
|
If Not dataForCSV.IncludeInExport(col) Then
|
|
Continue For
|
|
End If
|
|
|
|
val = rec.GetValue(col).ToString()
|
|
exportData.WriteColumnData(val, dataForCSV.IsString(col))
|
|
|
|
Next col
|
|
exportData.WriteNewRow()
|
|
Next rec
|
|
|
|
' If we already are below the pageSize, then we are done.
|
|
If totalRowsReturned < exportData.pageSize Then
|
|
done = True
|
|
End If
|
|
End While
|
|
exportData.FinishExport(Me.Page.Response)
|
|
Else
|
|
|
|
' Create an instance of the Excel report class with the table class, where clause and order by.
|
|
Dim excelReport As ExportDataToExcel = New ExportDataToExcel(View_PersonsView.Instance, wc, orderBy)
|
|
' Add each of the columns in order of export.
|
|
' To customize the data type, change the second parameter of the new ExcelColumn to be
|
|
' a format string from Excel's Format Cell menu. For example "dddd, mmmm dd, yyyy h:mm AM/PM;@", "#,##0.00"
|
|
|
|
If Me.Page.Response Is Nothing Then
|
|
Return
|
|
End If
|
|
|
|
excelReport.CreateExcelBook()
|
|
|
|
Dim width As Integer = 0
|
|
Dim columnCounter As Integer = 0
|
|
Dim data As DataForExport = New DataForExport(View_PersonsView.Instance, wc, orderBy, Nothing)
|
|
data.ColumnList.Add(New ExcelColumn(View_PersonsView.ArmSName, "Default"))
|
|
data.ColumnList.Add(New ExcelColumn(View_PersonsView.SectionAbbvrName, "Default"))
|
|
data.ColumnList.Add(New ExcelColumn(View_PersonsView.DeptAbbvr, "Default"))
|
|
data.ColumnList.Add(New ExcelColumn(View_PersonsView.Retire, "Default"))
|
|
data.ColumnList.Add(New ExcelColumn(View_PersonsView.Commission, "Default"))
|
|
data.ColumnList.Add(New ExcelColumn(View_PersonsView.Born, "Default"))
|
|
data.ColumnList.Add(New ExcelColumn(View_PersonsView.BProvince, "Default"))
|
|
data.ColumnList.Add(New ExcelColumn(View_PersonsView.SAmout, "#,###"))
|
|
data.ColumnList.Add(New ExcelColumn(View_PersonsView.CEdu, "Default"))
|
|
data.ColumnList.Add(New ExcelColumn(View_PersonsView.MobilePhone, "Default"))
|
|
data.ColumnList.Add(New ExcelColumn(View_PersonsView.RankDate, "Short Date"))
|
|
data.ColumnList.Add(New ExcelColumn(View_PersonsView.Title, "Default"))
|
|
data.ColumnList.Add(New ExcelColumn(View_PersonsView.RankAndName, "Default"))
|
|
|
|
|
|
For Each col As ExcelColumn In data.ColumnList
|
|
width = excelReport.GetExcelCellWidth(col)
|
|
If data.IncludeInExport(col) Then
|
|
excelReport.AddColumnToExcelBook(columnCounter, col.ToString(), excelReport.GetExcelDataType(col), width, excelReport.GetDisplayFormat(col))
|
|
columnCounter = columnCounter + 1
|
|
End If
|
|
Next col
|
|
|
|
While (Not done)
|
|
Dim recList As ArrayList = data.GetRows(excelReport.pageSize)
|
|
|
|
If recList Is Nothing Then
|
|
Exit While 'no more records we are done
|
|
End If
|
|
|
|
totalRowsReturned = recList.Count
|
|
|
|
For Each rec As BaseRecord In recList
|
|
excelReport.AddRowToExcelBook()
|
|
columnCounter = 0
|
|
|
|
For Each col As ExcelColumn In data.ColumnList
|
|
If Not data.IncludeInExport(col) Then
|
|
Continue For
|
|
End If
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = col.DisplayColumn.TableDefinition.IsExpandableNonCompositeForeignKey(col.DisplayColumn)
|
|
If _isExpandableNonCompositeForeignKey AndAlso col.DisplayColumn.IsApplyDisplayAs Then
|
|
val = View_PersonsView.GetDFKA(rec.GetValue(col.DisplayColumn).ToString(), col.DisplayColumn, Nothing)
|
|
If val Is Nothing Then
|
|
val = rec.Format(col.DisplayColumn)
|
|
End If
|
|
Else
|
|
val = excelReport.GetValueForExcelExport(col, rec)
|
|
End If
|
|
excelReport.AddCellToExcelRow(columnCounter, excelReport.GetExcelDataType(col), val, col.DisplayFormat)
|
|
|
|
columnCounter = columnCounter + 1
|
|
Next col
|
|
Next rec
|
|
|
|
' If we already are below the pageSize, then we are done.
|
|
If totalRowsReturned < excelReport.pageSize Then
|
|
done = True
|
|
End If
|
|
End While
|
|
|
|
excelReport.SaveExcelBook(Me.Page.Response)
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
' Upon error, rollback the transaction
|
|
Me.Page.RollBackTransaction(sender)
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub View_PersonsPDFButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
Dim report As PDFReport = New PDFReport()
|
|
report.SpecificReportFileName = Page.Server.MapPath("ShowViewPersons.View_PersonsPDFButton.report")
|
|
' report.Title replaces the value tag of page header and footer containing ${ReportTitle}
|
|
report.Title = "View_Persons"
|
|
' If ShowViewPersons.View_PersonsPDFButton.report specifies a valid report template,
|
|
' AddColumn method will generate a report template.
|
|
' Each AddColumn method-call specifies a column
|
|
' The 1st parameter represents the text of the column header
|
|
' The 2nd parameter represents the horizontal alignment of the column header
|
|
' The 3rd parameter represents the text format of the column detail
|
|
' The 4th parameter represents the horizontal alignment of the column detail
|
|
' The 5th parameter represents the relative width of the column
|
|
report.AddColumn(View_PersonsView.ArmSName.Name, ReportEnum.Align.Left, "${ArmSName}", ReportEnum.Align.Left, 30)
|
|
report.AddColumn(View_PersonsView.SectionAbbvrName.Name, ReportEnum.Align.Left, "${SectionAbbvrName}", ReportEnum.Align.Left, 20)
|
|
report.AddColumn(View_PersonsView.DeptAbbvr.Name, ReportEnum.Align.Left, "${DeptAbbvr}", ReportEnum.Align.Left, 20)
|
|
report.AddColumn(View_PersonsView.Retire.Name, ReportEnum.Align.Left, "${Retire}", ReportEnum.Align.Left, 15)
|
|
report.AddColumn(View_PersonsView.Commission.Name, ReportEnum.Align.Left, "${Commission}", ReportEnum.Align.Left, 30)
|
|
report.AddColumn(View_PersonsView.Born.Name, ReportEnum.Align.Left, "${Born}", ReportEnum.Align.Left, 20)
|
|
report.AddColumn(View_PersonsView.BProvince.Name, ReportEnum.Align.Left, "${BProvince}", ReportEnum.Align.Left, 30)
|
|
report.AddColumn(View_PersonsView.SAmout.Name, ReportEnum.Align.Right, "${SAmout}", ReportEnum.Align.Right, 20)
|
|
report.AddColumn(View_PersonsView.CEdu.Name, ReportEnum.Align.Left, "${CEdu}", ReportEnum.Align.Left, 30)
|
|
report.AddColumn(View_PersonsView.MobilePhone.Name, ReportEnum.Align.Left, "${MobilePhone}", ReportEnum.Align.Left, 15)
|
|
report.AddColumn(View_PersonsView.RankDate.Name, ReportEnum.Align.Left, "${RankDate}", ReportEnum.Align.Left, 20)
|
|
report.AddColumn(View_PersonsView.Title.Name, ReportEnum.Align.Left, "${Title}", ReportEnum.Align.Left, 30)
|
|
report.AddColumn(View_PersonsView.RankAndName.Name, ReportEnum.Align.Left, "${RankAndName}", ReportEnum.Align.Left, 30)
|
|
|
|
|
|
Dim rowsPerQuery As Integer = 5000
|
|
Dim recordCount As Integer = 0
|
|
|
|
report.Page = Page.GetResourceValue("Txt:Page", "Persons")
|
|
report.ApplicationPath = Me.Page.MapPath(Page.Request.ApplicationPath)
|
|
|
|
Dim whereClause As WhereClause = CreateWhereClause
|
|
Dim orderBy As OrderBy = CreateOrderBy
|
|
Dim joinFilter As BaseFilter = CreateCompoundJoinFilter()
|
|
|
|
Dim pageNum As Integer = 0
|
|
Dim totalRows As Integer = View_PersonsView.GetRecordCount(joinFilter,whereClause)
|
|
Dim columns As ColumnList = View_PersonsView.GetColumnList()
|
|
Dim records As View_PersonsRecord() = Nothing
|
|
|
|
Do
|
|
|
|
records = View_PersonsView.GetRecords(joinFilter,whereClause, orderBy, pageNum, rowsPerQuery)
|
|
If Not (records Is Nothing) AndAlso records.Length > 0 AndAlso whereClause.RunQuery Then
|
|
For Each record As View_PersonsRecord In records
|
|
|
|
' AddData method takes four parameters
|
|
' The 1st parameters represent the data format
|
|
' The 2nd parameters represent the data value
|
|
' The 3rd parameters represent the default alignment of column using the data
|
|
' The 4th parameters represent the maximum length of the data value being shown
|
|
report.AddData("${ArmSName}", record.Format(View_PersonsView.ArmSName), ReportEnum.Align.Left, 100)
|
|
report.AddData("${SectionAbbvrName}", record.Format(View_PersonsView.SectionAbbvrName), ReportEnum.Align.Left, 100)
|
|
report.AddData("${DeptAbbvr}", record.Format(View_PersonsView.DeptAbbvr), ReportEnum.Align.Left, 100)
|
|
report.AddData("${Retire}", record.Format(View_PersonsView.Retire), ReportEnum.Align.Left, 100)
|
|
report.AddData("${Commission}", record.Format(View_PersonsView.Commission), ReportEnum.Align.Left, 30)
|
|
report.AddData("${Born}", record.Format(View_PersonsView.Born), ReportEnum.Align.Left, 100)
|
|
report.AddData("${BProvince}", record.Format(View_PersonsView.BProvince), ReportEnum.Align.Left, 100)
|
|
report.AddData("${SAmout}", record.Format(View_PersonsView.SAmout), ReportEnum.Align.Right, 100)
|
|
report.AddData("${CEdu}", record.Format(View_PersonsView.CEdu), ReportEnum.Align.Left, 100)
|
|
report.AddData("${MobilePhone}", record.Format(View_PersonsView.MobilePhone), ReportEnum.Align.Left, 100)
|
|
report.AddData("${RankDate}", record.Format(View_PersonsView.RankDate), ReportEnum.Align.Left, 100)
|
|
report.AddData("${Title}", record.Format(View_PersonsView.Title), ReportEnum.Align.Left, 100)
|
|
report.AddData("${RankAndName}", record.Format(View_PersonsView.RankAndName), ReportEnum.Align.Left, 100)
|
|
|
|
report.WriteRow
|
|
Next
|
|
pageNum = pageNum + 1
|
|
recordCount += records.Length
|
|
End If
|
|
Loop While Not (records Is Nothing) AndAlso recordCount < totalRows AndAlso whereClause.RunQuery
|
|
|
|
report.Close
|
|
BaseClasses.Utils.NetUtils.WriteResponseBinaryAttachment(Me.Page.Response, report.Title + ".pdf", report.ReportInByteArray, 0, true)
|
|
|
|
Catch ex As Exception
|
|
' Upon error, rollback the transaction
|
|
Me.Page.RollBackTransaction(sender)
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub View_PersonsRefreshButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
Dim View_PersonsTableControlObj as View_PersonsTableControl = DirectCast(Me.Page.FindControlRecursively("View_PersonsTableControl"), View_PersonsTableControl)
|
|
View_PersonsTableControlObj.ResetData = True
|
|
|
|
View_PersonsTableControlObj.RemoveFromSession(View_PersonsTableControlObj, "DeletedRecordIds")
|
|
View_PersonsTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Catch ex As Exception
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub View_PersonsResetButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
Me.ArmyIdFromFilter1.ClearSelection()
|
|
Me.DeptIdFilter.ClearSelection()
|
|
Me.RankLevelFilter.ClearSelection()
|
|
Me.RetireFilter.ClearSelection()
|
|
Me.SectionIdFromFilter.ClearSelection()
|
|
Me.View_PersonsSearch1.Text = ""
|
|
Me.CurrentSortOrder.Reset()
|
|
If Me.InSession(Me, "Order_By") Then
|
|
Me.CurrentSortOrder = OrderBy.FromXmlString(Me.GetFromSession(Me, "Order_By", Nothing))
|
|
Else
|
|
Me.CurrentSortOrder = New OrderBy(True, False)
|
|
|
|
Me.CurrentSortOrder.Add(View_PersonsView.RankId, OrderByItem.OrderDir.Asc)
|
|
|
|
Me.CurrentSortOrder.Add(View_PersonsView.RankDate, OrderByItem.OrderDir.Asc)
|
|
|
|
Me.CurrentSortOrder.Add(View_PersonsView.DatePrevRank, OrderByItem.OrderDir.Asc)
|
|
|
|
|
|
End If
|
|
|
|
Me.SAmoutGrandTotal.Text = " "
|
|
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
Catch ex As Exception
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub View_PersonsWordButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
Dim report As WordReport = New WordReport
|
|
report.SpecificReportFileName = Page.Server.MapPath("ShowViewPersons.View_PersonsWordButton.word")
|
|
' report.Title replaces the value tag of page header and footer containing ${ReportTitle}
|
|
report.Title = "View_Persons"
|
|
' If ShowViewPersons.View_PersonsWordButton.report specifies a valid report template,
|
|
' AddColumn method will generate a report template.
|
|
' Each AddColumn method-call specifies a column
|
|
' The 1st parameter represents the text of the column header
|
|
' The 2nd parameter represents the horizontal alignment of the column header
|
|
' The 3rd parameter represents the text format of the column detail
|
|
' The 4th parameter represents the horizontal alignment of the column detail
|
|
' The 5th parameter represents the relative width of the column
|
|
report.AddColumn(View_PersonsView.ArmSName.Name, ReportEnum.Align.Left, "${ArmSName}", ReportEnum.Align.Left, 30)
|
|
report.AddColumn(View_PersonsView.SectionAbbvrName.Name, ReportEnum.Align.Left, "${SectionAbbvrName}", ReportEnum.Align.Left, 20)
|
|
report.AddColumn(View_PersonsView.DeptAbbvr.Name, ReportEnum.Align.Left, "${DeptAbbvr}", ReportEnum.Align.Left, 20)
|
|
report.AddColumn(View_PersonsView.Retire.Name, ReportEnum.Align.Left, "${Retire}", ReportEnum.Align.Left, 15)
|
|
report.AddColumn(View_PersonsView.Commission.Name, ReportEnum.Align.Left, "${Commission}", ReportEnum.Align.Left, 30)
|
|
report.AddColumn(View_PersonsView.Born.Name, ReportEnum.Align.Left, "${Born}", ReportEnum.Align.Left, 20)
|
|
report.AddColumn(View_PersonsView.BProvince.Name, ReportEnum.Align.Left, "${BProvince}", ReportEnum.Align.Left, 30)
|
|
report.AddColumn(View_PersonsView.SAmout.Name, ReportEnum.Align.Right, "${SAmout}", ReportEnum.Align.Right, 20)
|
|
report.AddColumn(View_PersonsView.CEdu.Name, ReportEnum.Align.Left, "${CEdu}", ReportEnum.Align.Left, 30)
|
|
report.AddColumn(View_PersonsView.MobilePhone.Name, ReportEnum.Align.Left, "${MobilePhone}", ReportEnum.Align.Left, 15)
|
|
report.AddColumn(View_PersonsView.RankDate.Name, ReportEnum.Align.Left, "${RankDate}", ReportEnum.Align.Left, 20)
|
|
report.AddColumn(View_PersonsView.Title.Name, ReportEnum.Align.Left, "${Title}", ReportEnum.Align.Left, 30)
|
|
report.AddColumn(View_PersonsView.RankAndName.Name, ReportEnum.Align.Left, "${RankAndName}", ReportEnum.Align.Left, 30)
|
|
|
|
Dim whereClause As WhereClause = CreateWhereClause
|
|
|
|
Dim orderBy As OrderBy = CreateOrderBy
|
|
Dim joinFilter As BaseFilter = CreateCompoundJoinFilter()
|
|
|
|
Dim rowsPerQuery As Integer = 5000
|
|
Dim pageNum As Integer = 0
|
|
Dim recordCount As Integer = 0
|
|
Dim totalRows As Integer = View_PersonsView.GetRecordCount(joinFilter,whereClause)
|
|
|
|
report.Page = Page.GetResourceValue("Txt:Page", "Persons")
|
|
report.ApplicationPath = Me.Page.MapPath(Page.Request.ApplicationPath)
|
|
|
|
Dim columns As ColumnList = View_PersonsView.GetColumnList()
|
|
Dim records As View_PersonsRecord() = Nothing
|
|
Do
|
|
records = View_PersonsView.GetRecords(joinFilter,whereClause, orderBy, pageNum, rowsPerQuery)
|
|
|
|
If Not (records Is Nothing) AndAlso records.Length > 0 AndAlso whereClause.RunQuery Then
|
|
For Each record As View_PersonsRecord In records
|
|
' AddData method takes four parameters
|
|
' The 1st parameters represent the data format
|
|
' The 2nd parameters represent the data value
|
|
' The 3rd parameters represent the default alignment of column using the data
|
|
' The 4th parameters represent the maximum length of the data value being shown
|
|
report.AddData("${ArmSName}", record.Format(View_PersonsView.ArmSName), ReportEnum.Align.Left, 100)
|
|
report.AddData("${SectionAbbvrName}", record.Format(View_PersonsView.SectionAbbvrName), ReportEnum.Align.Left, 100)
|
|
report.AddData("${DeptAbbvr}", record.Format(View_PersonsView.DeptAbbvr), ReportEnum.Align.Left, 100)
|
|
report.AddData("${Retire}", record.Format(View_PersonsView.Retire), ReportEnum.Align.Left, 100)
|
|
report.AddData("${Commission}", record.Format(View_PersonsView.Commission), ReportEnum.Align.Left, 30)
|
|
report.AddData("${Born}", record.Format(View_PersonsView.Born), ReportEnum.Align.Left, 100)
|
|
report.AddData("${BProvince}", record.Format(View_PersonsView.BProvince), ReportEnum.Align.Left, 100)
|
|
report.AddData("${SAmout}", record.Format(View_PersonsView.SAmout), ReportEnum.Align.Right, 100)
|
|
report.AddData("${CEdu}", record.Format(View_PersonsView.CEdu), ReportEnum.Align.Left, 100)
|
|
report.AddData("${MobilePhone}", record.Format(View_PersonsView.MobilePhone), ReportEnum.Align.Left, 100)
|
|
report.AddData("${RankDate}", record.Format(View_PersonsView.RankDate), ReportEnum.Align.Left, 100)
|
|
report.AddData("${Title}", record.Format(View_PersonsView.Title), ReportEnum.Align.Left, 100)
|
|
report.AddData("${RankAndName}", record.Format(View_PersonsView.RankAndName), ReportEnum.Align.Left, 100)
|
|
|
|
report.WriteRow
|
|
Next
|
|
pageNum = pageNum + 1
|
|
recordCount += records.Length
|
|
End If
|
|
Loop While Not (records Is Nothing) AndAlso recordCount < totalRows AndAlso whereClause.RunQuery
|
|
report.save
|
|
BaseClasses.Utils.NetUtils.WriteResponseBinaryAttachment(Me.Page.Response, report.Title + ".doc", report.ReportInByteArray, 0, true)
|
|
|
|
Catch ex As Exception
|
|
' Upon error, rollback the transaction
|
|
Me.Page.RollBackTransaction(sender)
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for Button with Layout
|
|
Public Overridable Sub View_PersonsSearchButton1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
Try
|
|
|
|
Me.DataChanged = True
|
|
|
|
Catch ex As Exception
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
' Generate the event handling functions for filter and search events.
|
|
|
|
' event handler for FieldFilter
|
|
Protected Overridable Sub ArmyIdFromFilter1_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
|
|
End Sub
|
|
|
|
' event handler for FieldFilter
|
|
Protected Overridable Sub DeptIdFilter_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
|
|
End Sub
|
|
|
|
' event handler for FieldFilter
|
|
Protected Overridable Sub RankLevelFilter_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
|
|
End Sub
|
|
|
|
' event handler for FieldFilter
|
|
Protected Overridable Sub RetireFilter_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
|
|
End Sub
|
|
|
|
' event handler for FieldFilter
|
|
Protected Overridable Sub SectionIdFromFilter_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
' Generate the event handling functions for others
|
|
|
|
|
|
Private _UIData As New System.Collections.Generic.List(Of Hashtable)
|
|
Public Property UIData() As System.Collections.Generic.List(Of Hashtable)
|
|
Get
|
|
Return Me._UIData
|
|
End Get
|
|
Set(ByVal value As System.Collections.Generic.List(Of Hashtable))
|
|
Me._UIData = value
|
|
End Set
|
|
End Property
|
|
|
|
' pagination properties
|
|
Protected _PageSize As Integer
|
|
Public Property PageSize() As Integer
|
|
Get
|
|
Return Me._PageSize
|
|
End Get
|
|
Set(ByVal value As Integer)
|
|
Me._PageSize = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected _PageIndex As Integer
|
|
Public Property PageIndex() As Integer
|
|
Get
|
|
' Return the PageIndex
|
|
Return Me._PageIndex
|
|
End Get
|
|
Set(ByVal value As Integer)
|
|
Me._PageIndex = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected _TotalRecords As Integer = -1
|
|
Public Property TotalRecords() As Integer
|
|
Get
|
|
If _TotalRecords < 0
|
|
_TotalRecords = View_PersonsView.GetRecordCount(CreateCompoundJoinFilter(), CreateWhereClause())
|
|
End If
|
|
Return Me._TotalRecords
|
|
End Get
|
|
Set(ByVal value As Integer)
|
|
If Me.PageSize > 0 Then
|
|
|
|
Me.TotalPages = CInt(Math.Ceiling(value / Me.PageSize))
|
|
|
|
End If
|
|
Me._TotalRecords = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
Protected _TotalPages As Integer = -1
|
|
Public Property TotalPages() As Integer
|
|
Get
|
|
If _TotalPages < 0 Then
|
|
|
|
Me.TotalPages = CInt(Math.Ceiling(TotalRecords / Me.PageSize))
|
|
|
|
End If
|
|
Return Me._TotalPages
|
|
End Get
|
|
Set(ByVal value As Integer)
|
|
Me._TotalPages = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected _DisplayLastPage As Boolean
|
|
Public Property DisplayLastPage() As Boolean
|
|
Get
|
|
Return Me._DisplayLastPage
|
|
End Get
|
|
Set(ByVal value As Boolean)
|
|
Me._DisplayLastPage = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataChanged As Boolean = False
|
|
Public Property DataChanged() As Boolean
|
|
Get
|
|
Return Me._DataChanged
|
|
End Get
|
|
Set(ByVal value As Boolean)
|
|
Me._DataChanged = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _ResetData As Boolean = False
|
|
Public Property ResetData() As Boolean
|
|
Get
|
|
Return Me._ResetData
|
|
End Get
|
|
Set(ByVal value As Boolean)
|
|
Me._ResetData = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _AddNewRecord As Integer = 0
|
|
Public Property AddNewRecord() As Integer
|
|
Get
|
|
Return Me._AddNewRecord
|
|
End Get
|
|
Set(ByVal value As Integer)
|
|
Me._AddNewRecord = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private _CurrentSortOrder As OrderBy = Nothing
|
|
Public Property CurrentSortOrder() As OrderBy
|
|
Get
|
|
Return Me._CurrentSortOrder
|
|
End Get
|
|
Set(ByVal value As BaseClasses.Data.OrderBy)
|
|
Me._CurrentSortOrder = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataSource() As View_PersonsRecord = Nothing
|
|
Public Property DataSource() As View_PersonsRecord ()
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
Set(ByVal value() As View_PersonsRecord)
|
|
Me._DataSource = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Helper Properties"
|
|
|
|
Public ReadOnly Property ArmSNameLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ArmSNameLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ArmyIdFromFilter1() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ArmyIdFromFilter1"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ArmyIdLabel2() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ArmyIdLabel2"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BornLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "BornLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BProvinceLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "BProvinceLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CEduLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CEduLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CommissionLabel() As System.Web.UI.WebControls.Label
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CommissionLabel"), System.Web.UI.WebControls.Label)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DeptIdFilter() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "DeptIdFilter"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DeptIdLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "DeptIdLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MobilePhoneLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "MobilePhoneLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalNameLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalNameLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property pictureLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "pictureLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RankDateLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RankDateLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RankDateLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RankDateLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RankLevelFilter() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RankLevelFilter"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RankLevelLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RankLevelLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RetireFilter() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RetireFilter"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RetireLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RetireLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RetireLabel1() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RetireLabel1"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SAmoutGrandTotal() As System.Web.UI.WebControls.Label
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SAmoutGrandTotal"), System.Web.UI.WebControls.Label)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SAmoutLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SAmoutLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SectionAbbvrNameLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SectionAbbvrNameLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SectionIdFromFilter() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SectionIdFromFilter"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SectionIdLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SectionIdLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property TitleLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "TitleLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property View_PersonsExportCSVButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsExportCSVButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property View_PersonsExportExcelButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsExportExcelButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property View_PersonsPagination() As Persons.UI.IPagination
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsPagination"), Persons.UI.IPagination)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property View_PersonsPDFButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsPDFButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property View_PersonsRefreshButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsRefreshButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property View_PersonsResetButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsResetButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property View_PersonsSearch1() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsSearch1"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property View_PersonsSearchButton1() As Persons.UI.IThemeButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsSearchButton1"), Persons.UI.IThemeButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property View_PersonsTableControlCollapsibleRegion() As System.Web.UI.WebControls.Panel
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsTableControlCollapsibleRegion"), System.Web.UI.WebControls.Panel)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property View_PersonsTableControlIcon() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsTableControlIcon"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property View_PersonsTableControlPanelExtender() As AjaxControlToolkit.CollapsiblePanelExtender
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsTableControlPanelExtender"), AjaxControlToolkit.CollapsiblePanelExtender)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property View_PersonsTitle() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsTitle"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property View_PersonsWordButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "View_PersonsWordButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
#Region "Helper Functions"
|
|
|
|
Public Overrides Overloads Function ModifyRedirectUrl(url As String, arg As String, ByVal bEncrypt As Boolean) As String
|
|
Return Me.Page.EvaluateExpressions(url, arg, bEncrypt, Me)
|
|
End Function
|
|
|
|
Public Overrides Overloads Function EvaluateExpressions(url As String, arg As String, ByVal bEncrypt As Boolean) As String
|
|
Dim needToProcess As Boolean = AreAnyUrlParametersForMe(url, arg)
|
|
If (needToProcess) Then
|
|
Dim recCtl As View_PersonsTableControlRow = Me.GetSelectedRecordControl()
|
|
If recCtl Is Nothing AndAlso url.IndexOf("{") >= 0 Then
|
|
' Localization.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoRecSelected", "Persons"))
|
|
End If
|
|
Dim rec As View_PersonsRecord = Nothing
|
|
If recCtl IsNot Nothing Then
|
|
rec = recCtl.GetRecord()
|
|
End If
|
|
Return EvaluateExpressions(url, arg, rec, bEncrypt)
|
|
End If
|
|
Return url
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControl() As View_PersonsTableControlRow
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControls() As View_PersonsTableControlRow()
|
|
|
|
Return DirectCast((new ArrayList()).ToArray(GetType(View_PersonsTableControlRow)), View_PersonsTableControlRow())
|
|
|
|
End Function
|
|
|
|
Public Overridable Sub DeleteSelectedRecords(ByVal deferDeletion As Boolean)
|
|
Dim recList() As View_PersonsTableControlRow = Me.GetSelectedRecordControls()
|
|
If recList.Length = 0 Then
|
|
' Localization.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoRecSelected", "Persons"))
|
|
End If
|
|
|
|
Dim recCtl As View_PersonsTableControlRow
|
|
For Each recCtl In recList
|
|
If deferDeletion Then
|
|
If Not recCtl.IsNewRecord Then
|
|
|
|
Me.AddToDeletedRecordIds(recCtl)
|
|
|
|
End If
|
|
recCtl.Visible = False
|
|
|
|
Else
|
|
|
|
recCtl.Delete()
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
Me.ResetData = True
|
|
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
Public Function GetRecordControls() As View_PersonsTableControlRow()
|
|
Dim recList As ArrayList = New ArrayList()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("View_PersonsTableControlRepeater"), System.Web.UI.WebControls.Repeater)
|
|
If rep Is Nothing Then Return Nothing
|
|
Dim repItem As System.Web.UI.WebControls.RepeaterItem
|
|
|
|
For Each repItem In rep.Items
|
|
|
|
Dim recControl As View_PersonsTableControlRow = DirectCast(repItem.FindControl("View_PersonsTableControlRow"), View_PersonsTableControlRow)
|
|
recList.Add(recControl)
|
|
|
|
Next
|
|
|
|
Return DirectCast(recList.ToArray(GetType(View_PersonsTableControlRow)), View_PersonsTableControlRow())
|
|
End Function
|
|
|
|
Public Shadows ReadOnly Property Page() As BaseApplicationPage
|
|
Get
|
|
Return DirectCast(MyBase.Page, BaseApplicationPage)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
End Class
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
End Namespace
|
|
|
|
|