protected virtual int MaximumBroughtForwardForSLCat2(DateTime AsOfDate)
        {
            EEmpPositionInfo empPos = AppUtils.GetLastPositionInfo(dbConn, AsOfDate, EmpID);

            if (empPos != null)
            {
                if (leaveTypeDisabledSLCat2 == false)   // if CAT2 is enabled
                {
                    ELeavePlan leavePlan = new ELeavePlan();
                    leavePlan.LeavePlanID = empPos.LeavePlanID;
                    if (ELeavePlan.db.select(dbConn, leavePlan))
                    {
                        DBFilter dbFilter = new DBFilter();
                        dbFilter.add(new Match("LeavePlanID", leavePlan.LeavePlanID));
                        dbFilter.add(new Match("LeaveTypeID", leaveTypeIDSLCat2));
                        ArrayList list = ELeavePlanBroughtForward.db.select(dbConn, dbFilter);
                        if (list.Count > 0)
                        {
                            ELeavePlanBroughtForward leavePlanBroughtForward = (ELeavePlanBroughtForward)list[0];
                            return(leavePlanBroughtForward.LeavePlanBroughtForwardMax);
                        }
                    }
                }
            }
            return(0);
            //return 9999;
        }
    public void loadObject()
    {
        DBFilter dbFilter = new DBFilter();

        dbFilter.add(new Match("LeaveTypeID", LeaveTypeID.Value));
        dbFilter.add(new Match("LeavePlanID", LeavePlanID.Value));

        ArrayList list = ELeavePlanBroughtForward.db.select(dbConn, dbFilter);

        if (list.Count > 0)
        {
            ELeavePlanBroughtForward leavePlanBroughtForward = (ELeavePlanBroughtForward)list[0];
            txtLeavePlanBroughtForward.Text = leavePlanBroughtForward.LeavePlanBroughtForwardMax.ToString();
            txtLeavePlanBroughtForwardNumOfMonthExpired.Text = leavePlanBroughtForward.LeavePlanBroughtForwardNumOfMonthExpired.ToString();
            if (leavePlanBroughtForward.LeavePlanBroughtForwardMax == 9999)
            {
                lblLeavePlanBroughtForward.Text = "¡Û";
//                lblLeavePlanBroughtForward.Font.Size = 14;
            }
            else
            {
                lblLeavePlanBroughtForward.Text = leavePlanBroughtForward.LeavePlanBroughtForwardMax.ToString();
//                lblLeavePlanBroughtForward.Font.Size = 12;
            }

            if (leavePlanBroughtForward.LeavePlanBroughtForwardNumOfMonthExpired == 9999)
            {
                lblLeavePlanBroughtForwardNumOfMonthExpired.Text = "¡Û";
//                lblLeavePlanBroughtForward.Font.Size = 14;
            }
            else
            {
                lblLeavePlanBroughtForwardNumOfMonthExpired.Text = leavePlanBroughtForward.LeavePlanBroughtForwardNumOfMonthExpired.ToString();
//                lblLeavePlanBroughtForward.Font.Size = 12;
            }
            // ****** Start 2013/11/15, Ricky So, remove forfeit checkbox
            // LeavePlanBroughtForwardForfeitLastYearBroughtForwardOnly.Checked = leavePlanBroughtForward.LeavePlanBroughtForwardForfeitLastYearBroughtForwardOnly;
            // chkLeavePlanBroughtForwardForfeitLastYearBroughtForwardOnly.Checked = leavePlanBroughtForward.LeavePlanBroughtForwardForfeitLastYearBroughtForwardOnly;
            // ****** End 2013/11/15, Ricky So, remove forfeit checkbox
        }
        else
        {
            lblLeavePlanBroughtForward.Text = "¡Û";
            txtLeavePlanBroughtForward.Text = "9999";
            // ****** Start 2013/11/15, Ricky So, remove forfeit checkbox
            // lblLeavePlanBroughtForwardNumOfMonthExpired.Text = "-";
            // LeavePlanBroughtForwardForfeitLastYearBroughtForwardOnly.Checked = false;
            // chkLeavePlanBroughtForwardForfeitLastYearBroughtForwardOnly.Checked = false;
            // ****** End 2013/11/15, Ricky So, remove forfeit checkbox
            txtLeavePlanBroughtForwardNumOfMonthExpired.Text = "9999";
            lblLeavePlanBroughtForwardNumOfMonthExpired.Text = "¡Û";
        }
    }
    protected void btnSaveLeavePlanBroughtForward_Click(object sender, EventArgs e)
    {
        int maxBF;
        int numMonthExpiry;

        if (!int.TryParse(txtLeavePlanBroughtForward.Text, out maxBF))
        {
            PageErrors errors = PageErrors.getErrors(ELeavePlanBroughtForward.db, this.Page);
            errors.addError(HROne.Common.WebUtility.GetLocalizedString("validate.int.prompt").Replace("{0}", LeavePlanBroughtForwardName.Text));
            return;
        }
        if (!int.TryParse(txtLeavePlanBroughtForwardNumOfMonthExpired.Text, out numMonthExpiry))
        {
            PageErrors errors = PageErrors.getErrors(ELeavePlanBroughtForward.db, this.Page);
            errors.addError(HROne.Common.WebUtility.GetLocalizedString("validate.int.prompt").Replace("{0}", LeavePlanBroughtForwardNumOfMonthExpiredName.Text));
            return;
        }
        if (maxBF == 0 && numMonthExpiry > 0)
        {
            PageErrors errors = PageErrors.getErrors(ELeavePlanBroughtForward.db, this.Page);
            errors.addError(HROne.Common.WebUtility.GetLocalizedString("Expiry For must be 0 when Max Days B/F is 0"));
            return;
        }
        else if (maxBF > 0 && numMonthExpiry == 0)
        {
            PageErrors errors = PageErrors.getErrors(ELeavePlanBroughtForward.db, this.Page);
            errors.addError(HROne.Common.WebUtility.GetLocalizedString("B/F leaves should not expire immediately.  Please enter correct No. Of Months before expiry"));
            return;
        }

        DBFilter dbFilter = new DBFilter();

        dbFilter.add(new Match("LeaveTypeID", LeaveTypeID.Value));
        dbFilter.add(new Match("LeavePlanID", LeavePlanID.Value));

        WebUtils.StartFunction(Session, FUNCTION_CODE);
        ArrayList list = ELeavePlanBroughtForward.db.select(dbConn, dbFilter);

        if (list.Count > 0)
        {
            ELeavePlanBroughtForward leavePlanBroughtForward = (ELeavePlanBroughtForward)list[0];
            leavePlanBroughtForward.LeavePlanBroughtForwardMax = maxBF;
            leavePlanBroughtForward.LeavePlanBroughtForwardNumOfMonthExpired = numMonthExpiry;
            // ****** Start 2013/11/15, Ricky So, Remove the frofeit last year b/f in leave balance calculation
            // leavePlanBroughtForward.LeavePlanBroughtForwardForfeitLastYearBroughtForwardOnly = LeavePlanBroughtForwardForfeitLastYearBroughtForwardOnly.Checked;
            // ****** End 2013/11/15, Ricky So, Remove the frofeit last year b/f in leave balance calculation
            ELeavePlanBroughtForward.db.update(dbConn, leavePlanBroughtForward);
        }
        else
        {
            ELeavePlanBroughtForward leavePlanBroughtForward = new ELeavePlanBroughtForward();
            leavePlanBroughtForward.LeavePlanID = Convert.ToInt32(LeavePlanID.Value);
            leavePlanBroughtForward.LeaveTypeID = Convert.ToInt32(LeaveTypeID.Value);
            leavePlanBroughtForward.LeavePlanBroughtForwardMax = maxBF;
            leavePlanBroughtForward.LeavePlanBroughtForwardNumOfMonthExpired = numMonthExpiry;
            // ****** Start 2013/11/15, Ricky So, Remove the frofeit last year b/f in leave balance calculation
            // leavePlanBroughtForward.LeavePlanBroughtForwardForfeitLastYearBroughtForwardOnly = LeavePlanBroughtForwardForfeitLastYearBroughtForwardOnly.Checked;
            // ****** End 2013/11/15, Ricky So, Remove the frofeit last year b/f in leave balance calculation
            ELeavePlanBroughtForward.db.insert(dbConn, leavePlanBroughtForward);
        }
        WebUtils.EndFunction(dbConn);

        LeavePlanBroughtForwardEditCell.Visible = false;
        LeavePlanBroughtForwardViewCell.Visible = true;

        loadObject();
        view = loadData(info, sdb, Repeater);
    }