Hi,
MasterPage
public void MasterPage.Page_Load()
{
if (!this.IsPostBack)
{
this.InitializeBackupLeavesListing(this._employees.EmployeeNo);
}
}
private void InitializeBackupLeavesListing(string backupEmployeeNo)
{
LVELeavesBO leavesBO;
LVELeavesBO leavesBackupBO;
bool isLoaded = SessionManager.Instance.Get(SessionVariableConstants.IS_PENDING_FOR_BACKUP_LEAVES_LOADED);
if (isLoaded)
{
leavesBackupBO = SessionManager.Instance.Get(SessionVariableConstants.PENDING_FOR_BACKUP_LEAVES_BO);
}
else
{
leavesBO = new LVELeavesBO();
leavesBackupBO = new LVELeavesBO();
object value = SessionManager.Instance.Get(SessionVariableConstants.CURRENT_SYSDOCID);
Guid SysDocId = Guid.Empty;
if (value != null)
{
SysDocId = new Guid(value.ToString());
}
BackupsBO BackupsPendingList = new BackupsBO();
BackupsPendingList.FillByBackupEmployeeNoBySysDocByPeriod(backupEmployeeNo, SysDocId, DateTime.Today);
if (BackupsPendingList.Count > 0)
{
if (BackupsPendingList.MoveFirst())
{
do
{
leavesBO.FillPendingLeavesByApprover(BackupsPendingList.ApproverEmployeeNo);
leavesBackupBO.CopyDataFrom(leavesBO, MicroFour.StrataFrame.Business.BusinessCloneDataType.AppendDataToTableFromCompleteTable);
}
while (BackupsPendingList.MoveNext());
}
SessionManager.Instance.Set(SessionVariableConstants.PENDING_FOR_BACKUP_LEAVES_BO, leavesBackupBO);
SessionManager.Instance.Set(SessionVariableConstants.IS_PENDING_FOR_BACKUP_LEAVES_LOADED, true);
}
}
}
private void UpdateBackupPendingTaskCount()
{
int count = 0;
LVELeavesBO leavesBackupBO;
if (!SessionManager.Instance.Get(SessionVariableConstants.IS_PENDING_FOR_BACKUP_LEAVES_LOADED))
{
this.InitializeBackupLeavesListing(this._employees.EmployeeNo);
}
leavesBackupBO = SessionManager.Instance.Get(SessionVariableConstants.PENDING_FOR_BACKUP_LEAVES_BO);
if (leavesBackupBO != null && leavesBackupBO.Count > 0)
{
string filterExpr = leavesBackupBO.Filter;
leavesBackupBO.Filter = "DocStatus IN (" + DocStatusType.Pending.GetHashCode() + "," + DocStatusType.PendingForBeforeApprove.GetHashCode() + "," + DocStatusType.PendingForAfterApproved.GetHashCode() + ")";
count = leavesBackupBO.Count;
leavesBackupBO.Filter = filterExpr;
}
// Update Total Pending Leaves by Approver Employee No
if (this._navigations.Seek("IsBackup"))
{
NavBarItem barItem = this.BaseNavigationBar1.Items.FindByName(this._navigations.NavigationId.ToString());
if (barItem != null)
{
barItem.Text = barItem.Text + string.Format("({0})", count);
}
}
}
private void Page_PreRender(object sender, EventArgs e)
{
//----------------------------------------------------------------------------------
//-- Initialize pending / backup pending leave count only at this stage so that it
//-- always show the updated pending count
//----------------------------------------------------------------------------------
this.UpdateBackupPendingTaskCount();
}
WebPage
protected void Page_Load(object sender, EventArgs e)
{
this.Initialize();
}
private void Initialize()
{
if (Convert.ToBoolean(SessionManager.Instance.Get(SessionVariableConstants.IS_PENDING_FOR_BACKUP_LEAVES_LOADED)))
{
this.LVELeaves.CopyDataFrom((LVELeavesBO)SessionManager.Instance.Get(SessionVariableConstants.PENDING_FOR_BACKUP_LEAVES_BO), MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable);
}
else
{
this.GetBackupPendingLeaves();
}
}
private void GetBackupPendingLeaves()
{
EmployeesBO backupEmployees;
LVELeavesBO backupLeaves = new LVELeavesBO();
backupEmployees = SessionManager.Instance.Get(EmployeesBO.WebSessionVariable) as EmployeesBO;
this.BackupsPendingList.FillByBackupEmployeeNoBySysDocByPeriod(backupEmployees.EmployeeNo, SysDocId, DateTime.Today);
if (this.BackupsPendingList.Count > 0)
{
this.LVELeaves.Clear();
if (this.BackupsPendingList.MoveFirst())
{
do
{
backupLeaves.FillPendingLeavesByApprover(this.BackupsPendingList.ApproverEmployeeNo);
this.LVELeaves.CopyDataFrom(backupLeaves, MicroFour.StrataFrame.Business.BusinessCloneDataType.AppendDataToTableFromCompleteTable);
}
while (this.BackupsPendingList.MoveNext());
}
SessionManager.Instance.Set(SessionVariableConstants.PENDING_FOR_BACKUP_LEAVES_BO, this.LVELeaves);
SessionManager.Instance.Set(SessionVariableConstants.IS_PENDING_FOR_BACKUP_LEAVES_LOADED, true);
}
}
protected void Page_Unload(object sender, EventArgs e)
{
SessionManager.Instance.Remove(SessionVariableConstants.IS_PENDING_FOR_BACKUP_LEAVES_LOADED);
SessionManager.Instance.Remove(SessionVariableConstants.PENDING_FOR_BACKUP_LEAVES_BO);
}