3171 lines
No EOL
137 KiB
VB.net
3171 lines
No EOL
137 KiB
VB.net
|
|
' This file implements the TableControl, TableControlRow, and RecordControl classes for the
|
|
' EditPersonalExtraSalaryTable.aspx page. The Row or RecordControl classes are the
|
|
' ideal place to add code customizations. For example, you can override the LoadData,
|
|
' CreateWhereClause, DataBind, SaveData, GetUIData, and Validate methods.
|
|
|
|
#Region "Imports statements"
|
|
|
|
Option Strict On
|
|
Imports Microsoft.VisualBasic
|
|
Imports BaseClasses.Web.UI.WebControls
|
|
Imports System
|
|
Imports System.Collections
|
|
Imports System.Collections.Generic
|
|
|
|
Imports System.Web
|
|
Imports System.Web.UI
|
|
Imports System.Web.UI.WebControls
|
|
Imports BaseClasses
|
|
Imports BaseClasses.Data
|
|
Imports BaseClasses.Utils
|
|
Imports ReportTools.ReportCreator
|
|
Imports ReportTools.Shared
|
|
|
|
|
|
|
|
Imports Persons.Business
|
|
Imports Persons.Data
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
Namespace Persons.UI.Controls.EditPersonalExtraSalaryTable
|
|
|
|
#Region "Section 1: Place your customizations here."
|
|
|
|
|
|
Public Class PersonalExtraSalaryTableControlRow
|
|
Inherits BasePersonalExtraSalaryTableControlRow
|
|
' The BasePersonalExtraSalaryTableControlRow implements code for a ROW within the
|
|
' the PersonalExtraSalaryTableControl table. The BasePersonalExtraSalaryTableControlRow implements the DataBind and SaveData methods.
|
|
' The loading of data is actually performed by the LoadData method in the base class of PersonalExtraSalaryTableControl.
|
|
|
|
' This is the ideal place to add your code customizations. For example, you can override the DataBind,
|
|
' SaveData, GetUIData, and Validate methods.
|
|
Public Overrides Sub GetUIData()
|
|
|
|
' Call MyBase.GetUIData
|
|
MyBase.GetUIData()
|
|
|
|
' Get PersonalDD Record
|
|
Dim myRec As PersonalExtraSalaryRecord = Me.GetRecord
|
|
|
|
' Set PersonalId field value to new value string
|
|
myRec.PersonalId = Utils.SecurityControls.GetCurrentUserID
|
|
|
|
End Sub
|
|
|
|
|
|
End Class
|
|
|
|
|
|
|
|
Public Class PersonalExtraSalaryTableControl
|
|
Inherits BasePersonalExtraSalaryTableControl
|
|
|
|
' The BasePersonalExtraSalaryTableControl class implements the LoadData, DataBind, CreateWhereClause
|
|
' and other methods to load and display the data in a table control.
|
|
|
|
' This is the ideal place to add your code customizations. You can override the LoadData and CreateWhereClause,
|
|
' The PersonalExtraSalaryTableControlRow class offers another place where you can customize
|
|
' the DataBind, GetUIData, SaveData and Validate methods specific to each row displayed on the table.
|
|
|
|
End Class
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
#Region "Section 2: Do not modify this section."
|
|
|
|
|
|
' Base class for the PersonalExtraSalaryTableControlRow control on the EditPersonalExtraSalaryTable page.
|
|
' Do not modify this class. Instead override any method in PersonalExtraSalaryTableControlRow.
|
|
Public Class BasePersonalExtraSalaryTableControlRow
|
|
Inherits Persons.UI.BaseApplicationRecordControl
|
|
|
|
' To customize, override this method in PersonalExtraSalaryTableControlRow.
|
|
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 PersonalExtraSalaryTableControlRow.
|
|
Protected Overridable Sub Control_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
|
|
|
'Call LoadFocusScripts from repeater so that onfocus attribute could be added to elements
|
|
Me.Page.LoadFocusScripts(Me)
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalExtraSalaryRowDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteRecordConfirm", "Persons") & "'));")
|
|
|
|
|
|
' Register the event handlers.
|
|
|
|
AddHandler Me.PersonalExtraSalaryRowDeleteButton.Click, AddressOf PersonalExtraSalaryRowDeleteButton_Click
|
|
|
|
AddHandler Me.ExtraSalaryId.SelectedIndexChanged, AddressOf ExtraSalaryId_SelectedIndexChanged
|
|
|
|
AddHandler Me.PersonalId.SelectedIndexChanged, AddressOf PersonalId_SelectedIndexChanged
|
|
|
|
AddHandler Me.Amout.TextChanged, AddressOf Amout_TextChanged
|
|
|
|
AddHandler Me.Ref1.TextChanged, AddressOf Ref1_TextChanged
|
|
|
|
AddHandler Me.RefDate.TextChanged, AddressOf RefDate_TextChanged
|
|
|
|
AddHandler Me.StartDate.TextChanged, AddressOf StartDate_TextChanged
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Load the data from the database into the DataSource PersonalExtraSalary 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 = PersonalExtraSalaryTable.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 BasePersonalExtraSalaryTableControl when the data for the entire
|
|
' table is loaded.
|
|
|
|
Me.DataSource = New PersonalExtraSalaryRecord()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
' Populate the UI controls using the DataSource. To customize, override this method in PersonalExtraSalaryTableControlRow.
|
|
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
|
|
|
|
SetAmout()
|
|
SetExtraSalaryId()
|
|
|
|
|
|
SetPersonalId()
|
|
SetRef1()
|
|
SetRefDate()
|
|
SetStartDate()
|
|
|
|
|
|
Me.IsNewRecord = True
|
|
|
|
If Me.DataSource.IsCreated Then
|
|
Me.IsNewRecord = False
|
|
|
|
Me.RecordUniqueId = Me.DataSource.GetID.ToXmlString()
|
|
End If
|
|
|
|
' Now load data for each record and table child UI controls.
|
|
' Ordering is important because child controls get
|
|
' their parent ids from their parent UI controls.
|
|
Dim shouldResetControl As Boolean = False
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub SetAmout()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Amout.ID) Then
|
|
|
|
Me.Amout.Text = Me.PreviousUIData(Me.Amout.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Amout TextBox on the webpage with value from the
|
|
' PersonalExtraSalary database record.
|
|
|
|
' Me.DataSource is the PersonalExtraSalary record retrieved from the database.
|
|
' Me.Amout is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetAmout()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.AmoutSpecified Then
|
|
|
|
' If the Amout is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalExtraSalaryTable.Amout)
|
|
|
|
Me.Amout.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Amout is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Amout.Text = PersonalExtraSalaryTable.Amout.Format(PersonalExtraSalaryTable.Amout.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetExtraSalaryId()
|
|
|
|
' If selection was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.ExtraSalaryId.ID) Then
|
|
If Me.PreviousUIData(Me.ExtraSalaryId.ID) Is Nothing
|
|
Me.PopulateExtraSalaryIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateExtraSalaryIdDropDownList(Me.PreviousUIData(Me.ExtraSalaryId.ID).ToString(), 100)
|
|
End If
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the ExtraSalaryId DropDownList on the webpage with value from the
|
|
' PersonalExtraSalary database record.
|
|
|
|
' Me.DataSource is the PersonalExtraSalary record retrieved from the database.
|
|
' Me.ExtraSalaryId is the ASP:DropDownList on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetExtraSalaryId()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.ExtraSalaryIdSpecified Then
|
|
|
|
' If the ExtraSalaryId is non-NULL, then format the value.
|
|
' The Format method will return the Display Foreign Key As (DFKA) value
|
|
Me.PopulateExtraSalaryIdDropDownList(Me.DataSource.ExtraSalaryId.ToString(), 100)
|
|
|
|
Else
|
|
|
|
' ExtraSalaryId 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.PopulateExtraSalaryIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulateExtraSalaryIdDropDownList(PersonalExtraSalaryTable.ExtraSalaryId.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalId()
|
|
|
|
' If selection was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.PersonalId.ID) Then
|
|
If Me.PreviousUIData(Me.PersonalId.ID) Is Nothing
|
|
Me.PopulatePersonalIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulatePersonalIdDropDownList(Me.PreviousUIData(Me.PersonalId.ID).ToString(), 100)
|
|
End If
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the PersonalId DropDownList on the webpage with value from the
|
|
' PersonalExtraSalary database record.
|
|
|
|
' Me.DataSource is the PersonalExtraSalary record retrieved from the database.
|
|
' Me.PersonalId is the ASP:DropDownList 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 return the Display Foreign Key As (DFKA) value
|
|
Me.PopulatePersonalIdDropDownList(Me.DataSource.PersonalId, 100)
|
|
|
|
Else
|
|
|
|
' PersonalId 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.PopulatePersonalIdDropDownList(Nothing, 100)
|
|
Else
|
|
Me.PopulatePersonalIdDropDownList(PersonalExtraSalaryTable.PersonalId.DefaultValue, 100)
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRef1()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.Ref1.ID) Then
|
|
|
|
Me.Ref1.Text = Me.PreviousUIData(Me.Ref1.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the Ref TextBox on the webpage with value from the
|
|
' PersonalExtraSalary database record.
|
|
|
|
' Me.DataSource is the PersonalExtraSalary record retrieved from the database.
|
|
' Me.Ref1 is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRef1()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.Ref0Specified Then
|
|
|
|
' If the Ref is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalExtraSalaryTable.Ref0)
|
|
|
|
Me.Ref1.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' Ref is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.Ref1.Text = PersonalExtraSalaryTable.Ref0.Format(PersonalExtraSalaryTable.Ref0.DefaultValue)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRefDate()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.RefDate.ID) Then
|
|
|
|
Me.RefDate.Text = Me.PreviousUIData(Me.RefDate.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the RefDate TextBox on the webpage with value from the
|
|
' PersonalExtraSalary database record.
|
|
|
|
' Me.DataSource is the PersonalExtraSalary record retrieved from the database.
|
|
' Me.RefDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetRefDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.RefDateSpecified Then
|
|
|
|
' If the RefDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalExtraSalaryTable.RefDate, "d MMM yyyy")
|
|
|
|
Me.RefDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' RefDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.RefDate.Text = PersonalExtraSalaryTable.RefDate.Format(PersonalExtraSalaryTable.RefDate.DefaultValue, "d MMM yyyy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetStartDate()
|
|
|
|
' If data was retrieved from UI previously, restore it
|
|
If Me.PreviousUIData.ContainsKey(Me.StartDate.ID) Then
|
|
|
|
Me.StartDate.Text = Me.PreviousUIData(Me.StartDate.ID).ToString()
|
|
|
|
Return
|
|
End If
|
|
|
|
|
|
' Set the StartDate TextBox on the webpage with value from the
|
|
' PersonalExtraSalary database record.
|
|
|
|
' Me.DataSource is the PersonalExtraSalary record retrieved from the database.
|
|
' Me.StartDate is the ASP:TextBox on the webpage.
|
|
|
|
' You can modify this method directly, or replace it with a call to
|
|
' MyBase.SetStartDate()
|
|
' and add your own code before or after the call to the MyBase function.
|
|
|
|
|
|
|
|
If Me.DataSource IsNot Nothing AndAlso Me.DataSource.StartDateSpecified Then
|
|
|
|
' If the StartDate is non-NULL, then format the value.
|
|
|
|
' The Format method will use the Display Format
|
|
Dim formattedValue As String = Me.DataSource.Format(PersonalExtraSalaryTable.StartDate, "d MMM yyyy")
|
|
|
|
Me.StartDate.Text = formattedValue
|
|
|
|
Else
|
|
|
|
' StartDate is NULL in the database, so use the Default Value.
|
|
' Default Value could also be NULL.
|
|
|
|
Me.StartDate.Text = PersonalExtraSalaryTable.StartDate.Format(PersonalExtraSalaryTable.StartDate.DefaultValue, "d MMM yyyy")
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
Public EvaluateFormulaDelegate As BaseClasses.Data.DataSource.EvaluateFormulaDelegate = New BaseClasses.Data.DataSource.EvaluateFormulaDelegate(AddressOf Me.EvaluateFormula)
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord, ByVal format As String, ByVal variables As System.Collections.Generic.IDictionary(Of String, Object), ByVal includeDS As Boolean, ByVal e As FormulaEvaluator) As String
|
|
If e Is Nothing Then
|
|
e = New FormulaEvaluator()
|
|
End If
|
|
|
|
e.Variables.Clear()
|
|
|
|
|
|
' add variables for formula evaluation
|
|
If variables IsNot Nothing Then
|
|
Dim enumerator As System.Collections.Generic.IEnumerator(Of System.Collections.Generic.KeyValuePair(Of String, Object)) = variables.GetEnumerator()
|
|
While enumerator.MoveNext()
|
|
e.Variables.Add(enumerator.Current.Key, enumerator.Current.Value)
|
|
End While
|
|
End If
|
|
|
|
If includeDS
|
|
|
|
End IF
|
|
|
|
|
|
' Other variables referred to in the formula are expected to be
|
|
' properties of the DataSource. For example, referring to
|
|
' UnitPrice as a variable will refer to DataSource.UnitPrice
|
|
If dataSourceForEvaluate Is Nothing Then
|
|
|
|
e.DataSource = Me.DataSource
|
|
|
|
Else
|
|
e.DataSource = dataSourceForEvaluate
|
|
End If
|
|
|
|
' Define the calling control. This is used to add other
|
|
' related table and record controls as variables.
|
|
e.CallingControl = Me
|
|
|
|
Dim resultObj As Object = e.Evaluate(formula)
|
|
If resultObj Is Nothing Then
|
|
Return ""
|
|
End If
|
|
|
|
If Not String.IsNullOrEmpty(format) AndAlso (String.IsNullOrEmpty(formula) OrElse formula.IndexOf("Format(") < 0) Then
|
|
Return FormulaUtils.Format(resultObj, format)
|
|
Else
|
|
Return resultObj.ToString()
|
|
End If
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate as BaseClasses.Data.BaseRecord, ByVal format as String, ByVal variables As System.Collections.Generic.IDictionary(Of String, Object), ByVal includeDS As Boolean) As String
|
|
Return EvaluateFormula(formula, dataSourceForEvaluate, format,variables ,includeDS, Nothing)
|
|
End Function
|
|
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord, ByVal format As String, ByVal variables As System.Collections.Generic.IDictionary(Of String, Object)) As String
|
|
Return EvaluateFormula(formula, dataSourceForEvaluate, format, variables ,True, Nothing)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord, ByVal format As String) As String
|
|
Return Me.EvaluateFormula(formula, dataSourceForEvaluate, format, Nothing, True, Nothing)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord, ByVal variables As System.Collections.Generic.IDictionary(Of String, Object), ByVal e as FormulaEvaluator) As String
|
|
Return Me.EvaluateFormula(formula, dataSourceForEvaluate, Nothing, variables, True, e)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord) As String
|
|
Return Me.EvaluateFormula(formula, dataSourceForEvaluate, Nothing, Nothing, True, Nothing)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal includeDS as Boolean) As String
|
|
Return Me.EvaluateFormula(formula, Nothing, Nothing, Nothing, includeDS, Nothing)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String) As String
|
|
Return Me.EvaluateFormula(formula, Nothing, Nothing, Nothing, True, Nothing)
|
|
End Function
|
|
|
|
|
|
Public Overridable Sub RegisterPostback()
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
' To customize, override this method in PersonalExtraSalaryTableControlRow.
|
|
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, "PersonalExtraSalaryTableControl"), PersonalExtraSalaryTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalExtraSalaryTableControl"), PersonalExtraSalaryTableControl).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 PersonalExtraSalaryTableControlRow.
|
|
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.
|
|
|
|
GetAmout()
|
|
GetExtraSalaryId()
|
|
GetPersonalId()
|
|
GetRef1()
|
|
GetRefDate()
|
|
GetStartDate()
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub GetAmout()
|
|
|
|
' Retrieve the value entered by the user on the Amout ASP:TextBox, and
|
|
' save it into the Amout field in DataSource PersonalExtraSalary record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Amout.Text, PersonalExtraSalaryTable.Amout)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetExtraSalaryId()
|
|
|
|
' Retrieve the value entered by the user on the ExtraSalaryId ASP:DropDownList, and
|
|
' save it into the ExtraSalaryId field in DataSource PersonalExtraSalary record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.ExtraSalaryId), PersonalExtraSalaryTable.ExtraSalaryId)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetPersonalId()
|
|
|
|
' Retrieve the value entered by the user on the PersonalId ASP:DropDownList, and
|
|
' save it into the PersonalId field in DataSource PersonalExtraSalary record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
Me.DataSource.Parse(GetValueSelectedPageRequest(Me.PersonalId), PersonalExtraSalaryTable.PersonalId)
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRef1()
|
|
|
|
' Retrieve the value entered by the user on the Ref ASP:TextBox, and
|
|
' save it into the Ref field in DataSource PersonalExtraSalary record.
|
|
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.Ref1.Text, PersonalExtraSalaryTable.Ref0)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetRefDate()
|
|
|
|
' Retrieve the value entered by the user on the RefDate ASP:TextBox, and
|
|
' save it into the RefDate field in DataSource PersonalExtraSalary record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.RefDate.Text, PersonalExtraSalaryTable.RefDate)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub GetStartDate()
|
|
|
|
' Retrieve the value entered by the user on the StartDate ASP:TextBox, and
|
|
' save it into the StartDate field in DataSource PersonalExtraSalary record.
|
|
' Parse will also validate the date to ensure it is of the proper format
|
|
' and a valid date. The format is verified based on the current culture
|
|
' settings including the order of month, day and year and the separator character.
|
|
' Parse throws an exception if the date is invalid.
|
|
' Custom validation should be performed in Validate, not here.
|
|
|
|
'Save the value to data source
|
|
Me.DataSource.Parse(Me.StartDate.Text, PersonalExtraSalaryTable.StartDate)
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
' To customize, override this method in PersonalExtraSalaryTableControlRow.
|
|
|
|
Public Overridable Function CreateWhereClause() As WhereClause
|
|
|
|
Return Nothing
|
|
|
|
End Function
|
|
|
|
|
|
|
|
' To customize, override this method in PersonalExtraSalaryTableControlRow.
|
|
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)
|
|
PersonalExtraSalaryTable.DeleteRecord(pkValue)
|
|
|
|
DirectCast(GetParentControlObject(Me, "PersonalExtraSalaryTableControl"), PersonalExtraSalaryTableControl).DataChanged = True
|
|
DirectCast(GetParentControlObject(Me, "PersonalExtraSalaryTableControl"), PersonalExtraSalaryTableControl).ResetData = True
|
|
End Sub
|
|
|
|
Protected Overridable Sub Control_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
|
|
' PreRender event is raised just before page is being displayed.
|
|
Try
|
|
DbUtils.StartTransaction()
|
|
Me.RegisterPostback()
|
|
|
|
If Not Me.Page.ErrorOnPage AndAlso (Me.Page.IsPageRefresh OrElse Me.DataChanged OrElse Me.ResetData) Then
|
|
|
|
|
|
' Re-load the data and update the web page if necessary.
|
|
' This is typically done during a postback (filter, search button, sort, pagination button).
|
|
' In each of the other click handlers, simply set DataChanged to True to reload the data.
|
|
Me.LoadData()
|
|
Me.DataBind()
|
|
End If
|
|
|
|
|
|
Catch ex As Exception
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
Finally
|
|
DbUtils.EndTransaction()
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub SaveControlsToSession()
|
|
MyBase.SaveControlsToSession()
|
|
|
|
|
|
'Save pagination state to session.
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Protected Overrides Sub ClearControlsFromSession()
|
|
MyBase.ClearControlsFromSession()
|
|
|
|
|
|
|
|
' Clear pagination state from session.
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub LoadViewState(ByVal savedState As Object)
|
|
MyBase.LoadViewState(savedState)
|
|
Dim isNewRecord As String = CType(ViewState("IsNewRecord"), String)
|
|
If Not isNewRecord Is Nothing AndAlso isNewRecord.Trim <> "" Then
|
|
Me.IsNewRecord = Boolean.Parse(isNewRecord)
|
|
End If
|
|
|
|
Dim myCheckSum As String = CType(ViewState("CheckSum"), String)
|
|
If Not myCheckSum Is Nothing AndAlso myCheckSum.Trim <> "" Then
|
|
Me.CheckSum = myCheckSum
|
|
End If
|
|
|
|
|
|
' Load view state for pagination control.
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Function SaveViewState() As Object
|
|
ViewState("IsNewRecord") = Me.IsNewRecord.ToString()
|
|
ViewState("CheckSum") = Me.CheckSum
|
|
|
|
|
|
' Load view state for pagination control.
|
|
|
|
Return MyBase.SaveViewState()
|
|
End Function
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_ExtraSalaryIdDropDownList() 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 ExTraSalary table.
|
|
' Examples:
|
|
' wc.iAND(ExTraSalaryTable.FullName, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(ExTraSalaryTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
|
|
Public Overridable Function CreateWhereClause_PersonalIdDropDownList() 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 PersonalId table.
|
|
' Examples:
|
|
' wc.iAND(PersonalIdTable.PersonalName, BaseFilter.ComparisonOperator.EqualsTo, "XYZ")
|
|
' wc.iAND(PersonalIdTable.Active, BaseFilter.ComparisonOperator.EqualsTo, "1")
|
|
|
|
Dim wc As WhereClause = New WhereClause()
|
|
Return wc
|
|
|
|
End Function
|
|
|
|
|
|
' Fill the ExtraSalaryId list.
|
|
Protected Overridable Sub PopulateExtraSalaryIdDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.ExtraSalaryId.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.ExtraSalaryId.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_ExtraSalaryIdDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_ExtraSalaryIdDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(ExTraSalaryTable.FullName, 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 ExTraSalaryRecord = 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 = ExTraSalaryTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
For each itemValue As ExTraSalaryRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.ExtraSalaryIdSpecified Then
|
|
cvalue = itemValue.ExtraSalaryId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.ExtraSalaryId.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalExtraSalaryTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalExtraSalaryTable.ExtraSalaryId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalExtraSalaryTable.ExtraSalaryId.IsApplyDisplayAs Then
|
|
fvalue = PersonalExtraSalaryTable.GetDFKA(itemValue, PersonalExtraSalaryTable.ExtraSalaryId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(ExTraSalaryTable.FullName)
|
|
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.ExtraSalaryId.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.ExtraSalaryId.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.ExtraSalaryId, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.ExtraSalaryId, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with ExTraSalary.ExtraSalaryId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(ExTraSalaryTable.ExtraSalaryId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As ExTraSalaryRecord = ExTraSalaryTable.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 ExTraSalaryRecord = DirectCast(rc(0), ExTraSalaryRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.ExtraSalaryIdSpecified Then
|
|
cvalue = itemValue.ExtraSalaryId.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalExtraSalaryTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalExtraSalaryTable.ExtraSalaryId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalExtraSalaryTable.ExtraSalaryId.IsApplyDisplayAs Then
|
|
fvalue = PersonalExtraSalaryTable.GetDFKA(itemValue, PersonalExtraSalaryTable.ExtraSalaryId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(ExTraSalaryTable.FullName)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.ExtraSalaryId.Items.Add(newItem)
|
|
SetSelectedValue(Me.ExtraSalaryId, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' Fill the PersonalId list.
|
|
Protected Overridable Sub PopulatePersonalIdDropDownList( _
|
|
ByVal selectedValue As String, _
|
|
ByVal maxItems As Integer)
|
|
|
|
Me.PersonalId.Items.Clear()
|
|
|
|
|
|
' 1. Setup the static list items
|
|
|
|
' Add the Please Select item.
|
|
Me.PersonalId.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_PersonalIdDropDownList function.
|
|
' It is better to customize the where clause there.
|
|
|
|
Dim wc As WhereClause = CreateWhereClause_PersonalIdDropDownList()
|
|
' Create the ORDER BY clause to sort based on the displayed value.
|
|
|
|
|
|
Dim orderBy As OrderBy = New OrderBy(false, false)
|
|
orderBy.Add(PersonalIdTable.PersonalName, 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 PersonalIdRecord = 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 = PersonalIdTable.GetRecords(wc, orderBy, pageNum, maxItems)
|
|
For each itemValue As PersonalIdRecord In itemValues
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.PersonalIdSpecified Then
|
|
cvalue = itemValue.PersonalId.ToString()
|
|
|
|
If counter < maxItems AndAlso Me.PersonalId.Items.FindByValue(cvalue) Is Nothing Then
|
|
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalExtraSalaryTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalExtraSalaryTable.PersonalId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalExtraSalaryTable.PersonalId.IsApplyDisplayAs Then
|
|
fvalue = PersonalExtraSalaryTable.GetDFKA(itemValue, PersonalExtraSalaryTable.PersonalId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(PersonalIdTable.PersonalName)
|
|
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.PersonalId.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.PersonalId.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.PersonalId, selectedValue) AndAlso _
|
|
Not SetSelectedDisplayText(Me.PersonalId, selectedValue)Then
|
|
|
|
' construct a whereclause to query a record with PersonalId.PersonalId = selectedValue
|
|
Dim filter2 As CompoundFilter = New CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, Nothing)
|
|
Dim whereClause2 As WhereClause = New WhereClause()
|
|
filter2.AddFilter(New BaseClasses.Data.ColumnValueFilter(PersonalIdTable.PersonalId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Try
|
|
' Execute the query
|
|
Dim rc() As PersonalIdRecord = PersonalIdTable.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 PersonalIdRecord = DirectCast(rc(0), PersonalIdRecord)
|
|
' Create the item and add to the list.
|
|
Dim cvalue As String = Nothing
|
|
Dim fvalue As String = Nothing
|
|
If itemValue.PersonalIdSpecified Then
|
|
cvalue = itemValue.PersonalId.ToString()
|
|
Dim _isExpandableNonCompositeForeignKey As Boolean = PersonalExtraSalaryTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(PersonalExtraSalaryTable.PersonalId)
|
|
If _isExpandableNonCompositeForeignKey AndAlso PersonalExtraSalaryTable.PersonalId.IsApplyDisplayAs Then
|
|
fvalue = PersonalExtraSalaryTable.GetDFKA(itemValue, PersonalExtraSalaryTable.PersonalId)
|
|
End If
|
|
If (Not _isExpandableNonCompositeForeignKey) Or (String.IsNullOrEmpty(fvalue)) Then
|
|
fvalue = itemValue.Format(PersonalIdTable.PersonalName)
|
|
End If
|
|
|
|
If fvalue Is Nothing OrElse fvalue.Trim() = "" Then fvalue = cvalue
|
|
Dim newItem As New ListItem(fvalue, cvalue)
|
|
Me.PersonalId.Items.Add(newItem)
|
|
SetSelectedValue(Me.PersonalId, selectedValue)
|
|
End If
|
|
End If
|
|
Catch
|
|
End Try
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonalExtraSalaryRowDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Dim tc As PersonalExtraSalaryTableControl = DirectCast(GetParentControlObject(Me, "PersonalExtraSalaryTableControl"), PersonalExtraSalaryTableControl)
|
|
If Not (IsNothing(tc)) Then
|
|
If Not Me.IsNewRecord Then
|
|
tc.AddToDeletedRecordIds(DirectCast(Me, PersonalExtraSalaryTableControlRow))
|
|
End If
|
|
Me.Visible = False
|
|
tc.SetFormulaControls()
|
|
End If
|
|
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
' Upon error, rollback the transaction
|
|
Me.Page.RollBackTransaction(sender)
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub ExtraSalaryId_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()(ExtraSalaryId.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(ExtraSalaryId.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.ExtraSalaryId.Items.Add(New ListItem(displayText, val))
|
|
Me.ExtraSalaryId.SelectedIndex = Me.ExtraSalaryId.Items.Count - 1
|
|
Me.Page.Session.Remove(ExtraSalaryId.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(ExtraSalaryId.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub PersonalId_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()(PersonalId.ClientID & "_SelectedValue"), String)
|
|
Dim displayText As String = CType(Me.Page.Session()(PersonalId.ClientID & "_SelectedDisplayText"), String)
|
|
If displayText <> "" AndAlso val <> "" Then
|
|
Me.PersonalId.Items.Add(New ListItem(displayText, val))
|
|
Me.PersonalId.SelectedIndex = Me.PersonalId.Items.Count - 1
|
|
Me.Page.Session.Remove(PersonalId.ClientID & "_SelectedValue")
|
|
Me.Page.Session.Remove(PersonalId.ClientID & "_SelectedDisplayText")
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Amout_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub Ref1_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub RefDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
Protected Overridable Sub StartDate_TextChanged(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
End Sub
|
|
|
|
|
|
Private _PreviousUIData As New Hashtable
|
|
Public Overridable Property PreviousUIData() As Hashtable
|
|
Get
|
|
Return _PreviousUIData
|
|
End Get
|
|
Set(ByVal value As Hashtable)
|
|
_PreviousUIData = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _IsNewRecord As Boolean = True
|
|
Public Overridable Property IsNewRecord() As Boolean
|
|
Get
|
|
Return Me._IsNewRecord
|
|
End Get
|
|
Set(ByVal value As Boolean)
|
|
Me._IsNewRecord = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataChanged As Boolean = False
|
|
Public Overridable Property DataChanged() As Boolean
|
|
Get
|
|
Return Me._DataChanged
|
|
End Get
|
|
Set(ByVal Value As Boolean)
|
|
Me._DataChanged = Value
|
|
End Set
|
|
End Property
|
|
|
|
Private _ResetData As Boolean = False
|
|
Public Overridable Property ResetData() As Boolean
|
|
Get
|
|
Return Me._ResetData
|
|
End Get
|
|
Set(ByVal Value As Boolean)
|
|
Me._ResetData = Value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property RecordUniqueId() As String
|
|
Get
|
|
Return CType(Me.ViewState("BasePersonalExtraSalaryTableControlRow_Rec"), String)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me.ViewState("BasePersonalExtraSalaryTableControlRow_Rec") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DataSource As PersonalExtraSalaryRecord
|
|
Public Property DataSource() As PersonalExtraSalaryRecord
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
|
|
Set(ByVal value As PersonalExtraSalaryRecord)
|
|
|
|
Me._DataSource = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
Private _checkSum As String
|
|
Public Overridable Property CheckSum() As String
|
|
Get
|
|
Return Me._checkSum
|
|
End Get
|
|
Set(ByVal value As String)
|
|
Me._checkSum = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _TotalPages As Integer
|
|
Public Property TotalPages() As Integer
|
|
Get
|
|
Return Me._TotalPages
|
|
End Get
|
|
Set(ByVal value As Integer)
|
|
Me._TotalPages = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _PageIndex As Integer
|
|
Public Property PageIndex() As Integer
|
|
Get
|
|
' Return the PageIndex
|
|
Return Me._PageIndex
|
|
End Get
|
|
Set(ByVal value As Integer)
|
|
Me._PageIndex = value
|
|
End Set
|
|
End Property
|
|
|
|
Private _DisplayLastPage As Boolean
|
|
Public Property DisplayLastPage() As Boolean
|
|
Get
|
|
Return Me._DisplayLastPage
|
|
End Get
|
|
Set(ByVal value As Boolean)
|
|
Me._DisplayLastPage = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
#Region "Helper Properties"
|
|
|
|
Public ReadOnly Property Amout() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Amout"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ExtraSalaryId() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ExtraSalaryId"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtraSalaryRecordRowSelection() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtraSalaryRecordRowSelection"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtraSalaryRowDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtraSalaryRowDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalId() As System.Web.UI.WebControls.DropDownList
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalId"), System.Web.UI.WebControls.DropDownList)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Ref1() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "Ref1"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RefDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RefDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property StartDate() As System.Web.UI.WebControls.TextBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "StartDate"), System.Web.UI.WebControls.TextBox)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
#Region "Helper Functions"
|
|
|
|
Public Overrides Overloads Function ModifyRedirectUrl(ByVal url As String, ByVal arg As String, ByVal bEncrypt As Boolean) As String
|
|
Return Me.Page.EvaluateExpressions(url, arg, bEncrypt, Me)
|
|
End Function
|
|
|
|
Public Overrides Overloads Function EvaluateExpressions(ByVal url As String, ByVal arg As String, ByVal bEncrypt As Boolean) As String
|
|
|
|
Dim rec As PersonalExtraSalaryRecord = 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 PersonalExtraSalaryRecord
|
|
If Not Me.DataSource Is Nothing Then
|
|
Return Me.DataSource
|
|
End If
|
|
|
|
If Not Me.RecordUniqueId Is Nothing Then
|
|
|
|
Return PersonalExtraSalaryTable.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 PersonalExtraSalaryTableControl control on the EditPersonalExtraSalaryTable page.
|
|
' Do not modify this class. Instead override any method in PersonalExtraSalaryTableControl.
|
|
Public Class BasePersonalExtraSalaryTableControl
|
|
Inherits Persons.UI.BaseApplicationTableControl
|
|
|
|
|
|
|
|
Protected Overridable Sub Control_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Init
|
|
|
|
|
|
|
|
' Setup the filter and search events.
|
|
|
|
|
|
|
|
' Control Initializations.
|
|
' Initialize the table's current sort order.
|
|
|
|
If Me.InSession(Me, "Order_By") Then
|
|
Me.CurrentSortOrder = OrderBy.FromXmlString(Me.GetFromSession(Me, "Order_By", Nothing))
|
|
Else
|
|
Me.CurrentSortOrder = New OrderBy(True, False)
|
|
|
|
Me.CurrentSortOrder.Add(PersonalExtraSalaryTable.StartDate, OrderByItem.OrderDir.Asc)
|
|
|
|
End If
|
|
|
|
|
|
|
|
' Setup default pagination settings.
|
|
|
|
Me.PageSize = CInt(Me.GetFromSession(Me, "Page_Size", "10"))
|
|
Me.PageIndex = CInt(Me.GetFromSession(Me, "Page_Index", "0"))
|
|
|
|
|
|
|
|
Me.ClearControlsFromSession()
|
|
End Sub
|
|
|
|
Protected Overridable Sub Control_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
|
|
|
SaveControlsToSession_Ajax()
|
|
|
|
' Show confirmation message on Click
|
|
Me.PersonalExtraSalaryDeleteButton.Attributes.Add("onClick", "return (confirm('" & (CType(Me.Page,BaseApplicationPage)).GetResourceValue("DeleteConfirm", "Persons") & "'));")
|
|
|
|
' Setup the pagination events.
|
|
|
|
AddHandler Me.PersonalExtraSalaryPagination.FirstPage.Click, AddressOf PersonalExtraSalaryPagination_FirstPage_Click
|
|
|
|
AddHandler Me.PersonalExtraSalaryPagination.LastPage.Click, AddressOf PersonalExtraSalaryPagination_LastPage_Click
|
|
|
|
AddHandler Me.PersonalExtraSalaryPagination.NextPage.Click, AddressOf PersonalExtraSalaryPagination_NextPage_Click
|
|
|
|
AddHandler Me.PersonalExtraSalaryPagination.PageSizeButton.Click, AddressOf PersonalExtraSalaryPagination_PageSizeButton_Click
|
|
|
|
AddHandler Me.PersonalExtraSalaryPagination.PreviousPage.Click, AddressOf PersonalExtraSalaryPagination_PreviousPage_Click
|
|
|
|
|
|
' Setup the sorting events.
|
|
|
|
AddHandler Me.AmoutLabel.Click, AddressOf AmoutLabel_Click
|
|
|
|
AddHandler Me.ExtraSalaryIdLabel1.Click, AddressOf ExtraSalaryIdLabel1_Click
|
|
|
|
AddHandler Me.RefDateLabel.Click, AddressOf RefDateLabel_Click
|
|
|
|
AddHandler Me.RefLabel.Click, AddressOf RefLabel_Click
|
|
|
|
AddHandler Me.StartDateLabel.Click, AddressOf StartDateLabel_Click
|
|
|
|
' Setup the button events.
|
|
|
|
AddHandler Me.PersonalExtraSalaryAddButton.Click, AddressOf PersonalExtraSalaryAddButton_Click
|
|
|
|
AddHandler Me.PersonalExtraSalaryDeleteButton.Click, AddressOf PersonalExtraSalaryDeleteButton_Click
|
|
|
|
AddHandler Me.PersonalExtraSalaryEditButton.Click, AddressOf PersonalExtraSalaryEditButton_Click
|
|
|
|
AddHandler Me.PersonalExtraSalaryRefreshButton.Click, AddressOf PersonalExtraSalaryRefreshButton_Click
|
|
|
|
AddHandler Me.PersonalExtraSalaryResetButton.Click, AddressOf PersonalExtraSalaryResetButton_Click
|
|
|
|
AddHandler Me.PersonalExtraSalarySaveButton.Click, AddressOf PersonalExtraSalarySaveButton_Click
|
|
|
|
Me.PersonalExtraSalarySaveButton.Attributes.Add("onclick", "SubmitHRefOnce(this, """ & Me.Page.GetResourceValue("Txt:SaveRecord", "Persons") & """);")
|
|
|
|
|
|
' Setup events for others
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub LoadData()
|
|
|
|
' Read data from database. Returns an array of records that can be assigned
|
|
' to the DataSource table control property.
|
|
Try
|
|
Dim joinFilter As CompoundFilter = CreateCompoundJoinFilter()
|
|
|
|
' The WHERE clause will be empty when displaying all records in table.
|
|
Dim wc As WhereClause = CreateWhereClause()
|
|
If wc IsNot Nothing AndAlso Not wc.RunQuery Then
|
|
' Initialize an empty array of records
|
|
Dim alist As New ArrayList(0)
|
|
Me.DataSource = DirectCast(alist.ToArray(GetType(PersonalExtraSalaryRecord)), PersonalExtraSalaryRecord())
|
|
' 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, PersonalExtraSalaryTable.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 PersonalExtraSalaryTableControlRow 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(PersonalExtraSalaryRecord)), PersonalExtraSalaryRecord())
|
|
Else ' Get the records from the database
|
|
Me.DataSource = PersonalExtraSalaryTable.GetRecords(joinFilter, wc, orderBy, Me.PageIndex, Me.PageSize)
|
|
|
|
End If
|
|
|
|
' if the datasource contains no records contained in database, then load the last page.
|
|
If (DbUtils.GetCreatedRecords(Me.DataSource).Length = 0 AndAlso Not Me.DisplayLastPage) Then
|
|
Me.DisplayLastPage = True
|
|
LoadData()
|
|
Else
|
|
|
|
' Add any new rows desired by the user.
|
|
Me.AddNewRecords()
|
|
|
|
' Turn off the ToggleAll checkbox
|
|
Me.PersonalExtraSalaryToggleAll.Checked = False
|
|
|
|
|
|
' Initialize the page and grand totals. now
|
|
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
' Report the error message to the end user
|
|
Dim msg As String = ex.Message
|
|
If ex.InnerException IsNot Nothing Then
|
|
msg = msg & " InnerException: " & ex.InnerException.Message
|
|
End If
|
|
Throw New Exception(msg, ex.InnerException)
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Public Overrides Sub DataBind()
|
|
' The DataBind method binds the user interface controls to the values
|
|
' from the database record for each row in the table. To do this, it calls the
|
|
' DataBind for each of the rows.
|
|
' DataBind also populates any filters above the table, and sets the pagination
|
|
' control to the correct number of records and the current page number.
|
|
|
|
MyBase.DataBind()
|
|
|
|
' Make sure that the DataSource is initialized.
|
|
If Me.DataSource Is Nothing Then
|
|
Return
|
|
End If
|
|
|
|
'LoadData for DataSource for chart and report if they exist
|
|
|
|
' Improve performance by prefetching display as records.
|
|
Me.PreFetchForeignKeyValues()
|
|
|
|
' Setup the pagination controls.
|
|
BindPaginationControls()
|
|
|
|
|
|
|
|
' Bind the repeater with the list of records to expand the UI.
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtraSalaryTableControlRepeater"), 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 PersonalExtraSalaryTableControlRow = DirectCast(repItem.FindControl("PersonalExtraSalaryTableControlRow"), PersonalExtraSalaryTableControlRow)
|
|
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
|
|
|
|
SetAmoutLabel()
|
|
SetExtraSalaryIdLabel1()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetPersonalExtraSalaryTableControlCollapsibleRegion()
|
|
SetPersonalExtraSalaryTableControlIcon()
|
|
SetPersonalExtraSalaryTableControlPanelExtender()
|
|
|
|
|
|
SetRefDateLabel()
|
|
SetRefLabel()
|
|
SetStartDateLabel()
|
|
' setting the state of expand or collapse alternative rows
|
|
|
|
|
|
' Load data for each record and table UI control.
|
|
' Ordering is important because child controls get
|
|
' their parent ids from their parent UI controls.
|
|
|
|
|
|
' this method calls the set method for controls with special formula like running total, sum, rank, etc
|
|
SetFormulaControls()
|
|
End Sub
|
|
|
|
Public Overridable Sub SetFormulaControls()
|
|
' this method calls Set methods for the control that has special formula
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Public Sub PreFetchForeignKeyValues()
|
|
If (IsNothing(Me.DataSource))
|
|
Return
|
|
End If
|
|
|
|
Me.Page.PregetDfkaRecords(PersonalExtraSalaryTable.ExtraSalaryId, Me.DataSource)
|
|
|
|
Me.Page.PregetDfkaRecords(PersonalExtraSalaryTable.PersonalId, Me.DataSource)
|
|
|
|
End Sub
|
|
|
|
|
|
Public Overridable Sub RegisterPostback()
|
|
|
|
Me.Page.RegisterPostBackTrigger(MiscUtils.FindControlRecursively(Me,"PersonalExtraSalarySaveButton"))
|
|
|
|
|
|
End Sub
|
|
|
|
Public EvaluateFormulaDelegate As BaseClasses.Data.DataSource.EvaluateFormulaDelegate = New BaseClasses.Data.DataSource.EvaluateFormulaDelegate(AddressOf Me.EvaluateFormula)
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate as BaseClasses.Data.BaseRecord, ByVal format as String, ByVal variables As System.Collections.Generic.IDictionary(Of String, Object), ByVal includeDS As Boolean, ByVal e as FormulaEvaluator) As String
|
|
If e Is Nothing
|
|
e = New FormulaEvaluator()
|
|
End If
|
|
|
|
e.Variables.Clear()
|
|
|
|
|
|
' add variables for formula evaluation
|
|
If variables IsNot Nothing Then
|
|
Dim enumerator As System.Collections.Generic.IEnumerator(Of System.Collections.Generic.KeyValuePair(Of String, Object)) = variables.GetEnumerator()
|
|
While enumerator.MoveNext()
|
|
e.Variables.Add(enumerator.Current.Key, enumerator.Current.Value)
|
|
End While
|
|
End If
|
|
|
|
If includeDS
|
|
|
|
End If
|
|
|
|
' All variables referred to in the formula are expected to be
|
|
' properties of the DataSource. For example, referring to
|
|
' UnitPrice as a variable will refer to DataSource.UnitPrice
|
|
e.DataSource = dataSourceForEvaluate
|
|
|
|
' Define the calling control. This is used to add other
|
|
' related table and record controls as variables.
|
|
e.CallingControl = Me
|
|
|
|
Dim resultObj As Object = e.Evaluate(formula)
|
|
If resultObj Is Nothing Then
|
|
Return ""
|
|
End If
|
|
|
|
If Not String.IsNullOrEmpty(format) AndAlso (String.IsNullOrEmpty(formula) OrElse formula.IndexOf("Format(") < 0) Then
|
|
Return FormulaUtils.Format(resultObj, format)
|
|
Else
|
|
Return resultObj.ToString()
|
|
End If
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate as BaseClasses.Data.BaseRecord, ByVal format as String, ByVal variables As System.Collections.Generic.IDictionary(Of String, Object), ByVal includeDS As Boolean) As String
|
|
Return EvaluateFormula(formula, dataSourceForEvaluate, format,variables ,includeDS, Nothing)
|
|
End Function
|
|
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord, ByVal format As String, ByVal variables As System.Collections.Generic.IDictionary(Of String, Object)) As String
|
|
Return EvaluateFormula(formula, dataSourceForEvaluate, format, variables ,True, Nothing)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord, ByVal format As String) As String
|
|
Return Me.EvaluateFormula(formula, dataSourceForEvaluate, format, Nothing, True, Nothing)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord, ByVal variables As System.Collections.Generic.IDictionary(Of String, Object), ByVal e as FormulaEvaluator) As String
|
|
Return Me.EvaluateFormula(formula, dataSourceForEvaluate, Nothing, variables, True, e)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord) As String
|
|
Return Me.EvaluateFormula(formula, dataSourceForEvaluate, Nothing, Nothing, True, Nothing)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String, ByVal includeDS as Boolean) As String
|
|
Return Me.EvaluateFormula(formula, Nothing, Nothing, Nothing, includeDS, Nothing)
|
|
End Function
|
|
|
|
Public Overridable Function EvaluateFormula(ByVal formula As String) As String
|
|
Return Me.EvaluateFormula(formula, Nothing, Nothing, Nothing, True, Nothing)
|
|
End Function
|
|
|
|
|
|
|
|
|
|
Public Overridable Sub ResetControl()
|
|
|
|
Me.CurrentSortOrder.Reset()
|
|
If (Me.InSession(Me, "Order_By")) Then
|
|
Me.CurrentSortOrder = OrderBy.FromXmlString(Me.GetFromSession(Me, "Order_By", Nothing))
|
|
Else
|
|
Me.CurrentSortOrder = New OrderBy(True, False)
|
|
|
|
Me.CurrentSortOrder.Add(PersonalExtraSalaryTable.StartDate, OrderByItem.OrderDir.Asc)
|
|
|
|
End If
|
|
|
|
Me.PageIndex = 0
|
|
End Sub
|
|
|
|
Protected Overridable Sub BindPaginationControls()
|
|
' Setup the pagination controls.
|
|
|
|
' Bind the pagination labels.
|
|
|
|
If DbUtils.GetCreatedRecords(Me.DataSource).Length > 0 Then
|
|
|
|
Me.PersonalExtraSalaryPagination.CurrentPage.Text = (Me.PageIndex + 1).ToString()
|
|
Else
|
|
Me.PersonalExtraSalaryPagination.CurrentPage.Text = "0"
|
|
End If
|
|
Me.PersonalExtraSalaryPagination.PageSize.Text = Me.PageSize.ToString()
|
|
Me.PersonalExtraSalaryPagination.TotalItems.Text = Me.TotalRecords.ToString()
|
|
Me.PersonalExtraSalaryPagination.TotalPages.Text = Me.TotalPages.ToString()
|
|
|
|
' Bind the buttons for PersonalExtraSalaryTableControl pagination.
|
|
|
|
Me.PersonalExtraSalaryPagination.FirstPage.Enabled = Not (Me.PageIndex = 0)
|
|
If Me._TotalPages < 0 Then ' if the total pages is not determined yet, enable last and next buttons
|
|
Me.PersonalExtraSalaryPagination.LastPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalExtraSalaryPagination.LastPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalExtraSalaryPagination.LastPage.Enabled = Not (Me.PageIndex = Me.TotalPages - 1)
|
|
End If
|
|
|
|
If Me._TotalPages < 0 Then ' if the total pages is not determined yet, enable last and next buttons
|
|
Me.PersonalExtraSalaryPagination.NextPage.Enabled = True
|
|
ElseIf Me._TotalPages = 0 ' if the total pages is determined and it is 0, enable last and next buttons
|
|
Me.PersonalExtraSalaryPagination.NextPage.Enabled = False
|
|
Else ' if the total pages is the last page, disable last and next buttons
|
|
Me.PersonalExtraSalaryPagination.NextPage.Enabled = Not (Me.PageIndex = Me.TotalPages - 1)
|
|
End If
|
|
|
|
Me.PersonalExtraSalaryPagination.PreviousPage.Enabled = Not (Me.PageIndex = 0)
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SaveData()
|
|
' Save the data from the entire table. Calls each row's Save Data
|
|
' to save their data. This function is called by the Click handler of the
|
|
' Save button. The button handler should Start/Commit/End a transaction.
|
|
|
|
Dim recCtl As PersonalExtraSalaryTableControlRow
|
|
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.
|
|
PersonalExtraSalaryTable.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.
|
|
|
|
|
|
' 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)
|
|
End If
|
|
|
|
Return wc
|
|
End Function
|
|
|
|
|
|
Public Overridable Function CreateWhereClause(ByVal searchText as String, ByVal fromSearchControl as String, ByVal AutoTypeAheadSearch as String, ByVal AutoTypeAheadWordSeparators as String) As WhereClause
|
|
' This CreateWhereClause is used for loading list of suggestions for Auto Type-Ahead feature.
|
|
PersonalExtraSalaryTable.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)
|
|
|
|
' 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)
|
|
End If
|
|
|
|
' Adds clauses if values are selected in Filter controls which are configured in the page.
|
|
|
|
|
|
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.PersonalExtraSalaryTable, App_Code").TableDefinition.ColumnList.GetByUniqueName("PersonalExtraSalary_.PersonalId"), New BaseClasses.Data.IdentifierAliasInfo("PersonalExtraSalary_", Nothing), BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, False))
|
|
|
|
whereClause.AddFilter(filter, CompoundFilter.CompoundingOperators.And_Operator)
|
|
|
|
Return whereClause
|
|
|
|
End Function
|
|
|
|
|
|
Public Overridable Function FormatSuggestions(ByVal prefixText As String, ByVal resultItem As String, _
|
|
ByVal columnLength As Integer, ByVal AutoTypeAheadDisplayFoundText As String, _
|
|
ByVal autoTypeAheadSearch As String, ByVal AutoTypeAheadWordSeparators As String, _
|
|
ByVal resultList As ArrayList) As Boolean
|
|
|
|
'Formats the resultItem and adds it to the list of suggestions.
|
|
Dim index As Integer = resultItem.ToUpper(System.Threading.Thread.CurrentThread.CurrentCulture).IndexOf(prefixText.ToUpper(System.Threading.Thread.CurrentThread.CurrentCulture))
|
|
Dim itemToAdd As String = ""
|
|
Dim isFound As Boolean = False
|
|
Dim isAdded As Boolean = False
|
|
' Get the index where prfixt is at the beginning of resultItem. If not found then, index of word which begins with prefixText.
|
|
If InvariantLCase(autoTypeAheadSearch).equals("wordsstartingwithsearchstring") And Not index = 0 Then
|
|
' Expression to find word which contains AutoTypeAheadWordSeparators followed by prefixText
|
|
Dim regex1 As System.Text.RegularExpressions.Regex = new System.Text.RegularExpressions.Regex( AutoTypeAheadWordSeparators + prefixText, System.Text.RegularExpressions.RegexOptions.IgnoreCase)
|
|
If regex1.IsMatch(resultItem) Then
|
|
index = regex1.Match(resultItem).Index
|
|
isFound = True
|
|
End If
|
|
' If the prefixText is found immediatly after white space then starting of the word is found so don not search any further
|
|
If not resultItem(index).ToString() = " " Then
|
|
' Expression to find beginning of the word which contains AutoTypeAheadWordSeparators followed by prefixText
|
|
Dim regex As System.Text.RegularExpressions.Regex = new System.Text.RegularExpressions.Regex("\\S*" + AutoTypeAheadWordSeparators + prefixText, System.Text.RegularExpressions.RegexOptions.IgnoreCase)
|
|
If regex.IsMatch(resultItem) Then
|
|
index = regex.Match(resultItem).Index
|
|
isFound = True
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
' If autoTypeAheadSearch value is wordsstartingwithsearchstring then, extract the substring only if the prefixText is found at the
|
|
' beginning of the resultItem (index = 0) or a word in resultItem is found starts with prefixText.
|
|
If index = 0 Or isFound Or InvariantLCase(autoTypeAheadSearch).Equals("anywhereinstring") then
|
|
If InvariantLCase(AutoTypeAheadDisplayFoundText).equals("atbeginningofmatchedstring") Then
|
|
' Expression to find beginning of the word which contains prefixText
|
|
Dim regex1 As System.Text.RegularExpressions.Regex = new System.Text.RegularExpressions.Regex("\\S*" + prefixText, System.Text.RegularExpressions.RegexOptions.IgnoreCase)
|
|
' Find the beginning of the word which contains prefexText
|
|
If (StringUtils.InvariantLCase(autoTypeAheadSearch).Equals("anywhereinstring") AndAlso regex1.IsMatch(resultItem)) Then
|
|
index = regex1.Match(resultItem).Index
|
|
isFound = True
|
|
End If
|
|
' Display string from the index till end of the string if sub string from index till end is less than columnLength value.
|
|
If Len(resultItem) - index <= columnLength Then
|
|
If index = 0 Then
|
|
itemToAdd = resultItem
|
|
Else
|
|
itemToAdd = "..." & resultItem.Substring(index, Len(resultItem) - index)
|
|
End If
|
|
Else
|
|
If index = 0 Then
|
|
itemToAdd = resultItem.Substring(index, (columnLength - 3)) & "..."
|
|
Else
|
|
'Truncate the string to show only columnLength - 6 characters as begining and trailing "..." has to be appended.
|
|
itemToAdd = "..." & resultItem.Substring(index , columnLength - 6) & "..."
|
|
End If
|
|
End If
|
|
ElseIf InvariantLCase(AutoTypeAheadDisplayFoundText).equals("inmiddleofmatchedstring") Then
|
|
Dim subStringBeginIndex As Integer = CType(columnLength/2, Integer)
|
|
If Len(resultItem) <= columnLength Then
|
|
itemToAdd = resultItem
|
|
Else
|
|
' Sanity check at end of the string
|
|
If index + Len(prefixText) = columnLength Then
|
|
itemToAdd = "..." & resultItem.Substring(index-columnLength,index)
|
|
ElseIf Len(resultItem) - index < subStringBeginIndex Then
|
|
' Display string from the end till columnLength value if, index is closer to the end of the string.
|
|
itemToAdd = "..." & resultItem.Substring(Len(resultItem)-columnLength,Len(resultItem))
|
|
ElseIf index <= subStringBeginIndex Then
|
|
' Sanity chet at beginning of the string
|
|
itemToAdd = resultItem.Substring(0, columnLength) & "..."
|
|
Else
|
|
' Display string containing text before the prefixText occures and text after the prefixText
|
|
itemToAdd = "..." & resultItem.Substring(index - subStringBeginIndex, columnLength) & "..."
|
|
End If
|
|
End If
|
|
ElseIf InvariantLCase(AutoTypeAheadDisplayFoundText).equals("atendofmatchedstring") Then
|
|
' Expression to find ending of the word which contains prefexText
|
|
Dim regex1 As System.Text.RegularExpressions.Regex = new System.Text.RegularExpressions.Regex("\s", System.Text.RegularExpressions.RegexOptions.IgnoreCase)
|
|
' Find the ending of the word which contains prefexText
|
|
If regex1.IsMatch(resultItem, index + 1) Then
|
|
index = regex1.Match(resultItem, index + 1).Index
|
|
Else
|
|
' If the word which contains prefexText is the last word in string, regex1.IsMatch returns false.
|
|
index = resultItem.Length
|
|
End If
|
|
If index > Len(resultItem) Then
|
|
index = Len(resultItem)
|
|
End If
|
|
' If text from beginning of the string till index is less than columnLength value then, display string from the beginning till index.
|
|
If index <= columnLength Then
|
|
if index = Len(resultItem) Then 'Make decision to append "..."
|
|
itemToAdd = resultItem.Substring(0,index)
|
|
Else
|
|
itemToAdd = resultItem.Substring(0,index) & "..."
|
|
End If
|
|
Else
|
|
If index = Len(resultItem) Then
|
|
itemToAdd = "..." & resultItem.Substring(index - (columnLength - 3), (columnLength - 3))
|
|
Else
|
|
'Truncate the string to show only columnLength - 6 characters as begining and trailing "..." has to be appended.
|
|
itemToAdd = "..." & resultItem.Substring(index - (columnLength - 6), columnLength - 6) & "..."
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
' Remove newline character from itemToAdd
|
|
Dim prefixTextIndex As Integer = itemToAdd.IndexOf(prefixText, StringComparison.CurrentCultureIgnoreCase)
|
|
' If itemToAdd contains any newline after the search text then show text only till newline
|
|
Dim regex2 As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex("(" & vbCrLf & "|" & vbLf & ")", System.Text.RegularExpressions.RegexOptions.IgnoreCase)
|
|
Dim newLineIndexAfterPrefix As Integer = -1
|
|
If regex2.IsMatch(itemToAdd, prefixTextIndex) Then
|
|
newLineIndexAfterPrefix = regex2.Match(itemToAdd, prefixTextIndex).Index
|
|
End If
|
|
If (newLineIndexAfterPrefix > -1) Then
|
|
If itemToAdd.EndsWith("...") Then
|
|
itemToAdd = (itemToAdd.Substring(0, newLineIndexAfterPrefix) + "...")
|
|
Else
|
|
itemToAdd = itemToAdd.Substring(0, newLineIndexAfterPrefix)
|
|
End If
|
|
End If
|
|
' If itemToAdd contains any newline before search text then show text which comes after newline
|
|
Dim regex3 As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex("(" & vbCrLf & "|" & vbLf & ")", (System.Text.RegularExpressions.RegexOptions.IgnoreCase Or System.Text.RegularExpressions.RegexOptions.RightToLeft))
|
|
Dim newLineIndexBeforePrefix As Integer = -1
|
|
If regex3.IsMatch(itemToAdd, prefixTextIndex) Then
|
|
newLineIndexBeforePrefix = regex3.Match(itemToAdd, prefixTextIndex).Index
|
|
End If
|
|
If (newLineIndexBeforePrefix > -1) Then
|
|
If itemToAdd.StartsWith("...") Then
|
|
itemToAdd = ("..." + itemToAdd.Substring((newLineIndexBeforePrefix + regex3.Match(itemToAdd, prefixTextIndex).Length)))
|
|
Else
|
|
itemToAdd = itemToAdd.Substring((newLineIndexBeforePrefix + regex3.Match(itemToAdd, prefixTextIndex).Length))
|
|
End If
|
|
End If
|
|
|
|
If Not itemToAdd is nothing AndAlso Not resultList.Contains(itemToAdd) Then
|
|
|
|
resultList.Add(itemToAdd)
|
|
|
|
isAdded = true
|
|
End If
|
|
End If
|
|
Return isAdded
|
|
End Function
|
|
|
|
|
|
Protected Overridable Sub GetPageSize()
|
|
|
|
If Me.PersonalExtraSalaryPagination.PageSize.Text.Trim <> "" Then
|
|
Try
|
|
'Me.PageSize = Integer.Parse(Me.PersonalExtraSalaryPagination.PageSize.Text)
|
|
Catch ex As Exception
|
|
End Try
|
|
End If
|
|
End Sub
|
|
|
|
Protected Overridable Sub AddNewRecords()
|
|
|
|
Dim newRecordList As ArrayList = New ArrayList()
|
|
|
|
Dim newUIDataList As System.Collections.Generic.List(Of Hashtable) = New System.Collections.Generic.List(Of Hashtable)()
|
|
|
|
' Loop though all the record controls and if the record control
|
|
' does not have a unique record id set, then create a record
|
|
' and add to the list.
|
|
If Not Me.ResetData Then
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtraSalaryTableControlRepeater"), 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 PersonalExtraSalaryTableControlRow = DirectCast(repItem.FindControl("PersonalExtraSalaryTableControlRow"), PersonalExtraSalaryTableControlRow)
|
|
|
|
If recControl.Visible AndAlso recControl.IsNewRecord() Then
|
|
|
|
Dim rec As PersonalExtraSalaryRecord = New PersonalExtraSalaryRecord()
|
|
|
|
If recControl.Amout.Text <> "" Then
|
|
rec.Parse(recControl.Amout.Text, PersonalExtraSalaryTable.Amout)
|
|
End If
|
|
If MiscUtils.IsValueSelected(recControl.ExtraSalaryId) Then
|
|
rec.Parse(recControl.ExtraSalaryId.SelectedItem.Value, PersonalExtraSalaryTable.ExtraSalaryId)
|
|
End If
|
|
If MiscUtils.IsValueSelected(recControl.PersonalId) Then
|
|
rec.Parse(recControl.PersonalId.SelectedItem.Value, PersonalExtraSalaryTable.PersonalId)
|
|
End If
|
|
If recControl.Ref1.Text <> "" Then
|
|
rec.Parse(recControl.Ref1.Text, PersonalExtraSalaryTable.Ref0)
|
|
End If
|
|
If recControl.RefDate.Text <> "" Then
|
|
rec.Parse(recControl.RefDate.Text, PersonalExtraSalaryTable.RefDate)
|
|
End If
|
|
If recControl.StartDate.Text <> "" Then
|
|
rec.Parse(recControl.StartDate.Text, PersonalExtraSalaryTable.StartDate)
|
|
End If
|
|
newUIDataList.Add(recControl.PreservedUIData())
|
|
newRecordList.Add(rec)
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
|
|
' Add any new record to the list.
|
|
Dim index As Integer = 0
|
|
For index = 1 To Me.AddNewRecord
|
|
|
|
newRecordList.Insert(0, New PersonalExtraSalaryRecord())
|
|
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(PersonalExtraSalaryRecord)), PersonalExtraSalaryRecord())
|
|
|
|
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 PersonalExtraSalaryTableControlRow)
|
|
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 PersonalExtraSalaryTableControlRow) 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 SetAmoutLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetExtraSalaryIdLabel1()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalExtraSalaryTableControlCollapsibleRegion()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalExtraSalaryTableControlIcon()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetPersonalExtraSalaryTableControlPanelExtender()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRefDateLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetRefLabel()
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub SetStartDateLabel()
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Protected Overridable Sub Control_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
|
|
' PreRender event is raised just before page is being displayed.
|
|
Try
|
|
DbUtils.StartTransaction
|
|
Me.RegisterPostback()
|
|
|
|
If Not Me.Page.ErrorOnPage AndAlso (Me.Page.IsPageRefresh OrElse Me.DataChanged OrElse Me.ResetData) Then
|
|
|
|
|
|
' Re-load the data and update the web page if necessary.
|
|
' This is typically done during a postback (filter, search button, sort, pagination button).
|
|
' In each of the other click handlers, simply set DataChanged to True to reload the data.
|
|
Dim added As Boolean = Me.AddNewRecord > 0
|
|
Me.LoadData()
|
|
Me.DataBind()
|
|
|
|
If added Then
|
|
Me.SetFocusToAddedRow()
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
Catch ex As Exception
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
End Sub
|
|
|
|
'this function sets focus to the first editable element in the new added row in the editable table
|
|
Protected Overridable Sub SetFocusToAddedRow()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalExtraSalaryTableControlRepeater"), System.Web.UI.WebControls.Repeater)
|
|
If rep Is Nothing OrElse rep.Items.Count = 0 Then Return
|
|
Dim repItem As System.Web.UI.WebControls.RepeaterItem
|
|
For Each repItem In rep.Items
|
|
'Load scripts to table rows
|
|
Me.Page.LoadFocusScripts(repItem)
|
|
Dim recControl As PersonalExtraSalaryTableControlRow = DirectCast(repItem.FindControl("PersonalExtraSalaryTableControlRow"), PersonalExtraSalaryTableControlRow)
|
|
If recControl.IsNewRecord Then
|
|
For Each field As Control In recControl.Controls
|
|
If field.Visible AndAlso Me.Page.IsControlEditable(field, False) Then
|
|
'set focus on the first editable field in the new row
|
|
field.Focus()
|
|
Dim updPan As UpdatePanel = DirectCast(Me.Page.FindControlRecursively("UpdatePanel1"), UpdatePanel)
|
|
If Not updPan Is Nothing Then updPan.Update()
|
|
Return
|
|
End If
|
|
Next
|
|
Return
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
|
|
Protected Overrides Sub SaveControlsToSession()
|
|
MyBase.SaveControlsToSession()
|
|
|
|
' Save filter controls to values to session.
|
|
|
|
|
|
'Save pagination state to session.
|
|
|
|
|
|
|
|
' Save table control properties to the session.
|
|
If Not Me.CurrentSortOrder Is Nothing Then
|
|
Me.SaveToSession(Me, "Order_By", Me.CurrentSortOrder.ToXmlString())
|
|
End If
|
|
|
|
Me.SaveToSession(Me, "Page_Index", Me.PageIndex.ToString())
|
|
Me.SaveToSession(Me, "Page_Size", Me.PageSize.ToString())
|
|
|
|
Me.SaveToSession(Me, "DeletedRecordIds", Me.DeletedRecordIds)
|
|
|
|
End Sub
|
|
|
|
Protected Sub SaveControlsToSession_Ajax()
|
|
' Save filter controls to values to session.
|
|
|
|
HttpContext.Current.Session("AppRelativeVirtualPath") = Me.Page.AppRelativeVirtualPath
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub ClearControlsFromSession()
|
|
MyBase.ClearControlsFromSession()
|
|
|
|
' Clear filter controls values from the session.
|
|
|
|
|
|
' Clear pagination state from session.
|
|
|
|
|
|
|
|
' Clear table properties from the session.
|
|
Me.RemoveFromSession(Me, "Order_By")
|
|
Me.RemoveFromSession(Me, "Page_Index")
|
|
Me.RemoveFromSession(Me, "Page_Size")
|
|
|
|
Me.RemoveFromSession(Me, "DeletedRecordIds")
|
|
|
|
End Sub
|
|
|
|
Protected Overrides Sub LoadViewState(ByVal savedState As Object)
|
|
MyBase.LoadViewState(savedState)
|
|
|
|
Dim orderByStr As String = CType(ViewState("PersonalExtraSalaryTableControl_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("PersonalExtraSalaryTableControl_OrderBy") = Me.CurrentSortOrder.ToXmlString()
|
|
End If
|
|
|
|
Me.ViewState("Page_Index") = Me.PageIndex
|
|
Me.ViewState("Page_Size") = Me.PageSize
|
|
|
|
Me.ViewState("DeletedRecordIds") = Me.DeletedRecordIds
|
|
|
|
|
|
' Load view state for pagination control.
|
|
|
|
|
|
Return MyBase.SaveViewState()
|
|
End Function
|
|
|
|
' Generate the event handling functions for pagination events.
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonalExtraSalaryPagination_FirstPage_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
Me.PageIndex = 0
|
|
Me.DataChanged = True
|
|
|
|
Catch ex As Exception
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonalExtraSalaryPagination_LastPage_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
Me.DisplayLastPage = True
|
|
Me.DataChanged = True
|
|
|
|
Catch ex As Exception
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonalExtraSalaryPagination_NextPage_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
Me.PageIndex += 1
|
|
Me.DataChanged = True
|
|
|
|
Catch ex As Exception
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for LinkButton
|
|
Public Overridable Sub PersonalExtraSalaryPagination_PageSizeButton_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
|
|
Try
|
|
|
|
Me.DataChanged = True
|
|
|
|
Me.PageSize = Integer.Parse(Me.PersonalExtraSalaryPagination.PageSize.Text)
|
|
|
|
Me.PageIndex = Integer.Parse(Me.PersonalExtraSalaryPagination.CurrentPage.Text) - 1
|
|
|
|
Catch ex As Exception
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonalExtraSalaryPagination_PreviousPage_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
If Me.PageIndex > 0 Then
|
|
Me.PageIndex -= 1
|
|
Me.DataChanged = True
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
|
|
' Generate the event handling functions for sorting events.
|
|
|
|
Public Overridable Sub AmoutLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Amout when clicked.
|
|
|
|
' Get previous sorting state for Amout.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalExtraSalaryTable.Amout)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for Amout.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalExtraSalaryTable.Amout, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Amout, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub ExtraSalaryIdLabel1_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by ExtraSalaryId when clicked.
|
|
|
|
' Get previous sorting state for ExtraSalaryId.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalExtraSalaryTable.ExtraSalaryId)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for ExtraSalaryId.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalExtraSalaryTable.ExtraSalaryId, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by ExtraSalaryId, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub RefDateLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by RefDate when clicked.
|
|
|
|
' Get previous sorting state for RefDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalExtraSalaryTable.RefDate)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for RefDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalExtraSalaryTable.RefDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by RefDate, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub RefLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by Ref when clicked.
|
|
|
|
' Get previous sorting state for Ref.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalExtraSalaryTable.Ref0)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for Ref.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalExtraSalaryTable.Ref0, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by Ref, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
Public Overridable Sub StartDateLabel_Click(ByVal sender As Object, ByVal args As EventArgs)
|
|
' Sorts by StartDate when clicked.
|
|
|
|
' Get previous sorting state for StartDate.
|
|
|
|
Dim sd As OrderByItem = Me.CurrentSortOrder.Find(PersonalExtraSalaryTable.StartDate)
|
|
If sd Is Nothing OrElse (Me.CurrentSortOrder.Items IsNot Nothing Andalso Me.CurrentSortOrder.Items.Length > 1) Then
|
|
' First time sort, so add sort order for StartDate.
|
|
Me.CurrentSortOrder.Reset()
|
|
Me.CurrentSortOrder.Add(PersonalExtraSalaryTable.StartDate, OrderByItem.OrderDir.Asc)
|
|
Else
|
|
' Previously sorted by StartDate, so just reverse.
|
|
sd.Reverse()
|
|
End If
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
End Sub
|
|
|
|
|
|
' Generate the event handling functions for button events.
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonalExtraSalaryAddButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
Me.AddNewRecord = 1
|
|
Me.DataChanged = True
|
|
|
|
Catch ex As Exception
|
|
' Upon error, rollback the transaction
|
|
Me.Page.RollBackTransaction(sender)
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonalExtraSalaryDeleteButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
If(Not Me.Page.IsPageRefresh) Then
|
|
|
|
Me.DeleteSelectedRecords(True)
|
|
Me.SetFormulaControls()
|
|
|
|
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
' Upon error, rollback the transaction
|
|
Me.Page.RollBackTransaction(sender)
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonalExtraSalaryEditButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
' The redirect URL is set on the Properties, Custom Properties or Actions.
|
|
' The ModifyRedirectURL call resolves the parameters before the
|
|
' Response.Redirect redirects the page to the URL.
|
|
' Any code after the Response.Redirect call will not be executed, since the page is
|
|
' redirected to the URL.
|
|
|
|
|
|
Dim url As String = "../Shared/ConfigureEditRecord.aspx"
|
|
|
|
Dim shouldRedirect As Boolean = True
|
|
Dim TargetKey As String = Nothing
|
|
Dim DFKA As String = TargetKey
|
|
Dim id As String = DFKA
|
|
Dim value As String = id
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
url = Me.ModifyRedirectUrl(url, "",False)
|
|
url = Me.Page.ModifyRedirectUrl(url, "",False)
|
|
|
|
Catch ex As Exception
|
|
' Upon error, rollback the transaction
|
|
Me.Page.RollBackTransaction(sender)
|
|
shouldRedirect = False
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
If shouldRedirect Then
|
|
Me.Page.ShouldSaveControlsToSession = True
|
|
Me.Page.Response.Redirect(url)
|
|
ElseIf Not TargetKey Is Nothing AndAlso _
|
|
Not shouldRedirect Then
|
|
Me.Page.ShouldSaveControlsToSession = True
|
|
Me.Page.CloseWindow(True)
|
|
|
|
End If
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonalExtraSalaryRefreshButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
Dim PersonalExtraSalaryTableControlObj as PersonalExtraSalaryTableControl = DirectCast(Me.Page.FindControlRecursively("PersonalExtraSalaryTableControl"), PersonalExtraSalaryTableControl)
|
|
PersonalExtraSalaryTableControlObj.ResetData = True
|
|
|
|
PersonalExtraSalaryTableControlObj.RemoveFromSession(PersonalExtraSalaryTableControlObj, "DeletedRecordIds")
|
|
PersonalExtraSalaryTableControlObj.DeletedRecordIds = Nothing
|
|
|
|
Catch ex As Exception
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonalExtraSalaryResetButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
|
|
Me.CurrentSortOrder.Reset()
|
|
If Me.InSession(Me, "Order_By") Then
|
|
Me.CurrentSortOrder = OrderBy.FromXmlString(Me.GetFromSession(Me, "Order_By", Nothing))
|
|
Else
|
|
Me.CurrentSortOrder = New OrderBy(True, False)
|
|
|
|
Me.CurrentSortOrder.Add(PersonalExtraSalaryTable.StartDate, OrderByItem.OrderDir.Asc)
|
|
|
|
|
|
End If
|
|
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
|
|
Catch ex As Exception
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
' event handler for ImageButton
|
|
Public Overridable Sub PersonalExtraSalarySaveButton_Click(ByVal sender As Object, ByVal args As ImageClickEventArgs)
|
|
|
|
Try
|
|
' Enclose all database retrieval/update code within a Transaction boundary
|
|
DbUtils.StartTransaction
|
|
|
|
|
|
If (Not Me.Page.IsPageRefresh) Then
|
|
Me.SaveData()
|
|
End If
|
|
|
|
Me.Page.CommitTransaction(sender)
|
|
' Set IsNewRecord to False for all records - since everything has been saved and is no longer "new"
|
|
Dim recCtl As PersonalExtraSalaryTableControlRow
|
|
For Each recCtl in Me.GetRecordControls()
|
|
|
|
recCtl.IsNewRecord = False
|
|
Next
|
|
|
|
|
|
' Set DeletedRecordsIds to Nothing since we have deleted all pending deletes.
|
|
|
|
Me.DeletedRecordIds = Nothing
|
|
|
|
Catch ex As Exception
|
|
' Upon error, rollback the transaction
|
|
Me.Page.RollBackTransaction(sender)
|
|
Me.Page.ErrorOnPage = True
|
|
|
|
' Report the error message to the end user
|
|
Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
|
|
|
|
Finally
|
|
DbUtils.EndTransaction
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
' Generate the event handling functions for filter and search events.
|
|
|
|
|
|
' Generate the event handling functions for others
|
|
|
|
|
|
Private _UIData As New System.Collections.Generic.List(Of Hashtable)
|
|
Public Property UIData() As System.Collections.Generic.List(Of Hashtable)
|
|
Get
|
|
Return Me._UIData
|
|
End Get
|
|
Set(ByVal value As System.Collections.Generic.List(Of Hashtable))
|
|
Me._UIData = value
|
|
End Set
|
|
End Property
|
|
|
|
' pagination properties
|
|
Protected _PageSize As Integer
|
|
Public Property PageSize() As Integer
|
|
Get
|
|
Return Me._PageSize
|
|
End Get
|
|
Set(ByVal value As Integer)
|
|
Me._PageSize = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected _PageIndex As Integer
|
|
Public Property PageIndex() As Integer
|
|
Get
|
|
' Return the PageIndex
|
|
Return Me._PageIndex
|
|
End Get
|
|
Set(ByVal value As Integer)
|
|
Me._PageIndex = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected _TotalRecords As Integer = -1
|
|
Public Property TotalRecords() As Integer
|
|
Get
|
|
If _TotalRecords < 0
|
|
_TotalRecords = PersonalExtraSalaryTable.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 PersonalExtraSalaryRecord = Nothing
|
|
Public Property DataSource() As PersonalExtraSalaryRecord ()
|
|
Get
|
|
Return Me._DataSource
|
|
End Get
|
|
Set(ByVal value() As PersonalExtraSalaryRecord)
|
|
Me._DataSource = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Helper Properties"
|
|
|
|
Public ReadOnly Property AmoutLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "AmoutLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ExtraSalaryIdLabel1() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "ExtraSalaryIdLabel1"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtraSalaryAddButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtraSalaryAddButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtraSalaryDeleteButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtraSalaryDeleteButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtraSalaryEditButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtraSalaryEditButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtraSalaryPagination() As Persons.UI.IPagination
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtraSalaryPagination"), Persons.UI.IPagination)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtraSalaryRefreshButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtraSalaryRefreshButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtraSalaryResetButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtraSalaryResetButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtraSalarySaveButton() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtraSalarySaveButton"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtraSalaryTableControlCollapsibleRegion() As System.Web.UI.WebControls.Panel
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtraSalaryTableControlCollapsibleRegion"), System.Web.UI.WebControls.Panel)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtraSalaryTableControlIcon() As System.Web.UI.WebControls.ImageButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtraSalaryTableControlIcon"), System.Web.UI.WebControls.ImageButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtraSalaryTableControlPanelExtender() As AjaxControlToolkit.CollapsiblePanelExtender
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtraSalaryTableControlPanelExtender"), AjaxControlToolkit.CollapsiblePanelExtender)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtraSalaryTitle() As System.Web.UI.WebControls.Literal
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtraSalaryTitle"), System.Web.UI.WebControls.Literal)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PersonalExtraSalaryToggleAll() As System.Web.UI.WebControls.CheckBox
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "PersonalExtraSalaryToggleAll"), System.Web.UI.WebControls.CheckBox)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RefDateLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RefDateLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property RefLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "RefLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property StartDateLabel() As System.Web.UI.WebControls.LinkButton
|
|
Get
|
|
Return CType(BaseClasses.Utils.MiscUtils.FindControlRecursively(Me, "StartDateLabel"), System.Web.UI.WebControls.LinkButton)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
#Region "Helper Functions"
|
|
|
|
Public Overrides Overloads Function ModifyRedirectUrl(url As String, arg As String, ByVal bEncrypt As Boolean) As String
|
|
Return Me.Page.EvaluateExpressions(url, arg, bEncrypt, Me)
|
|
End Function
|
|
|
|
Public Overrides Overloads Function EvaluateExpressions(url As String, arg As String, ByVal bEncrypt As Boolean) As String
|
|
Dim needToProcess As Boolean = AreAnyUrlParametersForMe(url, arg)
|
|
If (needToProcess) Then
|
|
Dim recCtl As PersonalExtraSalaryTableControlRow = 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 PersonalExtraSalaryRecord = Nothing
|
|
If recCtl IsNot Nothing Then
|
|
rec = recCtl.GetRecord()
|
|
End If
|
|
Return EvaluateExpressions(url, arg, rec, bEncrypt)
|
|
End If
|
|
Return url
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordIndex() As Integer
|
|
Dim counter As Integer = 0
|
|
Dim recControl As PersonalExtraSalaryTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalExtraSalaryRecordRowSelection.Checked Then
|
|
Return counter
|
|
End If
|
|
counter += 1
|
|
Next
|
|
Return -1
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControl() As PersonalExtraSalaryTableControlRow
|
|
Dim selectedList() As PersonalExtraSalaryTableControlRow = Me.GetSelectedRecordControls()
|
|
If selectedList.Length = 0 Then
|
|
Return Nothing
|
|
End If
|
|
Return selectedList(0)
|
|
|
|
End Function
|
|
|
|
Public Overridable Function GetSelectedRecordControls() As PersonalExtraSalaryTableControlRow()
|
|
|
|
Dim selectedList As ArrayList = New ArrayList(25)
|
|
Dim recControl As PersonalExtraSalaryTableControlRow
|
|
For Each recControl In Me.GetRecordControls()
|
|
If recControl.PersonalExtraSalaryRecordRowSelection IsNot Nothing AndAlso recControl.PersonalExtraSalaryRecordRowSelection.Checked Then
|
|
selectedList.Add(recControl)
|
|
End If
|
|
Next
|
|
Return DirectCast(selectedList.ToArray(GetType(PersonalExtraSalaryTableControlRow)), PersonalExtraSalaryTableControlRow())
|
|
|
|
End Function
|
|
|
|
Public Overridable Sub DeleteSelectedRecords(ByVal deferDeletion As Boolean)
|
|
Dim recList() As PersonalExtraSalaryTableControlRow = Me.GetSelectedRecordControls()
|
|
If recList.Length = 0 Then
|
|
' Localization.
|
|
Throw New Exception(Page.GetResourceValue("Err:NoRecSelected", "Persons"))
|
|
End If
|
|
|
|
Dim recCtl As PersonalExtraSalaryTableControlRow
|
|
For Each recCtl In recList
|
|
If deferDeletion Then
|
|
If Not recCtl.IsNewRecord Then
|
|
|
|
Me.AddToDeletedRecordIds(recCtl)
|
|
|
|
End If
|
|
recCtl.Visible = False
|
|
|
|
recCtl.PersonalExtraSalaryRecordRowSelection.Checked = False
|
|
|
|
Else
|
|
|
|
recCtl.Delete()
|
|
|
|
' Setting the DataChanged to True results in the page being refreshed with
|
|
' the most recent data from the database. This happens in PreRender event
|
|
' based on the current sort, search and filter criteria.
|
|
Me.DataChanged = True
|
|
Me.ResetData = True
|
|
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
Public Function GetRecordControls() As PersonalExtraSalaryTableControlRow()
|
|
Dim recList As ArrayList = New ArrayList()
|
|
Dim rep As System.Web.UI.WebControls.Repeater = CType(Me.FindControl("PersonalExtraSalaryTableControlRepeater"), 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 PersonalExtraSalaryTableControlRow = DirectCast(repItem.FindControl("PersonalExtraSalaryTableControlRow"), PersonalExtraSalaryTableControlRow)
|
|
recList.Add(recControl)
|
|
|
|
Next
|
|
|
|
Return DirectCast(recList.ToArray(GetType(PersonalExtraSalaryTableControlRow)), PersonalExtraSalaryTableControlRow())
|
|
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
|
|
|
|
|