' This file implements the TableControl, TableControlRow, and RecordControl classes for the ' EditPersonalId1.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 Imports CrPdf #End Region Namespace Persons.UI.Controls.EditPersonalId1 #Region "Section 1: Place your customizations here." 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 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() 'SaveData() Else Throw New ApplicationException("กรอกรหัสประจำตัวประชาชนไม่ถูกต้อง") 'MiscUtils.RegisterJScriptAlert(Me, "", "กรอกรหัสประจำตัวประชาชนไม่ถูกต้อง") End If End If DbUtils.CommitTransaction() Catch ex As ApplicationException MiscUtils.RegisterJScriptAlert(Me, "", ex.Message) End Try End Sub Public Overrides Sub SaveData() 'Dim Rec As PersonalIdRecord = Me.GetRecord If Ps.IsPid(Me.PersonalId.Text) Then ' Me.Page.RedirectToLoginPage() MyBase.SaveData() 'Me.Page.CurrentSecurity.SetUser(Me.PersonalName.Text, Me.PersonalId.Text) 'Me.Page.RedirectToLoginPage() 'Utils.SecurityControls.SetCurrentUserID(Me.PersonalId.Text) 'Me.Page.RedirectToDefaultPage() Else 'Throw New Exception("กรอกรหัสประจำตัวประชาชนไม่ถูกต้อง") Throw New ApplicationException("กรอกรหัสประจำตัวประชาชนไม่ถูกต้อง") 'MiscUtils.RegisterJScriptAlert(Me, "", "กรอกรหัสประจำตัวประชาชนไม่ถูกต้อง") End If 'MyBase.SaveData() 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 ' Public Overrides Sub View_PersonsPDFButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs) ' ' Try ' ' Dim cls As New CrPdf ' cls.GetCr(Me.Page, "report1.rpt", "Pid", Me.PersonalId.Text) ' ' 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 End Class Public Class ReportPropertiesTableControl Inherits BaseReportPropertiesTableControl Public Overrides Sub ReportPropertiesPDFButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs) Try Dim PID As TextBox = CType(Me.Page.FindControlRecursively("PersonalId"), TextBox) Dim cr As New CrPdf Dim param(0) As String param(0) = "PID," & PID.Text ' Utils.SecurityControls.GetCurrentUserID cr.GetCr(Me, "../Reports/Person_Record.rpt", param) 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 Public Overrides Sub ReportPropertiesWordButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs) Try Dim PID As TextBox = CType(Me.Page.FindControlRecursively("PersonalId"), TextBox) Dim cr As New CrPdf Dim param(0) As String param(0) = "PID," & PID.Text ' Utils.SecurityControls.GetCurrentUserID cr.GetCr(Me, "../Reports/Person_Record.rpt", param, 3) 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 Public Overrides Sub ReportPropertiesExportExcelButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs) Try Dim PID As TextBox = CType(Me.Page.FindControlRecursively("PersonalId"), TextBox) Dim cr As New CrPdf Dim param(0) As String param(0) = "PID," & PID.Text ' Utils.SecurityControls.GetCurrentUserID cr.GetCr(Me, "../Reports/Person_Record.rpt", param, 2) 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 Public Overrides Sub SaveData() ' do Nothing End Sub End Class Public Class ReportPropertiesTableControlRow Inherits BaseReportPropertiesTableControlRow End Class #End Region #Region "Section 2: Do not modify this section." ' Base class for the ReportPropertiesTableControlRow control on the EditPersonalId1 page. ' Do not modify this class. Instead override any method in ReportPropertiesTableControlRow. Public Class BaseReportPropertiesTableControlRow Inherits Persons.UI.BaseApplicationRecordControl ' To customize, override this method in ReportPropertiesTableControlRow. 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 ReportPropertiesTableControlRow. Protected Overridable Sub Control_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Call LoadFocusScripts from repeater so that onfocus attribute could be added to elements Me.Page.LoadFocusScripts(Me) ' Register the event handlers. End Sub Public Overridable Sub LoadData() ' Load the data from the database into the DataSource ReportProperties 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 = ReportPropertiesTable.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 BaseReportPropertiesTableControl when the data for the entire ' table is loaded. Me.DataSource = New ReportPropertiesRecord() End Sub ' Populate the UI controls using the DataSource. To customize, override this method in ReportPropertiesTableControlRow. 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 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 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 ReportPropertiesTableControlRow. Public Overridable Sub SaveData() ' Saves the associated record in the database. ' SaveData calls Validate and Get methods - so it may be more appropriate to ' customize those methods. ' 1. Load the existing record from the database. Since we save the entire record, this ensures ' that fields that are not displayed are also properly initialized. Me.LoadData() ' 2. Perform any custom validation. Me.Validate() ' 3. Set the values in the record with data from UI controls. ' This calls the Get() method for each of the user interface controls. Me.GetUIData() ' 4. Save in the database. ' We should not save the record if the data did not change. This ' will save a database hit and avoid triggering any database triggers. If Me.DataSource.IsAnyValueChanged Then ' Save record to database but do not commit yet. ' Auto generated ids are available after saving for use by child (dependent) records. Me.DataSource.Save() DirectCast(GetParentControlObject(Me, "ReportPropertiesTableControl"), ReportPropertiesTableControl).DataChanged = True DirectCast(GetParentControlObject(Me, "ReportPropertiesTableControl"), ReportPropertiesTableControl).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 ReportPropertiesTableControlRow. 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. End Sub ' To customize, override this method in ReportPropertiesTableControlRow. Public Overridable Function CreateWhereClause() As WhereClause Return Nothing End Function ' To customize, override this method in ReportPropertiesTableControlRow. 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) ReportPropertiesTable.DeleteRecord(pkValue) DirectCast(GetParentControlObject(Me, "ReportPropertiesTableControl"), ReportPropertiesTableControl).DataChanged = True DirectCast(GetParentControlObject(Me, "ReportPropertiesTableControl"), ReportPropertiesTableControl).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 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("BaseReportPropertiesTableControlRow_Rec"), String) End Get Set(ByVal value As String) Me.ViewState("BaseReportPropertiesTableControlRow_Rec") = value End Set End Property Private _DataSource As ReportPropertiesRecord Public Property DataSource() As ReportPropertiesRecord Get Return Me._DataSource End Get Set(ByVal value As ReportPropertiesRecord) 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" #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 ReportPropertiesRecord = 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 ReportPropertiesRecord If Not Me.DataSource Is Nothing Then Return Me.DataSource End If If Not Me.RecordUniqueId Is Nothing Then Return ReportPropertiesTable.GetRecord(Me.RecordUniqueId, True) End If ' Localization. Throw New Exception(Page.GetResourceValue("Err:RetrieveRec", "Persons")) End Function Public Shadows ReadOnly Property Page() As BaseApplicationPage Get Return DirectCast(MyBase.Page, BaseApplicationPage) End Get End Property #End Region End Class ' Base class for the ReportPropertiesTableControl control on the EditPersonalId1 page. ' Do not modify this class. Instead override any method in ReportPropertiesTableControl. Public Class BaseReportPropertiesTableControl 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() ' Setup the pagination events. ' Setup the sorting events. ' Setup the button events. AddHandler Me.ReportPropertiesExportExcelButton.Click, AddressOf ReportPropertiesExportExcelButton_Click AddHandler Me.ReportPropertiesPDFButton.Click, AddressOf ReportPropertiesPDFButton_Click AddHandler Me.ReportPropertiesWordButton.Click, AddressOf ReportPropertiesWordButton_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(ReportPropertiesRecord)), ReportPropertiesRecord()) ' 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, ReportPropertiesTable.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 ReportPropertiesTableControlRow 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(ReportPropertiesRecord)), ReportPropertiesRecord()) Else ' Get the records from the database Me.DataSource = ReportPropertiesTable.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 ' 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, "ReportPropertiesTableControlRepeater"), 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 ReportPropertiesTableControlRow = DirectCast(repItem.FindControl("ReportPropertiesTableControlRow"), ReportPropertiesTableControlRow) 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 SetReportPropertiesTableControlCollapsibleRegion() ' setting the state of expand or collapse alternative rows ' Load data for each record and table UI control. ' Ordering is important because child controls get ' their parent ids from their parent UI controls. ' this method calls the set method for controls with special formula like running total, sum, rank, etc SetFormulaControls() End Sub Public Overridable Sub SetFormulaControls() ' this method calls Set methods for the control that has special formula End Sub Public Overridable Sub RegisterPostback() Me.Page.RegisterPostBackTrigger(MiscUtils.FindControlRecursively(Me,"ReportPropertiesExportExcelButton")) Me.Page.RegisterPostBackTrigger(MiscUtils.FindControlRecursively(Me,"ReportPropertiesPDFButton")) Me.Page.RegisterPostBackTrigger(MiscUtils.FindControlRecursively(Me,"ReportPropertiesWordButton")) 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. ' Bind the buttons for ReportPropertiesTableControl pagination. 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 ReportPropertiesTableControlRow 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. ReportPropertiesTable.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. 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. ReportPropertiesTable.Instance.InnerFilter = Nothing Dim wc As WhereClause = New WhereClause() ' Compose the WHERE clause consiting of: ' 1. Static clause defined at design time. ' 2. User selected search criteria. ' 3. User selected filter criteria. Dim appRelativeVirtualPath As String = CType(HttpContext.Current.Session("AppRelativeVirtualPath"), String) ' Adds clauses if values are selected in Filter controls which are configured in the page. 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() 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, "ReportPropertiesTableControlRepeater"), 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 ReportPropertiesTableControlRow = DirectCast(repItem.FindControl("ReportPropertiesTableControlRow"), ReportPropertiesTableControlRow) If recControl.Visible AndAlso recControl.IsNewRecord() Then Dim rec As ReportPropertiesRecord = New ReportPropertiesRecord() 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 ReportPropertiesRecord()) 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(ReportPropertiesRecord)), ReportPropertiesRecord()) 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 ReportPropertiesTableControlRow) 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 ReportPropertiesTableControlRow) 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 SetReportPropertiesTableControlCollapsibleRegion() 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 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("ReportPropertiesTableControl_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("ReportPropertiesTableControl_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. ' Generate the event handling functions for sorting events. ' Generate the event handling functions for button events. ' event handler for ImageButton Public Overridable Sub ReportPropertiesExportExcelButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs) Try ' Enclose all database retrieval/update code within a Transaction boundary DbUtils.StartTransaction ' To customize the columns or the format, override this function in Section 1 of the page ' and modify it to your liking. ' Build the where clause based on the current filter and search criteria ' Create the Order By clause based on the user's current sorting preference. Dim wc As WhereClause = CreateWhereClause Dim orderBy As OrderBy = Nothing orderBy = CreateOrderBy Dim done As Boolean = False Dim val As Object = "" ' Read pageSize records at a time and write out the Excel file. Dim totalRowsReturned As Integer = 0 Me.TotalRecords = ReportPropertiesTable.GetRecordCount(wc) If Me.TotalRecords > 10000 Then ' Add each of the columns in order of export. Dim columns() as BaseColumn = New BaseColumn() { _ Nothing} Dim exportData as ExportDataToCSV = New ExportDataToCSV(ReportPropertiesTable.Instance, wc, orderBy, columns) exportData.StartExport(Me.Page.Response, True) Dim dataForCSV As DataForExport = New DataForExport(ReportPropertiesTable.Instance, wc, orderBy, columns) ' Read pageSize records at a time and write out the CSV file. While (Not done) Dim recList As ArrayList = dataForCSV.GetRows(exportData.pageSize) If recList Is Nothing Then Exit While 'no more records we are done End If totalRowsReturned = recList.Count For Each rec As BaseRecord In recList For Each col As BaseColumn In dataForCSV.ColumnList If col Is Nothing Then Continue For End If If Not dataForCSV.IncludeInExport(col) Then Continue For End If val = rec.GetValue(col).ToString() exportData.WriteColumnData(val, dataForCSV.IsString(col)) Next col exportData.WriteNewRow() Next rec ' If we already are below the pageSize, then we are done. If totalRowsReturned < exportData.pageSize Then done = True End If End While exportData.FinishExport(Me.Page.Response) Else ' Create an instance of the Excel report class with the table class, where clause and order by. Dim excelReport As ExportDataToExcel = New ExportDataToExcel(ReportPropertiesTable.Instance, wc, orderBy) ' Add each of the columns in order of export. ' To customize the data type, change the second parameter of the new ExcelColumn to be ' a format string from Excel's Format Cell menu. For example "dddd, mmmm dd, yyyy h:mm AM/PM;@", "#,##0.00" If Me.Page.Response Is Nothing Then Return End If excelReport.CreateExcelBook() Dim width As Integer = 0 Dim columnCounter As Integer = 0 Dim data As DataForExport = New DataForExport(ReportPropertiesTable.Instance, wc, orderBy, Nothing) For Each col As ExcelColumn In data.ColumnList width = excelReport.GetExcelCellWidth(col) If data.IncludeInExport(col) Then excelReport.AddColumnToExcelBook(columnCounter, col.ToString(), excelReport.GetExcelDataType(col), width, excelReport.GetDisplayFormat(col)) columnCounter = columnCounter + 1 End If Next col While (Not done) Dim recList As ArrayList = data.GetRows(excelReport.pageSize) If recList Is Nothing Then Exit While 'no more records we are done End If totalRowsReturned = recList.Count For Each rec As BaseRecord In recList excelReport.AddRowToExcelBook() columnCounter = 0 For Each col As ExcelColumn In data.ColumnList If Not data.IncludeInExport(col) Then Continue For End If Dim _isExpandableNonCompositeForeignKey As Boolean = col.DisplayColumn.TableDefinition.IsExpandableNonCompositeForeignKey(col.DisplayColumn) If _isExpandableNonCompositeForeignKey AndAlso col.DisplayColumn.IsApplyDisplayAs Then val = ReportPropertiesTable.GetDFKA(rec.GetValue(col.DisplayColumn).ToString(), col.DisplayColumn, Nothing) If val Is Nothing Then val = rec.Format(col.DisplayColumn) End If Else val = excelReport.GetValueForExcelExport(col, rec) End If excelReport.AddCellToExcelRow(columnCounter, excelReport.GetExcelDataType(col), val, col.DisplayFormat) columnCounter = columnCounter + 1 Next col Next rec ' If we already are below the pageSize, then we are done. If totalRowsReturned < excelReport.pageSize Then done = True End If End While excelReport.SaveExcelBook(Me.Page.Response) End If Catch ex As Exception ' Upon error, rollback the transaction Me.Page.RollBackTransaction(sender) Me.Page.ErrorOnPage = True ' Report the error message to the end user Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message) Finally DbUtils.EndTransaction End Try End Sub ' event handler for ImageButton Public Overridable Sub ReportPropertiesPDFButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs) Try ' Enclose all database retrieval/update code within a Transaction boundary DbUtils.StartTransaction Dim report As PDFReport = New PDFReport() report.SpecificReportFileName = Page.Server.MapPath("EditPersonalId1.ReportPropertiesPDFButton.report") ' report.Title replaces the value tag of page header and footer containing ${ReportTitle} report.Title = "ReportProperties" ' If EditPersonalId1.ReportPropertiesPDFButton.report specifies a valid report template, ' AddColumn method will generate a report template. ' Each AddColumn method-call specifies a column ' The 1st parameter represents the text of the column header ' The 2nd parameter represents the horizontal alignment of the column header ' The 3rd parameter represents the text format of the column detail ' The 4th parameter represents the horizontal alignment of the column detail ' The 5th parameter represents the relative width of the column Dim rowsPerQuery As Integer = 5000 Dim recordCount As Integer = 0 report.Page = Page.GetResourceValue("Txt:Page", "Persons") report.ApplicationPath = Me.Page.MapPath(Page.Request.ApplicationPath) Dim whereClause As WhereClause = CreateWhereClause Dim orderBy As OrderBy = CreateOrderBy Dim joinFilter As BaseFilter = CreateCompoundJoinFilter() Dim pageNum As Integer = 0 Dim totalRows As Integer = ReportPropertiesTable.GetRecordCount(joinFilter,whereClause) Dim columns As ColumnList = ReportPropertiesTable.GetColumnList() Dim records As ReportPropertiesRecord() = Nothing Do records = ReportPropertiesTable.GetRecords(joinFilter,whereClause, orderBy, pageNum, rowsPerQuery) If Not (records Is Nothing) AndAlso records.Length > 0 AndAlso whereClause.RunQuery Then For Each record As ReportPropertiesRecord In records ' AddData method takes four parameters ' The 1st parameters represent the data format ' The 2nd parameters represent the data value ' The 3rd parameters represent the default alignment of column using the data ' The 4th parameters represent the maximum length of the data value being shown report.WriteRow Next pageNum = pageNum + 1 recordCount += records.Length End If Loop While Not (records Is Nothing) AndAlso recordCount < totalRows AndAlso whereClause.RunQuery report.Close BaseClasses.Utils.NetUtils.WriteResponseBinaryAttachment(Me.Page.Response, report.Title + ".pdf", report.ReportInByteArray, 0, true) Catch ex As Exception ' Upon error, rollback the transaction Me.Page.RollBackTransaction(sender) Me.Page.ErrorOnPage = True ' Report the error message to the end user Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message) Finally DbUtils.EndTransaction End Try End Sub ' event handler for ImageButton Public Overridable Sub ReportPropertiesWordButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs) Try ' Enclose all database retrieval/update code within a Transaction boundary DbUtils.StartTransaction Dim report As WordReport = New WordReport report.SpecificReportFileName = Page.Server.MapPath("EditPersonalId1.ReportPropertiesWordButton.word") ' report.Title replaces the value tag of page header and footer containing ${ReportTitle} report.Title = "ReportProperties" ' If EditPersonalId1.ReportPropertiesWordButton.report specifies a valid report template, ' AddColumn method will generate a report template. ' Each AddColumn method-call specifies a column ' The 1st parameter represents the text of the column header ' The 2nd parameter represents the horizontal alignment of the column header ' The 3rd parameter represents the text format of the column detail ' The 4th parameter represents the horizontal alignment of the column detail ' The 5th parameter represents the relative width of the column Dim whereClause As WhereClause = CreateWhereClause Dim orderBy As OrderBy = CreateOrderBy Dim joinFilter As BaseFilter = CreateCompoundJoinFilter() Dim rowsPerQuery As Integer = 5000 Dim pageNum As Integer = 0 Dim recordCount As Integer = 0 Dim totalRows As Integer = ReportPropertiesTable.GetRecordCount(joinFilter,whereClause) report.Page = Page.GetResourceValue("Txt:Page", "Persons") report.ApplicationPath = Me.Page.MapPath(Page.Request.ApplicationPath) Dim columns As ColumnList = ReportPropertiesTable.GetColumnList() Dim records As ReportPropertiesRecord() = Nothing Do records = ReportPropertiesTable.GetRecords(joinFilter,whereClause, orderBy, pageNum, rowsPerQuery) If Not (records Is Nothing) AndAlso records.Length > 0 AndAlso whereClause.RunQuery Then For Each record As ReportPropertiesRecord In records ' AddData method takes four parameters ' The 1st parameters represent the data format ' The 2nd parameters represent the data value ' The 3rd parameters represent the default alignment of column using the data ' The 4th parameters represent the maximum length of the data value being shown report.WriteRow Next pageNum = pageNum + 1 recordCount += records.Length End If Loop While Not (records Is Nothing) AndAlso recordCount < totalRows AndAlso whereClause.RunQuery report.save BaseClasses.Utils.NetUtils.WriteResponseBinaryAttachment(Me.Page.Response, report.Title + ".doc", report.ReportInByteArray, 0, true) Catch ex As Exception ' Upon error, rollback the transaction Me.Page.RollBackTransaction(sender) Me.Page.ErrorOnPage = True ' Report the error message to the end user Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message) Finally DbUtils.EndTransaction End Try End Sub ' 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 = ReportPropertiesTable.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 ReportPropertiesRecord = Nothing Public Property DataSource() As ReportPropertiesRecord () Get Return Me._DataSource End Get Set(ByVal value() As ReportPropertiesRecord) Me._DataSource = value End Set End Property #Region "Helper Properties" Public ReadOnly Property ReportPropertiesExportExcelButton() As System.Web.UI.WebControls.ImageButton Get Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ReportPropertiesExportExcelButton"), System.Web.UI.WebControls.ImageButton) End Get End Property Public ReadOnly Property ReportPropertiesPDFButton() As System.Web.UI.WebControls.ImageButton Get Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ReportPropertiesPDFButton"), System.Web.UI.WebControls.ImageButton) End Get End Property Public ReadOnly Property ReportPropertiesTableControlCollapsibleRegion() As System.Web.UI.WebControls.Panel Get Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ReportPropertiesTableControlCollapsibleRegion"), System.Web.UI.WebControls.Panel) End Get End Property Public ReadOnly Property ReportPropertiesWordButton() As System.Web.UI.WebControls.ImageButton Get Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ReportPropertiesWordButton"), System.Web.UI.WebControls.ImageButton) End Get End Property #End Region #Region "Helper Functions" Public Overrides Overloads Function ModifyRedirectUrl(url As String, arg As String, ByVal bEncrypt As Boolean) As String Return Me.Page.EvaluateExpressions(url, arg, bEncrypt, Me) End Function Public Overrides Overloads Function EvaluateExpressions(url As String, arg As String, ByVal bEncrypt As Boolean) As String Dim needToProcess As Boolean = AreAnyUrlParametersForMe(url, arg) If (needToProcess) Then Dim recCtl As ReportPropertiesTableControlRow = 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 ReportPropertiesRecord = 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 ReportPropertiesTableControlRow Return Nothing End Function Public Overridable Function GetSelectedRecordControls() As ReportPropertiesTableControlRow() Return DirectCast((new ArrayList()).ToArray(GetType(ReportPropertiesTableControlRow)), ReportPropertiesTableControlRow()) End Function Public Overridable Sub DeleteSelectedRecords(ByVal deferDeletion As Boolean) Dim recList() As ReportPropertiesTableControlRow = Me.GetSelectedRecordControls() If recList.Length = 0 Then ' Localization. Throw New Exception(Page.GetResourceValue("Err:NoRecSelected", "Persons")) End If Dim recCtl As ReportPropertiesTableControlRow 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 ReportPropertiesTableControlRow() Dim recList As ArrayList = New ArrayList() Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("ReportPropertiesTableControlRepeater"), 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 ReportPropertiesTableControlRow = DirectCast(repItem.FindControl("ReportPropertiesTableControlRow"), ReportPropertiesTableControlRow) recList.Add(recControl) Next Return DirectCast(recList.ToArray(GetType(ReportPropertiesTableControlRow)), ReportPropertiesTableControlRow()) 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 EditPersonalId1 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 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 yyyy") 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 yyyy") 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 yyyy") 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 yyyy") 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, 250," _ & " 200, 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 yyyy") 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 yyyy") 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) 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 Return wc End Function Protected Overridable Function CreateQueryClause() As WhereClause ' Create a where clause for the Static clause defined at design time. Dim filter As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing) Dim whereClause As WhereClause = New WhereClause() filter.AddFilter(New BaseClasses.Data.SignedInUserFilter(BaseClasses.Data.BaseTable.CreateInstance("Persons.Business.PersonalIdTable, App_Code").TableDefinition.ColumnList.GetByUniqueName("PersonalId_.PersonalId"), New BaseClasses.Data.IdentifierAliasInfo("PersonalId_", Nothing), BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False)) whereClause.AddFilter(filter, CompoundFilter.CompoundingOperators.And_Operator) Return whereClause 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