42371 lines
No EOL
1.8 MiB
42371 lines
No EOL
1.8 MiB
|
|
' This file implements the TableControl, TableControlRow, and RecordControl classes for the
|
|
' EditPersonalId.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.EditPersonalId
|
|
|
|
#Region "Section 1: Place your customizations here."
|
|
|
|
|
|
|
|
Public Class PersonalDDTableControlRow
|
|
Inherits BasePersonalDDTableControlRow
|
|
' The BasePersonalDDTableControlRow implements code for a ROW within the
|
|
' the PersonalDDTableControl table. The BasePersonalDDTableControlRow implements the DataBind and SaveData methods.
|
|
' The loading of data is actually performed by the LoadData method in the base class of PersonalDDTableControl.
|
|
|
|
' This is the ideal place to add your code customizations. For example, you can override the DataBind,
|
|
' SaveData, GetUIData, and Validate methods.
|
|
|
|
|
|
End Class
|
|
|
|
|
|
|
|
Public Class PersonalDDTableControl
|
|
Inherits BasePersonalDDTableControl
|
|
|
|
' The BasePersonalDDTableControl 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 PersonalDDTableControlRow class offers another place where you can customize
|
|
' the DataBind, GetUIData, SaveData and Validate methods specific to each row displayed on the table.
|
|
|
|
End Class
|
|
|
|
|
|
Public Class PersonalEducationTableControlRow
|
|
Inherits BasePersonalEducationTableControlRow
|
|
' The BasePersonalEducationTableControlRow implements code for a ROW within the
|
|
' the PersonalEducationTableControl table. The BasePersonalEducationTableControlRow implements the DataBind and SaveData methods.
|
|
' The loading of data is actually performed by the LoadData method in the base class of PersonalEducationTableControl.
|
|
'Protected Overrides Sub PopulateEducationPeriodDropDownList( _
|
|
' ByVal selectedValue As String, _
|
|
' ByVal maxItems As Integer)
|
|
'
|
|
' Me.EducationPeriod.Items.Clear()
|
|
'
|
|
' Me.EducationPeriod.Items.Add(New ListItem("ก่อน", "1"))
|
|
' Me.EducationPeriod.Items.Add(New ListItem("หลัง", "2"))
|
|
'' 3. Set the selected value (insert if not already present).
|
|
' If Not selectedValue Is Nothing AndAlso _
|
|
' selectedValue.Trim <> "" AndAlso _
|
|
' Not SetSelectedValue(Me.EducationPeriod, selectedValue) AndAlso _
|
|
' Not MiscUtils.SetSelectedValue(Me.EducationPeriod, PersonalEducationTable.EducationPeriod.Format(selectedValue)) Then
|
|
'Dim fvalue As String = PersonalEducationTable.EducationPeriod.Format(selectedValue)
|
|
'Dim item As ListItem = New ListItem(fvalue, selectedValue)
|
|
' item.Selected = True
|
|
' Me.EducationPeriod.Items.Insert(0, item)
|
|
' End If
|
|
'
|
|
'
|
|
'' 4. Insert the language specific "Please Select" item at the top.
|
|
' Me.EducationPeriod.Items.Insert(0, New ListItem(Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
'
|
|
'End Sub
|
|
|
|
|
|
End Class
|
|
|
|
|
|
|
|
Public Class PersonalEducationTableControl
|
|
Inherits BasePersonalEducationTableControl
|
|
|
|
' The BasePersonalEducationTableControl 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 PersonalEducationTableControlRow class offers another place where you can customize
|
|
' the DataBind, GetUIData, SaveData and Validate methods specific to each row displayed on the table.
|
|
|
|
End Class
|
|
|
|
|
|
Public Class PersonalExtWorkTableControlRow
|
|
Inherits BasePersonalExtWorkTableControlRow
|
|
' The BasePersonalExtWorkTableControlRow implements code for a ROW within the
|
|
' the PersonalExtWorkTableControl table. The BasePersonalExtWorkTableControlRow implements the DataBind and SaveData methods.
|
|
' The loading of data is actually performed by the LoadData method in the base class of PersonalExtWorkTableControl.
|
|
|
|
' This is the ideal place to add your code customizations. For example, you can override the DataBind,
|
|
' SaveData, GetUIData, and Validate methods.
|
|
|
|
|
|
End Class
|
|
|
|
|
|
|
|
Public Class PersonalExtWorkTableControl
|
|
Inherits BasePersonalExtWorkTableControl
|
|
|
|
' The BasePersonalExtWorkTableControl 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 PersonalExtWorkTableControlRow class offers another place where you can customize
|
|
' the DataBind, GetUIData, SaveData and Validate methods specific to each row displayed on the table.
|
|
|
|
End Class
|
|
|
|
|
|
Public Class PersonalInsigniaTableControlRow
|
|
Inherits BasePersonalInsigniaTableControlRow
|
|
' The BasePersonalInsigniaTableControlRow implements code for a ROW within the
|
|
' the PersonalInsigniaTableControl table. The BasePersonalInsigniaTableControlRow implements the DataBind and SaveData methods.
|
|
' The loading of data is actually performed by the LoadData method in the base class of PersonalInsigniaTableControl.
|
|
|
|
' This is the ideal place to add your code customizations. For example, you can override the DataBind,
|
|
' SaveData, GetUIData, and Validate methods.
|
|
|
|
|
|
End Class
|
|
|
|
|
|
|
|
Public Class PersonalInsigniaTableControl
|
|
Inherits BasePersonalInsigniaTableControl
|
|
|
|
' The BasePersonalInsigniaTableControl 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 PersonalInsigniaTableControlRow class offers another place where you can customize
|
|
' the DataBind, GetUIData, SaveData and Validate methods specific to each row displayed on the table.
|
|
|
|
End Class
|
|
|
|
|
|
Public Class PersonalLanguageSkillTableControlRow
|
|
Inherits BasePersonalLanguageSkillTableControlRow
|
|
' The BasePersonalLanguageSkillTableControlRow implements code for a ROW within the
|
|
' the PersonalLanguageSkillTableControl table. The BasePersonalLanguageSkillTableControlRow implements the DataBind and SaveData methods.
|
|
' The loading of data is actually performed by the LoadData method in the base class of PersonalLanguageSkillTableControl.
|
|
|
|
' This is the ideal place to add your code customizations. For example, you can override the DataBind,
|
|
' SaveData, GetUIData, and Validate methods.
|
|
|
|
|
|
End Class
|
|
|
|
|
|
|
|
Public Class PersonalLanguageSkillTableControl
|
|
Inherits BasePersonalLanguageSkillTableControl
|
|
|
|
' The BasePersonalLanguageSkillTableControl 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 PersonalLanguageSkillTableControlRow class offers another place where you can customize
|
|
' the DataBind, GetUIData, SaveData and Validate methods specific to each row displayed on the table.
|
|
|
|
End Class
|
|
|
|
|
|
Public Class PersonalNameTableControlRow
|
|
Inherits BasePersonalNameTableControlRow
|
|
' The BasePersonalNameTableControlRow implements code for a ROW within the
|
|
' the PersonalNameTableControl table. The BasePersonalNameTableControlRow implements the DataBind and SaveData methods.
|
|
' The loading of data is actually performed by the LoadData method in the base class of PersonalNameTableControl.
|
|
|
|
' This is the ideal place to add your code customizations. For example, you can override the DataBind,
|
|
' SaveData, GetUIData, and Validate methods.
|
|
|
|
|
|
End Class
|
|
|
|
|
|
|
|
Public Class PersonalNameTableControl
|
|
Inherits BasePersonalNameTableControl
|
|
|
|
' The BasePersonalNameTableControl 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 PersonalNameTableControlRow class offers another place where you can customize
|
|
' the DataBind, GetUIData, SaveData and Validate methods specific to each row displayed on the table.
|
|
|
|
End Class
|
|
|
|
|
|
Public Class PersonalRankTableControlRow
|
|
Inherits BasePersonalRankTableControlRow
|
|
|
|
Protected Overrides Sub PopulateRankId1DropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_RankId1DropDownList()
|
|
wc.iAND(RankTable.RankId, BaseFilter.ComparisonOperator.Less_Than, "61")
|
|
wc.iOR(RankTable.RankId, BaseFilter.ComparisonOperator.Greater_Than, "69")
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(False, True)
|
|
orderBy.Add(RankTable.ArmyId, OrderByItem.OrderDir.Asc)
|
|
orderBy.Add(RankTable.RankId, OrderByItem.OrderDir.Asc)
|
|
|
|
|
|
' 2. Read a total of maxItems from the database and insert them into the RankId1DropDownList.
|
|
Me.RankId1.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 = Nothing
|
|
If itemValue.RankIdSpecified Then
|
|
cvalue = itemValue.RankId.ToString()
|
|
fvalue = itemValue.Format(RankTable.ArmyId) & " - " & itemValue.Format(RankTable.RankName)
|
|
End If
|
|
|
|
Dim item As ListItem = New ListItem(fvalue, cvalue)
|
|
Me.RankId1.Items.Add(item)
|
|
Next
|
|
|
|
' 3. Set the selected value (insert if not already present).
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.RankId1, selectedValue) AndAlso _
|
|
Not MiscUtils.SetSelectedValue(Me.RankId1, PersonalRankTable.RankId.Format(selectedValue)) Then
|
|
Dim fvalue As String = PersonalRankTable.RankId.Format(selectedValue)
|
|
Dim item As ListItem = New ListItem(fvalue, selectedValue)
|
|
item.Selected = True
|
|
Me.RankId1.Items.Insert(0, item)
|
|
End If
|
|
|
|
|
|
' 4. Insert the language specific "Please Select" item at the top.
|
|
Me.RankId1.Items.Insert(0, New ListItem(Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
End Sub
|
|
|
|
|
|
End Class
|
|
|
|
|
|
|
|
Public Class PersonalRankTableControl
|
|
Inherits BasePersonalRankTableControl
|
|
|
|
Public Overrides 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.
|
|
Dim orderby As OrderBy = New OrderBy(False, False)
|
|
orderby.Add(PersonalRankTable.RankId, OrderByItem.OrderDir.Desc)
|
|
orderby.Add(PersonalRankTable.PreRank, OrderByItem.OrderDir.Desc)
|
|
Return orderby
|
|
'Return Me.CurrentSortOrder
|
|
End Function
|
|
|
|
|
|
End Class
|
|
|
|
|
|
Public Class PersonalSalaryTableControlRow
|
|
Inherits BasePersonalSalaryTableControlRow
|
|
' The BasePersonalSalaryTableControlRow implements code for a ROW within the
|
|
' the PersonalSalaryTableControl table. The BasePersonalSalaryTableControlRow implements the DataBind and SaveData methods.
|
|
' The loading of data is actually performed by the LoadData method in the base class of PersonalSalaryTableControl.
|
|
|
|
' This is the ideal place to add your code customizations. For example, you can override the DataBind,
|
|
' SaveData, GetUIData, and Validate methods.
|
|
|
|
|
|
End Class
|
|
|
|
|
|
|
|
Public Class PersonalSalaryTableControl
|
|
Inherits BasePersonalSalaryTableControl
|
|
|
|
' The BasePersonalSalaryTableControl 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 PersonalSalaryTableControlRow class offers another place where you can customize
|
|
' the DataBind, GetUIData, SaveData and Validate methods specific to each row displayed on the table.
|
|
|
|
End Class
|
|
|
|
|
|
Public Class PersonalSpecialSkillTableControlRow
|
|
Inherits BasePersonalSpecialSkillTableControlRow
|
|
' The BasePersonalSpecialSkillTableControlRow implements code for a ROW within the
|
|
' the PersonalSpecialSkillTableControl table. The BasePersonalSpecialSkillTableControlRow implements the DataBind and SaveData methods.
|
|
' The loading of data is actually performed by the LoadData method in the base class of PersonalSpecialSkillTableControl.
|
|
|
|
' This is the ideal place to add your code customizations. For example, you can override the DataBind,
|
|
' SaveData, GetUIData, and Validate methods.
|
|
|
|
|
|
End Class
|
|
|
|
|
|
|
|
Public Class PersonalSpecialSkillTableControl
|
|
Inherits BasePersonalSpecialSkillTableControl
|
|
|
|
' The BasePersonalSpecialSkillTableControl 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 PersonalSpecialSkillTableControlRow class offers another place where you can customize
|
|
' the DataBind, GetUIData, SaveData and Validate methods specific to each row displayed on the table.
|
|
|
|
End Class
|
|
|
|
|
|
|
|
|
|
Public Class PersonalTitleTableControlRow
|
|
Inherits BasePersonalTitleTableControlRow
|
|
' The BasePersonalTitleTableControlRow implements code for a ROW within the
|
|
' the PersonalTitleTableControl table. The BasePersonalTitleTableControlRow implements the DataBind and SaveData methods.
|
|
' The loading of data is actually performed by the LoadData method in the base class of PersonalTitleTableControl.
|
|
|
|
' This is the ideal place to add your code customizations. For example, you can override the DataBind,
|
|
' SaveData, GetUIData, and Validate methods.
|
|
|
|
|
|
End Class
|
|
|
|
|
|
|
|
Public Class PersonalTitleTableControl
|
|
Inherits BasePersonalTitleTableControl
|
|
|
|
' The BasePersonalTitleTableControl 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 PersonalTitleTableControlRow class offers another place where you can customize
|
|
' the DataBind, GetUIData, SaveData and Validate methods specific to each row displayed on the table.
|
|
|
|
End Class
|
|
|
|
|
|
|
|
|
|
Public Class PersonalIdRecordControl
|
|
Inherits BasePersonalIdRecordControl
|
|
' The BasePersonalIdRecordControl implements the LoadData, DataBind and other
|
|
' methods to load and display the data in a table control.
|
|
|
|
Protected Overrides Sub PopulateRankIdDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
' Populate the RankIdDropDownList with the
|
|
' foreign key values from the Rank table.
|
|
|
|
' This is a four step process.
|
|
' 1. Set up the WHERE and the ORDER BY clause to read from the Rank.
|
|
' 2. Read a total of maxItems from the database and insert them into the RankIdDropDownList.
|
|
' 3. Set the selected value (insert if not already present).
|
|
' 4. Insert the language specific "Please Select" item at the top.
|
|
|
|
' 1. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_RankIdDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
Dim wc As WhereClause = CreateWhereClause_RankIdDropDownList()
|
|
wc.iAND(RankTable.RankId, BaseFilter.ComparisonOperator.Less_Than, "61")
|
|
wc.iOR(RankTable.RankId, BaseFilter.ComparisonOperator.Greater_Than, "69")
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(False, True)
|
|
orderBy.Add(RankTable.ArmyId, OrderByItem.OrderDir.Asc)
|
|
orderBy.Add(RankTable.RankId, OrderByItem.OrderDir.Asc)
|
|
|
|
' 2. Read a total of maxItems from the database and insert them into the RankIdDropDownList.
|
|
Me.RankId.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 = Nothing
|
|
If itemValue.RankIdSpecified Then
|
|
cvalue = itemValue.RankId.ToString()
|
|
fvalue = itemValue.Format(RankTable.ArmyId) & " - " & itemValue.Format(RankTable.RankName)
|
|
End If
|
|
|
|
Dim item As ListItem = New ListItem(fvalue, cvalue)
|
|
Me.RankId.Items.Add(item)
|
|
Next
|
|
|
|
' 3. Set the selected value (insert if not already present).
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.RankId, selectedValue) AndAlso _
|
|
Not MiscUtils.SetSelectedValue(Me.RankId, PersonalIdTable.RankId.Format(selectedValue)) Then
|
|
Dim fvalue As String = PersonalIdTable.RankId.Format(selectedValue)
|
|
Dim item As ListItem = New ListItem(fvalue, selectedValue)
|
|
item.Selected = True
|
|
Me.RankId.Items.Insert(0, item)
|
|
End If
|
|
|
|
|
|
' 4. Insert the language specific "Please Select" item at the top.
|
|
Me.RankId.Items.Insert(0, New ListItem(Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub PopulateArmIdDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
' Populate the ArmIdDropDownList with the
|
|
' foreign key values from the Arm table.
|
|
|
|
' This is a four step process.
|
|
' 1. Set up the WHERE and the ORDER BY clause to read from the Arm.
|
|
' 2. Read a total of maxItems from the database and insert them into the ArmIdDropDownList.
|
|
' 3. Set the selected value (insert if not already present).
|
|
' 4. Insert the language specific "Please Select" item at the top.
|
|
|
|
' 1. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_ArmIdDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
Dim wc As WhereClause = CreateWhereClause_ArmIdDropDownList()
|
|
' wc.iAND (PersonalIdTable .ArmyId ,BaseFilter.ComparisonOperator.EqualsTo ,Me.ArmyId .Text
|
|
Dim orderBy As OrderBy = New OrderBy(False, True)
|
|
orderBy.Add(ArmTable.ArmId, OrderByItem.OrderDir.Asc)
|
|
|
|
' 2. Read a total of maxItems from the database and insert them into the ArmIdDropDownList.
|
|
Me.ArmId.Items.Clear()
|
|
Dim itemValue As ArmRecord
|
|
For Each itemValue In ArmTable.GetRecords(wc, orderBy, 0, maxItems)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.ArmIdSpecified Then
|
|
cvalue = itemValue.ArmId.ToString()
|
|
fvalue = itemValue.Format(ArmTable.ArmyId) & " - " & itemValue.Format(ArmTable.ArmName)
|
|
End If
|
|
|
|
Dim item As ListItem = New ListItem(fvalue, cvalue)
|
|
Me.ArmId.Items.Add(item)
|
|
Next
|
|
|
|
' 3. Set the selected value (insert if not already present).
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.ArmId, selectedValue) AndAlso _
|
|
Not MiscUtils.SetSelectedValue(Me.ArmId, PersonalIdTable.ArmId.Format(selectedValue)) Then
|
|
Dim fvalue As String = PersonalIdTable.ArmId.Format(selectedValue)
|
|
Dim item As ListItem = New ListItem(fvalue, selectedValue)
|
|
item.Selected = True
|
|
Me.ArmId.Items.Insert(0, item)
|
|
End If
|
|
|
|
|
|
' 4. Insert the language specific "Please Select" item at the top.
|
|
Me.ArmId.Items.Insert(0, New ListItem(Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub PersonalIdRecordControl_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
|
|
AddHandler Me.PersonalId.TextChanged, AddressOf PersonalId_TextChanged
|
|
|
|
End Sub
|
|
|
|
Private Sub PersonalId_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
|
|
'update PersonalId
|
|
' Ps.ChingePID(Me.DataSource.PersonalId, Me.PersonalId.Text)
|
|
'Me.DataChanged = True
|
|
'Me.SaveData()
|
|
Try
|
|
DbUtils.StartTransaction()
|
|
Dim Rec As PersonalIdRecord = Me.GetRecord
|
|
If Me.PersonalId.Text <> Rec.PersonalId Then
|
|
If Ps.IsPid(Me.PersonalId.Text) Then
|
|
Ps.ChingePID(Rec.PersonalId, Me.PersonalId.Text)
|
|
DbUtils.CommitTransaction()
|
|
'Me.Page.CurrentSecurity.SetUser(Me.PersonalName.Text, Me.PersonalId.Text)
|
|
Me.Page.RedirectToLoginPage()
|
|
Else
|
|
Throw New Exception("กรอกรหัสประจำตัวประชาชนไม่ถูกต้อง")
|
|
End If
|
|
End If
|
|
Catch ex As ApplicationException
|
|
MiscUtils.RegisterJScriptAlert(Me, "", ex.Message)
|
|
End Try
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub PopulateDeptIdDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
' Populate the DeptIdDropDownList with the
|
|
' foreign key values from the Dept table.
|
|
|
|
' This is a four step process.
|
|
' 1. Set up the WHERE and the ORDER BY clause to read from the Dept.
|
|
' 2. Read a total of maxItems from the database and insert them into the DeptIdDropDownList.
|
|
' 3. Set the selected value (insert if not already present).
|
|
' 4. Insert the language specific "Please Select" item at the top.
|
|
|
|
' 1. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_DeptIdDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
Dim wc As WhereClause = CreateWhereClause_DeptIdDropDownList()
|
|
Dim orderBy As OrderBy = New OrderBy(False, True)
|
|
orderBy.Add(DeptTable.SectionId, OrderByItem.OrderDir.Asc)
|
|
orderBy.Add(DeptTable.Dept, OrderByItem.OrderDir.Asc)
|
|
|
|
' 2. Read a total of maxItems from the database and insert them into the DeptIdDropDownList.
|
|
Me.DeptId.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 = Nothing
|
|
If itemValue.DeptIdSpecified Then
|
|
cvalue = itemValue.DeptId.ToString()
|
|
fvalue = itemValue.Format(DeptTable.SectionId) & " - " & itemValue.Format(DeptTable.Dept)
|
|
End If
|
|
|
|
Dim item As ListItem = New ListItem(fvalue, cvalue)
|
|
Me.DeptId.Items.Add(item)
|
|
Next
|
|
|
|
' 3. Set the selected value (insert if not already present).
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.DeptId, selectedValue) AndAlso _
|
|
Not MiscUtils.SetSelectedValue(Me.DeptId, PersonalIdTable.DeptId.Format(selectedValue)) Then
|
|
Dim fvalue As String = PersonalIdTable.DeptId.Format(selectedValue)
|
|
Dim item As ListItem = New ListItem(fvalue, selectedValue)
|
|
item.Selected = True
|
|
Me.DeptId.Items.Insert(0, item)
|
|
End If
|
|
|
|
|
|
' 4. Insert the language specific "Please Select" item at the top.
|
|
Me.DeptId.Items.Insert(0, New ListItem(Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
End Class
|
|
|
|
|
|
|
|
Public Class PersonalSportSkillTableControl1
|
|
Inherits BasePersonalSportSkillTableControl1
|
|
|
|
' The BasePersonalSportSkillTableControl1 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 PersonalSportSkillTableControl1Row class offers another place where you can customize
|
|
' the DataBind, GetUIData, SaveData and Validate methods specific to each row displayed on the table.
|
|
|
|
End Class
|
|
Public Class PersonalSportSkillTableControl1Row
|
|
Inherits BasePersonalSportSkillTableControl1Row
|
|
' The BasePersonalSportSkillTableControl1Row implements code for a ROW within the
|
|
' the PersonalSportSkillTableControl1 table. The BasePersonalSportSkillTableControl1Row implements the DataBind and SaveData methods.
|
|
' The loading of data is actually performed by the LoadData method in the base class of PersonalSportSkillTableControl1.
|
|
|
|
' This is the ideal place to add your code customizations. For example, you can override the DataBind,
|
|
' SaveData, GetUIData, and Validate methods.
|
|
|
|
|
|
End Class
|
|
Public Class PersonRelativeTableControl
|
|
Inherits BasePersonRelativeTableControl
|
|
|
|
Public Overrides 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.
|
|
Dim orderby As OrderBy = New OrderBy(False, False)
|
|
orderby.Add(PersonRelativeTable.RelationId, OrderByItem.OrderDir.Asc)
|
|
orderby.Add(PersonRelativeTable.RBirthDate, OrderByItem.OrderDir.Asc)
|
|
Return orderby
|
|
'Return Me.CurrentSortOrder
|
|
End Function
|
|
|
|
|
|
End Class
|
|
Public Class PersonRelativeTableControlRow
|
|
Inherits BasePersonRelativeTableControlRow
|
|
' The BasePersonRelativeTableControlRow implements code for a ROW within the
|
|
' the PersonRelativeTableControl table. The BasePersonRelativeTableControlRow implements the DataBind and SaveData methods.
|
|
' The loading of data is actually performed by the LoadData method in the base class of PersonRelativeTableControl.
|
|
|
|
' This is the ideal place to add your code customizations. For example, you can override the DataBind,
|
|
' SaveData, GetUIData, and Validate methods.
|
|
|
|
|
|
End Class
|
|
#End Region
|
|
|
|
|
|
|
|
#Region "Section 2: Do not modify this section."
|
|
|
|
|
|
' Base class for the PersonalDDTableControlRow control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalDDTableControlRow.
|
|
Public Class BasePersonalDDTableControlRow
|
|
Inherits Persons.UI.BaseApplicationRecordControl
|
|
|
|
' To customize, override this method in PersonalDDTableControlRow.
|
|
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 PersonalDDTableControlRow.
|
|
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)
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalDDRowDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteRecordConfirm", "Persons") & "'));")
|
|
|
|
|
|
' Register the event handlers.
|
|
|
|
AddHandler Me.PersonalDDRowDeleteButton.Click, AddressOf PersonalDDRowDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalDDRowEditButton.Click, AddressOf PersonalDDRowEditButton_Click
|
|
|
|
AddHandler Me.PersonalDDRowViewButton.Click, AddressOf PersonalDDRowViewButton_Click
|
|
|
|
AddHandler Me.EndDate.TextChanged, AddressOf EndDate_TextChanged
|
|
|
|
AddHandler Me.Mission.TextChanged, AddressOf Mission_TextChanged
|
|
|
|
AddHandler Me.Ref1.TextChanged, AddressOf Ref1_TextChanged
|
|
|
|
AddHandler Me.RefDate.TextChanged, AddressOf RefDate_TextChanged
|
|
|
|
AddHandler Me.StartDate.TextChanged, AddressOf StartDate_TextChanged
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Load the data from the database into the DataSource PersonalDD 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 = PersonalDDTable.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 BasePersonalDDTableControl when the data for the entire
|
|
' table is loaded.
|
|
|
|
Me.DataSource = New PersonalDDRecord()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
' Populate the UI controls using the DataSource. To customize, override this method in PersonalDDTableControlRow.
|
|
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
|
|
|
|
SetEndDate()
|
|
SetMission()
|
|
|
|
|
|
|
|
|
|
SetRef1()
|
|
SetRefDate()
|
|
SetStartDate()
|
|
|
|
|
|
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 SetEndDate()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.EndDate.ID) Then
|
|
|
|
Me.EndDate.Text = Me.PreviousUIData(Me.EndDate.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the EndDate TextBox on the webpage with value from the
|
|
' PersonalDD database record.
|
|
|
|
' Me.DataSource is the PersonalDD record retrieved from the database.
|
|
' Me.EndDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetEndDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.EndDateSpecified Then
|
|
|
|
' If the EndDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalDDTable.EndDate, "d MMM yy")
|
|
|
|
Me.EndDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' EndDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.EndDate.Text = PersonalDDTable.EndDate.Format(PersonalDDTable.EndDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetMission()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Mission.ID) Then
|
|
|
|
Me.Mission.Text = Me.PreviousUIData(Me.Mission.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Mission TextBox on the webpage with value from the
|
|
' PersonalDD database record.
|
|
|
|
' Me.DataSource is the PersonalDD record retrieved from the database.
|
|
' Me.Mission is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetMission()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.MissionSpecified Then
|
|
|
|
' If the Mission is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalDDTable.Mission)
|
|
|
|
Me.Mission.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Mission is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Mission.Text = PersonalDDTable.Mission.Format(PersonalDDTable.Mission.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRef1()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Ref1.ID) Then
|
|
|
|
Me.Ref1.Text = Me.PreviousUIData(Me.Ref1.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Ref TextBox on the webpage with value from the
|
|
' PersonalDD database record.
|
|
|
|
' Me.DataSource is the PersonalDD record retrieved from the database.
|
|
' Me.Ref1 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRef1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.Ref0Specified Then
|
|
|
|
' If the Ref is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalDDTable.Ref0)
|
|
|
|
Me.Ref1.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Ref is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Ref1.Text = PersonalDDTable.Ref0.Format(PersonalDDTable.Ref0.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRefDate()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RefDate.ID) Then
|
|
|
|
Me.RefDate.Text = Me.PreviousUIData(Me.RefDate.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RefDate TextBox on the webpage with value from the
|
|
' PersonalDD database record.
|
|
|
|
' Me.DataSource is the PersonalDD record retrieved from the database.
|
|
' Me.RefDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRefDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RefDateSpecified Then
|
|
|
|
' If the RefDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalDDTable.RefDate, "d MMM yy")
|
|
|
|
Me.RefDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RefDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RefDate.Text = PersonalDDTable.RefDate.Format(PersonalDDTable.RefDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetStartDate()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.StartDate.ID) Then
|
|
|
|
Me.StartDate.Text = Me.PreviousUIData(Me.StartDate.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the StartDate TextBox on the webpage with value from the
|
|
' PersonalDD database record.
|
|
|
|
' Me.DataSource is the PersonalDD record retrieved from the database.
|
|
' Me.StartDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetStartDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.StartDateSpecified Then
|
|
|
|
' If the StartDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalDDTable.StartDate, "d MMM yy")
|
|
|
|
Me.StartDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' StartDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.StartDate.Text = PersonalDDTable.StartDate.Format(PersonalDDTable.StartDate.DefaultValue, "d MMM yy")
|
|
|
|
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 PersonalDDTableControlRow.
|
|
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()
|
|
|
|
Dim parentCtrl As PersonalIdRecordControl
|
|
|
|
|
|
parentCtrl = DirectCast(Me.Page.FindControlRecursively("PersonalIdRecordControl"), PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(parentCtrl) AndAlso IsNothing(parentCtrl.DataSource))
|
|
' Load the record if it is not loaded yet.
|
|
parentCtrl.LoadData()
|
|
End If
|
|
If (IsNothing(parentCtrl) OrElse IsNothing(parentCtrl.DataSource))
|
|
' Get the error message from the application resource file.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoParentRecId", "Persons"))
|
|
End If
|
|
|
|
Me.DataSource.PersonalId = parentCtrl.DataSource.PersonalId
|
|
|
|
' 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, "PersonalDDTableControl"), PersonalDDTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalDDTableControl"), PersonalDDTableControl).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 PersonalDDTableControlRow.
|
|
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.
|
|
|
|
GetEndDate()
|
|
GetMission()
|
|
GetRef1()
|
|
GetRefDate()
|
|
GetStartDate()
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub GetEndDate()
|
|
|
|
' Retrieve the value entered by the user on the EndDate ASP:TextBox, and
|
|
' save it into the EndDate field in DataSource PersonalDD record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.EndDate.Text, PersonalDDTable.EndDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetMission()
|
|
|
|
' Retrieve the value entered by the user on the Mission ASP:TextBox, and
|
|
' save it into the Mission field in DataSource PersonalDD record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Mission.Text, PersonalDDTable.Mission)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRef1()
|
|
|
|
' Retrieve the value entered by the user on the Ref ASP:TextBox, and
|
|
' save it into the Ref field in DataSource PersonalDD record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Ref1.Text, PersonalDDTable.Ref0)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRefDate()
|
|
|
|
' Retrieve the value entered by the user on the RefDate ASP:TextBox, and
|
|
' save it into the RefDate field in DataSource PersonalDD record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RefDate.Text, PersonalDDTable.RefDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetStartDate()
|
|
|
|
' Retrieve the value entered by the user on the StartDate ASP:TextBox, and
|
|
' save it into the StartDate field in DataSource PersonalDD record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.StartDate.Text, PersonalDDTable.StartDate)
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
' To customize, override this method in PersonalDDTableControlRow.
|
|
|
|
Public Overridable Function CreateWhereClause() As WhereClause
|
|
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
|
|
|
|
' To customize, override this method in PersonalDDTableControlRow.
|
|
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)
|
|
PersonalDDTable.DeleteRecord(pkValue)
|
|
|
|
DirectCast(GetParentControlObject(Me, "PersonalDDTableControl"), PersonalDDTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalDDTableControl"), PersonalDDTableControl).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
|
|
|
|
|
|
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 PersonalDDRowDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Dim tc As PersonalDDTableControl = DirectCast(GetParentControlObject(Me, "PersonalDDTableControl"), PersonalDDTableControl)
|
|
If Not (IsNothing(tc)) Then
|
|
If Not Me.IsNewRecord Then
|
|
tc.AddToDeletedRecordIds(DirectCast(Me, PersonalDDTableControlRow))
|
|
End If
|
|
Me.Visible = False
|
|
tc.SetFormulaControls()
|
|
End If
|
|
|
|
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 PersonalDDRowEditButton_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalDDRowViewButton_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 = "../Shared/ConfigureViewRecord.aspx"
|
|
|
|
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
|
|
|
|
Protected Overridable Sub EndDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Mission_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Ref1_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RefDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub StartDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
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("BasePersonalDDTableControlRow_Rec"), String)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me.ViewState("BasePersonalDDTableControlRow_Rec") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataSource As PersonalDDRecord
|
|
Public Property DataSource() As PersonalDDRecord
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
|
|
Set(ByVal value As PersonalDDRecord)
|
|
|
|
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 EndDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "EndDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Mission() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Mission"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalDDRecordRowSelection() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalDDRecordRowSelection"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalDDRowDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalDDRowDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalDDRowEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalDDRowEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalDDRowViewButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalDDRowViewButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Ref1() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Ref1"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RefDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RefDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property StartDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "StartDate"), System.Web.UI.WebControls.TextBox)
|
|
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 PersonalDDRecord = 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 PersonalDDRecord
|
|
If Not Me.DataSource Is Nothing Then
|
|
Return Me.DataSource
|
|
End If
|
|
|
|
If Not Me.RecordUniqueId Is Nothing Then
|
|
|
|
Return PersonalDDTable.GetRecord(Me.RecordUniqueId, True)
|
|
|
|
End If
|
|
|
|
' Localization.
|
|
|
|
Return Nothing
|
|
|
|
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 PersonalDDTableControl control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalDDTableControl.
|
|
Public Class BasePersonalDDTableControl
|
|
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.
|
|
|
|
|
|
|
|
' 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(PersonalDDTable.StartDate, 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()
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalDDDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteConfirm", "Persons") & "'));")
|
|
|
|
' Setup the pagination events.
|
|
|
|
AddHandler Me.PersonalDDPagination.FirstPage.Click, AddressOf PersonalDDPagination_FirstPage_Click
|
|
|
|
AddHandler Me.PersonalDDPagination.LastPage.Click, AddressOf PersonalDDPagination_LastPage_Click
|
|
|
|
AddHandler Me.PersonalDDPagination.NextPage.Click, AddressOf PersonalDDPagination_NextPage_Click
|
|
|
|
AddHandler Me.PersonalDDPagination.PageSizeButton.Click, AddressOf PersonalDDPagination_PageSizeButton_Click
|
|
|
|
AddHandler Me.PersonalDDPagination.PreviousPage.Click, AddressOf PersonalDDPagination_PreviousPage_Click
|
|
|
|
|
|
' Setup the sorting events.
|
|
|
|
AddHandler Me.EndDateLabel1.Click, AddressOf EndDateLabel1_Click
|
|
|
|
AddHandler Me.MissionLabel.Click, AddressOf MissionLabel_Click
|
|
|
|
AddHandler Me.RefDateLabel.Click, AddressOf RefDateLabel_Click
|
|
|
|
AddHandler Me.RefLabel.Click, AddressOf RefLabel_Click
|
|
|
|
AddHandler Me.StartDateLabel1.Click, AddressOf StartDateLabel1_Click
|
|
|
|
' Setup the button events.
|
|
|
|
AddHandler Me.PersonalDDAddButton.Click, AddressOf PersonalDDAddButton_Click
|
|
|
|
AddHandler Me.PersonalDDDeleteButton.Click, AddressOf PersonalDDDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalDDEditButton.Click, AddressOf PersonalDDEditButton_Click
|
|
|
|
AddHandler Me.PersonalDDResetButton.Click, AddressOf PersonalDDResetButton_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(PersonalDDRecord)), PersonalDDRecord())
|
|
' 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, PersonalDDTable.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 PersonalDDTableControlRow 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(PersonalDDRecord)), PersonalDDRecord())
|
|
Else ' Get the records from the database
|
|
Me.DataSource = PersonalDDTable.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()
|
|
|
|
' Turn off the ToggleAll checkbox
|
|
Me.PersonalDDToggleAll.Checked = False
|
|
|
|
|
|
' Initialize the page and grand totals. now
|
|
|
|
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, "PersonalDDTableControlRepeater"), 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 PersonalDDTableControlRow = DirectCast(repItem.FindControl("PersonalDDTableControlRow"), PersonalDDTableControlRow)
|
|
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
|
|
|
|
SetEndDateLabel1()
|
|
SetMissionLabel()
|
|
|
|
|
|
|
|
|
|
|
|
SetPersonalDDTableControlCollapsibleRegion()
|
|
|
|
SetRefDateLabel()
|
|
SetRefLabel()
|
|
SetStartDateLabel1()
|
|
' 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()
|
|
|
|
|
|
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.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(PersonalDDTable.StartDate, 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.PersonalDDPagination.CurrentPage.Text = (Me.PageIndex + 1).ToString()
|
|
Else
|
|
Me.PersonalDDPagination.CurrentPage.Text = "0"
|
|
End If
|
|
Me.PersonalDDPagination.PageSize.Text = Me.PageSize.ToString()
|
|
Me.PersonalDDPagination.TotalItems.Text = Me.TotalRecords.ToString()
|
|
Me.PersonalDDPagination.TotalPages.Text = Me.TotalPages.ToString()
|
|
|
|
' Bind the buttons for PersonalDDTableControl pagination.
|
|
|
|
Me.PersonalDDPagination.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.PersonalDDPagination.LastPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalDDPagination.LastPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalDDPagination.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.PersonalDDPagination.NextPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalDDPagination.NextPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalDDPagination.NextPage.Enabled = Not (Me.PageIndex = Me.TotalPages - 1)
|
|
End If
|
|
|
|
Me.PersonalDDPagination.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 PersonalDDTableControlRow
|
|
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.
|
|
PersonalDDTable.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 selectedRecordKeyValue as KeyValue = New KeyValue()
|
|
|
|
Dim personalIdRecordControlObj As Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalIdRecordControl"), Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(personalIdRecordControlObj) AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord()) AndAlso personalIdRecordControlObj.GetRecord().IsCreated AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord().PersonalId))
|
|
wc.iAND(PersonalDDTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
selectedRecordKeyValue.AddElement(PersonalDDTable.PersonalId.InternalName, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
Else
|
|
wc.RunQuery = False
|
|
Return wc
|
|
End If
|
|
|
|
HttpContext.Current.Session("PersonalDDTableControlWhereClause") = selectedRecordKeyValue.ToXmlString()
|
|
|
|
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.
|
|
PersonalDDTable.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)
|
|
|
|
Dim selectedRecordInPersonalIdRecordControl as String = DirectCast(HttpContext.Current.Session("PersonalDDTableControlWhereClause"), String)
|
|
|
|
If Not selectedRecordInPersonalIdRecordControl Is Nothing AndAlso KeyValue.IsXmlKey(selectedRecordInPersonalIdRecordControl) Then
|
|
Dim selectedRecordKeyValue as KeyValue = KeyValue.XmlToKey(selectedRecordInPersonalIdRecordControl)
|
|
|
|
If Not IsNothing(selectedRecordKeyValue) AndAlso selectedRecordKeyValue.ContainsColumn(PersonalDDTable.PersonalId) Then
|
|
wc.iAND(PersonalDDTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, selectedRecordKeyValue.GetColumnValue(PersonalDDTable.PersonalId).ToString())
|
|
End If
|
|
|
|
End If
|
|
|
|
' Adds clauses if values are selected in Filter controls which are configured in the page.
|
|
|
|
|
|
Return wc
|
|
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.PersonalDDPagination.PageSize.Text.Trim <> "" Then
|
|
Try
|
|
'Me.PageSize = Integer.Parse(Me.PersonalDDPagination.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, "PersonalDDTableControlRepeater"), 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 PersonalDDTableControlRow = DirectCast(repItem.FindControl("PersonalDDTableControlRow"), PersonalDDTableControlRow)
|
|
|
|
If recControl.Visible AndAlso recControl.IsNewRecord() Then
|
|
|
|
Dim rec As PersonalDDRecord = New PersonalDDRecord()
|
|
|
|
If recControl.EndDate.Text <> "" Then
|
|
rec.Parse(recControl.EndDate.Text, PersonalDDTable.EndDate)
|
|
End If
|
|
If recControl.Mission.Text <> "" Then
|
|
rec.Parse(recControl.Mission.Text, PersonalDDTable.Mission)
|
|
End If
|
|
If recControl.Ref1.Text <> "" Then
|
|
rec.Parse(recControl.Ref1.Text, PersonalDDTable.Ref0)
|
|
End If
|
|
If recControl.RefDate.Text <> "" Then
|
|
rec.Parse(recControl.RefDate.Text, PersonalDDTable.RefDate)
|
|
End If
|
|
If recControl.StartDate.Text <> "" Then
|
|
rec.Parse(recControl.StartDate.Text, PersonalDDTable.StartDate)
|
|
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 PersonalDDRecord())
|
|
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(PersonalDDRecord)), PersonalDDRecord())
|
|
|
|
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 PersonalDDTableControlRow)
|
|
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 PersonalDDTableControlRow) 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 SetEndDateLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetMissionLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalDDTableControlCollapsibleRegion()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRefDateLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRefLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetStartDateLabel1()
|
|
|
|
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.
|
|
Dim added As Boolean = Me.AddNewRecord > 0
|
|
Me.LoadData()
|
|
Me.DataBind()
|
|
|
|
If added Then
|
|
Me.SetFocusToAddedRow()
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
Catch ex As Exception
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
End Sub
|
|
|
|
'this function sets focus to the first editable element in the new added row in the editable table
|
|
Protected Overridable Sub SetFocusToAddedRow()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalDDTableControlRepeater"), System.Web.UI.WebControls.Repeater)
|
|
If rep Is Nothing OrElse rep.Items.Count = 0 Then Return
|
|
Dim repItem As System.Web.UI.WebControls.RepeaterItem
|
|
For Each repItem In rep.Items
|
|
'Load scripts to table rows
|
|
Me.Page.LoadFocusScripts(repItem)
|
|
Dim recControl As PersonalDDTableControlRow = DirectCast(repItem.FindControl("PersonalDDTableControlRow"), PersonalDDTableControlRow)
|
|
If recControl.IsNewRecord Then
|
|
For Each field As Control In recControl.Controls
|
|
If field.Visible AndAlso Me.Page.IsControlEditable(field, False) Then
|
|
'set focus on the first editable field in the new row
|
|
field.Focus()
|
|
Dim updPan As UpdatePanel = DirectCast(Me.Page.FindControlRecursively("UpdatePanel1"), UpdatePanel)
|
|
If Not updPan Is Nothing Then updPan.Update()
|
|
Return
|
|
End If
|
|
Next
|
|
Return
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub SaveControlsToSession()
|
|
MyBase.SaveControlsToSession()
|
|
|
|
' Save filter controls to values to session.
|
|
|
|
|
|
'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.
|
|
|
|
HttpContext.Current.Session("AppRelativeVirtualPath") = Me.Page.AppRelativeVirtualPath
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub ClearControlsFromSession()
|
|
MyBase.ClearControlsFromSession()
|
|
|
|
' Clear filter controls values from the session.
|
|
|
|
|
|
' 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("PersonalDDTableControl_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("PersonalDDTableControl_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 PersonalDDPagination_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 PersonalDDPagination_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 PersonalDDPagination_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 PersonalDDPagination_PageSizeButton_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
Try
|
|
|
|
Me.DataChanged = True
|
|
|
|
Me.PageSize = Integer.Parse(Me.PersonalDDPagination.PageSize.Text)
|
|
|
|
Me.PageIndex = Integer.Parse(Me.PersonalDDPagination.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 PersonalDDPagination_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 EndDateLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by EndDate when clicked.
|
|
|
|
' Get previous sorting state for EndDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalDDTable.EndDate)
|
|
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 EndDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalDDTable.EndDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by EndDate, 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 MissionLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Mission when clicked.
|
|
|
|
' Get previous sorting state for Mission.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalDDTable.Mission)
|
|
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 Mission.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalDDTable.Mission, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Mission, 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 RefDateLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by RefDate when clicked.
|
|
|
|
' Get previous sorting state for RefDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalDDTable.RefDate)
|
|
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 RefDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalDDTable.RefDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by RefDate, 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 RefLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Ref when clicked.
|
|
|
|
' Get previous sorting state for Ref.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalDDTable.Ref0)
|
|
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 Ref.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalDDTable.Ref0, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Ref, 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 StartDateLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by StartDate when clicked.
|
|
|
|
' Get previous sorting state for StartDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalDDTable.StartDate)
|
|
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 StartDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalDDTable.StartDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by StartDate, 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 PersonalDDAddButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
Me.AddNewRecord = 1
|
|
Me.DataChanged = 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 PersonalDDDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Me.DeleteSelectedRecords(True)
|
|
Me.SetFormulaControls()
|
|
|
|
|
|
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 PersonalDDEditButton_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalDDResetButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
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(PersonalDDTable.StartDate, OrderByItem.OrderDir.Asc)
|
|
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
|
|
' 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 = PersonalDDTable.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 PersonalDDRecord = Nothing
|
|
Public Property DataSource() As PersonalDDRecord ()
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
Set(ByVal value() As PersonalDDRecord)
|
|
Me._DataSource = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Helper Properties"
|
|
|
|
Public ReadOnly Property EndDateLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "EndDateLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MissionLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "MissionLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalDDAddButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalDDAddButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalDDDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalDDDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalDDEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalDDEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalDDPagination() As Persons.UI.IPagination
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalDDPagination"), Persons.UI.IPagination)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalDDResetButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalDDResetButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalDDTableControlCollapsibleRegion() As System.Web.UI.WebControls.Panel
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalDDTableControlCollapsibleRegion"), System.Web.UI.WebControls.Panel)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalDDToggleAll() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalDDToggleAll"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RefDateLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RefDateLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RefLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RefLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property StartDateLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "StartDateLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
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 PersonalDDTableControlRow = 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 PersonalDDRecord = 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 GetSelectedRecordIndex() As Integer
|
|
Dim counter As Integer = 0
|
|
Dim recControl As PersonalDDTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalDDRecordRowSelection.Checked Then
|
|
Return counter
|
|
End If
|
|
counter += 1
|
|
Next
|
|
Return -1
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControl() As PersonalDDTableControlRow
|
|
Dim selectedList() As PersonalDDTableControlRow = Me.GetSelectedRecordControls()
|
|
If selectedList.Length = 0 Then
|
|
Return Nothing
|
|
End If
|
|
Return selectedList(0)
|
|
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControls() As PersonalDDTableControlRow()
|
|
|
|
Dim selectedList As ArrayList = New ArrayList(25)
|
|
Dim recControl As PersonalDDTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalDDRecordRowSelection IsNot Nothing AndAlso recControl.PersonalDDRecordRowSelection.Checked Then
|
|
selectedList.Add(recControl)
|
|
End If
|
|
Next
|
|
Return DirectCast(selectedList.ToArray(GetType(PersonalDDTableControlRow)), PersonalDDTableControlRow())
|
|
|
|
End Function
|
|
|
|
Public Overridable Sub DeleteSelectedRecords(ByVal deferDeletion As Boolean)
|
|
Dim recList() As PersonalDDTableControlRow = Me.GetSelectedRecordControls()
|
|
If recList.Length = 0 Then
|
|
' Localization.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoRecSelected", "Persons"))
|
|
End If
|
|
|
|
Dim recCtl As PersonalDDTableControlRow
|
|
For Each recCtl In recList
|
|
If deferDeletion Then
|
|
If Not recCtl.IsNewRecord Then
|
|
|
|
Me.AddToDeletedRecordIds(recCtl)
|
|
|
|
End If
|
|
recCtl.Visible = False
|
|
|
|
recCtl.PersonalDDRecordRowSelection.Checked = 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 PersonalDDTableControlRow()
|
|
Dim recList As ArrayList = New ArrayList()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalDDTableControlRepeater"), 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 PersonalDDTableControlRow = DirectCast(repItem.FindControl("PersonalDDTableControlRow"), PersonalDDTableControlRow)
|
|
recList.Add(recControl)
|
|
|
|
Next
|
|
|
|
Return DirectCast(recList.ToArray(GetType(PersonalDDTableControlRow)), PersonalDDTableControlRow())
|
|
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 PersonalEducationTableControlRow control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalEducationTableControlRow.
|
|
Public Class BasePersonalEducationTableControlRow
|
|
Inherits Persons.UI.BaseApplicationRecordControl
|
|
|
|
' To customize, override this method in PersonalEducationTableControlRow.
|
|
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 PersonalEducationTableControlRow.
|
|
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)
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalEducationRowDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteRecordConfirm", "Persons") & "'));")
|
|
|
|
|
|
' Register the event handlers.
|
|
|
|
AddHandler Me.PersonalEducationRowDeleteButton.Click, AddressOf PersonalEducationRowDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalEducationRowEditButton.Click, AddressOf PersonalEducationRowEditButton_Click
|
|
|
|
AddHandler Me.PersonalEducationRowViewButton.Click, AddressOf PersonalEducationRowViewButton_Click
|
|
|
|
AddHandler Me.COUNTRY.SelectedIndexChanged, AddressOf COUNTRY_SelectedIndexChanged
|
|
|
|
AddHandler Me.EducationPeriod.SelectedIndexChanged, AddressOf EducationPeriod_SelectedIndexChanged
|
|
|
|
AddHandler Me.LevelId.SelectedIndexChanged, AddressOf LevelId_SelectedIndexChanged
|
|
|
|
AddHandler Me.Command.TextChanged, AddressOf Command_TextChanged
|
|
|
|
AddHandler Me.CommandDate.TextChanged, AddressOf CommandDate_TextChanged
|
|
|
|
AddHandler Me.Course.TextChanged, AddressOf Course_TextChanged
|
|
|
|
AddHandler Me.CourseAbbr.TextChanged, AddressOf CourseAbbr_TextChanged
|
|
|
|
AddHandler Me.CourseNo.TextChanged, AddressOf CourseNo_TextChanged
|
|
|
|
AddHandler Me.EdYear.TextChanged, AddressOf EdYear_TextChanged
|
|
|
|
AddHandler Me.EndDate1.TextChanged, AddressOf EndDate1_TextChanged
|
|
|
|
AddHandler Me.Facultry.TextChanged, AddressOf Facultry_TextChanged
|
|
|
|
AddHandler Me.Institue.TextChanged, AddressOf Institue_TextChanged
|
|
|
|
AddHandler Me.NoAll.TextChanged, AddressOf NoAll_TextChanged
|
|
|
|
AddHandler Me.Score.TextChanged, AddressOf Score_TextChanged
|
|
|
|
AddHandler Me.ScoreNo.TextChanged, AddressOf ScoreNo_TextChanged
|
|
|
|
AddHandler Me.StartDate1.TextChanged, AddressOf StartDate1_TextChanged
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Load the data from the database into the DataSource PersonalEducation 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 = PersonalEducationTable.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 BasePersonalEducationTableControl when the data for the entire
|
|
' table is loaded.
|
|
|
|
Me.DataSource = New PersonalEducationRecord()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
' Populate the UI controls using the DataSource. To customize, override this method in PersonalEducationTableControlRow.
|
|
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
|
|
|
|
SetCommand()
|
|
SetCommandDate()
|
|
SetCOUNTRY()
|
|
SetCourse()
|
|
SetCourseAbbr()
|
|
SetCourseNo()
|
|
SetEducationPeriod()
|
|
SetEdYear()
|
|
SetEndDate1()
|
|
SetFacultry()
|
|
SetInstitue()
|
|
SetLevelId()
|
|
SetNoAll()
|
|
|
|
|
|
|
|
|
|
SetScore()
|
|
SetScoreNo()
|
|
SetStartDate1()
|
|
|
|
|
|
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 SetCommand()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Command.ID) Then
|
|
|
|
Me.Command.Text = Me.PreviousUIData(Me.Command.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Command TextBox on the webpage with value from the
|
|
' PersonalEducation database record.
|
|
|
|
' Me.DataSource is the PersonalEducation record retrieved from the database.
|
|
' Me.Command is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetCommand()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.CommandSpecified Then
|
|
|
|
' If the Command is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalEducationTable.Command)
|
|
|
|
Me.Command.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Command is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Command.Text = PersonalEducationTable.Command.Format(PersonalEducationTable.Command.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCommandDate()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.CommandDate.ID) Then
|
|
|
|
Me.CommandDate.Text = Me.PreviousUIData(Me.CommandDate.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the CommandDate TextBox on the webpage with value from the
|
|
' PersonalEducation database record.
|
|
|
|
' Me.DataSource is the PersonalEducation record retrieved from the database.
|
|
' Me.CommandDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetCommandDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.CommandDateSpecified Then
|
|
|
|
' If the CommandDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalEducationTable.CommandDate, "d MMM yy")
|
|
|
|
Me.CommandDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' CommandDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.CommandDate.Text = PersonalEducationTable.CommandDate.Format(PersonalEducationTable.CommandDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCOUNTRY()
|
|
|
|
' If selection was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.COUNTRY.ID) Then
|
|
If Me.PreviousUIData(Me.COUNTRY.ID) Is Nothing
|
|
Me.PopulateCOUNTRYDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateCOUNTRYDropDownList(Me.PreviousUIData(Me.COUNTRY.ID).ToString(), 100)
|
|
End If
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the COUNTRY DropDownList on the webpage with value from the
|
|
' PersonalEducation database record.
|
|
|
|
' Me.DataSource is the PersonalEducation record retrieved from the database.
|
|
' Me.COUNTRY is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetCOUNTRY()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.COUNTRYSpecified Then
|
|
|
|
' If the COUNTRY is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateCOUNTRYDropDownList(Me.DataSource.COUNTRY.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' COUNTRY is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateCOUNTRYDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateCOUNTRYDropDownList(PersonalEducationTable.COUNTRY.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCourse()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Course.ID) Then
|
|
|
|
Me.Course.Text = Me.PreviousUIData(Me.Course.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Course TextBox on the webpage with value from the
|
|
' PersonalEducation database record.
|
|
|
|
' Me.DataSource is the PersonalEducation record retrieved from the database.
|
|
' Me.Course is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetCourse()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.CourseSpecified Then
|
|
|
|
' If the Course is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalEducationTable.Course)
|
|
|
|
Me.Course.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Course is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Course.Text = PersonalEducationTable.Course.Format(PersonalEducationTable.Course.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCourseAbbr()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.CourseAbbr.ID) Then
|
|
|
|
Me.CourseAbbr.Text = Me.PreviousUIData(Me.CourseAbbr.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the CourseAbbr TextBox on the webpage with value from the
|
|
' PersonalEducation database record.
|
|
|
|
' Me.DataSource is the PersonalEducation record retrieved from the database.
|
|
' Me.CourseAbbr is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetCourseAbbr()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.CourseAbbrSpecified Then
|
|
|
|
' If the CourseAbbr is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalEducationTable.CourseAbbr)
|
|
|
|
Me.CourseAbbr.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' CourseAbbr is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.CourseAbbr.Text = PersonalEducationTable.CourseAbbr.Format(PersonalEducationTable.CourseAbbr.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCourseNo()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.CourseNo.ID) Then
|
|
|
|
Me.CourseNo.Text = Me.PreviousUIData(Me.CourseNo.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the CourseNo TextBox on the webpage with value from the
|
|
' PersonalEducation database record.
|
|
|
|
' Me.DataSource is the PersonalEducation record retrieved from the database.
|
|
' Me.CourseNo is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetCourseNo()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.CourseNoSpecified Then
|
|
|
|
' If the CourseNo is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalEducationTable.CourseNo)
|
|
|
|
Me.CourseNo.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' CourseNo is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.CourseNo.Text = PersonalEducationTable.CourseNo.Format(PersonalEducationTable.CourseNo.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetEducationPeriod()
|
|
|
|
' If selection was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.EducationPeriod.ID) Then
|
|
If Me.PreviousUIData(Me.EducationPeriod.ID) Is Nothing
|
|
Me.PopulateEducationPeriodDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateEducationPeriodDropDownList(Me.PreviousUIData(Me.EducationPeriod.ID).ToString(), 100)
|
|
End If
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the EducationPeriod DropDownList on the webpage with value from the
|
|
' PersonalEducation database record.
|
|
|
|
' Me.DataSource is the PersonalEducation record retrieved from the database.
|
|
' Me.EducationPeriod is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetEducationPeriod()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.EducationPeriodSpecified Then
|
|
|
|
' If the EducationPeriod is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateEducationPeriodDropDownList(Me.DataSource.EducationPeriod.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' EducationPeriod is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateEducationPeriodDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateEducationPeriodDropDownList(PersonalEducationTable.EducationPeriod.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetEdYear()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.EdYear.ID) Then
|
|
|
|
Me.EdYear.Text = Me.PreviousUIData(Me.EdYear.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the EdYear TextBox on the webpage with value from the
|
|
' PersonalEducation database record.
|
|
|
|
' Me.DataSource is the PersonalEducation record retrieved from the database.
|
|
' Me.EdYear is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetEdYear()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.EdYearSpecified Then
|
|
|
|
' If the EdYear is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalEducationTable.EdYear)
|
|
|
|
Me.EdYear.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' EdYear is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.EdYear.Text = PersonalEducationTable.EdYear.Format(PersonalEducationTable.EdYear.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetEndDate1()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.EndDate1.ID) Then
|
|
|
|
Me.EndDate1.Text = Me.PreviousUIData(Me.EndDate1.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the EndDate TextBox on the webpage with value from the
|
|
' PersonalEducation database record.
|
|
|
|
' Me.DataSource is the PersonalEducation record retrieved from the database.
|
|
' Me.EndDate1 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetEndDate1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.EndDateSpecified Then
|
|
|
|
' If the EndDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalEducationTable.EndDate, "d MMM yy")
|
|
|
|
Me.EndDate1.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' EndDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.EndDate1.Text = PersonalEducationTable.EndDate.Format(PersonalEducationTable.EndDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetFacultry()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Facultry.ID) Then
|
|
|
|
Me.Facultry.Text = Me.PreviousUIData(Me.Facultry.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Facultry TextBox on the webpage with value from the
|
|
' PersonalEducation database record.
|
|
|
|
' Me.DataSource is the PersonalEducation record retrieved from the database.
|
|
' Me.Facultry is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetFacultry()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.FacultrySpecified Then
|
|
|
|
' If the Facultry is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalEducationTable.Facultry)
|
|
|
|
Me.Facultry.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Facultry is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Facultry.Text = PersonalEducationTable.Facultry.Format(PersonalEducationTable.Facultry.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetInstitue()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Institue.ID) Then
|
|
|
|
Me.Institue.Text = Me.PreviousUIData(Me.Institue.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Institue TextBox on the webpage with value from the
|
|
' PersonalEducation database record.
|
|
|
|
' Me.DataSource is the PersonalEducation record retrieved from the database.
|
|
' Me.Institue is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetInstitue()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.InstitueSpecified Then
|
|
|
|
' If the Institue is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalEducationTable.Institue)
|
|
|
|
Me.Institue.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Institue is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Institue.Text = PersonalEducationTable.Institue.Format(PersonalEducationTable.Institue.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetLevelId()
|
|
|
|
' If selection was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.LevelId.ID) Then
|
|
If Me.PreviousUIData(Me.LevelId.ID) Is Nothing
|
|
Me.PopulateLevelIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateLevelIdDropDownList(Me.PreviousUIData(Me.LevelId.ID).ToString(), 100)
|
|
End If
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the LevelId DropDownList on the webpage with value from the
|
|
' PersonalEducation database record.
|
|
|
|
' Me.DataSource is the PersonalEducation record retrieved from the database.
|
|
' Me.LevelId is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetLevelId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.LevelIdSpecified Then
|
|
|
|
' If the LevelId is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateLevelIdDropDownList(Me.DataSource.LevelId.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' LevelId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateLevelIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateLevelIdDropDownList(PersonalEducationTable.LevelId.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetNoAll()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.NoAll.ID) Then
|
|
|
|
Me.NoAll.Text = Me.PreviousUIData(Me.NoAll.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the NoAll TextBox on the webpage with value from the
|
|
' PersonalEducation database record.
|
|
|
|
' Me.DataSource is the PersonalEducation record retrieved from the database.
|
|
' Me.NoAll is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetNoAll()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.NoAllSpecified Then
|
|
|
|
' If the NoAll is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalEducationTable.NoAll)
|
|
|
|
Me.NoAll.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' NoAll is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.NoAll.Text = PersonalEducationTable.NoAll.Format(PersonalEducationTable.NoAll.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetScore()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Score.ID) Then
|
|
|
|
Me.Score.Text = Me.PreviousUIData(Me.Score.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Score TextBox on the webpage with value from the
|
|
' PersonalEducation database record.
|
|
|
|
' Me.DataSource is the PersonalEducation record retrieved from the database.
|
|
' Me.Score is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetScore()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.ScoreSpecified Then
|
|
|
|
' If the Score is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalEducationTable.Score)
|
|
|
|
Me.Score.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Score is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Score.Text = PersonalEducationTable.Score.Format(PersonalEducationTable.Score.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetScoreNo()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.ScoreNo.ID) Then
|
|
|
|
Me.ScoreNo.Text = Me.PreviousUIData(Me.ScoreNo.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the ScoreNo TextBox on the webpage with value from the
|
|
' PersonalEducation database record.
|
|
|
|
' Me.DataSource is the PersonalEducation record retrieved from the database.
|
|
' Me.ScoreNo is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetScoreNo()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.ScoreNoSpecified Then
|
|
|
|
' If the ScoreNo is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalEducationTable.ScoreNo)
|
|
|
|
Me.ScoreNo.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' ScoreNo is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.ScoreNo.Text = PersonalEducationTable.ScoreNo.Format(PersonalEducationTable.ScoreNo.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetStartDate1()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.StartDate1.ID) Then
|
|
|
|
Me.StartDate1.Text = Me.PreviousUIData(Me.StartDate1.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the StartDate TextBox on the webpage with value from the
|
|
' PersonalEducation database record.
|
|
|
|
' Me.DataSource is the PersonalEducation record retrieved from the database.
|
|
' Me.StartDate1 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetStartDate1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.StartDateSpecified Then
|
|
|
|
' If the StartDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalEducationTable.StartDate, "d MMM yy")
|
|
|
|
Me.StartDate1.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' StartDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.StartDate1.Text = PersonalEducationTable.StartDate.Format(PersonalEducationTable.StartDate.DefaultValue, "d MMM yy")
|
|
|
|
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 PersonalEducationTableControlRow.
|
|
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()
|
|
|
|
Dim parentCtrl As PersonalIdRecordControl
|
|
|
|
|
|
parentCtrl = DirectCast(Me.Page.FindControlRecursively("PersonalIdRecordControl"), PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(parentCtrl) AndAlso IsNothing(parentCtrl.DataSource))
|
|
' Load the record if it is not loaded yet.
|
|
parentCtrl.LoadData()
|
|
End If
|
|
If (IsNothing(parentCtrl) OrElse IsNothing(parentCtrl.DataSource))
|
|
' Get the error message from the application resource file.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoParentRecId", "Persons"))
|
|
End If
|
|
|
|
Me.DataSource.PersonalId = parentCtrl.DataSource.PersonalId
|
|
|
|
' 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, "PersonalEducationTableControl"), PersonalEducationTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalEducationTableControl"), PersonalEducationTableControl).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 PersonalEducationTableControlRow.
|
|
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.
|
|
|
|
GetCommand()
|
|
GetCommandDate()
|
|
GetCOUNTRY()
|
|
GetCourse()
|
|
GetCourseAbbr()
|
|
GetCourseNo()
|
|
GetEducationPeriod()
|
|
GetEdYear()
|
|
GetEndDate1()
|
|
GetFacultry()
|
|
GetInstitue()
|
|
GetLevelId()
|
|
GetNoAll()
|
|
GetScore()
|
|
GetScoreNo()
|
|
GetStartDate1()
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub GetCommand()
|
|
|
|
' Retrieve the value entered by the user on the Command ASP:TextBox, and
|
|
' save it into the Command field in DataSource PersonalEducation record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Command.Text, PersonalEducationTable.Command)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetCommandDate()
|
|
|
|
' Retrieve the value entered by the user on the CommandDate ASP:TextBox, and
|
|
' save it into the CommandDate field in DataSource PersonalEducation record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.CommandDate.Text, PersonalEducationTable.CommandDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetCOUNTRY()
|
|
|
|
' Retrieve the value entered by the user on the COUNTRY ASP:DropDownList, and
|
|
' save it into the COUNTRY field in DataSource PersonalEducation record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.COUNTRY), PersonalEducationTable.COUNTRY)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetCourse()
|
|
|
|
' Retrieve the value entered by the user on the Course ASP:TextBox, and
|
|
' save it into the Course field in DataSource PersonalEducation record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Course.Text, PersonalEducationTable.Course)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetCourseAbbr()
|
|
|
|
' Retrieve the value entered by the user on the CourseAbbr ASP:TextBox, and
|
|
' save it into the CourseAbbr field in DataSource PersonalEducation record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.CourseAbbr.Text, PersonalEducationTable.CourseAbbr)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetCourseNo()
|
|
|
|
' Retrieve the value entered by the user on the CourseNo ASP:TextBox, and
|
|
' save it into the CourseNo field in DataSource PersonalEducation record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.CourseNo.Text, PersonalEducationTable.CourseNo)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetEducationPeriod()
|
|
|
|
' Retrieve the value entered by the user on the EducationPeriod ASP:DropDownList, and
|
|
' save it into the EducationPeriod field in DataSource PersonalEducation record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.EducationPeriod), PersonalEducationTable.EducationPeriod)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetEdYear()
|
|
|
|
' Retrieve the value entered by the user on the EdYear ASP:TextBox, and
|
|
' save it into the EdYear field in DataSource PersonalEducation record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.EdYear.Text, PersonalEducationTable.EdYear)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetEndDate1()
|
|
|
|
' Retrieve the value entered by the user on the EndDate ASP:TextBox, and
|
|
' save it into the EndDate field in DataSource PersonalEducation record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.EndDate1.Text, PersonalEducationTable.EndDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetFacultry()
|
|
|
|
' Retrieve the value entered by the user on the Facultry ASP:TextBox, and
|
|
' save it into the Facultry field in DataSource PersonalEducation record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Facultry.Text, PersonalEducationTable.Facultry)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetInstitue()
|
|
|
|
' Retrieve the value entered by the user on the Institue ASP:TextBox, and
|
|
' save it into the Institue field in DataSource PersonalEducation record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Institue.Text, PersonalEducationTable.Institue)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetLevelId()
|
|
|
|
' Retrieve the value entered by the user on the LevelId ASP:DropDownList, and
|
|
' save it into the LevelId field in DataSource PersonalEducation record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.LevelId), PersonalEducationTable.LevelId)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetNoAll()
|
|
|
|
' Retrieve the value entered by the user on the NoAll ASP:TextBox, and
|
|
' save it into the NoAll field in DataSource PersonalEducation record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.NoAll.Text, PersonalEducationTable.NoAll)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetScore()
|
|
|
|
' Retrieve the value entered by the user on the Score ASP:TextBox, and
|
|
' save it into the Score field in DataSource PersonalEducation record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Score.Text, PersonalEducationTable.Score)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetScoreNo()
|
|
|
|
' Retrieve the value entered by the user on the ScoreNo ASP:TextBox, and
|
|
' save it into the ScoreNo field in DataSource PersonalEducation record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.ScoreNo.Text, PersonalEducationTable.ScoreNo)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetStartDate1()
|
|
|
|
' Retrieve the value entered by the user on the StartDate ASP:TextBox, and
|
|
' save it into the StartDate field in DataSource PersonalEducation record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.StartDate1.Text, PersonalEducationTable.StartDate)
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
' To customize, override this method in PersonalEducationTableControlRow.
|
|
|
|
Public Overridable Function CreateWhereClause() As WhereClause
|
|
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
|
|
|
|
' To customize, override this method in PersonalEducationTableControlRow.
|
|
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)
|
|
PersonalEducationTable.DeleteRecord(pkValue)
|
|
|
|
DirectCast(GetParentControlObject(Me, "PersonalEducationTableControl"), PersonalEducationTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalEducationTableControl"), PersonalEducationTableControl).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
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_COUNTRYDropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the Country table.
|
|
' Examples:
|
|
' wc.iAND(CountryTable.Country, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(CountryTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_EducationPeriodDropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the EducationPeriod table.
|
|
' Examples:
|
|
' wc.iAND(EducationPeriodTable.Period, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(EducationPeriodTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_LevelIdDropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the Education table.
|
|
' Examples:
|
|
' wc.iAND(EducationTable.Level, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(EducationTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
' Fill the COUNTRY list.
|
|
Protected Overridable Sub PopulateCOUNTRYDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.COUNTRY.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.COUNTRY.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_COUNTRYDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_COUNTRYDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(CountryTable.Country, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim itemValues() As CountryRecord = Nothing
|
|
Dim evaluator As New FormulaEvaluator
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
Do
|
|
itemValues = CountryTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
For each itemValue As CountryRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.CountryIdSpecified Then
|
|
cvalue = itemValue.CountryId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.COUNTRY.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalEducationTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalEducationTable.COUNTRY)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalEducationTable.COUNTRY.IsApplyDisplayAs Then
|
|
fvalue = PersonalEducationTable.GetDFKA(itemValue, PersonalEducationTable.COUNTRY)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(CountryTable.Country)
|
|
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.COUNTRY.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.COUNTRY.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
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.COUNTRY, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.COUNTRY, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with Country.CountryId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(CountryTable.CountryId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As CountryRecord = CountryTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As CountryRecord = DirectCast(rc(0), CountryRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.CountryIdSpecified Then
|
|
cvalue = itemValue.CountryId.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalEducationTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalEducationTable.COUNTRY)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalEducationTable.COUNTRY.IsApplyDisplayAs Then
|
|
fvalue = PersonalEducationTable.GetDFKA(itemValue, PersonalEducationTable.COUNTRY)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(CountryTable.Country)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.COUNTRY.Items.Add(newItem)
|
|
SetSelectedValue(Me.COUNTRY, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' Fill the EducationPeriod list.
|
|
Protected Overridable Sub PopulateEducationPeriodDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.EducationPeriod.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
Me.EducationPeriod.Items.Add(New ListItem(Me.Page.ExpandResourceValue("{Txt:PleaseSelect}"), "--PLEASE_SELECT--"))
|
|
|
|
Me.EducationPeriod.Items.Add(New ListItem(Me.Page.ExpandResourceValue("1,ก่อน"), "1,ก่อน"))
|
|
|
|
Me.EducationPeriod.Items.Add(New ListItem(Me.Page.ExpandResourceValue("2,หลัง"), "2,หลัง"))
|
|
|
|
' Skip step 2 and 3 because no need to load data from database and insert data
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.EducationPeriod, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.EducationPeriod, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with EducationPeriod.PeriodId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(EducationPeriodTable.PeriodId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As EducationPeriodRecord = EducationPeriodTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As EducationPeriodRecord = DirectCast(rc(0), EducationPeriodRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.PeriodIdSpecified Then
|
|
cvalue = itemValue.PeriodId.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalEducationTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalEducationTable.EducationPeriod)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalEducationTable.EducationPeriod.IsApplyDisplayAs Then
|
|
fvalue = PersonalEducationTable.GetDFKA(itemValue, PersonalEducationTable.EducationPeriod)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(EducationPeriodTable.Period)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.EducationPeriod.Items.Add(newItem)
|
|
SetSelectedValue(Me.EducationPeriod, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' Fill the LevelId list.
|
|
Protected Overridable Sub PopulateLevelIdDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.LevelId.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.LevelId.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_LevelIdDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_LevelIdDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(EducationTable.Level, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim itemValues() As EducationRecord = Nothing
|
|
Dim evaluator As New FormulaEvaluator
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
Do
|
|
itemValues = EducationTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
For each itemValue As EducationRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.EducationIdSpecified Then
|
|
cvalue = itemValue.EducationId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.LevelId.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalEducationTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalEducationTable.LevelId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalEducationTable.LevelId.IsApplyDisplayAs Then
|
|
fvalue = PersonalEducationTable.GetDFKA(itemValue, PersonalEducationTable.LevelId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(EducationTable.Level)
|
|
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.LevelId.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.LevelId.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
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.LevelId, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.LevelId, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with Education.EducationId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(EducationTable.EducationId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As EducationRecord = EducationTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As EducationRecord = DirectCast(rc(0), EducationRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.EducationIdSpecified Then
|
|
cvalue = itemValue.EducationId.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalEducationTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalEducationTable.LevelId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalEducationTable.LevelId.IsApplyDisplayAs Then
|
|
fvalue = PersonalEducationTable.GetDFKA(itemValue, PersonalEducationTable.LevelId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(EducationTable.Level)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.LevelId.Items.Add(newItem)
|
|
SetSelectedValue(Me.LevelId, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonalEducationRowDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Dim tc As PersonalEducationTableControl = DirectCast(GetParentControlObject(Me, "PersonalEducationTableControl"), PersonalEducationTableControl)
|
|
If Not (IsNothing(tc)) Then
|
|
If Not Me.IsNewRecord Then
|
|
tc.AddToDeletedRecordIds(DirectCast(Me, PersonalEducationTableControlRow))
|
|
End If
|
|
Me.Visible = False
|
|
tc.SetFormulaControls()
|
|
End If
|
|
|
|
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 PersonalEducationRowEditButton_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 = "../PersonalEducation/EditPersonalEducation.aspx?PersonalEducation={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 PersonalEducationRowViewButton_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 = "../PersonalEducation/ShowPersonalEducation.aspx?PersonalEducation={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
|
|
|
|
Protected Overridable Sub COUNTRY_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(COUNTRY.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(COUNTRY.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.COUNTRY.Items.Add(New ListItem(displayText, val))
|
|
Me.COUNTRY.SelectedIndex = Me.COUNTRY.Items.Count - 1
|
|
Me.Page.Session.Remove(COUNTRY.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(COUNTRY.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub EducationPeriod_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(EducationPeriod.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(EducationPeriod.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.EducationPeriod.Items.Add(New ListItem(displayText, val))
|
|
Me.EducationPeriod.SelectedIndex = Me.EducationPeriod.Items.Count - 1
|
|
Me.Page.Session.Remove(EducationPeriod.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(EducationPeriod.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub LevelId_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(LevelId.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(LevelId.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.LevelId.Items.Add(New ListItem(displayText, val))
|
|
Me.LevelId.SelectedIndex = Me.LevelId.Items.Count - 1
|
|
Me.Page.Session.Remove(LevelId.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(LevelId.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Command_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub CommandDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Course_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub CourseAbbr_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub CourseNo_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub EdYear_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub EndDate1_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Facultry_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Institue_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub NoAll_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Score_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub ScoreNo_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub StartDate1_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
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("BasePersonalEducationTableControlRow_Rec"), String)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me.ViewState("BasePersonalEducationTableControlRow_Rec") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataSource As PersonalEducationRecord
|
|
Public Property DataSource() As PersonalEducationRecord
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
|
|
Set(ByVal value As PersonalEducationRecord)
|
|
|
|
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 Command() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Command"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CommandDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CommandDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property COUNTRY() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "COUNTRY"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Course() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Course"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CourseAbbr() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CourseAbbr"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CourseNo() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CourseNo"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property EducationPeriod() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "EducationPeriod"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property EdYear() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "EdYear"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property EndDate1() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "EndDate1"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Facultry() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Facultry"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Institue() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Institue"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property LevelId() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "LevelId"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property NoAll() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "NoAll"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalEducationRecordRowSelection() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalEducationRecordRowSelection"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalEducationRowDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalEducationRowDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalEducationRowEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalEducationRowEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalEducationRowViewButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalEducationRowViewButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Score() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Score"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ScoreNo() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ScoreNo"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property StartDate1() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "StartDate1"), System.Web.UI.WebControls.TextBox)
|
|
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 PersonalEducationRecord = 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 PersonalEducationRecord
|
|
If Not Me.DataSource Is Nothing Then
|
|
Return Me.DataSource
|
|
End If
|
|
|
|
If Not Me.RecordUniqueId Is Nothing Then
|
|
|
|
Return PersonalEducationTable.GetRecord(Me.RecordUniqueId, True)
|
|
|
|
End If
|
|
|
|
' Localization.
|
|
|
|
Return Nothing
|
|
|
|
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 PersonalEducationTableControl control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalEducationTableControl.
|
|
Public Class BasePersonalEducationTableControl
|
|
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.
|
|
|
|
|
|
|
|
' 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(PersonalEducationTable.EducationPeriod, OrderByItem.OrderDir.Asc)
|
|
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.StartDate, 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()
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalEducationDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteConfirm", "Persons") & "'));")
|
|
|
|
' Setup the pagination events.
|
|
|
|
AddHandler Me.PersonalEducationPagination.FirstPage.Click, AddressOf PersonalEducationPagination_FirstPage_Click
|
|
|
|
AddHandler Me.PersonalEducationPagination.LastPage.Click, AddressOf PersonalEducationPagination_LastPage_Click
|
|
|
|
AddHandler Me.PersonalEducationPagination.NextPage.Click, AddressOf PersonalEducationPagination_NextPage_Click
|
|
|
|
AddHandler Me.PersonalEducationPagination.PageSizeButton.Click, AddressOf PersonalEducationPagination_PageSizeButton_Click
|
|
|
|
AddHandler Me.PersonalEducationPagination.PreviousPage.Click, AddressOf PersonalEducationPagination_PreviousPage_Click
|
|
|
|
|
|
' Setup the sorting events.
|
|
|
|
AddHandler Me.CommandDateLabel.Click, AddressOf CommandDateLabel_Click
|
|
|
|
AddHandler Me.CommandLabel.Click, AddressOf CommandLabel_Click
|
|
|
|
AddHandler Me.COUNTRYLabel1.Click, AddressOf COUNTRYLabel1_Click
|
|
|
|
AddHandler Me.CourseAbbrLabel.Click, AddressOf CourseAbbrLabel_Click
|
|
|
|
AddHandler Me.CourseLabel.Click, AddressOf CourseLabel_Click
|
|
|
|
AddHandler Me.CourseNoLabel.Click, AddressOf CourseNoLabel_Click
|
|
|
|
AddHandler Me.EducationPeriodLabel.Click, AddressOf EducationPeriodLabel_Click
|
|
|
|
AddHandler Me.EdYearLabel.Click, AddressOf EdYearLabel_Click
|
|
|
|
AddHandler Me.EndDateLabel2.Click, AddressOf EndDateLabel2_Click
|
|
|
|
AddHandler Me.FacultryLabel.Click, AddressOf FacultryLabel_Click
|
|
|
|
AddHandler Me.InstitueLabel.Click, AddressOf InstitueLabel_Click
|
|
|
|
AddHandler Me.LevelIdLabel1.Click, AddressOf LevelIdLabel1_Click
|
|
|
|
AddHandler Me.NoAllLabel.Click, AddressOf NoAllLabel_Click
|
|
|
|
AddHandler Me.ScoreLabel.Click, AddressOf ScoreLabel_Click
|
|
|
|
AddHandler Me.ScoreNoLabel.Click, AddressOf ScoreNoLabel_Click
|
|
|
|
AddHandler Me.StartDateLabel2.Click, AddressOf StartDateLabel2_Click
|
|
|
|
' Setup the button events.
|
|
|
|
AddHandler Me.PersonalEducationAddButton.Click, AddressOf PersonalEducationAddButton_Click
|
|
|
|
AddHandler Me.PersonalEducationDeleteButton.Click, AddressOf PersonalEducationDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalEducationEditButton.Click, AddressOf PersonalEducationEditButton_Click
|
|
|
|
AddHandler Me.PersonalEducationResetButton.Click, AddressOf PersonalEducationResetButton_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(PersonalEducationRecord)), PersonalEducationRecord())
|
|
' 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, PersonalEducationTable.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 PersonalEducationTableControlRow 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(PersonalEducationRecord)), PersonalEducationRecord())
|
|
Else ' Get the records from the database
|
|
Me.DataSource = PersonalEducationTable.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()
|
|
|
|
' Turn off the ToggleAll checkbox
|
|
Me.PersonalEducationToggleAll.Checked = False
|
|
|
|
|
|
' Initialize the page and grand totals. now
|
|
|
|
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
|
|
|
|
' Improve performance by prefetching display as records.
|
|
Me.PreFetchForeignKeyValues()
|
|
|
|
' 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, "PersonalEducationTableControlRepeater"), 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 PersonalEducationTableControlRow = DirectCast(repItem.FindControl("PersonalEducationTableControlRow"), PersonalEducationTableControlRow)
|
|
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
|
|
|
|
SetCommandDateLabel()
|
|
SetCommandLabel()
|
|
SetCOUNTRYLabel1()
|
|
SetCourseAbbrLabel()
|
|
SetCourseLabel()
|
|
SetCourseNoLabel()
|
|
SetEducationPeriodLabel()
|
|
SetEdYearLabel()
|
|
SetEndDateLabel2()
|
|
SetFacultryLabel()
|
|
SetInstitueLabel()
|
|
SetLevelIdLabel1()
|
|
SetNoAllLabel()
|
|
|
|
|
|
|
|
|
|
|
|
SetPersonalEducationTableControlCollapsibleRegion()
|
|
|
|
SetScoreLabel()
|
|
SetScoreNoLabel()
|
|
SetStartDateLabel2()
|
|
' 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 Sub PreFetchForeignKeyValues()
|
|
If (IsNothing(Me.DataSource))
|
|
Return
|
|
End If
|
|
|
|
Me.Page.PregetDfkaRecords(PersonalEducationTable.COUNTRY, Me.DataSource)
|
|
|
|
Me.Page.PregetDfkaRecords(PersonalEducationTable.EducationPeriod, Me.DataSource)
|
|
|
|
Me.Page.PregetDfkaRecords(PersonalEducationTable.LevelId, Me.DataSource)
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub RegisterPostback()
|
|
|
|
|
|
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.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(PersonalEducationTable.EducationPeriod, OrderByItem.OrderDir.Asc)
|
|
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.StartDate, 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.PersonalEducationPagination.CurrentPage.Text = (Me.PageIndex + 1).ToString()
|
|
Else
|
|
Me.PersonalEducationPagination.CurrentPage.Text = "0"
|
|
End If
|
|
Me.PersonalEducationPagination.PageSize.Text = Me.PageSize.ToString()
|
|
Me.PersonalEducationPagination.TotalItems.Text = Me.TotalRecords.ToString()
|
|
Me.PersonalEducationPagination.TotalPages.Text = Me.TotalPages.ToString()
|
|
|
|
' Bind the buttons for PersonalEducationTableControl pagination.
|
|
|
|
Me.PersonalEducationPagination.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.PersonalEducationPagination.LastPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalEducationPagination.LastPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalEducationPagination.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.PersonalEducationPagination.NextPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalEducationPagination.NextPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalEducationPagination.NextPage.Enabled = Not (Me.PageIndex = Me.TotalPages - 1)
|
|
End If
|
|
|
|
Me.PersonalEducationPagination.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 PersonalEducationTableControlRow
|
|
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.
|
|
PersonalEducationTable.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 selectedRecordKeyValue as KeyValue = New KeyValue()
|
|
|
|
Dim personalIdRecordControlObj As Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalIdRecordControl"), Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(personalIdRecordControlObj) AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord()) AndAlso personalIdRecordControlObj.GetRecord().IsCreated AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord().PersonalId))
|
|
wc.iAND(PersonalEducationTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
selectedRecordKeyValue.AddElement(PersonalEducationTable.PersonalId.InternalName, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
Else
|
|
wc.RunQuery = False
|
|
Return wc
|
|
End If
|
|
|
|
HttpContext.Current.Session("PersonalEducationTableControlWhereClause") = selectedRecordKeyValue.ToXmlString()
|
|
|
|
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.
|
|
PersonalEducationTable.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)
|
|
|
|
Dim selectedRecordInPersonalIdRecordControl as String = DirectCast(HttpContext.Current.Session("PersonalEducationTableControlWhereClause"), String)
|
|
|
|
If Not selectedRecordInPersonalIdRecordControl Is Nothing AndAlso KeyValue.IsXmlKey(selectedRecordInPersonalIdRecordControl) Then
|
|
Dim selectedRecordKeyValue as KeyValue = KeyValue.XmlToKey(selectedRecordInPersonalIdRecordControl)
|
|
|
|
If Not IsNothing(selectedRecordKeyValue) AndAlso selectedRecordKeyValue.ContainsColumn(PersonalEducationTable.PersonalId) Then
|
|
wc.iAND(PersonalEducationTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, selectedRecordKeyValue.GetColumnValue(PersonalEducationTable.PersonalId).ToString())
|
|
End If
|
|
|
|
End If
|
|
|
|
' Adds clauses if values are selected in Filter controls which are configured in the page.
|
|
|
|
|
|
Return wc
|
|
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.PersonalEducationPagination.PageSize.Text.Trim <> "" Then
|
|
Try
|
|
'Me.PageSize = Integer.Parse(Me.PersonalEducationPagination.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, "PersonalEducationTableControlRepeater"), 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 PersonalEducationTableControlRow = DirectCast(repItem.FindControl("PersonalEducationTableControlRow"), PersonalEducationTableControlRow)
|
|
|
|
If recControl.Visible AndAlso recControl.IsNewRecord() Then
|
|
|
|
Dim rec As PersonalEducationRecord = New PersonalEducationRecord()
|
|
|
|
If recControl.Command.Text <> "" Then
|
|
rec.Parse(recControl.Command.Text, PersonalEducationTable.Command)
|
|
End If
|
|
If recControl.CommandDate.Text <> "" Then
|
|
rec.Parse(recControl.CommandDate.Text, PersonalEducationTable.CommandDate)
|
|
End If
|
|
If MiscUtils.IsValueSelected(recControl.COUNTRY) Then
|
|
rec.Parse(recControl.COUNTRY.SelectedItem.Value, PersonalEducationTable.COUNTRY)
|
|
End If
|
|
If recControl.Course.Text <> "" Then
|
|
rec.Parse(recControl.Course.Text, PersonalEducationTable.Course)
|
|
End If
|
|
If recControl.CourseAbbr.Text <> "" Then
|
|
rec.Parse(recControl.CourseAbbr.Text, PersonalEducationTable.CourseAbbr)
|
|
End If
|
|
If recControl.CourseNo.Text <> "" Then
|
|
rec.Parse(recControl.CourseNo.Text, PersonalEducationTable.CourseNo)
|
|
End If
|
|
If MiscUtils.IsValueSelected(recControl.EducationPeriod) Then
|
|
rec.Parse(recControl.EducationPeriod.SelectedItem.Value, PersonalEducationTable.EducationPeriod)
|
|
End If
|
|
If recControl.EdYear.Text <> "" Then
|
|
rec.Parse(recControl.EdYear.Text, PersonalEducationTable.EdYear)
|
|
End If
|
|
If recControl.EndDate1.Text <> "" Then
|
|
rec.Parse(recControl.EndDate1.Text, PersonalEducationTable.EndDate)
|
|
End If
|
|
If recControl.Facultry.Text <> "" Then
|
|
rec.Parse(recControl.Facultry.Text, PersonalEducationTable.Facultry)
|
|
End If
|
|
If recControl.Institue.Text <> "" Then
|
|
rec.Parse(recControl.Institue.Text, PersonalEducationTable.Institue)
|
|
End If
|
|
If MiscUtils.IsValueSelected(recControl.LevelId) Then
|
|
rec.Parse(recControl.LevelId.SelectedItem.Value, PersonalEducationTable.LevelId)
|
|
End If
|
|
If recControl.NoAll.Text <> "" Then
|
|
rec.Parse(recControl.NoAll.Text, PersonalEducationTable.NoAll)
|
|
End If
|
|
If recControl.Score.Text <> "" Then
|
|
rec.Parse(recControl.Score.Text, PersonalEducationTable.Score)
|
|
End If
|
|
If recControl.ScoreNo.Text <> "" Then
|
|
rec.Parse(recControl.ScoreNo.Text, PersonalEducationTable.ScoreNo)
|
|
End If
|
|
If recControl.StartDate1.Text <> "" Then
|
|
rec.Parse(recControl.StartDate1.Text, PersonalEducationTable.StartDate)
|
|
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 PersonalEducationRecord())
|
|
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(PersonalEducationRecord)), PersonalEducationRecord())
|
|
|
|
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 PersonalEducationTableControlRow)
|
|
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 PersonalEducationTableControlRow) 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 SetCommandDateLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCommandLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCOUNTRYLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCourseAbbrLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCourseLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCourseNoLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetEducationPeriodLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetEdYearLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetEndDateLabel2()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetFacultryLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetInstitueLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetLevelIdLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetNoAllLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalEducationTableControlCollapsibleRegion()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetScoreLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetScoreNoLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetStartDateLabel2()
|
|
|
|
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.
|
|
Dim added As Boolean = Me.AddNewRecord > 0
|
|
Me.LoadData()
|
|
Me.DataBind()
|
|
|
|
If added Then
|
|
Me.SetFocusToAddedRow()
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
Catch ex As Exception
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
End Sub
|
|
|
|
'this function sets focus to the first editable element in the new added row in the editable table
|
|
Protected Overridable Sub SetFocusToAddedRow()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalEducationTableControlRepeater"), System.Web.UI.WebControls.Repeater)
|
|
If rep Is Nothing OrElse rep.Items.Count = 0 Then Return
|
|
Dim repItem As System.Web.UI.WebControls.RepeaterItem
|
|
For Each repItem In rep.Items
|
|
'Load scripts to table rows
|
|
Me.Page.LoadFocusScripts(repItem)
|
|
Dim recControl As PersonalEducationTableControlRow = DirectCast(repItem.FindControl("PersonalEducationTableControlRow"), PersonalEducationTableControlRow)
|
|
If recControl.IsNewRecord Then
|
|
For Each field As Control In recControl.Controls
|
|
If field.Visible AndAlso Me.Page.IsControlEditable(field, False) Then
|
|
'set focus on the first editable field in the new row
|
|
field.Focus()
|
|
Dim updPan As UpdatePanel = DirectCast(Me.Page.FindControlRecursively("UpdatePanel1"), UpdatePanel)
|
|
If Not updPan Is Nothing Then updPan.Update()
|
|
Return
|
|
End If
|
|
Next
|
|
Return
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub SaveControlsToSession()
|
|
MyBase.SaveControlsToSession()
|
|
|
|
' Save filter controls to values to session.
|
|
|
|
|
|
'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.
|
|
|
|
HttpContext.Current.Session("AppRelativeVirtualPath") = Me.Page.AppRelativeVirtualPath
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub ClearControlsFromSession()
|
|
MyBase.ClearControlsFromSession()
|
|
|
|
' Clear filter controls values from the session.
|
|
|
|
|
|
' 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("PersonalEducationTableControl_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("PersonalEducationTableControl_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 PersonalEducationPagination_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 PersonalEducationPagination_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 PersonalEducationPagination_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 PersonalEducationPagination_PageSizeButton_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
Try
|
|
|
|
Me.DataChanged = True
|
|
|
|
Me.PageSize = Integer.Parse(Me.PersonalEducationPagination.PageSize.Text)
|
|
|
|
Me.PageIndex = Integer.Parse(Me.PersonalEducationPagination.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 PersonalEducationPagination_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 CommandDateLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by CommandDate when clicked.
|
|
|
|
' Get previous sorting state for CommandDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalEducationTable.CommandDate)
|
|
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 CommandDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.CommandDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by CommandDate, 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 CommandLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Command when clicked.
|
|
|
|
' Get previous sorting state for Command.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalEducationTable.Command)
|
|
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 Command.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.Command, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Command, 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 COUNTRYLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by COUNTRY when clicked.
|
|
|
|
' Get previous sorting state for COUNTRY.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalEducationTable.COUNTRY)
|
|
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 COUNTRY.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.COUNTRY, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by COUNTRY, 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 CourseAbbrLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by CourseAbbr when clicked.
|
|
|
|
' Get previous sorting state for CourseAbbr.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalEducationTable.CourseAbbr)
|
|
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 CourseAbbr.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.CourseAbbr, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by CourseAbbr, 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 CourseLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Course when clicked.
|
|
|
|
' Get previous sorting state for Course.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalEducationTable.Course)
|
|
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 Course.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.Course, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Course, 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 CourseNoLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by CourseNo when clicked.
|
|
|
|
' Get previous sorting state for CourseNo.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalEducationTable.CourseNo)
|
|
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 CourseNo.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.CourseNo, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by CourseNo, 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 EducationPeriodLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by EducationPeriod when clicked.
|
|
|
|
' Get previous sorting state for EducationPeriod.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalEducationTable.EducationPeriod)
|
|
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 EducationPeriod.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.EducationPeriod, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by EducationPeriod, 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 EdYearLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by EdYear when clicked.
|
|
|
|
' Get previous sorting state for EdYear.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalEducationTable.EdYear)
|
|
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 EdYear.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.EdYear, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by EdYear, 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 EndDateLabel2_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by EndDate when clicked.
|
|
|
|
' Get previous sorting state for EndDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalEducationTable.EndDate)
|
|
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 EndDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.EndDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by EndDate, 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 FacultryLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Facultry when clicked.
|
|
|
|
' Get previous sorting state for Facultry.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalEducationTable.Facultry)
|
|
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 Facultry.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.Facultry, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Facultry, 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 InstitueLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Institue when clicked.
|
|
|
|
' Get previous sorting state for Institue.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalEducationTable.Institue)
|
|
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 Institue.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.Institue, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Institue, 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 LevelIdLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by LevelId when clicked.
|
|
|
|
' Get previous sorting state for LevelId.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalEducationTable.LevelId)
|
|
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 LevelId.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.LevelId, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by LevelId, 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 NoAllLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by NoAll when clicked.
|
|
|
|
' Get previous sorting state for NoAll.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalEducationTable.NoAll)
|
|
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 NoAll.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.NoAll, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by NoAll, 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 ScoreLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Score when clicked.
|
|
|
|
' Get previous sorting state for Score.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalEducationTable.Score)
|
|
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 Score.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.Score, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Score, 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 ScoreNoLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by ScoreNo when clicked.
|
|
|
|
' Get previous sorting state for ScoreNo.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalEducationTable.ScoreNo)
|
|
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 ScoreNo.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.ScoreNo, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by ScoreNo, 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 StartDateLabel2_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by StartDate when clicked.
|
|
|
|
' Get previous sorting state for StartDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalEducationTable.StartDate)
|
|
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 StartDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.StartDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by StartDate, 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 PersonalEducationAddButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
Me.AddNewRecord = 1
|
|
Me.DataChanged = 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 PersonalEducationDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Me.DeleteSelectedRecords(True)
|
|
Me.SetFormulaControls()
|
|
|
|
|
|
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 PersonalEducationEditButton_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 = "../PersonalEducation/EditPersonalEducation.aspx?PersonalEducation={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 PersonalEducationResetButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
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(PersonalEducationTable.EducationPeriod, OrderByItem.OrderDir.Asc)
|
|
|
|
Me.CurrentSortOrder.Add(PersonalEducationTable.StartDate, OrderByItem.OrderDir.Asc)
|
|
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
|
|
' 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 = PersonalEducationTable.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 PersonalEducationRecord = Nothing
|
|
Public Property DataSource() As PersonalEducationRecord ()
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
Set(ByVal value() As PersonalEducationRecord)
|
|
Me._DataSource = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Helper Properties"
|
|
|
|
Public ReadOnly Property CommandDateLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CommandDateLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CommandLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CommandLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property COUNTRYLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "COUNTRYLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CourseAbbrLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CourseAbbrLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CourseLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CourseLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CourseNoLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CourseNoLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property EducationPeriodLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "EducationPeriodLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property EdYearLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "EdYearLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property EndDateLabel2() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "EndDateLabel2"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property FacultryLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "FacultryLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property InstitueLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "InstitueLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property LevelIdLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "LevelIdLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property NoAllLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "NoAllLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalEducationAddButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalEducationAddButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalEducationDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalEducationDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalEducationEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalEducationEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalEducationPagination() As Persons.UI.IPagination
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalEducationPagination"), Persons.UI.IPagination)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalEducationResetButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalEducationResetButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalEducationTableControlCollapsibleRegion() As System.Web.UI.WebControls.Panel
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalEducationTableControlCollapsibleRegion"), System.Web.UI.WebControls.Panel)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalEducationToggleAll() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalEducationToggleAll"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ScoreLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ScoreLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ScoreNoLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ScoreNoLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property StartDateLabel2() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "StartDateLabel2"), System.Web.UI.WebControls.LinkButton)
|
|
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 PersonalEducationTableControlRow = 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 PersonalEducationRecord = 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 GetSelectedRecordIndex() As Integer
|
|
Dim counter As Integer = 0
|
|
Dim recControl As PersonalEducationTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalEducationRecordRowSelection.Checked Then
|
|
Return counter
|
|
End If
|
|
counter += 1
|
|
Next
|
|
Return -1
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControl() As PersonalEducationTableControlRow
|
|
Dim selectedList() As PersonalEducationTableControlRow = Me.GetSelectedRecordControls()
|
|
If selectedList.Length = 0 Then
|
|
Return Nothing
|
|
End If
|
|
Return selectedList(0)
|
|
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControls() As PersonalEducationTableControlRow()
|
|
|
|
Dim selectedList As ArrayList = New ArrayList(25)
|
|
Dim recControl As PersonalEducationTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalEducationRecordRowSelection IsNot Nothing AndAlso recControl.PersonalEducationRecordRowSelection.Checked Then
|
|
selectedList.Add(recControl)
|
|
End If
|
|
Next
|
|
Return DirectCast(selectedList.ToArray(GetType(PersonalEducationTableControlRow)), PersonalEducationTableControlRow())
|
|
|
|
End Function
|
|
|
|
Public Overridable Sub DeleteSelectedRecords(ByVal deferDeletion As Boolean)
|
|
Dim recList() As PersonalEducationTableControlRow = Me.GetSelectedRecordControls()
|
|
If recList.Length = 0 Then
|
|
' Localization.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoRecSelected", "Persons"))
|
|
End If
|
|
|
|
Dim recCtl As PersonalEducationTableControlRow
|
|
For Each recCtl In recList
|
|
If deferDeletion Then
|
|
If Not recCtl.IsNewRecord Then
|
|
|
|
Me.AddToDeletedRecordIds(recCtl)
|
|
|
|
End If
|
|
recCtl.Visible = False
|
|
|
|
recCtl.PersonalEducationRecordRowSelection.Checked = 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 PersonalEducationTableControlRow()
|
|
Dim recList As ArrayList = New ArrayList()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalEducationTableControlRepeater"), 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 PersonalEducationTableControlRow = DirectCast(repItem.FindControl("PersonalEducationTableControlRow"), PersonalEducationTableControlRow)
|
|
recList.Add(recControl)
|
|
|
|
Next
|
|
|
|
Return DirectCast(recList.ToArray(GetType(PersonalEducationTableControlRow)), PersonalEducationTableControlRow())
|
|
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 PersonalExtWorkTableControlRow control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalExtWorkTableControlRow.
|
|
Public Class BasePersonalExtWorkTableControlRow
|
|
Inherits Persons.UI.BaseApplicationRecordControl
|
|
|
|
' To customize, override this method in PersonalExtWorkTableControlRow.
|
|
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 PersonalExtWorkTableControlRow.
|
|
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)
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalExtWorkRowDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteRecordConfirm", "Persons") & "'));")
|
|
|
|
|
|
' Register the event handlers.
|
|
|
|
AddHandler Me.PersonalExtWorkRowDeleteButton.Click, AddressOf PersonalExtWorkRowDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalExtWorkRowEditButton.Click, AddressOf PersonalExtWorkRowEditButton_Click
|
|
|
|
AddHandler Me.PersonalExtWorkRowViewButton.Click, AddressOf PersonalExtWorkRowViewButton_Click
|
|
|
|
AddHandler Me.Active.CheckedChanged, AddressOf Active_CheckedChanged
|
|
|
|
AddHandler Me.BeginDate.TextChanged, AddressOf BeginDate_TextChanged
|
|
|
|
AddHandler Me.Command1.TextChanged, AddressOf Command1_TextChanged
|
|
|
|
AddHandler Me.CommandDate1.TextChanged, AddressOf CommandDate1_TextChanged
|
|
|
|
AddHandler Me.Description.TextChanged, AddressOf Description_TextChanged
|
|
|
|
AddHandler Me.EndDate2.TextChanged, AddressOf EndDate2_TextChanged
|
|
|
|
AddHandler Me.Place.TextChanged, AddressOf Place_TextChanged
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Load the data from the database into the DataSource PersonalExtWork 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 = PersonalExtWorkTable.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 BasePersonalExtWorkTableControl when the data for the entire
|
|
' table is loaded.
|
|
|
|
Me.DataSource = New PersonalExtWorkRecord()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
' Populate the UI controls using the DataSource. To customize, override this method in PersonalExtWorkTableControlRow.
|
|
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
|
|
|
|
SetActive()
|
|
SetBeginDate()
|
|
SetCommand1()
|
|
SetCommandDate1()
|
|
SetDescription()
|
|
SetEndDate2()
|
|
|
|
|
|
|
|
|
|
SetPlace()
|
|
|
|
|
|
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 SetActive()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Active.ID) Then
|
|
Me.Active.Checked = Convert.ToBoolean(Me.PreviousUIData(Me.Active.ID))
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Active CheckBox on the webpage with value from the
|
|
' PersonalExtWork database record.
|
|
|
|
' Me.DataSource is the PersonalExtWork record retrieved from the database.
|
|
' Me.Active is the ASP:CheckBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetActive()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.ActiveSpecified Then
|
|
|
|
' If the Active is non-NULL, then format the value.
|
|
' The Format method will use the Display Format
|
|
Me.Active.Checked = Me.DataSource.Active
|
|
Else
|
|
|
|
' Active is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Not Me.DataSource.IsCreated Then
|
|
Me.Active.Checked = PersonalExtWorkTable.Active.ParseValue(PersonalExtWorkTable.Active.DefaultValue).ToBoolean()
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetBeginDate()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.BeginDate.ID) Then
|
|
|
|
Me.BeginDate.Text = Me.PreviousUIData(Me.BeginDate.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the BeginDate TextBox on the webpage with value from the
|
|
' PersonalExtWork database record.
|
|
|
|
' Me.DataSource is the PersonalExtWork record retrieved from the database.
|
|
' Me.BeginDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetBeginDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.BeginDateSpecified Then
|
|
|
|
' If the BeginDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalExtWorkTable.BeginDate, "d MMM yy")
|
|
|
|
Me.BeginDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' BeginDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.BeginDate.Text = PersonalExtWorkTable.BeginDate.Format(PersonalExtWorkTable.BeginDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCommand1()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Command1.ID) Then
|
|
|
|
Me.Command1.Text = Me.PreviousUIData(Me.Command1.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Command TextBox on the webpage with value from the
|
|
' PersonalExtWork database record.
|
|
|
|
' Me.DataSource is the PersonalExtWork record retrieved from the database.
|
|
' Me.Command1 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetCommand1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.CommandSpecified Then
|
|
|
|
' If the Command is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalExtWorkTable.Command)
|
|
|
|
Me.Command1.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Command is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Command1.Text = PersonalExtWorkTable.Command.Format(PersonalExtWorkTable.Command.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCommandDate1()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.CommandDate1.ID) Then
|
|
|
|
Me.CommandDate1.Text = Me.PreviousUIData(Me.CommandDate1.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the CommandDate TextBox on the webpage with value from the
|
|
' PersonalExtWork database record.
|
|
|
|
' Me.DataSource is the PersonalExtWork record retrieved from the database.
|
|
' Me.CommandDate1 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetCommandDate1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.CommandDateSpecified Then
|
|
|
|
' If the CommandDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalExtWorkTable.CommandDate, "d MMM yy")
|
|
|
|
Me.CommandDate1.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' CommandDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.CommandDate1.Text = PersonalExtWorkTable.CommandDate.Format(PersonalExtWorkTable.CommandDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetDescription()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Description.ID) Then
|
|
|
|
Me.Description.Text = Me.PreviousUIData(Me.Description.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Description TextBox on the webpage with value from the
|
|
' PersonalExtWork database record.
|
|
|
|
' Me.DataSource is the PersonalExtWork record retrieved from the database.
|
|
' Me.Description is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetDescription()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.DescriptionSpecified Then
|
|
|
|
' If the Description is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalExtWorkTable.Description)
|
|
|
|
Me.Description.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Description is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Description.Text = PersonalExtWorkTable.Description.Format(PersonalExtWorkTable.Description.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetEndDate2()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.EndDate2.ID) Then
|
|
|
|
Me.EndDate2.Text = Me.PreviousUIData(Me.EndDate2.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the EndDate TextBox on the webpage with value from the
|
|
' PersonalExtWork database record.
|
|
|
|
' Me.DataSource is the PersonalExtWork record retrieved from the database.
|
|
' Me.EndDate2 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetEndDate2()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.EndDateSpecified Then
|
|
|
|
' If the EndDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalExtWorkTable.EndDate, "d MMM yy")
|
|
|
|
Me.EndDate2.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' EndDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.EndDate2.Text = PersonalExtWorkTable.EndDate.Format(PersonalExtWorkTable.EndDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPlace()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Place.ID) Then
|
|
|
|
Me.Place.Text = Me.PreviousUIData(Me.Place.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Place TextBox on the webpage with value from the
|
|
' PersonalExtWork database record.
|
|
|
|
' Me.DataSource is the PersonalExtWork record retrieved from the database.
|
|
' Me.Place is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetPlace()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.PlaceSpecified Then
|
|
|
|
' If the Place is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalExtWorkTable.Place)
|
|
|
|
Me.Place.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Place is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Place.Text = PersonalExtWorkTable.Place.Format(PersonalExtWorkTable.Place.DefaultValue)
|
|
|
|
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 PersonalExtWorkTableControlRow.
|
|
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()
|
|
|
|
Dim parentCtrl As PersonalIdRecordControl
|
|
|
|
|
|
parentCtrl = DirectCast(Me.Page.FindControlRecursively("PersonalIdRecordControl"), PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(parentCtrl) AndAlso IsNothing(parentCtrl.DataSource))
|
|
' Load the record if it is not loaded yet.
|
|
parentCtrl.LoadData()
|
|
End If
|
|
If (IsNothing(parentCtrl) OrElse IsNothing(parentCtrl.DataSource))
|
|
' Get the error message from the application resource file.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoParentRecId", "Persons"))
|
|
End If
|
|
|
|
Me.DataSource.PersonalId = parentCtrl.DataSource.PersonalId
|
|
|
|
' 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, "PersonalExtWorkTableControl"), PersonalExtWorkTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalExtWorkTableControl"), PersonalExtWorkTableControl).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 PersonalExtWorkTableControlRow.
|
|
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.
|
|
|
|
GetActive()
|
|
GetBeginDate()
|
|
GetCommand1()
|
|
GetCommandDate1()
|
|
GetDescription()
|
|
GetEndDate2()
|
|
GetPlace()
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub GetActive()
|
|
|
|
|
|
' Retrieve the value entered by the user on the Active ASP:CheckBox, and
|
|
' save it into the Active field in DataSource PersonalExtWork record.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
|
|
Me.DataSource.Active = Me.Active.Checked
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetBeginDate()
|
|
|
|
' Retrieve the value entered by the user on the BeginDate ASP:TextBox, and
|
|
' save it into the BeginDate field in DataSource PersonalExtWork record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.BeginDate.Text, PersonalExtWorkTable.BeginDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetCommand1()
|
|
|
|
' Retrieve the value entered by the user on the Command ASP:TextBox, and
|
|
' save it into the Command field in DataSource PersonalExtWork record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Command1.Text, PersonalExtWorkTable.Command)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetCommandDate1()
|
|
|
|
' Retrieve the value entered by the user on the CommandDate ASP:TextBox, and
|
|
' save it into the CommandDate field in DataSource PersonalExtWork record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.CommandDate1.Text, PersonalExtWorkTable.CommandDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetDescription()
|
|
|
|
' Retrieve the value entered by the user on the Description ASP:TextBox, and
|
|
' save it into the Description field in DataSource PersonalExtWork record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Description.Text, PersonalExtWorkTable.Description)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetEndDate2()
|
|
|
|
' Retrieve the value entered by the user on the EndDate ASP:TextBox, and
|
|
' save it into the EndDate field in DataSource PersonalExtWork record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.EndDate2.Text, PersonalExtWorkTable.EndDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetPlace()
|
|
|
|
' Retrieve the value entered by the user on the Place ASP:TextBox, and
|
|
' save it into the Place field in DataSource PersonalExtWork record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Place.Text, PersonalExtWorkTable.Place)
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
' To customize, override this method in PersonalExtWorkTableControlRow.
|
|
|
|
Public Overridable Function CreateWhereClause() As WhereClause
|
|
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
|
|
|
|
' To customize, override this method in PersonalExtWorkTableControlRow.
|
|
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)
|
|
PersonalExtWorkTable.DeleteRecord(pkValue)
|
|
|
|
DirectCast(GetParentControlObject(Me, "PersonalExtWorkTableControl"), PersonalExtWorkTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalExtWorkTableControl"), PersonalExtWorkTableControl).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
|
|
|
|
|
|
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 PersonalExtWorkRowDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Dim tc As PersonalExtWorkTableControl = DirectCast(GetParentControlObject(Me, "PersonalExtWorkTableControl"), PersonalExtWorkTableControl)
|
|
If Not (IsNothing(tc)) Then
|
|
If Not Me.IsNewRecord Then
|
|
tc.AddToDeletedRecordIds(DirectCast(Me, PersonalExtWorkTableControlRow))
|
|
End If
|
|
Me.Visible = False
|
|
tc.SetFormulaControls()
|
|
End If
|
|
|
|
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 PersonalExtWorkRowEditButton_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 = "../PersonalExtWork/EditPersonalExtWork.aspx?PersonalExtWork={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 PersonalExtWorkRowViewButton_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 = "../PersonalExtWork/ShowPersonalExtWork.aspx?PersonalExtWork={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
|
|
|
|
Protected Overridable Sub Active_CheckedChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub BeginDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Command1_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub CommandDate1_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Description_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub EndDate2_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Place_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
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("BasePersonalExtWorkTableControlRow_Rec"), String)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me.ViewState("BasePersonalExtWorkTableControlRow_Rec") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataSource As PersonalExtWorkRecord
|
|
Public Property DataSource() As PersonalExtWorkRecord
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
|
|
Set(ByVal value As PersonalExtWorkRecord)
|
|
|
|
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 Active() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Active"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BeginDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "BeginDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Command1() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Command1"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CommandDate1() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CommandDate1"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Description() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Description"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property EndDate2() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "EndDate2"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtWorkRecordRowSelection() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtWorkRecordRowSelection"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtWorkRowDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtWorkRowDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtWorkRowEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtWorkRowEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtWorkRowViewButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtWorkRowViewButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Place() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Place"), System.Web.UI.WebControls.TextBox)
|
|
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 PersonalExtWorkRecord = 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 PersonalExtWorkRecord
|
|
If Not Me.DataSource Is Nothing Then
|
|
Return Me.DataSource
|
|
End If
|
|
|
|
If Not Me.RecordUniqueId Is Nothing Then
|
|
|
|
Return PersonalExtWorkTable.GetRecord(Me.RecordUniqueId, True)
|
|
|
|
End If
|
|
|
|
' Localization.
|
|
|
|
Return Nothing
|
|
|
|
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 PersonalExtWorkTableControl control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalExtWorkTableControl.
|
|
Public Class BasePersonalExtWorkTableControl
|
|
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.
|
|
|
|
|
|
|
|
' 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)
|
|
|
|
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()
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalExtWorkDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteConfirm", "Persons") & "'));")
|
|
|
|
' Setup the pagination events.
|
|
|
|
AddHandler Me.PersonalExtWorkPagination.FirstPage.Click, AddressOf PersonalExtWorkPagination_FirstPage_Click
|
|
|
|
AddHandler Me.PersonalExtWorkPagination.LastPage.Click, AddressOf PersonalExtWorkPagination_LastPage_Click
|
|
|
|
AddHandler Me.PersonalExtWorkPagination.NextPage.Click, AddressOf PersonalExtWorkPagination_NextPage_Click
|
|
|
|
AddHandler Me.PersonalExtWorkPagination.PageSizeButton.Click, AddressOf PersonalExtWorkPagination_PageSizeButton_Click
|
|
|
|
AddHandler Me.PersonalExtWorkPagination.PreviousPage.Click, AddressOf PersonalExtWorkPagination_PreviousPage_Click
|
|
|
|
|
|
' Setup the sorting events.
|
|
|
|
AddHandler Me.ActiveLabel.Click, AddressOf ActiveLabel_Click
|
|
|
|
AddHandler Me.BeginDateLabel.Click, AddressOf BeginDateLabel_Click
|
|
|
|
AddHandler Me.CommandDateLabel1.Click, AddressOf CommandDateLabel1_Click
|
|
|
|
AddHandler Me.CommandLabel1.Click, AddressOf CommandLabel1_Click
|
|
|
|
AddHandler Me.DescriptionLabel1.Click, AddressOf DescriptionLabel1_Click
|
|
|
|
AddHandler Me.EndDateLabel3.Click, AddressOf EndDateLabel3_Click
|
|
|
|
AddHandler Me.PlaceLabel1.Click, AddressOf PlaceLabel1_Click
|
|
|
|
' Setup the button events.
|
|
|
|
AddHandler Me.PersonalExtWorkAddButton.Click, AddressOf PersonalExtWorkAddButton_Click
|
|
|
|
AddHandler Me.PersonalExtWorkDeleteButton.Click, AddressOf PersonalExtWorkDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalExtWorkEditButton.Click, AddressOf PersonalExtWorkEditButton_Click
|
|
|
|
AddHandler Me.PersonalExtWorkResetButton.Click, AddressOf PersonalExtWorkResetButton_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(PersonalExtWorkRecord)), PersonalExtWorkRecord())
|
|
' 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, PersonalExtWorkTable.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 PersonalExtWorkTableControlRow 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(PersonalExtWorkRecord)), PersonalExtWorkRecord())
|
|
Else ' Get the records from the database
|
|
Me.DataSource = PersonalExtWorkTable.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()
|
|
|
|
' Turn off the ToggleAll checkbox
|
|
Me.PersonalExtWorkToggleAll.Checked = False
|
|
|
|
|
|
' Initialize the page and grand totals. now
|
|
|
|
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, "PersonalExtWorkTableControlRepeater"), 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 PersonalExtWorkTableControlRow = DirectCast(repItem.FindControl("PersonalExtWorkTableControlRow"), PersonalExtWorkTableControlRow)
|
|
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
|
|
|
|
SetActiveLabel()
|
|
SetBeginDateLabel()
|
|
SetCommandDateLabel1()
|
|
SetCommandLabel1()
|
|
SetDescriptionLabel1()
|
|
SetEndDateLabel3()
|
|
|
|
|
|
|
|
|
|
|
|
SetPersonalExtWorkTableControlCollapsibleRegion()
|
|
|
|
SetPlaceLabel1()
|
|
' 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()
|
|
|
|
|
|
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.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)
|
|
|
|
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.PersonalExtWorkPagination.CurrentPage.Text = (Me.PageIndex + 1).ToString()
|
|
Else
|
|
Me.PersonalExtWorkPagination.CurrentPage.Text = "0"
|
|
End If
|
|
Me.PersonalExtWorkPagination.PageSize.Text = Me.PageSize.ToString()
|
|
Me.PersonalExtWorkPagination.TotalItems.Text = Me.TotalRecords.ToString()
|
|
Me.PersonalExtWorkPagination.TotalPages.Text = Me.TotalPages.ToString()
|
|
|
|
' Bind the buttons for PersonalExtWorkTableControl pagination.
|
|
|
|
Me.PersonalExtWorkPagination.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.PersonalExtWorkPagination.LastPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalExtWorkPagination.LastPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalExtWorkPagination.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.PersonalExtWorkPagination.NextPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalExtWorkPagination.NextPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalExtWorkPagination.NextPage.Enabled = Not (Me.PageIndex = Me.TotalPages - 1)
|
|
End If
|
|
|
|
Me.PersonalExtWorkPagination.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 PersonalExtWorkTableControlRow
|
|
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.
|
|
PersonalExtWorkTable.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 selectedRecordKeyValue as KeyValue = New KeyValue()
|
|
|
|
Dim personalIdRecordControlObj As Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalIdRecordControl"), Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(personalIdRecordControlObj) AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord()) AndAlso personalIdRecordControlObj.GetRecord().IsCreated AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord().PersonalId))
|
|
wc.iAND(PersonalExtWorkTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
selectedRecordKeyValue.AddElement(PersonalExtWorkTable.PersonalId.InternalName, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
Else
|
|
wc.RunQuery = False
|
|
Return wc
|
|
End If
|
|
|
|
HttpContext.Current.Session("PersonalExtWorkTableControlWhereClause") = selectedRecordKeyValue.ToXmlString()
|
|
|
|
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.
|
|
PersonalExtWorkTable.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)
|
|
|
|
Dim selectedRecordInPersonalIdRecordControl as String = DirectCast(HttpContext.Current.Session("PersonalExtWorkTableControlWhereClause"), String)
|
|
|
|
If Not selectedRecordInPersonalIdRecordControl Is Nothing AndAlso KeyValue.IsXmlKey(selectedRecordInPersonalIdRecordControl) Then
|
|
Dim selectedRecordKeyValue as KeyValue = KeyValue.XmlToKey(selectedRecordInPersonalIdRecordControl)
|
|
|
|
If Not IsNothing(selectedRecordKeyValue) AndAlso selectedRecordKeyValue.ContainsColumn(PersonalExtWorkTable.PersonalId) Then
|
|
wc.iAND(PersonalExtWorkTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, selectedRecordKeyValue.GetColumnValue(PersonalExtWorkTable.PersonalId).ToString())
|
|
End If
|
|
|
|
End If
|
|
|
|
' Adds clauses if values are selected in Filter controls which are configured in the page.
|
|
|
|
|
|
Return wc
|
|
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.PersonalExtWorkPagination.PageSize.Text.Trim <> "" Then
|
|
Try
|
|
'Me.PageSize = Integer.Parse(Me.PersonalExtWorkPagination.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, "PersonalExtWorkTableControlRepeater"), 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 PersonalExtWorkTableControlRow = DirectCast(repItem.FindControl("PersonalExtWorkTableControlRow"), PersonalExtWorkTableControlRow)
|
|
|
|
If recControl.Visible AndAlso recControl.IsNewRecord() Then
|
|
|
|
Dim rec As PersonalExtWorkRecord = New PersonalExtWorkRecord()
|
|
|
|
rec.Active = recControl.Active.Checked
|
|
|
|
If recControl.BeginDate.Text <> "" Then
|
|
rec.Parse(recControl.BeginDate.Text, PersonalExtWorkTable.BeginDate)
|
|
End If
|
|
If recControl.Command1.Text <> "" Then
|
|
rec.Parse(recControl.Command1.Text, PersonalExtWorkTable.Command)
|
|
End If
|
|
If recControl.CommandDate1.Text <> "" Then
|
|
rec.Parse(recControl.CommandDate1.Text, PersonalExtWorkTable.CommandDate)
|
|
End If
|
|
If recControl.Description.Text <> "" Then
|
|
rec.Parse(recControl.Description.Text, PersonalExtWorkTable.Description)
|
|
End If
|
|
If recControl.EndDate2.Text <> "" Then
|
|
rec.Parse(recControl.EndDate2.Text, PersonalExtWorkTable.EndDate)
|
|
End If
|
|
If recControl.Place.Text <> "" Then
|
|
rec.Parse(recControl.Place.Text, PersonalExtWorkTable.Place)
|
|
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 PersonalExtWorkRecord())
|
|
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(PersonalExtWorkRecord)), PersonalExtWorkRecord())
|
|
|
|
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 PersonalExtWorkTableControlRow)
|
|
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 PersonalExtWorkTableControlRow) 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 SetActiveLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetBeginDateLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCommandDateLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCommandLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetDescriptionLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetEndDateLabel3()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalExtWorkTableControlCollapsibleRegion()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPlaceLabel1()
|
|
|
|
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.
|
|
Dim added As Boolean = Me.AddNewRecord > 0
|
|
Me.LoadData()
|
|
Me.DataBind()
|
|
|
|
If added Then
|
|
Me.SetFocusToAddedRow()
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
Catch ex As Exception
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
End Sub
|
|
|
|
'this function sets focus to the first editable element in the new added row in the editable table
|
|
Protected Overridable Sub SetFocusToAddedRow()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalExtWorkTableControlRepeater"), System.Web.UI.WebControls.Repeater)
|
|
If rep Is Nothing OrElse rep.Items.Count = 0 Then Return
|
|
Dim repItem As System.Web.UI.WebControls.RepeaterItem
|
|
For Each repItem In rep.Items
|
|
'Load scripts to table rows
|
|
Me.Page.LoadFocusScripts(repItem)
|
|
Dim recControl As PersonalExtWorkTableControlRow = DirectCast(repItem.FindControl("PersonalExtWorkTableControlRow"), PersonalExtWorkTableControlRow)
|
|
If recControl.IsNewRecord Then
|
|
For Each field As Control In recControl.Controls
|
|
If field.Visible AndAlso Me.Page.IsControlEditable(field, False) Then
|
|
'set focus on the first editable field in the new row
|
|
field.Focus()
|
|
Dim updPan As UpdatePanel = DirectCast(Me.Page.FindControlRecursively("UpdatePanel1"), UpdatePanel)
|
|
If Not updPan Is Nothing Then updPan.Update()
|
|
Return
|
|
End If
|
|
Next
|
|
Return
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub SaveControlsToSession()
|
|
MyBase.SaveControlsToSession()
|
|
|
|
' Save filter controls to values to session.
|
|
|
|
|
|
'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.
|
|
|
|
HttpContext.Current.Session("AppRelativeVirtualPath") = Me.Page.AppRelativeVirtualPath
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub ClearControlsFromSession()
|
|
MyBase.ClearControlsFromSession()
|
|
|
|
' Clear filter controls values from the session.
|
|
|
|
|
|
' 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("PersonalExtWorkTableControl_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("PersonalExtWorkTableControl_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 PersonalExtWorkPagination_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 PersonalExtWorkPagination_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 PersonalExtWorkPagination_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 PersonalExtWorkPagination_PageSizeButton_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
Try
|
|
|
|
Me.DataChanged = True
|
|
|
|
Me.PageSize = Integer.Parse(Me.PersonalExtWorkPagination.PageSize.Text)
|
|
|
|
Me.PageIndex = Integer.Parse(Me.PersonalExtWorkPagination.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 PersonalExtWorkPagination_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 ActiveLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Active when clicked.
|
|
|
|
' Get previous sorting state for Active.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalExtWorkTable.Active)
|
|
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 Active.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalExtWorkTable.Active, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Active, 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 BeginDateLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by BeginDate when clicked.
|
|
|
|
' Get previous sorting state for BeginDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalExtWorkTable.BeginDate)
|
|
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 BeginDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalExtWorkTable.BeginDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by BeginDate, 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 CommandDateLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by CommandDate when clicked.
|
|
|
|
' Get previous sorting state for CommandDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalExtWorkTable.CommandDate)
|
|
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 CommandDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalExtWorkTable.CommandDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by CommandDate, 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 CommandLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Command when clicked.
|
|
|
|
' Get previous sorting state for Command.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalExtWorkTable.Command)
|
|
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 Command.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalExtWorkTable.Command, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Command, 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 DescriptionLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Description when clicked.
|
|
|
|
' Get previous sorting state for Description.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalExtWorkTable.Description)
|
|
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 Description.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalExtWorkTable.Description, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Description, 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 EndDateLabel3_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by EndDate when clicked.
|
|
|
|
' Get previous sorting state for EndDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalExtWorkTable.EndDate)
|
|
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 EndDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalExtWorkTable.EndDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by EndDate, 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 PlaceLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Place when clicked.
|
|
|
|
' Get previous sorting state for Place.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalExtWorkTable.Place)
|
|
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 Place.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalExtWorkTable.Place, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Place, 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 PersonalExtWorkAddButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
Me.AddNewRecord = 1
|
|
Me.DataChanged = 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 PersonalExtWorkDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Me.DeleteSelectedRecords(True)
|
|
Me.SetFormulaControls()
|
|
|
|
|
|
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 PersonalExtWorkEditButton_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 = "../PersonalExtWork/EditPersonalExtWork.aspx?PersonalExtWork={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 PersonalExtWorkResetButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
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)
|
|
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
|
|
' 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 = PersonalExtWorkTable.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 PersonalExtWorkRecord = Nothing
|
|
Public Property DataSource() As PersonalExtWorkRecord ()
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
Set(ByVal value() As PersonalExtWorkRecord)
|
|
Me._DataSource = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Helper Properties"
|
|
|
|
Public ReadOnly Property ActiveLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ActiveLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BeginDateLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "BeginDateLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CommandDateLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CommandDateLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CommandLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CommandLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DescriptionLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "DescriptionLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property EndDateLabel3() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "EndDateLabel3"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtWorkAddButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtWorkAddButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtWorkDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtWorkDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtWorkEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtWorkEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtWorkPagination() As Persons.UI.IPagination
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtWorkPagination"), Persons.UI.IPagination)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtWorkResetButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtWorkResetButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtWorkTableControlCollapsibleRegion() As System.Web.UI.WebControls.Panel
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtWorkTableControlCollapsibleRegion"), System.Web.UI.WebControls.Panel)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtWorkToggleAll() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtWorkToggleAll"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PlaceLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PlaceLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
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 PersonalExtWorkTableControlRow = 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 PersonalExtWorkRecord = 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 GetSelectedRecordIndex() As Integer
|
|
Dim counter As Integer = 0
|
|
Dim recControl As PersonalExtWorkTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalExtWorkRecordRowSelection.Checked Then
|
|
Return counter
|
|
End If
|
|
counter += 1
|
|
Next
|
|
Return -1
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControl() As PersonalExtWorkTableControlRow
|
|
Dim selectedList() As PersonalExtWorkTableControlRow = Me.GetSelectedRecordControls()
|
|
If selectedList.Length = 0 Then
|
|
Return Nothing
|
|
End If
|
|
Return selectedList(0)
|
|
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControls() As PersonalExtWorkTableControlRow()
|
|
|
|
Dim selectedList As ArrayList = New ArrayList(25)
|
|
Dim recControl As PersonalExtWorkTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalExtWorkRecordRowSelection IsNot Nothing AndAlso recControl.PersonalExtWorkRecordRowSelection.Checked Then
|
|
selectedList.Add(recControl)
|
|
End If
|
|
Next
|
|
Return DirectCast(selectedList.ToArray(GetType(PersonalExtWorkTableControlRow)), PersonalExtWorkTableControlRow())
|
|
|
|
End Function
|
|
|
|
Public Overridable Sub DeleteSelectedRecords(ByVal deferDeletion As Boolean)
|
|
Dim recList() As PersonalExtWorkTableControlRow = Me.GetSelectedRecordControls()
|
|
If recList.Length = 0 Then
|
|
' Localization.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoRecSelected", "Persons"))
|
|
End If
|
|
|
|
Dim recCtl As PersonalExtWorkTableControlRow
|
|
For Each recCtl In recList
|
|
If deferDeletion Then
|
|
If Not recCtl.IsNewRecord Then
|
|
|
|
Me.AddToDeletedRecordIds(recCtl)
|
|
|
|
End If
|
|
recCtl.Visible = False
|
|
|
|
recCtl.PersonalExtWorkRecordRowSelection.Checked = 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 PersonalExtWorkTableControlRow()
|
|
Dim recList As ArrayList = New ArrayList()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalExtWorkTableControlRepeater"), 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 PersonalExtWorkTableControlRow = DirectCast(repItem.FindControl("PersonalExtWorkTableControlRow"), PersonalExtWorkTableControlRow)
|
|
recList.Add(recControl)
|
|
|
|
Next
|
|
|
|
Return DirectCast(recList.ToArray(GetType(PersonalExtWorkTableControlRow)), PersonalExtWorkTableControlRow())
|
|
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 PersonalInsigniaTableControlRow control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalInsigniaTableControlRow.
|
|
Public Class BasePersonalInsigniaTableControlRow
|
|
Inherits Persons.UI.BaseApplicationRecordControl
|
|
|
|
' To customize, override this method in PersonalInsigniaTableControlRow.
|
|
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 PersonalInsigniaTableControlRow.
|
|
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)
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalInsigniaRowDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteRecordConfirm", "Persons") & "'));")
|
|
|
|
|
|
' Register the event handlers.
|
|
|
|
AddHandler Me.PersonalInsigniaRowDeleteButton.Click, AddressOf PersonalInsigniaRowDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalInsigniaRowEditButton.Click, AddressOf PersonalInsigniaRowEditButton_Click
|
|
|
|
AddHandler Me.PersonalInsigniaRowViewButton.Click, AddressOf PersonalInsigniaRowViewButton_Click
|
|
|
|
AddHandler Me.InsigniaId.SelectedIndexChanged, AddressOf InsigniaId_SelectedIndexChanged
|
|
|
|
AddHandler Me.GazetteDate.TextChanged, AddressOf GazetteDate_TextChanged
|
|
|
|
AddHandler Me.GazetteNO.TextChanged, AddressOf GazetteNO_TextChanged
|
|
|
|
AddHandler Me.GazettePage.TextChanged, AddressOf GazettePage_TextChanged
|
|
|
|
AddHandler Me.GazetteSection.TextChanged, AddressOf GazetteSection_TextChanged
|
|
|
|
AddHandler Me.InsigniaDate.TextChanged, AddressOf InsigniaDate_TextChanged
|
|
|
|
AddHandler Me.InsigniaReturn.TextChanged, AddressOf InsigniaReturn_TextChanged
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Load the data from the database into the DataSource PersonalInsignia 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 = PersonalInsigniaTable.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 BasePersonalInsigniaTableControl when the data for the entire
|
|
' table is loaded.
|
|
|
|
Me.DataSource = New PersonalInsigniaRecord()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
' Populate the UI controls using the DataSource. To customize, override this method in PersonalInsigniaTableControlRow.
|
|
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
|
|
|
|
SetGazetteDate()
|
|
SetGazetteNO()
|
|
SetGazettePage()
|
|
SetGazetteSection()
|
|
SetInsigniaDate()
|
|
SetInsigniaId()
|
|
SetInsigniaReturn()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 SetGazetteDate()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.GazetteDate.ID) Then
|
|
|
|
Me.GazetteDate.Text = Me.PreviousUIData(Me.GazetteDate.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the GazetteDate TextBox on the webpage with value from the
|
|
' PersonalInsignia database record.
|
|
|
|
' Me.DataSource is the PersonalInsignia record retrieved from the database.
|
|
' Me.GazetteDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetGazetteDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.GazetteDateSpecified Then
|
|
|
|
' If the GazetteDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalInsigniaTable.GazetteDate, "d MMM yy")
|
|
|
|
Me.GazetteDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' GazetteDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.GazetteDate.Text = PersonalInsigniaTable.GazetteDate.Format(PersonalInsigniaTable.GazetteDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetGazetteNO()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.GazetteNO.ID) Then
|
|
|
|
Me.GazetteNO.Text = Me.PreviousUIData(Me.GazetteNO.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the GazetteNO TextBox on the webpage with value from the
|
|
' PersonalInsignia database record.
|
|
|
|
' Me.DataSource is the PersonalInsignia record retrieved from the database.
|
|
' Me.GazetteNO is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetGazetteNO()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.GazetteNOSpecified Then
|
|
|
|
' If the GazetteNO is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalInsigniaTable.GazetteNO)
|
|
|
|
Me.GazetteNO.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' GazetteNO is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.GazetteNO.Text = PersonalInsigniaTable.GazetteNO.Format(PersonalInsigniaTable.GazetteNO.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetGazettePage()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.GazettePage.ID) Then
|
|
|
|
Me.GazettePage.Text = Me.PreviousUIData(Me.GazettePage.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the GazettePage TextBox on the webpage with value from the
|
|
' PersonalInsignia database record.
|
|
|
|
' Me.DataSource is the PersonalInsignia record retrieved from the database.
|
|
' Me.GazettePage is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetGazettePage()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.GazettePageSpecified Then
|
|
|
|
' If the GazettePage is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalInsigniaTable.GazettePage)
|
|
|
|
Me.GazettePage.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' GazettePage is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.GazettePage.Text = PersonalInsigniaTable.GazettePage.Format(PersonalInsigniaTable.GazettePage.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetGazetteSection()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.GazetteSection.ID) Then
|
|
|
|
Me.GazetteSection.Text = Me.PreviousUIData(Me.GazetteSection.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the GazetteSection TextBox on the webpage with value from the
|
|
' PersonalInsignia database record.
|
|
|
|
' Me.DataSource is the PersonalInsignia record retrieved from the database.
|
|
' Me.GazetteSection is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetGazetteSection()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.GazetteSectionSpecified Then
|
|
|
|
' If the GazetteSection is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalInsigniaTable.GazetteSection)
|
|
|
|
Me.GazetteSection.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' GazetteSection is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.GazetteSection.Text = PersonalInsigniaTable.GazetteSection.Format(PersonalInsigniaTable.GazetteSection.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetInsigniaDate()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.InsigniaDate.ID) Then
|
|
|
|
Me.InsigniaDate.Text = Me.PreviousUIData(Me.InsigniaDate.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the InsigniaDate TextBox on the webpage with value from the
|
|
' PersonalInsignia database record.
|
|
|
|
' Me.DataSource is the PersonalInsignia record retrieved from the database.
|
|
' Me.InsigniaDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetInsigniaDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.InsigniaDateSpecified Then
|
|
|
|
' If the InsigniaDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalInsigniaTable.InsigniaDate, "d MMM yy")
|
|
|
|
Me.InsigniaDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' InsigniaDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.InsigniaDate.Text = PersonalInsigniaTable.InsigniaDate.Format(PersonalInsigniaTable.InsigniaDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetInsigniaId()
|
|
|
|
' If selection was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.InsigniaId.ID) Then
|
|
If Me.PreviousUIData(Me.InsigniaId.ID) Is Nothing
|
|
Me.PopulateInsigniaIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateInsigniaIdDropDownList(Me.PreviousUIData(Me.InsigniaId.ID).ToString(), 100)
|
|
End If
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the InsigniaId DropDownList on the webpage with value from the
|
|
' PersonalInsignia database record.
|
|
|
|
' Me.DataSource is the PersonalInsignia record retrieved from the database.
|
|
' Me.InsigniaId is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetInsigniaId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.InsigniaIdSpecified Then
|
|
|
|
' If the InsigniaId is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateInsigniaIdDropDownList(Me.DataSource.InsigniaId.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' InsigniaId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateInsigniaIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateInsigniaIdDropDownList(PersonalInsigniaTable.InsigniaId.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetInsigniaReturn()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.InsigniaReturn.ID) Then
|
|
|
|
Me.InsigniaReturn.Text = Me.PreviousUIData(Me.InsigniaReturn.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the InsigniaReturn TextBox on the webpage with value from the
|
|
' PersonalInsignia database record.
|
|
|
|
' Me.DataSource is the PersonalInsignia record retrieved from the database.
|
|
' Me.InsigniaReturn is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetInsigniaReturn()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.InsigniaReturnSpecified Then
|
|
|
|
' If the InsigniaReturn is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalInsigniaTable.InsigniaReturn)
|
|
|
|
Me.InsigniaReturn.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' InsigniaReturn is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.InsigniaReturn.Text = PersonalInsigniaTable.InsigniaReturn.Format(PersonalInsigniaTable.InsigniaReturn.DefaultValue)
|
|
|
|
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 PersonalInsigniaTableControlRow.
|
|
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()
|
|
|
|
Dim parentCtrl As PersonalIdRecordControl
|
|
|
|
|
|
parentCtrl = DirectCast(Me.Page.FindControlRecursively("PersonalIdRecordControl"), PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(parentCtrl) AndAlso IsNothing(parentCtrl.DataSource))
|
|
' Load the record if it is not loaded yet.
|
|
parentCtrl.LoadData()
|
|
End If
|
|
If (IsNothing(parentCtrl) OrElse IsNothing(parentCtrl.DataSource))
|
|
' Get the error message from the application resource file.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoParentRecId", "Persons"))
|
|
End If
|
|
|
|
Me.DataSource.PersonalId = parentCtrl.DataSource.PersonalId
|
|
|
|
' 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, "PersonalInsigniaTableControl"), PersonalInsigniaTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalInsigniaTableControl"), PersonalInsigniaTableControl).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 PersonalInsigniaTableControlRow.
|
|
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.
|
|
|
|
GetGazetteDate()
|
|
GetGazetteNO()
|
|
GetGazettePage()
|
|
GetGazetteSection()
|
|
GetInsigniaDate()
|
|
GetInsigniaId()
|
|
GetInsigniaReturn()
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub GetGazetteDate()
|
|
|
|
' Retrieve the value entered by the user on the GazetteDate ASP:TextBox, and
|
|
' save it into the GazetteDate field in DataSource PersonalInsignia record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.GazetteDate.Text, PersonalInsigniaTable.GazetteDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetGazetteNO()
|
|
|
|
' Retrieve the value entered by the user on the GazetteNO ASP:TextBox, and
|
|
' save it into the GazetteNO field in DataSource PersonalInsignia record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.GazetteNO.Text, PersonalInsigniaTable.GazetteNO)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetGazettePage()
|
|
|
|
' Retrieve the value entered by the user on the GazettePage ASP:TextBox, and
|
|
' save it into the GazettePage field in DataSource PersonalInsignia record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.GazettePage.Text, PersonalInsigniaTable.GazettePage)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetGazetteSection()
|
|
|
|
' Retrieve the value entered by the user on the GazetteSection ASP:TextBox, and
|
|
' save it into the GazetteSection field in DataSource PersonalInsignia record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.GazetteSection.Text, PersonalInsigniaTable.GazetteSection)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetInsigniaDate()
|
|
|
|
' Retrieve the value entered by the user on the InsigniaDate ASP:TextBox, and
|
|
' save it into the InsigniaDate field in DataSource PersonalInsignia record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.InsigniaDate.Text, PersonalInsigniaTable.InsigniaDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetInsigniaId()
|
|
|
|
' Retrieve the value entered by the user on the InsigniaId ASP:DropDownList, and
|
|
' save it into the InsigniaId field in DataSource PersonalInsignia record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.InsigniaId), PersonalInsigniaTable.InsigniaId)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetInsigniaReturn()
|
|
|
|
' Retrieve the value entered by the user on the InsigniaReturn ASP:TextBox, and
|
|
' save it into the InsigniaReturn field in DataSource PersonalInsignia record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.InsigniaReturn.Text, PersonalInsigniaTable.InsigniaReturn)
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
' To customize, override this method in PersonalInsigniaTableControlRow.
|
|
|
|
Public Overridable Function CreateWhereClause() As WhereClause
|
|
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
|
|
|
|
' To customize, override this method in PersonalInsigniaTableControlRow.
|
|
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)
|
|
PersonalInsigniaTable.DeleteRecord(pkValue)
|
|
|
|
DirectCast(GetParentControlObject(Me, "PersonalInsigniaTableControl"), PersonalInsigniaTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalInsigniaTableControl"), PersonalInsigniaTableControl).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
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_InsigniaIdDropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the Insignia table.
|
|
' Examples:
|
|
' wc.iAND(InsigniaTable.InsigniaName, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(InsigniaTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
' Fill the InsigniaId list.
|
|
Protected Overridable Sub PopulateInsigniaIdDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.InsigniaId.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.InsigniaId.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_InsigniaIdDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_InsigniaIdDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(InsigniaTable.InsigniaName, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim itemValues() As InsigniaRecord = Nothing
|
|
Dim evaluator As New FormulaEvaluator
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
Do
|
|
itemValues = InsigniaTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
For each itemValue As InsigniaRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.InsigniaIdSpecified Then
|
|
cvalue = itemValue.InsigniaId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.InsigniaId.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalInsigniaTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalInsigniaTable.InsigniaId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalInsigniaTable.InsigniaId.IsApplyDisplayAs Then
|
|
fvalue = PersonalInsigniaTable.GetDFKA(itemValue, PersonalInsigniaTable.InsigniaId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(InsigniaTable.InsigniaName)
|
|
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.InsigniaId.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.InsigniaId.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
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.InsigniaId, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.InsigniaId, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with Insignia.InsigniaId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(InsigniaTable.InsigniaId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As InsigniaRecord = InsigniaTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As InsigniaRecord = DirectCast(rc(0), InsigniaRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.InsigniaIdSpecified Then
|
|
cvalue = itemValue.InsigniaId.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalInsigniaTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalInsigniaTable.InsigniaId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalInsigniaTable.InsigniaId.IsApplyDisplayAs Then
|
|
fvalue = PersonalInsigniaTable.GetDFKA(itemValue, PersonalInsigniaTable.InsigniaId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(InsigniaTable.InsigniaName)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.InsigniaId.Items.Add(newItem)
|
|
SetSelectedValue(Me.InsigniaId, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonalInsigniaRowDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Dim tc As PersonalInsigniaTableControl = DirectCast(GetParentControlObject(Me, "PersonalInsigniaTableControl"), PersonalInsigniaTableControl)
|
|
If Not (IsNothing(tc)) Then
|
|
If Not Me.IsNewRecord Then
|
|
tc.AddToDeletedRecordIds(DirectCast(Me, PersonalInsigniaTableControlRow))
|
|
End If
|
|
Me.Visible = False
|
|
tc.SetFormulaControls()
|
|
End If
|
|
|
|
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 PersonalInsigniaRowEditButton_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalInsigniaRowViewButton_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 = "../Shared/ConfigureViewRecord.aspx"
|
|
|
|
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
|
|
|
|
Protected Overridable Sub InsigniaId_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(InsigniaId.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(InsigniaId.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.InsigniaId.Items.Add(New ListItem(displayText, val))
|
|
Me.InsigniaId.SelectedIndex = Me.InsigniaId.Items.Count - 1
|
|
Me.Page.Session.Remove(InsigniaId.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(InsigniaId.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub GazetteDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub GazetteNO_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub GazettePage_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub GazetteSection_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub InsigniaDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub InsigniaReturn_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
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("BasePersonalInsigniaTableControlRow_Rec"), String)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me.ViewState("BasePersonalInsigniaTableControlRow_Rec") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataSource As PersonalInsigniaRecord
|
|
Public Property DataSource() As PersonalInsigniaRecord
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
|
|
Set(ByVal value As PersonalInsigniaRecord)
|
|
|
|
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 GazetteDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "GazetteDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GazetteNO() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "GazetteNO"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GazettePage() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "GazettePage"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GazetteSection() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "GazetteSection"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property InsigniaDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "InsigniaDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property InsigniaId() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "InsigniaId"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property InsigniaReturn() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "InsigniaReturn"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalInsigniaRecordRowSelection() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalInsigniaRecordRowSelection"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalInsigniaRowDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalInsigniaRowDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalInsigniaRowEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalInsigniaRowEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalInsigniaRowViewButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalInsigniaRowViewButton"), 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 PersonalInsigniaRecord = 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 PersonalInsigniaRecord
|
|
If Not Me.DataSource Is Nothing Then
|
|
Return Me.DataSource
|
|
End If
|
|
|
|
If Not Me.RecordUniqueId Is Nothing Then
|
|
|
|
Return PersonalInsigniaTable.GetRecord(Me.RecordUniqueId, True)
|
|
|
|
End If
|
|
|
|
' Localization.
|
|
|
|
Return Nothing
|
|
|
|
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 PersonalInsigniaTableControl control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalInsigniaTableControl.
|
|
Public Class BasePersonalInsigniaTableControl
|
|
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.
|
|
|
|
|
|
|
|
' 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(PersonalInsigniaTable.InsigniaDate, 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()
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalInsigniaDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteConfirm", "Persons") & "'));")
|
|
|
|
' Setup the pagination events.
|
|
|
|
AddHandler Me.PersonalInsigniaPagination.FirstPage.Click, AddressOf PersonalInsigniaPagination_FirstPage_Click
|
|
|
|
AddHandler Me.PersonalInsigniaPagination.LastPage.Click, AddressOf PersonalInsigniaPagination_LastPage_Click
|
|
|
|
AddHandler Me.PersonalInsigniaPagination.NextPage.Click, AddressOf PersonalInsigniaPagination_NextPage_Click
|
|
|
|
AddHandler Me.PersonalInsigniaPagination.PageSizeButton.Click, AddressOf PersonalInsigniaPagination_PageSizeButton_Click
|
|
|
|
AddHandler Me.PersonalInsigniaPagination.PreviousPage.Click, AddressOf PersonalInsigniaPagination_PreviousPage_Click
|
|
|
|
|
|
' Setup the sorting events.
|
|
|
|
AddHandler Me.GazetteDateLabel.Click, AddressOf GazetteDateLabel_Click
|
|
|
|
AddHandler Me.GazetteNOLabel.Click, AddressOf GazetteNOLabel_Click
|
|
|
|
AddHandler Me.GazettePageLabel.Click, AddressOf GazettePageLabel_Click
|
|
|
|
AddHandler Me.GazetteSectionLabel.Click, AddressOf GazetteSectionLabel_Click
|
|
|
|
AddHandler Me.InsigniaDateLabel1.Click, AddressOf InsigniaDateLabel1_Click
|
|
|
|
AddHandler Me.InsigniaIdLabel1.Click, AddressOf InsigniaIdLabel1_Click
|
|
|
|
AddHandler Me.InsigniaReturnLabel.Click, AddressOf InsigniaReturnLabel_Click
|
|
|
|
' Setup the button events.
|
|
|
|
AddHandler Me.PersonalInsigniaAddButton.Click, AddressOf PersonalInsigniaAddButton_Click
|
|
|
|
AddHandler Me.PersonalInsigniaDeleteButton.Click, AddressOf PersonalInsigniaDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalInsigniaEditButton.Click, AddressOf PersonalInsigniaEditButton_Click
|
|
|
|
AddHandler Me.PersonalInsigniaResetButton.Click, AddressOf PersonalInsigniaResetButton_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(PersonalInsigniaRecord)), PersonalInsigniaRecord())
|
|
' 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, PersonalInsigniaTable.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 PersonalInsigniaTableControlRow 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(PersonalInsigniaRecord)), PersonalInsigniaRecord())
|
|
Else ' Get the records from the database
|
|
Me.DataSource = PersonalInsigniaTable.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()
|
|
|
|
' Turn off the ToggleAll checkbox
|
|
Me.PersonalInsigniaToggleAll.Checked = False
|
|
|
|
|
|
' Initialize the page and grand totals. now
|
|
|
|
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
|
|
|
|
' Improve performance by prefetching display as records.
|
|
Me.PreFetchForeignKeyValues()
|
|
|
|
' 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, "PersonalInsigniaTableControlRepeater"), 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 PersonalInsigniaTableControlRow = DirectCast(repItem.FindControl("PersonalInsigniaTableControlRow"), PersonalInsigniaTableControlRow)
|
|
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
|
|
|
|
SetGazetteDateLabel()
|
|
SetGazetteNOLabel()
|
|
SetGazettePageLabel()
|
|
SetGazetteSectionLabel()
|
|
SetInsigniaDateLabel1()
|
|
SetInsigniaIdLabel1()
|
|
SetInsigniaReturnLabel()
|
|
|
|
|
|
|
|
|
|
|
|
SetPersonalInsigniaTableControlCollapsibleRegion()
|
|
|
|
' 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 Sub PreFetchForeignKeyValues()
|
|
If (IsNothing(Me.DataSource))
|
|
Return
|
|
End If
|
|
|
|
Me.Page.PregetDfkaRecords(PersonalInsigniaTable.InsigniaId, Me.DataSource)
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub RegisterPostback()
|
|
|
|
|
|
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.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(PersonalInsigniaTable.InsigniaDate, 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.PersonalInsigniaPagination.CurrentPage.Text = (Me.PageIndex + 1).ToString()
|
|
Else
|
|
Me.PersonalInsigniaPagination.CurrentPage.Text = "0"
|
|
End If
|
|
Me.PersonalInsigniaPagination.PageSize.Text = Me.PageSize.ToString()
|
|
Me.PersonalInsigniaPagination.TotalItems.Text = Me.TotalRecords.ToString()
|
|
Me.PersonalInsigniaPagination.TotalPages.Text = Me.TotalPages.ToString()
|
|
|
|
' Bind the buttons for PersonalInsigniaTableControl pagination.
|
|
|
|
Me.PersonalInsigniaPagination.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.PersonalInsigniaPagination.LastPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalInsigniaPagination.LastPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalInsigniaPagination.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.PersonalInsigniaPagination.NextPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalInsigniaPagination.NextPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalInsigniaPagination.NextPage.Enabled = Not (Me.PageIndex = Me.TotalPages - 1)
|
|
End If
|
|
|
|
Me.PersonalInsigniaPagination.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 PersonalInsigniaTableControlRow
|
|
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.
|
|
PersonalInsigniaTable.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 selectedRecordKeyValue as KeyValue = New KeyValue()
|
|
|
|
Dim personalIdRecordControlObj As Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalIdRecordControl"), Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(personalIdRecordControlObj) AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord()) AndAlso personalIdRecordControlObj.GetRecord().IsCreated AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord().PersonalId))
|
|
wc.iAND(PersonalInsigniaTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
selectedRecordKeyValue.AddElement(PersonalInsigniaTable.PersonalId.InternalName, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
Else
|
|
wc.RunQuery = False
|
|
Return wc
|
|
End If
|
|
|
|
HttpContext.Current.Session("PersonalInsigniaTableControlWhereClause") = selectedRecordKeyValue.ToXmlString()
|
|
|
|
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.
|
|
PersonalInsigniaTable.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)
|
|
|
|
Dim selectedRecordInPersonalIdRecordControl as String = DirectCast(HttpContext.Current.Session("PersonalInsigniaTableControlWhereClause"), String)
|
|
|
|
If Not selectedRecordInPersonalIdRecordControl Is Nothing AndAlso KeyValue.IsXmlKey(selectedRecordInPersonalIdRecordControl) Then
|
|
Dim selectedRecordKeyValue as KeyValue = KeyValue.XmlToKey(selectedRecordInPersonalIdRecordControl)
|
|
|
|
If Not IsNothing(selectedRecordKeyValue) AndAlso selectedRecordKeyValue.ContainsColumn(PersonalInsigniaTable.PersonalId) Then
|
|
wc.iAND(PersonalInsigniaTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, selectedRecordKeyValue.GetColumnValue(PersonalInsigniaTable.PersonalId).ToString())
|
|
End If
|
|
|
|
End If
|
|
|
|
' Adds clauses if values are selected in Filter controls which are configured in the page.
|
|
|
|
|
|
Return wc
|
|
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.PersonalInsigniaPagination.PageSize.Text.Trim <> "" Then
|
|
Try
|
|
'Me.PageSize = Integer.Parse(Me.PersonalInsigniaPagination.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, "PersonalInsigniaTableControlRepeater"), 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 PersonalInsigniaTableControlRow = DirectCast(repItem.FindControl("PersonalInsigniaTableControlRow"), PersonalInsigniaTableControlRow)
|
|
|
|
If recControl.Visible AndAlso recControl.IsNewRecord() Then
|
|
|
|
Dim rec As PersonalInsigniaRecord = New PersonalInsigniaRecord()
|
|
|
|
If recControl.GazetteDate.Text <> "" Then
|
|
rec.Parse(recControl.GazetteDate.Text, PersonalInsigniaTable.GazetteDate)
|
|
End If
|
|
If recControl.GazetteNO.Text <> "" Then
|
|
rec.Parse(recControl.GazetteNO.Text, PersonalInsigniaTable.GazetteNO)
|
|
End If
|
|
If recControl.GazettePage.Text <> "" Then
|
|
rec.Parse(recControl.GazettePage.Text, PersonalInsigniaTable.GazettePage)
|
|
End If
|
|
If recControl.GazetteSection.Text <> "" Then
|
|
rec.Parse(recControl.GazetteSection.Text, PersonalInsigniaTable.GazetteSection)
|
|
End If
|
|
If recControl.InsigniaDate.Text <> "" Then
|
|
rec.Parse(recControl.InsigniaDate.Text, PersonalInsigniaTable.InsigniaDate)
|
|
End If
|
|
If MiscUtils.IsValueSelected(recControl.InsigniaId) Then
|
|
rec.Parse(recControl.InsigniaId.SelectedItem.Value, PersonalInsigniaTable.InsigniaId)
|
|
End If
|
|
If recControl.InsigniaReturn.Text <> "" Then
|
|
rec.Parse(recControl.InsigniaReturn.Text, PersonalInsigniaTable.InsigniaReturn)
|
|
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 PersonalInsigniaRecord())
|
|
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(PersonalInsigniaRecord)), PersonalInsigniaRecord())
|
|
|
|
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 PersonalInsigniaTableControlRow)
|
|
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 PersonalInsigniaTableControlRow) 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 SetGazetteDateLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetGazetteNOLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetGazettePageLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetGazetteSectionLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetInsigniaDateLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetInsigniaIdLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetInsigniaReturnLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalInsigniaTableControlCollapsibleRegion()
|
|
|
|
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.
|
|
Dim added As Boolean = Me.AddNewRecord > 0
|
|
Me.LoadData()
|
|
Me.DataBind()
|
|
|
|
If added Then
|
|
Me.SetFocusToAddedRow()
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
Catch ex As Exception
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
End Sub
|
|
|
|
'this function sets focus to the first editable element in the new added row in the editable table
|
|
Protected Overridable Sub SetFocusToAddedRow()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalInsigniaTableControlRepeater"), System.Web.UI.WebControls.Repeater)
|
|
If rep Is Nothing OrElse rep.Items.Count = 0 Then Return
|
|
Dim repItem As System.Web.UI.WebControls.RepeaterItem
|
|
For Each repItem In rep.Items
|
|
'Load scripts to table rows
|
|
Me.Page.LoadFocusScripts(repItem)
|
|
Dim recControl As PersonalInsigniaTableControlRow = DirectCast(repItem.FindControl("PersonalInsigniaTableControlRow"), PersonalInsigniaTableControlRow)
|
|
If recControl.IsNewRecord Then
|
|
For Each field As Control In recControl.Controls
|
|
If field.Visible AndAlso Me.Page.IsControlEditable(field, False) Then
|
|
'set focus on the first editable field in the new row
|
|
field.Focus()
|
|
Dim updPan As UpdatePanel = DirectCast(Me.Page.FindControlRecursively("UpdatePanel1"), UpdatePanel)
|
|
If Not updPan Is Nothing Then updPan.Update()
|
|
Return
|
|
End If
|
|
Next
|
|
Return
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub SaveControlsToSession()
|
|
MyBase.SaveControlsToSession()
|
|
|
|
' Save filter controls to values to session.
|
|
|
|
|
|
'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.
|
|
|
|
HttpContext.Current.Session("AppRelativeVirtualPath") = Me.Page.AppRelativeVirtualPath
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub ClearControlsFromSession()
|
|
MyBase.ClearControlsFromSession()
|
|
|
|
' Clear filter controls values from the session.
|
|
|
|
|
|
' 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("PersonalInsigniaTableControl_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("PersonalInsigniaTableControl_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 PersonalInsigniaPagination_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 PersonalInsigniaPagination_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 PersonalInsigniaPagination_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 PersonalInsigniaPagination_PageSizeButton_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
Try
|
|
|
|
Me.DataChanged = True
|
|
|
|
Me.PageSize = Integer.Parse(Me.PersonalInsigniaPagination.PageSize.Text)
|
|
|
|
Me.PageIndex = Integer.Parse(Me.PersonalInsigniaPagination.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 PersonalInsigniaPagination_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 GazetteDateLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by GazetteDate when clicked.
|
|
|
|
' Get previous sorting state for GazetteDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalInsigniaTable.GazetteDate)
|
|
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 GazetteDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalInsigniaTable.GazetteDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by GazetteDate, 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 GazetteNOLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by GazetteNO when clicked.
|
|
|
|
' Get previous sorting state for GazetteNO.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalInsigniaTable.GazetteNO)
|
|
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 GazetteNO.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalInsigniaTable.GazetteNO, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by GazetteNO, 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 GazettePageLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by GazettePage when clicked.
|
|
|
|
' Get previous sorting state for GazettePage.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalInsigniaTable.GazettePage)
|
|
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 GazettePage.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalInsigniaTable.GazettePage, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by GazettePage, 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 GazetteSectionLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by GazetteSection when clicked.
|
|
|
|
' Get previous sorting state for GazetteSection.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalInsigniaTable.GazetteSection)
|
|
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 GazetteSection.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalInsigniaTable.GazetteSection, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by GazetteSection, 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 InsigniaDateLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by InsigniaDate when clicked.
|
|
|
|
' Get previous sorting state for InsigniaDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalInsigniaTable.InsigniaDate)
|
|
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 InsigniaDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalInsigniaTable.InsigniaDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by InsigniaDate, 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 InsigniaIdLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by InsigniaId when clicked.
|
|
|
|
' Get previous sorting state for InsigniaId.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalInsigniaTable.InsigniaId)
|
|
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 InsigniaId.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalInsigniaTable.InsigniaId, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by InsigniaId, 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 InsigniaReturnLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by InsigniaReturn when clicked.
|
|
|
|
' Get previous sorting state for InsigniaReturn.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalInsigniaTable.InsigniaReturn)
|
|
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 InsigniaReturn.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalInsigniaTable.InsigniaReturn, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by InsigniaReturn, 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 PersonalInsigniaAddButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
Me.AddNewRecord = 1
|
|
Me.DataChanged = 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 PersonalInsigniaDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Me.DeleteSelectedRecords(True)
|
|
Me.SetFormulaControls()
|
|
|
|
|
|
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 PersonalInsigniaEditButton_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalInsigniaResetButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
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(PersonalInsigniaTable.InsigniaDate, OrderByItem.OrderDir.Asc)
|
|
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
|
|
' 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 = PersonalInsigniaTable.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 PersonalInsigniaRecord = Nothing
|
|
Public Property DataSource() As PersonalInsigniaRecord ()
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
Set(ByVal value() As PersonalInsigniaRecord)
|
|
Me._DataSource = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Helper Properties"
|
|
|
|
Public ReadOnly Property GazetteDateLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "GazetteDateLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GazetteNOLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "GazetteNOLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GazettePageLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "GazettePageLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GazetteSectionLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "GazetteSectionLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property InsigniaDateLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "InsigniaDateLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property InsigniaIdLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "InsigniaIdLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property InsigniaReturnLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "InsigniaReturnLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalInsigniaAddButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalInsigniaAddButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalInsigniaDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalInsigniaDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalInsigniaEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalInsigniaEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalInsigniaPagination() As Persons.UI.IPagination
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalInsigniaPagination"), Persons.UI.IPagination)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalInsigniaResetButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalInsigniaResetButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalInsigniaTableControlCollapsibleRegion() As System.Web.UI.WebControls.Panel
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalInsigniaTableControlCollapsibleRegion"), System.Web.UI.WebControls.Panel)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalInsigniaToggleAll() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalInsigniaToggleAll"), System.Web.UI.WebControls.CheckBox)
|
|
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 PersonalInsigniaTableControlRow = 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 PersonalInsigniaRecord = 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 GetSelectedRecordIndex() As Integer
|
|
Dim counter As Integer = 0
|
|
Dim recControl As PersonalInsigniaTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalInsigniaRecordRowSelection.Checked Then
|
|
Return counter
|
|
End If
|
|
counter += 1
|
|
Next
|
|
Return -1
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControl() As PersonalInsigniaTableControlRow
|
|
Dim selectedList() As PersonalInsigniaTableControlRow = Me.GetSelectedRecordControls()
|
|
If selectedList.Length = 0 Then
|
|
Return Nothing
|
|
End If
|
|
Return selectedList(0)
|
|
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControls() As PersonalInsigniaTableControlRow()
|
|
|
|
Dim selectedList As ArrayList = New ArrayList(25)
|
|
Dim recControl As PersonalInsigniaTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalInsigniaRecordRowSelection IsNot Nothing AndAlso recControl.PersonalInsigniaRecordRowSelection.Checked Then
|
|
selectedList.Add(recControl)
|
|
End If
|
|
Next
|
|
Return DirectCast(selectedList.ToArray(GetType(PersonalInsigniaTableControlRow)), PersonalInsigniaTableControlRow())
|
|
|
|
End Function
|
|
|
|
Public Overridable Sub DeleteSelectedRecords(ByVal deferDeletion As Boolean)
|
|
Dim recList() As PersonalInsigniaTableControlRow = Me.GetSelectedRecordControls()
|
|
If recList.Length = 0 Then
|
|
' Localization.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoRecSelected", "Persons"))
|
|
End If
|
|
|
|
Dim recCtl As PersonalInsigniaTableControlRow
|
|
For Each recCtl In recList
|
|
If deferDeletion Then
|
|
If Not recCtl.IsNewRecord Then
|
|
|
|
Me.AddToDeletedRecordIds(recCtl)
|
|
|
|
End If
|
|
recCtl.Visible = False
|
|
|
|
recCtl.PersonalInsigniaRecordRowSelection.Checked = 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 PersonalInsigniaTableControlRow()
|
|
Dim recList As ArrayList = New ArrayList()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalInsigniaTableControlRepeater"), 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 PersonalInsigniaTableControlRow = DirectCast(repItem.FindControl("PersonalInsigniaTableControlRow"), PersonalInsigniaTableControlRow)
|
|
recList.Add(recControl)
|
|
|
|
Next
|
|
|
|
Return DirectCast(recList.ToArray(GetType(PersonalInsigniaTableControlRow)), PersonalInsigniaTableControlRow())
|
|
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 PersonalLanguageSkillTableControlRow control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalLanguageSkillTableControlRow.
|
|
Public Class BasePersonalLanguageSkillTableControlRow
|
|
Inherits Persons.UI.BaseApplicationRecordControl
|
|
|
|
' To customize, override this method in PersonalLanguageSkillTableControlRow.
|
|
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 PersonalLanguageSkillTableControlRow.
|
|
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)
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalLanguageSkillRowDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteRecordConfirm", "Persons") & "'));")
|
|
|
|
|
|
' Register the event handlers.
|
|
|
|
AddHandler Me.PersonalLanguageSkillRowDeleteButton.Click, AddressOf PersonalLanguageSkillRowDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalLanguageSkillRowEditButton.Click, AddressOf PersonalLanguageSkillRowEditButton_Click
|
|
|
|
AddHandler Me.PersonalLanguageSkillRowViewButton.Click, AddressOf PersonalLanguageSkillRowViewButton_Click
|
|
|
|
AddHandler Me.LanguageId.SelectedIndexChanged, AddressOf LanguageId_SelectedIndexChanged
|
|
|
|
AddHandler Me.Level.TextChanged, AddressOf Level_TextChanged
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Load the data from the database into the DataSource PersonalLanguageSkill 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 = PersonalLanguageSkillTable.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 BasePersonalLanguageSkillTableControl when the data for the entire
|
|
' table is loaded.
|
|
|
|
Me.DataSource = New PersonalLanguageSkillRecord()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
' Populate the UI controls using the DataSource. To customize, override this method in PersonalLanguageSkillTableControlRow.
|
|
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
|
|
|
|
SetLanguageId()
|
|
SetLevel()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 SetLanguageId()
|
|
|
|
' If selection was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.LanguageId.ID) Then
|
|
If Me.PreviousUIData(Me.LanguageId.ID) Is Nothing
|
|
Me.PopulateLanguageIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateLanguageIdDropDownList(Me.PreviousUIData(Me.LanguageId.ID).ToString(), 100)
|
|
End If
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the LanguageId DropDownList on the webpage with value from the
|
|
' PersonalLanguageSkill database record.
|
|
|
|
' Me.DataSource is the PersonalLanguageSkill record retrieved from the database.
|
|
' Me.LanguageId is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetLanguageId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.LanguageIdSpecified Then
|
|
|
|
' If the LanguageId is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateLanguageIdDropDownList(Me.DataSource.LanguageId.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' LanguageId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateLanguageIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateLanguageIdDropDownList(PersonalLanguageSkillTable.LanguageId.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetLevel()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Level.ID) Then
|
|
|
|
Me.Level.Text = Me.PreviousUIData(Me.Level.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Level TextBox on the webpage with value from the
|
|
' PersonalLanguageSkill database record.
|
|
|
|
' Me.DataSource is the PersonalLanguageSkill record retrieved from the database.
|
|
' Me.Level is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetLevel()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.LevelSpecified Then
|
|
|
|
' If the Level is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalLanguageSkillTable.Level)
|
|
|
|
Me.Level.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Level is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Level.Text = PersonalLanguageSkillTable.Level.Format(PersonalLanguageSkillTable.Level.DefaultValue)
|
|
|
|
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 PersonalLanguageSkillTableControlRow.
|
|
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()
|
|
|
|
Dim parentCtrl As PersonalIdRecordControl
|
|
|
|
|
|
parentCtrl = DirectCast(Me.Page.FindControlRecursively("PersonalIdRecordControl"), PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(parentCtrl) AndAlso IsNothing(parentCtrl.DataSource))
|
|
' Load the record if it is not loaded yet.
|
|
parentCtrl.LoadData()
|
|
End If
|
|
If (IsNothing(parentCtrl) OrElse IsNothing(parentCtrl.DataSource))
|
|
' Get the error message from the application resource file.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoParentRecId", "Persons"))
|
|
End If
|
|
|
|
Me.DataSource.PersonalId = parentCtrl.DataSource.PersonalId
|
|
|
|
' 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, "PersonalLanguageSkillTableControl"), PersonalLanguageSkillTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalLanguageSkillTableControl"), PersonalLanguageSkillTableControl).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 PersonalLanguageSkillTableControlRow.
|
|
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.
|
|
|
|
GetLanguageId()
|
|
GetLevel()
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub GetLanguageId()
|
|
|
|
' Retrieve the value entered by the user on the LanguageId ASP:DropDownList, and
|
|
' save it into the LanguageId field in DataSource PersonalLanguageSkill record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.LanguageId), PersonalLanguageSkillTable.LanguageId)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetLevel()
|
|
|
|
' Retrieve the value entered by the user on the Level ASP:TextBox, and
|
|
' save it into the Level field in DataSource PersonalLanguageSkill record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Level.Text, PersonalLanguageSkillTable.Level)
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
' To customize, override this method in PersonalLanguageSkillTableControlRow.
|
|
|
|
Public Overridable Function CreateWhereClause() As WhereClause
|
|
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
|
|
|
|
' To customize, override this method in PersonalLanguageSkillTableControlRow.
|
|
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)
|
|
PersonalLanguageSkillTable.DeleteRecord(pkValue)
|
|
|
|
DirectCast(GetParentControlObject(Me, "PersonalLanguageSkillTableControl"), PersonalLanguageSkillTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalLanguageSkillTableControl"), PersonalLanguageSkillTableControl).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
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_LanguageIdDropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the Language table.
|
|
' Examples:
|
|
' wc.iAND(LanguageTable.Language0, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(LanguageTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
' Fill the LanguageId list.
|
|
Protected Overridable Sub PopulateLanguageIdDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.LanguageId.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.LanguageId.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_LanguageIdDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_LanguageIdDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(LanguageTable.Language0, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim itemValues() As LanguageRecord = Nothing
|
|
Dim evaluator As New FormulaEvaluator
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
Do
|
|
itemValues = LanguageTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
For each itemValue As LanguageRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.LanguageIdSpecified Then
|
|
cvalue = itemValue.LanguageId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.LanguageId.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalLanguageSkillTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalLanguageSkillTable.LanguageId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalLanguageSkillTable.LanguageId.IsApplyDisplayAs Then
|
|
fvalue = PersonalLanguageSkillTable.GetDFKA(itemValue, PersonalLanguageSkillTable.LanguageId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(LanguageTable.Language0)
|
|
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.LanguageId.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.LanguageId.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
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.LanguageId, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.LanguageId, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with Language.LanguageId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(LanguageTable.LanguageId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As LanguageRecord = LanguageTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As LanguageRecord = DirectCast(rc(0), LanguageRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.LanguageIdSpecified Then
|
|
cvalue = itemValue.LanguageId.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalLanguageSkillTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalLanguageSkillTable.LanguageId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalLanguageSkillTable.LanguageId.IsApplyDisplayAs Then
|
|
fvalue = PersonalLanguageSkillTable.GetDFKA(itemValue, PersonalLanguageSkillTable.LanguageId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(LanguageTable.Language0)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.LanguageId.Items.Add(newItem)
|
|
SetSelectedValue(Me.LanguageId, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonalLanguageSkillRowDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Dim tc As PersonalLanguageSkillTableControl = DirectCast(GetParentControlObject(Me, "PersonalLanguageSkillTableControl"), PersonalLanguageSkillTableControl)
|
|
If Not (IsNothing(tc)) Then
|
|
If Not Me.IsNewRecord Then
|
|
tc.AddToDeletedRecordIds(DirectCast(Me, PersonalLanguageSkillTableControlRow))
|
|
End If
|
|
Me.Visible = False
|
|
tc.SetFormulaControls()
|
|
End If
|
|
|
|
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 PersonalLanguageSkillRowEditButton_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalLanguageSkillRowViewButton_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 = "../Shared/ConfigureViewRecord.aspx"
|
|
|
|
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
|
|
|
|
Protected Overridable Sub LanguageId_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(LanguageId.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(LanguageId.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.LanguageId.Items.Add(New ListItem(displayText, val))
|
|
Me.LanguageId.SelectedIndex = Me.LanguageId.Items.Count - 1
|
|
Me.Page.Session.Remove(LanguageId.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(LanguageId.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Level_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
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("BasePersonalLanguageSkillTableControlRow_Rec"), String)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me.ViewState("BasePersonalLanguageSkillTableControlRow_Rec") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataSource As PersonalLanguageSkillRecord
|
|
Public Property DataSource() As PersonalLanguageSkillRecord
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
|
|
Set(ByVal value As PersonalLanguageSkillRecord)
|
|
|
|
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 LanguageId() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "LanguageId"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Level() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Level"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalLanguageSkillRecordRowSelection() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalLanguageSkillRecordRowSelection"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalLanguageSkillRowDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalLanguageSkillRowDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalLanguageSkillRowEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalLanguageSkillRowEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalLanguageSkillRowViewButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalLanguageSkillRowViewButton"), 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 PersonalLanguageSkillRecord = 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 PersonalLanguageSkillRecord
|
|
If Not Me.DataSource Is Nothing Then
|
|
Return Me.DataSource
|
|
End If
|
|
|
|
If Not Me.RecordUniqueId Is Nothing Then
|
|
|
|
Return PersonalLanguageSkillTable.GetRecord(Me.RecordUniqueId, True)
|
|
|
|
End If
|
|
|
|
' Localization.
|
|
|
|
Return Nothing
|
|
|
|
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 PersonalLanguageSkillTableControl control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalLanguageSkillTableControl.
|
|
Public Class BasePersonalLanguageSkillTableControl
|
|
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.
|
|
|
|
|
|
|
|
' 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)
|
|
|
|
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()
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalLanguageSkillDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteConfirm", "Persons") & "'));")
|
|
|
|
' Setup the pagination events.
|
|
|
|
AddHandler Me.PersonalLanguageSkillPagination.FirstPage.Click, AddressOf PersonalLanguageSkillPagination_FirstPage_Click
|
|
|
|
AddHandler Me.PersonalLanguageSkillPagination.LastPage.Click, AddressOf PersonalLanguageSkillPagination_LastPage_Click
|
|
|
|
AddHandler Me.PersonalLanguageSkillPagination.NextPage.Click, AddressOf PersonalLanguageSkillPagination_NextPage_Click
|
|
|
|
AddHandler Me.PersonalLanguageSkillPagination.PageSizeButton.Click, AddressOf PersonalLanguageSkillPagination_PageSizeButton_Click
|
|
|
|
AddHandler Me.PersonalLanguageSkillPagination.PreviousPage.Click, AddressOf PersonalLanguageSkillPagination_PreviousPage_Click
|
|
|
|
|
|
' Setup the sorting events.
|
|
|
|
AddHandler Me.LanguageIdLabel1.Click, AddressOf LanguageIdLabel1_Click
|
|
|
|
AddHandler Me.LevelLabel1.Click, AddressOf LevelLabel1_Click
|
|
|
|
' Setup the button events.
|
|
|
|
AddHandler Me.PersonalLanguageSkillAddButton.Click, AddressOf PersonalLanguageSkillAddButton_Click
|
|
|
|
AddHandler Me.PersonalLanguageSkillDeleteButton.Click, AddressOf PersonalLanguageSkillDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalLanguageSkillEditButton.Click, AddressOf PersonalLanguageSkillEditButton_Click
|
|
|
|
AddHandler Me.PersonalLanguageSkillResetButton.Click, AddressOf PersonalLanguageSkillResetButton_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(PersonalLanguageSkillRecord)), PersonalLanguageSkillRecord())
|
|
' 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, PersonalLanguageSkillTable.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 PersonalLanguageSkillTableControlRow 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(PersonalLanguageSkillRecord)), PersonalLanguageSkillRecord())
|
|
Else ' Get the records from the database
|
|
Me.DataSource = PersonalLanguageSkillTable.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()
|
|
|
|
' Turn off the ToggleAll checkbox
|
|
Me.PersonalLanguageSkillToggleAll.Checked = False
|
|
|
|
|
|
' Initialize the page and grand totals. now
|
|
|
|
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
|
|
|
|
' Improve performance by prefetching display as records.
|
|
Me.PreFetchForeignKeyValues()
|
|
|
|
' 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, "PersonalLanguageSkillTableControlRepeater"), 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 PersonalLanguageSkillTableControlRow = DirectCast(repItem.FindControl("PersonalLanguageSkillTableControlRow"), PersonalLanguageSkillTableControlRow)
|
|
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
|
|
|
|
SetLanguageIdLabel1()
|
|
SetLevelLabel1()
|
|
|
|
|
|
|
|
|
|
|
|
SetPersonalLanguageSkillTableControlCollapsibleRegion()
|
|
|
|
' 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 Sub PreFetchForeignKeyValues()
|
|
If (IsNothing(Me.DataSource))
|
|
Return
|
|
End If
|
|
|
|
Me.Page.PregetDfkaRecords(PersonalLanguageSkillTable.LanguageId, Me.DataSource)
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub RegisterPostback()
|
|
|
|
|
|
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.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)
|
|
|
|
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.PersonalLanguageSkillPagination.CurrentPage.Text = (Me.PageIndex + 1).ToString()
|
|
Else
|
|
Me.PersonalLanguageSkillPagination.CurrentPage.Text = "0"
|
|
End If
|
|
Me.PersonalLanguageSkillPagination.PageSize.Text = Me.PageSize.ToString()
|
|
Me.PersonalLanguageSkillPagination.TotalItems.Text = Me.TotalRecords.ToString()
|
|
Me.PersonalLanguageSkillPagination.TotalPages.Text = Me.TotalPages.ToString()
|
|
|
|
' Bind the buttons for PersonalLanguageSkillTableControl pagination.
|
|
|
|
Me.PersonalLanguageSkillPagination.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.PersonalLanguageSkillPagination.LastPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalLanguageSkillPagination.LastPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalLanguageSkillPagination.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.PersonalLanguageSkillPagination.NextPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalLanguageSkillPagination.NextPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalLanguageSkillPagination.NextPage.Enabled = Not (Me.PageIndex = Me.TotalPages - 1)
|
|
End If
|
|
|
|
Me.PersonalLanguageSkillPagination.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 PersonalLanguageSkillTableControlRow
|
|
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.
|
|
PersonalLanguageSkillTable.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 selectedRecordKeyValue as KeyValue = New KeyValue()
|
|
|
|
Dim personalIdRecordControlObj As Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalIdRecordControl"), Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(personalIdRecordControlObj) AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord()) AndAlso personalIdRecordControlObj.GetRecord().IsCreated AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord().PersonalId))
|
|
wc.iAND(PersonalLanguageSkillTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
selectedRecordKeyValue.AddElement(PersonalLanguageSkillTable.PersonalId.InternalName, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
Else
|
|
wc.RunQuery = False
|
|
Return wc
|
|
End If
|
|
|
|
HttpContext.Current.Session("PersonalLanguageSkillTableControlWhereClause") = selectedRecordKeyValue.ToXmlString()
|
|
|
|
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.
|
|
PersonalLanguageSkillTable.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)
|
|
|
|
Dim selectedRecordInPersonalIdRecordControl as String = DirectCast(HttpContext.Current.Session("PersonalLanguageSkillTableControlWhereClause"), String)
|
|
|
|
If Not selectedRecordInPersonalIdRecordControl Is Nothing AndAlso KeyValue.IsXmlKey(selectedRecordInPersonalIdRecordControl) Then
|
|
Dim selectedRecordKeyValue as KeyValue = KeyValue.XmlToKey(selectedRecordInPersonalIdRecordControl)
|
|
|
|
If Not IsNothing(selectedRecordKeyValue) AndAlso selectedRecordKeyValue.ContainsColumn(PersonalLanguageSkillTable.PersonalId) Then
|
|
wc.iAND(PersonalLanguageSkillTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, selectedRecordKeyValue.GetColumnValue(PersonalLanguageSkillTable.PersonalId).ToString())
|
|
End If
|
|
|
|
End If
|
|
|
|
' Adds clauses if values are selected in Filter controls which are configured in the page.
|
|
|
|
|
|
Return wc
|
|
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.PersonalLanguageSkillPagination.PageSize.Text.Trim <> "" Then
|
|
Try
|
|
'Me.PageSize = Integer.Parse(Me.PersonalLanguageSkillPagination.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, "PersonalLanguageSkillTableControlRepeater"), 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 PersonalLanguageSkillTableControlRow = DirectCast(repItem.FindControl("PersonalLanguageSkillTableControlRow"), PersonalLanguageSkillTableControlRow)
|
|
|
|
If recControl.Visible AndAlso recControl.IsNewRecord() Then
|
|
|
|
Dim rec As PersonalLanguageSkillRecord = New PersonalLanguageSkillRecord()
|
|
|
|
If MiscUtils.IsValueSelected(recControl.LanguageId) Then
|
|
rec.Parse(recControl.LanguageId.SelectedItem.Value, PersonalLanguageSkillTable.LanguageId)
|
|
End If
|
|
If recControl.Level.Text <> "" Then
|
|
rec.Parse(recControl.Level.Text, PersonalLanguageSkillTable.Level)
|
|
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 PersonalLanguageSkillRecord())
|
|
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(PersonalLanguageSkillRecord)), PersonalLanguageSkillRecord())
|
|
|
|
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 PersonalLanguageSkillTableControlRow)
|
|
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 PersonalLanguageSkillTableControlRow) 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 SetLanguageIdLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetLevelLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalLanguageSkillTableControlCollapsibleRegion()
|
|
|
|
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.
|
|
Dim added As Boolean = Me.AddNewRecord > 0
|
|
Me.LoadData()
|
|
Me.DataBind()
|
|
|
|
If added Then
|
|
Me.SetFocusToAddedRow()
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
Catch ex As Exception
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
End Sub
|
|
|
|
'this function sets focus to the first editable element in the new added row in the editable table
|
|
Protected Overridable Sub SetFocusToAddedRow()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalLanguageSkillTableControlRepeater"), System.Web.UI.WebControls.Repeater)
|
|
If rep Is Nothing OrElse rep.Items.Count = 0 Then Return
|
|
Dim repItem As System.Web.UI.WebControls.RepeaterItem
|
|
For Each repItem In rep.Items
|
|
'Load scripts to table rows
|
|
Me.Page.LoadFocusScripts(repItem)
|
|
Dim recControl As PersonalLanguageSkillTableControlRow = DirectCast(repItem.FindControl("PersonalLanguageSkillTableControlRow"), PersonalLanguageSkillTableControlRow)
|
|
If recControl.IsNewRecord Then
|
|
For Each field As Control In recControl.Controls
|
|
If field.Visible AndAlso Me.Page.IsControlEditable(field, False) Then
|
|
'set focus on the first editable field in the new row
|
|
field.Focus()
|
|
Dim updPan As UpdatePanel = DirectCast(Me.Page.FindControlRecursively("UpdatePanel1"), UpdatePanel)
|
|
If Not updPan Is Nothing Then updPan.Update()
|
|
Return
|
|
End If
|
|
Next
|
|
Return
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub SaveControlsToSession()
|
|
MyBase.SaveControlsToSession()
|
|
|
|
' Save filter controls to values to session.
|
|
|
|
|
|
'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.
|
|
|
|
HttpContext.Current.Session("AppRelativeVirtualPath") = Me.Page.AppRelativeVirtualPath
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub ClearControlsFromSession()
|
|
MyBase.ClearControlsFromSession()
|
|
|
|
' Clear filter controls values from the session.
|
|
|
|
|
|
' 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("PersonalLanguageSkillTableControl_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("PersonalLanguageSkillTableControl_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 PersonalLanguageSkillPagination_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 PersonalLanguageSkillPagination_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 PersonalLanguageSkillPagination_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 PersonalLanguageSkillPagination_PageSizeButton_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
Try
|
|
|
|
Me.DataChanged = True
|
|
|
|
Me.PageSize = Integer.Parse(Me.PersonalLanguageSkillPagination.PageSize.Text)
|
|
|
|
Me.PageIndex = Integer.Parse(Me.PersonalLanguageSkillPagination.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 PersonalLanguageSkillPagination_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 LanguageIdLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by LanguageId when clicked.
|
|
|
|
' Get previous sorting state for LanguageId.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalLanguageSkillTable.LanguageId)
|
|
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 LanguageId.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalLanguageSkillTable.LanguageId, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by LanguageId, 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 LevelLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Level when clicked.
|
|
|
|
' Get previous sorting state for Level.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalLanguageSkillTable.Level)
|
|
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 Level.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalLanguageSkillTable.Level, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Level, 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 PersonalLanguageSkillAddButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
Me.AddNewRecord = 1
|
|
Me.DataChanged = 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 PersonalLanguageSkillDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Me.DeleteSelectedRecords(True)
|
|
Me.SetFormulaControls()
|
|
|
|
|
|
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 PersonalLanguageSkillEditButton_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalLanguageSkillResetButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
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)
|
|
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
|
|
' 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 = PersonalLanguageSkillTable.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 PersonalLanguageSkillRecord = Nothing
|
|
Public Property DataSource() As PersonalLanguageSkillRecord ()
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
Set(ByVal value() As PersonalLanguageSkillRecord)
|
|
Me._DataSource = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Helper Properties"
|
|
|
|
Public ReadOnly Property LanguageIdLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "LanguageIdLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property LevelLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "LevelLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalLanguageSkillAddButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalLanguageSkillAddButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalLanguageSkillDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalLanguageSkillDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalLanguageSkillEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalLanguageSkillEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalLanguageSkillPagination() As Persons.UI.IPagination
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalLanguageSkillPagination"), Persons.UI.IPagination)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalLanguageSkillResetButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalLanguageSkillResetButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalLanguageSkillTableControlCollapsibleRegion() As System.Web.UI.WebControls.Panel
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalLanguageSkillTableControlCollapsibleRegion"), System.Web.UI.WebControls.Panel)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalLanguageSkillToggleAll() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalLanguageSkillToggleAll"), System.Web.UI.WebControls.CheckBox)
|
|
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 PersonalLanguageSkillTableControlRow = 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 PersonalLanguageSkillRecord = 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 GetSelectedRecordIndex() As Integer
|
|
Dim counter As Integer = 0
|
|
Dim recControl As PersonalLanguageSkillTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalLanguageSkillRecordRowSelection.Checked Then
|
|
Return counter
|
|
End If
|
|
counter += 1
|
|
Next
|
|
Return -1
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControl() As PersonalLanguageSkillTableControlRow
|
|
Dim selectedList() As PersonalLanguageSkillTableControlRow = Me.GetSelectedRecordControls()
|
|
If selectedList.Length = 0 Then
|
|
Return Nothing
|
|
End If
|
|
Return selectedList(0)
|
|
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControls() As PersonalLanguageSkillTableControlRow()
|
|
|
|
Dim selectedList As ArrayList = New ArrayList(25)
|
|
Dim recControl As PersonalLanguageSkillTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalLanguageSkillRecordRowSelection IsNot Nothing AndAlso recControl.PersonalLanguageSkillRecordRowSelection.Checked Then
|
|
selectedList.Add(recControl)
|
|
End If
|
|
Next
|
|
Return DirectCast(selectedList.ToArray(GetType(PersonalLanguageSkillTableControlRow)), PersonalLanguageSkillTableControlRow())
|
|
|
|
End Function
|
|
|
|
Public Overridable Sub DeleteSelectedRecords(ByVal deferDeletion As Boolean)
|
|
Dim recList() As PersonalLanguageSkillTableControlRow = Me.GetSelectedRecordControls()
|
|
If recList.Length = 0 Then
|
|
' Localization.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoRecSelected", "Persons"))
|
|
End If
|
|
|
|
Dim recCtl As PersonalLanguageSkillTableControlRow
|
|
For Each recCtl In recList
|
|
If deferDeletion Then
|
|
If Not recCtl.IsNewRecord Then
|
|
|
|
Me.AddToDeletedRecordIds(recCtl)
|
|
|
|
End If
|
|
recCtl.Visible = False
|
|
|
|
recCtl.PersonalLanguageSkillRecordRowSelection.Checked = 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 PersonalLanguageSkillTableControlRow()
|
|
Dim recList As ArrayList = New ArrayList()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalLanguageSkillTableControlRepeater"), 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 PersonalLanguageSkillTableControlRow = DirectCast(repItem.FindControl("PersonalLanguageSkillTableControlRow"), PersonalLanguageSkillTableControlRow)
|
|
recList.Add(recControl)
|
|
|
|
Next
|
|
|
|
Return DirectCast(recList.ToArray(GetType(PersonalLanguageSkillTableControlRow)), PersonalLanguageSkillTableControlRow())
|
|
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 PersonalNameTableControlRow control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalNameTableControlRow.
|
|
Public Class BasePersonalNameTableControlRow
|
|
Inherits Persons.UI.BaseApplicationRecordControl
|
|
|
|
' To customize, override this method in PersonalNameTableControlRow.
|
|
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 PersonalNameTableControlRow.
|
|
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)
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalNameRowDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteRecordConfirm", "Persons") & "'));")
|
|
|
|
|
|
' Register the event handlers.
|
|
|
|
AddHandler Me.PersonalNameRowDeleteButton.Click, AddressOf PersonalNameRowDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalNameRowEditButton.Click, AddressOf PersonalNameRowEditButton_Click
|
|
|
|
AddHandler Me.PersonalNameRowViewButton.Click, AddressOf PersonalNameRowViewButton_Click
|
|
|
|
AddHandler Me.NameDate.TextChanged, AddressOf NameDate_TextChanged
|
|
|
|
AddHandler Me.PersonalLastName1.TextChanged, AddressOf PersonalLastName1_TextChanged
|
|
|
|
AddHandler Me.PersonalName1.TextChanged, AddressOf PersonalName1_TextChanged
|
|
|
|
AddHandler Me.Ref2.TextChanged, AddressOf Ref2_TextChanged
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Load the data from the database into the DataSource PersonalName 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 = PersonalNameTable.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 BasePersonalNameTableControl when the data for the entire
|
|
' table is loaded.
|
|
|
|
Me.DataSource = New PersonalNameRecord()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
' Populate the UI controls using the DataSource. To customize, override this method in PersonalNameTableControlRow.
|
|
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
|
|
|
|
SetNameDate()
|
|
SetPersonalLastName1()
|
|
SetPersonalName1()
|
|
|
|
|
|
|
|
|
|
SetRef2()
|
|
|
|
|
|
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 SetNameDate()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.NameDate.ID) Then
|
|
|
|
Me.NameDate.Text = Me.PreviousUIData(Me.NameDate.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the NameDate TextBox on the webpage with value from the
|
|
' PersonalName database record.
|
|
|
|
' Me.DataSource is the PersonalName record retrieved from the database.
|
|
' Me.NameDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetNameDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.NameDateSpecified Then
|
|
|
|
' If the NameDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalNameTable.NameDate, "d MMM yy")
|
|
|
|
Me.NameDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' NameDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.NameDate.Text = PersonalNameTable.NameDate.Format(PersonalNameTable.NameDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalLastName1()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.PersonalLastName1.ID) Then
|
|
|
|
Me.PersonalLastName1.Text = Me.PreviousUIData(Me.PersonalLastName1.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the PersonalLastName TextBox on the webpage with value from the
|
|
' PersonalName database record.
|
|
|
|
' Me.DataSource is the PersonalName record retrieved from the database.
|
|
' Me.PersonalLastName1 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetPersonalLastName1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.PersonalLastNameSpecified Then
|
|
|
|
' If the PersonalLastName is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalNameTable.PersonalLastName)
|
|
|
|
Me.PersonalLastName1.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' PersonalLastName is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.PersonalLastName1.Text = PersonalNameTable.PersonalLastName.Format(PersonalNameTable.PersonalLastName.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalName1()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.PersonalName1.ID) Then
|
|
|
|
Me.PersonalName1.Text = Me.PreviousUIData(Me.PersonalName1.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the PersonalName TextBox on the webpage with value from the
|
|
' PersonalName database record.
|
|
|
|
' Me.DataSource is the PersonalName record retrieved from the database.
|
|
' Me.PersonalName1 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetPersonalName1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.PersonalNameSpecified Then
|
|
|
|
' If the PersonalName is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalNameTable.PersonalName)
|
|
|
|
Me.PersonalName1.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' PersonalName is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.PersonalName1.Text = PersonalNameTable.PersonalName.Format(PersonalNameTable.PersonalName.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRef2()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Ref2.ID) Then
|
|
|
|
Me.Ref2.Text = Me.PreviousUIData(Me.Ref2.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Ref TextBox on the webpage with value from the
|
|
' PersonalName database record.
|
|
|
|
' Me.DataSource is the PersonalName record retrieved from the database.
|
|
' Me.Ref2 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRef2()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.Ref0Specified Then
|
|
|
|
' If the Ref is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalNameTable.Ref0)
|
|
|
|
Me.Ref2.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Ref is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Ref2.Text = PersonalNameTable.Ref0.Format(PersonalNameTable.Ref0.DefaultValue)
|
|
|
|
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 PersonalNameTableControlRow.
|
|
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()
|
|
|
|
Dim parentCtrl As PersonalIdRecordControl
|
|
|
|
|
|
parentCtrl = DirectCast(Me.Page.FindControlRecursively("PersonalIdRecordControl"), PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(parentCtrl) AndAlso IsNothing(parentCtrl.DataSource))
|
|
' Load the record if it is not loaded yet.
|
|
parentCtrl.LoadData()
|
|
End If
|
|
If (IsNothing(parentCtrl) OrElse IsNothing(parentCtrl.DataSource))
|
|
' Get the error message from the application resource file.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoParentRecId", "Persons"))
|
|
End If
|
|
|
|
Me.DataSource.PersonalId = parentCtrl.DataSource.PersonalId
|
|
|
|
' 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, "PersonalNameTableControl"), PersonalNameTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalNameTableControl"), PersonalNameTableControl).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 PersonalNameTableControlRow.
|
|
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.
|
|
|
|
GetNameDate()
|
|
GetPersonalLastName1()
|
|
GetPersonalName1()
|
|
GetRef2()
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub GetNameDate()
|
|
|
|
' Retrieve the value entered by the user on the NameDate ASP:TextBox, and
|
|
' save it into the NameDate field in DataSource PersonalName record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.NameDate.Text, PersonalNameTable.NameDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetPersonalLastName1()
|
|
|
|
' Retrieve the value entered by the user on the PersonalLastName ASP:TextBox, and
|
|
' save it into the PersonalLastName field in DataSource PersonalName record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.PersonalLastName1.Text, PersonalNameTable.PersonalLastName)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetPersonalName1()
|
|
|
|
' Retrieve the value entered by the user on the PersonalName ASP:TextBox, and
|
|
' save it into the PersonalName field in DataSource PersonalName record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.PersonalName1.Text, PersonalNameTable.PersonalName)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRef2()
|
|
|
|
' Retrieve the value entered by the user on the Ref ASP:TextBox, and
|
|
' save it into the Ref field in DataSource PersonalName record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Ref2.Text, PersonalNameTable.Ref0)
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
' To customize, override this method in PersonalNameTableControlRow.
|
|
|
|
Public Overridable Function CreateWhereClause() As WhereClause
|
|
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
|
|
|
|
' To customize, override this method in PersonalNameTableControlRow.
|
|
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)
|
|
PersonalNameTable.DeleteRecord(pkValue)
|
|
|
|
DirectCast(GetParentControlObject(Me, "PersonalNameTableControl"), PersonalNameTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalNameTableControl"), PersonalNameTableControl).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
|
|
|
|
|
|
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 PersonalNameRowDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Dim tc As PersonalNameTableControl = DirectCast(GetParentControlObject(Me, "PersonalNameTableControl"), PersonalNameTableControl)
|
|
If Not (IsNothing(tc)) Then
|
|
If Not Me.IsNewRecord Then
|
|
tc.AddToDeletedRecordIds(DirectCast(Me, PersonalNameTableControlRow))
|
|
End If
|
|
Me.Visible = False
|
|
tc.SetFormulaControls()
|
|
End If
|
|
|
|
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 PersonalNameRowEditButton_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalNameRowViewButton_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 = "../Shared/ConfigureViewRecord.aspx"
|
|
|
|
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
|
|
|
|
Protected Overridable Sub NameDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub PersonalLastName1_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub PersonalName1_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Ref2_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
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("BasePersonalNameTableControlRow_Rec"), String)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me.ViewState("BasePersonalNameTableControlRow_Rec") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataSource As PersonalNameRecord
|
|
Public Property DataSource() As PersonalNameRecord
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
|
|
Set(ByVal value As PersonalNameRecord)
|
|
|
|
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 NameDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "NameDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalLastName1() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalLastName1"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalName1() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalName1"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalNameRecordRowSelection() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalNameRecordRowSelection"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalNameRowDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalNameRowDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalNameRowEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalNameRowEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalNameRowViewButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalNameRowViewButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Ref2() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Ref2"), System.Web.UI.WebControls.TextBox)
|
|
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 PersonalNameRecord = 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 PersonalNameRecord
|
|
If Not Me.DataSource Is Nothing Then
|
|
Return Me.DataSource
|
|
End If
|
|
|
|
If Not Me.RecordUniqueId Is Nothing Then
|
|
|
|
Return PersonalNameTable.GetRecord(Me.RecordUniqueId, True)
|
|
|
|
End If
|
|
|
|
' Localization.
|
|
|
|
Return Nothing
|
|
|
|
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 PersonalNameTableControl control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalNameTableControl.
|
|
Public Class BasePersonalNameTableControl
|
|
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.
|
|
|
|
|
|
|
|
' 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(PersonalNameTable.NameDate, 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()
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalNameDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteConfirm", "Persons") & "'));")
|
|
|
|
' Setup the pagination events.
|
|
|
|
AddHandler Me.PersonalNamePagination.FirstPage.Click, AddressOf PersonalNamePagination_FirstPage_Click
|
|
|
|
AddHandler Me.PersonalNamePagination.LastPage.Click, AddressOf PersonalNamePagination_LastPage_Click
|
|
|
|
AddHandler Me.PersonalNamePagination.NextPage.Click, AddressOf PersonalNamePagination_NextPage_Click
|
|
|
|
AddHandler Me.PersonalNamePagination.PageSizeButton.Click, AddressOf PersonalNamePagination_PageSizeButton_Click
|
|
|
|
AddHandler Me.PersonalNamePagination.PreviousPage.Click, AddressOf PersonalNamePagination_PreviousPage_Click
|
|
|
|
|
|
' Setup the sorting events.
|
|
|
|
AddHandler Me.NameDateLabel.Click, AddressOf NameDateLabel_Click
|
|
|
|
AddHandler Me.PersonalLastNameLabel2.Click, AddressOf PersonalLastNameLabel2_Click
|
|
|
|
AddHandler Me.PersonalNameLabel2.Click, AddressOf PersonalNameLabel2_Click
|
|
|
|
AddHandler Me.RefLabel1.Click, AddressOf RefLabel1_Click
|
|
|
|
' Setup the button events.
|
|
|
|
AddHandler Me.PersonalNameAddButton.Click, AddressOf PersonalNameAddButton_Click
|
|
|
|
AddHandler Me.PersonalNameDeleteButton.Click, AddressOf PersonalNameDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalNameEditButton.Click, AddressOf PersonalNameEditButton_Click
|
|
|
|
AddHandler Me.PersonalNameResetButton.Click, AddressOf PersonalNameResetButton_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(PersonalNameRecord)), PersonalNameRecord())
|
|
' 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, PersonalNameTable.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 PersonalNameTableControlRow 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(PersonalNameRecord)), PersonalNameRecord())
|
|
Else ' Get the records from the database
|
|
Me.DataSource = PersonalNameTable.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()
|
|
|
|
' Turn off the ToggleAll checkbox
|
|
Me.PersonalNameToggleAll.Checked = False
|
|
|
|
|
|
' Initialize the page and grand totals. now
|
|
|
|
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, "PersonalNameTableControlRepeater"), 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 PersonalNameTableControlRow = DirectCast(repItem.FindControl("PersonalNameTableControlRow"), PersonalNameTableControlRow)
|
|
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
|
|
|
|
SetNameDateLabel()
|
|
SetPersonalLastNameLabel2()
|
|
|
|
|
|
|
|
SetPersonalNameLabel2()
|
|
|
|
|
|
SetPersonalNameTableControlCollapsibleRegion()
|
|
|
|
SetRefLabel1()
|
|
' 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()
|
|
|
|
|
|
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.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(PersonalNameTable.NameDate, 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.PersonalNamePagination.CurrentPage.Text = (Me.PageIndex + 1).ToString()
|
|
Else
|
|
Me.PersonalNamePagination.CurrentPage.Text = "0"
|
|
End If
|
|
Me.PersonalNamePagination.PageSize.Text = Me.PageSize.ToString()
|
|
Me.PersonalNamePagination.TotalItems.Text = Me.TotalRecords.ToString()
|
|
Me.PersonalNamePagination.TotalPages.Text = Me.TotalPages.ToString()
|
|
|
|
' Bind the buttons for PersonalNameTableControl pagination.
|
|
|
|
Me.PersonalNamePagination.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.PersonalNamePagination.LastPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalNamePagination.LastPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalNamePagination.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.PersonalNamePagination.NextPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalNamePagination.NextPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalNamePagination.NextPage.Enabled = Not (Me.PageIndex = Me.TotalPages - 1)
|
|
End If
|
|
|
|
Me.PersonalNamePagination.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 PersonalNameTableControlRow
|
|
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.
|
|
PersonalNameTable.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 selectedRecordKeyValue as KeyValue = New KeyValue()
|
|
|
|
Dim personalIdRecordControlObj As Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalIdRecordControl"), Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(personalIdRecordControlObj) AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord()) AndAlso personalIdRecordControlObj.GetRecord().IsCreated AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord().PersonalId))
|
|
wc.iAND(PersonalNameTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
selectedRecordKeyValue.AddElement(PersonalNameTable.PersonalId.InternalName, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
Else
|
|
wc.RunQuery = False
|
|
Return wc
|
|
End If
|
|
|
|
HttpContext.Current.Session("PersonalNameTableControlWhereClause") = selectedRecordKeyValue.ToXmlString()
|
|
|
|
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.
|
|
PersonalNameTable.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)
|
|
|
|
Dim selectedRecordInPersonalIdRecordControl as String = DirectCast(HttpContext.Current.Session("PersonalNameTableControlWhereClause"), String)
|
|
|
|
If Not selectedRecordInPersonalIdRecordControl Is Nothing AndAlso KeyValue.IsXmlKey(selectedRecordInPersonalIdRecordControl) Then
|
|
Dim selectedRecordKeyValue as KeyValue = KeyValue.XmlToKey(selectedRecordInPersonalIdRecordControl)
|
|
|
|
If Not IsNothing(selectedRecordKeyValue) AndAlso selectedRecordKeyValue.ContainsColumn(PersonalNameTable.PersonalId) Then
|
|
wc.iAND(PersonalNameTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, selectedRecordKeyValue.GetColumnValue(PersonalNameTable.PersonalId).ToString())
|
|
End If
|
|
|
|
End If
|
|
|
|
' Adds clauses if values are selected in Filter controls which are configured in the page.
|
|
|
|
|
|
Return wc
|
|
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.PersonalNamePagination.PageSize.Text.Trim <> "" Then
|
|
Try
|
|
'Me.PageSize = Integer.Parse(Me.PersonalNamePagination.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, "PersonalNameTableControlRepeater"), 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 PersonalNameTableControlRow = DirectCast(repItem.FindControl("PersonalNameTableControlRow"), PersonalNameTableControlRow)
|
|
|
|
If recControl.Visible AndAlso recControl.IsNewRecord() Then
|
|
|
|
Dim rec As PersonalNameRecord = New PersonalNameRecord()
|
|
|
|
If recControl.NameDate.Text <> "" Then
|
|
rec.Parse(recControl.NameDate.Text, PersonalNameTable.NameDate)
|
|
End If
|
|
If recControl.PersonalLastName1.Text <> "" Then
|
|
rec.Parse(recControl.PersonalLastName1.Text, PersonalNameTable.PersonalLastName)
|
|
End If
|
|
If recControl.PersonalName1.Text <> "" Then
|
|
rec.Parse(recControl.PersonalName1.Text, PersonalNameTable.PersonalName)
|
|
End If
|
|
If recControl.Ref2.Text <> "" Then
|
|
rec.Parse(recControl.Ref2.Text, PersonalNameTable.Ref0)
|
|
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 PersonalNameRecord())
|
|
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(PersonalNameRecord)), PersonalNameRecord())
|
|
|
|
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 PersonalNameTableControlRow)
|
|
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 PersonalNameTableControlRow) 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 SetNameDateLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalLastNameLabel2()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalNameLabel2()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalNameTableControlCollapsibleRegion()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRefLabel1()
|
|
|
|
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.
|
|
Dim added As Boolean = Me.AddNewRecord > 0
|
|
Me.LoadData()
|
|
Me.DataBind()
|
|
|
|
If added Then
|
|
Me.SetFocusToAddedRow()
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
Catch ex As Exception
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
End Sub
|
|
|
|
'this function sets focus to the first editable element in the new added row in the editable table
|
|
Protected Overridable Sub SetFocusToAddedRow()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalNameTableControlRepeater"), System.Web.UI.WebControls.Repeater)
|
|
If rep Is Nothing OrElse rep.Items.Count = 0 Then Return
|
|
Dim repItem As System.Web.UI.WebControls.RepeaterItem
|
|
For Each repItem In rep.Items
|
|
'Load scripts to table rows
|
|
Me.Page.LoadFocusScripts(repItem)
|
|
Dim recControl As PersonalNameTableControlRow = DirectCast(repItem.FindControl("PersonalNameTableControlRow"), PersonalNameTableControlRow)
|
|
If recControl.IsNewRecord Then
|
|
For Each field As Control In recControl.Controls
|
|
If field.Visible AndAlso Me.Page.IsControlEditable(field, False) Then
|
|
'set focus on the first editable field in the new row
|
|
field.Focus()
|
|
Dim updPan As UpdatePanel = DirectCast(Me.Page.FindControlRecursively("UpdatePanel1"), UpdatePanel)
|
|
If Not updPan Is Nothing Then updPan.Update()
|
|
Return
|
|
End If
|
|
Next
|
|
Return
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub SaveControlsToSession()
|
|
MyBase.SaveControlsToSession()
|
|
|
|
' Save filter controls to values to session.
|
|
|
|
|
|
'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.
|
|
|
|
HttpContext.Current.Session("AppRelativeVirtualPath") = Me.Page.AppRelativeVirtualPath
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub ClearControlsFromSession()
|
|
MyBase.ClearControlsFromSession()
|
|
|
|
' Clear filter controls values from the session.
|
|
|
|
|
|
' 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("PersonalNameTableControl_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("PersonalNameTableControl_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 PersonalNamePagination_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 PersonalNamePagination_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 PersonalNamePagination_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 PersonalNamePagination_PageSizeButton_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
Try
|
|
|
|
Me.DataChanged = True
|
|
|
|
Me.PageSize = Integer.Parse(Me.PersonalNamePagination.PageSize.Text)
|
|
|
|
Me.PageIndex = Integer.Parse(Me.PersonalNamePagination.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 PersonalNamePagination_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 NameDateLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by NameDate when clicked.
|
|
|
|
' Get previous sorting state for NameDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalNameTable.NameDate)
|
|
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 NameDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalNameTable.NameDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by NameDate, 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 PersonalLastNameLabel2_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by PersonalLastName when clicked.
|
|
|
|
' Get previous sorting state for PersonalLastName.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalNameTable.PersonalLastName)
|
|
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 PersonalLastName.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalNameTable.PersonalLastName, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by PersonalLastName, 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 PersonalNameLabel2_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(PersonalNameTable.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(PersonalNameTable.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 RefLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Ref when clicked.
|
|
|
|
' Get previous sorting state for Ref.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalNameTable.Ref0)
|
|
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 Ref.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalNameTable.Ref0, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Ref, 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 PersonalNameAddButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
Me.AddNewRecord = 1
|
|
Me.DataChanged = 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 PersonalNameDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Me.DeleteSelectedRecords(True)
|
|
Me.SetFormulaControls()
|
|
|
|
|
|
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 PersonalNameEditButton_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalNameResetButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
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(PersonalNameTable.NameDate, OrderByItem.OrderDir.Asc)
|
|
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
|
|
' 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 = PersonalNameTable.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 PersonalNameRecord = Nothing
|
|
Public Property DataSource() As PersonalNameRecord ()
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
Set(ByVal value() As PersonalNameRecord)
|
|
Me._DataSource = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Helper Properties"
|
|
|
|
Public ReadOnly Property NameDateLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "NameDateLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalLastNameLabel2() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalLastNameLabel2"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalNameAddButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalNameAddButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalNameDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalNameDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalNameEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalNameEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalNameLabel2() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalNameLabel2"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalNamePagination() As Persons.UI.IPagination
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalNamePagination"), Persons.UI.IPagination)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalNameResetButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalNameResetButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalNameTableControlCollapsibleRegion() As System.Web.UI.WebControls.Panel
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalNameTableControlCollapsibleRegion"), System.Web.UI.WebControls.Panel)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalNameToggleAll() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalNameToggleAll"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RefLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RefLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
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 PersonalNameTableControlRow = 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 PersonalNameRecord = 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 GetSelectedRecordIndex() As Integer
|
|
Dim counter As Integer = 0
|
|
Dim recControl As PersonalNameTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalNameRecordRowSelection.Checked Then
|
|
Return counter
|
|
End If
|
|
counter += 1
|
|
Next
|
|
Return -1
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControl() As PersonalNameTableControlRow
|
|
Dim selectedList() As PersonalNameTableControlRow = Me.GetSelectedRecordControls()
|
|
If selectedList.Length = 0 Then
|
|
Return Nothing
|
|
End If
|
|
Return selectedList(0)
|
|
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControls() As PersonalNameTableControlRow()
|
|
|
|
Dim selectedList As ArrayList = New ArrayList(25)
|
|
Dim recControl As PersonalNameTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalNameRecordRowSelection IsNot Nothing AndAlso recControl.PersonalNameRecordRowSelection.Checked Then
|
|
selectedList.Add(recControl)
|
|
End If
|
|
Next
|
|
Return DirectCast(selectedList.ToArray(GetType(PersonalNameTableControlRow)), PersonalNameTableControlRow())
|
|
|
|
End Function
|
|
|
|
Public Overridable Sub DeleteSelectedRecords(ByVal deferDeletion As Boolean)
|
|
Dim recList() As PersonalNameTableControlRow = Me.GetSelectedRecordControls()
|
|
If recList.Length = 0 Then
|
|
' Localization.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoRecSelected", "Persons"))
|
|
End If
|
|
|
|
Dim recCtl As PersonalNameTableControlRow
|
|
For Each recCtl In recList
|
|
If deferDeletion Then
|
|
If Not recCtl.IsNewRecord Then
|
|
|
|
Me.AddToDeletedRecordIds(recCtl)
|
|
|
|
End If
|
|
recCtl.Visible = False
|
|
|
|
recCtl.PersonalNameRecordRowSelection.Checked = 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 PersonalNameTableControlRow()
|
|
Dim recList As ArrayList = New ArrayList()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalNameTableControlRepeater"), 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 PersonalNameTableControlRow = DirectCast(repItem.FindControl("PersonalNameTableControlRow"), PersonalNameTableControlRow)
|
|
recList.Add(recControl)
|
|
|
|
Next
|
|
|
|
Return DirectCast(recList.ToArray(GetType(PersonalNameTableControlRow)), PersonalNameTableControlRow())
|
|
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 PersonalRankTableControlRow control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalRankTableControlRow.
|
|
Public Class BasePersonalRankTableControlRow
|
|
Inherits Persons.UI.BaseApplicationRecordControl
|
|
|
|
' To customize, override this method in PersonalRankTableControlRow.
|
|
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 PersonalRankTableControlRow.
|
|
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)
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalRankRowDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteRecordConfirm", "Persons") & "'));")
|
|
|
|
|
|
' Register the event handlers.
|
|
|
|
AddHandler Me.PersonalRankRowDeleteButton.Click, AddressOf PersonalRankRowDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalRankRowEditButton.Click, AddressOf PersonalRankRowEditButton_Click
|
|
|
|
AddHandler Me.PersonalRankRowViewButton.Click, AddressOf PersonalRankRowViewButton_Click
|
|
|
|
AddHandler Me.RankId1.SelectedIndexChanged, AddressOf RankId1_SelectedIndexChanged
|
|
|
|
AddHandler Me.PreRank.CheckedChanged, AddressOf PreRank_CheckedChanged
|
|
|
|
AddHandler Me.GazetteDate1.TextChanged, AddressOf GazetteDate1_TextChanged
|
|
|
|
AddHandler Me.GazetteNO1.TextChanged, AddressOf GazetteNO1_TextChanged
|
|
|
|
AddHandler Me.GazettePage1.TextChanged, AddressOf GazettePage1_TextChanged
|
|
|
|
AddHandler Me.GazetteSection1.TextChanged, AddressOf GazetteSection1_TextChanged
|
|
|
|
AddHandler Me.RankDate.TextChanged, AddressOf RankDate_TextChanged
|
|
|
|
AddHandler Me.Ref3.TextChanged, AddressOf Ref3_TextChanged
|
|
|
|
AddHandler Me.RefDate1.TextChanged, AddressOf RefDate1_TextChanged
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Load the data from the database into the DataSource PersonalRank 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 = PersonalRankTable.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 BasePersonalRankTableControl when the data for the entire
|
|
' table is loaded.
|
|
|
|
Me.DataSource = New PersonalRankRecord()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
' Populate the UI controls using the DataSource. To customize, override this method in PersonalRankTableControlRow.
|
|
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
|
|
|
|
SetGazetteDate1()
|
|
SetGazetteNO1()
|
|
SetGazettePage1()
|
|
SetGazetteSection1()
|
|
|
|
|
|
|
|
|
|
SetPreRank()
|
|
SetRankDate()
|
|
SetRankId1()
|
|
SetRef3()
|
|
SetRefDate1()
|
|
|
|
|
|
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 SetGazetteDate1()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.GazetteDate1.ID) Then
|
|
|
|
Me.GazetteDate1.Text = Me.PreviousUIData(Me.GazetteDate1.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the GazetteDate TextBox on the webpage with value from the
|
|
' PersonalRank database record.
|
|
|
|
' Me.DataSource is the PersonalRank record retrieved from the database.
|
|
' Me.GazetteDate1 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetGazetteDate1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.GazetteDateSpecified Then
|
|
|
|
' If the GazetteDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalRankTable.GazetteDate, "d MMM yyyy")
|
|
|
|
Me.GazetteDate1.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' GazetteDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.GazetteDate1.Text = PersonalRankTable.GazetteDate.Format(PersonalRankTable.GazetteDate.DefaultValue, "d MMM yyyy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetGazetteNO1()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.GazetteNO1.ID) Then
|
|
|
|
Me.GazetteNO1.Text = Me.PreviousUIData(Me.GazetteNO1.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the GazetteNO TextBox on the webpage with value from the
|
|
' PersonalRank database record.
|
|
|
|
' Me.DataSource is the PersonalRank record retrieved from the database.
|
|
' Me.GazetteNO1 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetGazetteNO1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.GazetteNOSpecified Then
|
|
|
|
' If the GazetteNO is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalRankTable.GazetteNO)
|
|
|
|
Me.GazetteNO1.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' GazetteNO is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.GazetteNO1.Text = PersonalRankTable.GazetteNO.Format(PersonalRankTable.GazetteNO.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetGazettePage1()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.GazettePage1.ID) Then
|
|
|
|
Me.GazettePage1.Text = Me.PreviousUIData(Me.GazettePage1.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the GazettePage TextBox on the webpage with value from the
|
|
' PersonalRank database record.
|
|
|
|
' Me.DataSource is the PersonalRank record retrieved from the database.
|
|
' Me.GazettePage1 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetGazettePage1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.GazettePageSpecified Then
|
|
|
|
' If the GazettePage is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalRankTable.GazettePage)
|
|
|
|
Me.GazettePage1.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' GazettePage is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.GazettePage1.Text = PersonalRankTable.GazettePage.Format(PersonalRankTable.GazettePage.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetGazetteSection1()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.GazetteSection1.ID) Then
|
|
|
|
Me.GazetteSection1.Text = Me.PreviousUIData(Me.GazetteSection1.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the GazetteSection TextBox on the webpage with value from the
|
|
' PersonalRank database record.
|
|
|
|
' Me.DataSource is the PersonalRank record retrieved from the database.
|
|
' Me.GazetteSection1 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetGazetteSection1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.GazetteSectionSpecified Then
|
|
|
|
' If the GazetteSection is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalRankTable.GazetteSection)
|
|
|
|
Me.GazetteSection1.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' GazetteSection is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.GazetteSection1.Text = PersonalRankTable.GazetteSection.Format(PersonalRankTable.GazetteSection.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPreRank()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.PreRank.ID) Then
|
|
Me.PreRank.Checked = Convert.ToBoolean(Me.PreviousUIData(Me.PreRank.ID))
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the PreRank CheckBox on the webpage with value from the
|
|
' PersonalRank database record.
|
|
|
|
' Me.DataSource is the PersonalRank record retrieved from the database.
|
|
' Me.PreRank is the ASP:CheckBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetPreRank()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.PreRankSpecified Then
|
|
|
|
' If the PreRank is non-NULL, then format the value.
|
|
' The Format method will use the Display Format
|
|
If Me.DataSource.PreRank.ToString() = "1" Then
|
|
|
|
Me.PreRank.Checked = True
|
|
Else
|
|
Me.PreRank.Checked = False
|
|
End If
|
|
|
|
Else
|
|
|
|
' PreRank is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Not Me.DataSource.IsCreated Then
|
|
Me.PreRank.Checked = PersonalRankTable.PreRank.ParseValue(PersonalRankTable.PreRank.DefaultValue).ToBoolean()
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRankDate()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RankDate.ID) Then
|
|
|
|
Me.RankDate.Text = Me.PreviousUIData(Me.RankDate.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RankDate TextBox on the webpage with value from the
|
|
' PersonalRank database record.
|
|
|
|
' Me.DataSource is the PersonalRank record retrieved from the database.
|
|
' Me.RankDate is the ASP:TextBox 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(PersonalRankTable.RankDate, "d MMM yyyy")
|
|
|
|
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 = PersonalRankTable.RankDate.Format(PersonalRankTable.RankDate.DefaultValue, "d MMM yyyy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRankId1()
|
|
|
|
' If selection was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RankId1.ID) Then
|
|
If Me.PreviousUIData(Me.RankId1.ID) Is Nothing
|
|
Me.PopulateRankId1DropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateRankId1DropDownList(Me.PreviousUIData(Me.RankId1.ID).ToString(), 100)
|
|
End If
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RankId DropDownList on the webpage with value from the
|
|
' PersonalRank database record.
|
|
|
|
' Me.DataSource is the PersonalRank record retrieved from the database.
|
|
' Me.RankId1 is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRankId1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RankIdSpecified Then
|
|
|
|
' If the RankId is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateRankId1DropDownList(Me.DataSource.RankId.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' RankId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateRankId1DropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateRankId1DropDownList(PersonalRankTable.RankId.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRef3()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Ref3.ID) Then
|
|
|
|
Me.Ref3.Text = Me.PreviousUIData(Me.Ref3.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Ref TextBox on the webpage with value from the
|
|
' PersonalRank database record.
|
|
|
|
' Me.DataSource is the PersonalRank record retrieved from the database.
|
|
' Me.Ref3 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRef3()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.Ref0Specified Then
|
|
|
|
' If the Ref is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalRankTable.Ref0)
|
|
|
|
Me.Ref3.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Ref is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Ref3.Text = PersonalRankTable.Ref0.Format(PersonalRankTable.Ref0.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRefDate1()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RefDate1.ID) Then
|
|
|
|
Me.RefDate1.Text = Me.PreviousUIData(Me.RefDate1.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RefDate TextBox on the webpage with value from the
|
|
' PersonalRank database record.
|
|
|
|
' Me.DataSource is the PersonalRank record retrieved from the database.
|
|
' Me.RefDate1 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRefDate1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RefDateSpecified Then
|
|
|
|
' If the RefDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalRankTable.RefDate, "d MMM yyyy")
|
|
|
|
Me.RefDate1.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RefDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RefDate1.Text = PersonalRankTable.RefDate.Format(PersonalRankTable.RefDate.DefaultValue, "d MMM yyyy")
|
|
|
|
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 PersonalRankTableControlRow.
|
|
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()
|
|
|
|
Dim parentCtrl As PersonalIdRecordControl
|
|
|
|
|
|
parentCtrl = DirectCast(Me.Page.FindControlRecursively("PersonalIdRecordControl"), PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(parentCtrl) AndAlso IsNothing(parentCtrl.DataSource))
|
|
' Load the record if it is not loaded yet.
|
|
parentCtrl.LoadData()
|
|
End If
|
|
If (IsNothing(parentCtrl) OrElse IsNothing(parentCtrl.DataSource))
|
|
' Get the error message from the application resource file.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoParentRecId", "Persons"))
|
|
End If
|
|
|
|
Me.DataSource.PersonalId = parentCtrl.DataSource.PersonalId
|
|
|
|
' 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, "PersonalRankTableControl"), PersonalRankTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalRankTableControl"), PersonalRankTableControl).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 PersonalRankTableControlRow.
|
|
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.
|
|
|
|
GetGazetteDate1()
|
|
GetGazetteNO1()
|
|
GetGazettePage1()
|
|
GetGazetteSection1()
|
|
GetPreRank()
|
|
GetRankDate()
|
|
GetRankId1()
|
|
GetRef3()
|
|
GetRefDate1()
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub GetGazetteDate1()
|
|
|
|
' Retrieve the value entered by the user on the GazetteDate ASP:TextBox, and
|
|
' save it into the GazetteDate field in DataSource PersonalRank record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.GazetteDate1.Text, PersonalRankTable.GazetteDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetGazetteNO1()
|
|
|
|
' Retrieve the value entered by the user on the GazetteNO ASP:TextBox, and
|
|
' save it into the GazetteNO field in DataSource PersonalRank record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.GazetteNO1.Text, PersonalRankTable.GazetteNO)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetGazettePage1()
|
|
|
|
' Retrieve the value entered by the user on the GazettePage ASP:TextBox, and
|
|
' save it into the GazettePage field in DataSource PersonalRank record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.GazettePage1.Text, PersonalRankTable.GazettePage)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetGazetteSection1()
|
|
|
|
' Retrieve the value entered by the user on the GazetteSection ASP:TextBox, and
|
|
' save it into the GazetteSection field in DataSource PersonalRank record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.GazetteSection1.Text, PersonalRankTable.GazetteSection)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetPreRank()
|
|
|
|
|
|
' Retrieve the value entered by the user on the PreRank ASP:CheckBox, and
|
|
' save it into the PreRank field in DataSource PersonalRank record.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
|
|
If Me.PreRank.Checked Then
|
|
Me.DataSource.Parse("1", PersonalRankTable.PreRank)
|
|
Else
|
|
Me.DataSource.Parse("0", PersonalRankTable.PreRank)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRankDate()
|
|
|
|
' Retrieve the value entered by the user on the RankDate ASP:TextBox, and
|
|
' save it into the RankDate field in DataSource PersonalRank record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RankDate.Text, PersonalRankTable.RankDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRankId1()
|
|
|
|
' Retrieve the value entered by the user on the RankId ASP:DropDownList, and
|
|
' save it into the RankId field in DataSource PersonalRank record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.RankId1), PersonalRankTable.RankId)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRef3()
|
|
|
|
' Retrieve the value entered by the user on the Ref ASP:TextBox, and
|
|
' save it into the Ref field in DataSource PersonalRank record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Ref3.Text, PersonalRankTable.Ref0)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRefDate1()
|
|
|
|
' Retrieve the value entered by the user on the RefDate ASP:TextBox, and
|
|
' save it into the RefDate field in DataSource PersonalRank record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RefDate1.Text, PersonalRankTable.RefDate)
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
' To customize, override this method in PersonalRankTableControlRow.
|
|
|
|
Public Overridable Function CreateWhereClause() As WhereClause
|
|
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
|
|
|
|
' To customize, override this method in PersonalRankTableControlRow.
|
|
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)
|
|
PersonalRankTable.DeleteRecord(pkValue)
|
|
|
|
DirectCast(GetParentControlObject(Me, "PersonalRankTableControl"), PersonalRankTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalRankTableControl"), PersonalRankTableControl).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
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_RankId1DropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the Rank table.
|
|
' Examples:
|
|
' wc.iAND(RankTable.ShortRank, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(RankTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
' Fill the RankId1 list.
|
|
Protected Overridable Sub PopulateRankId1DropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.RankId1.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.RankId1.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_RankId1DropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_RankId1DropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(RankTable.ShortRank, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim itemValues() As RankRecord = Nothing
|
|
Dim evaluator As New FormulaEvaluator
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
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.RankIdSpecified Then
|
|
cvalue = itemValue.RankId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.RankId1.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalRankTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalRankTable.RankId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalRankTable.RankId.IsApplyDisplayAs Then
|
|
fvalue = PersonalRankTable.GetDFKA(itemValue, PersonalRankTable.RankId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(RankTable.ShortRank)
|
|
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.RankId1.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.RankId1.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
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.RankId1, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.RankId1, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with Rank.RankId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(RankTable.RankId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As RankRecord = RankTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As RankRecord = DirectCast(rc(0), RankRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.RankIdSpecified Then
|
|
cvalue = itemValue.RankId.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalRankTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalRankTable.RankId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalRankTable.RankId.IsApplyDisplayAs Then
|
|
fvalue = PersonalRankTable.GetDFKA(itemValue, PersonalRankTable.RankId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(RankTable.ShortRank)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.RankId1.Items.Add(newItem)
|
|
SetSelectedValue(Me.RankId1, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonalRankRowDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Dim tc As PersonalRankTableControl = DirectCast(GetParentControlObject(Me, "PersonalRankTableControl"), PersonalRankTableControl)
|
|
If Not (IsNothing(tc)) Then
|
|
If Not Me.IsNewRecord Then
|
|
tc.AddToDeletedRecordIds(DirectCast(Me, PersonalRankTableControlRow))
|
|
End If
|
|
Me.Visible = False
|
|
tc.SetFormulaControls()
|
|
End If
|
|
|
|
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 PersonalRankRowEditButton_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalRankRowViewButton_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 = "../Shared/ConfigureViewRecord.aspx"
|
|
|
|
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
|
|
|
|
Protected Overridable Sub RankId1_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(RankId1.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(RankId1.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.RankId1.Items.Add(New ListItem(displayText, val))
|
|
Me.RankId1.SelectedIndex = Me.RankId1.Items.Count - 1
|
|
Me.Page.Session.Remove(RankId1.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(RankId1.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub PreRank_CheckedChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub GazetteDate1_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub GazetteNO1_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub GazettePage1_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub GazetteSection1_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RankDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Ref3_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RefDate1_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
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("BasePersonalRankTableControlRow_Rec"), String)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me.ViewState("BasePersonalRankTableControlRow_Rec") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataSource As PersonalRankRecord
|
|
Public Property DataSource() As PersonalRankRecord
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
|
|
Set(ByVal value As PersonalRankRecord)
|
|
|
|
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 GazetteDate1() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "GazetteDate1"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GazetteNO1() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "GazetteNO1"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GazettePage1() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "GazettePage1"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GazetteSection1() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "GazetteSection1"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalRankRecordRowSelection() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalRankRecordRowSelection"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalRankRowDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalRankRowDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalRankRowEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalRankRowEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalRankRowViewButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalRankRowViewButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PreRank() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PreRank"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RankDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RankDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RankId1() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RankId1"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Ref3() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Ref3"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RefDate1() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RefDate1"), System.Web.UI.WebControls.TextBox)
|
|
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 PersonalRankRecord = 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 PersonalRankRecord
|
|
If Not Me.DataSource Is Nothing Then
|
|
Return Me.DataSource
|
|
End If
|
|
|
|
If Not Me.RecordUniqueId Is Nothing Then
|
|
|
|
Return PersonalRankTable.GetRecord(Me.RecordUniqueId, True)
|
|
|
|
End If
|
|
|
|
' Localization.
|
|
|
|
Return Nothing
|
|
|
|
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 PersonalRankTableControl control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalRankTableControl.
|
|
Public Class BasePersonalRankTableControl
|
|
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.
|
|
|
|
|
|
|
|
' 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)
|
|
|
|
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()
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalRankDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteConfirm", "Persons") & "'));")
|
|
|
|
' Setup the pagination events.
|
|
|
|
AddHandler Me.PersonalRankPagination.FirstPage.Click, AddressOf PersonalRankPagination_FirstPage_Click
|
|
|
|
AddHandler Me.PersonalRankPagination.LastPage.Click, AddressOf PersonalRankPagination_LastPage_Click
|
|
|
|
AddHandler Me.PersonalRankPagination.NextPage.Click, AddressOf PersonalRankPagination_NextPage_Click
|
|
|
|
AddHandler Me.PersonalRankPagination.PageSizeButton.Click, AddressOf PersonalRankPagination_PageSizeButton_Click
|
|
|
|
AddHandler Me.PersonalRankPagination.PreviousPage.Click, AddressOf PersonalRankPagination_PreviousPage_Click
|
|
|
|
|
|
' Setup the sorting events.
|
|
|
|
AddHandler Me.GazetteDateLabel1.Click, AddressOf GazetteDateLabel1_Click
|
|
|
|
AddHandler Me.GazetteNOLabel1.Click, AddressOf GazetteNOLabel1_Click
|
|
|
|
AddHandler Me.GazettePageLabel1.Click, AddressOf GazettePageLabel1_Click
|
|
|
|
AddHandler Me.GazetteSectionLabel1.Click, AddressOf GazetteSectionLabel1_Click
|
|
|
|
AddHandler Me.PreRankLabel1.Click, AddressOf PreRankLabel1_Click
|
|
|
|
AddHandler Me.RankDateLabel.Click, AddressOf RankDateLabel_Click
|
|
|
|
AddHandler Me.RankIdLabel2.Click, AddressOf RankIdLabel2_Click
|
|
|
|
AddHandler Me.RefDateLabel1.Click, AddressOf RefDateLabel1_Click
|
|
|
|
AddHandler Me.RefLabel2.Click, AddressOf RefLabel2_Click
|
|
|
|
' Setup the button events.
|
|
|
|
AddHandler Me.PersonalRankAddButton.Click, AddressOf PersonalRankAddButton_Click
|
|
|
|
AddHandler Me.PersonalRankDeleteButton.Click, AddressOf PersonalRankDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalRankEditButton.Click, AddressOf PersonalRankEditButton_Click
|
|
|
|
AddHandler Me.PersonalRankResetButton.Click, AddressOf PersonalRankResetButton_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(PersonalRankRecord)), PersonalRankRecord())
|
|
' 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, PersonalRankTable.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 PersonalRankTableControlRow 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(PersonalRankRecord)), PersonalRankRecord())
|
|
Else ' Get the records from the database
|
|
Me.DataSource = PersonalRankTable.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()
|
|
|
|
' Turn off the ToggleAll checkbox
|
|
Me.PersonalRankToggleAll.Checked = False
|
|
|
|
|
|
' Initialize the page and grand totals. now
|
|
|
|
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
|
|
|
|
' Improve performance by prefetching display as records.
|
|
Me.PreFetchForeignKeyValues()
|
|
|
|
' 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, "PersonalRankTableControlRepeater"), 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 PersonalRankTableControlRow = DirectCast(repItem.FindControl("PersonalRankTableControlRow"), PersonalRankTableControlRow)
|
|
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
|
|
|
|
SetGazetteDateLabel1()
|
|
SetGazetteNOLabel1()
|
|
SetGazettePageLabel1()
|
|
SetGazetteSectionLabel1()
|
|
|
|
|
|
|
|
|
|
|
|
SetPersonalRankTableControlCollapsibleRegion()
|
|
|
|
SetPreRankLabel1()
|
|
SetRankDateLabel()
|
|
SetRankIdLabel2()
|
|
SetRefDateLabel1()
|
|
SetRefLabel2()
|
|
' 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 Sub PreFetchForeignKeyValues()
|
|
If (IsNothing(Me.DataSource))
|
|
Return
|
|
End If
|
|
|
|
Me.Page.PregetDfkaRecords(PersonalRankTable.RankId, Me.DataSource)
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub RegisterPostback()
|
|
|
|
|
|
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.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)
|
|
|
|
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.PersonalRankPagination.CurrentPage.Text = (Me.PageIndex + 1).ToString()
|
|
Else
|
|
Me.PersonalRankPagination.CurrentPage.Text = "0"
|
|
End If
|
|
Me.PersonalRankPagination.PageSize.Text = Me.PageSize.ToString()
|
|
Me.PersonalRankPagination.TotalItems.Text = Me.TotalRecords.ToString()
|
|
Me.PersonalRankPagination.TotalPages.Text = Me.TotalPages.ToString()
|
|
|
|
' Bind the buttons for PersonalRankTableControl pagination.
|
|
|
|
Me.PersonalRankPagination.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.PersonalRankPagination.LastPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalRankPagination.LastPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalRankPagination.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.PersonalRankPagination.NextPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalRankPagination.NextPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalRankPagination.NextPage.Enabled = Not (Me.PageIndex = Me.TotalPages - 1)
|
|
End If
|
|
|
|
Me.PersonalRankPagination.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 PersonalRankTableControlRow
|
|
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.
|
|
PersonalRankTable.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 selectedRecordKeyValue as KeyValue = New KeyValue()
|
|
|
|
Dim personalIdRecordControlObj As Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalIdRecordControl"), Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(personalIdRecordControlObj) AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord()) AndAlso personalIdRecordControlObj.GetRecord().IsCreated AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord().PersonalId))
|
|
wc.iAND(PersonalRankTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
selectedRecordKeyValue.AddElement(PersonalRankTable.PersonalId.InternalName, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
Else
|
|
wc.RunQuery = False
|
|
Return wc
|
|
End If
|
|
|
|
HttpContext.Current.Session("PersonalRankTableControlWhereClause") = selectedRecordKeyValue.ToXmlString()
|
|
|
|
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.
|
|
PersonalRankTable.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)
|
|
|
|
Dim selectedRecordInPersonalIdRecordControl as String = DirectCast(HttpContext.Current.Session("PersonalRankTableControlWhereClause"), String)
|
|
|
|
If Not selectedRecordInPersonalIdRecordControl Is Nothing AndAlso KeyValue.IsXmlKey(selectedRecordInPersonalIdRecordControl) Then
|
|
Dim selectedRecordKeyValue as KeyValue = KeyValue.XmlToKey(selectedRecordInPersonalIdRecordControl)
|
|
|
|
If Not IsNothing(selectedRecordKeyValue) AndAlso selectedRecordKeyValue.ContainsColumn(PersonalRankTable.PersonalId) Then
|
|
wc.iAND(PersonalRankTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, selectedRecordKeyValue.GetColumnValue(PersonalRankTable.PersonalId).ToString())
|
|
End If
|
|
|
|
End If
|
|
|
|
' Adds clauses if values are selected in Filter controls which are configured in the page.
|
|
|
|
|
|
Return wc
|
|
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.PersonalRankPagination.PageSize.Text.Trim <> "" Then
|
|
Try
|
|
'Me.PageSize = Integer.Parse(Me.PersonalRankPagination.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, "PersonalRankTableControlRepeater"), 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 PersonalRankTableControlRow = DirectCast(repItem.FindControl("PersonalRankTableControlRow"), PersonalRankTableControlRow)
|
|
|
|
If recControl.Visible AndAlso recControl.IsNewRecord() Then
|
|
|
|
Dim rec As PersonalRankRecord = New PersonalRankRecord()
|
|
|
|
If recControl.GazetteDate1.Text <> "" Then
|
|
rec.Parse(recControl.GazetteDate1.Text, PersonalRankTable.GazetteDate)
|
|
End If
|
|
If recControl.GazetteNO1.Text <> "" Then
|
|
rec.Parse(recControl.GazetteNO1.Text, PersonalRankTable.GazetteNO)
|
|
End If
|
|
If recControl.GazettePage1.Text <> "" Then
|
|
rec.Parse(recControl.GazettePage1.Text, PersonalRankTable.GazettePage)
|
|
End If
|
|
If recControl.GazetteSection1.Text <> "" Then
|
|
rec.Parse(recControl.GazetteSection1.Text, PersonalRankTable.GazetteSection)
|
|
End If
|
|
If recControl.PreRank.Checked Then
|
|
rec.Parse("1", PersonalRankTable.PreRank)
|
|
Else
|
|
rec.Parse("0", PersonalRankTable.PreRank)
|
|
End If
|
|
|
|
If recControl.RankDate.Text <> "" Then
|
|
rec.Parse(recControl.RankDate.Text, PersonalRankTable.RankDate)
|
|
End If
|
|
If MiscUtils.IsValueSelected(recControl.RankId1) Then
|
|
rec.Parse(recControl.RankId1.SelectedItem.Value, PersonalRankTable.RankId)
|
|
End If
|
|
If recControl.Ref3.Text <> "" Then
|
|
rec.Parse(recControl.Ref3.Text, PersonalRankTable.Ref0)
|
|
End If
|
|
If recControl.RefDate1.Text <> "" Then
|
|
rec.Parse(recControl.RefDate1.Text, PersonalRankTable.RefDate)
|
|
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 PersonalRankRecord())
|
|
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(PersonalRankRecord)), PersonalRankRecord())
|
|
|
|
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 PersonalRankTableControlRow)
|
|
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 PersonalRankTableControlRow) 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 SetGazetteDateLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetGazetteNOLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetGazettePageLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetGazetteSectionLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalRankTableControlCollapsibleRegion()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPreRankLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRankDateLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRankIdLabel2()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRefDateLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRefLabel2()
|
|
|
|
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.
|
|
Dim added As Boolean = Me.AddNewRecord > 0
|
|
Me.LoadData()
|
|
Me.DataBind()
|
|
|
|
If added Then
|
|
Me.SetFocusToAddedRow()
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
Catch ex As Exception
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
End Sub
|
|
|
|
'this function sets focus to the first editable element in the new added row in the editable table
|
|
Protected Overridable Sub SetFocusToAddedRow()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalRankTableControlRepeater"), System.Web.UI.WebControls.Repeater)
|
|
If rep Is Nothing OrElse rep.Items.Count = 0 Then Return
|
|
Dim repItem As System.Web.UI.WebControls.RepeaterItem
|
|
For Each repItem In rep.Items
|
|
'Load scripts to table rows
|
|
Me.Page.LoadFocusScripts(repItem)
|
|
Dim recControl As PersonalRankTableControlRow = DirectCast(repItem.FindControl("PersonalRankTableControlRow"), PersonalRankTableControlRow)
|
|
If recControl.IsNewRecord Then
|
|
For Each field As Control In recControl.Controls
|
|
If field.Visible AndAlso Me.Page.IsControlEditable(field, False) Then
|
|
'set focus on the first editable field in the new row
|
|
field.Focus()
|
|
Dim updPan As UpdatePanel = DirectCast(Me.Page.FindControlRecursively("UpdatePanel1"), UpdatePanel)
|
|
If Not updPan Is Nothing Then updPan.Update()
|
|
Return
|
|
End If
|
|
Next
|
|
Return
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub SaveControlsToSession()
|
|
MyBase.SaveControlsToSession()
|
|
|
|
' Save filter controls to values to session.
|
|
|
|
|
|
'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.
|
|
|
|
HttpContext.Current.Session("AppRelativeVirtualPath") = Me.Page.AppRelativeVirtualPath
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub ClearControlsFromSession()
|
|
MyBase.ClearControlsFromSession()
|
|
|
|
' Clear filter controls values from the session.
|
|
|
|
|
|
' 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("PersonalRankTableControl_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("PersonalRankTableControl_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 PersonalRankPagination_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 PersonalRankPagination_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 PersonalRankPagination_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 PersonalRankPagination_PageSizeButton_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
Try
|
|
|
|
Me.DataChanged = True
|
|
|
|
Me.PageSize = Integer.Parse(Me.PersonalRankPagination.PageSize.Text)
|
|
|
|
Me.PageIndex = Integer.Parse(Me.PersonalRankPagination.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 PersonalRankPagination_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 GazetteDateLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by GazetteDate when clicked.
|
|
|
|
' Get previous sorting state for GazetteDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalRankTable.GazetteDate)
|
|
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 GazetteDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalRankTable.GazetteDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by GazetteDate, 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 GazetteNOLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by GazetteNO when clicked.
|
|
|
|
' Get previous sorting state for GazetteNO.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalRankTable.GazetteNO)
|
|
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 GazetteNO.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalRankTable.GazetteNO, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by GazetteNO, 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 GazettePageLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by GazettePage when clicked.
|
|
|
|
' Get previous sorting state for GazettePage.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalRankTable.GazettePage)
|
|
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 GazettePage.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalRankTable.GazettePage, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by GazettePage, 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 GazetteSectionLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by GazetteSection when clicked.
|
|
|
|
' Get previous sorting state for GazetteSection.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalRankTable.GazetteSection)
|
|
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 GazetteSection.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalRankTable.GazetteSection, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by GazetteSection, 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 PreRankLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by PreRank when clicked.
|
|
|
|
' Get previous sorting state for PreRank.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalRankTable.PreRank)
|
|
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 PreRank.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalRankTable.PreRank, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by PreRank, 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(PersonalRankTable.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(PersonalRankTable.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 RankIdLabel2_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by RankId when clicked.
|
|
|
|
' Get previous sorting state for RankId.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalRankTable.RankId)
|
|
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 RankId.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalRankTable.RankId, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by RankId, 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 RefDateLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by RefDate when clicked.
|
|
|
|
' Get previous sorting state for RefDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalRankTable.RefDate)
|
|
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 RefDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalRankTable.RefDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by RefDate, 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 RefLabel2_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Ref when clicked.
|
|
|
|
' Get previous sorting state for Ref.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalRankTable.Ref0)
|
|
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 Ref.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalRankTable.Ref0, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Ref, 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 PersonalRankAddButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
Me.AddNewRecord = 1
|
|
Me.DataChanged = 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 PersonalRankDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Me.DeleteSelectedRecords(True)
|
|
Me.SetFormulaControls()
|
|
|
|
|
|
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 PersonalRankEditButton_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalRankResetButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
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)
|
|
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
|
|
' 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 = PersonalRankTable.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 PersonalRankRecord = Nothing
|
|
Public Property DataSource() As PersonalRankRecord ()
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
Set(ByVal value() As PersonalRankRecord)
|
|
Me._DataSource = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Helper Properties"
|
|
|
|
Public ReadOnly Property GazetteDateLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "GazetteDateLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GazetteNOLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "GazetteNOLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GazettePageLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "GazettePageLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GazetteSectionLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "GazetteSectionLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalRankAddButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalRankAddButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalRankDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalRankDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalRankEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalRankEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalRankPagination() As Persons.UI.IPagination
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalRankPagination"), Persons.UI.IPagination)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalRankResetButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalRankResetButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalRankTableControlCollapsibleRegion() As System.Web.UI.WebControls.Panel
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalRankTableControlCollapsibleRegion"), System.Web.UI.WebControls.Panel)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalRankToggleAll() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalRankToggleAll"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PreRankLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PreRankLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
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 RankIdLabel2() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RankIdLabel2"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RefDateLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RefDateLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RefLabel2() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RefLabel2"), System.Web.UI.WebControls.LinkButton)
|
|
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 PersonalRankTableControlRow = 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 PersonalRankRecord = 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 GetSelectedRecordIndex() As Integer
|
|
Dim counter As Integer = 0
|
|
Dim recControl As PersonalRankTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalRankRecordRowSelection.Checked Then
|
|
Return counter
|
|
End If
|
|
counter += 1
|
|
Next
|
|
Return -1
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControl() As PersonalRankTableControlRow
|
|
Dim selectedList() As PersonalRankTableControlRow = Me.GetSelectedRecordControls()
|
|
If selectedList.Length = 0 Then
|
|
Return Nothing
|
|
End If
|
|
Return selectedList(0)
|
|
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControls() As PersonalRankTableControlRow()
|
|
|
|
Dim selectedList As ArrayList = New ArrayList(25)
|
|
Dim recControl As PersonalRankTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalRankRecordRowSelection IsNot Nothing AndAlso recControl.PersonalRankRecordRowSelection.Checked Then
|
|
selectedList.Add(recControl)
|
|
End If
|
|
Next
|
|
Return DirectCast(selectedList.ToArray(GetType(PersonalRankTableControlRow)), PersonalRankTableControlRow())
|
|
|
|
End Function
|
|
|
|
Public Overridable Sub DeleteSelectedRecords(ByVal deferDeletion As Boolean)
|
|
Dim recList() As PersonalRankTableControlRow = Me.GetSelectedRecordControls()
|
|
If recList.Length = 0 Then
|
|
' Localization.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoRecSelected", "Persons"))
|
|
End If
|
|
|
|
Dim recCtl As PersonalRankTableControlRow
|
|
For Each recCtl In recList
|
|
If deferDeletion Then
|
|
If Not recCtl.IsNewRecord Then
|
|
|
|
Me.AddToDeletedRecordIds(recCtl)
|
|
|
|
End If
|
|
recCtl.Visible = False
|
|
|
|
recCtl.PersonalRankRecordRowSelection.Checked = 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 PersonalRankTableControlRow()
|
|
Dim recList As ArrayList = New ArrayList()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalRankTableControlRepeater"), 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 PersonalRankTableControlRow = DirectCast(repItem.FindControl("PersonalRankTableControlRow"), PersonalRankTableControlRow)
|
|
recList.Add(recControl)
|
|
|
|
Next
|
|
|
|
Return DirectCast(recList.ToArray(GetType(PersonalRankTableControlRow)), PersonalRankTableControlRow())
|
|
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 PersonalSalaryTableControlRow control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalSalaryTableControlRow.
|
|
Public Class BasePersonalSalaryTableControlRow
|
|
Inherits Persons.UI.BaseApplicationRecordControl
|
|
|
|
' To customize, override this method in PersonalSalaryTableControlRow.
|
|
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 PersonalSalaryTableControlRow.
|
|
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)
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalSalaryRowDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteRecordConfirm", "Persons") & "'));")
|
|
|
|
|
|
' Register the event handlers.
|
|
|
|
AddHandler Me.PersonalSalaryRowDeleteButton.Click, AddressOf PersonalSalaryRowDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalSalaryRowEditButton.Click, AddressOf PersonalSalaryRowEditButton_Click
|
|
|
|
AddHandler Me.PersonalSalaryRowViewButton.Click, AddressOf PersonalSalaryRowViewButton_Click
|
|
|
|
AddHandler Me.CommandDate2.TextChanged, AddressOf CommandDate2_TextChanged
|
|
|
|
AddHandler Me.PositionSalary.TextChanged, AddressOf PositionSalary_TextChanged
|
|
|
|
AddHandler Me.SalaryAmout.TextChanged, AddressOf SalaryAmout_TextChanged
|
|
|
|
AddHandler Me.SalaryCommand.TextChanged, AddressOf SalaryCommand_TextChanged
|
|
|
|
AddHandler Me.SalaryDate.TextChanged, AddressOf SalaryDate_TextChanged
|
|
|
|
AddHandler Me.SalaryPlus.TextChanged, AddressOf SalaryPlus_TextChanged
|
|
|
|
AddHandler Me.SalaryRank.TextChanged, AddressOf SalaryRank_TextChanged
|
|
|
|
AddHandler Me.SalaryStep.TextChanged, AddressOf SalaryStep_TextChanged
|
|
|
|
AddHandler Me.SalaryYear.TextChanged, AddressOf SalaryYear_TextChanged
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Load the data from the database into the DataSource PersonalSalary 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 = PersonalSalaryTable.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 BasePersonalSalaryTableControl when the data for the entire
|
|
' table is loaded.
|
|
|
|
Me.DataSource = New PersonalSalaryRecord()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
' Populate the UI controls using the DataSource. To customize, override this method in PersonalSalaryTableControlRow.
|
|
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
|
|
|
|
SetCommandDate2()
|
|
|
|
|
|
|
|
|
|
SetPositionSalary()
|
|
SetSalaryAmout()
|
|
SetSalaryCommand()
|
|
SetSalaryDate()
|
|
SetSalaryPlus()
|
|
SetSalaryRank()
|
|
SetSalaryStep()
|
|
SetSalaryYear()
|
|
|
|
|
|
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 SetCommandDate2()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.CommandDate2.ID) Then
|
|
|
|
Me.CommandDate2.Text = Me.PreviousUIData(Me.CommandDate2.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the CommandDate TextBox on the webpage with value from the
|
|
' PersonalSalary database record.
|
|
|
|
' Me.DataSource is the PersonalSalary record retrieved from the database.
|
|
' Me.CommandDate2 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetCommandDate2()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.CommandDateSpecified Then
|
|
|
|
' If the CommandDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalSalaryTable.CommandDate, "d MMM yyyy")
|
|
|
|
Me.CommandDate2.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' CommandDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.CommandDate2.Text = PersonalSalaryTable.CommandDate.Format(PersonalSalaryTable.CommandDate.DefaultValue, "d MMM yyyy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPositionSalary()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.PositionSalary.ID) Then
|
|
|
|
Me.PositionSalary.Text = Me.PreviousUIData(Me.PositionSalary.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the PositionSalary TextBox on the webpage with value from the
|
|
' PersonalSalary database record.
|
|
|
|
' Me.DataSource is the PersonalSalary record retrieved from the database.
|
|
' Me.PositionSalary is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetPositionSalary()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.PositionSalarySpecified Then
|
|
|
|
' If the PositionSalary is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalSalaryTable.PositionSalary, "#####")
|
|
|
|
Me.PositionSalary.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' PositionSalary is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.PositionSalary.Text = PersonalSalaryTable.PositionSalary.Format(PersonalSalaryTable.PositionSalary.DefaultValue, "#####")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSalaryAmout()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.SalaryAmout.ID) Then
|
|
|
|
Me.SalaryAmout.Text = Me.PreviousUIData(Me.SalaryAmout.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the SalaryAmout TextBox on the webpage with value from the
|
|
' PersonalSalary database record.
|
|
|
|
' Me.DataSource is the PersonalSalary record retrieved from the database.
|
|
' Me.SalaryAmout is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetSalaryAmout()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.SalaryAmoutSpecified Then
|
|
|
|
' If the SalaryAmout is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalSalaryTable.SalaryAmout, "#,###")
|
|
|
|
Me.SalaryAmout.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' SalaryAmout is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.SalaryAmout.Text = PersonalSalaryTable.SalaryAmout.Format(PersonalSalaryTable.SalaryAmout.DefaultValue, "#,###")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSalaryCommand()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.SalaryCommand.ID) Then
|
|
|
|
Me.SalaryCommand.Text = Me.PreviousUIData(Me.SalaryCommand.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the SalaryCommand TextBox on the webpage with value from the
|
|
' PersonalSalary database record.
|
|
|
|
' Me.DataSource is the PersonalSalary record retrieved from the database.
|
|
' Me.SalaryCommand is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetSalaryCommand()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.SalaryCommandSpecified Then
|
|
|
|
' If the SalaryCommand is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalSalaryTable.SalaryCommand)
|
|
|
|
Me.SalaryCommand.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' SalaryCommand is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.SalaryCommand.Text = PersonalSalaryTable.SalaryCommand.Format(PersonalSalaryTable.SalaryCommand.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSalaryDate()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.SalaryDate.ID) Then
|
|
|
|
Me.SalaryDate.Text = Me.PreviousUIData(Me.SalaryDate.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the SalaryDate TextBox on the webpage with value from the
|
|
' PersonalSalary database record.
|
|
|
|
' Me.DataSource is the PersonalSalary record retrieved from the database.
|
|
' Me.SalaryDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetSalaryDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.SalaryDateSpecified Then
|
|
|
|
' If the SalaryDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalSalaryTable.SalaryDate, "d MMM yyyy")
|
|
|
|
Me.SalaryDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' SalaryDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.SalaryDate.Text = PersonalSalaryTable.SalaryDate.Format(PersonalSalaryTable.SalaryDate.DefaultValue, "d MMM yyyy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSalaryPlus()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.SalaryPlus.ID) Then
|
|
|
|
Me.SalaryPlus.Text = Me.PreviousUIData(Me.SalaryPlus.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the SalaryPlus TextBox on the webpage with value from the
|
|
' PersonalSalary database record.
|
|
|
|
' Me.DataSource is the PersonalSalary record retrieved from the database.
|
|
' Me.SalaryPlus is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetSalaryPlus()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.SalaryPlusSpecified Then
|
|
|
|
' If the SalaryPlus is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalSalaryTable.SalaryPlus, "#####")
|
|
|
|
Me.SalaryPlus.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' SalaryPlus is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.SalaryPlus.Text = PersonalSalaryTable.SalaryPlus.Format(PersonalSalaryTable.SalaryPlus.DefaultValue, "#####")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSalaryRank()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.SalaryRank.ID) Then
|
|
|
|
Me.SalaryRank.Text = Me.PreviousUIData(Me.SalaryRank.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the SalaryRank TextBox on the webpage with value from the
|
|
' PersonalSalary database record.
|
|
|
|
' Me.DataSource is the PersonalSalary record retrieved from the database.
|
|
' Me.SalaryRank is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetSalaryRank()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.SalaryRankSpecified Then
|
|
|
|
' If the SalaryRank is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalSalaryTable.SalaryRank)
|
|
|
|
Me.SalaryRank.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' SalaryRank is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.SalaryRank.Text = PersonalSalaryTable.SalaryRank.Format(PersonalSalaryTable.SalaryRank.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSalaryStep()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.SalaryStep.ID) Then
|
|
|
|
Me.SalaryStep.Text = Me.PreviousUIData(Me.SalaryStep.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the SalaryStep TextBox on the webpage with value from the
|
|
' PersonalSalary database record.
|
|
|
|
' Me.DataSource is the PersonalSalary record retrieved from the database.
|
|
' Me.SalaryStep is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetSalaryStep()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.SalaryStepSpecified Then
|
|
|
|
' If the SalaryStep is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalSalaryTable.SalaryStep)
|
|
|
|
Me.SalaryStep.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' SalaryStep is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.SalaryStep.Text = PersonalSalaryTable.SalaryStep.Format(PersonalSalaryTable.SalaryStep.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSalaryYear()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.SalaryYear.ID) Then
|
|
|
|
Me.SalaryYear.Text = Me.PreviousUIData(Me.SalaryYear.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the SalaryYear TextBox on the webpage with value from the
|
|
' PersonalSalary database record.
|
|
|
|
' Me.DataSource is the PersonalSalary record retrieved from the database.
|
|
' Me.SalaryYear is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetSalaryYear()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.SalaryYearSpecified Then
|
|
|
|
' If the SalaryYear is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalSalaryTable.SalaryYear)
|
|
|
|
Me.SalaryYear.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' SalaryYear is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.SalaryYear.Text = PersonalSalaryTable.SalaryYear.Format(PersonalSalaryTable.SalaryYear.DefaultValue)
|
|
|
|
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 PersonalSalaryTableControlRow.
|
|
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()
|
|
|
|
Dim parentCtrl As PersonalIdRecordControl
|
|
|
|
|
|
parentCtrl = DirectCast(Me.Page.FindControlRecursively("PersonalIdRecordControl"), PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(parentCtrl) AndAlso IsNothing(parentCtrl.DataSource))
|
|
' Load the record if it is not loaded yet.
|
|
parentCtrl.LoadData()
|
|
End If
|
|
If (IsNothing(parentCtrl) OrElse IsNothing(parentCtrl.DataSource))
|
|
' Get the error message from the application resource file.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoParentRecId", "Persons"))
|
|
End If
|
|
|
|
Me.DataSource.PersonalId = parentCtrl.DataSource.PersonalId
|
|
|
|
' 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, "PersonalSalaryTableControl"), PersonalSalaryTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalSalaryTableControl"), PersonalSalaryTableControl).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 PersonalSalaryTableControlRow.
|
|
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.
|
|
|
|
GetCommandDate2()
|
|
GetPositionSalary()
|
|
GetSalaryAmout()
|
|
GetSalaryCommand()
|
|
GetSalaryDate()
|
|
GetSalaryPlus()
|
|
GetSalaryRank()
|
|
GetSalaryStep()
|
|
GetSalaryYear()
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub GetCommandDate2()
|
|
|
|
' Retrieve the value entered by the user on the CommandDate ASP:TextBox, and
|
|
' save it into the CommandDate field in DataSource PersonalSalary record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.CommandDate2.Text, PersonalSalaryTable.CommandDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetPositionSalary()
|
|
|
|
' Retrieve the value entered by the user on the PositionSalary ASP:TextBox, and
|
|
' save it into the PositionSalary field in DataSource PersonalSalary record.
|
|
' Parse will also validate the amount to ensure it is of the proper format
|
|
' and valid. The format is verified based on the current culture
|
|
' settings including the currency symbol and decimal separator
|
|
' (no currency conversion is performed).
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.PositionSalary.Text, PersonalSalaryTable.PositionSalary)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetSalaryAmout()
|
|
|
|
' Retrieve the value entered by the user on the SalaryAmout ASP:TextBox, and
|
|
' save it into the SalaryAmout field in DataSource PersonalSalary record.
|
|
' Parse will also validate the amount to ensure it is of the proper format
|
|
' and valid. The format is verified based on the current culture
|
|
' settings including the currency symbol and decimal separator
|
|
' (no currency conversion is performed).
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.SalaryAmout.Text, PersonalSalaryTable.SalaryAmout)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetSalaryCommand()
|
|
|
|
' Retrieve the value entered by the user on the SalaryCommand ASP:TextBox, and
|
|
' save it into the SalaryCommand field in DataSource PersonalSalary record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.SalaryCommand.Text, PersonalSalaryTable.SalaryCommand)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetSalaryDate()
|
|
|
|
' Retrieve the value entered by the user on the SalaryDate ASP:TextBox, and
|
|
' save it into the SalaryDate field in DataSource PersonalSalary record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.SalaryDate.Text, PersonalSalaryTable.SalaryDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetSalaryPlus()
|
|
|
|
' Retrieve the value entered by the user on the SalaryPlus ASP:TextBox, and
|
|
' save it into the SalaryPlus field in DataSource PersonalSalary record.
|
|
' Parse will also validate the amount to ensure it is of the proper format
|
|
' and valid. The format is verified based on the current culture
|
|
' settings including the currency symbol and decimal separator
|
|
' (no currency conversion is performed).
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.SalaryPlus.Text, PersonalSalaryTable.SalaryPlus)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetSalaryRank()
|
|
|
|
' Retrieve the value entered by the user on the SalaryRank ASP:TextBox, and
|
|
' save it into the SalaryRank field in DataSource PersonalSalary record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.SalaryRank.Text, PersonalSalaryTable.SalaryRank)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetSalaryStep()
|
|
|
|
' Retrieve the value entered by the user on the SalaryStep ASP:TextBox, and
|
|
' save it into the SalaryStep field in DataSource PersonalSalary record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.SalaryStep.Text, PersonalSalaryTable.SalaryStep)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetSalaryYear()
|
|
|
|
' Retrieve the value entered by the user on the SalaryYear ASP:TextBox, and
|
|
' save it into the SalaryYear field in DataSource PersonalSalary record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.SalaryYear.Text, PersonalSalaryTable.SalaryYear)
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
' To customize, override this method in PersonalSalaryTableControlRow.
|
|
|
|
Public Overridable Function CreateWhereClause() As WhereClause
|
|
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
|
|
|
|
' To customize, override this method in PersonalSalaryTableControlRow.
|
|
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)
|
|
PersonalSalaryTable.DeleteRecord(pkValue)
|
|
|
|
DirectCast(GetParentControlObject(Me, "PersonalSalaryTableControl"), PersonalSalaryTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalSalaryTableControl"), PersonalSalaryTableControl).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
|
|
|
|
|
|
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 PersonalSalaryRowDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Dim tc As PersonalSalaryTableControl = DirectCast(GetParentControlObject(Me, "PersonalSalaryTableControl"), PersonalSalaryTableControl)
|
|
If Not (IsNothing(tc)) Then
|
|
If Not Me.IsNewRecord Then
|
|
tc.AddToDeletedRecordIds(DirectCast(Me, PersonalSalaryTableControlRow))
|
|
End If
|
|
Me.Visible = False
|
|
tc.SetFormulaControls()
|
|
End If
|
|
|
|
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 PersonalSalaryRowEditButton_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalSalaryRowViewButton_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 = "../Shared/ConfigureViewRecord.aspx"
|
|
|
|
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
|
|
|
|
Protected Overridable Sub CommandDate2_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub PositionSalary_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub SalaryAmout_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub SalaryCommand_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub SalaryDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub SalaryPlus_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub SalaryRank_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub SalaryStep_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub SalaryYear_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
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("BasePersonalSalaryTableControlRow_Rec"), String)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me.ViewState("BasePersonalSalaryTableControlRow_Rec") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataSource As PersonalSalaryRecord
|
|
Public Property DataSource() As PersonalSalaryRecord
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
|
|
Set(ByVal value As PersonalSalaryRecord)
|
|
|
|
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 CommandDate2() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CommandDate2"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSalaryRecordRowSelection() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSalaryRecordRowSelection"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSalaryRowDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSalaryRowDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSalaryRowEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSalaryRowEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSalaryRowViewButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSalaryRowViewButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PositionSalary() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PositionSalary"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SalaryAmout() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SalaryAmout"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SalaryCommand() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SalaryCommand"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SalaryDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SalaryDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SalaryPlus() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SalaryPlus"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SalaryRank() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SalaryRank"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SalaryStep() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SalaryStep"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SalaryYear() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SalaryYear"), System.Web.UI.WebControls.TextBox)
|
|
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 PersonalSalaryRecord = 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 PersonalSalaryRecord
|
|
If Not Me.DataSource Is Nothing Then
|
|
Return Me.DataSource
|
|
End If
|
|
|
|
If Not Me.RecordUniqueId Is Nothing Then
|
|
|
|
Return PersonalSalaryTable.GetRecord(Me.RecordUniqueId, True)
|
|
|
|
End If
|
|
|
|
' Localization.
|
|
|
|
Return Nothing
|
|
|
|
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 PersonalSalaryTableControl control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalSalaryTableControl.
|
|
Public Class BasePersonalSalaryTableControl
|
|
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.
|
|
|
|
|
|
|
|
' 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(PersonalSalaryTable.SalaryDate, OrderByItem.OrderDir.Asc)
|
|
|
|
Me.CurrentSortOrder.Add(PersonalSalaryTable.CommandDate, 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()
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalSalaryDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteConfirm", "Persons") & "'));")
|
|
|
|
' Setup the pagination events.
|
|
|
|
AddHandler Me.PersonalSalaryPagination.FirstPage.Click, AddressOf PersonalSalaryPagination_FirstPage_Click
|
|
|
|
AddHandler Me.PersonalSalaryPagination.LastPage.Click, AddressOf PersonalSalaryPagination_LastPage_Click
|
|
|
|
AddHandler Me.PersonalSalaryPagination.NextPage.Click, AddressOf PersonalSalaryPagination_NextPage_Click
|
|
|
|
AddHandler Me.PersonalSalaryPagination.PageSizeButton.Click, AddressOf PersonalSalaryPagination_PageSizeButton_Click
|
|
|
|
AddHandler Me.PersonalSalaryPagination.PreviousPage.Click, AddressOf PersonalSalaryPagination_PreviousPage_Click
|
|
|
|
|
|
' Setup the sorting events.
|
|
|
|
AddHandler Me.CommandDateLabel2.Click, AddressOf CommandDateLabel2_Click
|
|
|
|
AddHandler Me.PositionSalaryLabel.Click, AddressOf PositionSalaryLabel_Click
|
|
|
|
AddHandler Me.SalaryAmoutLabel.Click, AddressOf SalaryAmoutLabel_Click
|
|
|
|
AddHandler Me.SalaryCommandLabel.Click, AddressOf SalaryCommandLabel_Click
|
|
|
|
AddHandler Me.SalaryDateLabel1.Click, AddressOf SalaryDateLabel1_Click
|
|
|
|
AddHandler Me.SalaryPlusLabel.Click, AddressOf SalaryPlusLabel_Click
|
|
|
|
AddHandler Me.SalaryRankLabel1.Click, AddressOf SalaryRankLabel1_Click
|
|
|
|
AddHandler Me.SalaryStepLabel.Click, AddressOf SalaryStepLabel_Click
|
|
|
|
AddHandler Me.SalaryYearLabel.Click, AddressOf SalaryYearLabel_Click
|
|
|
|
' Setup the button events.
|
|
|
|
AddHandler Me.PersonalSalaryAddButton.Click, AddressOf PersonalSalaryAddButton_Click
|
|
|
|
AddHandler Me.PersonalSalaryDeleteButton.Click, AddressOf PersonalSalaryDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalSalaryEditButton.Click, AddressOf PersonalSalaryEditButton_Click
|
|
|
|
AddHandler Me.PersonalSalaryResetButton.Click, AddressOf PersonalSalaryResetButton_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(PersonalSalaryRecord)), PersonalSalaryRecord())
|
|
' 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, PersonalSalaryTable.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 PersonalSalaryTableControlRow 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(PersonalSalaryRecord)), PersonalSalaryRecord())
|
|
Else ' Get the records from the database
|
|
Me.DataSource = PersonalSalaryTable.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()
|
|
|
|
' Turn off the ToggleAll checkbox
|
|
Me.PersonalSalaryToggleAll.Checked = False
|
|
|
|
|
|
' Initialize the page and grand totals. now
|
|
|
|
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, "PersonalSalaryTableControlRepeater"), 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 PersonalSalaryTableControlRow = DirectCast(repItem.FindControl("PersonalSalaryTableControlRow"), PersonalSalaryTableControlRow)
|
|
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
|
|
|
|
SetCommandDateLabel2()
|
|
|
|
|
|
|
|
|
|
|
|
SetPersonalSalaryTableControlCollapsibleRegion()
|
|
|
|
SetPositionSalaryLabel()
|
|
SetSalaryAmoutLabel()
|
|
SetSalaryCommandLabel()
|
|
SetSalaryDateLabel1()
|
|
SetSalaryPlusLabel()
|
|
SetSalaryRankLabel1()
|
|
SetSalaryStepLabel()
|
|
SetSalaryYearLabel()
|
|
' 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()
|
|
|
|
|
|
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.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(PersonalSalaryTable.SalaryDate, OrderByItem.OrderDir.Asc)
|
|
|
|
Me.CurrentSortOrder.Add(PersonalSalaryTable.CommandDate, 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.PersonalSalaryPagination.CurrentPage.Text = (Me.PageIndex + 1).ToString()
|
|
Else
|
|
Me.PersonalSalaryPagination.CurrentPage.Text = "0"
|
|
End If
|
|
Me.PersonalSalaryPagination.PageSize.Text = Me.PageSize.ToString()
|
|
Me.PersonalSalaryPagination.TotalItems.Text = Me.TotalRecords.ToString()
|
|
Me.PersonalSalaryPagination.TotalPages.Text = Me.TotalPages.ToString()
|
|
|
|
' Bind the buttons for PersonalSalaryTableControl pagination.
|
|
|
|
Me.PersonalSalaryPagination.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.PersonalSalaryPagination.LastPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalSalaryPagination.LastPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalSalaryPagination.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.PersonalSalaryPagination.NextPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalSalaryPagination.NextPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalSalaryPagination.NextPage.Enabled = Not (Me.PageIndex = Me.TotalPages - 1)
|
|
End If
|
|
|
|
Me.PersonalSalaryPagination.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 PersonalSalaryTableControlRow
|
|
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.
|
|
PersonalSalaryTable.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 selectedRecordKeyValue as KeyValue = New KeyValue()
|
|
|
|
Dim personalIdRecordControlObj As Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalIdRecordControl"), Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(personalIdRecordControlObj) AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord()) AndAlso personalIdRecordControlObj.GetRecord().IsCreated AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord().PersonalId))
|
|
wc.iAND(PersonalSalaryTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
selectedRecordKeyValue.AddElement(PersonalSalaryTable.PersonalId.InternalName, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
Else
|
|
wc.RunQuery = False
|
|
Return wc
|
|
End If
|
|
|
|
HttpContext.Current.Session("PersonalSalaryTableControlWhereClause") = selectedRecordKeyValue.ToXmlString()
|
|
|
|
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.
|
|
PersonalSalaryTable.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)
|
|
|
|
Dim selectedRecordInPersonalIdRecordControl as String = DirectCast(HttpContext.Current.Session("PersonalSalaryTableControlWhereClause"), String)
|
|
|
|
If Not selectedRecordInPersonalIdRecordControl Is Nothing AndAlso KeyValue.IsXmlKey(selectedRecordInPersonalIdRecordControl) Then
|
|
Dim selectedRecordKeyValue as KeyValue = KeyValue.XmlToKey(selectedRecordInPersonalIdRecordControl)
|
|
|
|
If Not IsNothing(selectedRecordKeyValue) AndAlso selectedRecordKeyValue.ContainsColumn(PersonalSalaryTable.PersonalId) Then
|
|
wc.iAND(PersonalSalaryTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, selectedRecordKeyValue.GetColumnValue(PersonalSalaryTable.PersonalId).ToString())
|
|
End If
|
|
|
|
End If
|
|
|
|
' Adds clauses if values are selected in Filter controls which are configured in the page.
|
|
|
|
|
|
Return wc
|
|
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.PersonalSalaryPagination.PageSize.Text.Trim <> "" Then
|
|
Try
|
|
'Me.PageSize = Integer.Parse(Me.PersonalSalaryPagination.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, "PersonalSalaryTableControlRepeater"), 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 PersonalSalaryTableControlRow = DirectCast(repItem.FindControl("PersonalSalaryTableControlRow"), PersonalSalaryTableControlRow)
|
|
|
|
If recControl.Visible AndAlso recControl.IsNewRecord() Then
|
|
|
|
Dim rec As PersonalSalaryRecord = New PersonalSalaryRecord()
|
|
|
|
If recControl.CommandDate2.Text <> "" Then
|
|
rec.Parse(recControl.CommandDate2.Text, PersonalSalaryTable.CommandDate)
|
|
End If
|
|
If recControl.PositionSalary.Text <> "" Then
|
|
rec.Parse(recControl.PositionSalary.Text, PersonalSalaryTable.PositionSalary)
|
|
End If
|
|
If recControl.SalaryAmout.Text <> "" Then
|
|
rec.Parse(recControl.SalaryAmout.Text, PersonalSalaryTable.SalaryAmout)
|
|
End If
|
|
If recControl.SalaryCommand.Text <> "" Then
|
|
rec.Parse(recControl.SalaryCommand.Text, PersonalSalaryTable.SalaryCommand)
|
|
End If
|
|
If recControl.SalaryDate.Text <> "" Then
|
|
rec.Parse(recControl.SalaryDate.Text, PersonalSalaryTable.SalaryDate)
|
|
End If
|
|
If recControl.SalaryPlus.Text <> "" Then
|
|
rec.Parse(recControl.SalaryPlus.Text, PersonalSalaryTable.SalaryPlus)
|
|
End If
|
|
If recControl.SalaryRank.Text <> "" Then
|
|
rec.Parse(recControl.SalaryRank.Text, PersonalSalaryTable.SalaryRank)
|
|
End If
|
|
If recControl.SalaryStep.Text <> "" Then
|
|
rec.Parse(recControl.SalaryStep.Text, PersonalSalaryTable.SalaryStep)
|
|
End If
|
|
If recControl.SalaryYear.Text <> "" Then
|
|
rec.Parse(recControl.SalaryYear.Text, PersonalSalaryTable.SalaryYear)
|
|
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 PersonalSalaryRecord())
|
|
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(PersonalSalaryRecord)), PersonalSalaryRecord())
|
|
|
|
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 PersonalSalaryTableControlRow)
|
|
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 PersonalSalaryTableControlRow) 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 SetCommandDateLabel2()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalSalaryTableControlCollapsibleRegion()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPositionSalaryLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSalaryAmoutLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSalaryCommandLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSalaryDateLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSalaryPlusLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSalaryRankLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSalaryStepLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSalaryYearLabel()
|
|
|
|
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.
|
|
Dim added As Boolean = Me.AddNewRecord > 0
|
|
Me.LoadData()
|
|
Me.DataBind()
|
|
|
|
If added Then
|
|
Me.SetFocusToAddedRow()
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
Catch ex As Exception
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
End Sub
|
|
|
|
'this function sets focus to the first editable element in the new added row in the editable table
|
|
Protected Overridable Sub SetFocusToAddedRow()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalSalaryTableControlRepeater"), System.Web.UI.WebControls.Repeater)
|
|
If rep Is Nothing OrElse rep.Items.Count = 0 Then Return
|
|
Dim repItem As System.Web.UI.WebControls.RepeaterItem
|
|
For Each repItem In rep.Items
|
|
'Load scripts to table rows
|
|
Me.Page.LoadFocusScripts(repItem)
|
|
Dim recControl As PersonalSalaryTableControlRow = DirectCast(repItem.FindControl("PersonalSalaryTableControlRow"), PersonalSalaryTableControlRow)
|
|
If recControl.IsNewRecord Then
|
|
For Each field As Control In recControl.Controls
|
|
If field.Visible AndAlso Me.Page.IsControlEditable(field, False) Then
|
|
'set focus on the first editable field in the new row
|
|
field.Focus()
|
|
Dim updPan As UpdatePanel = DirectCast(Me.Page.FindControlRecursively("UpdatePanel1"), UpdatePanel)
|
|
If Not updPan Is Nothing Then updPan.Update()
|
|
Return
|
|
End If
|
|
Next
|
|
Return
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub SaveControlsToSession()
|
|
MyBase.SaveControlsToSession()
|
|
|
|
' Save filter controls to values to session.
|
|
|
|
|
|
'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.
|
|
|
|
HttpContext.Current.Session("AppRelativeVirtualPath") = Me.Page.AppRelativeVirtualPath
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub ClearControlsFromSession()
|
|
MyBase.ClearControlsFromSession()
|
|
|
|
' Clear filter controls values from the session.
|
|
|
|
|
|
' 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("PersonalSalaryTableControl_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("PersonalSalaryTableControl_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 PersonalSalaryPagination_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 PersonalSalaryPagination_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 PersonalSalaryPagination_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 PersonalSalaryPagination_PageSizeButton_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
Try
|
|
|
|
Me.DataChanged = True
|
|
|
|
Me.PageSize = Integer.Parse(Me.PersonalSalaryPagination.PageSize.Text)
|
|
|
|
Me.PageIndex = Integer.Parse(Me.PersonalSalaryPagination.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 PersonalSalaryPagination_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 CommandDateLabel2_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by CommandDate when clicked.
|
|
|
|
' Get previous sorting state for CommandDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalSalaryTable.CommandDate)
|
|
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 CommandDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalSalaryTable.CommandDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by CommandDate, 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 PositionSalaryLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by PositionSalary when clicked.
|
|
|
|
' Get previous sorting state for PositionSalary.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalSalaryTable.PositionSalary)
|
|
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 PositionSalary.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalSalaryTable.PositionSalary, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by PositionSalary, 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 SalaryAmoutLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by SalaryAmout when clicked.
|
|
|
|
' Get previous sorting state for SalaryAmout.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalSalaryTable.SalaryAmout)
|
|
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 SalaryAmout.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalSalaryTable.SalaryAmout, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by SalaryAmout, 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 SalaryCommandLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by SalaryCommand when clicked.
|
|
|
|
' Get previous sorting state for SalaryCommand.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalSalaryTable.SalaryCommand)
|
|
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 SalaryCommand.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalSalaryTable.SalaryCommand, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by SalaryCommand, 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 SalaryDateLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by SalaryDate when clicked.
|
|
|
|
' Get previous sorting state for SalaryDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalSalaryTable.SalaryDate)
|
|
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 SalaryDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalSalaryTable.SalaryDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by SalaryDate, 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 SalaryPlusLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by SalaryPlus when clicked.
|
|
|
|
' Get previous sorting state for SalaryPlus.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalSalaryTable.SalaryPlus)
|
|
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 SalaryPlus.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalSalaryTable.SalaryPlus, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by SalaryPlus, 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 SalaryRankLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by SalaryRank when clicked.
|
|
|
|
' Get previous sorting state for SalaryRank.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalSalaryTable.SalaryRank)
|
|
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 SalaryRank.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalSalaryTable.SalaryRank, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by SalaryRank, 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 SalaryStepLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by SalaryStep when clicked.
|
|
|
|
' Get previous sorting state for SalaryStep.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalSalaryTable.SalaryStep)
|
|
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 SalaryStep.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalSalaryTable.SalaryStep, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by SalaryStep, 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 SalaryYearLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by SalaryYear when clicked.
|
|
|
|
' Get previous sorting state for SalaryYear.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalSalaryTable.SalaryYear)
|
|
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 SalaryYear.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalSalaryTable.SalaryYear, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by SalaryYear, 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 PersonalSalaryAddButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
Me.AddNewRecord = 1
|
|
Me.DataChanged = 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 PersonalSalaryDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Me.DeleteSelectedRecords(True)
|
|
Me.SetFormulaControls()
|
|
|
|
|
|
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 PersonalSalaryEditButton_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalSalaryResetButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
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(PersonalSalaryTable.SalaryDate, OrderByItem.OrderDir.Asc)
|
|
|
|
Me.CurrentSortOrder.Add(PersonalSalaryTable.CommandDate, OrderByItem.OrderDir.Asc)
|
|
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
|
|
' 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 = PersonalSalaryTable.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 PersonalSalaryRecord = Nothing
|
|
Public Property DataSource() As PersonalSalaryRecord ()
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
Set(ByVal value() As PersonalSalaryRecord)
|
|
Me._DataSource = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Helper Properties"
|
|
|
|
Public ReadOnly Property CommandDateLabel2() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CommandDateLabel2"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSalaryAddButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSalaryAddButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSalaryDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSalaryDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSalaryEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSalaryEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSalaryPagination() As Persons.UI.IPagination
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSalaryPagination"), Persons.UI.IPagination)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSalaryResetButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSalaryResetButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSalaryTableControlCollapsibleRegion() As System.Web.UI.WebControls.Panel
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSalaryTableControlCollapsibleRegion"), System.Web.UI.WebControls.Panel)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSalaryToggleAll() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSalaryToggleAll"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PositionSalaryLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PositionSalaryLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SalaryAmoutLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SalaryAmoutLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SalaryCommandLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SalaryCommandLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SalaryDateLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SalaryDateLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SalaryPlusLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SalaryPlusLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SalaryRankLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SalaryRankLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SalaryStepLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SalaryStepLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SalaryYearLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SalaryYearLabel"), System.Web.UI.WebControls.LinkButton)
|
|
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 PersonalSalaryTableControlRow = 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 PersonalSalaryRecord = 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 GetSelectedRecordIndex() As Integer
|
|
Dim counter As Integer = 0
|
|
Dim recControl As PersonalSalaryTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalSalaryRecordRowSelection.Checked Then
|
|
Return counter
|
|
End If
|
|
counter += 1
|
|
Next
|
|
Return -1
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControl() As PersonalSalaryTableControlRow
|
|
Dim selectedList() As PersonalSalaryTableControlRow = Me.GetSelectedRecordControls()
|
|
If selectedList.Length = 0 Then
|
|
Return Nothing
|
|
End If
|
|
Return selectedList(0)
|
|
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControls() As PersonalSalaryTableControlRow()
|
|
|
|
Dim selectedList As ArrayList = New ArrayList(25)
|
|
Dim recControl As PersonalSalaryTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalSalaryRecordRowSelection IsNot Nothing AndAlso recControl.PersonalSalaryRecordRowSelection.Checked Then
|
|
selectedList.Add(recControl)
|
|
End If
|
|
Next
|
|
Return DirectCast(selectedList.ToArray(GetType(PersonalSalaryTableControlRow)), PersonalSalaryTableControlRow())
|
|
|
|
End Function
|
|
|
|
Public Overridable Sub DeleteSelectedRecords(ByVal deferDeletion As Boolean)
|
|
Dim recList() As PersonalSalaryTableControlRow = Me.GetSelectedRecordControls()
|
|
If recList.Length = 0 Then
|
|
' Localization.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoRecSelected", "Persons"))
|
|
End If
|
|
|
|
Dim recCtl As PersonalSalaryTableControlRow
|
|
For Each recCtl In recList
|
|
If deferDeletion Then
|
|
If Not recCtl.IsNewRecord Then
|
|
|
|
Me.AddToDeletedRecordIds(recCtl)
|
|
|
|
End If
|
|
recCtl.Visible = False
|
|
|
|
recCtl.PersonalSalaryRecordRowSelection.Checked = 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 PersonalSalaryTableControlRow()
|
|
Dim recList As ArrayList = New ArrayList()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalSalaryTableControlRepeater"), 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 PersonalSalaryTableControlRow = DirectCast(repItem.FindControl("PersonalSalaryTableControlRow"), PersonalSalaryTableControlRow)
|
|
recList.Add(recControl)
|
|
|
|
Next
|
|
|
|
Return DirectCast(recList.ToArray(GetType(PersonalSalaryTableControlRow)), PersonalSalaryTableControlRow())
|
|
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 PersonalSpecialSkillTableControlRow control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalSpecialSkillTableControlRow.
|
|
Public Class BasePersonalSpecialSkillTableControlRow
|
|
Inherits Persons.UI.BaseApplicationRecordControl
|
|
|
|
' To customize, override this method in PersonalSpecialSkillTableControlRow.
|
|
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 PersonalSpecialSkillTableControlRow.
|
|
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)
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalSpecialSkillRowDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteRecordConfirm", "Persons") & "'));")
|
|
|
|
|
|
' Register the event handlers.
|
|
|
|
AddHandler Me.PersonalSpecialSkillRowDeleteButton.Click, AddressOf PersonalSpecialSkillRowDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalSpecialSkillRowEditButton.Click, AddressOf PersonalSpecialSkillRowEditButton_Click
|
|
|
|
AddHandler Me.PersonalSpecialSkillRowViewButton.Click, AddressOf PersonalSpecialSkillRowViewButton_Click
|
|
|
|
AddHandler Me.Level1.TextChanged, AddressOf Level1_TextChanged
|
|
|
|
AddHandler Me.Skill.TextChanged, AddressOf Skill_TextChanged
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Load the data from the database into the DataSource PersonalSpecialSkill 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 = PersonalSpecialSkillTable.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 BasePersonalSpecialSkillTableControl when the data for the entire
|
|
' table is loaded.
|
|
|
|
Me.DataSource = New PersonalSpecialSkillRecord()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
' Populate the UI controls using the DataSource. To customize, override this method in PersonalSpecialSkillTableControlRow.
|
|
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
|
|
|
|
SetLevel1()
|
|
|
|
|
|
|
|
|
|
SetSkill()
|
|
|
|
|
|
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 SetLevel1()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Level1.ID) Then
|
|
|
|
Me.Level1.Text = Me.PreviousUIData(Me.Level1.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Level TextBox on the webpage with value from the
|
|
' PersonalSpecialSkill database record.
|
|
|
|
' Me.DataSource is the PersonalSpecialSkill record retrieved from the database.
|
|
' Me.Level1 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetLevel1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.LevelSpecified Then
|
|
|
|
' If the Level is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalSpecialSkillTable.Level)
|
|
|
|
Me.Level1.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Level is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Level1.Text = PersonalSpecialSkillTable.Level.Format(PersonalSpecialSkillTable.Level.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSkill()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Skill.ID) Then
|
|
|
|
Me.Skill.Text = Me.PreviousUIData(Me.Skill.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Skill TextBox on the webpage with value from the
|
|
' PersonalSpecialSkill database record.
|
|
|
|
' Me.DataSource is the PersonalSpecialSkill record retrieved from the database.
|
|
' Me.Skill is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetSkill()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.SkillSpecified Then
|
|
|
|
' If the Skill is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalSpecialSkillTable.Skill)
|
|
|
|
Me.Skill.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Skill is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Skill.Text = PersonalSpecialSkillTable.Skill.Format(PersonalSpecialSkillTable.Skill.DefaultValue)
|
|
|
|
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 PersonalSpecialSkillTableControlRow.
|
|
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()
|
|
|
|
Dim parentCtrl As PersonalIdRecordControl
|
|
|
|
|
|
parentCtrl = DirectCast(Me.Page.FindControlRecursively("PersonalIdRecordControl"), PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(parentCtrl) AndAlso IsNothing(parentCtrl.DataSource))
|
|
' Load the record if it is not loaded yet.
|
|
parentCtrl.LoadData()
|
|
End If
|
|
If (IsNothing(parentCtrl) OrElse IsNothing(parentCtrl.DataSource))
|
|
' Get the error message from the application resource file.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoParentRecId", "Persons"))
|
|
End If
|
|
|
|
Me.DataSource.PersonalId = parentCtrl.DataSource.PersonalId
|
|
|
|
' 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, "PersonalSpecialSkillTableControl"), PersonalSpecialSkillTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalSpecialSkillTableControl"), PersonalSpecialSkillTableControl).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 PersonalSpecialSkillTableControlRow.
|
|
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.
|
|
|
|
GetLevel1()
|
|
GetSkill()
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub GetLevel1()
|
|
|
|
' Retrieve the value entered by the user on the Level ASP:TextBox, and
|
|
' save it into the Level field in DataSource PersonalSpecialSkill record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Level1.Text, PersonalSpecialSkillTable.Level)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetSkill()
|
|
|
|
' Retrieve the value entered by the user on the Skill ASP:TextBox, and
|
|
' save it into the Skill field in DataSource PersonalSpecialSkill record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Skill.Text, PersonalSpecialSkillTable.Skill)
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
' To customize, override this method in PersonalSpecialSkillTableControlRow.
|
|
|
|
Public Overridable Function CreateWhereClause() As WhereClause
|
|
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
|
|
|
|
' To customize, override this method in PersonalSpecialSkillTableControlRow.
|
|
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)
|
|
PersonalSpecialSkillTable.DeleteRecord(pkValue)
|
|
|
|
DirectCast(GetParentControlObject(Me, "PersonalSpecialSkillTableControl"), PersonalSpecialSkillTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalSpecialSkillTableControl"), PersonalSpecialSkillTableControl).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
|
|
|
|
|
|
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 PersonalSpecialSkillRowDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Dim tc As PersonalSpecialSkillTableControl = DirectCast(GetParentControlObject(Me, "PersonalSpecialSkillTableControl"), PersonalSpecialSkillTableControl)
|
|
If Not (IsNothing(tc)) Then
|
|
If Not Me.IsNewRecord Then
|
|
tc.AddToDeletedRecordIds(DirectCast(Me, PersonalSpecialSkillTableControlRow))
|
|
End If
|
|
Me.Visible = False
|
|
tc.SetFormulaControls()
|
|
End If
|
|
|
|
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 PersonalSpecialSkillRowEditButton_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalSpecialSkillRowViewButton_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 = "../Shared/ConfigureViewRecord.aspx"
|
|
|
|
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
|
|
|
|
Protected Overridable Sub Level1_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Skill_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
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("BasePersonalSpecialSkillTableControlRow_Rec"), String)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me.ViewState("BasePersonalSpecialSkillTableControlRow_Rec") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataSource As PersonalSpecialSkillRecord
|
|
Public Property DataSource() As PersonalSpecialSkillRecord
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
|
|
Set(ByVal value As PersonalSpecialSkillRecord)
|
|
|
|
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 Level1() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Level1"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSpecialSkillRecordRowSelection() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSpecialSkillRecordRowSelection"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSpecialSkillRowDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSpecialSkillRowDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSpecialSkillRowEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSpecialSkillRowEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSpecialSkillRowViewButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSpecialSkillRowViewButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Skill() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Skill"), System.Web.UI.WebControls.TextBox)
|
|
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 PersonalSpecialSkillRecord = 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 PersonalSpecialSkillRecord
|
|
If Not Me.DataSource Is Nothing Then
|
|
Return Me.DataSource
|
|
End If
|
|
|
|
If Not Me.RecordUniqueId Is Nothing Then
|
|
|
|
Return PersonalSpecialSkillTable.GetRecord(Me.RecordUniqueId, True)
|
|
|
|
End If
|
|
|
|
' Localization.
|
|
|
|
Return Nothing
|
|
|
|
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 PersonalSpecialSkillTableControl control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalSpecialSkillTableControl.
|
|
Public Class BasePersonalSpecialSkillTableControl
|
|
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.
|
|
|
|
|
|
|
|
' 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)
|
|
|
|
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()
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalSpecialSkillDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteConfirm", "Persons") & "'));")
|
|
|
|
' Setup the pagination events.
|
|
|
|
AddHandler Me.PersonalSpecialSkillPagination.FirstPage.Click, AddressOf PersonalSpecialSkillPagination_FirstPage_Click
|
|
|
|
AddHandler Me.PersonalSpecialSkillPagination.LastPage.Click, AddressOf PersonalSpecialSkillPagination_LastPage_Click
|
|
|
|
AddHandler Me.PersonalSpecialSkillPagination.NextPage.Click, AddressOf PersonalSpecialSkillPagination_NextPage_Click
|
|
|
|
AddHandler Me.PersonalSpecialSkillPagination.PageSizeButton.Click, AddressOf PersonalSpecialSkillPagination_PageSizeButton_Click
|
|
|
|
AddHandler Me.PersonalSpecialSkillPagination.PreviousPage.Click, AddressOf PersonalSpecialSkillPagination_PreviousPage_Click
|
|
|
|
|
|
' Setup the sorting events.
|
|
|
|
AddHandler Me.LevelLabel3.Click, AddressOf LevelLabel3_Click
|
|
|
|
AddHandler Me.SkillLabel1.Click, AddressOf SkillLabel1_Click
|
|
|
|
' Setup the button events.
|
|
|
|
AddHandler Me.PersonalSpecialSkillAddButton.Click, AddressOf PersonalSpecialSkillAddButton_Click
|
|
|
|
AddHandler Me.PersonalSpecialSkillDeleteButton.Click, AddressOf PersonalSpecialSkillDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalSpecialSkillEditButton.Click, AddressOf PersonalSpecialSkillEditButton_Click
|
|
|
|
AddHandler Me.PersonalSpecialSkillResetButton.Click, AddressOf PersonalSpecialSkillResetButton_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(PersonalSpecialSkillRecord)), PersonalSpecialSkillRecord())
|
|
' 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, PersonalSpecialSkillTable.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 PersonalSpecialSkillTableControlRow 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(PersonalSpecialSkillRecord)), PersonalSpecialSkillRecord())
|
|
Else ' Get the records from the database
|
|
Me.DataSource = PersonalSpecialSkillTable.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()
|
|
|
|
' Turn off the ToggleAll checkbox
|
|
Me.PersonalSpecialSkillToggleAll.Checked = False
|
|
|
|
|
|
' Initialize the page and grand totals. now
|
|
|
|
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, "PersonalSpecialSkillTableControlRepeater"), 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 PersonalSpecialSkillTableControlRow = DirectCast(repItem.FindControl("PersonalSpecialSkillTableControlRow"), PersonalSpecialSkillTableControlRow)
|
|
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
|
|
|
|
SetLevelLabel3()
|
|
|
|
|
|
|
|
|
|
|
|
SetPersonalSpecialSkillTableControlCollapsibleRegion()
|
|
|
|
SetSkillLabel1()
|
|
' 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()
|
|
|
|
|
|
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.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)
|
|
|
|
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.PersonalSpecialSkillPagination.CurrentPage.Text = (Me.PageIndex + 1).ToString()
|
|
Else
|
|
Me.PersonalSpecialSkillPagination.CurrentPage.Text = "0"
|
|
End If
|
|
Me.PersonalSpecialSkillPagination.PageSize.Text = Me.PageSize.ToString()
|
|
Me.PersonalSpecialSkillPagination.TotalItems.Text = Me.TotalRecords.ToString()
|
|
Me.PersonalSpecialSkillPagination.TotalPages.Text = Me.TotalPages.ToString()
|
|
|
|
' Bind the buttons for PersonalSpecialSkillTableControl pagination.
|
|
|
|
Me.PersonalSpecialSkillPagination.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.PersonalSpecialSkillPagination.LastPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalSpecialSkillPagination.LastPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalSpecialSkillPagination.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.PersonalSpecialSkillPagination.NextPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalSpecialSkillPagination.NextPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalSpecialSkillPagination.NextPage.Enabled = Not (Me.PageIndex = Me.TotalPages - 1)
|
|
End If
|
|
|
|
Me.PersonalSpecialSkillPagination.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 PersonalSpecialSkillTableControlRow
|
|
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.
|
|
PersonalSpecialSkillTable.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 selectedRecordKeyValue as KeyValue = New KeyValue()
|
|
|
|
Dim personalIdRecordControlObj As Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalIdRecordControl"), Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(personalIdRecordControlObj) AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord()) AndAlso personalIdRecordControlObj.GetRecord().IsCreated AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord().PersonalId))
|
|
wc.iAND(PersonalSpecialSkillTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
selectedRecordKeyValue.AddElement(PersonalSpecialSkillTable.PersonalId.InternalName, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
Else
|
|
wc.RunQuery = False
|
|
Return wc
|
|
End If
|
|
|
|
HttpContext.Current.Session("PersonalSpecialSkillTableControlWhereClause") = selectedRecordKeyValue.ToXmlString()
|
|
|
|
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.
|
|
PersonalSpecialSkillTable.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)
|
|
|
|
Dim selectedRecordInPersonalIdRecordControl as String = DirectCast(HttpContext.Current.Session("PersonalSpecialSkillTableControlWhereClause"), String)
|
|
|
|
If Not selectedRecordInPersonalIdRecordControl Is Nothing AndAlso KeyValue.IsXmlKey(selectedRecordInPersonalIdRecordControl) Then
|
|
Dim selectedRecordKeyValue as KeyValue = KeyValue.XmlToKey(selectedRecordInPersonalIdRecordControl)
|
|
|
|
If Not IsNothing(selectedRecordKeyValue) AndAlso selectedRecordKeyValue.ContainsColumn(PersonalSpecialSkillTable.PersonalId) Then
|
|
wc.iAND(PersonalSpecialSkillTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, selectedRecordKeyValue.GetColumnValue(PersonalSpecialSkillTable.PersonalId).ToString())
|
|
End If
|
|
|
|
End If
|
|
|
|
' Adds clauses if values are selected in Filter controls which are configured in the page.
|
|
|
|
|
|
Return wc
|
|
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.PersonalSpecialSkillPagination.PageSize.Text.Trim <> "" Then
|
|
Try
|
|
'Me.PageSize = Integer.Parse(Me.PersonalSpecialSkillPagination.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, "PersonalSpecialSkillTableControlRepeater"), 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 PersonalSpecialSkillTableControlRow = DirectCast(repItem.FindControl("PersonalSpecialSkillTableControlRow"), PersonalSpecialSkillTableControlRow)
|
|
|
|
If recControl.Visible AndAlso recControl.IsNewRecord() Then
|
|
|
|
Dim rec As PersonalSpecialSkillRecord = New PersonalSpecialSkillRecord()
|
|
|
|
If recControl.Level1.Text <> "" Then
|
|
rec.Parse(recControl.Level1.Text, PersonalSpecialSkillTable.Level)
|
|
End If
|
|
If recControl.Skill.Text <> "" Then
|
|
rec.Parse(recControl.Skill.Text, PersonalSpecialSkillTable.Skill)
|
|
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 PersonalSpecialSkillRecord())
|
|
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(PersonalSpecialSkillRecord)), PersonalSpecialSkillRecord())
|
|
|
|
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 PersonalSpecialSkillTableControlRow)
|
|
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 PersonalSpecialSkillTableControlRow) 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 SetLevelLabel3()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalSpecialSkillTableControlCollapsibleRegion()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSkillLabel1()
|
|
|
|
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.
|
|
Dim added As Boolean = Me.AddNewRecord > 0
|
|
Me.LoadData()
|
|
Me.DataBind()
|
|
|
|
If added Then
|
|
Me.SetFocusToAddedRow()
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
Catch ex As Exception
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
End Sub
|
|
|
|
'this function sets focus to the first editable element in the new added row in the editable table
|
|
Protected Overridable Sub SetFocusToAddedRow()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalSpecialSkillTableControlRepeater"), System.Web.UI.WebControls.Repeater)
|
|
If rep Is Nothing OrElse rep.Items.Count = 0 Then Return
|
|
Dim repItem As System.Web.UI.WebControls.RepeaterItem
|
|
For Each repItem In rep.Items
|
|
'Load scripts to table rows
|
|
Me.Page.LoadFocusScripts(repItem)
|
|
Dim recControl As PersonalSpecialSkillTableControlRow = DirectCast(repItem.FindControl("PersonalSpecialSkillTableControlRow"), PersonalSpecialSkillTableControlRow)
|
|
If recControl.IsNewRecord Then
|
|
For Each field As Control In recControl.Controls
|
|
If field.Visible AndAlso Me.Page.IsControlEditable(field, False) Then
|
|
'set focus on the first editable field in the new row
|
|
field.Focus()
|
|
Dim updPan As UpdatePanel = DirectCast(Me.Page.FindControlRecursively("UpdatePanel1"), UpdatePanel)
|
|
If Not updPan Is Nothing Then updPan.Update()
|
|
Return
|
|
End If
|
|
Next
|
|
Return
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub SaveControlsToSession()
|
|
MyBase.SaveControlsToSession()
|
|
|
|
' Save filter controls to values to session.
|
|
|
|
|
|
'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.
|
|
|
|
HttpContext.Current.Session("AppRelativeVirtualPath") = Me.Page.AppRelativeVirtualPath
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub ClearControlsFromSession()
|
|
MyBase.ClearControlsFromSession()
|
|
|
|
' Clear filter controls values from the session.
|
|
|
|
|
|
' 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("PersonalSpecialSkillTableControl_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("PersonalSpecialSkillTableControl_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 PersonalSpecialSkillPagination_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 PersonalSpecialSkillPagination_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 PersonalSpecialSkillPagination_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 PersonalSpecialSkillPagination_PageSizeButton_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
Try
|
|
|
|
Me.DataChanged = True
|
|
|
|
Me.PageSize = Integer.Parse(Me.PersonalSpecialSkillPagination.PageSize.Text)
|
|
|
|
Me.PageIndex = Integer.Parse(Me.PersonalSpecialSkillPagination.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 PersonalSpecialSkillPagination_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 LevelLabel3_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Level when clicked.
|
|
|
|
' Get previous sorting state for Level.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalSpecialSkillTable.Level)
|
|
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 Level.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalSpecialSkillTable.Level, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Level, 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 SkillLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Skill when clicked.
|
|
|
|
' Get previous sorting state for Skill.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalSpecialSkillTable.Skill)
|
|
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 Skill.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalSpecialSkillTable.Skill, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Skill, 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 PersonalSpecialSkillAddButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
Me.AddNewRecord = 1
|
|
Me.DataChanged = 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 PersonalSpecialSkillDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Me.DeleteSelectedRecords(True)
|
|
Me.SetFormulaControls()
|
|
|
|
|
|
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 PersonalSpecialSkillEditButton_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalSpecialSkillResetButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
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)
|
|
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
|
|
' 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 = PersonalSpecialSkillTable.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 PersonalSpecialSkillRecord = Nothing
|
|
Public Property DataSource() As PersonalSpecialSkillRecord ()
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
Set(ByVal value() As PersonalSpecialSkillRecord)
|
|
Me._DataSource = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Helper Properties"
|
|
|
|
Public ReadOnly Property LevelLabel3() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "LevelLabel3"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSpecialSkillAddButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSpecialSkillAddButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSpecialSkillDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSpecialSkillDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSpecialSkillEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSpecialSkillEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSpecialSkillPagination() As Persons.UI.IPagination
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSpecialSkillPagination"), Persons.UI.IPagination)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSpecialSkillResetButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSpecialSkillResetButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSpecialSkillTableControlCollapsibleRegion() As System.Web.UI.WebControls.Panel
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSpecialSkillTableControlCollapsibleRegion"), System.Web.UI.WebControls.Panel)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSpecialSkillToggleAll() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSpecialSkillToggleAll"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SkillLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SkillLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
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 PersonalSpecialSkillTableControlRow = 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 PersonalSpecialSkillRecord = 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 GetSelectedRecordIndex() As Integer
|
|
Dim counter As Integer = 0
|
|
Dim recControl As PersonalSpecialSkillTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalSpecialSkillRecordRowSelection.Checked Then
|
|
Return counter
|
|
End If
|
|
counter += 1
|
|
Next
|
|
Return -1
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControl() As PersonalSpecialSkillTableControlRow
|
|
Dim selectedList() As PersonalSpecialSkillTableControlRow = Me.GetSelectedRecordControls()
|
|
If selectedList.Length = 0 Then
|
|
Return Nothing
|
|
End If
|
|
Return selectedList(0)
|
|
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControls() As PersonalSpecialSkillTableControlRow()
|
|
|
|
Dim selectedList As ArrayList = New ArrayList(25)
|
|
Dim recControl As PersonalSpecialSkillTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalSpecialSkillRecordRowSelection IsNot Nothing AndAlso recControl.PersonalSpecialSkillRecordRowSelection.Checked Then
|
|
selectedList.Add(recControl)
|
|
End If
|
|
Next
|
|
Return DirectCast(selectedList.ToArray(GetType(PersonalSpecialSkillTableControlRow)), PersonalSpecialSkillTableControlRow())
|
|
|
|
End Function
|
|
|
|
Public Overridable Sub DeleteSelectedRecords(ByVal deferDeletion As Boolean)
|
|
Dim recList() As PersonalSpecialSkillTableControlRow = Me.GetSelectedRecordControls()
|
|
If recList.Length = 0 Then
|
|
' Localization.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoRecSelected", "Persons"))
|
|
End If
|
|
|
|
Dim recCtl As PersonalSpecialSkillTableControlRow
|
|
For Each recCtl In recList
|
|
If deferDeletion Then
|
|
If Not recCtl.IsNewRecord Then
|
|
|
|
Me.AddToDeletedRecordIds(recCtl)
|
|
|
|
End If
|
|
recCtl.Visible = False
|
|
|
|
recCtl.PersonalSpecialSkillRecordRowSelection.Checked = 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 PersonalSpecialSkillTableControlRow()
|
|
Dim recList As ArrayList = New ArrayList()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalSpecialSkillTableControlRepeater"), 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 PersonalSpecialSkillTableControlRow = DirectCast(repItem.FindControl("PersonalSpecialSkillTableControlRow"), PersonalSpecialSkillTableControlRow)
|
|
recList.Add(recControl)
|
|
|
|
Next
|
|
|
|
Return DirectCast(recList.ToArray(GetType(PersonalSpecialSkillTableControlRow)), PersonalSpecialSkillTableControlRow())
|
|
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 PersonalSportSkillTableControl1Row control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalSportSkillTableControl1Row.
|
|
Public Class BasePersonalSportSkillTableControl1Row
|
|
Inherits Persons.UI.BaseApplicationRecordControl
|
|
|
|
' To customize, override this method in PersonalSportSkillTableControl1Row.
|
|
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 PersonalSportSkillTableControl1Row.
|
|
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)
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalSportSkillRowDeleteButton1.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteRecordConfirm", "Persons") & "'));")
|
|
|
|
|
|
' Register the event handlers.
|
|
|
|
AddHandler Me.PersonalSportSkillRowDeleteButton1.Click, AddressOf PersonalSportSkillRowDeleteButton1_Click
|
|
|
|
AddHandler Me.PersonalSportSkillRowEditButton1.Click, AddressOf PersonalSportSkillRowEditButton1_Click
|
|
|
|
AddHandler Me.PersonalSportSkillRowViewButton1.Click, AddressOf PersonalSportSkillRowViewButton1_Click
|
|
|
|
Me.SportId1AddRecordLink.PostBackUrl = "../Sport/AddSport.aspx" & "?Target=" & Me.SportId1.ClientID & "&DFKA=" & HttpUtility.UrlEncode("SPORT")
|
|
Me.SportId1AddRecordLink.Attributes.Item("onClick") = "window.open('" & Me.SportId1AddRecordLink.PostBackUrl & "','_blank', 'width=900, height=700, resizable, scrollbars, modal=yes'); return false;"
|
|
|
|
AddHandler Me.SportId1.SelectedIndexChanged, AddressOf SportId1_SelectedIndexChanged
|
|
|
|
AddHandler Me.Level3.TextChanged, AddressOf Level3_TextChanged
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Load the data from the database into the DataSource PersonalSportSkill 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 = PersonalSportSkillTable.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 BasePersonalSportSkillTableControl1 when the data for the entire
|
|
' table is loaded.
|
|
|
|
Me.DataSource = New PersonalSportSkillRecord()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
' Populate the UI controls using the DataSource. To customize, override this method in PersonalSportSkillTableControl1Row.
|
|
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
|
|
|
|
SetLevel3()
|
|
|
|
|
|
|
|
|
|
SetSportId1()
|
|
|
|
|
|
|
|
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 SetLevel3()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Level3.ID) Then
|
|
|
|
Me.Level3.Text = Me.PreviousUIData(Me.Level3.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Level TextBox on the webpage with value from the
|
|
' PersonalSportSkill database record.
|
|
|
|
' Me.DataSource is the PersonalSportSkill record retrieved from the database.
|
|
' Me.Level3 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetLevel3()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.LevelSpecified Then
|
|
|
|
' If the Level is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalSportSkillTable.Level)
|
|
|
|
Me.Level3.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Level is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Level3.Text = PersonalSportSkillTable.Level.Format(PersonalSportSkillTable.Level.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSportId1()
|
|
|
|
' If selection was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.SportId1.ID) Then
|
|
If Me.PreviousUIData(Me.SportId1.ID) Is Nothing
|
|
Me.PopulateSportId1DropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateSportId1DropDownList(Me.PreviousUIData(Me.SportId1.ID).ToString(), 100)
|
|
End If
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the SportId DropDownList on the webpage with value from the
|
|
' PersonalSportSkill database record.
|
|
|
|
' Me.DataSource is the PersonalSportSkill record retrieved from the database.
|
|
' Me.SportId1 is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetSportId1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.SportIdSpecified Then
|
|
|
|
' If the SportId is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateSportId1DropDownList(Me.DataSource.SportId.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' SportId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateSportId1DropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateSportId1DropDownList(PersonalSportSkillTable.SportId.DefaultValue, 100)
|
|
End If
|
|
|
|
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 PersonalSportSkillTableControl1Row.
|
|
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()
|
|
|
|
Dim parentCtrl As PersonalIdRecordControl
|
|
|
|
|
|
parentCtrl = DirectCast(Me.Page.FindControlRecursively("PersonalIdRecordControl"), PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(parentCtrl) AndAlso IsNothing(parentCtrl.DataSource))
|
|
' Load the record if it is not loaded yet.
|
|
parentCtrl.LoadData()
|
|
End If
|
|
If (IsNothing(parentCtrl) OrElse IsNothing(parentCtrl.DataSource))
|
|
' Get the error message from the application resource file.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoParentRecId", "Persons"))
|
|
End If
|
|
|
|
Me.DataSource.PersonalId = parentCtrl.DataSource.PersonalId
|
|
|
|
' 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, "PersonalSportSkillTableControl1"), PersonalSportSkillTableControl1).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalSportSkillTableControl1"), PersonalSportSkillTableControl1).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 PersonalSportSkillTableControl1Row.
|
|
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.
|
|
|
|
GetLevel3()
|
|
GetSportId1()
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub GetLevel3()
|
|
|
|
' Retrieve the value entered by the user on the Level ASP:TextBox, and
|
|
' save it into the Level field in DataSource PersonalSportSkill record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Level3.Text, PersonalSportSkillTable.Level)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetSportId1()
|
|
|
|
' Retrieve the value entered by the user on the SportId ASP:DropDownList, and
|
|
' save it into the SportId field in DataSource PersonalSportSkill record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.SportId1), PersonalSportSkillTable.SportId)
|
|
|
|
End Sub
|
|
|
|
|
|
' To customize, override this method in PersonalSportSkillTableControl1Row.
|
|
|
|
Public Overridable Function CreateWhereClause() As WhereClause
|
|
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
|
|
|
|
' To customize, override this method in PersonalSportSkillTableControl1Row.
|
|
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)
|
|
PersonalSportSkillTable.DeleteRecord(pkValue)
|
|
|
|
DirectCast(GetParentControlObject(Me, "PersonalSportSkillTableControl1"), PersonalSportSkillTableControl1).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalSportSkillTableControl1"), PersonalSportSkillTableControl1).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
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_SportId1DropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the Sport table.
|
|
' Examples:
|
|
' wc.iAND(SportTable.SPORT, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(SportTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
' Fill the SportId1 list.
|
|
Protected Overridable Sub PopulateSportId1DropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.SportId1.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.SportId1.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_SportId1DropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_SportId1DropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(SportTable.SPORT, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim itemValues() As SportRecord = Nothing
|
|
Dim evaluator As New FormulaEvaluator
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
Do
|
|
itemValues = SportTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
For each itemValue As SportRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.SportIdSpecified Then
|
|
cvalue = itemValue.SportId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.SportId1.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalSportSkillTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalSportSkillTable.SportId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalSportSkillTable.SportId.IsApplyDisplayAs Then
|
|
fvalue = PersonalSportSkillTable.GetDFKA(itemValue, PersonalSportSkillTable.SportId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(SportTable.SPORT)
|
|
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.SportId1.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.SportId1.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
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.SportId1, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.SportId1, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with Sport.SportId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(SportTable.SportId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As SportRecord = SportTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As SportRecord = DirectCast(rc(0), SportRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.SportIdSpecified Then
|
|
cvalue = itemValue.SportId.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalSportSkillTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalSportSkillTable.SportId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalSportSkillTable.SportId.IsApplyDisplayAs Then
|
|
fvalue = PersonalSportSkillTable.GetDFKA(itemValue, PersonalSportSkillTable.SportId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(SportTable.SPORT)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.SportId1.Items.Add(newItem)
|
|
SetSelectedValue(Me.SportId1, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonalSportSkillRowDeleteButton1_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Dim tc As PersonalSportSkillTableControl1 = DirectCast(GetParentControlObject(Me, "PersonalSportSkillTableControl1"), PersonalSportSkillTableControl1)
|
|
If Not (IsNothing(tc)) Then
|
|
If Not Me.IsNewRecord Then
|
|
tc.AddToDeletedRecordIds(DirectCast(Me, PersonalSportSkillTableControl1Row))
|
|
End If
|
|
Me.Visible = False
|
|
tc.SetFormulaControls()
|
|
End If
|
|
|
|
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 PersonalSportSkillRowEditButton1_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalSportSkillRowViewButton1_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 = "../Shared/ConfigureViewRecord.aspx"
|
|
|
|
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
|
|
|
|
Protected Overridable Sub SportId1_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(SportId1.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(SportId1.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.SportId1.Items.Add(New ListItem(displayText, val))
|
|
Me.SportId1.SelectedIndex = Me.SportId1.Items.Count - 1
|
|
Me.Page.Session.Remove(SportId1.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(SportId1.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Level3_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
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("BasePersonalSportSkillTableControl1Row_Rec"), String)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me.ViewState("BasePersonalSportSkillTableControl1Row_Rec") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataSource As PersonalSportSkillRecord
|
|
Public Property DataSource() As PersonalSportSkillRecord
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
|
|
Set(ByVal value As PersonalSportSkillRecord)
|
|
|
|
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 Level3() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Level3"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSportSkillRecordRowSelection1() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSportSkillRecordRowSelection1"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSportSkillRowDeleteButton1() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSportSkillRowDeleteButton1"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSportSkillRowEditButton1() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSportSkillRowEditButton1"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSportSkillRowViewButton1() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSportSkillRowViewButton1"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SportId1() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SportId1"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SportId1AddRecordLink() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SportId1AddRecordLink"), 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 PersonalSportSkillRecord = 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 PersonalSportSkillRecord
|
|
If Not Me.DataSource Is Nothing Then
|
|
Return Me.DataSource
|
|
End If
|
|
|
|
If Not Me.RecordUniqueId Is Nothing Then
|
|
|
|
Return PersonalSportSkillTable.GetRecord(Me.RecordUniqueId, True)
|
|
|
|
End If
|
|
|
|
' Localization.
|
|
|
|
Return Nothing
|
|
|
|
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 PersonalSportSkillTableControl1 control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalSportSkillTableControl1.
|
|
Public Class BasePersonalSportSkillTableControl1
|
|
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.
|
|
|
|
|
|
|
|
' 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)
|
|
|
|
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()
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalSportSkillDeleteButton1.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteConfirm", "Persons") & "'));")
|
|
|
|
' Setup the pagination events.
|
|
|
|
AddHandler Me.PersonalSportSkillPagination1.FirstPage.Click, AddressOf PersonalSportSkillPagination1_FirstPage_Click
|
|
|
|
AddHandler Me.PersonalSportSkillPagination1.LastPage.Click, AddressOf PersonalSportSkillPagination1_LastPage_Click
|
|
|
|
AddHandler Me.PersonalSportSkillPagination1.NextPage.Click, AddressOf PersonalSportSkillPagination1_NextPage_Click
|
|
|
|
AddHandler Me.PersonalSportSkillPagination1.PageSizeButton.Click, AddressOf PersonalSportSkillPagination1_PageSizeButton_Click
|
|
|
|
AddHandler Me.PersonalSportSkillPagination1.PreviousPage.Click, AddressOf PersonalSportSkillPagination1_PreviousPage_Click
|
|
|
|
|
|
' Setup the sorting events.
|
|
|
|
AddHandler Me.LevelLabel.Click, AddressOf LevelLabel_Click
|
|
|
|
AddHandler Me.SportIdLabel2.Click, AddressOf SportIdLabel2_Click
|
|
|
|
' Setup the button events.
|
|
|
|
AddHandler Me.PersonalSportSkillAddButton1.Click, AddressOf PersonalSportSkillAddButton1_Click
|
|
|
|
AddHandler Me.PersonalSportSkillDeleteButton1.Click, AddressOf PersonalSportSkillDeleteButton1_Click
|
|
|
|
AddHandler Me.PersonalSportSkillEditButton1.Click, AddressOf PersonalSportSkillEditButton1_Click
|
|
|
|
AddHandler Me.PersonalSportSkillRefreshButton.Click, AddressOf PersonalSportSkillRefreshButton_Click
|
|
|
|
AddHandler Me.PersonalSportSkillResetButton1.Click, AddressOf PersonalSportSkillResetButton1_Click
|
|
|
|
AddHandler Me.PersonalSportSkillSaveButton.Click, AddressOf PersonalSportSkillSaveButton_Click
|
|
|
|
Me.PersonalSportSkillSaveButton.Attributes.Add("onclick", "SubmitHRefOnce(this, """ & Me.Page.GetResourceValue("Txt:SaveRecord", "Persons") & """);")
|
|
|
|
|
|
' 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(PersonalSportSkillRecord)), PersonalSportSkillRecord())
|
|
' 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, PersonalSportSkillTable.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 PersonalSportSkillTableControl1Row 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(PersonalSportSkillRecord)), PersonalSportSkillRecord())
|
|
Else ' Get the records from the database
|
|
Me.DataSource = PersonalSportSkillTable.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()
|
|
|
|
' Turn off the ToggleAll checkbox
|
|
Me.PersonalSportSkillToggleAll1.Checked = False
|
|
|
|
|
|
' Initialize the page and grand totals. now
|
|
|
|
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
|
|
|
|
' Improve performance by prefetching display as records.
|
|
Me.PreFetchForeignKeyValues()
|
|
|
|
' 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, "PersonalSportSkillTableControl1Repeater"), 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 PersonalSportSkillTableControl1Row = DirectCast(repItem.FindControl("PersonalSportSkillTableControl1Row"), PersonalSportSkillTableControl1Row)
|
|
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
|
|
|
|
SetLevelLabel()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetPersonalSportSkillTableControl1CollapsibleRegion()
|
|
|
|
SetSportIdLabel2()
|
|
' 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 Sub PreFetchForeignKeyValues()
|
|
If (IsNothing(Me.DataSource))
|
|
Return
|
|
End If
|
|
|
|
Me.Page.PregetDfkaRecords(PersonalSportSkillTable.SportId, Me.DataSource)
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub RegisterPostback()
|
|
|
|
Me.Page.RegisterPostBackTrigger(MiscUtils.FindControlRecursively(Me,"PersonalSportSkillSaveButton"))
|
|
|
|
|
|
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.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)
|
|
|
|
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.PersonalSportSkillPagination1.CurrentPage.Text = (Me.PageIndex + 1).ToString()
|
|
Else
|
|
Me.PersonalSportSkillPagination1.CurrentPage.Text = "0"
|
|
End If
|
|
Me.PersonalSportSkillPagination1.PageSize.Text = Me.PageSize.ToString()
|
|
Me.PersonalSportSkillPagination1.TotalItems.Text = Me.TotalRecords.ToString()
|
|
Me.PersonalSportSkillPagination1.TotalPages.Text = Me.TotalPages.ToString()
|
|
|
|
' Bind the buttons for PersonalSportSkillTableControl1 pagination.
|
|
|
|
Me.PersonalSportSkillPagination1.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.PersonalSportSkillPagination1.LastPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalSportSkillPagination1.LastPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalSportSkillPagination1.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.PersonalSportSkillPagination1.NextPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalSportSkillPagination1.NextPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalSportSkillPagination1.NextPage.Enabled = Not (Me.PageIndex = Me.TotalPages - 1)
|
|
End If
|
|
|
|
Me.PersonalSportSkillPagination1.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 PersonalSportSkillTableControl1Row
|
|
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.
|
|
PersonalSportSkillTable.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 selectedRecordKeyValue as KeyValue = New KeyValue()
|
|
|
|
Dim personalIdRecordControlObj As Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalIdRecordControl"), Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(personalIdRecordControlObj) AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord()) AndAlso personalIdRecordControlObj.GetRecord().IsCreated AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord().PersonalId))
|
|
wc.iAND(PersonalSportSkillTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
selectedRecordKeyValue.AddElement(PersonalSportSkillTable.PersonalId.InternalName, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
Else
|
|
wc.RunQuery = False
|
|
Return wc
|
|
End If
|
|
|
|
HttpContext.Current.Session("PersonalSportSkillTableControl1WhereClause") = selectedRecordKeyValue.ToXmlString()
|
|
|
|
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.
|
|
PersonalSportSkillTable.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)
|
|
|
|
Dim selectedRecordInPersonalIdRecordControl as String = DirectCast(HttpContext.Current.Session("PersonalSportSkillTableControl1WhereClause"), String)
|
|
|
|
If Not selectedRecordInPersonalIdRecordControl Is Nothing AndAlso KeyValue.IsXmlKey(selectedRecordInPersonalIdRecordControl) Then
|
|
Dim selectedRecordKeyValue as KeyValue = KeyValue.XmlToKey(selectedRecordInPersonalIdRecordControl)
|
|
|
|
If Not IsNothing(selectedRecordKeyValue) AndAlso selectedRecordKeyValue.ContainsColumn(PersonalSportSkillTable.PersonalId) Then
|
|
wc.iAND(PersonalSportSkillTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, selectedRecordKeyValue.GetColumnValue(PersonalSportSkillTable.PersonalId).ToString())
|
|
End If
|
|
|
|
End If
|
|
|
|
' Adds clauses if values are selected in Filter controls which are configured in the page.
|
|
|
|
|
|
Return wc
|
|
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.PersonalSportSkillPagination1.PageSize.Text.Trim <> "" Then
|
|
Try
|
|
'Me.PageSize = Integer.Parse(Me.PersonalSportSkillPagination1.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, "PersonalSportSkillTableControl1Repeater"), 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 PersonalSportSkillTableControl1Row = DirectCast(repItem.FindControl("PersonalSportSkillTableControl1Row"), PersonalSportSkillTableControl1Row)
|
|
|
|
If recControl.Visible AndAlso recControl.IsNewRecord() Then
|
|
|
|
Dim rec As PersonalSportSkillRecord = New PersonalSportSkillRecord()
|
|
|
|
If recControl.Level3.Text <> "" Then
|
|
rec.Parse(recControl.Level3.Text, PersonalSportSkillTable.Level)
|
|
End If
|
|
If MiscUtils.IsValueSelected(recControl.SportId1) Then
|
|
rec.Parse(recControl.SportId1.SelectedItem.Value, PersonalSportSkillTable.SportId)
|
|
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 PersonalSportSkillRecord())
|
|
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(PersonalSportSkillRecord)), PersonalSportSkillRecord())
|
|
|
|
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 PersonalSportSkillTableControl1Row)
|
|
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 PersonalSportSkillTableControl1Row) 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 SetLevelLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalSportSkillTableControl1CollapsibleRegion()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSportIdLabel2()
|
|
|
|
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.
|
|
Dim added As Boolean = Me.AddNewRecord > 0
|
|
Me.LoadData()
|
|
Me.DataBind()
|
|
|
|
If added Then
|
|
Me.SetFocusToAddedRow()
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
Catch ex As Exception
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
End Sub
|
|
|
|
'this function sets focus to the first editable element in the new added row in the editable table
|
|
Protected Overridable Sub SetFocusToAddedRow()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalSportSkillTableControl1Repeater"), System.Web.UI.WebControls.Repeater)
|
|
If rep Is Nothing OrElse rep.Items.Count = 0 Then Return
|
|
Dim repItem As System.Web.UI.WebControls.RepeaterItem
|
|
For Each repItem In rep.Items
|
|
'Load scripts to table rows
|
|
Me.Page.LoadFocusScripts(repItem)
|
|
Dim recControl As PersonalSportSkillTableControl1Row = DirectCast(repItem.FindControl("PersonalSportSkillTableControl1Row"), PersonalSportSkillTableControl1Row)
|
|
If recControl.IsNewRecord Then
|
|
For Each field As Control In recControl.Controls
|
|
If field.Visible AndAlso Me.Page.IsControlEditable(field, False) Then
|
|
'set focus on the first editable field in the new row
|
|
field.Focus()
|
|
Dim updPan As UpdatePanel = DirectCast(Me.Page.FindControlRecursively("UpdatePanel1"), UpdatePanel)
|
|
If Not updPan Is Nothing Then updPan.Update()
|
|
Return
|
|
End If
|
|
Next
|
|
Return
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub SaveControlsToSession()
|
|
MyBase.SaveControlsToSession()
|
|
|
|
' Save filter controls to values to session.
|
|
|
|
|
|
'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.
|
|
|
|
HttpContext.Current.Session("AppRelativeVirtualPath") = Me.Page.AppRelativeVirtualPath
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub ClearControlsFromSession()
|
|
MyBase.ClearControlsFromSession()
|
|
|
|
' Clear filter controls values from the session.
|
|
|
|
|
|
' 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("PersonalSportSkillTableControl1_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("PersonalSportSkillTableControl1_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 PersonalSportSkillPagination1_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 PersonalSportSkillPagination1_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 PersonalSportSkillPagination1_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 PersonalSportSkillPagination1_PageSizeButton_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
Try
|
|
|
|
Me.DataChanged = True
|
|
|
|
Me.PageSize = Integer.Parse(Me.PersonalSportSkillPagination1.PageSize.Text)
|
|
|
|
Me.PageIndex = Integer.Parse(Me.PersonalSportSkillPagination1.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 PersonalSportSkillPagination1_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 LevelLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Level when clicked.
|
|
|
|
' Get previous sorting state for Level.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalSportSkillTable.Level)
|
|
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 Level.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalSportSkillTable.Level, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Level, 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 SportIdLabel2_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by SportId when clicked.
|
|
|
|
' Get previous sorting state for SportId.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalSportSkillTable.SportId)
|
|
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 SportId.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalSportSkillTable.SportId, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by SportId, 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 PersonalSportSkillAddButton1_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
Me.AddNewRecord = 1
|
|
Me.DataChanged = 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 PersonalSportSkillDeleteButton1_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Me.DeleteSelectedRecords(True)
|
|
Me.SetFormulaControls()
|
|
|
|
|
|
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 PersonalSportSkillEditButton1_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalSportSkillRefreshButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
Dim PersonalDDTableControlObj as PersonalDDTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalDDTableControl"), PersonalDDTableControl)
|
|
PersonalDDTableControlObj.ResetData = True
|
|
|
|
PersonalDDTableControlObj.RemoveFromSession(PersonalDDTableControlObj, "DeletedRecordIds")
|
|
PersonalDDTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalEducationTableControlObj as PersonalEducationTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalEducationTableControl"), PersonalEducationTableControl)
|
|
PersonalEducationTableControlObj.ResetData = True
|
|
|
|
PersonalEducationTableControlObj.RemoveFromSession(PersonalEducationTableControlObj, "DeletedRecordIds")
|
|
PersonalEducationTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalExtWorkTableControlObj as PersonalExtWorkTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalExtWorkTableControl"), PersonalExtWorkTableControl)
|
|
PersonalExtWorkTableControlObj.ResetData = True
|
|
|
|
PersonalExtWorkTableControlObj.RemoveFromSession(PersonalExtWorkTableControlObj, "DeletedRecordIds")
|
|
PersonalExtWorkTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalIdRecordControlObj as PersonalIdRecordControl = DirectCast(Me.Page.FindControlRecursively("PersonalIdRecordControl"), PersonalIdRecordControl)
|
|
PersonalIdRecordControlObj.ResetData = True
|
|
|
|
|
|
Dim PersonalInsigniaTableControlObj as PersonalInsigniaTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalInsigniaTableControl"), PersonalInsigniaTableControl)
|
|
PersonalInsigniaTableControlObj.ResetData = True
|
|
|
|
PersonalInsigniaTableControlObj.RemoveFromSession(PersonalInsigniaTableControlObj, "DeletedRecordIds")
|
|
PersonalInsigniaTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalLanguageSkillTableControlObj as PersonalLanguageSkillTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalLanguageSkillTableControl"), PersonalLanguageSkillTableControl)
|
|
PersonalLanguageSkillTableControlObj.ResetData = True
|
|
|
|
PersonalLanguageSkillTableControlObj.RemoveFromSession(PersonalLanguageSkillTableControlObj, "DeletedRecordIds")
|
|
PersonalLanguageSkillTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalNameTableControlObj as PersonalNameTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalNameTableControl"), PersonalNameTableControl)
|
|
PersonalNameTableControlObj.ResetData = True
|
|
|
|
PersonalNameTableControlObj.RemoveFromSession(PersonalNameTableControlObj, "DeletedRecordIds")
|
|
PersonalNameTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalRankTableControlObj as PersonalRankTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalRankTableControl"), PersonalRankTableControl)
|
|
PersonalRankTableControlObj.ResetData = True
|
|
|
|
PersonalRankTableControlObj.RemoveFromSession(PersonalRankTableControlObj, "DeletedRecordIds")
|
|
PersonalRankTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalSalaryTableControlObj as PersonalSalaryTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalSalaryTableControl"), PersonalSalaryTableControl)
|
|
PersonalSalaryTableControlObj.ResetData = True
|
|
|
|
PersonalSalaryTableControlObj.RemoveFromSession(PersonalSalaryTableControlObj, "DeletedRecordIds")
|
|
PersonalSalaryTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalSpecialSkillTableControlObj as PersonalSpecialSkillTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalSpecialSkillTableControl"), PersonalSpecialSkillTableControl)
|
|
PersonalSpecialSkillTableControlObj.ResetData = True
|
|
|
|
PersonalSpecialSkillTableControlObj.RemoveFromSession(PersonalSpecialSkillTableControlObj, "DeletedRecordIds")
|
|
PersonalSpecialSkillTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalSportSkillTableControl1Obj as PersonalSportSkillTableControl1 = DirectCast(Me.Page.FindControlRecursively("PersonalSportSkillTableControl1"), PersonalSportSkillTableControl1)
|
|
PersonalSportSkillTableControl1Obj.ResetData = True
|
|
|
|
PersonalSportSkillTableControl1Obj.RemoveFromSession(PersonalSportSkillTableControl1Obj, "DeletedRecordIds")
|
|
PersonalSportSkillTableControl1Obj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalTitleTableControlObj as PersonalTitleTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalTitleTableControl"), PersonalTitleTableControl)
|
|
PersonalTitleTableControlObj.ResetData = True
|
|
|
|
PersonalTitleTableControlObj.RemoveFromSession(PersonalTitleTableControlObj, "DeletedRecordIds")
|
|
PersonalTitleTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonRelativeTableControlObj as PersonRelativeTableControl = DirectCast(Me.Page.FindControlRecursively("PersonRelativeTableControl"), PersonRelativeTableControl)
|
|
PersonRelativeTableControlObj.ResetData = True
|
|
|
|
PersonRelativeTableControlObj.RemoveFromSession(PersonRelativeTableControlObj, "DeletedRecordIds")
|
|
PersonRelativeTableControlObj.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 PersonalSportSkillResetButton1_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
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)
|
|
|
|
|
|
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
|
|
|
|
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 PersonalSportSkillSaveButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
|
|
If (Not Me.Page.IsPageRefresh) Then
|
|
Me.SaveData()
|
|
End If
|
|
|
|
Me.Page.CommitTransaction(sender)
|
|
' Set IsNewRecord to False for all records - since everything has been saved and is no longer "new"
|
|
Dim recCtl As PersonalSportSkillTableControl1Row
|
|
For Each recCtl in Me.GetRecordControls()
|
|
|
|
recCtl.IsNewRecord = False
|
|
Next
|
|
|
|
|
|
' Set DeletedRecordsIds to Nothing since we have deleted all pending deletes.
|
|
|
|
Me.DeletedRecordIds = Nothing
|
|
|
|
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
|
|
|
|
|
|
|
|
' Generate the event handling functions for filter and search events.
|
|
|
|
|
|
' 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 = PersonalSportSkillTable.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 PersonalSportSkillRecord = Nothing
|
|
Public Property DataSource() As PersonalSportSkillRecord ()
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
Set(ByVal value() As PersonalSportSkillRecord)
|
|
Me._DataSource = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Helper Properties"
|
|
|
|
Public ReadOnly Property LevelLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "LevelLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSportSkillAddButton1() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSportSkillAddButton1"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSportSkillDeleteButton1() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSportSkillDeleteButton1"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSportSkillEditButton1() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSportSkillEditButton1"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSportSkillPagination1() As Persons.UI.IPagination
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSportSkillPagination1"), Persons.UI.IPagination)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSportSkillRefreshButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSportSkillRefreshButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSportSkillResetButton1() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSportSkillResetButton1"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSportSkillSaveButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSportSkillSaveButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSportSkillTableControl1CollapsibleRegion() As System.Web.UI.WebControls.Panel
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSportSkillTableControl1CollapsibleRegion"), System.Web.UI.WebControls.Panel)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalSportSkillToggleAll1() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalSportSkillToggleAll1"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SportIdLabel2() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SportIdLabel2"), System.Web.UI.WebControls.LinkButton)
|
|
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 PersonalSportSkillTableControl1Row = 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 PersonalSportSkillRecord = 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 GetSelectedRecordIndex() As Integer
|
|
Dim counter As Integer = 0
|
|
Dim recControl As PersonalSportSkillTableControl1Row
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalSportSkillRecordRowSelection1.Checked Then
|
|
Return counter
|
|
End If
|
|
counter += 1
|
|
Next
|
|
Return -1
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControl() As PersonalSportSkillTableControl1Row
|
|
Dim selectedList() As PersonalSportSkillTableControl1Row = Me.GetSelectedRecordControls()
|
|
If selectedList.Length = 0 Then
|
|
Return Nothing
|
|
End If
|
|
Return selectedList(0)
|
|
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControls() As PersonalSportSkillTableControl1Row()
|
|
|
|
Dim selectedList As ArrayList = New ArrayList(25)
|
|
Dim recControl As PersonalSportSkillTableControl1Row
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalSportSkillRecordRowSelection1 IsNot Nothing AndAlso recControl.PersonalSportSkillRecordRowSelection1.Checked Then
|
|
selectedList.Add(recControl)
|
|
End If
|
|
Next
|
|
Return DirectCast(selectedList.ToArray(GetType(PersonalSportSkillTableControl1Row)), PersonalSportSkillTableControl1Row())
|
|
|
|
End Function
|
|
|
|
Public Overridable Sub DeleteSelectedRecords(ByVal deferDeletion As Boolean)
|
|
Dim recList() As PersonalSportSkillTableControl1Row = Me.GetSelectedRecordControls()
|
|
If recList.Length = 0 Then
|
|
' Localization.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoRecSelected", "Persons"))
|
|
End If
|
|
|
|
Dim recCtl As PersonalSportSkillTableControl1Row
|
|
For Each recCtl In recList
|
|
If deferDeletion Then
|
|
If Not recCtl.IsNewRecord Then
|
|
|
|
Me.AddToDeletedRecordIds(recCtl)
|
|
|
|
End If
|
|
recCtl.Visible = False
|
|
|
|
recCtl.PersonalSportSkillRecordRowSelection1.Checked = 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 PersonalSportSkillTableControl1Row()
|
|
Dim recList As ArrayList = New ArrayList()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalSportSkillTableControl1Repeater"), 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 PersonalSportSkillTableControl1Row = DirectCast(repItem.FindControl("PersonalSportSkillTableControl1Row"), PersonalSportSkillTableControl1Row)
|
|
recList.Add(recControl)
|
|
|
|
Next
|
|
|
|
Return DirectCast(recList.ToArray(GetType(PersonalSportSkillTableControl1Row)), PersonalSportSkillTableControl1Row())
|
|
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 PersonalTitleTableControlRow control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalTitleTableControlRow.
|
|
Public Class BasePersonalTitleTableControlRow
|
|
Inherits Persons.UI.BaseApplicationRecordControl
|
|
|
|
' To customize, override this method in PersonalTitleTableControlRow.
|
|
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 PersonalTitleTableControlRow.
|
|
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)
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalTitleRowDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteRecordConfirm", "Persons") & "'));")
|
|
|
|
|
|
' Register the event handlers.
|
|
|
|
AddHandler Me.PersonalTitleRowDeleteButton.Click, AddressOf PersonalTitleRowDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalTitleRowEditButton.Click, AddressOf PersonalTitleRowEditButton_Click
|
|
|
|
AddHandler Me.PersonalTitleRowViewButton.Click, AddressOf PersonalTitleRowViewButton_Click
|
|
|
|
AddHandler Me.Command2.TextChanged, AddressOf Command2_TextChanged
|
|
|
|
AddHandler Me.CommandDate3.TextChanged, AddressOf CommandDate3_TextChanged
|
|
|
|
AddHandler Me.Dept.TextChanged, AddressOf Dept_TextChanged
|
|
|
|
AddHandler Me.SkillNo.TextChanged, AddressOf SkillNo_TextChanged
|
|
|
|
AddHandler Me.Title.TextChanged, AddressOf Title_TextChanged
|
|
|
|
AddHandler Me.TitleDate.TextChanged, AddressOf TitleDate_TextChanged
|
|
|
|
AddHandler Me.TitleRank.TextChanged, AddressOf TitleRank_TextChanged
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Load the data from the database into the DataSource PersonalTitle 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 = PersonalTitleTable.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 BasePersonalTitleTableControl when the data for the entire
|
|
' table is loaded.
|
|
|
|
Me.DataSource = New PersonalTitleRecord()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
' Populate the UI controls using the DataSource. To customize, override this method in PersonalTitleTableControlRow.
|
|
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
|
|
|
|
SetCommand2()
|
|
SetCommandDate3()
|
|
SetDept()
|
|
|
|
|
|
|
|
|
|
SetSkillNo()
|
|
SetTitle()
|
|
SetTitleDate()
|
|
SetTitleRank()
|
|
|
|
|
|
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 SetCommand2()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Command2.ID) Then
|
|
|
|
Me.Command2.Text = Me.PreviousUIData(Me.Command2.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Command TextBox on the webpage with value from the
|
|
' PersonalTitle database record.
|
|
|
|
' Me.DataSource is the PersonalTitle record retrieved from the database.
|
|
' Me.Command2 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetCommand2()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.CommandSpecified Then
|
|
|
|
' If the Command is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalTitleTable.Command)
|
|
|
|
Me.Command2.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Command is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Command2.Text = PersonalTitleTable.Command.Format(PersonalTitleTable.Command.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCommandDate3()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.CommandDate3.ID) Then
|
|
|
|
Me.CommandDate3.Text = Me.PreviousUIData(Me.CommandDate3.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the CommandDate TextBox on the webpage with value from the
|
|
' PersonalTitle database record.
|
|
|
|
' Me.DataSource is the PersonalTitle record retrieved from the database.
|
|
' Me.CommandDate3 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetCommandDate3()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.CommandDateSpecified Then
|
|
|
|
' If the CommandDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalTitleTable.CommandDate, "d MMM yy")
|
|
|
|
Me.CommandDate3.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' CommandDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.CommandDate3.Text = PersonalTitleTable.CommandDate.Format(PersonalTitleTable.CommandDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetDept()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Dept.ID) Then
|
|
|
|
Me.Dept.Text = Me.PreviousUIData(Me.Dept.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Dept TextBox on the webpage with value from the
|
|
' PersonalTitle database record.
|
|
|
|
' Me.DataSource is the PersonalTitle record retrieved from the database.
|
|
' Me.Dept is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetDept()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.DeptSpecified Then
|
|
|
|
' If the Dept is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalTitleTable.Dept)
|
|
|
|
Me.Dept.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Dept is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Dept.Text = PersonalTitleTable.Dept.Format(PersonalTitleTable.Dept.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSkillNo()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.SkillNo.ID) Then
|
|
|
|
Me.SkillNo.Text = Me.PreviousUIData(Me.SkillNo.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the SkillNo TextBox on the webpage with value from the
|
|
' PersonalTitle database record.
|
|
|
|
' Me.DataSource is the PersonalTitle record retrieved from the database.
|
|
' Me.SkillNo is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetSkillNo()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.SkillNoSpecified Then
|
|
|
|
' If the SkillNo is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalTitleTable.SkillNo)
|
|
|
|
Me.SkillNo.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' SkillNo is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.SkillNo.Text = PersonalTitleTable.SkillNo.Format(PersonalTitleTable.SkillNo.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetTitle()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Title.ID) Then
|
|
|
|
Me.Title.Text = Me.PreviousUIData(Me.Title.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Title TextBox on the webpage with value from the
|
|
' PersonalTitle database record.
|
|
|
|
' Me.DataSource is the PersonalTitle record retrieved from the database.
|
|
' Me.Title is the ASP:TextBox 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(PersonalTitleTable.Title)
|
|
|
|
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 = PersonalTitleTable.Title.Format(PersonalTitleTable.Title.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetTitleDate()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.TitleDate.ID) Then
|
|
|
|
Me.TitleDate.Text = Me.PreviousUIData(Me.TitleDate.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the TitleDate TextBox on the webpage with value from the
|
|
' PersonalTitle database record.
|
|
|
|
' Me.DataSource is the PersonalTitle record retrieved from the database.
|
|
' Me.TitleDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetTitleDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.TitleDateSpecified Then
|
|
|
|
' If the TitleDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalTitleTable.TitleDate, "d MMM yy")
|
|
|
|
Me.TitleDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' TitleDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.TitleDate.Text = PersonalTitleTable.TitleDate.Format(PersonalTitleTable.TitleDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetTitleRank()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.TitleRank.ID) Then
|
|
|
|
Me.TitleRank.Text = Me.PreviousUIData(Me.TitleRank.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the TitleRank TextBox on the webpage with value from the
|
|
' PersonalTitle database record.
|
|
|
|
' Me.DataSource is the PersonalTitle record retrieved from the database.
|
|
' Me.TitleRank is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetTitleRank()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.TitleRankSpecified Then
|
|
|
|
' If the TitleRank is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalTitleTable.TitleRank)
|
|
|
|
Me.TitleRank.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' TitleRank is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.TitleRank.Text = PersonalTitleTable.TitleRank.Format(PersonalTitleTable.TitleRank.DefaultValue)
|
|
|
|
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 PersonalTitleTableControlRow.
|
|
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()
|
|
|
|
Dim parentCtrl As PersonalIdRecordControl
|
|
|
|
|
|
parentCtrl = DirectCast(Me.Page.FindControlRecursively("PersonalIdRecordControl"), PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(parentCtrl) AndAlso IsNothing(parentCtrl.DataSource))
|
|
' Load the record if it is not loaded yet.
|
|
parentCtrl.LoadData()
|
|
End If
|
|
If (IsNothing(parentCtrl) OrElse IsNothing(parentCtrl.DataSource))
|
|
' Get the error message from the application resource file.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoParentRecId", "Persons"))
|
|
End If
|
|
|
|
Me.DataSource.PersonalId = parentCtrl.DataSource.PersonalId
|
|
|
|
' 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, "PersonalTitleTableControl"), PersonalTitleTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalTitleTableControl"), PersonalTitleTableControl).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 PersonalTitleTableControlRow.
|
|
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.
|
|
|
|
GetCommand2()
|
|
GetCommandDate3()
|
|
GetDept()
|
|
GetSkillNo()
|
|
GetTitle()
|
|
GetTitleDate()
|
|
GetTitleRank()
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub GetCommand2()
|
|
|
|
' Retrieve the value entered by the user on the Command ASP:TextBox, and
|
|
' save it into the Command field in DataSource PersonalTitle record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Command2.Text, PersonalTitleTable.Command)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetCommandDate3()
|
|
|
|
' Retrieve the value entered by the user on the CommandDate ASP:TextBox, and
|
|
' save it into the CommandDate field in DataSource PersonalTitle record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.CommandDate3.Text, PersonalTitleTable.CommandDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetDept()
|
|
|
|
' Retrieve the value entered by the user on the Dept ASP:TextBox, and
|
|
' save it into the Dept field in DataSource PersonalTitle record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Dept.Text, PersonalTitleTable.Dept)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetSkillNo()
|
|
|
|
' Retrieve the value entered by the user on the SkillNo ASP:TextBox, and
|
|
' save it into the SkillNo field in DataSource PersonalTitle record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.SkillNo.Text, PersonalTitleTable.SkillNo)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetTitle()
|
|
|
|
' Retrieve the value entered by the user on the Title ASP:TextBox, and
|
|
' save it into the Title field in DataSource PersonalTitle record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Title.Text, PersonalTitleTable.Title)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetTitleDate()
|
|
|
|
' Retrieve the value entered by the user on the TitleDate ASP:TextBox, and
|
|
' save it into the TitleDate field in DataSource PersonalTitle record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.TitleDate.Text, PersonalTitleTable.TitleDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetTitleRank()
|
|
|
|
' Retrieve the value entered by the user on the TitleRank ASP:TextBox, and
|
|
' save it into the TitleRank field in DataSource PersonalTitle record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.TitleRank.Text, PersonalTitleTable.TitleRank)
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
' To customize, override this method in PersonalTitleTableControlRow.
|
|
|
|
Public Overridable Function CreateWhereClause() As WhereClause
|
|
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
|
|
|
|
' To customize, override this method in PersonalTitleTableControlRow.
|
|
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)
|
|
PersonalTitleTable.DeleteRecord(pkValue)
|
|
|
|
DirectCast(GetParentControlObject(Me, "PersonalTitleTableControl"), PersonalTitleTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalTitleTableControl"), PersonalTitleTableControl).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
|
|
|
|
|
|
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 PersonalTitleRowDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Dim tc As PersonalTitleTableControl = DirectCast(GetParentControlObject(Me, "PersonalTitleTableControl"), PersonalTitleTableControl)
|
|
If Not (IsNothing(tc)) Then
|
|
If Not Me.IsNewRecord Then
|
|
tc.AddToDeletedRecordIds(DirectCast(Me, PersonalTitleTableControlRow))
|
|
End If
|
|
Me.Visible = False
|
|
tc.SetFormulaControls()
|
|
End If
|
|
|
|
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 PersonalTitleRowEditButton_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalTitleRowViewButton_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 = "../Shared/ConfigureViewRecord.aspx"
|
|
|
|
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
|
|
|
|
Protected Overridable Sub Command2_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub CommandDate3_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Dept_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub SkillNo_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Title_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub TitleDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub TitleRank_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
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("BasePersonalTitleTableControlRow_Rec"), String)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me.ViewState("BasePersonalTitleTableControlRow_Rec") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataSource As PersonalTitleRecord
|
|
Public Property DataSource() As PersonalTitleRecord
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
|
|
Set(ByVal value As PersonalTitleRecord)
|
|
|
|
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 Command2() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Command2"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CommandDate3() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CommandDate3"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Dept() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Dept"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalTitleRecordRowSelection() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalTitleRecordRowSelection"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalTitleRowDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalTitleRowDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalTitleRowEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalTitleRowEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalTitleRowViewButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalTitleRowViewButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SkillNo() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SkillNo"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Title() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Title"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property TitleDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "TitleDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property TitleRank() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "TitleRank"), System.Web.UI.WebControls.TextBox)
|
|
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 PersonalTitleRecord = 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 PersonalTitleRecord
|
|
If Not Me.DataSource Is Nothing Then
|
|
Return Me.DataSource
|
|
End If
|
|
|
|
If Not Me.RecordUniqueId Is Nothing Then
|
|
|
|
Return PersonalTitleTable.GetRecord(Me.RecordUniqueId, True)
|
|
|
|
End If
|
|
|
|
' Localization.
|
|
|
|
Return Nothing
|
|
|
|
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 PersonalTitleTableControl control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalTitleTableControl.
|
|
Public Class BasePersonalTitleTableControl
|
|
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.
|
|
|
|
|
|
|
|
' 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(PersonalTitleTable.TitleDate, 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()
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalTitleDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteConfirm", "Persons") & "'));")
|
|
|
|
' Setup the pagination events.
|
|
|
|
AddHandler Me.PersonalTitlePagination.FirstPage.Click, AddressOf PersonalTitlePagination_FirstPage_Click
|
|
|
|
AddHandler Me.PersonalTitlePagination.LastPage.Click, AddressOf PersonalTitlePagination_LastPage_Click
|
|
|
|
AddHandler Me.PersonalTitlePagination.NextPage.Click, AddressOf PersonalTitlePagination_NextPage_Click
|
|
|
|
AddHandler Me.PersonalTitlePagination.PageSizeButton.Click, AddressOf PersonalTitlePagination_PageSizeButton_Click
|
|
|
|
AddHandler Me.PersonalTitlePagination.PreviousPage.Click, AddressOf PersonalTitlePagination_PreviousPage_Click
|
|
|
|
|
|
' Setup the sorting events.
|
|
|
|
AddHandler Me.CommandDateLabel3.Click, AddressOf CommandDateLabel3_Click
|
|
|
|
AddHandler Me.CommandLabel2.Click, AddressOf CommandLabel2_Click
|
|
|
|
AddHandler Me.DeptLabel.Click, AddressOf DeptLabel_Click
|
|
|
|
AddHandler Me.SkillNoLabel.Click, AddressOf SkillNoLabel_Click
|
|
|
|
AddHandler Me.TitleDateLabel1.Click, AddressOf TitleDateLabel1_Click
|
|
|
|
AddHandler Me.TitleLabel.Click, AddressOf TitleLabel_Click
|
|
|
|
AddHandler Me.TitleRankLabel.Click, AddressOf TitleRankLabel_Click
|
|
|
|
' Setup the button events.
|
|
|
|
AddHandler Me.PersonalTitleAddButton.Click, AddressOf PersonalTitleAddButton_Click
|
|
|
|
AddHandler Me.PersonalTitleDeleteButton.Click, AddressOf PersonalTitleDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalTitleEditButton.Click, AddressOf PersonalTitleEditButton_Click
|
|
|
|
AddHandler Me.PersonalTitleResetButton.Click, AddressOf PersonalTitleResetButton_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(PersonalTitleRecord)), PersonalTitleRecord())
|
|
' 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, PersonalTitleTable.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 PersonalTitleTableControlRow 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(PersonalTitleRecord)), PersonalTitleRecord())
|
|
Else ' Get the records from the database
|
|
Me.DataSource = PersonalTitleTable.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()
|
|
|
|
' Turn off the ToggleAll checkbox
|
|
Me.PersonalTitleToggleAll.Checked = False
|
|
|
|
|
|
' Initialize the page and grand totals. now
|
|
|
|
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, "PersonalTitleTableControlRepeater"), 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 PersonalTitleTableControlRow = DirectCast(repItem.FindControl("PersonalTitleTableControlRow"), PersonalTitleTableControlRow)
|
|
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
|
|
|
|
SetCommandDateLabel3()
|
|
SetCommandLabel2()
|
|
SetDeptLabel()
|
|
|
|
|
|
|
|
|
|
|
|
SetPersonalTitleTableControlCollapsibleRegion()
|
|
|
|
SetSkillNoLabel()
|
|
SetTitleDateLabel1()
|
|
SetTitleLabel()
|
|
SetTitleRankLabel()
|
|
' 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()
|
|
|
|
|
|
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.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(PersonalTitleTable.TitleDate, 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.PersonalTitlePagination.CurrentPage.Text = (Me.PageIndex + 1).ToString()
|
|
Else
|
|
Me.PersonalTitlePagination.CurrentPage.Text = "0"
|
|
End If
|
|
Me.PersonalTitlePagination.PageSize.Text = Me.PageSize.ToString()
|
|
Me.PersonalTitlePagination.TotalItems.Text = Me.TotalRecords.ToString()
|
|
Me.PersonalTitlePagination.TotalPages.Text = Me.TotalPages.ToString()
|
|
|
|
' Bind the buttons for PersonalTitleTableControl pagination.
|
|
|
|
Me.PersonalTitlePagination.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.PersonalTitlePagination.LastPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalTitlePagination.LastPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalTitlePagination.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.PersonalTitlePagination.NextPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalTitlePagination.NextPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalTitlePagination.NextPage.Enabled = Not (Me.PageIndex = Me.TotalPages - 1)
|
|
End If
|
|
|
|
Me.PersonalTitlePagination.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 PersonalTitleTableControlRow
|
|
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.
|
|
PersonalTitleTable.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 selectedRecordKeyValue as KeyValue = New KeyValue()
|
|
|
|
Dim personalIdRecordControlObj As Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalIdRecordControl"), Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(personalIdRecordControlObj) AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord()) AndAlso personalIdRecordControlObj.GetRecord().IsCreated AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord().PersonalId))
|
|
wc.iAND(PersonalTitleTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
selectedRecordKeyValue.AddElement(PersonalTitleTable.PersonalId.InternalName, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
Else
|
|
wc.RunQuery = False
|
|
Return wc
|
|
End If
|
|
|
|
HttpContext.Current.Session("PersonalTitleTableControlWhereClause") = selectedRecordKeyValue.ToXmlString()
|
|
|
|
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.
|
|
PersonalTitleTable.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)
|
|
|
|
Dim selectedRecordInPersonalIdRecordControl as String = DirectCast(HttpContext.Current.Session("PersonalTitleTableControlWhereClause"), String)
|
|
|
|
If Not selectedRecordInPersonalIdRecordControl Is Nothing AndAlso KeyValue.IsXmlKey(selectedRecordInPersonalIdRecordControl) Then
|
|
Dim selectedRecordKeyValue as KeyValue = KeyValue.XmlToKey(selectedRecordInPersonalIdRecordControl)
|
|
|
|
If Not IsNothing(selectedRecordKeyValue) AndAlso selectedRecordKeyValue.ContainsColumn(PersonalTitleTable.PersonalId) Then
|
|
wc.iAND(PersonalTitleTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, selectedRecordKeyValue.GetColumnValue(PersonalTitleTable.PersonalId).ToString())
|
|
End If
|
|
|
|
End If
|
|
|
|
' Adds clauses if values are selected in Filter controls which are configured in the page.
|
|
|
|
|
|
Return wc
|
|
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.PersonalTitlePagination.PageSize.Text.Trim <> "" Then
|
|
Try
|
|
'Me.PageSize = Integer.Parse(Me.PersonalTitlePagination.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, "PersonalTitleTableControlRepeater"), 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 PersonalTitleTableControlRow = DirectCast(repItem.FindControl("PersonalTitleTableControlRow"), PersonalTitleTableControlRow)
|
|
|
|
If recControl.Visible AndAlso recControl.IsNewRecord() Then
|
|
|
|
Dim rec As PersonalTitleRecord = New PersonalTitleRecord()
|
|
|
|
If recControl.Command2.Text <> "" Then
|
|
rec.Parse(recControl.Command2.Text, PersonalTitleTable.Command)
|
|
End If
|
|
If recControl.CommandDate3.Text <> "" Then
|
|
rec.Parse(recControl.CommandDate3.Text, PersonalTitleTable.CommandDate)
|
|
End If
|
|
If recControl.Dept.Text <> "" Then
|
|
rec.Parse(recControl.Dept.Text, PersonalTitleTable.Dept)
|
|
End If
|
|
If recControl.SkillNo.Text <> "" Then
|
|
rec.Parse(recControl.SkillNo.Text, PersonalTitleTable.SkillNo)
|
|
End If
|
|
If recControl.Title.Text <> "" Then
|
|
rec.Parse(recControl.Title.Text, PersonalTitleTable.Title)
|
|
End If
|
|
If recControl.TitleDate.Text <> "" Then
|
|
rec.Parse(recControl.TitleDate.Text, PersonalTitleTable.TitleDate)
|
|
End If
|
|
If recControl.TitleRank.Text <> "" Then
|
|
rec.Parse(recControl.TitleRank.Text, PersonalTitleTable.TitleRank)
|
|
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 PersonalTitleRecord())
|
|
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(PersonalTitleRecord)), PersonalTitleRecord())
|
|
|
|
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 PersonalTitleTableControlRow)
|
|
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 PersonalTitleTableControlRow) 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 SetCommandDateLabel3()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCommandLabel2()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetDeptLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalTitleTableControlCollapsibleRegion()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSkillNoLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetTitleDateLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetTitleLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetTitleRankLabel()
|
|
|
|
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.
|
|
Dim added As Boolean = Me.AddNewRecord > 0
|
|
Me.LoadData()
|
|
Me.DataBind()
|
|
|
|
If added Then
|
|
Me.SetFocusToAddedRow()
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
Catch ex As Exception
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
End Sub
|
|
|
|
'this function sets focus to the first editable element in the new added row in the editable table
|
|
Protected Overridable Sub SetFocusToAddedRow()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalTitleTableControlRepeater"), System.Web.UI.WebControls.Repeater)
|
|
If rep Is Nothing OrElse rep.Items.Count = 0 Then Return
|
|
Dim repItem As System.Web.UI.WebControls.RepeaterItem
|
|
For Each repItem In rep.Items
|
|
'Load scripts to table rows
|
|
Me.Page.LoadFocusScripts(repItem)
|
|
Dim recControl As PersonalTitleTableControlRow = DirectCast(repItem.FindControl("PersonalTitleTableControlRow"), PersonalTitleTableControlRow)
|
|
If recControl.IsNewRecord Then
|
|
For Each field As Control In recControl.Controls
|
|
If field.Visible AndAlso Me.Page.IsControlEditable(field, False) Then
|
|
'set focus on the first editable field in the new row
|
|
field.Focus()
|
|
Dim updPan As UpdatePanel = DirectCast(Me.Page.FindControlRecursively("UpdatePanel1"), UpdatePanel)
|
|
If Not updPan Is Nothing Then updPan.Update()
|
|
Return
|
|
End If
|
|
Next
|
|
Return
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub SaveControlsToSession()
|
|
MyBase.SaveControlsToSession()
|
|
|
|
' Save filter controls to values to session.
|
|
|
|
|
|
'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.
|
|
|
|
HttpContext.Current.Session("AppRelativeVirtualPath") = Me.Page.AppRelativeVirtualPath
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub ClearControlsFromSession()
|
|
MyBase.ClearControlsFromSession()
|
|
|
|
' Clear filter controls values from the session.
|
|
|
|
|
|
' 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("PersonalTitleTableControl_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("PersonalTitleTableControl_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 PersonalTitlePagination_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 PersonalTitlePagination_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 PersonalTitlePagination_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 PersonalTitlePagination_PageSizeButton_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
Try
|
|
|
|
Me.DataChanged = True
|
|
|
|
Me.PageSize = Integer.Parse(Me.PersonalTitlePagination.PageSize.Text)
|
|
|
|
Me.PageIndex = Integer.Parse(Me.PersonalTitlePagination.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 PersonalTitlePagination_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 CommandDateLabel3_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by CommandDate when clicked.
|
|
|
|
' Get previous sorting state for CommandDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalTitleTable.CommandDate)
|
|
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 CommandDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalTitleTable.CommandDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by CommandDate, 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 CommandLabel2_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Command when clicked.
|
|
|
|
' Get previous sorting state for Command.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalTitleTable.Command)
|
|
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 Command.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalTitleTable.Command, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Command, 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 DeptLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Dept when clicked.
|
|
|
|
' Get previous sorting state for Dept.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalTitleTable.Dept)
|
|
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 Dept.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalTitleTable.Dept, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Dept, 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 SkillNoLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by SkillNo when clicked.
|
|
|
|
' Get previous sorting state for SkillNo.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalTitleTable.SkillNo)
|
|
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 SkillNo.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalTitleTable.SkillNo, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by SkillNo, 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 TitleDateLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by TitleDate when clicked.
|
|
|
|
' Get previous sorting state for TitleDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalTitleTable.TitleDate)
|
|
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 TitleDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalTitleTable.TitleDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by TitleDate, 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(PersonalTitleTable.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(PersonalTitleTable.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
|
|
|
|
Public Overridable Sub TitleRankLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by TitleRank when clicked.
|
|
|
|
' Get previous sorting state for TitleRank.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalTitleTable.TitleRank)
|
|
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 TitleRank.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalTitleTable.TitleRank, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by TitleRank, 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 PersonalTitleAddButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
Me.AddNewRecord = 1
|
|
Me.DataChanged = 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 PersonalTitleDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Me.DeleteSelectedRecords(True)
|
|
Me.SetFormulaControls()
|
|
|
|
|
|
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 PersonalTitleEditButton_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 = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
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 PersonalTitleResetButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
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(PersonalTitleTable.TitleDate, OrderByItem.OrderDir.Asc)
|
|
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
|
|
' 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 = PersonalTitleTable.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 PersonalTitleRecord = Nothing
|
|
Public Property DataSource() As PersonalTitleRecord ()
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
Set(ByVal value() As PersonalTitleRecord)
|
|
Me._DataSource = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Helper Properties"
|
|
|
|
Public ReadOnly Property CommandDateLabel3() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CommandDateLabel3"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CommandLabel2() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CommandLabel2"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DeptLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "DeptLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalTitleAddButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalTitleAddButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalTitleDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalTitleDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalTitleEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalTitleEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalTitlePagination() As Persons.UI.IPagination
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalTitlePagination"), Persons.UI.IPagination)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalTitleResetButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalTitleResetButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalTitleTableControlCollapsibleRegion() As System.Web.UI.WebControls.Panel
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalTitleTableControlCollapsibleRegion"), System.Web.UI.WebControls.Panel)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalTitleToggleAll() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalTitleToggleAll"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SkillNoLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SkillNoLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property TitleDateLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "TitleDateLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
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 TitleRankLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "TitleRankLabel"), System.Web.UI.WebControls.LinkButton)
|
|
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 PersonalTitleTableControlRow = 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 PersonalTitleRecord = 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 GetSelectedRecordIndex() As Integer
|
|
Dim counter As Integer = 0
|
|
Dim recControl As PersonalTitleTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalTitleRecordRowSelection.Checked Then
|
|
Return counter
|
|
End If
|
|
counter += 1
|
|
Next
|
|
Return -1
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControl() As PersonalTitleTableControlRow
|
|
Dim selectedList() As PersonalTitleTableControlRow = Me.GetSelectedRecordControls()
|
|
If selectedList.Length = 0 Then
|
|
Return Nothing
|
|
End If
|
|
Return selectedList(0)
|
|
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControls() As PersonalTitleTableControlRow()
|
|
|
|
Dim selectedList As ArrayList = New ArrayList(25)
|
|
Dim recControl As PersonalTitleTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalTitleRecordRowSelection IsNot Nothing AndAlso recControl.PersonalTitleRecordRowSelection.Checked Then
|
|
selectedList.Add(recControl)
|
|
End If
|
|
Next
|
|
Return DirectCast(selectedList.ToArray(GetType(PersonalTitleTableControlRow)), PersonalTitleTableControlRow())
|
|
|
|
End Function
|
|
|
|
Public Overridable Sub DeleteSelectedRecords(ByVal deferDeletion As Boolean)
|
|
Dim recList() As PersonalTitleTableControlRow = Me.GetSelectedRecordControls()
|
|
If recList.Length = 0 Then
|
|
' Localization.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoRecSelected", "Persons"))
|
|
End If
|
|
|
|
Dim recCtl As PersonalTitleTableControlRow
|
|
For Each recCtl In recList
|
|
If deferDeletion Then
|
|
If Not recCtl.IsNewRecord Then
|
|
|
|
Me.AddToDeletedRecordIds(recCtl)
|
|
|
|
End If
|
|
recCtl.Visible = False
|
|
|
|
recCtl.PersonalTitleRecordRowSelection.Checked = 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 PersonalTitleTableControlRow()
|
|
Dim recList As ArrayList = New ArrayList()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalTitleTableControlRepeater"), 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 PersonalTitleTableControlRow = DirectCast(repItem.FindControl("PersonalTitleTableControlRow"), PersonalTitleTableControlRow)
|
|
recList.Add(recControl)
|
|
|
|
Next
|
|
|
|
Return DirectCast(recList.ToArray(GetType(PersonalTitleTableControlRow)), PersonalTitleTableControlRow())
|
|
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 PersonRelativeTableControlRow control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonRelativeTableControlRow.
|
|
Public Class BasePersonRelativeTableControlRow
|
|
Inherits Persons.UI.BaseApplicationRecordControl
|
|
|
|
' To customize, override this method in PersonRelativeTableControlRow.
|
|
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 PersonRelativeTableControlRow.
|
|
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)
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonRelativeRowDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteRecordConfirm", "Persons") & "'));")
|
|
|
|
|
|
' Register the event handlers.
|
|
|
|
AddHandler Me.PersonRelativeRowDeleteButton.Click, AddressOf PersonRelativeRowDeleteButton_Click
|
|
|
|
AddHandler Me.PersonRelativeRowEditButton.Click, AddressOf PersonRelativeRowEditButton_Click
|
|
|
|
AddHandler Me.RelationId.SelectedIndexChanged, AddressOf RelationId_SelectedIndexChanged
|
|
|
|
AddHandler Me.RStatus.SelectedIndexChanged, AddressOf RStatus_SelectedIndexChanged
|
|
|
|
AddHandler Me.FLastName.TextChanged, AddressOf FLastName_TextChanged
|
|
|
|
AddHandler Me.FName.TextChanged, AddressOf FName_TextChanged
|
|
|
|
AddHandler Me.MLastName.TextChanged, AddressOf MLastName_TextChanged
|
|
|
|
AddHandler Me.MName.TextChanged, AddressOf MName_TextChanged
|
|
|
|
AddHandler Me.MOrLastName.TextChanged, AddressOf MOrLastName_TextChanged
|
|
|
|
AddHandler Me.RAddress.TextChanged, AddressOf RAddress_TextChanged
|
|
|
|
AddHandler Me.RAmphur.TextChanged, AddressOf RAmphur_TextChanged
|
|
|
|
AddHandler Me.RBirthDate.TextChanged, AddressOf RBirthDate_TextChanged
|
|
|
|
AddHandler Me.Ref4.TextChanged, AddressOf Ref4_TextChanged
|
|
|
|
AddHandler Me.RefDate2.TextChanged, AddressOf RefDate2_TextChanged
|
|
|
|
AddHandler Me.RFirstName.TextChanged, AddressOf RFirstName_TextChanged
|
|
|
|
AddHandler Me.RLastName.TextChanged, AddressOf RLastName_TextChanged
|
|
|
|
AddHandler Me.RNationality.TextChanged, AddressOf RNationality_TextChanged
|
|
|
|
AddHandler Me.ROrigin.TextChanged, AddressOf ROrigin_TextChanged
|
|
|
|
AddHandler Me.ROrLastName.TextChanged, AddressOf ROrLastName_TextChanged
|
|
|
|
AddHandler Me.RPreName.TextChanged, AddressOf RPreName_TextChanged
|
|
|
|
AddHandler Me.RProvince.TextChanged, AddressOf RProvince_TextChanged
|
|
|
|
AddHandler Me.RReligion.TextChanged, AddressOf RReligion_TextChanged
|
|
|
|
AddHandler Me.RRemark.TextChanged, AddressOf RRemark_TextChanged
|
|
|
|
AddHandler Me.RStatusDate.TextChanged, AddressOf RStatusDate_TextChanged
|
|
|
|
AddHandler Me.RStatusRef.TextChanged, AddressOf RStatusRef_TextChanged
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Load the data from the database into the DataSource PersonRelative 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 = PersonRelativeTable.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 BasePersonRelativeTableControl when the data for the entire
|
|
' table is loaded.
|
|
|
|
Me.DataSource = New PersonRelativeRecord()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
' Populate the UI controls using the DataSource. To customize, override this method in PersonRelativeTableControlRow.
|
|
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
|
|
|
|
SetFLastName()
|
|
SetFName()
|
|
SetMLastName()
|
|
SetMName()
|
|
SetMOrLastName()
|
|
|
|
|
|
SetRAddress()
|
|
SetRAmphur()
|
|
SetRBirthDate()
|
|
SetRef4()
|
|
SetRefDate2()
|
|
SetRelationId()
|
|
SetRFirstName()
|
|
SetRLastName()
|
|
SetRNationality()
|
|
SetROrigin()
|
|
SetROrLastName()
|
|
SetRPreName()
|
|
SetRProvince()
|
|
SetRReligion()
|
|
SetRRemark()
|
|
SetRStatus()
|
|
SetRStatusDate()
|
|
SetRStatusRef()
|
|
|
|
|
|
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 SetFLastName()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.FLastName.ID) Then
|
|
|
|
Me.FLastName.Text = Me.PreviousUIData(Me.FLastName.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the FLastName TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.FLastName is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetFLastName()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.FLastNameSpecified Then
|
|
|
|
' If the FLastName is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.FLastName)
|
|
|
|
Me.FLastName.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' FLastName is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.FLastName.Text = PersonRelativeTable.FLastName.Format(PersonRelativeTable.FLastName.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetFName()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.FName.ID) Then
|
|
|
|
Me.FName.Text = Me.PreviousUIData(Me.FName.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the FName TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.FName is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetFName()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.FNameSpecified Then
|
|
|
|
' If the FName is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.FName)
|
|
|
|
Me.FName.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' FName is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.FName.Text = PersonRelativeTable.FName.Format(PersonRelativeTable.FName.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetMLastName()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.MLastName.ID) Then
|
|
|
|
Me.MLastName.Text = Me.PreviousUIData(Me.MLastName.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the MLastName TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.MLastName is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetMLastName()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.MLastNameSpecified Then
|
|
|
|
' If the MLastName is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.MLastName)
|
|
|
|
Me.MLastName.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' MLastName is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.MLastName.Text = PersonRelativeTable.MLastName.Format(PersonRelativeTable.MLastName.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetMName()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.MName.ID) Then
|
|
|
|
Me.MName.Text = Me.PreviousUIData(Me.MName.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the MName TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.MName is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetMName()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.MNameSpecified Then
|
|
|
|
' If the MName is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.MName)
|
|
|
|
Me.MName.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' MName is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.MName.Text = PersonRelativeTable.MName.Format(PersonRelativeTable.MName.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetMOrLastName()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.MOrLastName.ID) Then
|
|
|
|
Me.MOrLastName.Text = Me.PreviousUIData(Me.MOrLastName.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the MOrLastName TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.MOrLastName is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetMOrLastName()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.MOrLastNameSpecified Then
|
|
|
|
' If the MOrLastName is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.MOrLastName)
|
|
|
|
Me.MOrLastName.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' MOrLastName is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.MOrLastName.Text = PersonRelativeTable.MOrLastName.Format(PersonRelativeTable.MOrLastName.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRAddress()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RAddress.ID) Then
|
|
|
|
Me.RAddress.Text = Me.PreviousUIData(Me.RAddress.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RAddress TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.RAddress is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRAddress()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RAddressSpecified Then
|
|
|
|
' If the RAddress is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.RAddress)
|
|
|
|
Me.RAddress.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RAddress is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RAddress.Text = PersonRelativeTable.RAddress.Format(PersonRelativeTable.RAddress.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRAmphur()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RAmphur.ID) Then
|
|
|
|
Me.RAmphur.Text = Me.PreviousUIData(Me.RAmphur.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RAmphur TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.RAmphur is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRAmphur()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RAmphurSpecified Then
|
|
|
|
' If the RAmphur is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.RAmphur)
|
|
|
|
Me.RAmphur.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RAmphur is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RAmphur.Text = PersonRelativeTable.RAmphur.Format(PersonRelativeTable.RAmphur.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRBirthDate()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RBirthDate.ID) Then
|
|
|
|
Me.RBirthDate.Text = Me.PreviousUIData(Me.RBirthDate.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RBirthDate TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.RBirthDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRBirthDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RBirthDateSpecified Then
|
|
|
|
' If the RBirthDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.RBirthDate, "d MMM yy")
|
|
|
|
Me.RBirthDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RBirthDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RBirthDate.Text = PersonRelativeTable.RBirthDate.Format(PersonRelativeTable.RBirthDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRef4()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Ref4.ID) Then
|
|
|
|
Me.Ref4.Text = Me.PreviousUIData(Me.Ref4.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Ref TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.Ref4 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRef4()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.Ref0Specified Then
|
|
|
|
' If the Ref is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.Ref0)
|
|
|
|
Me.Ref4.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Ref is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Ref4.Text = PersonRelativeTable.Ref0.Format(PersonRelativeTable.Ref0.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRefDate2()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RefDate2.ID) Then
|
|
|
|
Me.RefDate2.Text = Me.PreviousUIData(Me.RefDate2.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RefDate TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.RefDate2 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRefDate2()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RefDateSpecified Then
|
|
|
|
' If the RefDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.RefDate, "d MMM yy")
|
|
|
|
Me.RefDate2.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RefDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RefDate2.Text = PersonRelativeTable.RefDate.Format(PersonRelativeTable.RefDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRelationId()
|
|
|
|
' If selection was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RelationId.ID) Then
|
|
If Me.PreviousUIData(Me.RelationId.ID) Is Nothing
|
|
Me.PopulateRelationIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateRelationIdDropDownList(Me.PreviousUIData(Me.RelationId.ID).ToString(), 100)
|
|
End If
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RelationId DropDownList on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.RelationId is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRelationId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RelationIdSpecified Then
|
|
|
|
' If the RelationId is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateRelationIdDropDownList(Me.DataSource.RelationId.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' RelationId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateRelationIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateRelationIdDropDownList(PersonRelativeTable.RelationId.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRFirstName()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RFirstName.ID) Then
|
|
|
|
Me.RFirstName.Text = Me.PreviousUIData(Me.RFirstName.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RFirstName TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.RFirstName is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRFirstName()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RFirstNameSpecified Then
|
|
|
|
' If the RFirstName is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.RFirstName)
|
|
|
|
Me.RFirstName.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RFirstName is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RFirstName.Text = PersonRelativeTable.RFirstName.Format(PersonRelativeTable.RFirstName.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRLastName()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RLastName.ID) Then
|
|
|
|
Me.RLastName.Text = Me.PreviousUIData(Me.RLastName.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RLastName TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.RLastName is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRLastName()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RLastNameSpecified Then
|
|
|
|
' If the RLastName is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.RLastName)
|
|
|
|
Me.RLastName.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RLastName is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RLastName.Text = PersonRelativeTable.RLastName.Format(PersonRelativeTable.RLastName.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRNationality()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RNationality.ID) Then
|
|
|
|
Me.RNationality.Text = Me.PreviousUIData(Me.RNationality.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RNationality TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.RNationality is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRNationality()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RNationalitySpecified Then
|
|
|
|
' If the RNationality is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.RNationality)
|
|
|
|
Me.RNationality.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RNationality is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RNationality.Text = PersonRelativeTable.RNationality.Format(PersonRelativeTable.RNationality.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetROrigin()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.ROrigin.ID) Then
|
|
|
|
Me.ROrigin.Text = Me.PreviousUIData(Me.ROrigin.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the ROrigin TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.ROrigin is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetROrigin()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.ROriginSpecified Then
|
|
|
|
' If the ROrigin is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.ROrigin)
|
|
|
|
Me.ROrigin.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' ROrigin is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.ROrigin.Text = PersonRelativeTable.ROrigin.Format(PersonRelativeTable.ROrigin.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetROrLastName()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.ROrLastName.ID) Then
|
|
|
|
Me.ROrLastName.Text = Me.PreviousUIData(Me.ROrLastName.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the ROrLastName TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.ROrLastName is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetROrLastName()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.ROrLastNameSpecified Then
|
|
|
|
' If the ROrLastName is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.ROrLastName)
|
|
|
|
Me.ROrLastName.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' ROrLastName is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.ROrLastName.Text = PersonRelativeTable.ROrLastName.Format(PersonRelativeTable.ROrLastName.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRPreName()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RPreName.ID) Then
|
|
|
|
Me.RPreName.Text = Me.PreviousUIData(Me.RPreName.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RPreName TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.RPreName is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRPreName()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RPreNameSpecified Then
|
|
|
|
' If the RPreName is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.RPreName)
|
|
|
|
Me.RPreName.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RPreName is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RPreName.Text = PersonRelativeTable.RPreName.Format(PersonRelativeTable.RPreName.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRProvince()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RProvince.ID) Then
|
|
|
|
Me.RProvince.Text = Me.PreviousUIData(Me.RProvince.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RProvince TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.RProvince is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRProvince()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RProvinceSpecified Then
|
|
|
|
' If the RProvince is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.RProvince)
|
|
|
|
Me.RProvince.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RProvince is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RProvince.Text = PersonRelativeTable.RProvince.Format(PersonRelativeTable.RProvince.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRReligion()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RReligion.ID) Then
|
|
|
|
Me.RReligion.Text = Me.PreviousUIData(Me.RReligion.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RReligion TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.RReligion is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRReligion()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RReligionSpecified Then
|
|
|
|
' If the RReligion is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.RReligion)
|
|
|
|
Me.RReligion.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RReligion is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RReligion.Text = PersonRelativeTable.RReligion.Format(PersonRelativeTable.RReligion.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRRemark()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RRemark.ID) Then
|
|
|
|
Me.RRemark.Text = Me.PreviousUIData(Me.RRemark.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RRemark TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.RRemark is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRRemark()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RRemarkSpecified Then
|
|
|
|
' If the RRemark is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.RRemark)
|
|
|
|
Me.RRemark.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RRemark is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RRemark.Text = PersonRelativeTable.RRemark.Format(PersonRelativeTable.RRemark.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRStatus()
|
|
|
|
' If selection was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RStatus.ID) Then
|
|
If Me.PreviousUIData(Me.RStatus.ID) Is Nothing
|
|
Me.PopulateRStatusDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateRStatusDropDownList(Me.PreviousUIData(Me.RStatus.ID).ToString(), 100)
|
|
End If
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RStatus DropDownList on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.RStatus is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRStatus()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RStatusSpecified Then
|
|
|
|
' If the RStatus is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateRStatusDropDownList(Me.DataSource.RStatus.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' RStatus is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateRStatusDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateRStatusDropDownList(PersonRelativeTable.RStatus.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRStatusDate()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RStatusDate.ID) Then
|
|
|
|
Me.RStatusDate.Text = Me.PreviousUIData(Me.RStatusDate.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RStatusDate TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.RStatusDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRStatusDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RStatusDateSpecified Then
|
|
|
|
' If the RStatusDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.RStatusDate, "d MMM yy")
|
|
|
|
Me.RStatusDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RStatusDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RStatusDate.Text = PersonRelativeTable.RStatusDate.Format(PersonRelativeTable.RStatusDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRStatusRef()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RStatusRef.ID) Then
|
|
|
|
Me.RStatusRef.Text = Me.PreviousUIData(Me.RStatusRef.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RStatusRef TextBox on the webpage with value from the
|
|
' PersonRelative database record.
|
|
|
|
' Me.DataSource is the PersonRelative record retrieved from the database.
|
|
' Me.RStatusRef is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRStatusRef()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RStatusRefSpecified Then
|
|
|
|
' If the RStatusRef is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonRelativeTable.RStatusRef)
|
|
|
|
Me.RStatusRef.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RStatusRef is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RStatusRef.Text = PersonRelativeTable.RStatusRef.Format(PersonRelativeTable.RStatusRef.DefaultValue)
|
|
|
|
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 PersonRelativeTableControlRow.
|
|
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()
|
|
|
|
Dim parentCtrl As PersonalIdRecordControl
|
|
|
|
|
|
parentCtrl = DirectCast(Me.Page.FindControlRecursively("PersonalIdRecordControl"), PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(parentCtrl) AndAlso IsNothing(parentCtrl.DataSource))
|
|
' Load the record if it is not loaded yet.
|
|
parentCtrl.LoadData()
|
|
End If
|
|
If (IsNothing(parentCtrl) OrElse IsNothing(parentCtrl.DataSource))
|
|
' Get the error message from the application resource file.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoParentRecId", "Persons"))
|
|
End If
|
|
|
|
Me.DataSource.PersonalId = parentCtrl.DataSource.PersonalId
|
|
|
|
' 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, "PersonRelativeTableControl"), PersonRelativeTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonRelativeTableControl"), PersonRelativeTableControl).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 PersonRelativeTableControlRow.
|
|
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.
|
|
|
|
GetFLastName()
|
|
GetFName()
|
|
GetMLastName()
|
|
GetMName()
|
|
GetMOrLastName()
|
|
GetRAddress()
|
|
GetRAmphur()
|
|
GetRBirthDate()
|
|
GetRef4()
|
|
GetRefDate2()
|
|
GetRelationId()
|
|
GetRFirstName()
|
|
GetRLastName()
|
|
GetRNationality()
|
|
GetROrigin()
|
|
GetROrLastName()
|
|
GetRPreName()
|
|
GetRProvince()
|
|
GetRReligion()
|
|
GetRRemark()
|
|
GetRStatus()
|
|
GetRStatusDate()
|
|
GetRStatusRef()
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub GetFLastName()
|
|
|
|
' Retrieve the value entered by the user on the FLastName ASP:TextBox, and
|
|
' save it into the FLastName field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.FLastName.Text, PersonRelativeTable.FLastName)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetFName()
|
|
|
|
' Retrieve the value entered by the user on the FName ASP:TextBox, and
|
|
' save it into the FName field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.FName.Text, PersonRelativeTable.FName)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetMLastName()
|
|
|
|
' Retrieve the value entered by the user on the MLastName ASP:TextBox, and
|
|
' save it into the MLastName field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.MLastName.Text, PersonRelativeTable.MLastName)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetMName()
|
|
|
|
' Retrieve the value entered by the user on the MName ASP:TextBox, and
|
|
' save it into the MName field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.MName.Text, PersonRelativeTable.MName)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetMOrLastName()
|
|
|
|
' Retrieve the value entered by the user on the MOrLastName ASP:TextBox, and
|
|
' save it into the MOrLastName field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.MOrLastName.Text, PersonRelativeTable.MOrLastName)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRAddress()
|
|
|
|
' Retrieve the value entered by the user on the RAddress ASP:TextBox, and
|
|
' save it into the RAddress field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RAddress.Text, PersonRelativeTable.RAddress)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRAmphur()
|
|
|
|
' Retrieve the value entered by the user on the RAmphur ASP:TextBox, and
|
|
' save it into the RAmphur field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RAmphur.Text, PersonRelativeTable.RAmphur)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRBirthDate()
|
|
|
|
' Retrieve the value entered by the user on the RBirthDate ASP:TextBox, and
|
|
' save it into the RBirthDate field in DataSource PersonRelative record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RBirthDate.Text, PersonRelativeTable.RBirthDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRef4()
|
|
|
|
' Retrieve the value entered by the user on the Ref ASP:TextBox, and
|
|
' save it into the Ref field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Ref4.Text, PersonRelativeTable.Ref0)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRefDate2()
|
|
|
|
' Retrieve the value entered by the user on the RefDate ASP:TextBox, and
|
|
' save it into the RefDate field in DataSource PersonRelative record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RefDate2.Text, PersonRelativeTable.RefDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRelationId()
|
|
|
|
' Retrieve the value entered by the user on the RelationId ASP:DropDownList, and
|
|
' save it into the RelationId field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.RelationId), PersonRelativeTable.RelationId)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRFirstName()
|
|
|
|
' Retrieve the value entered by the user on the RFirstName ASP:TextBox, and
|
|
' save it into the RFirstName field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RFirstName.Text, PersonRelativeTable.RFirstName)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRLastName()
|
|
|
|
' Retrieve the value entered by the user on the RLastName ASP:TextBox, and
|
|
' save it into the RLastName field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RLastName.Text, PersonRelativeTable.RLastName)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRNationality()
|
|
|
|
' Retrieve the value entered by the user on the RNationality ASP:TextBox, and
|
|
' save it into the RNationality field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RNationality.Text, PersonRelativeTable.RNationality)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetROrigin()
|
|
|
|
' Retrieve the value entered by the user on the ROrigin ASP:TextBox, and
|
|
' save it into the ROrigin field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.ROrigin.Text, PersonRelativeTable.ROrigin)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetROrLastName()
|
|
|
|
' Retrieve the value entered by the user on the ROrLastName ASP:TextBox, and
|
|
' save it into the ROrLastName field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.ROrLastName.Text, PersonRelativeTable.ROrLastName)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRPreName()
|
|
|
|
' Retrieve the value entered by the user on the RPreName ASP:TextBox, and
|
|
' save it into the RPreName field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RPreName.Text, PersonRelativeTable.RPreName)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRProvince()
|
|
|
|
' Retrieve the value entered by the user on the RProvince ASP:TextBox, and
|
|
' save it into the RProvince field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RProvince.Text, PersonRelativeTable.RProvince)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRReligion()
|
|
|
|
' Retrieve the value entered by the user on the RReligion ASP:TextBox, and
|
|
' save it into the RReligion field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RReligion.Text, PersonRelativeTable.RReligion)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRRemark()
|
|
|
|
' Retrieve the value entered by the user on the RRemark ASP:TextBox, and
|
|
' save it into the RRemark field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RRemark.Text, PersonRelativeTable.RRemark)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRStatus()
|
|
|
|
' Retrieve the value entered by the user on the RStatus ASP:DropDownList, and
|
|
' save it into the RStatus field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.RStatus), PersonRelativeTable.RStatus)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRStatusDate()
|
|
|
|
' Retrieve the value entered by the user on the RStatusDate ASP:TextBox, and
|
|
' save it into the RStatusDate field in DataSource PersonRelative record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RStatusDate.Text, PersonRelativeTable.RStatusDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRStatusRef()
|
|
|
|
' Retrieve the value entered by the user on the RStatusRef ASP:TextBox, and
|
|
' save it into the RStatusRef field in DataSource PersonRelative record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RStatusRef.Text, PersonRelativeTable.RStatusRef)
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
' To customize, override this method in PersonRelativeTableControlRow.
|
|
|
|
Public Overridable Function CreateWhereClause() As WhereClause
|
|
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
|
|
|
|
' To customize, override this method in PersonRelativeTableControlRow.
|
|
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)
|
|
PersonRelativeTable.DeleteRecord(pkValue)
|
|
|
|
DirectCast(GetParentControlObject(Me, "PersonRelativeTableControl"), PersonRelativeTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonRelativeTableControl"), PersonRelativeTableControl).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
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_RelationIdDropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the relation table.
|
|
' Examples:
|
|
' wc.iAND(RelationTable.Relation, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(RelationTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_RStatusDropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the RStatus table.
|
|
' Examples:
|
|
' wc.iAND(RStatusTable.RStatus, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(RStatusTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
' Fill the RelationId list.
|
|
Protected Overridable Sub PopulateRelationIdDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.RelationId.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.RelationId.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_RelationIdDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_RelationIdDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(RelationTable.Relation, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim itemValues() As RelationRecord = Nothing
|
|
Dim evaluator As New FormulaEvaluator
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
Do
|
|
itemValues = RelationTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
For each itemValue As RelationRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.RelationIdSpecified Then
|
|
cvalue = itemValue.RelationId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.RelationId.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonRelativeTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonRelativeTable.RelationId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonRelativeTable.RelationId.IsApplyDisplayAs Then
|
|
fvalue = PersonRelativeTable.GetDFKA(itemValue, PersonRelativeTable.RelationId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(RelationTable.Relation)
|
|
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.RelationId.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.RelationId.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
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.RelationId, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.RelationId, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with relation.RelationId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(RelationTable.RelationId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As RelationRecord = RelationTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As RelationRecord = DirectCast(rc(0), RelationRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.RelationIdSpecified Then
|
|
cvalue = itemValue.RelationId.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonRelativeTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonRelativeTable.RelationId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonRelativeTable.RelationId.IsApplyDisplayAs Then
|
|
fvalue = PersonRelativeTable.GetDFKA(itemValue, PersonRelativeTable.RelationId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(RelationTable.Relation)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.RelationId.Items.Add(newItem)
|
|
SetSelectedValue(Me.RelationId, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' Fill the RStatus list.
|
|
Protected Overridable Sub PopulateRStatusDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.RStatus.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.RStatus.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_RStatusDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_RStatusDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(RStatusTable.RStatus, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim itemValues() As RStatusRecord = Nothing
|
|
Dim evaluator As New FormulaEvaluator
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
Do
|
|
itemValues = RStatusTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
For each itemValue As RStatusRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.RStatusIdSpecified Then
|
|
cvalue = itemValue.RStatusId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.RStatus.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonRelativeTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonRelativeTable.RStatus)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonRelativeTable.RStatus.IsApplyDisplayAs Then
|
|
fvalue = PersonRelativeTable.GetDFKA(itemValue, PersonRelativeTable.RStatus)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(RStatusTable.RStatus)
|
|
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.RStatus.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.RStatus.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
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.RStatus, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.RStatus, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with RStatus.RStatusId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(RStatusTable.RStatusId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As RStatusRecord = RStatusTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As RStatusRecord = DirectCast(rc(0), RStatusRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.RStatusIdSpecified Then
|
|
cvalue = itemValue.RStatusId.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonRelativeTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonRelativeTable.RStatus)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonRelativeTable.RStatus.IsApplyDisplayAs Then
|
|
fvalue = PersonRelativeTable.GetDFKA(itemValue, PersonRelativeTable.RStatus)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(RStatusTable.RStatus)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.RStatus.Items.Add(newItem)
|
|
SetSelectedValue(Me.RStatus, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonRelativeRowDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Dim tc As PersonRelativeTableControl = DirectCast(GetParentControlObject(Me, "PersonRelativeTableControl"), PersonRelativeTableControl)
|
|
If Not (IsNothing(tc)) Then
|
|
If Not Me.IsNewRecord Then
|
|
tc.AddToDeletedRecordIds(DirectCast(Me, PersonRelativeTableControlRow))
|
|
End If
|
|
Me.Visible = False
|
|
tc.SetFormulaControls()
|
|
End If
|
|
|
|
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 PersonRelativeRowEditButton_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 = "../PersonRelative/EditPersonRelative.aspx?PersonRelative={PersonRelativeTableControlRow: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
|
|
|
|
Protected Overridable Sub RelationId_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(RelationId.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(RelationId.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.RelationId.Items.Add(New ListItem(displayText, val))
|
|
Me.RelationId.SelectedIndex = Me.RelationId.Items.Count - 1
|
|
Me.Page.Session.Remove(RelationId.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(RelationId.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RStatus_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(RStatus.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(RStatus.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.RStatus.Items.Add(New ListItem(displayText, val))
|
|
Me.RStatus.SelectedIndex = Me.RStatus.Items.Count - 1
|
|
Me.Page.Session.Remove(RStatus.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(RStatus.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub FLastName_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub FName_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub MLastName_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub MName_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub MOrLastName_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RAddress_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RAmphur_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RBirthDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Ref4_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RefDate2_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RFirstName_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RLastName_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RNationality_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub ROrigin_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub ROrLastName_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RPreName_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RProvince_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RReligion_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RRemark_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RStatusDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RStatusRef_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
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("BasePersonRelativeTableControlRow_Rec"), String)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me.ViewState("BasePersonRelativeTableControlRow_Rec") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataSource As PersonRelativeRecord
|
|
Public Property DataSource() As PersonRelativeRecord
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
|
|
Set(ByVal value As PersonRelativeRecord)
|
|
|
|
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 FLastName() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "FLastName"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property FName() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "FName"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MLastName() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "MLastName"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MName() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "MName"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MOrLastName() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "MOrLastName"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonRelativeRowDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonRelativeRowDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonRelativeRowEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonRelativeRowEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RAddress() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RAddress"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RAmphur() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RAmphur"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RBirthDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RBirthDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Ref4() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Ref4"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RefDate2() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RefDate2"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RelationId() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RelationId"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RFirstName() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RFirstName"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RLastName() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RLastName"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RNationality() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RNationality"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ROrigin() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ROrigin"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ROrLastName() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ROrLastName"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RPreName() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RPreName"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RProvince() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RProvince"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RReligion() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RReligion"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RRemark() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RRemark"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RStatus() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RStatus"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RStatusDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RStatusDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RStatusRef() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RStatusRef"), System.Web.UI.WebControls.TextBox)
|
|
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 PersonRelativeRecord = 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 PersonRelativeRecord
|
|
If Not Me.DataSource Is Nothing Then
|
|
Return Me.DataSource
|
|
End If
|
|
|
|
If Not Me.RecordUniqueId Is Nothing Then
|
|
|
|
Return PersonRelativeTable.GetRecord(Me.RecordUniqueId, True)
|
|
|
|
End If
|
|
|
|
' Localization.
|
|
|
|
Return Nothing
|
|
|
|
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 PersonRelativeTableControl control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonRelativeTableControl.
|
|
Public Class BasePersonRelativeTableControl
|
|
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.
|
|
|
|
|
|
|
|
' 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(PersonRelativeTable.RelationId, OrderByItem.OrderDir.Asc)
|
|
|
|
Me.CurrentSortOrder.Add(PersonRelativeTable.RBirthDate, 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.PersonRelativePagination.FirstPage.Click, AddressOf PersonRelativePagination_FirstPage_Click
|
|
|
|
AddHandler Me.PersonRelativePagination.LastPage.Click, AddressOf PersonRelativePagination_LastPage_Click
|
|
|
|
AddHandler Me.PersonRelativePagination.NextPage.Click, AddressOf PersonRelativePagination_NextPage_Click
|
|
|
|
AddHandler Me.PersonRelativePagination.PageSizeButton.Click, AddressOf PersonRelativePagination_PageSizeButton_Click
|
|
|
|
AddHandler Me.PersonRelativePagination.PreviousPage.Click, AddressOf PersonRelativePagination_PreviousPage_Click
|
|
|
|
|
|
' Setup the sorting events.
|
|
|
|
' Setup the button events.
|
|
|
|
AddHandler Me.PersonRelativeAddButton.Click, AddressOf PersonRelativeAddButton_Click
|
|
|
|
AddHandler Me.PersonRelativeRefreshButton.Click, AddressOf PersonRelativeRefreshButton_Click
|
|
|
|
AddHandler Me.PersonRelativeResetButton.Click, AddressOf PersonRelativeResetButton_Click
|
|
|
|
AddHandler Me.PersonRelativeSaveButton.Click, AddressOf PersonRelativeSaveButton_Click
|
|
|
|
Me.PersonRelativeSaveButton.Attributes.Add("onclick", "SubmitHRefOnce(this, """ & Me.Page.GetResourceValue("Txt:SaveRecord", "Persons") & """);")
|
|
|
|
|
|
' 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(PersonRelativeRecord)), PersonRelativeRecord())
|
|
' 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, PersonRelativeTable.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 PersonRelativeTableControlRow 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(PersonRelativeRecord)), PersonRelativeRecord())
|
|
Else ' Get the records from the database
|
|
Me.DataSource = PersonRelativeTable.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
|
|
|
|
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
|
|
|
|
' Improve performance by prefetching display as records.
|
|
Me.PreFetchForeignKeyValues()
|
|
|
|
' 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, "PersonRelativeTableControlRepeater"), 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 PersonRelativeTableControlRow = DirectCast(repItem.FindControl("PersonRelativeTableControlRow"), PersonRelativeTableControlRow)
|
|
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
|
|
|
|
SetFLastNameLabel()
|
|
SetFNameLabel()
|
|
SetMLastNameLabel()
|
|
SetMNameLabel()
|
|
SetMOrLastNameLabel()
|
|
|
|
|
|
|
|
|
|
|
|
SetPersonRelativeTableControlCollapsibleRegion()
|
|
SetRAddressLabel()
|
|
SetRAmphurLabel()
|
|
SetRBirthDateLabel()
|
|
SetRefDateLabel2()
|
|
SetRefLabel3()
|
|
SetRelationIdLabel1()
|
|
SetRFirstNameLabel()
|
|
SetRLastNameLabel()
|
|
SetRNationalityLabel()
|
|
SetROriginLabel()
|
|
SetROrLastNameLabel()
|
|
SetRPreNameLabel()
|
|
SetRProvinceLabel()
|
|
SetRReligionLabel()
|
|
SetRRemarkLabel()
|
|
SetRStatusDateLabel()
|
|
SetRStatusLabel()
|
|
SetRStatusRefLabel()
|
|
' 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 Sub PreFetchForeignKeyValues()
|
|
If (IsNothing(Me.DataSource))
|
|
Return
|
|
End If
|
|
|
|
Me.Page.PregetDfkaRecords(PersonRelativeTable.RelationId, Me.DataSource)
|
|
|
|
Me.Page.PregetDfkaRecords(PersonRelativeTable.RStatus, Me.DataSource)
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub RegisterPostback()
|
|
|
|
Me.Page.RegisterPostBackTrigger(MiscUtils.FindControlRecursively(Me,"PersonRelativeSaveButton"))
|
|
|
|
|
|
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.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(PersonRelativeTable.RelationId, OrderByItem.OrderDir.Asc)
|
|
|
|
Me.CurrentSortOrder.Add(PersonRelativeTable.RBirthDate, 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.PersonRelativePagination.CurrentPage.Text = (Me.PageIndex + 1).ToString()
|
|
Else
|
|
Me.PersonRelativePagination.CurrentPage.Text = "0"
|
|
End If
|
|
Me.PersonRelativePagination.PageSize.Text = Me.PageSize.ToString()
|
|
Me.PersonRelativePagination.TotalItems.Text = Me.TotalRecords.ToString()
|
|
Me.PersonRelativePagination.TotalPages.Text = Me.TotalPages.ToString()
|
|
|
|
' Bind the buttons for PersonRelativeTableControl pagination.
|
|
|
|
Me.PersonRelativePagination.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.PersonRelativePagination.LastPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonRelativePagination.LastPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonRelativePagination.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.PersonRelativePagination.NextPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonRelativePagination.NextPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonRelativePagination.NextPage.Enabled = Not (Me.PageIndex = Me.TotalPages - 1)
|
|
End If
|
|
|
|
Me.PersonRelativePagination.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 PersonRelativeTableControlRow
|
|
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.
|
|
PersonRelativeTable.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 selectedRecordKeyValue as KeyValue = New KeyValue()
|
|
|
|
Dim personalIdRecordControlObj As Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalIdRecordControl"), Persons.UI.Controls.EditPersonalId.PersonalIdRecordControl)
|
|
|
|
If (Not IsNothing(personalIdRecordControlObj) AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord()) AndAlso personalIdRecordControlObj.GetRecord().IsCreated AndAlso Not IsNothing(personalIdRecordControlObj.GetRecord().PersonalId))
|
|
wc.iAND(PersonRelativeTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
selectedRecordKeyValue.AddElement(PersonRelativeTable.PersonalId.InternalName, personalIdRecordControlObj.GetRecord().PersonalId.ToString())
|
|
Else
|
|
wc.RunQuery = False
|
|
Return wc
|
|
End If
|
|
|
|
HttpContext.Current.Session("PersonRelativeTableControlWhereClause") = selectedRecordKeyValue.ToXmlString()
|
|
|
|
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.
|
|
PersonRelativeTable.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)
|
|
|
|
Dim selectedRecordInPersonalIdRecordControl as String = DirectCast(HttpContext.Current.Session("PersonRelativeTableControlWhereClause"), String)
|
|
|
|
If Not selectedRecordInPersonalIdRecordControl Is Nothing AndAlso KeyValue.IsXmlKey(selectedRecordInPersonalIdRecordControl) Then
|
|
Dim selectedRecordKeyValue as KeyValue = KeyValue.XmlToKey(selectedRecordInPersonalIdRecordControl)
|
|
|
|
If Not IsNothing(selectedRecordKeyValue) AndAlso selectedRecordKeyValue.ContainsColumn(PersonRelativeTable.PersonalId) Then
|
|
wc.iAND(PersonRelativeTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, selectedRecordKeyValue.GetColumnValue(PersonRelativeTable.PersonalId).ToString())
|
|
End If
|
|
|
|
End If
|
|
|
|
' Adds clauses if values are selected in Filter controls which are configured in the page.
|
|
|
|
|
|
Return wc
|
|
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.PersonRelativePagination.PageSize.Text.Trim <> "" Then
|
|
Try
|
|
'Me.PageSize = Integer.Parse(Me.PersonRelativePagination.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, "PersonRelativeTableControlRepeater"), 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 PersonRelativeTableControlRow = DirectCast(repItem.FindControl("PersonRelativeTableControlRow"), PersonRelativeTableControlRow)
|
|
|
|
If recControl.Visible AndAlso recControl.IsNewRecord() Then
|
|
|
|
Dim rec As PersonRelativeRecord = New PersonRelativeRecord()
|
|
|
|
If recControl.FLastName.Text <> "" Then
|
|
rec.Parse(recControl.FLastName.Text, PersonRelativeTable.FLastName)
|
|
End If
|
|
If recControl.FName.Text <> "" Then
|
|
rec.Parse(recControl.FName.Text, PersonRelativeTable.FName)
|
|
End If
|
|
If recControl.MLastName.Text <> "" Then
|
|
rec.Parse(recControl.MLastName.Text, PersonRelativeTable.MLastName)
|
|
End If
|
|
If recControl.MName.Text <> "" Then
|
|
rec.Parse(recControl.MName.Text, PersonRelativeTable.MName)
|
|
End If
|
|
If recControl.MOrLastName.Text <> "" Then
|
|
rec.Parse(recControl.MOrLastName.Text, PersonRelativeTable.MOrLastName)
|
|
End If
|
|
If recControl.RAddress.Text <> "" Then
|
|
rec.Parse(recControl.RAddress.Text, PersonRelativeTable.RAddress)
|
|
End If
|
|
If recControl.RAmphur.Text <> "" Then
|
|
rec.Parse(recControl.RAmphur.Text, PersonRelativeTable.RAmphur)
|
|
End If
|
|
If recControl.RBirthDate.Text <> "" Then
|
|
rec.Parse(recControl.RBirthDate.Text, PersonRelativeTable.RBirthDate)
|
|
End If
|
|
If recControl.Ref4.Text <> "" Then
|
|
rec.Parse(recControl.Ref4.Text, PersonRelativeTable.Ref0)
|
|
End If
|
|
If recControl.RefDate2.Text <> "" Then
|
|
rec.Parse(recControl.RefDate2.Text, PersonRelativeTable.RefDate)
|
|
End If
|
|
If MiscUtils.IsValueSelected(recControl.RelationId) Then
|
|
rec.Parse(recControl.RelationId.SelectedItem.Value, PersonRelativeTable.RelationId)
|
|
End If
|
|
If recControl.RFirstName.Text <> "" Then
|
|
rec.Parse(recControl.RFirstName.Text, PersonRelativeTable.RFirstName)
|
|
End If
|
|
If recControl.RLastName.Text <> "" Then
|
|
rec.Parse(recControl.RLastName.Text, PersonRelativeTable.RLastName)
|
|
End If
|
|
If recControl.RNationality.Text <> "" Then
|
|
rec.Parse(recControl.RNationality.Text, PersonRelativeTable.RNationality)
|
|
End If
|
|
If recControl.ROrigin.Text <> "" Then
|
|
rec.Parse(recControl.ROrigin.Text, PersonRelativeTable.ROrigin)
|
|
End If
|
|
If recControl.ROrLastName.Text <> "" Then
|
|
rec.Parse(recControl.ROrLastName.Text, PersonRelativeTable.ROrLastName)
|
|
End If
|
|
If recControl.RPreName.Text <> "" Then
|
|
rec.Parse(recControl.RPreName.Text, PersonRelativeTable.RPreName)
|
|
End If
|
|
If recControl.RProvince.Text <> "" Then
|
|
rec.Parse(recControl.RProvince.Text, PersonRelativeTable.RProvince)
|
|
End If
|
|
If recControl.RReligion.Text <> "" Then
|
|
rec.Parse(recControl.RReligion.Text, PersonRelativeTable.RReligion)
|
|
End If
|
|
If recControl.RRemark.Text <> "" Then
|
|
rec.Parse(recControl.RRemark.Text, PersonRelativeTable.RRemark)
|
|
End If
|
|
If MiscUtils.IsValueSelected(recControl.RStatus) Then
|
|
rec.Parse(recControl.RStatus.SelectedItem.Value, PersonRelativeTable.RStatus)
|
|
End If
|
|
If recControl.RStatusDate.Text <> "" Then
|
|
rec.Parse(recControl.RStatusDate.Text, PersonRelativeTable.RStatusDate)
|
|
End If
|
|
If recControl.RStatusRef.Text <> "" Then
|
|
rec.Parse(recControl.RStatusRef.Text, PersonRelativeTable.RStatusRef)
|
|
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 PersonRelativeRecord())
|
|
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(PersonRelativeRecord)), PersonRelativeRecord())
|
|
|
|
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 PersonRelativeTableControlRow)
|
|
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 PersonRelativeTableControlRow) 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 SetFLastNameLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetFNameLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetMLastNameLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetMNameLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetMOrLastNameLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonRelativeTableControlCollapsibleRegion()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRAddressLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRAmphurLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRBirthDateLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRefDateLabel2()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRefLabel3()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRelationIdLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRFirstNameLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRLastNameLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRNationalityLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetROriginLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetROrLastNameLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRPreNameLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRProvinceLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRReligionLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRRemarkLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRStatusDateLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRStatusLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRStatusRefLabel()
|
|
|
|
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.
|
|
Dim added As Boolean = Me.AddNewRecord > 0
|
|
Me.LoadData()
|
|
Me.DataBind()
|
|
|
|
If added Then
|
|
Me.SetFocusToAddedRow()
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
Catch ex As Exception
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
End Sub
|
|
|
|
'this function sets focus to the first editable element in the new added row in the editable table
|
|
Protected Overridable Sub SetFocusToAddedRow()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonRelativeTableControlRepeater"), System.Web.UI.WebControls.Repeater)
|
|
If rep Is Nothing OrElse rep.Items.Count = 0 Then Return
|
|
Dim repItem As System.Web.UI.WebControls.RepeaterItem
|
|
For Each repItem In rep.Items
|
|
'Load scripts to table rows
|
|
Me.Page.LoadFocusScripts(repItem)
|
|
Dim recControl As PersonRelativeTableControlRow = DirectCast(repItem.FindControl("PersonRelativeTableControlRow"), PersonRelativeTableControlRow)
|
|
If recControl.IsNewRecord Then
|
|
For Each field As Control In recControl.Controls
|
|
If field.Visible AndAlso Me.Page.IsControlEditable(field, False) Then
|
|
'set focus on the first editable field in the new row
|
|
field.Focus()
|
|
Dim updPan As UpdatePanel = DirectCast(Me.Page.FindControlRecursively("UpdatePanel1"), UpdatePanel)
|
|
If Not updPan Is Nothing Then updPan.Update()
|
|
Return
|
|
End If
|
|
Next
|
|
Return
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub SaveControlsToSession()
|
|
MyBase.SaveControlsToSession()
|
|
|
|
' Save filter controls to values to session.
|
|
|
|
|
|
'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.
|
|
|
|
HttpContext.Current.Session("AppRelativeVirtualPath") = Me.Page.AppRelativeVirtualPath
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub ClearControlsFromSession()
|
|
MyBase.ClearControlsFromSession()
|
|
|
|
' Clear filter controls values from the session.
|
|
|
|
|
|
' 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("PersonRelativeTableControl_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("PersonRelativeTableControl_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 PersonRelativePagination_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 PersonRelativePagination_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 PersonRelativePagination_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 PersonRelativePagination_PageSizeButton_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
Try
|
|
|
|
Me.DataChanged = True
|
|
|
|
Me.PageSize = Integer.Parse(Me.PersonRelativePagination.PageSize.Text)
|
|
|
|
Me.PageIndex = Integer.Parse(Me.PersonRelativePagination.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 PersonRelativePagination_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.
|
|
|
|
|
|
' Generate the event handling functions for button events.
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonRelativeAddButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
Me.AddNewRecord = 1
|
|
Me.DataChanged = 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 PersonRelativeRefreshButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
Dim PersonalDDTableControlObj as PersonalDDTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalDDTableControl"), PersonalDDTableControl)
|
|
PersonalDDTableControlObj.ResetData = True
|
|
|
|
PersonalDDTableControlObj.RemoveFromSession(PersonalDDTableControlObj, "DeletedRecordIds")
|
|
PersonalDDTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalEducationTableControlObj as PersonalEducationTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalEducationTableControl"), PersonalEducationTableControl)
|
|
PersonalEducationTableControlObj.ResetData = True
|
|
|
|
PersonalEducationTableControlObj.RemoveFromSession(PersonalEducationTableControlObj, "DeletedRecordIds")
|
|
PersonalEducationTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalExtWorkTableControlObj as PersonalExtWorkTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalExtWorkTableControl"), PersonalExtWorkTableControl)
|
|
PersonalExtWorkTableControlObj.ResetData = True
|
|
|
|
PersonalExtWorkTableControlObj.RemoveFromSession(PersonalExtWorkTableControlObj, "DeletedRecordIds")
|
|
PersonalExtWorkTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalIdRecordControlObj as PersonalIdRecordControl = DirectCast(Me.Page.FindControlRecursively("PersonalIdRecordControl"), PersonalIdRecordControl)
|
|
PersonalIdRecordControlObj.ResetData = True
|
|
|
|
|
|
Dim PersonalInsigniaTableControlObj as PersonalInsigniaTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalInsigniaTableControl"), PersonalInsigniaTableControl)
|
|
PersonalInsigniaTableControlObj.ResetData = True
|
|
|
|
PersonalInsigniaTableControlObj.RemoveFromSession(PersonalInsigniaTableControlObj, "DeletedRecordIds")
|
|
PersonalInsigniaTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalLanguageSkillTableControlObj as PersonalLanguageSkillTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalLanguageSkillTableControl"), PersonalLanguageSkillTableControl)
|
|
PersonalLanguageSkillTableControlObj.ResetData = True
|
|
|
|
PersonalLanguageSkillTableControlObj.RemoveFromSession(PersonalLanguageSkillTableControlObj, "DeletedRecordIds")
|
|
PersonalLanguageSkillTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalNameTableControlObj as PersonalNameTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalNameTableControl"), PersonalNameTableControl)
|
|
PersonalNameTableControlObj.ResetData = True
|
|
|
|
PersonalNameTableControlObj.RemoveFromSession(PersonalNameTableControlObj, "DeletedRecordIds")
|
|
PersonalNameTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalRankTableControlObj as PersonalRankTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalRankTableControl"), PersonalRankTableControl)
|
|
PersonalRankTableControlObj.ResetData = True
|
|
|
|
PersonalRankTableControlObj.RemoveFromSession(PersonalRankTableControlObj, "DeletedRecordIds")
|
|
PersonalRankTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalSalaryTableControlObj as PersonalSalaryTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalSalaryTableControl"), PersonalSalaryTableControl)
|
|
PersonalSalaryTableControlObj.ResetData = True
|
|
|
|
PersonalSalaryTableControlObj.RemoveFromSession(PersonalSalaryTableControlObj, "DeletedRecordIds")
|
|
PersonalSalaryTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalSpecialSkillTableControlObj as PersonalSpecialSkillTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalSpecialSkillTableControl"), PersonalSpecialSkillTableControl)
|
|
PersonalSpecialSkillTableControlObj.ResetData = True
|
|
|
|
PersonalSpecialSkillTableControlObj.RemoveFromSession(PersonalSpecialSkillTableControlObj, "DeletedRecordIds")
|
|
PersonalSpecialSkillTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalSportSkillTableControl1Obj as PersonalSportSkillTableControl1 = DirectCast(Me.Page.FindControlRecursively("PersonalSportSkillTableControl1"), PersonalSportSkillTableControl1)
|
|
PersonalSportSkillTableControl1Obj.ResetData = True
|
|
|
|
PersonalSportSkillTableControl1Obj.RemoveFromSession(PersonalSportSkillTableControl1Obj, "DeletedRecordIds")
|
|
PersonalSportSkillTableControl1Obj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonalTitleTableControlObj as PersonalTitleTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalTitleTableControl"), PersonalTitleTableControl)
|
|
PersonalTitleTableControlObj.ResetData = True
|
|
|
|
PersonalTitleTableControlObj.RemoveFromSession(PersonalTitleTableControlObj, "DeletedRecordIds")
|
|
PersonalTitleTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Dim PersonRelativeTableControlObj as PersonRelativeTableControl = DirectCast(Me.Page.FindControlRecursively("PersonRelativeTableControl"), PersonRelativeTableControl)
|
|
PersonRelativeTableControlObj.ResetData = True
|
|
|
|
PersonRelativeTableControlObj.RemoveFromSession(PersonRelativeTableControlObj, "DeletedRecordIds")
|
|
PersonRelativeTableControlObj.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 PersonRelativeResetButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
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(PersonRelativeTable.RelationId, OrderByItem.OrderDir.Asc)
|
|
|
|
Me.CurrentSortOrder.Add(PersonRelativeTable.RBirthDate, OrderByItem.OrderDir.Asc)
|
|
|
|
|
|
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
|
|
|
|
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 PersonRelativeSaveButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
|
|
If (Not Me.Page.IsPageRefresh) Then
|
|
Me.SaveData()
|
|
End If
|
|
|
|
Me.Page.CommitTransaction(sender)
|
|
' Set IsNewRecord to False for all records - since everything has been saved and is no longer "new"
|
|
Dim recCtl As PersonRelativeTableControlRow
|
|
For Each recCtl in Me.GetRecordControls()
|
|
|
|
recCtl.IsNewRecord = False
|
|
Next
|
|
|
|
|
|
' Set DeletedRecordsIds to Nothing since we have deleted all pending deletes.
|
|
|
|
Me.DeletedRecordIds = Nothing
|
|
|
|
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
|
|
|
|
|
|
|
|
' Generate the event handling functions for filter and search events.
|
|
|
|
|
|
' 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 = PersonRelativeTable.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 PersonRelativeRecord = Nothing
|
|
Public Property DataSource() As PersonRelativeRecord ()
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
Set(ByVal value() As PersonRelativeRecord)
|
|
Me._DataSource = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Helper Properties"
|
|
|
|
Public ReadOnly Property FLastNameLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "FLastNameLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property FNameLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "FNameLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MLastNameLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "MLastNameLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MNameLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "MNameLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MOrLastNameLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "MOrLastNameLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonRelativeAddButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonRelativeAddButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonRelativePagination() As Persons.UI.IPagination
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonRelativePagination"), Persons.UI.IPagination)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonRelativeRefreshButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonRelativeRefreshButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonRelativeResetButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonRelativeResetButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonRelativeSaveButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonRelativeSaveButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonRelativeTableControlCollapsibleRegion() As System.Web.UI.WebControls.Panel
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonRelativeTableControlCollapsibleRegion"), System.Web.UI.WebControls.Panel)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RAddressLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RAddressLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RAmphurLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RAmphurLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RBirthDateLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RBirthDateLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RefDateLabel2() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RefDateLabel2"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RefLabel3() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RefLabel3"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RelationIdLabel1() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RelationIdLabel1"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RFirstNameLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RFirstNameLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RLastNameLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RLastNameLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RNationalityLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RNationalityLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ROriginLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ROriginLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ROrLastNameLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ROrLastNameLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RPreNameLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RPreNameLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RProvinceLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RProvinceLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RReligionLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RReligionLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RRemarkLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RRemarkLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RStatusDateLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RStatusDateLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RStatusLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RStatusLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RStatusRefLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RStatusRefLabel"), System.Web.UI.WebControls.Literal)
|
|
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 PersonRelativeTableControlRow = 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 PersonRelativeRecord = 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 PersonRelativeTableControlRow
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControls() As PersonRelativeTableControlRow()
|
|
|
|
Return DirectCast((new ArrayList()).ToArray(GetType(PersonRelativeTableControlRow)), PersonRelativeTableControlRow())
|
|
|
|
End Function
|
|
|
|
Public Overridable Sub DeleteSelectedRecords(ByVal deferDeletion As Boolean)
|
|
Dim recList() As PersonRelativeTableControlRow = Me.GetSelectedRecordControls()
|
|
If recList.Length = 0 Then
|
|
' Localization.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoRecSelected", "Persons"))
|
|
End If
|
|
|
|
Dim recCtl As PersonRelativeTableControlRow
|
|
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 PersonRelativeTableControlRow()
|
|
Dim recList As ArrayList = New ArrayList()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonRelativeTableControlRepeater"), 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 PersonRelativeTableControlRow = DirectCast(repItem.FindControl("PersonRelativeTableControlRow"), PersonRelativeTableControlRow)
|
|
recList.Add(recControl)
|
|
|
|
Next
|
|
|
|
Return DirectCast(recList.ToArray(GetType(PersonRelativeTableControlRow)), PersonRelativeTableControlRow())
|
|
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 PersonalIdRecordControl control on the EditPersonalId page.
|
|
' Do not modify this class. Instead override any method in PersonalIdRecordControl.
|
|
Public Class BasePersonalIdRecordControl
|
|
Inherits Persons.UI.BaseApplicationRecordControl
|
|
|
|
' To customize, override this method in PersonalIdRecordControl.
|
|
Protected Overridable Sub Control_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Init
|
|
|
|
' Setup the filter and search events.
|
|
|
|
Me.ClearControlsFromSession()
|
|
End Sub
|
|
|
|
' To customize, override this method in PersonalIdRecordControl.
|
|
Protected Overridable Sub Control_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
|
|
|
' Setup the pagination events.
|
|
|
|
|
|
' Register the event handlers.
|
|
|
|
AddHandler Me.ArmId.SelectedIndexChanged, AddressOf ArmId_SelectedIndexChanged
|
|
|
|
AddHandler Me.ArmyId.SelectedIndexChanged, AddressOf ArmyId_SelectedIndexChanged
|
|
|
|
AddHandler Me.BloodId.SelectedIndexChanged, AddressOf BloodId_SelectedIndexChanged
|
|
|
|
AddHandler Me.Born.SelectedIndexChanged, AddressOf Born_SelectedIndexChanged
|
|
|
|
AddHandler Me.DeptId.SelectedIndexChanged, AddressOf DeptId_SelectedIndexChanged
|
|
|
|
AddHandler Me.RankId.SelectedIndexChanged, AddressOf RankId_SelectedIndexChanged
|
|
|
|
AddHandler Me.SectionId.SelectedIndexChanged, AddressOf SectionId_SelectedIndexChanged
|
|
|
|
AddHandler Me.Sex.SelectedIndexChanged, AddressOf Sex_SelectedIndexChanged
|
|
|
|
AddHandler Me.StatusId.SelectedIndexChanged, AddressOf StatusId_SelectedIndexChanged
|
|
|
|
AddHandler Me.Addr.TextChanged, AddressOf Addr_TextChanged
|
|
|
|
AddHandler Me.Amphur.TextChanged, AddressOf Amphur_TextChanged
|
|
|
|
AddHandler Me.ArmyWelfareMemId.TextChanged, AddressOf ArmyWelfareMemId_TextChanged
|
|
|
|
AddHandler Me.BAmphur.TextChanged, AddressOf BAmphur_TextChanged
|
|
|
|
AddHandler Me.BirthDate.TextChanged, AddressOf BirthDate_TextChanged
|
|
|
|
AddHandler Me.BProvince.TextChanged, AddressOf BProvince_TextChanged
|
|
|
|
AddHandler Me.CremateMemId.TextChanged, AddressOf CremateMemId_TextChanged
|
|
|
|
AddHandler Me.MId.TextChanged, AddressOf MId_TextChanged
|
|
|
|
AddHandler Me.MobilePhone.TextChanged, AddressOf MobilePhone_TextChanged
|
|
|
|
AddHandler Me.Nationality.TextChanged, AddressOf Nationality_TextChanged
|
|
|
|
AddHandler Me.OfficerDate.TextChanged, AddressOf OfficerDate_TextChanged
|
|
|
|
AddHandler Me.Origin.TextChanged, AddressOf Origin_TextChanged
|
|
|
|
AddHandler Me.PersonalId.TextChanged, AddressOf PersonalId_TextChanged
|
|
|
|
AddHandler Me.PersonalLastName.TextChanged, AddressOf PersonalLastName_TextChanged
|
|
|
|
AddHandler Me.PersonalName.TextChanged, AddressOf PersonalName_TextChanged
|
|
|
|
AddHandler Me.Phone.TextChanged, AddressOf Phone_TextChanged
|
|
|
|
AddHandler Me.PhoneExt.TextChanged, AddressOf PhoneExt_TextChanged
|
|
|
|
AddHandler Me.PlaceOfBirth.TextChanged, AddressOf PlaceOfBirth_TextChanged
|
|
|
|
AddHandler Me.PostCode.TextChanged, AddressOf PostCode_TextChanged
|
|
|
|
AddHandler Me.Province.TextChanged, AddressOf Province_TextChanged
|
|
|
|
AddHandler Me.RegDate.TextChanged, AddressOf RegDate_TextChanged
|
|
|
|
AddHandler Me.RegNo1.TextChanged, AddressOf RegNo1_TextChanged
|
|
|
|
AddHandler Me.RegNo2.TextChanged, AddressOf RegNo2_TextChanged
|
|
|
|
AddHandler Me.Religion.TextChanged, AddressOf Religion_TextChanged
|
|
|
|
AddHandler Me.TId.TextChanged, AddressOf TId_TextChanged
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Load the data from the database into the DataSource PersonalId 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 = PersonalIdTable.GetRecord(Me.RecordUniqueId, True)
|
|
|
|
Return
|
|
End If
|
|
|
|
' This is the first time a record is being retrieved from the database.
|
|
' So create a Where Clause based on the staic Where clause specified
|
|
' on the Query wizard and the dynamic part specified by the end user
|
|
' on the search and filter controls (if any).
|
|
|
|
Dim wc As WhereClause = Me.CreateWhereClause()
|
|
|
|
Dim Panel As System.Web.UI.WebControls.Panel = CType(MiscUtils.FindControlRecursively(Me, "PersonalIdRecordControlPanel"), System.Web.UI.WebControls.Panel)
|
|
If Not Panel is Nothing Then
|
|
Panel.visible = True
|
|
End If
|
|
|
|
' If there is no Where clause, then simply create a new, blank record.
|
|
|
|
If wc Is Nothing OrElse Not wc.RunQuery Then
|
|
Me.DataSource = New PersonalIdRecord()
|
|
|
|
If Not Panel is Nothing Then
|
|
Panel.visible = False
|
|
End If
|
|
|
|
Return
|
|
End If
|
|
|
|
' Retrieve the record from the database. It is possible
|
|
|
|
Dim recList() As PersonalIdRecord = PersonalIdTable.GetRecords(wc, Nothing, 0, 2)
|
|
If recList.Length = 0 Then
|
|
' There is no data for this Where clause.
|
|
wc.RunQuery = False
|
|
|
|
If Not Panel is Nothing Then
|
|
Panel.visible = False
|
|
End If
|
|
|
|
Return
|
|
End If
|
|
|
|
' Set DataSource based on record retrieved from the database.
|
|
Me.DataSource = PersonalIdTable.GetRecord(recList(0).GetID.ToXmlString(), True)
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
' Populate the UI controls using the DataSource. To customize, override this method in PersonalIdRecordControl.
|
|
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
|
|
|
|
SetAddr()
|
|
SetAddrLabel()
|
|
SetAmphur()
|
|
SetAmphurLabel()
|
|
SetArmId()
|
|
SetArmIdLabel()
|
|
SetArmyId()
|
|
SetArmyIdLabel()
|
|
SetArmyWelfareMemId()
|
|
SetArmyWelfareMemIdLabel()
|
|
SetBAmphur()
|
|
SetBAmphurLabel()
|
|
SetBirthDate()
|
|
SetBirthDateLabel()
|
|
SetBloodId()
|
|
SetBloodIdLabel()
|
|
SetBorn()
|
|
SetBornLabel()
|
|
SetBProvince()
|
|
SetBProvinceLabel()
|
|
SetCremateMemId()
|
|
SetCremateMemIdLabel()
|
|
SetDeptId()
|
|
SetDeptIdLabel()
|
|
SetMId()
|
|
SetMIdLabel()
|
|
SetMobilePhone()
|
|
SetMobilePhoneLabel()
|
|
SetNationality()
|
|
SetNationalityLabel()
|
|
SetOfficerDate()
|
|
SetOfficerDateLabel()
|
|
SetOrigin()
|
|
SetOriginLabel()
|
|
SetPersonalId()
|
|
SetPersonalIdLabel()
|
|
SetPersonalIdRecordControlCollapsibleRegion()
|
|
SetPersonalIdRecordControlIcon()
|
|
SetPersonalIdRecordControlPanelExtender()
|
|
|
|
SetPersonalLastName()
|
|
SetPersonalLastNameLabel()
|
|
SetPersonalName()
|
|
SetPersonalNameLabel()
|
|
SetPhone()
|
|
SetPhoneExt()
|
|
SetPhoneExtLabel()
|
|
SetPhoneLabel()
|
|
|
|
SetpictureImage()
|
|
SetpictureLabel()
|
|
SetPlaceOfBirth()
|
|
SetPlaceOfBirthLabel()
|
|
SetPostCode()
|
|
SetPostCodeLabel()
|
|
SetProvince()
|
|
SetProvinceLabel()
|
|
SetRankId()
|
|
SetRankIdLabel()
|
|
SetRegDate()
|
|
SetRegDateLabel()
|
|
SetRegNo1()
|
|
SetRegNo1Label()
|
|
SetRegNo2()
|
|
SetRegNo2Label()
|
|
SetReligion()
|
|
SetReligionLabel()
|
|
SetSectionId()
|
|
SetSectionIdLabel()
|
|
SetSex()
|
|
SetSexLabel()
|
|
SetStatusId()
|
|
SetStatusIdLabel()
|
|
SetTId()
|
|
SetTIdLabel()
|
|
|
|
|
|
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
|
|
|
|
Dim recPersonalDDTableControl as PersonalDDTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalDDTableControl"), PersonalDDTableControl)
|
|
|
|
If (shouldResetControl OrElse Me.Page.IsPageRefresh)
|
|
recPersonalDDTableControl.ResetControl()
|
|
End IF
|
|
|
|
recPersonalDDTableControl.LoadData()
|
|
recPersonalDDTableControl.DataBind()
|
|
|
|
Dim recPersonalEducationTableControl as PersonalEducationTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalEducationTableControl"), PersonalEducationTableControl)
|
|
|
|
If (shouldResetControl OrElse Me.Page.IsPageRefresh)
|
|
recPersonalEducationTableControl.ResetControl()
|
|
End IF
|
|
|
|
recPersonalEducationTableControl.LoadData()
|
|
recPersonalEducationTableControl.DataBind()
|
|
|
|
Dim recPersonalExtWorkTableControl as PersonalExtWorkTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalExtWorkTableControl"), PersonalExtWorkTableControl)
|
|
|
|
If (shouldResetControl OrElse Me.Page.IsPageRefresh)
|
|
recPersonalExtWorkTableControl.ResetControl()
|
|
End IF
|
|
|
|
recPersonalExtWorkTableControl.LoadData()
|
|
recPersonalExtWorkTableControl.DataBind()
|
|
|
|
Dim recPersonalInsigniaTableControl as PersonalInsigniaTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalInsigniaTableControl"), PersonalInsigniaTableControl)
|
|
|
|
If (shouldResetControl OrElse Me.Page.IsPageRefresh)
|
|
recPersonalInsigniaTableControl.ResetControl()
|
|
End IF
|
|
|
|
recPersonalInsigniaTableControl.LoadData()
|
|
recPersonalInsigniaTableControl.DataBind()
|
|
|
|
Dim recPersonalLanguageSkillTableControl as PersonalLanguageSkillTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalLanguageSkillTableControl"), PersonalLanguageSkillTableControl)
|
|
|
|
If (shouldResetControl OrElse Me.Page.IsPageRefresh)
|
|
recPersonalLanguageSkillTableControl.ResetControl()
|
|
End IF
|
|
|
|
recPersonalLanguageSkillTableControl.LoadData()
|
|
recPersonalLanguageSkillTableControl.DataBind()
|
|
|
|
Dim recPersonalNameTableControl as PersonalNameTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalNameTableControl"), PersonalNameTableControl)
|
|
|
|
If (shouldResetControl OrElse Me.Page.IsPageRefresh)
|
|
recPersonalNameTableControl.ResetControl()
|
|
End IF
|
|
|
|
recPersonalNameTableControl.LoadData()
|
|
recPersonalNameTableControl.DataBind()
|
|
|
|
Dim recPersonalRankTableControl as PersonalRankTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalRankTableControl"), PersonalRankTableControl)
|
|
|
|
If (shouldResetControl OrElse Me.Page.IsPageRefresh)
|
|
recPersonalRankTableControl.ResetControl()
|
|
End IF
|
|
|
|
recPersonalRankTableControl.LoadData()
|
|
recPersonalRankTableControl.DataBind()
|
|
|
|
Dim recPersonalSalaryTableControl as PersonalSalaryTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalSalaryTableControl"), PersonalSalaryTableControl)
|
|
|
|
If (shouldResetControl OrElse Me.Page.IsPageRefresh)
|
|
recPersonalSalaryTableControl.ResetControl()
|
|
End IF
|
|
|
|
recPersonalSalaryTableControl.LoadData()
|
|
recPersonalSalaryTableControl.DataBind()
|
|
|
|
Dim recPersonalSpecialSkillTableControl as PersonalSpecialSkillTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalSpecialSkillTableControl"), PersonalSpecialSkillTableControl)
|
|
|
|
If (shouldResetControl OrElse Me.Page.IsPageRefresh)
|
|
recPersonalSpecialSkillTableControl.ResetControl()
|
|
End IF
|
|
|
|
recPersonalSpecialSkillTableControl.LoadData()
|
|
recPersonalSpecialSkillTableControl.DataBind()
|
|
|
|
Dim recPersonalSportSkillTableControl1 as PersonalSportSkillTableControl1 = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalSportSkillTableControl1"), PersonalSportSkillTableControl1)
|
|
|
|
If (shouldResetControl OrElse Me.Page.IsPageRefresh)
|
|
recPersonalSportSkillTableControl1.ResetControl()
|
|
End IF
|
|
|
|
recPersonalSportSkillTableControl1.LoadData()
|
|
recPersonalSportSkillTableControl1.DataBind()
|
|
|
|
Dim recPersonalTitleTableControl as PersonalTitleTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalTitleTableControl"), PersonalTitleTableControl)
|
|
|
|
If (shouldResetControl OrElse Me.Page.IsPageRefresh)
|
|
recPersonalTitleTableControl.ResetControl()
|
|
End IF
|
|
|
|
recPersonalTitleTableControl.LoadData()
|
|
recPersonalTitleTableControl.DataBind()
|
|
|
|
Dim recPersonRelativeTableControl as PersonRelativeTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonRelativeTableControl"), PersonRelativeTableControl)
|
|
|
|
If (shouldResetControl OrElse Me.Page.IsPageRefresh)
|
|
recPersonRelativeTableControl.ResetControl()
|
|
End IF
|
|
|
|
recPersonRelativeTableControl.LoadData()
|
|
recPersonRelativeTableControl.DataBind()
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub SetAddr()
|
|
|
|
|
|
' Set the Addr TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.Addr is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetAddr()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.AddrSpecified Then
|
|
|
|
' If the Addr is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.Addr)
|
|
|
|
Me.Addr.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Addr is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Addr.Text = PersonalIdTable.Addr.Format(PersonalIdTable.Addr.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetAmphur()
|
|
|
|
|
|
' Set the Amphur TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.Amphur is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetAmphur()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.AmphurSpecified Then
|
|
|
|
' If the Amphur is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.Amphur)
|
|
|
|
Me.Amphur.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Amphur is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Amphur.Text = PersonalIdTable.Amphur.Format(PersonalIdTable.Amphur.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetArmId()
|
|
|
|
|
|
' Set the ArmId DropDownList on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.ArmId is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetArmId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.ArmIdSpecified Then
|
|
|
|
' If the ArmId is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateArmIdDropDownList(Me.DataSource.ArmId.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' ArmId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateArmIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateArmIdDropDownList(PersonalIdTable.ArmId.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetArmyId()
|
|
|
|
|
|
' Set the ArmyId DropDownList on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.ArmyId is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetArmyId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.ArmyIdSpecified Then
|
|
|
|
' If the ArmyId is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateArmyIdDropDownList(Me.DataSource.ArmyId.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' ArmyId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateArmyIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateArmyIdDropDownList(PersonalIdTable.ArmyId.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetArmyWelfareMemId()
|
|
|
|
|
|
' Set the ArmyWelfareMemId TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.ArmyWelfareMemId is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetArmyWelfareMemId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.ArmyWelfareMemIdSpecified Then
|
|
|
|
' If the ArmyWelfareMemId is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.ArmyWelfareMemId)
|
|
|
|
Me.ArmyWelfareMemId.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' ArmyWelfareMemId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.ArmyWelfareMemId.Text = PersonalIdTable.ArmyWelfareMemId.Format(PersonalIdTable.ArmyWelfareMemId.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetBAmphur()
|
|
|
|
|
|
' Set the BAmphur TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.BAmphur is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetBAmphur()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.BAmphurSpecified Then
|
|
|
|
' If the BAmphur is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.BAmphur)
|
|
|
|
Me.BAmphur.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' BAmphur is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.BAmphur.Text = PersonalIdTable.BAmphur.Format(PersonalIdTable.BAmphur.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetBirthDate()
|
|
|
|
|
|
' Set the BirthDate TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.BirthDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetBirthDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.BirthDateSpecified Then
|
|
|
|
' If the BirthDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.BirthDate, "d MMM yy")
|
|
|
|
Me.BirthDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' BirthDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.BirthDate.Text = PersonalIdTable.BirthDate.Format(PersonalIdTable.BirthDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetBloodId()
|
|
|
|
|
|
' Set the BloodId DropDownList on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.BloodId is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetBloodId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.BloodIdSpecified Then
|
|
|
|
' If the BloodId is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateBloodIdDropDownList(Me.DataSource.BloodId.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' BloodId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateBloodIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateBloodIdDropDownList(PersonalIdTable.BloodId.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetBorn()
|
|
|
|
|
|
' Set the Born DropDownList on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.Born is the ASP:DropDownList 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 return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateBornDropDownList(Me.DataSource.Born, 100)
|
|
|
|
Else
|
|
|
|
' Born is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateBornDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateBornDropDownList(PersonalIdTable.Born.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetBProvince()
|
|
|
|
|
|
' Set the BProvince TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.BProvince is the ASP:TextBox 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(PersonalIdTable.BProvince)
|
|
|
|
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 = PersonalIdTable.BProvince.Format(PersonalIdTable.BProvince.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCremateMemId()
|
|
|
|
|
|
' Set the CremateMemId TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.CremateMemId is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetCremateMemId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.CremateMemIdSpecified Then
|
|
|
|
' If the CremateMemId is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.CremateMemId)
|
|
|
|
Me.CremateMemId.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' CremateMemId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.CremateMemId.Text = PersonalIdTable.CremateMemId.Format(PersonalIdTable.CremateMemId.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetDeptId()
|
|
|
|
|
|
' Set the DeptId DropDownList on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.DeptId is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetDeptId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.DeptIdSpecified Then
|
|
|
|
' If the DeptId is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateDeptIdDropDownList(Me.DataSource.DeptId.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' DeptId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateDeptIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateDeptIdDropDownList(PersonalIdTable.DeptId.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetMId()
|
|
|
|
|
|
' Set the MId TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.MId is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetMId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.MIdSpecified Then
|
|
|
|
' If the MId is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.MId)
|
|
|
|
Me.MId.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' MId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.MId.Text = PersonalIdTable.MId.Format(PersonalIdTable.MId.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetMobilePhone()
|
|
|
|
|
|
' Set the MobilePhone TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.MobilePhone is the ASP:TextBox 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(PersonalIdTable.MobilePhone)
|
|
|
|
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 = PersonalIdTable.MobilePhone.Format(PersonalIdTable.MobilePhone.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetNationality()
|
|
|
|
|
|
' Set the Nationality TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.Nationality is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetNationality()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.NationalitySpecified Then
|
|
|
|
' If the Nationality is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.Nationality)
|
|
|
|
Me.Nationality.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Nationality is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Nationality.Text = PersonalIdTable.Nationality.Format(PersonalIdTable.Nationality.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetOfficerDate()
|
|
|
|
|
|
' Set the OfficerDate TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.OfficerDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetOfficerDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.OfficerDateSpecified Then
|
|
|
|
' If the OfficerDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.OfficerDate, "d MMM yy")
|
|
|
|
Me.OfficerDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' OfficerDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.OfficerDate.Text = PersonalIdTable.OfficerDate.Format(PersonalIdTable.OfficerDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetOrigin()
|
|
|
|
|
|
' Set the Origin TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.Origin is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetOrigin()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.OriginSpecified Then
|
|
|
|
' If the Origin is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.Origin)
|
|
|
|
Me.Origin.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Origin is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Origin.Text = PersonalIdTable.Origin.Format(PersonalIdTable.Origin.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalId()
|
|
|
|
|
|
' Set the PersonalId TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.PersonalId is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetPersonalId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.PersonalIdSpecified Then
|
|
|
|
' If the PersonalId is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.PersonalId)
|
|
|
|
Me.PersonalId.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' PersonalId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.PersonalId.Text = PersonalIdTable.PersonalId.Format(PersonalIdTable.PersonalId.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalLastName()
|
|
|
|
|
|
' Set the PersonalLastName TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.PersonalLastName is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetPersonalLastName()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.PersonalLastNameSpecified Then
|
|
|
|
' If the PersonalLastName is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.PersonalLastName)
|
|
|
|
Me.PersonalLastName.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' PersonalLastName is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.PersonalLastName.Text = PersonalIdTable.PersonalLastName.Format(PersonalIdTable.PersonalLastName.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalName()
|
|
|
|
|
|
' Set the PersonalName TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.PersonalName is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetPersonalName()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.PersonalNameSpecified Then
|
|
|
|
' If the PersonalName is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.PersonalName)
|
|
|
|
Me.PersonalName.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' PersonalName is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.PersonalName.Text = PersonalIdTable.PersonalName.Format(PersonalIdTable.PersonalName.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPhone()
|
|
|
|
|
|
' Set the Phone TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.Phone is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetPhone()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.PhoneSpecified Then
|
|
|
|
' If the Phone is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.Phone)
|
|
|
|
Me.Phone.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Phone is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Phone.Text = PersonalIdTable.Phone.Format(PersonalIdTable.Phone.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPhoneExt()
|
|
|
|
|
|
' Set the PhoneExt TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.PhoneExt is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetPhoneExt()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.PhoneExtSpecified Then
|
|
|
|
' If the PhoneExt is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.PhoneExt)
|
|
|
|
Me.PhoneExt.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' PhoneExt is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.PhoneExt.Text = PersonalIdTable.PhoneExt.Format(PersonalIdTable.PhoneExt.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetpictureImage()
|
|
' Set the picture Image on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.pictureImage is the ASP:Image on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetpictureImage()
|
|
' 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.pictureImage.Attributes.Add("onclick", "gPersist=true;")
|
|
Me.pictureImage.Attributes.Add("onmouseout","detailRolloverPopupClose();")
|
|
|
|
Dim name As String = HttpUtility.HtmlEncode(PersonalIdTable.picture.Name)
|
|
|
|
If Not HttpUtility.HtmlEncode("%ISD_DEFAULT%").Equals("%ISD_DEFAULT%") Then
|
|
name = HttpUtility.HtmlEncode(Me.Page.GetResourceValue("%ISD_DEFAULT%"))
|
|
End If
|
|
|
|
Me.pictureImage.Attributes.Add("onmouseover","SaveMousePosition(event);delayRolloverPopup(""PageMethods.GetImage(\""" & Me.Page.Encrypt("PersonalId") _
|
|
& "\"", \""" & Me.Page.Encrypt(HttpUtility.UrlEncode(Me.DataSource.GetID().ToString())) _
|
|
& "\"", \""" & Me.Page.Encrypt("picture") & "\"", \""" & NetUtils.EncodeStringForHtmlDisplay(name.Substring(0, name.Length)) & "\"", false, 200," _
|
|
& " 300, true, PopupDisplayWindowCallBackWith20);"",500);")
|
|
|
|
' Shrunk image size specified by ImagePercentSize on Properties.
|
|
Me.pictureImage.ImageUrl = Me.DataSource.FormatImageUrl(PersonalIdTable.picture, Me.Page.Encrypt("PersonalId"), Me.Page.Encrypt("picture"), Me.Page.Encrypt(Me.DataSource.GetID().ToXmlString()), 20)
|
|
|
|
Me.pictureImage.Visible = True
|
|
Else
|
|
' picture is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
Me.pictureImage.Visible = False
|
|
End If
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPlaceOfBirth()
|
|
|
|
|
|
' Set the PlaceOfBirth TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.PlaceOfBirth is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetPlaceOfBirth()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.PlaceOfBirthSpecified Then
|
|
|
|
' If the PlaceOfBirth is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.PlaceOfBirth)
|
|
|
|
Me.PlaceOfBirth.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' PlaceOfBirth is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.PlaceOfBirth.Text = PersonalIdTable.PlaceOfBirth.Format(PersonalIdTable.PlaceOfBirth.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPostCode()
|
|
|
|
|
|
' Set the PostCode TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.PostCode is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetPostCode()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.PostCodeSpecified Then
|
|
|
|
' If the PostCode is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.PostCode)
|
|
|
|
Me.PostCode.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' PostCode is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.PostCode.Text = PersonalIdTable.PostCode.Format(PersonalIdTable.PostCode.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetProvince()
|
|
|
|
|
|
' Set the Province TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.Province is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetProvince()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.ProvinceSpecified Then
|
|
|
|
' If the Province is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.Province)
|
|
|
|
Me.Province.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Province is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Province.Text = PersonalIdTable.Province.Format(PersonalIdTable.Province.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRankId()
|
|
|
|
|
|
' Set the RankId DropDownList on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.RankId is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRankId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RankIdSpecified Then
|
|
|
|
' If the RankId is non-NULL, then format the value.
|
|
' The Format method will use the Display Format
|
|
Me.PopulateRankIdDropDownList(Me.DataSource.RankId.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' RankId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateRankIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateRankIdDropDownList(PersonalIdTable.RankId.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRegDate()
|
|
|
|
|
|
' Set the RegDate TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.RegDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRegDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RegDateSpecified Then
|
|
|
|
' If the RegDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.RegDate, "d MMM yy")
|
|
|
|
Me.RegDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RegDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RegDate.Text = PersonalIdTable.RegDate.Format(PersonalIdTable.RegDate.DefaultValue, "d MMM yy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRegNo1()
|
|
|
|
|
|
' Set the RegNo1 TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.RegNo1 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRegNo1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RegNo1Specified Then
|
|
|
|
' If the RegNo1 is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.RegNo1)
|
|
|
|
Me.RegNo1.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RegNo1 is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RegNo1.Text = PersonalIdTable.RegNo1.Format(PersonalIdTable.RegNo1.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRegNo2()
|
|
|
|
|
|
' Set the RegNo2 TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.RegNo2 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRegNo2()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RegNo2Specified Then
|
|
|
|
' If the RegNo2 is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.RegNo2)
|
|
|
|
Me.RegNo2.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RegNo2 is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RegNo2.Text = PersonalIdTable.RegNo2.Format(PersonalIdTable.RegNo2.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetReligion()
|
|
|
|
|
|
' Set the Religion TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.Religion is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetReligion()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.ReligionSpecified Then
|
|
|
|
' If the Religion is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.Religion)
|
|
|
|
Me.Religion.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Religion is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Religion.Text = PersonalIdTable.Religion.Format(PersonalIdTable.Religion.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSectionId()
|
|
|
|
|
|
' Set the SectionId DropDownList on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.SectionId is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetSectionId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.SectionIdSpecified Then
|
|
|
|
' If the SectionId is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateSectionIdDropDownList(Me.DataSource.SectionId.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' SectionId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateSectionIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateSectionIdDropDownList(PersonalIdTable.SectionId.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSex()
|
|
|
|
|
|
' Set the Sex DropDownList on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.Sex is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetSex()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.SexSpecified Then
|
|
|
|
' If the Sex is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateSexDropDownList(Me.DataSource.Sex.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' Sex is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateSexDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateSexDropDownList(PersonalIdTable.Sex.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetStatusId()
|
|
|
|
|
|
' Set the StatusId DropDownList on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.StatusId is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetStatusId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.StatusIdSpecified Then
|
|
|
|
' If the StatusId is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateStatusIdDropDownList(Me.DataSource.StatusId.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' StatusId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.IsCreated Then
|
|
Me.PopulateStatusIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateStatusIdDropDownList(PersonalIdTable.StatusId.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetTId()
|
|
|
|
|
|
' Set the TId TextBox on the webpage with value from the
|
|
' PersonalId database record.
|
|
|
|
' Me.DataSource is the PersonalId record retrieved from the database.
|
|
' Me.TId is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetTId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.TIdSpecified Then
|
|
|
|
' If the TId is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalIdTable.TId)
|
|
|
|
Me.TId.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' TId is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.TId.Text = PersonalIdTable.TId.Format(PersonalIdTable.TId.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetAddrLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetAmphurLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetArmIdLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetArmyIdLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetArmyWelfareMemIdLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetBAmphurLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetBirthDateLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetBloodIdLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetBornLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetBProvinceLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetCremateMemIdLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetDeptIdLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetMIdLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetMobilePhoneLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetNationalityLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetOfficerDateLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetOriginLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalIdLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalIdRecordControlCollapsibleRegion()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalIdRecordControlIcon()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalIdRecordControlPanelExtender()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalLastNameLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalNameLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPhoneExtLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPhoneLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetpictureLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPlaceOfBirthLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPostCodeLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetProvinceLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRankIdLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRegDateLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRegNo1Label()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRegNo2Label()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetReligionLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSectionIdLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetSexLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetStatusIdLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetTIdLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub ResetControl()
|
|
|
|
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 PersonalIdRecordControl.
|
|
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()
|
|
|
|
Dim Panel As System.Web.UI.WebControls.Panel = CType(MiscUtils.FindControlRecursively(Me, "PersonalIdRecordControlPanel"), System.Web.UI.WebControls.Panel)
|
|
|
|
If ((Not IsNothing(Panel)) AndAlso (Not Panel.Visible)) OrElse IsNothing(Me.DataSource) Then
|
|
Return
|
|
End If
|
|
|
|
|
|
' 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()
|
|
|
|
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)
|
|
|
|
Dim recPersonalDDTableControl as PersonalDDTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalDDTableControl"), PersonalDDTableControl)
|
|
recPersonalDDTableControl.SaveData()
|
|
|
|
Dim recPersonalEducationTableControl as PersonalEducationTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalEducationTableControl"), PersonalEducationTableControl)
|
|
recPersonalEducationTableControl.SaveData()
|
|
|
|
Dim recPersonalExtWorkTableControl as PersonalExtWorkTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalExtWorkTableControl"), PersonalExtWorkTableControl)
|
|
recPersonalExtWorkTableControl.SaveData()
|
|
|
|
Dim recPersonalInsigniaTableControl as PersonalInsigniaTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalInsigniaTableControl"), PersonalInsigniaTableControl)
|
|
recPersonalInsigniaTableControl.SaveData()
|
|
|
|
Dim recPersonalLanguageSkillTableControl as PersonalLanguageSkillTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalLanguageSkillTableControl"), PersonalLanguageSkillTableControl)
|
|
recPersonalLanguageSkillTableControl.SaveData()
|
|
|
|
Dim recPersonalNameTableControl as PersonalNameTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalNameTableControl"), PersonalNameTableControl)
|
|
recPersonalNameTableControl.SaveData()
|
|
|
|
Dim recPersonalRankTableControl as PersonalRankTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalRankTableControl"), PersonalRankTableControl)
|
|
recPersonalRankTableControl.SaveData()
|
|
|
|
Dim recPersonalSalaryTableControl as PersonalSalaryTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalSalaryTableControl"), PersonalSalaryTableControl)
|
|
recPersonalSalaryTableControl.SaveData()
|
|
|
|
Dim recPersonalSpecialSkillTableControl as PersonalSpecialSkillTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalSpecialSkillTableControl"), PersonalSpecialSkillTableControl)
|
|
recPersonalSpecialSkillTableControl.SaveData()
|
|
|
|
Dim recPersonalSportSkillTableControl1 as PersonalSportSkillTableControl1 = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalSportSkillTableControl1"), PersonalSportSkillTableControl1)
|
|
recPersonalSportSkillTableControl1.SaveData()
|
|
|
|
Dim recPersonalTitleTableControl as PersonalTitleTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonalTitleTableControl"), PersonalTitleTableControl)
|
|
recPersonalTitleTableControl.SaveData()
|
|
|
|
Dim recPersonRelativeTableControl as PersonRelativeTableControl = DirectCast(MiscUtils.FindControlRecursively(Me.Page, "PersonRelativeTableControl"), PersonRelativeTableControl)
|
|
recPersonRelativeTableControl.SaveData()
|
|
|
|
End Sub
|
|
|
|
' To customize, override this method in PersonalIdRecordControl.
|
|
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.
|
|
|
|
GetAddr()
|
|
GetAmphur()
|
|
GetArmId()
|
|
GetArmyId()
|
|
GetArmyWelfareMemId()
|
|
GetBAmphur()
|
|
GetBirthDate()
|
|
GetBloodId()
|
|
GetBorn()
|
|
GetBProvince()
|
|
GetCremateMemId()
|
|
GetDeptId()
|
|
GetMId()
|
|
GetMobilePhone()
|
|
GetNationality()
|
|
GetOfficerDate()
|
|
GetOrigin()
|
|
GetPersonalId()
|
|
GetPersonalLastName()
|
|
GetPersonalName()
|
|
GetPhone()
|
|
GetPhoneExt()
|
|
Getpicture()
|
|
GetPlaceOfBirth()
|
|
GetPostCode()
|
|
GetProvince()
|
|
GetRankId()
|
|
GetRegDate()
|
|
GetRegNo1()
|
|
GetRegNo2()
|
|
GetReligion()
|
|
GetSectionId()
|
|
GetSex()
|
|
GetStatusId()
|
|
GetTId()
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub GetAddr()
|
|
|
|
' Retrieve the value entered by the user on the Addr ASP:TextBox, and
|
|
' save it into the Addr field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Addr.Text, PersonalIdTable.Addr)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetAmphur()
|
|
|
|
' Retrieve the value entered by the user on the Amphur ASP:TextBox, and
|
|
' save it into the Amphur field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Amphur.Text, PersonalIdTable.Amphur)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetArmId()
|
|
|
|
' Retrieve the value entered by the user on the ArmId ASP:DropDownList, and
|
|
' save it into the ArmId field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.ArmId), PersonalIdTable.ArmId)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetArmyId()
|
|
|
|
' Retrieve the value entered by the user on the ArmyId ASP:DropDownList, and
|
|
' save it into the ArmyId field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.ArmyId), PersonalIdTable.ArmyId)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetArmyWelfareMemId()
|
|
|
|
' Retrieve the value entered by the user on the ArmyWelfareMemId ASP:TextBox, and
|
|
' save it into the ArmyWelfareMemId field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.ArmyWelfareMemId.Text, PersonalIdTable.ArmyWelfareMemId)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetBAmphur()
|
|
|
|
' Retrieve the value entered by the user on the BAmphur ASP:TextBox, and
|
|
' save it into the BAmphur field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.BAmphur.Text, PersonalIdTable.BAmphur)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetBirthDate()
|
|
|
|
' Retrieve the value entered by the user on the BirthDate ASP:TextBox, and
|
|
' save it into the BirthDate field in DataSource PersonalId record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.BirthDate.Text, PersonalIdTable.BirthDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetBloodId()
|
|
|
|
' Retrieve the value entered by the user on the BloodId ASP:DropDownList, and
|
|
' save it into the BloodId field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.BloodId), PersonalIdTable.BloodId)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetBorn()
|
|
|
|
' Retrieve the value entered by the user on the Born ASP:DropDownList, and
|
|
' save it into the Born field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.Born), PersonalIdTable.Born)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetBProvince()
|
|
|
|
' Retrieve the value entered by the user on the BProvince ASP:TextBox, and
|
|
' save it into the BProvince field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.BProvince.Text, PersonalIdTable.BProvince)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetCremateMemId()
|
|
|
|
' Retrieve the value entered by the user on the CremateMemId ASP:TextBox, and
|
|
' save it into the CremateMemId field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.CremateMemId.Text, PersonalIdTable.CremateMemId)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetDeptId()
|
|
|
|
' Retrieve the value entered by the user on the DeptId ASP:DropDownList, and
|
|
' save it into the DeptId field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.DeptId), PersonalIdTable.DeptId)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetMId()
|
|
|
|
' Retrieve the value entered by the user on the MId ASP:TextBox, and
|
|
' save it into the MId field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.MId.Text, PersonalIdTable.MId)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetMobilePhone()
|
|
|
|
' Retrieve the value entered by the user on the MobilePhone ASP:TextBox, and
|
|
' save it into the MobilePhone field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.MobilePhone.Text, PersonalIdTable.MobilePhone)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetNationality()
|
|
|
|
' Retrieve the value entered by the user on the Nationality ASP:TextBox, and
|
|
' save it into the Nationality field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Nationality.Text, PersonalIdTable.Nationality)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetOfficerDate()
|
|
|
|
' Retrieve the value entered by the user on the OfficerDate ASP:TextBox, and
|
|
' save it into the OfficerDate field in DataSource PersonalId record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.OfficerDate.Text, PersonalIdTable.OfficerDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetOrigin()
|
|
|
|
' Retrieve the value entered by the user on the Origin ASP:TextBox, and
|
|
' save it into the Origin field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Origin.Text, PersonalIdTable.Origin)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetPersonalId()
|
|
|
|
' Retrieve the value entered by the user on the PersonalId ASP:TextBox, and
|
|
' save it into the PersonalId field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.PersonalId.Text, PersonalIdTable.PersonalId)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetPersonalLastName()
|
|
|
|
' Retrieve the value entered by the user on the PersonalLastName ASP:TextBox, and
|
|
' save it into the PersonalLastName field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.PersonalLastName.Text, PersonalIdTable.PersonalLastName)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetPersonalName()
|
|
|
|
' Retrieve the value entered by the user on the PersonalName ASP:TextBox, and
|
|
' save it into the PersonalName field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.PersonalName.Text, PersonalIdTable.PersonalName)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetPhone()
|
|
|
|
' Retrieve the value entered by the user on the Phone ASP:TextBox, and
|
|
' save it into the Phone field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Phone.Text, PersonalIdTable.Phone)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetPhoneExt()
|
|
|
|
' Retrieve the value entered by the user on the PhoneExt ASP:TextBox, and
|
|
' save it into the PhoneExt field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.PhoneExt.Text, PersonalIdTable.PhoneExt)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub Getpicture()
|
|
' Retrieve the value entered by the user on the picture ASP:FileUpload, and
|
|
' save it into the picture field in DataSource PersonalId record.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
If Not Me.picture.PostedFile is Nothing then
|
|
If Me.picture.PostedFile.FileName.Length > 0 AndAlso Me.picture.PostedFile.ContentLength > 0 Then
|
|
' Retrieve the file contents and store them in picture field.
|
|
Me.DataSource.Parse(MiscUtils.GetFileContent(Me.picture.PostedFile), PersonalIdTable.picture)
|
|
|
|
' If there is a FileName companion field specified, then save the file name as well.
|
|
' Strip off the path and just save the part after the last \
|
|
Dim path As String = Me.picture.PostedFile.FileName
|
|
Dim LastIndex As Integer = path.LastIndexOf("\")
|
|
|
|
Me.DataSource.PictureName = path.Substring(LastIndex + 1).Replace("'", "_")
|
|
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Public Overridable Sub GetPlaceOfBirth()
|
|
|
|
' Retrieve the value entered by the user on the PlaceOfBirth ASP:TextBox, and
|
|
' save it into the PlaceOfBirth field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.PlaceOfBirth.Text, PersonalIdTable.PlaceOfBirth)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetPostCode()
|
|
|
|
' Retrieve the value entered by the user on the PostCode ASP:TextBox, and
|
|
' save it into the PostCode field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.PostCode.Text, PersonalIdTable.PostCode)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetProvince()
|
|
|
|
' Retrieve the value entered by the user on the Province ASP:TextBox, and
|
|
' save it into the Province field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Province.Text, PersonalIdTable.Province)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRankId()
|
|
|
|
' Retrieve the value entered by the user on the RankId ASP:DropDownList, and
|
|
' save it into the RankId field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.RankId), PersonalIdTable.RankId)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRegDate()
|
|
|
|
' Retrieve the value entered by the user on the RegDate ASP:TextBox, and
|
|
' save it into the RegDate field in DataSource PersonalId record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RegDate.Text, PersonalIdTable.RegDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRegNo1()
|
|
|
|
' Retrieve the value entered by the user on the RegNo1 ASP:TextBox, and
|
|
' save it into the RegNo1 field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RegNo1.Text, PersonalIdTable.RegNo1)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRegNo2()
|
|
|
|
' Retrieve the value entered by the user on the RegNo2 ASP:TextBox, and
|
|
' save it into the RegNo2 field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RegNo2.Text, PersonalIdTable.RegNo2)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetReligion()
|
|
|
|
' Retrieve the value entered by the user on the Religion ASP:TextBox, and
|
|
' save it into the Religion field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Religion.Text, PersonalIdTable.Religion)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetSectionId()
|
|
|
|
' Retrieve the value entered by the user on the SectionId ASP:DropDownList, and
|
|
' save it into the SectionId field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.SectionId), PersonalIdTable.SectionId)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetSex()
|
|
|
|
' Retrieve the value entered by the user on the Sex ASP:DropDownList, and
|
|
' save it into the Sex field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.Sex), PersonalIdTable.Sex)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetStatusId()
|
|
|
|
' Retrieve the value entered by the user on the StatusId ASP:DropDownList, and
|
|
' save it into the StatusId field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.StatusId), PersonalIdTable.StatusId)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetTId()
|
|
|
|
' Retrieve the value entered by the user on the TId ASP:TextBox, and
|
|
' save it into the TId field in DataSource PersonalId record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.TId.Text, PersonalIdTable.TId)
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
' To customize, override this method in PersonalIdRecordControl.
|
|
|
|
Public Overridable Function CreateWhereClause() As WhereClause
|
|
|
|
Dim wc As WhereClause
|
|
PersonalIdTable.Instance.InnerFilter = Nothing
|
|
wc = New WhereClause()
|
|
|
|
' Compose the WHERE clause consiting of:
|
|
' 1. Static clause defined at design time.
|
|
' 2. User selected filter criteria.
|
|
' 3. User selected search criteria.
|
|
|
|
|
|
' Get the static clause defined at design time on the Record Panel Wizard
|
|
|
|
Dim qc As WhereClause = Me.CreateQueryClause()
|
|
If Not(IsNothing(qc)) Then
|
|
wc.iAND(qc)
|
|
End If
|
|
|
|
' Retrieve the record id from the URL parameter.
|
|
|
|
Dim recId As String = Me.Page.Request.QueryString.Item("PersonalId")
|
|
|
|
If recId Is Nothing OrElse recId.Trim = "" Then
|
|
' Get the error message from the application resource file.
|
|
Throw New Exception(Page.GetResourceValue("Err:UrlParamMissing", "Persons").Replace("{URL}", "PersonalId"))
|
|
End If
|
|
HttpContext.Current.Session("QueryString in EditPersonalId") = recId
|
|
|
|
If KeyValue.IsXmlKey(recId) Then
|
|
' Keys are typically passed as XML structures to handle composite keys.
|
|
' If XML, then add a Where clause based on the Primary Key in the XML.
|
|
Dim pkValue As KeyValue = KeyValue.XmlToKey(recId)
|
|
|
|
wc.iAND(PersonalIdTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, pkValue.GetColumnValueString(PersonalIdTable.PersonalId))
|
|
|
|
Else
|
|
' The URL parameter contains the actual value, not an XML structure.
|
|
|
|
wc.iAND(PersonalIdTable.PersonalId, BaseFilter.ComparisonOperator.EqualsTo, recId)
|
|
|
|
End If
|
|
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
Protected Overridable Function CreateQueryClause() As WhereClause
|
|
' Create a where clause for the Static clause defined at design time.
|
|
Return Nothing
|
|
End Function
|
|
|
|
' This CreateWhereClause is used for loading list of suggestions for Auto Type-Ahead feature.
|
|
|
|
Public Overridable Function CreateWhereClause(ByVal searchText As String, ByVal fromSearchControl As String, ByVal AutoTypeAheadSearch As String, ByVal AutoTypeAheadWordSeparators As String) As WhereClause
|
|
PersonalIdTable.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 filter criteria.
|
|
' 3. User selected search criteria.
|
|
Dim appRelativeVirtualPath As String = CType(HttpContext.Current.Session("AppRelativeVirtualPath"), String)
|
|
|
|
|
|
' Get the static clause defined at design time on the Table Panel Wizard
|
|
Dim qc As WhereClause = Me.CreateQueryClause()
|
|
If Not(IsNothing(qc)) Then
|
|
wc.iAND(qc) ''nope nothing
|
|
End If
|
|
|
|
' Adds clauses if values are selected in Filter controls which are configured in the page.
|
|
|
|
|
|
|
|
Return wc
|
|
End Function
|
|
|
|
|
|
'Formats the resultItem and adds it to the list of suggestions.
|
|
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
|
|
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
|
|
|
|
|
|
|
|
' To customize, override this method in PersonalIdRecordControl.
|
|
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)
|
|
PersonalIdTable.DeleteRecord(pkValue)
|
|
|
|
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
|
|
|
|
|
|
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
|
|
|
|
|
|
' Generate the event handling functions for pagination events.
|
|
|
|
|
|
' Generate the event handling functions for filter and search events.
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_ArmIdDropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the Arm table.
|
|
' Examples:
|
|
' wc.iAND(ArmTable.ArmSName, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(ArmTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_ArmyIdDropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the Army table.
|
|
' Examples:
|
|
' wc.iAND(ArmyTable.Army, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(ArmyTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_BloodIdDropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the BloodId table.
|
|
' Examples:
|
|
' wc.iAND(BloodIdTable.BloodName, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(BloodIdTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_BornDropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the Born table.
|
|
' Examples:
|
|
' wc.iAND(BornTable.BornDesc, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(BornTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_DeptIdDropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the Dept table.
|
|
' Examples:
|
|
' wc.iAND(DeptTable.Dept, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(DeptTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_RankIdDropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_SectionIdDropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the Section table.
|
|
' Examples:
|
|
' wc.iAND(SectionTable.SectionName, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(SectionTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_SexDropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the Sex table.
|
|
' Examples:
|
|
' wc.iAND(SexTable.Sex, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(SexTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_StatusIdDropDownList() As WhereClause
|
|
' By default, we simply return a new WhereClause.
|
|
' Add additional where clauses to restrict the items shown in the dropdown list.
|
|
|
|
' This WhereClause is for the Status table.
|
|
' Examples:
|
|
' wc.iAND(StatusTable.Status, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(StatusTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
' Fill the ArmId list.
|
|
Protected Overridable Sub PopulateArmIdDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.ArmId.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.ArmId.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_ArmIdDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_ArmIdDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(ArmTable.ArmSName, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim itemValues() As ArmRecord = Nothing
|
|
Dim evaluator As New FormulaEvaluator
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
Do
|
|
itemValues = ArmTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
For each itemValue As ArmRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.ArmIdSpecified Then
|
|
cvalue = itemValue.ArmId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.ArmId.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalIdTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalIdTable.ArmId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalIdTable.ArmId.IsApplyDisplayAs Then
|
|
fvalue = PersonalIdTable.GetDFKA(itemValue, PersonalIdTable.ArmId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(ArmTable.ArmSName)
|
|
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.ArmId.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.ArmId.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
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.ArmId, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.ArmId, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with Arm.ArmId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(ArmTable.ArmId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As ArmRecord = ArmTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As ArmRecord = DirectCast(rc(0), ArmRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.ArmIdSpecified Then
|
|
cvalue = itemValue.ArmId.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalIdTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalIdTable.ArmId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalIdTable.ArmId.IsApplyDisplayAs Then
|
|
fvalue = PersonalIdTable.GetDFKA(itemValue, PersonalIdTable.ArmId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(ArmTable.ArmSName)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.ArmId.Items.Add(newItem)
|
|
SetSelectedValue(Me.ArmId, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' Fill the ArmyId list.
|
|
Protected Overridable Sub PopulateArmyIdDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.ArmyId.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.ArmyId.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_ArmyIdDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_ArmyIdDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
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)
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim itemValues() As ArmyRecord = Nothing
|
|
Dim evaluator As New FormulaEvaluator
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
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.ArmyId.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalIdTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalIdTable.ArmyId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalIdTable.ArmyId.IsApplyDisplayAs Then
|
|
fvalue = PersonalIdTable.GetDFKA(itemValue, PersonalIdTable.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.ArmyId.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.ArmyId.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
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.ArmyId, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.ArmyId, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with Army.ArmyId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(ArmyTable.ArmyId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As ArmyRecord = ArmyTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As ArmyRecord = DirectCast(rc(0), ArmyRecord)
|
|
' 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()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalIdTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalIdTable.ArmyId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalIdTable.ArmyId.IsApplyDisplayAs Then
|
|
fvalue = PersonalIdTable.GetDFKA(itemValue, PersonalIdTable.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
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.ArmyId.Items.Add(newItem)
|
|
SetSelectedValue(Me.ArmyId, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' Fill the BloodId list.
|
|
Protected Overridable Sub PopulateBloodIdDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.BloodId.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.BloodId.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_BloodIdDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_BloodIdDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(BloodIdTable.BloodName, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim itemValues() As BloodIdRecord = Nothing
|
|
Dim evaluator As New FormulaEvaluator
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
Do
|
|
itemValues = BloodIdTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
For each itemValue As BloodIdRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.BloodIdSpecified Then
|
|
cvalue = itemValue.BloodId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.BloodId.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalIdTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalIdTable.BloodId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalIdTable.BloodId.IsApplyDisplayAs Then
|
|
fvalue = PersonalIdTable.GetDFKA(itemValue, PersonalIdTable.BloodId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(BloodIdTable.BloodName)
|
|
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.BloodId.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.BloodId.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
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.BloodId, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.BloodId, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with BloodId.BloodId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(BloodIdTable.BloodId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As BloodIdRecord = BloodIdTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As BloodIdRecord = DirectCast(rc(0), BloodIdRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.BloodIdSpecified Then
|
|
cvalue = itemValue.BloodId.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalIdTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalIdTable.BloodId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalIdTable.BloodId.IsApplyDisplayAs Then
|
|
fvalue = PersonalIdTable.GetDFKA(itemValue, PersonalIdTable.BloodId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(BloodIdTable.BloodName)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.BloodId.Items.Add(newItem)
|
|
SetSelectedValue(Me.BloodId, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' Fill the Born list.
|
|
Protected Overridable Sub PopulateBornDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.Born.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.Born.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_BornDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_BornDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(BornTable.BornDesc, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim itemValues() As BornRecord = Nothing
|
|
Dim evaluator As New FormulaEvaluator
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
Do
|
|
itemValues = BornTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
For each itemValue As BornRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.BornSpecified Then
|
|
cvalue = itemValue.Born.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.Born.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalIdTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalIdTable.Born)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalIdTable.Born.IsApplyDisplayAs Then
|
|
fvalue = PersonalIdTable.GetDFKA(itemValue, PersonalIdTable.Born)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(BornTable.BornDesc)
|
|
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.Born.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.Born.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
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.Born, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.Born, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with Born.Born = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(BornTable.Born, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As BornRecord = BornTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As BornRecord = DirectCast(rc(0), BornRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.BornSpecified Then
|
|
cvalue = itemValue.Born.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalIdTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalIdTable.Born)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalIdTable.Born.IsApplyDisplayAs Then
|
|
fvalue = PersonalIdTable.GetDFKA(itemValue, PersonalIdTable.Born)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(BornTable.BornDesc)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.Born.Items.Add(newItem)
|
|
SetSelectedValue(Me.Born, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' Fill the DeptId list.
|
|
Protected Overridable Sub PopulateDeptIdDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.DeptId.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.DeptId.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_DeptIdDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_DeptIdDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(DeptTable.Dept, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim itemValues() As DeptRecord = Nothing
|
|
Dim evaluator As New FormulaEvaluator
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
Do
|
|
itemValues = DeptTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
For each itemValue As DeptRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.DeptIdSpecified Then
|
|
cvalue = itemValue.DeptId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.DeptId.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalIdTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalIdTable.DeptId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalIdTable.DeptId.IsApplyDisplayAs Then
|
|
fvalue = PersonalIdTable.GetDFKA(itemValue, PersonalIdTable.DeptId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(DeptTable.Dept)
|
|
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.DeptId.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.DeptId.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
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.DeptId, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.DeptId, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with Dept.DeptId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(DeptTable.DeptId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As DeptRecord = DeptTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As DeptRecord = DirectCast(rc(0), DeptRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.DeptIdSpecified Then
|
|
cvalue = itemValue.DeptId.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalIdTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalIdTable.DeptId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalIdTable.DeptId.IsApplyDisplayAs Then
|
|
fvalue = PersonalIdTable.GetDFKA(itemValue, PersonalIdTable.DeptId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(DeptTable.Dept)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.DeptId.Items.Add(newItem)
|
|
SetSelectedValue(Me.DeptId, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' Fill the RankId list.
|
|
Protected Overridable Sub PopulateRankIdDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.RankId.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.RankId.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_RankIdDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_RankIdDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim orderBy As OrderBy = New OrderBy(False, False)
|
|
orderBy.Add(PersonalIdTable.RankId, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim itemValue As String
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
For Each itemValue In PersonalIdTable.GetValues(PersonalIdTable.RankId, wc, orderBy, maxItems)
|
|
' Create the dropdown list item and add it to the list.
|
|
Dim fvalue As String = PersonalIdTable.RankId.Format(itemValue)
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = itemValue
|
|
Dim dupItem As ListItem = Me.RankId.Items.FindByText(fvalue)
|
|
|
|
If Not IsNothing(dupItem) Then
|
|
listDuplicates.Add(fvalue)
|
|
dupItem.Text = fvalue & " (ID " & dupItem.Value & ")"
|
|
End If
|
|
|
|
Dim newItem As ListItem = New ListItem(fvalue, itemValue)
|
|
Me.RankId.Items.Add(newItem)
|
|
|
|
If listDuplicates.Contains(fvalue) Then
|
|
newItem.Text = fvalue & " (ID " & itemValue & ")"
|
|
End If
|
|
Next
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.RankId, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.RankId, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.RankId, PersonalIdTable.RankId.Format(selectedValue))Then
|
|
Dim fvalue As String = PersonalIdTable.RankId.Format(selectedValue)
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = selectedValue
|
|
Dim item As ListItem = New ListItem(fvalue, selectedValue)
|
|
item.Selected = True
|
|
Me.RankId.Items.Add(item)
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' Fill the SectionId list.
|
|
Protected Overridable Sub PopulateSectionIdDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.SectionId.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.SectionId.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_SectionIdDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_SectionIdDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(SectionTable.SectionName, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim itemValues() As SectionRecord = Nothing
|
|
Dim evaluator As New FormulaEvaluator
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
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.SectionId.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalIdTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalIdTable.SectionId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalIdTable.SectionId.IsApplyDisplayAs Then
|
|
fvalue = PersonalIdTable.GetDFKA(itemValue, PersonalIdTable.SectionId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(SectionTable.SectionName)
|
|
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.SectionId.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.SectionId.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
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.SectionId, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.SectionId, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with Section.SectionId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(SectionTable.SectionId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As SectionRecord = SectionTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As SectionRecord = DirectCast(rc(0), SectionRecord)
|
|
' 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()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalIdTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalIdTable.SectionId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalIdTable.SectionId.IsApplyDisplayAs Then
|
|
fvalue = PersonalIdTable.GetDFKA(itemValue, PersonalIdTable.SectionId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(SectionTable.SectionName)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.SectionId.Items.Add(newItem)
|
|
SetSelectedValue(Me.SectionId, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' Fill the Sex list.
|
|
Protected Overridable Sub PopulateSexDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.Sex.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.Sex.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_SexDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_SexDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(SexTable.Sex, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim itemValues() As SexRecord = Nothing
|
|
Dim evaluator As New FormulaEvaluator
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
Do
|
|
itemValues = SexTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
For each itemValue As SexRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.SexIdSpecified Then
|
|
cvalue = itemValue.SexId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.Sex.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalIdTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalIdTable.Sex)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalIdTable.Sex.IsApplyDisplayAs Then
|
|
fvalue = PersonalIdTable.GetDFKA(itemValue, PersonalIdTable.Sex)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(SexTable.Sex)
|
|
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.Sex.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.Sex.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
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.Sex, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.Sex, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with Sex.SexId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(SexTable.SexId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As SexRecord = SexTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As SexRecord = DirectCast(rc(0), SexRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.SexIdSpecified Then
|
|
cvalue = itemValue.SexId.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalIdTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalIdTable.Sex)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalIdTable.Sex.IsApplyDisplayAs Then
|
|
fvalue = PersonalIdTable.GetDFKA(itemValue, PersonalIdTable.Sex)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(SexTable.Sex)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.Sex.Items.Add(newItem)
|
|
SetSelectedValue(Me.Sex, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' Fill the StatusId list.
|
|
Protected Overridable Sub PopulateStatusIdDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.StatusId.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.StatusId.Items.Insert(0, new ListItem(Me.Page.GetResourceValue("Txt:PleaseSelect", "Persons"), "--PLEASE_SELECT--"))
|
|
|
|
' 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_StatusIdDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_StatusIdDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(StatusTable.Status, OrderByItem.OrderDir.Asc)
|
|
|
|
Dim variables As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
|
|
' 3. Read a total of maxItems from the database and insert them
|
|
Dim itemValues() As StatusRecord = Nothing
|
|
Dim evaluator As New FormulaEvaluator
|
|
If wc.RunQuery
|
|
Dim counter As Integer = 0
|
|
Dim pageNum As Integer = 0
|
|
Dim listDuplicates As New ArrayList()
|
|
|
|
Do
|
|
itemValues = StatusTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
For each itemValue As StatusRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.StatusIdSpecified Then
|
|
cvalue = itemValue.StatusId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.StatusId.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalIdTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalIdTable.StatusId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalIdTable.StatusId.IsApplyDisplayAs Then
|
|
fvalue = PersonalIdTable.GetDFKA(itemValue, PersonalIdTable.StatusId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(StatusTable.Status)
|
|
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.StatusId.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.StatusId.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
|
|
|
|
|
|
' 4. Set the selected value (insert if not already present).
|
|
|
|
If Not selectedValue Is Nothing AndAlso _
|
|
selectedValue.Trim <> "" AndAlso _
|
|
Not SetSelectedValue(Me.StatusId, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.StatusId, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with Status.StatusId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(StatusTable.StatusId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As StatusRecord = StatusTable.GetRecords(whereClause2, New OrderBy(False, False), 0, 1)
|
|
Dim vars As System.Collections.Generic.IDictionary(Of String, Object) = New System.Collections.Generic.Dictionary(Of String, Object)
|
|
' if find a record, add it to the dropdown and set it as selected item
|
|
If rc IsNot Nothing AndAlso rc.Length = 1 Then
|
|
Dim itemValue As StatusRecord = DirectCast(rc(0), StatusRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.StatusIdSpecified Then
|
|
cvalue = itemValue.StatusId.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalIdTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalIdTable.StatusId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalIdTable.StatusId.IsApplyDisplayAs Then
|
|
fvalue = PersonalIdTable.GetDFKA(itemValue, PersonalIdTable.StatusId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(StatusTable.Status)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.StatusId.Items.Add(newItem)
|
|
SetSelectedValue(Me.StatusId, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub ArmId_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(ArmId.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(ArmId.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.ArmId.Items.Add(New ListItem(displayText, val))
|
|
Me.ArmId.SelectedIndex = Me.ArmId.Items.Count - 1
|
|
Me.Page.Session.Remove(ArmId.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(ArmId.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub ArmyId_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(ArmyId.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(ArmyId.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.ArmyId.Items.Add(New ListItem(displayText, val))
|
|
Me.ArmyId.SelectedIndex = Me.ArmyId.Items.Count - 1
|
|
Me.Page.Session.Remove(ArmyId.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(ArmyId.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub BloodId_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(BloodId.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(BloodId.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.BloodId.Items.Add(New ListItem(displayText, val))
|
|
Me.BloodId.SelectedIndex = Me.BloodId.Items.Count - 1
|
|
Me.Page.Session.Remove(BloodId.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(BloodId.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Born_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(Born.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(Born.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.Born.Items.Add(New ListItem(displayText, val))
|
|
Me.Born.SelectedIndex = Me.Born.Items.Count - 1
|
|
Me.Page.Session.Remove(Born.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(Born.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub DeptId_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(DeptId.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(DeptId.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.DeptId.Items.Add(New ListItem(displayText, val))
|
|
Me.DeptId.SelectedIndex = Me.DeptId.Items.Count - 1
|
|
Me.Page.Session.Remove(DeptId.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(DeptId.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RankId_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(RankId.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(RankId.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.RankId.Items.Add(New ListItem(displayText, val))
|
|
Me.RankId.SelectedIndex = Me.RankId.Items.Count - 1
|
|
Me.Page.Session.Remove(RankId.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(RankId.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub SectionId_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(SectionId.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(SectionId.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.SectionId.Items.Add(New ListItem(displayText, val))
|
|
Me.SectionId.SelectedIndex = Me.SectionId.Items.Count - 1
|
|
Me.Page.Session.Remove(SectionId.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(SectionId.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Sex_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(Sex.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(Sex.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.Sex.Items.Add(New ListItem(displayText, val))
|
|
Me.Sex.SelectedIndex = Me.Sex.Items.Count - 1
|
|
Me.Page.Session.Remove(Sex.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(Sex.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub StatusId_SelectedIndexChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
' for the value inserted by quick add button or large list selector,
|
|
' the value is necessary to be inserted by this event during postback
|
|
Dim val As String = CType(Me.Page.Session()(StatusId.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(StatusId.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.StatusId.Items.Add(New ListItem(displayText, val))
|
|
Me.StatusId.SelectedIndex = Me.StatusId.Items.Count - 1
|
|
Me.Page.Session.Remove(StatusId.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(StatusId.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Addr_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Amphur_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub ArmyWelfareMemId_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub BAmphur_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub BirthDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub BProvince_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub CremateMemId_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub MId_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub MobilePhone_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Nationality_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub OfficerDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Origin_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub PersonalId_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub PersonalLastName_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub PersonalName_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Phone_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub PhoneExt_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub PlaceOfBirth_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub PostCode_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Province_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RegDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RegNo1_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RegNo2_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Religion_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub TId_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
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("BasePersonalIdRecordControl_Rec"), String)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me.ViewState("BasePersonalIdRecordControl_Rec") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataSource As PersonalIdRecord
|
|
Public Property DataSource() As PersonalIdRecord
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
|
|
Set(ByVal value As PersonalIdRecord)
|
|
|
|
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 _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
|
|
|
|
Private _TotalRecords As Integer
|
|
Public Property TotalRecords() As Integer
|
|
Get
|
|
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
|
|
|
|
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 Addr() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Addr"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property AddrLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "AddrLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Amphur() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Amphur"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property AmphurLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "AmphurLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ArmId() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ArmId"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ArmIdLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ArmIdLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ArmyId() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ArmyId"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ArmyIdLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ArmyIdLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ArmyWelfareMemId() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ArmyWelfareMemId"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ArmyWelfareMemIdLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ArmyWelfareMemIdLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BAmphur() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "BAmphur"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BAmphurLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "BAmphurLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BirthDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "BirthDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BirthDateLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "BirthDateLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BloodId() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "BloodId"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BloodIdLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "BloodIdLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Born() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Born"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BornLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "BornLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BProvince() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "BProvince"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BProvinceLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "BProvinceLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CremateMemId() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CremateMemId"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CremateMemIdLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "CremateMemIdLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DeptId() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "DeptId"), 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 MId() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "MId"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MIdLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "MIdLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MobilePhone() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "MobilePhone"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MobilePhoneLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "MobilePhoneLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Nationality() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Nationality"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property NationalityLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "NationalityLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property OfficerDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "OfficerDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property OfficerDateLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "OfficerDateLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Origin() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Origin"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property OriginLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "OriginLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalId() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalId"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalIdLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalIdLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalIdRecordControlCollapsibleRegion() As System.Web.UI.WebControls.Panel
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalIdRecordControlCollapsibleRegion"), System.Web.UI.WebControls.Panel)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalIdRecordControlIcon() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalIdRecordControlIcon"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalIdRecordControlPanelExtender() As AjaxControlToolkit.CollapsiblePanelExtender
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalIdRecordControlPanelExtender"), AjaxControlToolkit.CollapsiblePanelExtender)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalIdTitle() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalIdTitle"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalLastName() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalLastName"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalLastNameLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalLastNameLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalName() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalName"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalNameLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalNameLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Phone() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Phone"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PhoneExt() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PhoneExt"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PhoneExtLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PhoneExtLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PhoneLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PhoneLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property picture() As System.Web.UI.WebControls.FileUpload
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "picture"), System.Web.UI.WebControls.FileUpload)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property pictureImage() As System.Web.UI.WebControls.Image
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "pictureImage"), System.Web.UI.WebControls.Image)
|
|
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 PlaceOfBirth() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PlaceOfBirth"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PlaceOfBirthLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PlaceOfBirthLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PostCode() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PostCode"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PostCodeLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PostCodeLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Province() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Province"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ProvinceLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ProvinceLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RankId() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RankId"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RankIdLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RankIdLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RegDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RegDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RegDateLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RegDateLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RegNo1() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RegNo1"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RegNo1Label() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RegNo1Label"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RegNo2() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RegNo2"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RegNo2Label() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RegNo2Label"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Religion() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Religion"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ReligionLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ReligionLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SectionId() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SectionId"), 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 Sex() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Sex"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SexLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "SexLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property StatusId() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "StatusId"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property StatusIdLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "StatusIdLabel"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property TId() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "TId"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property TIdLabel() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "TIdLabel"), System.Web.UI.WebControls.Literal)
|
|
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 PersonalIdRecord = 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 PersonalIdRecord
|
|
If Not Me.DataSource Is Nothing Then
|
|
Return Me.DataSource
|
|
End If
|
|
|
|
If Not Me.RecordUniqueId Is Nothing Then
|
|
|
|
Return PersonalIdTable.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
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
End Namespace
|
|
|
|
|