コード例 #1
0
    protected void RefreshMinimumWagesInfo()
    {
        DBFilter filter = new DBFilter();

        filter.add(new Match("EmpPayrollID", CurID));
        filter.add(WebUtils.AddRankFilter(Session, "EmpID", true));
        ArrayList empPayrollList = EEmpPayroll.db.select(dbConn, filter);

        if (empPayrollList.Count == 0)
        {
            TotalWagesForMinimumWages.Text = string.Empty;
            MinimumWagesRequired.Text      = string.Empty;
            return;
        }
        EEmpPayroll empPayroll = (EEmpPayroll)empPayrollList[0];

        double dblTotalWagesForMinimumWages = 0;
        double dblMinimumWagesRequired      = 0;

        EPayrollPeriod payPeriod = new EPayrollPeriod();

        payPeriod.PayPeriodID = empPayroll.PayPeriodID;
        if (EPayrollPeriod.db.select(dbConn, payPeriod))
        {
            dblTotalWagesForMinimumWages = HROne.Payroll.PayrollProcess.GetTotalWagesWithoutRestDayPayment(dbConn, empPayroll.EmpID, payPeriod.PayPeriodFr, payPeriod.PayPeriodTo, null);
        }

        double totalWorkingHour = HROne.Payroll.PayrollProcess.GetTotalEmpPayrollWorkingHours(dbConn, empPayroll.EmpID, empPayroll.PayPeriodID);

        lblTotalWorkingHours.Text = totalWorkingHour.ToString();


        dblMinimumWagesRequired        = ((double)(HROne.Payroll.PayrollProcess.GetMinimumWages(dbConn, empPayroll.EmpID, payPeriod.PayPeriodTo) * totalWorkingHour));
        TotalWagesForMinimumWages.Text = dblTotalWagesForMinimumWages.ToString("#,##0.00");
        MinimumWagesRequired.Text      = dblMinimumWagesRequired.ToString("#,##0.00");
        if (dblMinimumWagesRequired - dblTotalWagesForMinimumWages <= 0.01)
        {
            btnAddAdditionalRemuneration.Visible = false;
        }
        else
        {
            EPayrollGroup payGroup = new EPayrollGroup();
            payGroup.PayGroupID = payPeriod.PayGroupID;
            if (EPayrollGroup.db.select(dbConn, payGroup))
            {
                if (payGroup.PayGroupAdditionalRemunerationPayCodeID > 0)
                {
                    btnAddAdditionalRemuneration.Visible = true & toolBar.EditButton_Visible;
                }
                else
                {
                    btnAddAdditionalRemuneration.Visible = false;
                }
            }
            else
            {
                btnAddAdditionalRemuneration.Visible = false;
            }
        }
    }
コード例 #2
0
    protected void Delete_Click(object sender, EventArgs e)
    {
        ArrayList list = new ArrayList();

        foreach (DataListItem item in Repeater.Items)
        {
            CheckBox        c = (CheckBox)item.FindControl("DeleteItem");
            HtmlInputHidden h = (HtmlInputHidden)item.FindControl("ORSORecordID");
            if (c.Checked)
            {
                EORSORecord obj = new EORSORecord();
                obj.ORSORecordID = Int32.Parse(h.Value);
                list.Add(obj);
            }
        }

        EEmpPayroll empPayroll = new EEmpPayroll();

        empPayroll.EmpPayrollID = int.Parse(EmpPayrollID.Value);
        if (EEmpPayroll.db.select(dbConn, empPayroll))
        {
            WebUtils.StartFunction(Session, m_FunctionCode, empPayroll.EmpID);
            foreach (EORSORecord obj in list)
            {
                if (db.select(dbConn, obj))
                {
                    db.delete(dbConn, obj);
                }
            }
            WebUtils.EndFunction(dbConn);
        }
        view = loadData(info, db, Repeater);
    }
コード例 #3
0
    protected void Repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        DataRowView row = (DataRowView)e.Item.DataItem;
        CheckBox    cb  = (CheckBox)e.Item.FindControl("ItemSelect");

        WebFormUtils.LoadKeys(EEmpPayroll.db, row, cb);
        cb.Visible = IsAllowEdit;

        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Binding ebinding = new Binding(dbConn, EEmpPayroll.db);
            ebinding.add(new BlankZeroLabelVLBinder(EEmpPayroll.db, (Label)e.Item.FindControl("EmpPayConfirmBy"), EUser.VLUserName));
            ebinding.init(Request, Session);


            EEmpPayroll obj = new EEmpPayroll();
            EEmpPayroll.db.toObject(((DataRowView)e.Item.DataItem).Row, obj);
            Hashtable values = new Hashtable();
            EEmpPayroll.db.populate(obj, values);
            ebinding.toControl(values);

            string[] payrollProcessTypeDescriptionList = obj.PayrollProcessTypeDescription();
            for (int i = 0; i < payrollProcessTypeDescriptionList.Length; i++)
            {
                payrollProcessTypeDescriptionList[i] = HROne.Common.WebUtility.GetLocalizedString(payrollProcessTypeDescriptionList[i], ci);
            }

            ((Label)e.Item.FindControl("Type")).Text = string.Join(" + ", payrollProcessTypeDescriptionList);
        }
    }
コード例 #4
0
    protected void Add_Click(object sender, EventArgs e)
    {
        Repeater.EditItemIndex = -1;
        EORSORecord c = new EORSORecord();

        Hashtable values = new Hashtable();

        newBinding.toValues(values);

        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();


        db.validate(errors, values);

        if (!errors.isEmpty())
        {
            return;
        }


        db.parse(values, c);
        c.ORSORecType = "A";

        EEmpPayroll empPayroll = new EEmpPayroll();

        empPayroll.EmpPayrollID = c.EmpPayrollID;
        if (EEmpPayroll.db.select(dbConn, empPayroll))
        {
            EPayrollPeriod payPeriod = new EPayrollPeriod();
            payPeriod.PayPeriodID = empPayroll.PayPeriodID;

            if (EPayrollPeriod.db.select(dbConn, payPeriod))
            {
                if (c.ORSORecPeriodFr <= payPeriod.PayPeriodTo && c.ORSORecPeriodTo <= payPeriod.PayPeriodTo)
                {
                    WebUtils.StartFunction(Session, m_FunctionCode, empPayroll.EmpID);
                    db.insert(dbConn, c);
                    WebUtils.EndFunction(dbConn);
                }
                else
                {
                    errors.addError(HROne.Translation.PageErrorMessage.ERROR_INVALID_PERIOD);
                    return;
                }
            }
        }
        ORSORecPeriodFr.TextBox.Text = string.Empty;
        ORSORecPeriodTo.TextBox.Text = string.Empty;
        ORSORecActRI.Text            = string.Empty;
        ORSORecActER.Text            = string.Empty;
        ORSORecActEE.Text            = string.Empty;
        ORSOPlanID.SelectedIndex     = 0;

        view = loadData(info, db, Repeater);
        //Response.Redirect(Request.Url.LocalPath + "?" + Request.QueryString);
    }
コード例 #5
0
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        ArrayList list = new ArrayList();

        foreach (RepeaterItem i in Repeater.Items)
        {
            CheckBox cb = (CheckBox)i.FindControl("ItemSelect");
            if (cb.Checked)
            {
                EEmpPayroll o = (EEmpPayroll)EEmpPayroll.db.createObject();
                WebFormUtils.GetKeys(EEmpPayroll.db, o, cb);
                list.Add(o);
            }
        }

        DateTime processDateTime = AppUtils.ServerDateTime();


        if (list.Count > 0)
        {
            int UserID = WebUtils.GetCurUser(Session).UserID;


            EPayrollPeriod payPeriod = new EPayrollPeriod();
            payPeriod.PayPeriodID          = CurPayPeriodID;
            payPeriod.PayPeriodStatus      = "C";
            payPeriod.PayPeriodConfirmDate = processDateTime;
            payPeriod.PayPeriodConfirmBy   = UserID;
            EPayrollPeriod.db.update(dbConn, payPeriod);

            EPayrollBatch payBatch = new EPayrollBatch();
            payBatch.PayBatchConfirmDate = processDateTime;
            payBatch.PayBatchRemark      = txtRemark.Text;
            EPayrollBatch.db.insert(dbConn, payBatch);

            PayrollProcess payrollProcess = new PayrollProcess(dbConn);
            WebUtils.StartFunction(Session, FUNCTION_CODE, 0, true);
            foreach (EEmpPayroll o in list)
            {
                if (EEmpPayroll.db.select(dbConn, o))
                {
                    AppUtils.StartChildFunction(dbConn, o.EmpID);
                    payrollProcess.PayrollConfirm(o, payBatch.PayBatchID, UserID);
                    AppUtils.EndChildFunction(dbConn);
                }
            }
            WebUtils.EndFunction(dbConn);
            PageErrors.getErrors(db, Page).addError("Complete");
            txtRemark.Text = string.Empty;
            //Response.Write("<script>alert('Completed'); </script>");
        }
        loadObject();
        loadData(info, EEmpPayroll.db, Repeater);
    }
コード例 #6
0
        private bool GenerateORSOData(int PaySlipID, ArrayList orsoRecords)
        {
            bool hasORSO = false;

            DataSet.Payroll_PaySlip.PaySlip_ORSORow orsoRow = null;
            foreach (EORSORecord orsoRecord in orsoRecords)
            {
                hasORSO = true;

                if (orsoRow == null)
                {
                    orsoRow = CreatePaySlipORSORow(PaySlipID, orsoRecord.ORSORecPeriodFr, orsoRecord.ORSORecPeriodTo);
                }
                if (!(orsoRecord.ORSORecPeriodFr.Equals(orsoRow.PeriodFr) && orsoRecord.ORSORecPeriodTo.Equals(orsoRow.PeriodTo)))
                {
                    dataSet.PaySlip_ORSO.Rows.Add(orsoRow);
                    orsoRow = CreatePaySlipORSORow(PaySlipID, orsoRecord.ORSORecPeriodFr, orsoRecord.ORSORecPeriodTo);
                }
                // Start 0000206, Ricky So, 2015-05-22
                //orsoRow.RelevantIncome += orsoRecord.ORSORecActRI;
                // End 0000206, Ricky So, 2015-05-22
                orsoRow.EE += orsoRecord.ORSORecActEE;
                orsoRow.ER += orsoRecord.ORSORecActER;
            }
            // Start 0000206, Ricky So, 2015-05-22
            if (orsoRow != null)
            {
                EEmpPayroll    m_empPayroll = EEmpPayroll.GetObject(dbConn, ((EORSORecord)orsoRecords[0]).EmpPayrollID);
                EPayrollPeriod m_payPeriod  = EPayrollPeriod.GetObject(dbConn, m_empPayroll.PayPeriodID);

                DBFilter m_basicSalaryFilter = new DBFilter();
                m_basicSalaryFilter.add(AppUtils.GetPayemntCodeDBTermByPaymentType(dbConn, "PayCodeID", "BASICSAL"));
                m_basicSalaryFilter.add(new Match("EmpID", m_empPayroll.EmpID));
                m_basicSalaryFilter.add(new Match("EmpRPEffFr", "<=", m_payPeriod.PayPeriodTo));

                OR m_or = new OR();
                m_or.add(new Match("EmpRPEffTo", ">=", m_payPeriod.PayPeriodFr));
                m_or.add(new NullTerm("EmpRPEffTo"));

                m_basicSalaryFilter.add(m_or);

                foreach (EEmpRecurringPayment m_payment in EEmpRecurringPayment.db.select(dbConn, m_basicSalaryFilter))
                {
                    orsoRow.RelevantIncome += m_payment.EmpRPAmount;
                }
            }
            // End 0000206, Ricky So, 2015-05-22

            if (orsoRow != null)
            {
                dataSet.PaySlip_ORSO.Rows.Add(orsoRow);
            }
            return(hasORSO);
        }
コード例 #7
0
        public static void UndoORSO(DatabaseConnection dbConn, EEmpPayroll empPayroll)
        {
            DBFilter filter = new DBFilter();

            filter.add(new Match("EmpPayrollID", empPayroll.EmpPayrollID));
            ArrayList ORSORecords = EORSORecord.db.select(dbConn, filter);

            foreach (EORSORecord ORSORecord in ORSORecords)
            {
                EORSORecord.db.delete(dbConn, ORSORecord);
            }
        }
コード例 #8
0
    protected void Recalculate_Click(object sender, EventArgs e)
    {
        EEmpPayroll empPayroll = new EEmpPayroll();

        empPayroll.EmpPayrollID = CurrentEmpPayrollID;
        if (EEmpPayroll.db.select(dbConn, empPayroll))
        {
            WebUtils.StartFunction(Session, m_FunctionCode, empPayroll.EmpID);
            HROne.Payroll.MPFProcess.Recalculate(dbConn, empPayroll);
            WebUtils.EndFunction(dbConn);
        }
        view = loadData(info, db, Repeater);
        Recalculate(this, EventArgs.Empty);
    }
コード例 #9
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        EEmpPayroll c = new EEmpPayroll();

        Hashtable values = new Hashtable();

        binding.toValues(values);

        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();


        db.validate(errors, values);

        if (!errors.isEmpty())
        {
            return;
        }


        db.parse(values, c);

        if (!errors.isEmpty())
        {
            return;
        }

        WebUtils.StartFunction(Session, FUNCTION_CODE.Value, c.EmpID);
        if (CurID < 0)
        {
            //            Utils.MarkCreate(Session, c);
            db.insert(dbConn, c);
            //            url = Utils.BuildURL(-1, CurID);
        }
        else
        {
            //            Utils.Mark(Session, c);
            db.update(dbConn, c);
        }
        WebUtils.EndFunction(dbConn);
        db.select(dbConn, c);

        //errors.addError(HROne.Common.WebUtility.GetLocalizedStringByCode("Updated", "Updated"));
        ChangeSavedCancelAction();
        loadObject();
    }
コード例 #10
0
    protected void btnUndo_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(EEmpPayroll.db, Page.Master);

        errors.clear();

        ArrayList list = new ArrayList();

        foreach (RepeaterItem i in Repeater.Items)
        {
            CheckBox cb = (CheckBox)i.FindControl("ItemSelect");
            if (cb.Checked)
            {
                EEmpPayroll o = (EEmpPayroll)EEmpPayroll.db.createObject();
                WebFormUtils.GetKeys(EEmpPayroll.db, o, cb);
                list.Add(o);
            }
        }
        if (list.Count > 0)
        {
            DateTime paidDate = new DateTime();

            if (!string.IsNullOrEmpty(SetPaidDate.Value))
            {
                paidDate = DateTime.Parse(SetPaidDate.Value);
            }
            foreach (EEmpPayroll o in list)
            {
                if (EEmpPayroll.db.select(dbConn, o))
                {
                    if (!o.EmpPayValueDate.Equals(paidDate))
                    {
                        WebUtils.StartFunction(Session, FUNCTION_CODE, o.EmpID, true);
                        o.EmpPayValueDate = paidDate;
                        EEmpPayroll.db.update(dbConn, o);
                        WebUtils.EndFunction(dbConn);
                    }
                }
            }


            errors.addError("Paid Date is updated");
            SetPaidDate.Value = string.Empty;
        }
        loadData(info, EEmpPayroll.db, Repeater);
    }
    protected bool loadObject()
    {
        ECostAllocation obj   = new ECostAllocation();
        bool            isNew = WebFormWorkers.loadKeys(db, obj, DecryptedRequest);

        DBFilter filter = new DBFilter();

        filter.add(new Match("CostAllocationID", obj.CostAllocationID));
        filter.add(WebUtils.AddRankFilter(Session, "EmpID", true));
        ArrayList costAllocationList = db.select(dbConn, filter);

        if (costAllocationList.Count == 0)
        {
            return(false);
        }
        obj = (ECostAllocation)costAllocationList[0];

        Hashtable values = new Hashtable();

        db.populate(obj, values);
        binding.toControl(values);
        ucEmp_Header.CurrentEmpID = obj.EmpID;

        EEmpPayroll empPayroll = new EEmpPayroll();

        empPayroll.EmpPayrollID = obj.EmpPayrollID;
        EEmpPayroll.db.select(dbConn, empPayroll);
        ucPayroll_PeriodInfo.CurrentPayPeriodID            = empPayroll.PayPeriodID;
        Payroll_CostAllocationList.CurrentCostAllocationID = obj.CostAllocationID;
        //Payroll_PaymentRecordList.CurrentEmpPayrollID = obj.EmpPayrollID;
        //Payroll_PaymentRecordList.CurrentEmpPayStatus = obj.EmpPayStatus;

        //Payroll_MPFRecordList.CurrentEmpPayrollID = obj.EmpPayrollID;
        //Payroll_MPFRecordList.CurrentEmpPayStatus = obj.EmpPayStatus;

        //Payroll_ORSORecordList.CurrentEmpPayrollID = obj.EmpPayrollID;
        //Payroll_ORSORecordList.CurrentEmpPayStatus = obj.EmpPayStatus;

        return(true);
    }
コード例 #12
0
    protected void btnAddAdditionalRemuneration_Click(object sender, EventArgs e)
    {
        DBFilter filter = new DBFilter();

        filter.add(new Match("EmpPayrollID", CurID));
        filter.add(WebUtils.AddRankFilter(Session, "EmpID", true));
        ArrayList empPayrollList = EEmpPayroll.db.select(dbConn, filter);

        if (empPayrollList.Count == 0)
        {
            TotalWagesForMinimumWages.Text = string.Empty;
            MinimumWagesRequired.Text      = string.Empty;
            return;
        }
        EEmpPayroll empPayroll = (EEmpPayroll)empPayrollList[0];

        WebUtils.StartFunction(Session, FUNCTION_CODE.Value, empPayroll.EmpID);
        HROne.Payroll.PayrollProcess.InsertAdditionalRemuneration(dbConn, empPayroll);
        WebUtils.EndFunction(dbConn);

        Payroll_PaymentRecordList.Refresh();
        RefreshMinimumWagesInfo();
    }
コード例 #13
0
        public override ReportDocument GenerateReport()
        {
            DataSet.Payroll_ORSOStatement dataSet = new DataSet.Payroll_ORSOStatement();
            DataSet.Payroll_ORSOStatement.ExistingMemberDataTable existingORSO;
            DataSet.Payroll_ORSOStatement.ORSOPlanDataTable       orsoPlan;

            existingORSO = dataSet.ExistingMember;

            orsoPlan = dataSet.ORSOPlan;



            if (PayPeriodFr.Ticks != 0 && PayPeriodTo.Ticks != 0 && EmpList != null)
            {
                string strPrintPeriod = PayPeriodFr.ToString("yyyy-MM-dd") + " - " + PayPeriodTo.ToString("yyyy-MM-dd");


                DBFilter payPeriodFilter = new DBFilter();
                payPeriodFilter.add(new Match("pp.PayPeriodFr", "<=", PayPeriodTo));
                payPeriodFilter.add(new Match("pp.PayPeriodTo", ">=", PayPeriodFr));

                foreach (EEmpPersonalInfo empInfo in EmpList)
                {
                    EEmpPersonalInfo.db.select(dbConn, empInfo);



                    DBFilter empPayrollFilter = new DBFilter();
                    empPayrollFilter.add(new Match("EmpID", empInfo.EmpID));
                    empPayrollFilter.add(new IN("PayPeriodID", "Select PayPeriodID from PayrollPeriod pp", payPeriodFilter));


                    DBFilter orsoRecordFilter = new DBFilter();
                    orsoRecordFilter.add(new IN("EmpPayrollID", "Select EmpPayrollID from EmpPayroll", empPayrollFilter));
                    orsoRecordFilter.add(new Match("ORSOPlanID", ORSOPlanID));
                    orsoRecordFilter.add("ORSORecPeriodFr", true);
                    orsoRecordFilter.add("ORSORecPeriodTo", true);
                    ArrayList orsoRecords = EORSORecord.db.select(dbConn, orsoRecordFilter);


                    DataSet.Payroll_ORSOStatement.ExistingMemberRow existingORSORow = null;
                    foreach (EORSORecord orsoRecord in orsoRecords)
                    {
                        EORSOPlan orsoPlanObject = new EORSOPlan();
                        orsoPlanObject.ORSOPlanID = orsoRecord.ORSOPlanID;
                        if (EORSOPlan.db.select(dbConn, orsoPlanObject))
                        {
                            if (orsoPlan.Select("ORSOPlanID=" + orsoPlanObject.ORSOPlanID).Length == 0)
                            {
                                DataSet.Payroll_ORSOStatement.ORSOPlanRow orsoPlanRow = orsoPlan.NewORSOPlanRow();
                                orsoPlanRow.ORSOPlanID          = orsoPlanObject.ORSOPlanID;
                                orsoPlanRow.ORSOPlanCode        = orsoPlanObject.ORSOPlanCode;
                                orsoPlanRow.ORSOPlanCompanyName = orsoPlanObject.ORSOPlanCompanyName;
                                orsoPlanRow.ORSOPlanPayCenter   = orsoPlanObject.ORSOPlanPayCenter;
                                orsoPlanRow.ORSOPlanSchemeNo    = orsoPlanObject.ORSOPlanSchemeNo;
                                orsoPlanRow.ORSOPlanDesc        = orsoPlanObject.ORSOPlanDesc;

                                orsoPlan.Rows.Add(orsoPlanRow);
                            }
                        }
                        EEmpPayroll empPayroll = new EEmpPayroll();
                        empPayroll.EmpPayrollID = orsoRecord.EmpPayrollID;
                        EEmpPayroll.db.select(dbConn, empPayroll);
                        EPayrollPeriod payrollPeriod = new EPayrollPeriod();
                        payrollPeriod.PayPeriodID = empPayroll.PayPeriodID;
                        EPayrollPeriod.db.select(dbConn, payrollPeriod);

                        {
                            if (existingORSORow == null)
                            {
                                existingORSORow = existingORSO.NewExistingMemberRow();
                                LoadExistingMemberRowInfo(empInfo, orsoRecord, existingORSORow);
                            }
                            else
                            {
                                if (!(existingORSORow.EmpID == empInfo.EmpID && existingORSORow.PeriodFrom.Equals(orsoRecord.ORSORecPeriodFr) && existingORSORow.PeriodTo.Equals(orsoRecord.ORSORecPeriodTo)))
                                {
                                    existingORSO.Rows.Add(existingORSORow);
                                    existingORSORow = existingORSO.NewExistingMemberRow();
                                    LoadExistingMemberRowInfo(empInfo, orsoRecord, existingORSORow);
                                }
                            }

                            existingORSORow.RelevantIncome += orsoRecord.ORSORecActRI;
                            existingORSORow.EE             += orsoRecord.ORSORecActEE;
                            existingORSORow.ER             += orsoRecord.ORSORecActER;
                        }
                    }

                    if (existingORSORow != null)
                    {
                        existingORSO.Rows.Add(existingORSORow);
                    }
                }



                if (reportDocument == null)
                {
                    reportDocument = new ReportTemplate.Report_Payroll_PFundStatement();
                }
                else
                {
                }


                reportDocument.SetDataSource(dataSet);
                reportDocument.SetParameterValue("ContributionPeriod", PayPeriodFr.ToString("yyyy-MM-dd") + " - " + PayPeriodTo.ToString("yyyy-MM-dd"));
                return(reportDocument);
            }
            else
            {
                return(null);
            }
        }
コード例 #14
0
    protected bool loadObject()
    {
        EEmpPayroll obj   = new EEmpPayroll();
        bool        isNew = WebFormWorkers.loadKeys(db, obj, DecryptedRequest);

        DBFilter filter = new DBFilter();

        filter.add(new Match("EmpPayrollID", obj.EmpPayrollID));
        filter.add(WebUtils.AddRankFilter(Session, "EmpID", true));
        ArrayList empPayrollList = EEmpPayroll.db.select(dbConn, filter);

        if (empPayrollList.Count == 0)
        {
            //IsAllowEdit = false;

            Payroll_PaymentRecordList.Visible = false;
            Payroll_MPFRecordList.Visible     = false;
            Payroll_ORSORecordList.Visible    = false;

            return(false);
        }
        obj = (EEmpPayroll)empPayrollList[0];

        if (obj.EmpPayNumOfDayCount > 0)
        {
            OldNumOfDayContPanel.Visible = true;
        }
        else
        {
            OldNumOfDayContPanel.Visible = false;
        }

        Hashtable values = new Hashtable();

        db.populate(obj, values);
        binding.toControl(values);
        ucEmp_Header.CurrentEmpID = obj.EmpID;
        ucPayroll_PeriodInfo.CurrentPayPeriodID       = obj.PayPeriodID;
        Payroll_PaymentRecordList.CurrentEmpPayrollID = obj.EmpPayrollID;
        Payroll_PaymentRecordList.CurrentEmpPayStatus = obj.EmpPayStatus;

        Payroll_MPFRecordList.CurrentEmpPayrollID = obj.EmpPayrollID;
        Payroll_MPFRecordList.CurrentEmpPayStatus = obj.EmpPayStatus;

        Payroll_ORSORecordList.CurrentEmpPayrollID = obj.EmpPayrollID;
        Payroll_ORSORecordList.CurrentEmpPayStatus = obj.EmpPayStatus;
        if (obj.EmpPayStatus == "C")
        {
            Payroll_PaymentRecordList.IsTrialMode = false;
            Payroll_MPFRecordList.IsTrialMode     = false;
            Payroll_ORSORecordList.IsTrialMode    = false;

            FUNCTION_CODE.Value = HISTORY_FUNCTION_CODE;
            //Payroll_PaymentRecordList.FunctionCode = HISTORY_FUNCTION_CODE;
            //Payroll_MPFRecordList.FunctionCode = HISTORY_FUNCTION_CODE;
            //Payroll_ORSORecordList.FunctionCode = HISTORY_FUNCTION_CODE;

            Title.Text    = HROne.Common.WebUtility.GetLocalizedStringByCode(HISTORY_FUNCTION_CODE, "Payroll History Enquiry/Adjustment");
            SubTitle.Text = HROne.Common.WebUtility.GetLocalizedString("Payroll History Information");
            if (!WebUtils.CheckAccess(Response, Session, HISTORY_FUNCTION_CODE, WebUtils.AccessLevel.Read))
            {
                return(false);
            }
            if (!WebUtils.CheckPermission(Session, HISTORY_FUNCTION_CODE, WebUtils.AccessLevel.ReadWrite))
            {
                //IsAllowEdit = false;
                Payroll_PaymentRecordList.IsAllowEdit = false;
                Payroll_MPFRecordList.IsAllowEdit     = false;
                Payroll_ORSORecordList.IsAllowEdit    = false;
                EmpPayNumOfDayCount.Enabled           = false;
                toolBar.EditButton_Visible            = false;
            }
        }
        else
        {
            FUNCTION_CODE.Value = TRIALRUN_FUNCTION_CODE;

            Payroll_PaymentRecordList.IsTrialMode = true;
            Payroll_MPFRecordList.IsTrialMode     = true;
            Payroll_ORSORecordList.IsTrialMode    = true;



            Title.Text    = HROne.Common.WebUtility.GetLocalizedStringByCode(TRIALRUN_FUNCTION_CODE, "Payroll Trial Run Adjustment");
            SubTitle.Text = HROne.Common.WebUtility.GetLocalizedString("Payroll Trial Run Information");
            if (!WebUtils.CheckAccess(Response, Session, TRIALRUN_FUNCTION_CODE, WebUtils.AccessLevel.Read))
            {
                return(false);
            }
            if (!WebUtils.CheckPermission(Session, TRIALRUN_FUNCTION_CODE, WebUtils.AccessLevel.ReadWrite))
            {
                Payroll_PaymentRecordList.IsAllowEdit = false;
                Payroll_MPFRecordList.IsAllowEdit     = false;
                Payroll_ORSORecordList.IsAllowEdit    = false;
                EmpPayNumOfDayCount.Enabled           = false;
                toolBar.EditButton_Visible            = false;
            }
        }
        RefreshMinimumWagesInfo();

        return(true);
    }
コード例 #15
0
        // Start 000162, Ricky So, 2015-01-26
        public static void Recalculate(DatabaseConnection dbConn, EEmpPayroll empPayroll)
        {
            EPayrollPeriod payPeriod = new EPayrollPeriod();

            payPeriod.PayPeriodID = empPayroll.PayPeriodID;
            if (EPayrollPeriod.db.select(dbConn, payPeriod))
            {
                DBFilter paymentFilter = new DBFilter();
                paymentFilter.add(new Match("EmpPayrollID", empPayroll.EmpPayrollID));
                ArrayList paymentRecords = EPaymentRecord.db.select(dbConn, paymentFilter);

                ArrayList mpfRecords  = HROne.Payroll.MPFProcess.MPFTrialRun(dbConn, empPayroll.EmpID, payPeriod, new ArrayList());
                ArrayList orsoRecords = HROne.Payroll.ORSOProcess.ORSOTrialRun(dbConn, empPayroll.EmpID, payPeriod, paymentRecords, (mpfRecords.Count > 0) ? (EMPFRecord)mpfRecords[0] : null);

                //ArrayList mpfPaymentRecords = HROne.Payroll.MPFProcess.GenerateMPFEEPaymentRecords(dbConn, empPayroll.EmpID, payPeriod, mpfRecords, paymentRecords);
                ArrayList orsoPaymentRecords = HROne.Payroll.ORSOProcess.GenerateORSOEEPaymentRecords(dbConn, empPayroll.EmpID, orsoRecords, paymentRecords);

                if (orsoRecords != null)
                {
                    foreach (EORSORecord orsoRecord in orsoRecords)
                    {
                        DBFilter existingORSORecordFilter = new DBFilter();
                        existingORSORecordFilter.add(new Match("EmpPayrollID", empPayroll.EmpPayrollID));
                        existingORSORecordFilter.add(new Match("ORSORecPeriodFr", orsoRecord.ORSORecPeriodFr));
                        existingORSORecordFilter.add(new Match("ORSORecPeriodTo", orsoRecord.ORSORecPeriodTo));
                        existingORSORecordFilter.add(new Match("ORSOPlanID", orsoRecord.ORSOPlanID));

                        if (!(orsoRecord.ORSORecActEE == 0 && orsoRecord.ORSORecActER == 0 && orsoRecord.ORSORecActRI == 0) || EORSORecord.db.count(dbConn, existingORSORecordFilter) <= 0)
                        {
                            orsoRecord.EmpPayrollID = empPayroll.EmpPayrollID;
                            if (!empPayroll.EmpPayStatus.Equals("T"))
                            {
                                orsoRecord.ORSORecType = "A";
                            }
                            EORSORecord.db.insert(dbConn, orsoRecord);
                        }
                    }
                }

                //if (mpfRecords != null)
                //    foreach (EMPFRecord mpfRecord in mpfRecords)
                //{
                //    DBFilter existingMPFRecordFilter = new DBFilter();
                //    existingMPFRecordFilter.add(new Match("EmpPayrollID", empPayroll.EmpPayrollID));
                //    existingMPFRecordFilter.add(new Match("MPFRecPeriodFr", mpfRecord.MPFRecPeriodFr));
                //    existingMPFRecordFilter.add(new Match("MPFRecPeriodTo", mpfRecord.MPFRecPeriodTo));
                //    existingMPFRecordFilter.add(new Match("MPFPlanID", mpfRecord.MPFPlanID));

                //    if (!(mpfRecord.MPFRecActMCEE == 0 && mpfRecord.MPFRecActMCER == 0 && mpfRecord.MPFRecActMCRI == 0 && mpfRecord.MPFRecActVCEE == 0 && mpfRecord.MPFRecActVCER == 0 && mpfRecord.MPFRecActVCRI == 0) || EMPFRecord.db.count(dbConn, existingMPFRecordFilter) <= 0)
                //    {
                //        mpfRecord.EmpPayrollID = empPayroll.EmpPayrollID;
                //        if (!empPayroll.EmpPayStatus.Equals("T"))
                //            mpfRecord.MPFRecType = "A";
                //        EMPFRecord.db.insert(dbConn, mpfRecord);
                //    }
                //}
                if (orsoPaymentRecords != null)
                {
                    foreach (EPaymentRecord paymentRecord in orsoPaymentRecords)
                    {
                        paymentRecord.EmpPayrollID = empPayroll.EmpPayrollID;
                        if (!empPayroll.EmpPayStatus.Equals("T"))
                        {
                            paymentRecord.PayRecType = "A";
                        }
                        EPaymentRecord.db.insert(dbConn, paymentRecord);
                    }
                }

                //if (mpfPaymentRecords != null)
                //    foreach (EPaymentRecord paymentRecord in mpfPaymentRecords)
                //    {
                //        paymentRecord.EmpPayrollID = empPayroll.EmpPayrollID;
                //        if (!empPayroll.EmpPayStatus.Equals("T"))
                //            paymentRecord.PayRecType = "A";
                //        EPaymentRecord.db.insert(dbConn, paymentRecord);
                //    }
            }
        }
コード例 #16
0
    protected void btnUndo_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(EEmpPayroll.db, Page.Master);

        errors.clear();

        ArrayList list = new ArrayList();

        foreach (RepeaterItem i in Repeater.Items)
        {
            CheckBox cb = (CheckBox)i.FindControl("ItemSelect");
            if (cb.Checked)
            {
                EEmpPayroll o = (EEmpPayroll)EEmpPayroll.db.createObject();
                WebFormUtils.GetKeys(EEmpPayroll.db, o, cb);
                list.Add(o);
            }
        }
        if (list.Count > 0)
        {
            System.Collections.Generic.List <int> payPeriodIDList = new System.Collections.Generic.List <int>();
            PayrollProcess payrollProcess = new PayrollProcess(dbConn);
            foreach (EEmpPayroll o in list)
            {
                if (EEmpPayroll.db.select(dbConn, o))
                {
                    if (!payPeriodIDList.Contains(o.PayPeriodID))
                    {
                        payPeriodIDList.Add(o.PayPeriodID);
                    }
                    WebUtils.StartFunction(Session, FUNCTION_CODE, o.EmpID, true);
                    payrollProcess.UndoPayroll(o);
                    WebUtils.EndFunction(dbConn);
                }
            }

            foreach (int CurPayPeriodID in payPeriodIDList)
            {
                DBFilter trialrunStatusEmpPayrollFilter = new DBFilter();
                trialrunStatusEmpPayrollFilter.add(new Match("EmpPayStatus", "T"));
                trialrunStatusEmpPayrollFilter.add(new Match("PayPeriodID", CurPayPeriodID));

                DBFilter confirmStatusEmpPayrollFilter = new DBFilter();
                confirmStatusEmpPayrollFilter.add(new Match("EmpPayStatus", "C"));
                confirmStatusEmpPayrollFilter.add(new Match("PayPeriodID", CurPayPeriodID));

                EPayrollPeriod payPeriod = new EPayrollPeriod();
                payPeriod.PayPeriodID = CurPayPeriodID;
                ArrayList trialrunStatusEmpPayrollList = EEmpPayroll.db.select(dbConn, trialrunStatusEmpPayrollFilter);
                ArrayList confirmStatusEmpPayrollList  = EEmpPayroll.db.select(dbConn, confirmStatusEmpPayrollFilter);
                if (trialrunStatusEmpPayrollList.Count == 0 && confirmStatusEmpPayrollList.Count == 0)
                {
                    payPeriod.PayPeriodStatus = EPayrollPeriod.PAYPERIOD_STATUS_NORMAL_FLAG;
                }
                else if (trialrunStatusEmpPayrollList.Count != 0)
                {
                    payPeriod.PayPeriodStatus = EPayrollPeriod.PAYPERIOD_STATUS_TRIALRUN_FLAG;
                }
                else if (confirmStatusEmpPayrollList.Count != 0)
                {
                    payPeriod.PayPeriodStatus = EPayrollPeriod.PAYPERIOD_STATUS_CONFIRM_FLAG;
                }

                payPeriod.PayPeriodRollbackDate = AppUtils.ServerDateTime();
                payPeriod.PayPeriodRollbackBy   = WebUtils.GetCurUser(Session).UserID;
                EPayrollPeriod.db.update(dbConn, payPeriod);
            }
            errors.addError("Stop Payment Successful");
        }
        loadData(info, EEmpPayroll.db, Repeater);
    }
コード例 #17
0
    protected bool loadObject()
    {
        obj = new ELeaveApplication();
        bool isNew = WebFormWorkers.loadKeys(db, obj, DecryptedRequest);

        DBFilter filter = new DBFilter();

        filter.add(new Match("EmpID", CurEmpID));
        filter.add(WebUtils.AddRankFilter(Session, "EmpID", true));
        if (EEmpPersonalInfo.db.count(dbConn, filter) == 0)
        {
            if (CurEmpID <= 0)
            {
                return(false);
            }
            else
            {
                HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx");
            }
        }

        if (!db.select(dbConn, obj))
        {
            if (CurID <= 0)
            {
                return(false);
            }
            else
            {
                HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx");
            }
        }

        if (obj.EmpID != CurEmpID)
        {
            if (CurID <= 0)
            {
                return(false);
            }
            else
            {
                HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx");
            }
        }

        Hashtable values = new Hashtable();

        db.populate(obj, values);

        //int empPayrollID = int.Parse((string)values["EmpPayrollID"]);
        if (obj.EmpPayrollID > 0)
        {
            EEmpPayroll empPayroll = new EEmpPayroll();
            empPayroll.EmpPayrollID = obj.EmpPayrollID;
            if (EEmpPayroll.db.select(dbConn, empPayroll))
            {
                values.Add("PayPeriodID", empPayroll.PayPeriodID.ToString());
            }
        }

        binding.toControl(values);
        if (obj.LeaveAppUnit.Equals("D"))
        {
            TimeRow.Visible = false;
            LeaveAppDateToPlaceHolder.Visible = true;
        }
        else
        {
            TimeRow.Visible = true;
            LeaveAppDateToPlaceHolder.Visible = false;
        }
        if (obj.EmpPaymentID != 0 || obj.EmpPayrollID != 0)
        {
            toolBar.EditButton_Visible    = false;
            toolBar.DeleteButton_Visible  = false;
            toolBar.CustomButton1_Visible = true;
            toolBar.CustomButton2_Visible = true;
        }
        else
        {
            toolBar.EditButton_Visible    = true;
            toolBar.DeleteButton_Visible  = true;
            toolBar.CustomButton1_Visible = false;
            toolBar.CustomButton2_Visible = false;
        }

        if (obj.LeaveAppCancelID > 0)
        {
            toolBar.EditButton_Visible    = false;
            toolBar.DeleteButton_Visible  = false;
            toolBar.CustomButton1_Visible = false;
            toolBar.CustomButton2_Visible = false;
        }

        ELeaveCode leaveCode = new ELeaveCode();

        leaveCode.LeaveCodeID = obj.LeaveCodeID;
        if (ELeaveCode.db.select(dbConn, leaveCode))
        {
            PayrollProcessPanel.Visible = !leaveCode.LeaveCodeIsSkipPayrollProcess;
            LeaveCodeIsShowMedicalCertOptionPanel.Visible = leaveCode.LeaveCodeIsShowMedicalCertOption;
            //if (!leaveCode.LeaveCodeIsSkipPayrollProcess)
            //{
            //    ELeaveApplication leaveApp = new ELeaveApplication();
            //    leaveApp.LeaveAppID = CurID;
            //    if (ELeaveApplication.db.select(dbConn, leaveApp))
            //    {
            //        ELeaveCode prevLeaveCode = new ELeaveCode();
            //        prevLeaveCode.LeaveCodeID = leaveApp.LeaveCodeID;
            //        if (ELeaveCode.db.select(dbConn, prevLeaveCode))
            //            if (prevLeaveCode.LeaveCodeIsSkipPayrollProcess)
            //                LeaveAppNoPayProcess.Checked = false;
            //    }
            //}

            if (leaveCode.LeaveTypeID.Equals(ELeaveType.COMPENSATION_LEAVE_TYPE(dbConn).LeaveTypeID))
            {
                HoursClaimPanel.Visible = true;
            }
            else
            {
                HoursClaimPanel.Visible = false;
            }
        }
        else
        {
            HoursClaimPanel.Visible = false;
        }
        CurEmpID = obj.EmpID;
        return(true);
    }
コード例 #18
0
        public static string GetValueFromID(DatabaseConnection dbConn, string fieldName, string fieldValue)
        {
            try
            {
                string tmpfieldName = fieldName;
                if (tmpfieldName.Equals("PreviousEmpID", StringComparison.CurrentCultureIgnoreCase) || tmpfieldName.Equals("NewEmpID", StringComparison.CurrentCultureIgnoreCase))
                {
                    tmpfieldName = "EmpID";
                }
                if (tmpfieldName.EndsWith("PaymentCodeID", StringComparison.CurrentCultureIgnoreCase) || tmpfieldName.EndsWith("PayCodeID", StringComparison.CurrentCultureIgnoreCase))
                {
                    tmpfieldName = "PaymentCodeID";
                }
                if (tmpfieldName.Equals("DefaultMPFPlanID", StringComparison.CurrentCultureIgnoreCase))
                {
                    tmpfieldName = "MPFPlanID";
                }
                if (tmpfieldName.Equals("AttendanceFormulaPayFormID", StringComparison.CurrentCultureIgnoreCase) || tmpfieldName.Equals("ReferencePayFormID", StringComparison.CurrentCultureIgnoreCase))
                {
                    tmpfieldName = "PayFormID";
                }
                if (tmpfieldName.StartsWith("LeaveCode", StringComparison.CurrentCultureIgnoreCase) && tmpfieldName.EndsWith("Formula", StringComparison.CurrentCultureIgnoreCase))
                {
                    tmpfieldName = "PayFormID";
                }
                if (tmpfieldName.StartsWith("PayGroup", StringComparison.CurrentCultureIgnoreCase) && tmpfieldName.EndsWith("Formula", StringComparison.CurrentCultureIgnoreCase))
                {
                    tmpfieldName = "PayFormID";
                }
                if (tmpfieldName.Equals("CurrentPayPeriodID", StringComparison.CurrentCultureIgnoreCase))
                {
                    tmpfieldName = "PayPeriodID";
                }
                if (tmpfieldName.Equals("EmpPosDefaultRosterCodeID", StringComparison.CurrentCultureIgnoreCase))
                {
                    tmpfieldName = "RosterCodeID";
                }
                if (tmpfieldName.Equals("RosterClientMappingSiteCodeToHLevelID", StringComparison.CurrentCultureIgnoreCase))
                {
                    tmpfieldName = "HLevelID";
                }
                if (tmpfieldName.Equals("EmpFirstAuthorizationGp", StringComparison.CurrentCultureIgnoreCase) || tmpfieldName.Equals("EmpSecondAuthorizationGp", StringComparison.CurrentCultureIgnoreCase))
                {
                    tmpfieldName = "AuthorizationGroupID";
                }



                if (tmpfieldName.StartsWith("A", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpfieldName.Equals("ALProrataRoundingRuleID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EALProrataRoundingRule obj = new EALProrataRoundingRule();
                        obj.ALProrataRoundingRuleID = int.Parse(fieldValue);
                        if (EALProrataRoundingRule.db.select(dbConn, obj))
                        {
                            return(obj.ALProrataRoundingRuleCode + " - " + obj.ALProrataRoundingRuleDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("AttendancePlanID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EAttendancePlan obj = new EAttendancePlan();
                        obj.AttendancePlanID = int.Parse(fieldValue);
                        if (EAttendancePlan.db.select(dbConn, obj))
                        {
                            return(obj.AttendancePlanCode + " - " + obj.AttendancePlanDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("AuthorizationGroupID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EAuthorizationGroup obj = new EAuthorizationGroup();
                        obj.AuthorizationGroupID = int.Parse(fieldValue);
                        if (EAuthorizationGroup.db.select(dbConn, obj))
                        {
                            return(obj.AuthorizationCode + " - " + obj.AuthorizationDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("AVCPlanID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EAVCPlan obj = new EAVCPlan();
                        obj.AVCPlanID = int.Parse(fieldValue);
                        if (EAVCPlan.db.select(dbConn, obj))
                        {
                            return(obj.AVCPlanCode + " - " + obj.AVCPlanDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
                else if (tmpfieldName.StartsWith("C", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpfieldName.Equals("CessationReasonID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ECessationReason obj = new ECessationReason();
                        obj.CessationReasonID = int.Parse(fieldValue);
                        if (ECessationReason.db.select(dbConn, obj))
                        {
                            return(obj.CessationReasonCode + " - " + obj.CessationReasonDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("CompanyID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ECompany obj = new ECompany();
                        obj.CompanyID = int.Parse(fieldValue);
                        if (ECompany.db.select(dbConn, obj))
                        {
                            return(obj.CompanyCode + " - " + obj.CompanyName);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }


                    if (tmpfieldName.Equals("CostAllocationDetailID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ECostAllocationDetail obj = new ECostAllocationDetail();
                        obj.CostAllocationDetailID = int.Parse(fieldValue);
                        if (ECostAllocationDetail.db.select(dbConn, obj))
                        {
                            return(GetValueFromID(dbConn, "PayCodeID", obj.PaymentCodeID.ToString()) + ", " + GetValueFromID(dbConn, "CostCenterID", obj.CostCenterID.ToString()));
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("CostAllocationID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ECostAllocation obj = new ECostAllocation();
                        obj.CostAllocationID = int.Parse(fieldValue);
                        if (ECostAllocation.db.select(dbConn, obj))
                        {
                            return(GetValueFromID(dbConn, "EmpPayrollID", obj.EmpPayrollID.ToString()));
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("CostCenterID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ECostCenter obj = new ECostCenter();
                        obj.CostCenterID = int.Parse(fieldValue);
                        if (ECostCenter.db.select(dbConn, obj))
                        {
                            return(obj.CostCenterCode + " - " + obj.CostCenterDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
                else if (tmpfieldName.StartsWith("D", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpfieldName.Equals("DocumentTypeID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EDocumentType obj = new EDocumentType();
                        obj.DocumentTypeID = int.Parse(fieldValue);
                        if (EDocumentType.db.select(dbConn, obj))
                        {
                            return(obj.DocumentTypeCode + " - " + obj.DocumentTypeDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
                else if (tmpfieldName.StartsWith("E", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpfieldName.Equals("EmpAccID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EEmpBankAccount obj = new EEmpBankAccount();
                        obj.EmpBankAccountID = int.Parse(fieldValue);
                        if (EEmpBankAccount.db.select(dbConn, obj))
                        {
                            return(obj.EmpBankCode + "-" + obj.EmpBranchCode + "-" + obj.EmpAccountNo);
                        }
                        //return obj.EmpBankCode + "-" + obj.EmpBranchCode + "-" + string.Empty.PadRight(obj.EmpAccountNo.Length, 'X');
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("EmpCostCenterID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EEmpCostCenter obj = new EEmpCostCenter();
                        obj.EmpCostCenterID = int.Parse(fieldValue);
                        if (EEmpCostCenter.db.select(dbConn, obj))
                        {
                            return(GetValueFromID(dbConn, "EmpID", obj.EmpID.ToString()));
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("EmpExtraFieldID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EEmpExtraField obj = new EEmpExtraField();
                        obj.EmpExtraFieldID = int.Parse(fieldValue);
                        if (EEmpExtraField.db.select(dbConn, obj))
                        {
                            return(obj.EmpExtraFieldName);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("EmpID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EEmpPersonalInfo obj = new EEmpPersonalInfo();
                        obj.EmpID = int.Parse(fieldValue);
                        if (EEmpPersonalInfo.db.select(dbConn, obj))
                        {
                            return(obj.EmpNo + " - " + obj.EmpEngFullName);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("EmpPayrollID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EEmpPayroll obj = new EEmpPayroll();
                        obj.EmpPayrollID = int.Parse(fieldValue);
                        if (EEmpPayroll.db.select(dbConn, obj))
                        {
                            return(GetValueFromID(dbConn, "EmpID", obj.EmpID.ToString()) + " : " + GetValueFromID(dbConn, "PayPeriodID", obj.PayPeriodID.ToString()));
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("EmpPosID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EEmpPositionInfo obj = new EEmpPositionInfo();
                        obj.EmpPosID = int.Parse(fieldValue);
                        if (EEmpPositionInfo.db.select(dbConn, obj))
                        {
                            return(obj.EmpPosEffFr.ToString("yyyy-MM-dd") + " - " + (obj.EmpPosEffTo.Ticks.Equals(0) ? "Present" : obj.EmpPosEffTo.ToString("yyyy-MM-dd")));
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("EmploymentTypeID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EEmploymentType obj = new EEmploymentType();
                        obj.EmploymentTypeID = int.Parse(fieldValue);
                        if (EEmploymentType.db.select(dbConn, obj))
                        {
                            return(obj.EmploymentTypeCode + " - " + obj.EmploymentTypeDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
                else if (tmpfieldName.StartsWith("F", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpfieldName.Equals("FunctionID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ESystemFunction obj = new ESystemFunction();
                        obj.FunctionID = int.Parse(fieldValue);
                        if (ESystemFunction.db.select(dbConn, obj))
                        {
                            return(obj.FunctionCode + " - " + obj.Description);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
                else if (tmpfieldName.StartsWith("H", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpfieldName.Equals("HElementID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EHierarchyElement obj = new EHierarchyElement();
                        obj.HElementID = int.Parse(fieldValue);
                        if (EHierarchyElement.db.select(dbConn, obj))
                        {
                            return(obj.HElementCode + " - " + obj.HElementDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("HLevelID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EHierarchyLevel obj = new EHierarchyLevel();
                        obj.HLevelID = int.Parse(fieldValue);
                        if (EHierarchyLevel.db.select(dbConn, obj))
                        {
                            return(obj.HLevelCode + " - " + obj.HLevelDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
                else if (tmpfieldName.StartsWith("L", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpfieldName.Equals("LeaveTypeID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ELeaveType obj = new ELeaveType();
                        obj.LeaveTypeID = int.Parse(fieldValue);
                        if (ELeaveType.db.select(dbConn, obj))
                        {
                            return(obj.LeaveType + " - " + obj.LeaveTypeDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("LeaveCodeID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ELeaveCode obj = new ELeaveCode();
                        obj.LeaveCodeID = int.Parse(fieldValue);
                        if (ELeaveCode.db.select(dbConn, obj))
                        {
                            return(obj.LeaveCode + " - " + obj.LeaveCodeDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("LeavePlanID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ELeavePlan obj = new ELeavePlan();
                        obj.LeavePlanID = int.Parse(fieldValue);
                        if (ELeavePlan.db.select(dbConn, obj))
                        {
                            return(obj.LeavePlanCode + " - " + obj.LeavePlanDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
                else if (tmpfieldName.StartsWith("M", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpfieldName.Equals("MPFPlanID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EMPFPlan obj = new EMPFPlan();
                        obj.MPFPlanID = int.Parse(fieldValue);
                        if (EMPFPlan.db.select(dbConn, obj))
                        {
                            return(obj.MPFPlanCode + " - " + obj.MPFPlanDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }

                    if (tmpfieldName.Equals("MPFSchemeID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EMPFScheme obj = new EMPFScheme();
                        obj.MPFSchemeID = int.Parse(fieldValue);
                        if (EMPFScheme.db.select(dbConn, obj))
                        {
                            return(obj.MPFSchemeCode + " - " + obj.MPFSchemeDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("MPFSchemeCessationReasonID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EMPFSchemeCessationReason obj = new EMPFSchemeCessationReason();
                        obj.MPFSchemeCessationReasonID = int.Parse(fieldValue);
                        if (EMPFSchemeCessationReason.db.select(dbConn, obj))
                        {
                            return(obj.MPFSchemeCessationReasonCode + " - " + obj.MPFSchemeCessationReasonDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
                else if (tmpfieldName.StartsWith("O", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpfieldName.Equals("ORSOPlanID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EORSOPlan obj = new EORSOPlan();
                        obj.ORSOPlanID = int.Parse(fieldValue);
                        if (EORSOPlan.db.select(dbConn, obj))
                        {
                            return(obj.ORSOPlanCode + " - " + obj.ORSOPlanDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
                else if (tmpfieldName.StartsWith("P", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpfieldName.Equals("PayGroupID", StringComparison.CurrentCultureIgnoreCase) || tmpfieldName.Equals("PayrollGroupID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EPayrollGroup obj = new EPayrollGroup();
                        obj.PayGroupID = int.Parse(fieldValue);
                        if (EPayrollGroup.db.select(dbConn, obj))
                        {
                            return(obj.PayGroupCode + " - " + obj.PayGroupDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("PayFormID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EPayrollProrataFormula obj = new EPayrollProrataFormula();
                        obj.PayFormID = int.Parse(fieldValue);
                        if (EPayrollProrataFormula.db.select(dbConn, obj))
                        {
                            return(obj.PayFormCode + " - " + obj.PayFormDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("PaymentCodeID", StringComparison.CurrentCultureIgnoreCase) || tmpfieldName.Equals("PayCodeID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EPaymentCode obj = new EPaymentCode();
                        obj.PaymentCodeID = int.Parse(fieldValue);
                        if (EPaymentCode.db.select(dbConn, obj))
                        {
                            return(obj.PaymentCode + " - " + obj.PaymentCodeDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("PaymentTypeID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EPaymentType obj = new EPaymentType();
                        obj.PaymentTypeID = int.Parse(fieldValue);
                        if (EPaymentType.db.select(dbConn, obj))
                        {
                            return(obj.PaymentTypeCode + " - " + obj.PaymentTypeDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("PayPeriodID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EPayrollPeriod obj = new EPayrollPeriod();
                        obj.PayPeriodID = int.Parse(fieldValue);
                        if (EPayrollPeriod.db.select(dbConn, obj))
                        {
                            return(GetValueFromID(dbConn, "PayrollGroupID", obj.PayGroupID.ToString()) + ": " + obj.PayPeriodFr.ToString("yyyy-MM-dd") + " to " + obj.PayPeriodTo.ToString("yyyy-MM-dd"));
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("PermitTypeID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EPermitType obj = new EPermitType();
                        obj.PermitTypeID = int.Parse(fieldValue);
                        if (EPermitType.db.select(dbConn, obj))
                        {
                            return(obj.PermitTypeCode + " - " + obj.PermitTypeDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("PositionID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EPosition obj = new EPosition();
                        obj.PositionID = int.Parse(fieldValue);
                        if (EPosition.db.select(dbConn, obj))
                        {
                            return(obj.PositionCode + " - " + obj.PositionDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
                else if (tmpfieldName.StartsWith("Q", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpfieldName.Equals("QualificationID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EQualification obj = new EQualification();
                        obj.QualificationID = int.Parse(fieldValue);
                        if (EQualification.db.select(dbConn, obj))
                        {
                            return(obj.QualificationCode + " - " + obj.QualificationDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
                else if (tmpfieldName.StartsWith("R", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpfieldName.Equals("RankID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ERank obj = new ERank();
                        obj.RankID = int.Parse(fieldValue);
                        if (ERank.db.select(dbConn, obj))
                        {
                            return(obj.RankCode + " - " + obj.RankDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("ReminderTypeID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EReminderType obj = new EReminderType();
                        obj.ReminderTypeID = int.Parse(fieldValue);
                        if (EReminderType.db.select(dbConn, obj))
                        {
                            return(obj.ReminderTypeCode + " - " + obj.ReminderTypeDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("RosterClientID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ERosterClient obj = new ERosterClient();
                        obj.RosterClientID = int.Parse(fieldValue);
                        if (ERosterClient.db.select(dbConn, obj))
                        {
                            return(obj.RosterClientCode + " - " + obj.RosterClientName);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("RosterClientSiteID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ERosterClientSite obj = new ERosterClientSite();
                        obj.RosterClientSiteID = int.Parse(fieldValue);
                        if (ERosterClientSite.db.select(dbConn, obj))
                        {
                            return(obj.RosterClientSiteCode);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("RosterCodeID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ERosterCode obj = new ERosterCode();
                        obj.RosterCodeID = int.Parse(fieldValue);
                        if (ERosterCode.db.select(dbConn, obj))
                        {
                            return(obj.RosterCode + " - " + obj.RosterCodeDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
                else if (tmpfieldName.StartsWith("S", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpfieldName.Equals("SkillID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ESkill obj = new ESkill();
                        obj.SkillID = int.Parse(fieldValue);
                        if (ESkill.db.select(dbConn, obj))
                        {
                            return(obj.SkillCode + " - " + obj.SkillDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("SkillLevelID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ESkillLevel obj = new ESkillLevel();
                        obj.SkillLevelID = int.Parse(fieldValue);
                        if (ESkillLevel.db.select(dbConn, obj))
                        {
                            return(obj.SkillLevelCode + " - " + obj.SkillLevelDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("StaffTypeID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EStaffType obj = new EStaffType();
                        obj.StaffTypeID = int.Parse(fieldValue);
                        if (EStaffType.db.select(dbConn, obj))
                        {
                            return(obj.StaffTypeCode + " - " + obj.StaffTypeDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
                else if (tmpfieldName.StartsWith("T", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpfieldName.Equals("TaxCompID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ETaxCompany obj = new ETaxCompany();
                        obj.TaxCompID = int.Parse(fieldValue);
                        if (ETaxCompany.db.select(dbConn, obj))
                        {
                            return(obj.TaxCompEmployerName);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("TaxEmpID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ETaxEmp obj = new ETaxEmp();
                        obj.TaxEmpID = int.Parse(fieldValue);
                        if (ETaxEmp.db.select(dbConn, obj))
                        {
                            return(obj.TaxEmpSurname + ", " + obj.TaxEmpOtherName + ", " + GetValueFromID(dbConn, "TaxFormID", obj.TaxFormID.ToString()));
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("TaxFormID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ETaxForm obj = new ETaxForm();
                        obj.TaxFormID = int.Parse(fieldValue);
                        if (ETaxForm.db.select(dbConn, obj))
                        {
                            return("Tax Year :" + obj.TaxFormYear + ", Form: IR56" + obj.TaxFormType);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("TaxPayID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ETaxPayment obj = new ETaxPayment();
                        obj.TaxPayID = int.Parse(fieldValue);
                        if (ETaxPayment.db.select(dbConn, obj))
                        {
                            return(obj.TaxPayCode + " - " + obj.TaxPayDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("TrainingCourseID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ETrainingCourse obj = new ETrainingCourse();
                        obj.TrainingCourseID = int.Parse(fieldValue);
                        if (ETrainingCourse.db.select(dbConn, obj))
                        {
                            return(obj.TrainingCourseCode + " - " + obj.TrainingCourseName);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("TrainingSeminarID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ETrainingSeminar obj = new ETrainingSeminar();
                        obj.TrainingSeminarID = int.Parse(fieldValue);
                        if (ETrainingSeminar.db.select(dbConn, obj))
                        {
                            return(GetValueFromID(dbConn, "TrainingCourseID", obj.TrainingCourseID.ToString()) + ": " + obj.TrainingSeminarDateFrom.ToString("yyyy-MM-dd") + " to " + obj.TrainingSeminarDateTo.ToString("yyyy-MM-dd"));
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
                else if (tmpfieldName.StartsWith("U", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpfieldName.Equals("UserID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EUser obj = new EUser();
                        obj.UserID = int.Parse(fieldValue);
                        if (EUser.db.select(dbConn, obj))
                        {
                            return(obj.LoginID + " - " + obj.UserName);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    if (tmpfieldName.Equals("UserGroupID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EUserGroup obj = new EUserGroup();
                        obj.UserGroupID = int.Parse(fieldValue);
                        if (EUserGroup.db.select(dbConn, obj))
                        {
                            return(obj.UserGroupName + " - " + obj.UserGroupDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
                else if (tmpfieldName.StartsWith("Y", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpfieldName.Equals("YebPlanID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        EYEBPlan obj = new EYEBPlan();
                        obj.YEBPlanID = int.Parse(fieldValue);
                        if (EYEBPlan.db.select(dbConn, obj))
                        {
                            return(obj.YEBPlanCode + " - " + obj.YEBPlanDesc);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }

                if (tmpfieldName.EndsWith("ID") && !tmpfieldName.EndsWith("HKID") && !tmpfieldName.EndsWith("LoginID") && !tmpfieldName.EndsWith("CurrencyID") && !tmpfieldName.EndsWith("LeaveAppID") && !tmpfieldName.EndsWith("EmpPaymentID") && !tmpfieldName.EndsWith("PayBatchID") && !tmpfieldName.EndsWith("PayRecID") && !tmpfieldName.EndsWith("RosterTableID") && !tmpfieldName.EndsWith("SynID") && !tmpfieldName.EndsWith("CNDImportBatchID"))
                {
                    if (ESystemParameter.getParameter(dbConn, "DebugMode").Equals("Y"))
                    {
                        throw new Exception("ID field not define:" + fieldName);
                    }
                }
                return(string.Empty);
            }
            catch (Exception ex)
            {
                if (ESystemParameter.getParameter(dbConn, "DebugMode").Equals("Y"))
                {
                    throw ex;
                }
                else
                {
                    return(string.Empty);
                }
            }
        }
    protected void btnExport_Click(object sender, EventArgs e)
    {
        ArrayList list = WebUtils.SelectedRepeaterItemToBaseObjectList(ECostAllocation.db, Repeater, "ItemSelect");
        int       GroupingHierarchyLevelID   = 1;
        string    GroupingHierarchyLevelDesc = string.Empty;

        if (list.Count > 0)
        {
            string exportFileName = System.IO.Path.GetTempFileName();
            System.IO.File.Delete(exportFileName);
            exportFileName += ".xls";
            //System.IO.File.Copy(Server.MapPath("~/template/HistoryList_Template.xls"), exportFileName, true);
            HROne.Export.ExcelExport export = new HROne.Export.ExcelExport(exportFileName);
            DataSet dataSet = new DataSet();//export.GetDataSet();

            CreateSummaryDataTable(dataSet);

            DBFilter  hierarchyLevelFilter    = new DBFilter();
            Hashtable hierarchyLevelHashTable = new Hashtable();
            hierarchyLevelFilter.add("HLevelSeqNo", true);
            ArrayList hierarchyLevelList = EHierarchyLevel.db.select(dbConn, hierarchyLevelFilter);
            foreach (EHierarchyLevel hlevel in hierarchyLevelList)
            {
                if (string.IsNullOrEmpty(GroupingHierarchyLevelDesc))
                {
                    GroupingHierarchyLevelID   = hlevel.HLevelID;
                    GroupingHierarchyLevelDesc = hlevel.HLevelDesc.Trim();
                }
                hierarchyLevelHashTable.Add(hlevel.HLevelID, hlevel);
            }

            foreach (ECostAllocation obj in list)
            {
                if (ECostAllocation.db.select(dbConn, obj))
                {
                    EEmpPayroll empPayroll = new EEmpPayroll();
                    empPayroll.EmpPayrollID = obj.EmpPayrollID;
                    EEmpPayroll.db.select(dbConn, empPayroll);

                    EPayrollPeriod payPeriod = new EPayrollPeriod();
                    payPeriod.PayPeriodID = empPayroll.PayPeriodID;
                    EPayrollPeriod.db.select(dbConn, payPeriod);

                    EPayrollGroup payGroup = new EPayrollGroup();
                    payGroup.PayGroupID = payPeriod.PayGroupID;
                    EPayrollGroup.db.select(dbConn, payGroup);

                    EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
                    empInfo.EmpID = obj.EmpID;
                    EEmpPersonalInfo.db.select(dbConn, empInfo);



                    DBFilter costAllocationDetailFilter = new DBFilter();
                    costAllocationDetailFilter.add(new Match("CostAllocationID", obj.CostAllocationID));

                    ArrayList costAllocationDetailList = ECostAllocationDetail.db.select(dbConn, costAllocationDetailFilter);

                    foreach (ECostAllocationDetail detail in costAllocationDetailList)
                    {
                        ECompany company = new ECompany();
                        company.CompanyID = detail.CompanyID;
                        ECompany.db.select(dbConn, company);

                        ECostCenter costCenter = new ECostCenter();
                        costCenter.CostCenterID = detail.CostCenterID;
                        ECostCenter.db.select(dbConn, costCenter);

                        int    HElementID   = 0;
                        string hElementDesc = string.Empty;

                        DBFilter costAllocationDetailHierarchyFilter = new DBFilter();
                        costAllocationDetailHierarchyFilter.add(new Match("CostAllocationDetailID", detail.CostAllocationDetailID));


                        ArrayList empHierarchyList = ECostAllocationDetailHElement.db.select(dbConn, costAllocationDetailHierarchyFilter);
                        foreach (ECostAllocationDetailHElement empHierarchy in empHierarchyList)
                        {
                            EHierarchyLevel hierarchyLevel = (EHierarchyLevel)hierarchyLevelHashTable[empHierarchy.HLevelID];
                            if (hierarchyLevel != null)
                            {
                                EHierarchyElement hierarchyElement = new EHierarchyElement();
                                hierarchyElement.HElementID = empHierarchy.HElementID;
                                if (EHierarchyElement.db.select(dbConn, hierarchyElement))
                                {
                                    //  Select first hierarchy for testing
                                    if (hierarchyLevel.HLevelDesc.Equals(GroupingHierarchyLevelDesc.Trim()) && HElementID == 0)
                                    {
                                        HElementID   = hierarchyElement.HElementID;
                                        hElementDesc = hierarchyElement.HElementDesc;
                                    }
                                }
                            }
                        }

                        DataTable hierarchyTable    = dataSet.Tables["hierarchy"];
                        DataTable paymentTable      = dataSet.Tables["payment"];
                        DataTable contributionTable = dataSet.Tables["contribution"];
                        DataRow[] rows           = hierarchyTable.Select("CompanyID=" + company.CompanyID + " and PayGroupID=" + payGroup.PayGroupID + " and HElementID=" + HElementID + " and CostCenterID=" + detail.CostCenterID);
                        int       hierarchyRowID = 0;
                        if (rows.Length == 0)
                        {
                            hierarchyRowID = hierarchyTable.Rows.Count + 1;
                            DataRow hierarchyRow = hierarchyTable.NewRow();
                            hierarchyRow["ID"]               = hierarchyRowID;
                            hierarchyRow["Company"]          = company.CompanyName;
                            hierarchyRow["PayrollGroupDesc"] = payGroup.PayGroupDesc;
                            hierarchyRow["HierarchyDesc"]    = hElementDesc;
                            hierarchyRow["CostCenterDesc"]   = costCenter.CostCenterDesc;
                            hierarchyRow["CompanyID"]        = company.CompanyID;
                            hierarchyRow["hElementID"]       = HElementID;
                            hierarchyRow["CostCenterID"]     = costCenter.CostCenterID;
                            hierarchyRow["PayGroupID"]       = payGroup.PayGroupID;
                            hierarchyTable.Rows.Add(hierarchyRow);
                        }
                        else
                        {
                            hierarchyRowID = (int)rows[0]["ID"];
                        }


                        EPaymentCode paymentCode = new EPaymentCode();
                        paymentCode.PaymentCodeID = detail.PaymentCodeID;
                        EPaymentCode.db.select(dbConn, paymentCode);

                        if (!detail.CostAllocationDetailIsContribution)
                        {
                            if (!paymentTable.Columns.Contains(paymentCode.PaymentCodeDesc.Trim()))
                            {
                                paymentTable.Columns.Add(paymentCode.PaymentCodeDesc.Trim(), typeof(double));
                            }

                            rows = paymentTable.Select("ID=" + hierarchyRowID);
                            DataRow paymentRow;
                            if (rows.Length == 0)
                            {
                                paymentRow       = paymentTable.NewRow();
                                paymentRow["ID"] = hierarchyRowID;
                                paymentTable.Rows.Add(paymentRow);
                            }
                            else
                            {
                                paymentRow = rows[0];
                            }
                            if (paymentRow.IsNull(paymentCode.PaymentCodeDesc.Trim()))
                            {
                                paymentRow[paymentCode.PaymentCodeDesc.Trim()] = detail.CostAllocationDetailAmount;
                            }
                            else
                            {
                                paymentRow[paymentCode.PaymentCodeDesc.Trim()] = (double)paymentRow[paymentCode.PaymentCodeDesc.Trim()] + detail.CostAllocationDetailAmount;
                            }
                        }
                        else
                        {
                            rows = contributionTable.Select("ID=" + hierarchyRowID);
                            DataRow contributionRow;
                            if (rows.Length == 0)
                            {
                                contributionRow            = contributionTable.NewRow();
                                contributionRow["ID"]      = hierarchyRowID;
                                contributionRow["MCEE"]    = 0;
                                contributionRow["MCER"]    = 0;
                                contributionRow["VCEE"]    = 0;
                                contributionRow["VCER"]    = 0;
                                contributionRow["PFUNDEE"] = 0;
                                contributionRow["PFUNDER"] = 0;
                                contributionTable.Rows.Add(contributionRow);
                            }
                            else
                            {
                                contributionRow = rows[0];
                            }
                            if (paymentCode.PaymentTypeID.Equals(EPaymentType.SystemPaymentType.MPFEmployeeMandatoryContributionPaymentType(dbConn).PaymentTypeID))
                            {
                                contributionRow["MCEE"] = (double)contributionRow["MCEE"] + detail.CostAllocationDetailAmount;
                            }
                            else if (paymentCode.PaymentTypeID.Equals(EPaymentType.SystemPaymentType.MPFEmployeeVoluntaryContributionPaymentType(dbConn).PaymentTypeID))
                            {
                                contributionRow["VCEE"] = (double)contributionRow["VCEE"] + detail.CostAllocationDetailAmount;
                            }
                            else if (paymentCode.PaymentTypeID.Equals(EPaymentType.SystemPaymentType.MPFEmployerMandatoryContributionPaymentType(dbConn).PaymentTypeID))
                            {
                                contributionRow["MCER"] = (double)contributionRow["MCER"] + detail.CostAllocationDetailAmount;
                            }
                            else if (paymentCode.PaymentTypeID.Equals(EPaymentType.SystemPaymentType.MPFEmployerVoluntaryContributionPaymentType(dbConn).PaymentTypeID))
                            {
                                contributionRow["VCER"] = (double)contributionRow["VCER"] + detail.CostAllocationDetailAmount;
                            }
                            else if (paymentCode.PaymentTypeID.Equals(EPaymentType.SystemPaymentType.PFundEmployeeContributionPaymentType(dbConn).PaymentTypeID))
                            {
                                contributionRow["PFUNDEE"] = (double)contributionRow["PFUNDEE"] + detail.CostAllocationDetailAmount;
                            }
                            else if (paymentCode.PaymentTypeID.Equals(EPaymentType.SystemPaymentType.PFundEmployerContributionPaymentType(dbConn).PaymentTypeID))
                            {
                                contributionRow["PFUNDER"] = (double)contributionRow["PFUNDER"] + detail.CostAllocationDetailAmount;
                            }
                        }
                    }
                }
            }
            GenerateExcelReport(dataSet, exportFileName);
            //export.Update(dataSet);
            WebUtils.TransmitFile(Response, exportFileName, "CostALlocation" + (CostAllocationStatus.SelectedValue.Equals("T") ? "Trial" : "Confirm") + "_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + ".xls", true);
            Response.End();
        }

        else
        {
            PageErrors errors = PageErrors.getErrors(db, Page.Master);
            errors.addError("Employee not selected");
        }

        view = loadData(info, EEmpPayroll.db, Repeater);
    }
コード例 #20
0
        protected DataTable LoadORSODetail()
        {
            DataTable _table = new DataSet.Payroll_MPFRemittanceStatement.ExistingMemberDataTable();

            DBFilter _payPeriodFilter = new DBFilter();

            _payPeriodFilter.add(new Match("PayPeriodFr", "<=", this.PayPeriodTo));
            _payPeriodFilter.add(new Match("PayPeriodTo", ">=", this.PayPeriodFr));

            DBFilter _empPayrollFilter = new DBFilter();

            _empPayrollFilter.add(new IN("PayPeriodID", "SELECT PayPeriodID FROM PayrollPeriod", _payPeriodFilter));

            DBFilter _orsoRecordFilter = new DBFilter();

            _orsoRecordFilter.add(new Match("ORSOPlanID", this.ORSOPlanID));
            _orsoRecordFilter.add(new IN("EmpPayrollID", "SELECT EmpPayrollID FROM EmpPayroll", _empPayrollFilter));

            foreach (EORSORecord _orsoRecord in EORSORecord.db.select(dbConn, _orsoRecordFilter))
            {
                DataRow _newRow = _table.NewRow();

                EEmpPayroll      _payroll = EEmpPayroll.GetObject(dbConn, _orsoRecord.EmpPayrollID);
                EEmpPersonalInfo _empInfo = EEmpPersonalInfo.GetObject(dbConn, _payroll.EmpID);

                _newRow["EmpID"]          = _empInfo.EmpID;
                _newRow["MPFPlanID"]      = _orsoRecord.ORSOPlanID;
                _newRow["EmpNo"]          = _empInfo.EmpNo;
                _newRow["EmpName"]        = _empInfo.EmpEngFullName;
                _newRow["SchemeJoinDate"] = _empInfo.EmpDateOfJoin;

                if (string.IsNullOrEmpty(_empInfo.EmpHKID))
                {
                    _newRow["HKID"] = _empInfo.EmpPassportNo;
                }
                else
                {
                    _newRow["HKID"] = _empInfo.EmpHKID;
                }

                _newRow["PeriodFrom"] = _orsoRecord.ORSORecPeriodFr;
                _newRow["PeriodTo"]   = _orsoRecord.ORSORecPeriodTo;

                _newRow["RelevantIncome"] = 0; //_orsoRecord.ORSORecActRI;
                _newRow["MCEE"]           = _orsoRecord.ORSORecActEE;
                _newRow["MCER"]           = _orsoRecord.ORSORecActER;
                _newRow["VCEE"]           = 0;
                _newRow["VCER"]           = 0;

                EEmpTermination _empTermination = EEmpTermination.GetObjectByEmpID(dbConn, _empInfo.EmpID);
                if (_empTermination != null && _empTermination.EmpTermLastDate.Ticks != 0)
                {
                    _newRow["LastEmploymentDate"] = _empTermination.EmpTermLastDate;
                    _newRow["IsBackPayRecord"]    = (_empTermination.EmpTermLastDate > this.PayPeriodFr);
                }
                else
                {
                    _newRow["LastEmploymentDate"] = DBNull.Value;
                    _newRow["IsBackPayRecord"]    = false;
                }
                _newRow["IsLSP"]               = false;
                _newRow["IsSP"]                = false;
                _newRow["LSPSPAmount"]         = 0;
                _newRow["LSPSPAmountPaidByER"] = 0;

                _table.Rows.Add(_newRow);
            }
            return(_table);
        }
コード例 #21
0
    protected void Repeater_ItemCommand(object source, DataListCommandEventArgs e)
    {
        Button b = (Button)e.CommandSource;



        if (b.ID.Equals("Edit"))
        {
            Repeater.EditItemIndex = e.Item.ItemIndex;
            //AddPanel.Visible = false;
            view = loadData(info, db, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, false);
        }
        else if (b.ID.Equals("Cancel"))
        {
            Repeater.EditItemIndex = -1;
            //AddPanel.Visible = IsAllowEdit;
            view = loadData(info, db, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, true);
        }
        else if (b.ID.Equals("Save"))
        {
            Binding eBinding;

            //  Hard code set Currency to HKD
            ((DropDownList)e.Item.FindControl("CurrencyID")).SelectedValue = "HKD";

            eBinding = new Binding(dbConn, db);
            eBinding.add(EmpPayrollID);
            eBinding.add((HtmlInputHidden)e.Item.FindControl("PayRecID"));
            eBinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("CurrencyID"), Values.VLCurrency));
            if (((DropDownList)e.Item.FindControl("PaymentCodeID")).Enabled)
            {
                eBinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("PaymentCodeID"), EPaymentCode.VLPaymentCode));
            }
            if (((TextBox)e.Item.FindControl("PayRecActAmount")).Enabled)
            {
                eBinding.add((TextBox)e.Item.FindControl("PayRecActAmount"));
            }
            if (((TextBox)e.Item.FindControl("PayRecNumOfDayAdj")).Enabled)
            {
                eBinding.add((TextBox)e.Item.FindControl("PayRecNumOfDayAdj"));
            }
            if (((TextBox)e.Item.FindControl("PayRecRemark")).Enabled)
            {
                eBinding.add((TextBox)e.Item.FindControl("PayRecRemark"));
            }
            eBinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("CostCenterID"), ECostCenter.VLCostCenter).setNotSelected(HROne.Common.WebUtility.GetLocalizedString(ECostCenter.DEFAULT_COST_CENTER_TEXT)));
            eBinding.add(new CheckBoxBinder(db, (CheckBox)e.Item.FindControl("PayRecIsRestDayPayment")));

            eBinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("PayRecMethod"), Values.VLPaymentMethod).setNotSelected(null));

            //DBFilter filter = new DBFilter();
            //DBFilter inFilter = new DBFilter();
            //inFilter.add(new Match("EmpPayrollID", EmpPayrollID.Value));
            //filter.add(new IN("EmpID", "Select EmpID from EmpPayroll", inFilter));
            eBinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("EmpAccID"), EEmpBankAccount.VLBankAccount, empBankAccountFilter).setNotSelected(HROne.Common.WebUtility.GetLocalizedString(EEmpBankAccount.DEFAULT_BANK_ACCOUNT_TEXT)));

            eBinding.init(Request, Session);


            EPaymentRecord obj    = new EPaymentRecord();
            Hashtable      values = new Hashtable();

            PageErrors errors = PageErrors.getErrors(db, Page.Master);
            errors.clear();


            eBinding.toValues(values);
            db.validate(errors, values);

            if (!errors.isEmpty())
            {
                HROne.Common.WebUtility.WebControlsLocalization(Session, e.Item.Controls);
                return;
            }

            db.parse(values, obj);

            EEmpPayroll empPayroll = new EEmpPayroll();
            empPayroll.EmpPayrollID = obj.EmpPayrollID;
            if (EEmpPayroll.db.select(dbConn, empPayroll))
            {
                if (obj.PayRecMethod.Equals("A"))
                {
                    if (obj.EmpAccID == 0)
                    {
                        EEmpBankAccount bankAccount = EEmpBankAccount.GetDefaultBankAccount(dbConn, empPayroll.EmpID);
                        if (bankAccount != null)
                        {
                            //obj.EmpAccID = bankAccount.EmpBankAccountID;
                        }
                        else
                        {
                            errors.addError("EmpAccID", HROne.Translation.PageErrorMessage.ERROR_ACCOUNT_REQUIRED);
                        }
                    }
                }

                if (!errors.isEmpty())
                {
                    HROne.Common.WebUtility.WebControlsLocalization(Session, e.Item.Controls);
                    return;
                }

                WebUtils.StartFunction(Session, m_FunctionCode, empPayroll.EmpID);
                db.update(dbConn, obj);
                WebUtils.EndFunction(dbConn);

                Repeater.EditItemIndex = -1;
                //AddPanel.Visible = IsAllowEdit;
                view = loadData(info, db, Repeater);
                WebUtils.SetEnabledControlSection(AddPanel, true);
            }

            //Response.Redirect(Request.Url.LocalPath + "?" + Request.QueryString);
        }
    }
コード例 #22
0
        public void TrialRun(int EmpPayrollID, EUser user)
        {
            EEmpPayroll empPayroll = new EEmpPayroll();

            empPayroll.EmpPayrollID = EmpPayrollID;
            if (EEmpPayroll.db.select(dbConn, empPayroll))
            {
                EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
                empInfo.EmpID = empPayroll.EmpID;
                if (EEmpPersonalInfo.db.select(dbConn, empInfo))
                {
                    EPayrollPeriod payPeriod = new EPayrollPeriod();
                    payPeriod.PayPeriodID = empPayroll.PayPeriodID;
                    if (EPayrollPeriod.db.select(dbConn, payPeriod))
                    {
                        DateTime startDate = payPeriod.PayPeriodFr;
                        DateTime endDate   = payPeriod.PayPeriodTo;

                        if (empInfo.EmpDateOfJoin > payPeriod.PayPeriodFr && empInfo.EmpDateOfJoin < payPeriod.PayPeriodTo)
                        {
                            startDate = empInfo.EmpDateOfJoin;
                        }

                        DBFilter empTerminationFilter = new DBFilter();
                        empTerminationFilter.add(new Match("EmpID", empPayroll.EmpID));
                        ArrayList empTerminationList = EEmpTermination.db.select(dbConn, empTerminationFilter);
                        foreach (EEmpTermination empTerm in empTerminationList)
                        {
                            if (empTerm.EmpTermLastDate > payPeriod.PayPeriodFr && empTerm.EmpTermLastDate < payPeriod.PayPeriodTo)
                            {
                                endDate = empTerm.EmpTermLastDate;
                            }
                        }

                        DBFilter empPosFilter = new DBFilter();
                        empPosFilter.add(new Match("EmpID", empPayroll.EmpID));
                        empPosFilter.add(new Match("EmpPosEffFr", "<=", payPeriod.PayPeriodTo));
                        OR orEmpPosEffToTerms = new OR();
                        orEmpPosEffToTerms.add(new Match("EmpPosEffTo", ">=", payPeriod.PayPeriodFr));
                        orEmpPosEffToTerms.add(new NullTerm("EmpPosEffTo"));
                        empPosFilter.add(orEmpPosEffToTerms);
                        empPosFilter.add(new Match("PayGroupID", payPeriod.PayGroupID));

                        ArrayList empPosList = EEmpPositionInfo.db.select(dbConn, empPosFilter);

                        DBFilter empCostCenterFilter = new DBFilter();
                        empCostCenterFilter.add(new Match("EmpID", empPayroll.EmpID));
                        empCostCenterFilter.add(new Match("EmpCostCenterEffFr", "<=", payPeriod.PayPeriodTo));
                        OR orEmpCostCenterEffToTerms = new OR();
                        orEmpCostCenterEffToTerms.add(new Match("EmpCostCenterEffTo", ">=", payPeriod.PayPeriodFr));
                        orEmpCostCenterEffToTerms.add(new NullTerm("EmpCostCenterEffTo"));
                        empCostCenterFilter.add(orEmpCostCenterEffToTerms);

                        ArrayList empCostCenterList = EEmpCostCenter.db.select(dbConn, empCostCenterFilter);



                        ArrayList costAllocationDetailList          = new ArrayList();
                        ArrayList costAllocationDetailHierarchyLIst = new ArrayList();

                        DBFilter paymentRecordFilter = new DBFilter();
                        paymentRecordFilter.add(new Match("EmpPayrollID", EmpPayrollID));

                        ArrayList paymentRecordList = EPaymentRecord.db.select(dbConn, paymentRecordFilter);

                        if (empCostCenterList.Count == 0 && paymentRecordList.Count > 0)
                        {
                            errorLogBuiler.AppendLine(
                                string.Format(
                                    HROne.Common.WebUtility.GetLocalizedStringByCode(MESSAGE_COST_CENTER_NOT_FOUND, "Cost Center for Employee ({0}) has not been set.")
                                    , new string[] { empInfo.EmpNo })
                                );
                            return;
                        }

                        foreach (EPaymentRecord paymentRecord in paymentRecordList)
                        {
                            try
                            {
                                costAllocationDetailList.AddRange(CreateCostAllocationRecordList(startDate, endDate, empPosList, empCostCenterList, paymentRecord.PaymentCodeID, paymentRecord.PayRecActAmount, paymentRecord.PayRecID, false, paymentRecord.CostCenterID));
                            }
                            catch (Exception e)
                            {
                                errorLogBuiler.AppendLine(
                                    string.Format(
                                        e.Message
                                        , new string[] { empInfo.EmpNo })
                                    );
                            }
                            //ArrayList costAllocationDetailListByPaymentRecord = new ArrayList();
                            //int daysTotal = 0;
                            //foreach (EEmpPositionInfo empPos in empPosList)
                            //{
                            //    DateTime posStartDate = startDate;
                            //    DateTime posEndDate = endDate;

                            //    if (empPos.EmpPosEffFr > posStartDate)
                            //        posStartDate = empPos.EmpPosEffFr;

                            //    if (empPos.EmpPosEffTo < posEndDate && empPos.EmpPosEffTo > posStartDate)
                            //        posEndDate = empPos.EmpPosEffTo;

                            //    DBFilter empHierarchyElementFilter = new DBFilter();
                            //    empHierarchyElementFilter.add(new Match("EmpPosID", empPos.EmpPosID));
                            //    ArrayList empHiererchyElementList = EEmpHierarchy.db.select(dbConn, empHierarchyElementFilter);

                            //    double percentagePaymentTotal = 0;

                            //    foreach (EEmpCostCenter empCostCenter in empCostCenterList)
                            //    {
                            //        DateTime costStartDate = posStartDate;
                            //        DateTime costEndDate = posEndDate;

                            //        if (empCostCenter.EmpCostCenterEffFr > costStartDate)
                            //            costStartDate = empCostCenter.EmpCostCenterEffFr;

                            //        if (empCostCenter.EmpCostCenterEffTo < costEndDate && empCostCenter.EmpCostCenterEffTo > costStartDate)
                            //            costEndDate = empCostCenter.EmpCostCenterEffTo;

                            //        if (costStartDate > costEndDate)
                            //            continue;

                            //        int numOfDays = ((TimeSpan)costEndDate.Subtract(costStartDate)).Days;
                            //        daysTotal += numOfDays;

                            //        DBFilter empCostCenterDetailFilter = new DBFilter();
                            //        empCostCenterDetailFilter.add(new Match("EmpCostCenterID", empCostCenter.EmpCostCenterID));
                            //        ArrayList empCostCenterDetailList = EEmpCostCenterDetail.db.select(dbConn, empCostCenterDetailFilter);

                            //        double percentageCostCenterTotal = 0;
                            //        foreach (EEmpCostCenterDetail empCostCenterDetail in empCostCenterDetailList)
                            //        {

                            //            ECostAllocationDetail costAllocDetail = new ECostAllocationDetail();
                            //            costAllocDetail.CostCenterID = empCostCenterDetail.CostCenterID;
                            //            costAllocDetail.CostAllocationDetailRoundCalAmount = paymentRecord.PayRecActAmount * daysTotal * empCostCenterDetail.EmpCostCenterPercentage;
                            //            costAllocDetail.PaymentCodeID = paymentRecord.PaymentCodeID;
                            //            costAllocDetail.PayRecID = paymentRecord.PayRecID;
                            //            costAllocDetail.CompanyID = empPos.CompanyID;
                            //            costAllocationDetailListByPaymentRecord.Add(costAllocDetail);

                            //            foreach (EEmpHierarchy empHierarchy in empHiererchyElementList)
                            //            {
                            //                ECostAllocationDetailHElement costAllocHierarchy = new ECostAllocationDetailHElement();
                            //                costAllocHierarchy.HElementID = empHierarchy.HElementID;
                            //                costAllocHierarchy.HLevelID = empHierarchy.HLevelID;
                            //                costAllocHierarchy.RelatedCostAllocationDetailObject = costAllocDetail;
                            //                costAllocationDetailHierarchyLIst.Add(costAllocHierarchy);
                            //            }

                            //            percentageCostCenterTotal += empCostCenterDetail.EmpCostCenterPercentage;


                            //        }

                            //        if (Math.Round(Math.Abs(percentageCostCenterTotal - 100), 2, MidpointRounding.AwayFromZero) > 0)
                            //        {
                            //            errorLogBuiler.AppendLine(
                            //                string.Format(
                            //                HROne.Common.WebUtility.GetLocalizedStringByCode(MESSAGE_NOT_100_PERCENTAGE, "Total Percentage of Employee ({0}) is not 100%.")
                            //                , new string[] { empInfo.EmpNo })
                            //            );
                            //        }
                            //    }

                            //}

                            ////SortedList sortedCostAllocationDetailbyDecimalPlaceRoundDown = new SortedList();
                            ////SortedList sortedCostAllocationDetailbyDecimalPlaceRoundUp = new SortedList();

                            //double totalCostAllocPayment = 0;
                            //foreach (ECostAllocationDetail costAllocationDetail in costAllocationDetailListByPaymentRecord)
                            //{
                            //    costAllocationDetail.CostAllocationDetailRoundCalAmount = costAllocationDetail.CostAllocationDetailRoundCalAmount / (100 * daysTotal);
                            //    costAllocationDetail.CostAllocationDetailAmount = Math.Round(costAllocationDetail.CostAllocationDetailRoundCalAmount, 2, MidpointRounding.AwayFromZero);
                            //    totalCostAllocPayment += costAllocationDetail.CostAllocationDetailAmount;

                            //    //sortedCostAllocationDetailbyDecimalPlaceRoundDown.Add(costAllocationDetail.CostAllocationDetailAmount - originalCostAllocationAmount, costAllocationDetail.CostAllocationDetailAmount);
                            //    //sortedCostAllocationDetailbyDecimalPlaceRoundUp.Add(originalCostAllocationAmount - costAllocationDetail.CostAllocationDetailAmount, costAllocationDetail.CostAllocationDetailAmount);

                            //}
                            //double diff = Math.Round(paymentRecord.PayRecActAmount - totalCostAllocPayment, 2, MidpointRounding.AwayFromZero);
                            //if (Math.Abs(diff) >= 0.01 && costAllocationDetailListByPaymentRecord.Count>0)
                            //{
                            //    if (diff > 0)
                            //    {
                            //        while (Math.Abs(diff) >= 0.01)
                            //        {
                            //            ECostAllocationDetail minCostAllocationDetail = null;
                            //            double minDiff = 1;
                            //            foreach (ECostAllocationDetail costAllocationDetail in costAllocationDetailListByPaymentRecord)
                            //            {
                            //                double costAllocDiff= costAllocationDetail.CostAllocationDetailAmount -costAllocationDetail.CostAllocationDetailRoundCalAmount;
                            //                if (costAllocDiff < minDiff)
                            //                {
                            //                    minDiff = costAllocDiff;
                            //                    minCostAllocationDetail = costAllocationDetail;
                            //                }
                            //            }
                            //            if (minCostAllocationDetail != null)
                            //            {
                            //                minCostAllocationDetail.CostAllocationDetailAmount += 0.01;
                            //                diff -= 0.01;
                            //            }
                            //        }
                            //    }
                            //    else
                            //    {
                            //        while (Math.Abs(diff) >= 0.01)
                            //        {
                            //            ECostAllocationDetail maxCostAllocationDetail = null;
                            //            double maxDiff = 1;
                            //            foreach (ECostAllocationDetail costAllocationDetail in costAllocationDetailListByPaymentRecord)
                            //            {
                            //                double costAllocDiff = costAllocationDetail.CostAllocationDetailAmount - costAllocationDetail.CostAllocationDetailRoundCalAmount;
                            //                if (costAllocDiff > maxDiff)
                            //                {
                            //                    maxDiff = costAllocDiff;
                            //                    maxCostAllocationDetail = costAllocationDetail;
                            //                }
                            //            }
                            //            if (maxCostAllocationDetail != null)
                            //            {
                            //                maxCostAllocationDetail.CostAllocationDetailAmount -= 0.01;
                            //                diff += 0.01;
                            //            }
                            //        }
                            //    }
                            //}
                            //costAllocationDetailList.AddRange(costAllocationDetailListByPaymentRecord);
                        }

                        ArrayList mpfRecordList = EMPFRecord.db.select(dbConn, paymentRecordFilter);

                        foreach (EMPFRecord mpfRecord in mpfRecordList)
                        {
                            try
                            {
                                ArrayList paymentList = PayrollProcess.GetPaymentCodeByPaymentType(dbConn, EPaymentType.SystemPaymentType.MPFEmployeeMandatoryContributionPaymentType(dbConn).PaymentTypeCode);
                                if (paymentList.Count > 0)
                                {
                                    costAllocationDetailList.AddRange(CreateCostAllocationRecordList(startDate, endDate, empPosList, empCostCenterList, ((EPaymentCode)paymentList[0]).PaymentCodeID, mpfRecord.MPFRecActMCEE, mpfRecord.MPFRecordID, true));
                                }
                                paymentList = PayrollProcess.GetPaymentCodeByPaymentType(dbConn, EPaymentType.SystemPaymentType.MPFEmployerMandatoryContributionPaymentType(dbConn).PaymentTypeCode);
                                if (paymentList.Count > 0)
                                {
                                    costAllocationDetailList.AddRange(CreateCostAllocationRecordList(startDate, endDate, empPosList, empCostCenterList, ((EPaymentCode)paymentList[0]).PaymentCodeID, mpfRecord.MPFRecActMCER, mpfRecord.MPFRecordID, true));
                                }
                                paymentList = PayrollProcess.GetPaymentCodeByPaymentType(dbConn, EPaymentType.SystemPaymentType.MPFEmployeeVoluntaryContributionPaymentType(dbConn).PaymentTypeCode);
                                if (paymentList.Count > 0)
                                {
                                    costAllocationDetailList.AddRange(CreateCostAllocationRecordList(startDate, endDate, empPosList, empCostCenterList, ((EPaymentCode)paymentList[0]).PaymentCodeID, mpfRecord.MPFRecActVCEE, mpfRecord.MPFRecordID, true));
                                }
                                paymentList = PayrollProcess.GetPaymentCodeByPaymentType(dbConn, EPaymentType.SystemPaymentType.MPFEmployerVoluntaryContributionPaymentType(dbConn).PaymentTypeCode);
                                if (paymentList.Count > 0)
                                {
                                    costAllocationDetailList.AddRange(CreateCostAllocationRecordList(startDate, endDate, empPosList, empCostCenterList, ((EPaymentCode)paymentList[0]).PaymentCodeID, mpfRecord.MPFRecActVCER, mpfRecord.MPFRecordID, true));
                                }
                            }
                            catch (Exception e)
                            {
                                errorLogBuiler.AppendLine(
                                    string.Format(
                                        e.Message
                                        , new string[] { empInfo.EmpNo })
                                    );
                            }
                        }

                        ArrayList orsoRecordList = EORSORecord.db.select(dbConn, paymentRecordFilter);

                        foreach (EORSORecord orsoRecord in orsoRecordList)
                        {
                            try
                            {
                                ArrayList paymentList = PayrollProcess.GetPaymentCodeByPaymentType(dbConn, EPaymentType.SystemPaymentType.PFundEmployeeContributionPaymentType(dbConn).PaymentTypeCode);
                                if (paymentList.Count > 0)
                                {
                                    costAllocationDetailList.AddRange(CreateCostAllocationRecordList(startDate, endDate, empPosList, empCostCenterList, ((EPaymentCode)paymentList[0]).PaymentCodeID, orsoRecord.ORSORecActEE, orsoRecord.ORSORecordID, true));
                                }
                                paymentList = PayrollProcess.GetPaymentCodeByPaymentType(dbConn, EPaymentType.SystemPaymentType.PFundEmployerContributionPaymentType(dbConn).PaymentTypeCode);
                                if (paymentList.Count > 0)
                                {
                                    costAllocationDetailList.AddRange(CreateCostAllocationRecordList(startDate, endDate, empPosList, empCostCenterList, ((EPaymentCode)paymentList[0]).PaymentCodeID, orsoRecord.ORSORecActER, orsoRecord.ORSORecordID, true));
                                }
                            }
                            catch (Exception e)
                            {
                                errorLogBuiler.AppendLine(
                                    string.Format(
                                        e.Message
                                        , new string[] { empInfo.EmpNo })
                                    );
                            }
                        }

                        ECostAllocation costAllocation = new ECostAllocation();
                        costAllocation.EmpID = empInfo.EmpID;
                        costAllocation.CostAllocationStatus       = "T";
                        costAllocation.CostAllocationTrialRunDate = AppUtils.ServerDateTime();
                        costAllocation.CostAllocationTrialRunBy   = user.UserID;
                        costAllocation.EmpPayrollID = EmpPayrollID;
                        ECostAllocation.db.insert(dbConn, costAllocation);
                        foreach (ECostAllocationDetail costAllocationDetail in costAllocationDetailList)
                        {
                            costAllocationDetail.CostAllocationID = costAllocation.CostAllocationID;
                            ECostAllocationDetail.db.insert(dbConn, costAllocationDetail);
                            foreach (ECostAllocationDetailHElement costAllocationDetailHierarchy in costAllocationDetail.HierarchyElementList)
                            {
                                costAllocationDetailHierarchy.CostAllocationDetailID = costAllocationDetail.CostAllocationDetailID;
                                ECostAllocationDetailHElement.db.insert(dbConn, costAllocationDetailHierarchy);
                            }
                        }
                    }
                }
            }
        }
コード例 #23
0
    protected void Repeater_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        Binding ebinding;

        EClaimsAndDeductions obj = new EClaimsAndDeductions();

        db.toObject(((DataRowView)e.Item.DataItem).Row, obj);

        if (e.Item.ItemIndex == Repeater.EditItemIndex)
        {
            ebinding = new Binding(dbConn, db);
            ebinding.add(new TextBoxBinder(db, ((WebDatePicker)e.Item.FindControl("CNDEffDate")).TextBox, "CNDEffDate"));
            ebinding.add((HtmlInputHidden)e.Item.FindControl("CNDID"));
            ebinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("PayCodeID"), EPaymentCode.VLPaymentCode));
            ebinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("CurrencyID"), Values.VLCurrency));
            ebinding.add((TextBox)e.Item.FindControl("CNDAmount"));
            ebinding.add(new CheckBoxBinder(db, (CheckBox)e.Item.FindControl("CNDIsRestDayPayment")));
            ebinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("CNDPayMethod"), Values.VLPaymentMethod).setNotSelected(null));
            ebinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("CostCenterID"), ECostCenter.VLCostCenter).setNotSelected(HROne.Common.WebUtility.GetLocalizedString(ECostCenter.DEFAULT_COST_CENTER_TEXT)));
            ebinding.add((TextBox)e.Item.FindControl("CNDNumOfDayAdj"));
            ebinding.add((TextBox)e.Item.FindControl("CNDRemark"));

            DBFilter empBankAccountFilter = new DBFilter();
            OR       bankAccountORTerm    = new OR();
            bankAccountORTerm.add(new Match("EmpID", CurID));
            {
                EEmpPersonalInfo tmpEmpInfo = new EEmpPersonalInfo();
                tmpEmpInfo.EmpID = CurID;
                if (EEmpPersonalInfo.db.select(dbConn, tmpEmpInfo) && tmpEmpInfo.MasterEmpID > 0)
                {
                    bankAccountORTerm.add(new Match("EmpID", tmpEmpInfo.MasterEmpID));
                }
            }
            empBankAccountFilter.add(bankAccountORTerm);
            ebinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("EmpAccID"), EEmpBankAccount.VLBankAccount, empBankAccountFilter).setNotSelected(HROne.Common.WebUtility.GetLocalizedString(EEmpBankAccount.DEFAULT_BANK_ACCOUNT_TEXT)));



            ebinding.init(Request, Session);

            Hashtable values = new Hashtable();
            db.populate(obj, values);

            ebinding.toControl(values);

            ((HtmlTableCell)e.Item.FindControl("CostCenterDetailCell")).Visible = WebUtils.productLicense(Session).IsCostCenter;
            ((HtmlTableCell)e.Item.FindControl("RemarkCell")).ColSpan           = ((HtmlTableRow)e.Item.FindControl("detailRow")).Cells.Count - 5 - (WebUtils.productLicense(Session).IsCostCenter ? 0 : 1);
        }
        else
        {
            ((Button)e.Item.FindControl("Edit")).Visible         = IsAllowEdit;
            ((CheckBox)e.Item.FindControl("DeleteItem")).Visible = IsAllowEdit;
            if (obj.PayRecID != null)
            {
                ((Button)e.Item.FindControl("Edit")).Visible         = false;
                ((CheckBox)e.Item.FindControl("DeleteItem")).Visible = false;
            }

            ebinding = new Binding(dbConn, db);
            ebinding.add((HtmlInputHidden)e.Item.FindControl("CNDID"));
            ebinding.add(new BlankZeroLabelVLBinder(db, (Label)e.Item.FindControl("CostCenterID"), ECostCenter.VLCostCenter).setTextDisplayForZero(HROne.Common.WebUtility.GetLocalizedString(ECostCenter.DEFAULT_COST_CENTER_TEXT)));

            DBFilter empBankAccountFilter = new DBFilter();
            OR       bankAccountORTerm    = new OR();
            bankAccountORTerm.add(new Match("EmpID", CurID));
            {
                EEmpPersonalInfo tmpEmpInfo = new EEmpPersonalInfo();
                tmpEmpInfo.EmpID = CurID;
                if (EEmpPersonalInfo.db.select(dbConn, tmpEmpInfo) && tmpEmpInfo.MasterEmpID > 0)
                {
                    bankAccountORTerm.add(new Match("EmpID", tmpEmpInfo.MasterEmpID));
                }
            }
            empBankAccountFilter.add(bankAccountORTerm);
            ebinding.add(new BlankZeroLabelVLBinder(db, (Label)e.Item.FindControl("EmpAccID"), EEmpBankAccount.VLBankAccount, empBankAccountFilter).setTextDisplayForZero(HROne.Common.WebUtility.GetLocalizedString(EEmpBankAccount.DEFAULT_BANK_ACCOUNT_TEXT)));

            Label PayPeriodID = (Label)e.Item.FindControl("PayPeriodID");
            if (PayPeriodID != null)
            {
                ebinding.add(new BlankZeroLabelVLBinder(db, PayPeriodID, EPayrollPeriod.VLPayrollPeriod));
            }

            ebinding.init(Request, Session);

            Hashtable values = new Hashtable();
            db.populate(obj, values);

            if (obj.EmpPayrollID is int)
            {
                int EmpPayrollID = (int)obj.EmpPayrollID;
                if (EmpPayrollID > 0)
                {
                    EEmpPayroll empPayroll = new EEmpPayroll();
                    empPayroll.EmpPayrollID = EmpPayrollID;
                    if (EEmpPayroll.db.select(dbConn, empPayroll))
                    {
                        values.Add("PayPeriodID", empPayroll.PayPeriodID.ToString());
                    }
                }
            }
            ebinding.toControl(values);

            ((HtmlTableCell)e.Item.FindControl("CostCenterDetailCell")).Visible = WebUtils.productLicense(Session).IsCostCenter;
            ((HtmlTableCell)e.Item.FindControl("RemarkCell")).ColSpan           = ((HtmlTableRow)e.Item.FindControl("detailRow")).Cells.Count - 5 - (WebUtils.productLicense(Session).IsCostCenter ? 0 : 1) - (PayPeriodID != null ? 2 : 0);
        }

        HROne.Common.WebUtility.WebControlsLocalization(this, e.Item.Controls);
    }
コード例 #24
0
        protected DataSet.Payroll_KTPFundStatement CreateDataSource()
        {
            DataSet.Payroll_KTPFundStatement dataSet = new DataSet.Payroll_KTPFundStatement();

            Payroll_KTPFundStatement.ExistingMemberDataTable existingORSO = dataSet.ExistingMember;

            Payroll_KTPFundStatement.ORSOPlanDataTable orsoPlan = dataSet.ORSOPlan;

            if (_payPeriodFr.Ticks != 0 && _payPeriodTo.Ticks != 0 && EmpList != null)
            {
                string strPrintPeriod = _payPeriodFr.ToString("yyyy-MM-dd") + " - " + _payPeriodTo.ToString("yyyy-MM-dd");

                DBFilter payPeriodFilter = new DBFilter();
                payPeriodFilter.add(new Match("pp.PayPeriodFr", "<=", _payPeriodTo));
                payPeriodFilter.add(new Match("pp.PayPeriodTo", ">=", _payPeriodFr));

                foreach (EEmpPersonalInfo empInfo in EmpList)
                {
                    EEmpPersonalInfo.db.select(dbConn, empInfo);

                    DBFilter empPayrollFilter = new DBFilter();
                    empPayrollFilter.add(new Match("EmpID", empInfo.EmpID));
                    empPayrollFilter.add(new IN("PayPeriodID", "Select PayPeriodID from PayrollPeriod pp", payPeriodFilter));


                    DBFilter orsoRecordFilter = new DBFilter();
                    orsoRecordFilter.add(new IN("EmpPayrollID", "Select EmpPayrollID from EmpPayroll", empPayrollFilter));
                    orsoRecordFilter.add(new Match("ORSOPlanID", ORSOPlanID));
                    orsoRecordFilter.add("ORSORecPeriodFr", true);
                    orsoRecordFilter.add("ORSORecPeriodTo", true);
                    ArrayList orsoRecords = EORSORecord.db.select(dbConn, orsoRecordFilter);


                    DataSet.Payroll_KTPFundStatement.ExistingMemberRow existingORSORow = null;
                    foreach (EORSORecord orsoRecord in orsoRecords)
                    {
                        EORSOPlan orsoPlanObject = new EORSOPlan();
                        orsoPlanObject.ORSOPlanID = orsoRecord.ORSOPlanID;
                        if (EORSOPlan.db.select(dbConn, orsoPlanObject))
                        {
                            if (orsoPlan.Select("ORSOPlanID=" + orsoPlanObject.ORSOPlanID).Length == 0)
                            {
                                DataSet.Payroll_KTPFundStatement.ORSOPlanRow orsoPlanRow = orsoPlan.NewORSOPlanRow();
                                orsoPlanRow.ORSOPlanID          = orsoPlanObject.ORSOPlanID;
                                orsoPlanRow.ORSOPlanCode        = orsoPlanObject.ORSOPlanCode;
                                orsoPlanRow.ORSOPlanCompanyName = orsoPlanObject.ORSOPlanCompanyName;
                                orsoPlanRow.ORSOPlanPayCenter   = orsoPlanObject.ORSOPlanPayCenter;
                                orsoPlanRow.ORSOPlanSchemeNo    = orsoPlanObject.ORSOPlanSchemeNo;
                                orsoPlanRow.ORSOPlanDesc        = orsoPlanObject.ORSOPlanDesc;

                                orsoPlan.Rows.Add(orsoPlanRow);
                            }
                        }

                        EEmpPayroll empPayroll = new EEmpPayroll();
                        empPayroll.EmpPayrollID = orsoRecord.EmpPayrollID;
                        EEmpPayroll.db.select(dbConn, empPayroll);
                        EPayrollPeriod payrollPeriod = new EPayrollPeriod();
                        payrollPeriod.PayPeriodID = empPayroll.PayPeriodID;
                        EPayrollPeriod.db.select(dbConn, payrollPeriod);

                        {
                            if (existingORSORow == null)
                            {
                                existingORSORow = existingORSO.NewExistingMemberRow();
                                LoadExistingMemberRowInfo(empInfo, orsoRecord, existingORSORow);
                            }
                            else
                            {
                                if (!(existingORSORow.EmpID == empInfo.EmpID && existingORSORow.PeriodFrom.Equals(orsoRecord.ORSORecPeriodFr) && existingORSORow.PeriodTo.Equals(orsoRecord.ORSORecPeriodTo)))
                                {
                                    existingORSO.Rows.Add(existingORSORow);
                                    existingORSORow = existingORSO.NewExistingMemberRow();
                                    LoadExistingMemberRowInfo(empInfo, orsoRecord, existingORSORow);
                                }
                            }

                            existingORSORow.RelevantIncome += orsoRecord.ORSORecActRI;
                            existingORSORow.EE             += orsoRecord.ORSORecActEE;
                            existingORSORow.ER             += orsoRecord.ORSORecActER;

                            DBFilter m_mpfRecordFilter = new DBFilter();
                            m_mpfRecordFilter.add(new Match("EmpPayrollID", orsoRecord.EmpPayrollID));
                            foreach (EMPFRecord m_mpfRecord in EMPFRecord.db.select(dbConn, m_mpfRecordFilter))
                            {
                                existingORSORow.MpfMCEE += m_mpfRecord.MPFRecActMCEE;
                                existingORSORow.MpfMCER += m_mpfRecord.MPFRecActMCER;
                                existingORSORow.MpfVCEE += m_mpfRecord.MPFRecActVCEE;
                                existingORSORow.MpfVCER += m_mpfRecord.MPFRecActVCER;
                            }
                        }
                    }

                    if (existingORSORow != null)
                    {
                        // business requirement from user, "Basic Salary over $100,000 should be shown $100,000 only
                        if (existingORSORow.RelevantIncome > 100000)
                        {
                            existingORSORow.RelevantIncome = 100000;
                        }

                        existingORSO.Rows.Add(existingORSORow);
                    }
                }
            }

            return(dataSet);
        }
コード例 #25
0
        private void GeneratePayrollData(int PaySlipID, ArrayList paymentRecords, out DateTime LastValueDate)
        {
            LastValueDate = new DateTime();
            DataSet.Payroll_PaySlip.PaySlipRow row = null;
            foreach (EPaymentRecord paymentRecord in paymentRecords)
            {
                string paymentMethod = string.Empty;
                if (paymentRecord.PayRecMethod.Equals("A", StringComparison.CurrentCultureIgnoreCase))
                {
                    paymentMethod = "Autopay";
                }
                else if (paymentRecord.PayRecMethod.Equals("Q", StringComparison.CurrentCultureIgnoreCase))
                {
                    paymentMethod = "Cheque";
                }
                else if (paymentRecord.PayRecMethod.Equals("C", StringComparison.CurrentCultureIgnoreCase))
                {
                    paymentMethod = "Cash";
                }
                else if (paymentRecord.PayRecMethod.Equals("O", StringComparison.CurrentCultureIgnoreCase))
                {
                    paymentMethod = "Others";
                }
                else
                {
                    paymentMethod = paymentRecord.PayRecMethod;
                }


                EPaymentCode paymentCode = new EPaymentCode();
                paymentCode.PaymentCodeID = paymentRecord.PaymentCodeID;
                EPaymentCode.db.select(dbConn, paymentCode);

                DateTime    valueDate  = new DateTime();
                EEmpPayroll empPayroll = new EEmpPayroll();
                empPayroll.EmpPayrollID = paymentRecord.EmpPayrollID;
                if (EEmpPayroll.db.select(dbConn, empPayroll))
                {
                    EPayrollBatch payBatch = new EPayrollBatch();
                    payBatch.PayBatchID = empPayroll.PayBatchID;
                    if (EPayrollBatch.db.select(dbConn, payBatch))
                    {
                        if (!payBatch.PayBatchValueDate.Ticks.Equals(0))
                        {
                            valueDate = payBatch.PayBatchValueDate;
                        }
                    }
                    if (!empPayroll.EmpPayValueDate.Ticks.Equals(0))
                    {
                        if (valueDate.Ticks.Equals(0))
                        {
                            valueDate = empPayroll.EmpPayValueDate;
                        }
                        else
                        {
                            valueDate = empPayroll.EmpPayValueDate > valueDate ? empPayroll.EmpPayValueDate : valueDate;
                        }
                    }
                }

                //  Hide payment if payment code is chosen for hidden under payslip
                if (!this.reportType.Equals(ReportType.PaySlip) || !paymentCode.PaymentCodeHideInPaySlip)
                {
                    //                    string paymentCodeFullName = paymentCode.PaymentCode + " - " + paymentCode.PaymentCodeDesc;
                    if (row == null)
                    {
                        row = dataSet.PaySlip.NewPaySlipRow();
                    }
                    else if (!(row.EmpID == PaySlipID && row.PayMethod == paymentMethod && row.PaymentCode == paymentCode.PaymentCode && (valueDate.Equals(row.ValueDate) || !this.reportType.Equals(ReportType.PaySlip))))
                    {
                        if (row.ValueDate.Ticks.Equals(0))
                        {
                            row.SetValueDateNull();
                        }
                        dataSet.PaySlip.Rows.Add(row);
                        row = dataSet.PaySlip.NewPaySlipRow();
                    }
                    if (row.IsNull("EmpID"))
                    {
                        row.EmpID                   = PaySlipID;
                        row.PaymentCode             = paymentCode.PaymentCode;
                        row.PaymentCodeDesc         = paymentCode.PaymentCodeDesc;
                        row.PaymentCodeDisplaySeqNo = paymentCode.PaymentCodeDisplaySeqNo;
                        row.PayMethod               = paymentMethod;
                        row.PayAmount               = 0;
                        //if (!valueDate.Ticks.Equals(0))
                        row.ValueDate = valueDate;
                    }
                    row.PayAmount += paymentRecord.PayRecActAmount;
                    if (!string.IsNullOrEmpty(paymentRecord.PayRecRemark))
                    {
                        if (row.IsRemarkNull())
                        {
                            row.Remark = paymentRecord.PayRecRemark;
                        }
                        else
                        {
                            row.Remark += "\r\n" + paymentRecord.PayRecRemark;
                        }
                    }
                }
                if (valueDate > LastValueDate)
                {
                    LastValueDate = valueDate;
                }
            }
            if (row != null)
            {
                if (row.ValueDate.Ticks.Equals(0))
                {
                    row.SetValueDateNull();
                }
                dataSet.PaySlip.Rows.Add(row);
            }
        }
コード例 #26
0
    protected void btnTrialRun_Click(object sender, EventArgs e)
    {
        ArrayList list = new ArrayList();

        foreach (RepeaterItem i in Repeater.Items)
        {
            CheckBox cb = (CheckBox)i.FindControl("ItemSelect");
            if (cb.Checked)
            {
                EEmpPayroll o = (EEmpPayroll)EEmpPayroll.db.createObject();
                WebFormUtils.GetKeys(EEmpPayroll.db, o, cb);
                list.Add(o);
            }
        }

        DateTime processDateTime = AppUtils.ServerDateTime();


        if (list.Count > 0)
        {
            //EPayrollPeriod payPeriod = new EPayrollPeriod();
            //payPeriod.PayPeriodID = CurPayPeriodID;
            //payPeriod.PayPeriodStatus = "C";
            //payPeriod.PayPeriodConfirmDate = processDateTime;
            //payPeriod.PayPeriodConfirmBy = WebUtils.GetCurUser(Session).UserID;
            //EPayrollPeriod.db.update(dbConn, payPeriod);

            //EPayrollBatch payBatch = new EPayrollBatch();
            //payBatch.PayBatchConfirmDate = processDateTime;
            //EPayrollBatch.db.insert(dbConn, payBatch);
            CostAllocationProcess costAllocationProcess = new CostAllocationProcess(dbConn);

            foreach (EEmpPayroll o in list)
            {
                if (EEmpPayroll.db.select(dbConn, o))
                {
                    WebUtils.StartFunction(Session, FUNCTION_CODE, o.EmpID, true);
                    costAllocationProcess.TrialRun(o.EmpPayrollID, WebUtils.GetCurUser(Session));
                    WebUtils.EndFunction(dbConn);

                    //EEmpPayroll empPayroll = new EEmpPayroll();
                    //empPayroll.EmpPayrollID = o.EmpPayrollID;
                    //EEmpPayroll.db.select(dbConn, empPayroll);
                    //if (empPayroll.EmpPayStatus.Equals("T", StringComparison.CurrentCultureIgnoreCase))
                    //{
                    //    empPayroll.EmpPayStatus = "C";
                    //    empPayroll.EmpPayConfirmDate = processDateTime;
                    //    empPayroll.PayBatchID = payBatch.PayBatchID;
                    //    EEmpPayroll.db.update(dbConn, empPayroll);
                    //}
                }
            }
            if (costAllocationProcess.hasError)
            {
                PageErrors.getErrors(db, Page).addGlobalError("Complete with error");
                PageErrors.getErrors(db, Page).addGlobalError(costAllocationProcess.ErrorLog.Replace("\r", "\\r"));
            }
            else
            {
                PageErrors.getErrors(db, Page).addError("Complete");
            }
            //Response.Write("<script>alert('Completed'); </script>");
        }
        loadObject();
        loadData(info, EEmpPayroll.db, Repeater);
    }
コード例 #27
0
    protected void Repeater_ItemCommand(object source, DataListCommandEventArgs e)
    {
        Button b = (Button)e.CommandSource;



        if (b.ID.Equals("Edit"))
        {
            Repeater.EditItemIndex = e.Item.ItemIndex;
            //AddPanel.Visible = false;
            view = loadData(info, db, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, false);
        }
        else if (b.ID.Equals("Cancel"))
        {
            Repeater.EditItemIndex = -1;
            //AddPanel.Visible = IsAllowEdit;
            view = loadData(info, db, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, true);
        }
        else if (b.ID.Equals("Save"))
        {
            Binding eBinding;
            eBinding = new Binding(dbConn, db);
            eBinding.add(EmpPayrollID);
            eBinding.add((HtmlInputHidden)e.Item.FindControl("ORSORecordID"));
            eBinding.add(new TextBoxBinder(db, ((WebDatePicker)e.Item.FindControl("ORSORecPeriodFr")).TextBox, "ORSORecPeriodFr"));
            eBinding.add(new TextBoxBinder(db, ((WebDatePicker)e.Item.FindControl("ORSORecPeriodTo")).TextBox, "ORSORecPeriodTo"));
            eBinding.add((TextBox)e.Item.FindControl("ORSORecActRI"));
            eBinding.add((TextBox)e.Item.FindControl("ORSORecActER"));
            eBinding.add((TextBox)e.Item.FindControl("ORSORecActEE"));
            eBinding.add(new DropDownVLBinder(db, (DropDownList)e.Item.FindControl("ORSOPlanID"), EORSOPlan.VLORSOPlan));


            eBinding.init(Request, Session);


            EORSORecord obj    = new EORSORecord();
            Hashtable   values = new Hashtable();

            PageErrors errors = PageErrors.getErrors(db, Page.Master);
            errors.clear();


            eBinding.toValues(values);
            db.validate(errors, values);

            if (!errors.isEmpty())
            {
                return;
            }

            db.parse(values, obj);

            EEmpPayroll empPayroll = new EEmpPayroll();
            empPayroll.EmpPayrollID = obj.EmpPayrollID;
            if (EEmpPayroll.db.select(dbConn, empPayroll))
            {
                EPayrollPeriod payPeriod = new EPayrollPeriod();
                payPeriod.PayPeriodID = empPayroll.PayPeriodID;

                if (EPayrollPeriod.db.select(dbConn, payPeriod))
                {
                    if (obj.ORSORecPeriodFr <= payPeriod.PayPeriodTo && obj.ORSORecPeriodTo <= payPeriod.PayPeriodTo)
                    {
                        WebUtils.StartFunction(Session, m_FunctionCode, empPayroll.EmpID);
                        db.update(dbConn, obj);
                        WebUtils.EndFunction(dbConn);
                    }
                    else
                    {
                        errors.addError(HROne.Translation.PageErrorMessage.ERROR_INVALID_PERIOD);
                        return;
                    }
                }
            }
            Repeater.EditItemIndex = -1;
            //AddPanel.Visible = IsAllowEdit;
            view = loadData(info, db, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, true);
        }
    }
コード例 #28
0
        public override ReportDocument GenerateReport()
        {
            dataSet = new DataSet.Payroll_EEOverallPayrollSummary();


            if (PayPeriodFr.Ticks != 0 && EmpList.Count > 0)
            {
                //  initialize Payment Code for Employer Contribution

                ArrayList    mcERPaymentCodeList = HROne.Payroll.PayrollProcess.GetPaymentCodeByPaymentType(dbConn, EPaymentType.SystemPaymentType.MPFEmployerMandatoryContributionPaymentType(dbConn).PaymentTypeCode);
                EPaymentCode mpfMCERPaymentCode;
                if (mcERPaymentCodeList.Count > 0)
                {
                    mpfMCERPaymentCode = (EPaymentCode)mcERPaymentCodeList[0];
                }
                else
                {
                    mpfMCERPaymentCode = new EPaymentCode();
                    mpfMCERPaymentCode.PaymentCodeID   = -1;
                    mpfMCERPaymentCode.PaymentCode     = "MCER";
                    mpfMCERPaymentCode.PaymentCodeDesc = "Employer Mandatory Contribution";
                }

                ArrayList    vcERPaymentCodeList = HROne.Payroll.PayrollProcess.GetPaymentCodeByPaymentType(dbConn, EPaymentType.SystemPaymentType.MPFEmployerVoluntaryContributionPaymentType(dbConn).PaymentTypeCode);
                EPaymentCode mpfVCERPaymentCode;
                if (vcERPaymentCodeList.Count > 0)
                {
                    mpfVCERPaymentCode = (EPaymentCode)vcERPaymentCodeList[0];
                }
                else
                {
                    mpfVCERPaymentCode = new EPaymentCode();
                    mpfVCERPaymentCode.PaymentCodeID   = -2;
                    mpfVCERPaymentCode.PaymentCode     = "VCER";
                    mpfVCERPaymentCode.PaymentCodeDesc = "Employer Voluntary Contribution";
                }

                ArrayList    pfundERPaymentCodeList = HROne.Payroll.PayrollProcess.GetPaymentCodeByPaymentType(dbConn, EPaymentType.SystemPaymentType.PFundEmployerContributionPaymentType(dbConn).PaymentTypeCode);
                EPaymentCode pFundERPaymentCode;
                if (pfundERPaymentCodeList.Count > 0)
                {
                    pFundERPaymentCode = (EPaymentCode)pfundERPaymentCodeList[0];
                }
                else
                {
                    pFundERPaymentCode = new EPaymentCode();
                    pFundERPaymentCode.PaymentCodeID   = -3;
                    pFundERPaymentCode.PaymentCode     = "PFUNDER";
                    pFundERPaymentCode.PaymentCodeDesc = "Employer P-Fund Contribution";
                }

                dtPayPeriodFr = PayPeriodFr;
                dtPayPeriodTo = dtPayPeriodFr.AddMonths(12).AddDays(-1);


                string strPrintPeriod = string.Empty;
                //if (lngPayPeriodFr != 0 && lngPayPeriodTo != 0)
                strPrintPeriod = dtPayPeriodFr.ToString("yyyy-MM-dd") + " - " + dtPayPeriodTo.ToString("yyyy-MM-dd");

                DataSet.Payroll_EEOverallPayrollSummary.EmpInfoDataTable        empInfoTable = dataSet.EmpInfo;
                DataSet.Payroll_EEOverallPayrollSummary.OverallPaymentDataTable payTable     = dataSet.OverallPayment;

                DataSet.Payroll_EEOverallPayrollSummary.OverallContributionDataTable contributionTable = dataSet.OverallContribution;
                foreach (EEmpPersonalInfo empInfo in EmpList)
                {
                    EEmpPersonalInfo.db.select(dbConn, empInfo);


                    DBFilter positionFilter = new DBFilter();
                    positionFilter.add(new Match("EmpID", empInfo.EmpID));
                    //if (lngPayPeriodFr != 0 && lngPayPeriodTo != 0)
                    //{
                    positionFilter.add(new Match("EmpPosEffFr", "<=", dtPayPeriodTo.CompareTo(AppUtils.ServerDateTime()) < 0 ? dtPayPeriodTo : AppUtils.ServerDateTime()));
                    OR orPosEffToTerms = new OR();
                    orPosEffToTerms.add(new Match("EmpPosEffTo", ">=", dtPayPeriodFr));
                    orPosEffToTerms.add(new NullTerm("EmpPosEffTo"));
                    positionFilter.add(orPosEffToTerms);
                    //}
                    positionFilter.add("EmpPosEffFr", false);

                    ArrayList        empPositionInfos = EEmpPositionInfo.db.select(dbConn, positionFilter);
                    EEmpPositionInfo empPositionInfo;
                    if (empPositionInfos.Count > 0)
                    {
                        empPositionInfo = (EEmpPositionInfo)empPositionInfos[0];
                    }
                    else
                    {
                        empPositionInfo = new EEmpPositionInfo();
                    }

                    ECompany company = new ECompany();
                    company.CompanyID = empPositionInfo.CompanyID;
                    ECompany.db.select(dbConn, company);

                    EPosition position = new EPosition();
                    position.PositionID = empPositionInfo.PositionID;
                    EPosition.db.select(dbConn, position);

                    DataSet.Payroll_EEOverallPayrollSummary.EmpInfoRow empInfoRow = empInfoTable.NewEmpInfoRow();
                    empInfoRow.EmpID       = empInfo.EmpID;
                    empInfoRow.EmpNo       = empInfo.EmpNo;
                    empInfoRow.EmpName     = empInfo.EmpEngFullName;
                    empInfoRow.JoinDate    = empInfo.EmpDateOfJoin;
                    empInfoRow.CompanyCode = company.CompanyCode;
                    empInfoRow.CompanyName = company.CompanyName;
                    //                empInfoRow.PrintPeriod = strPrintPeriod;
                    empInfoRow.PositionDesc = position.PositionDesc;

                    empInfoTable.Rows.Add(empInfoRow);

                    DBFilter payPeriodFilter = new DBFilter();
                    //if (lngPayPeriodFr != 0 && lngPayPeriodTo != 0)
                    //{
                    payPeriodFilter.add(new Match("pp.PayPeriodTo", "<=", dtPayPeriodTo));
                    payPeriodFilter.add(new Match("pp.PayPeriodTo", ">=", dtPayPeriodFr));
                    //}
                    DBFilter empPayrollFilter = new DBFilter();
                    empPayrollFilter.add(new Match("EmpID", empInfo.EmpID));
                    empPayrollFilter.add(new IN("PayPeriodID", "Select PayPeriodID from PayrollPeriod pp", payPeriodFilter));


                    DBFilter payRecordFilter = new DBFilter();
                    payRecordFilter.add(new IN("EmpPayrollID", "Select EmpPayrollID from EmpPayroll", empPayrollFilter));
                    ArrayList payRecords = EPaymentRecord.db.select(dbConn, payRecordFilter);

                    ArrayList mpfRecords = EMPFRecord.db.select(dbConn, payRecordFilter);

                    ArrayList orsoRecords = EORSORecord.db.select(dbConn, payRecordFilter);
                    foreach (EPaymentRecord payRecord in payRecords)
                    {
                        EEmpPayroll empPayroll = new EEmpPayroll();
                        empPayroll.EmpPayrollID = payRecord.EmpPayrollID;
                        EEmpPayroll.db.select(dbConn, empPayroll);

                        EPayrollPeriod payrollPeriod = new EPayrollPeriod();
                        payrollPeriod.PayPeriodID = empPayroll.PayPeriodID;
                        EPayrollPeriod.db.select(dbConn, payrollPeriod);

                        EPaymentCode payCode = new EPaymentCode();
                        payCode.PaymentCodeID = payRecord.PaymentCodeID;
                        EPaymentCode.db.select(dbConn, payCode);

                        DataSet.Payroll_EEOverallPayrollSummary.OverallPaymentRow payRow = payTable.NewOverallPaymentRow();

                        payRow.EmpID                   = empInfo.EmpID;
                        payRow.PaymentCode             = payCode.PaymentCode;
                        payRow.PaymentCodeDisplaySeqNo = payCode.PaymentCodeDisplaySeqNo;

                        DBFilter taxPaymentMapFilter = new DBFilter();
                        taxPaymentMapFilter.add(new Match("PaymentCodeID", payRecord.PaymentCodeID));
                        if (ETaxPaymentMap.db.count(dbConn, taxPaymentMapFilter) > 0)
                        {
                            payRow.IsTaxable = true;
                        }
                        else
                        {
                            payRow.IsTaxable = false;
                        }

                        for (int fieldsNo = 1; fieldsNo < 13; fieldsNo++)
                        {
                            payRow["Amount" + fieldsNo.ToString("00")] = 0;
                        }

                        payRow["Amount" + ((payrollPeriod.PayPeriodTo.Month + 12 - dtPayPeriodFr.Month) % 12 + 1).ToString("00")] = payRecord.PayRecActAmount;

                        payTable.Rows.Add(payRow);
                        try
                        {
                            DataSet.Payroll_EEOverallPayrollSummary.PaymentCodeDataTable paymentCodeTable = dataSet.PaymentCode;
                            DataSet.Payroll_EEOverallPayrollSummary.PaymentCodeRow       paymentCodeRow   = paymentCodeTable.NewPaymentCodeRow();
                            paymentCodeRow.EmpID           = empInfo.EmpID;
                            paymentCodeRow.PaymentCodeID   = payCode.PaymentCodeID;
                            paymentCodeRow.PaymentCode     = payCode.PaymentCode;
                            paymentCodeRow.PaymentCodeDesc = payCode.PaymentCodeDesc;
                            paymentCodeTable.Rows.Add(paymentCodeRow);
                        }
                        catch
                        {
                        }
                        try
                        {
                            DataSet.Payroll_EEOverallPayrollSummary.GrandTotalPaymentCodeDataTable paymentCodeTable = dataSet.GrandTotalPaymentCode;
                            if (paymentCodeTable.Select("PaymentCodeID=" + payCode.PaymentCodeID.ToString()).Length <= 0)
                            {
                                DataSet.Payroll_EEOverallPayrollSummary.GrandTotalPaymentCodeRow paymentCodeRow = paymentCodeTable.NewGrandTotalPaymentCodeRow();
                                paymentCodeRow.PaymentCodeID   = payCode.PaymentCodeID;
                                paymentCodeRow.PaymentCode     = payCode.PaymentCode;
                                paymentCodeRow.PaymentCodeDesc = payCode.PaymentCodeDesc;
                                paymentCodeTable.Rows.Add(paymentCodeRow);
                            }
                        }
                        catch
                        {
                        }
                    }
                    foreach (EMPFRecord mpfRecord in mpfRecords)
                    {
                        EEmpPayroll empPayroll = new EEmpPayroll();
                        empPayroll.EmpPayrollID = mpfRecord.EmpPayrollID;
                        EEmpPayroll.db.select(dbConn, empPayroll);

                        EPayrollPeriod payrollPeriod = new EPayrollPeriod();
                        payrollPeriod.PayPeriodID = empPayroll.PayPeriodID;
                        EPayrollPeriod.db.select(dbConn, payrollPeriod);


                        DataSet.Payroll_EEOverallPayrollSummary.OverallContributionRow contributionRow = contributionTable.NewOverallContributionRow();

                        contributionRow.EmpID       = empInfo.EmpID;
                        contributionRow.PaymentCode = mpfMCERPaymentCode.PaymentCode;


                        for (int fieldsNo = 1; fieldsNo < 13; fieldsNo++)
                        {
                            contributionRow["Amount" + fieldsNo.ToString("00")] = 0;
                        }

                        contributionRow["Amount" + ((payrollPeriod.PayPeriodTo.Month + 12 - dtPayPeriodFr.Month) % 12 + 1).ToString("00")] = mpfRecord.MPFRecActMCER;

                        contributionTable.Rows.Add(contributionRow);

                        contributionRow = contributionTable.NewOverallContributionRow();

                        contributionRow.EmpID       = empInfo.EmpID;
                        contributionRow.PaymentCode = mpfVCERPaymentCode.PaymentCode;


                        for (int fieldsNo = 1; fieldsNo < 13; fieldsNo++)
                        {
                            contributionRow["Amount" + fieldsNo.ToString("00")] = 0;
                        }

                        contributionRow["Amount" + ((payrollPeriod.PayPeriodTo.Month + 12 - dtPayPeriodFr.Month) % 12 + 1).ToString("00")] = mpfRecord.MPFRecActVCER;

                        contributionTable.Rows.Add(contributionRow);
                        try
                        {
                            DataSet.Payroll_EEOverallPayrollSummary.PaymentCodeDataTable paymentCodeTable = dataSet.PaymentCode;
                            DataSet.Payroll_EEOverallPayrollSummary.PaymentCodeRow       paymentCodeRow   = paymentCodeTable.NewPaymentCodeRow();
                            paymentCodeRow.EmpID           = empInfo.EmpID;
                            paymentCodeRow.PaymentCodeID   = mpfMCERPaymentCode.PaymentCodeID;
                            paymentCodeRow.PaymentCode     = mpfMCERPaymentCode.PaymentCode;
                            paymentCodeRow.PaymentCodeDesc = mpfMCERPaymentCode.PaymentCodeDesc;
                            paymentCodeTable.Rows.Add(paymentCodeRow);
                        }
                        catch
                        {
                        }
                        try
                        {
                            DataSet.Payroll_EEOverallPayrollSummary.GrandTotalPaymentCodeDataTable paymentCodeTable = dataSet.GrandTotalPaymentCode;
                            if (paymentCodeTable.Select("PaymentCodeID=" + mpfMCERPaymentCode.PaymentCodeID.ToString()).Length <= 0)
                            {
                                DataSet.Payroll_EEOverallPayrollSummary.GrandTotalPaymentCodeRow paymentCodeRow = paymentCodeTable.NewGrandTotalPaymentCodeRow();
                                paymentCodeRow.PaymentCodeID   = mpfMCERPaymentCode.PaymentCodeID;
                                paymentCodeRow.PaymentCode     = mpfMCERPaymentCode.PaymentCode;
                                paymentCodeRow.PaymentCodeDesc = mpfMCERPaymentCode.PaymentCodeDesc;
                                paymentCodeTable.Rows.Add(paymentCodeRow);
                            }
                        }
                        catch
                        {
                        }

                        try
                        {
                            DataSet.Payroll_EEOverallPayrollSummary.PaymentCodeDataTable paymentCodeTable = dataSet.PaymentCode;
                            DataSet.Payroll_EEOverallPayrollSummary.PaymentCodeRow       paymentCodeRow   = paymentCodeTable.NewPaymentCodeRow();
                            paymentCodeRow.EmpID           = empInfo.EmpID;
                            paymentCodeRow.PaymentCodeID   = mpfVCERPaymentCode.PaymentCodeID;
                            paymentCodeRow.PaymentCode     = mpfVCERPaymentCode.PaymentCode;
                            paymentCodeRow.PaymentCodeDesc = mpfVCERPaymentCode.PaymentCodeDesc;
                            paymentCodeTable.Rows.Add(paymentCodeRow);
                        }
                        catch
                        {
                        }
                        try
                        {
                            DataSet.Payroll_EEOverallPayrollSummary.GrandTotalPaymentCodeDataTable paymentCodeTable = dataSet.GrandTotalPaymentCode;
                            if (paymentCodeTable.Select("PaymentCodeID=" + mpfVCERPaymentCode.PaymentCodeID.ToString()).Length <= 0)
                            {
                                DataSet.Payroll_EEOverallPayrollSummary.GrandTotalPaymentCodeRow paymentCodeRow = paymentCodeTable.NewGrandTotalPaymentCodeRow();
                                paymentCodeRow.PaymentCodeID   = mpfVCERPaymentCode.PaymentCodeID;
                                paymentCodeRow.PaymentCode     = mpfVCERPaymentCode.PaymentCode;
                                paymentCodeRow.PaymentCodeDesc = mpfVCERPaymentCode.PaymentCodeDesc;
                                paymentCodeTable.Rows.Add(paymentCodeRow);
                            }
                        }
                        catch
                        {
                        }
                    }
                    foreach (EORSORecord orsoRecord in orsoRecords)
                    {
                        EEmpPayroll empPayroll = new EEmpPayroll();
                        empPayroll.EmpPayrollID = orsoRecord.EmpPayrollID;
                        EEmpPayroll.db.select(dbConn, empPayroll);

                        EPayrollPeriod payrollPeriod = new EPayrollPeriod();
                        payrollPeriod.PayPeriodID = empPayroll.PayPeriodID;
                        EPayrollPeriod.db.select(dbConn, payrollPeriod);


                        DataSet.Payroll_EEOverallPayrollSummary.OverallContributionRow contributionRow = contributionTable.NewOverallContributionRow();

                        contributionRow.EmpID       = empInfo.EmpID;
                        contributionRow.PaymentCode = pFundERPaymentCode.PaymentCode;


                        for (int fieldsNo = 1; fieldsNo < 13; fieldsNo++)
                        {
                            contributionRow["Amount" + fieldsNo.ToString("00")] = 0;
                        }

                        contributionRow["Amount" + ((payrollPeriod.PayPeriodTo.Month + 12 - dtPayPeriodFr.Month) % 12 + 1).ToString("00")] = orsoRecord.ORSORecActER;

                        contributionTable.Rows.Add(contributionRow);


                        try
                        {
                            DataSet.Payroll_EEOverallPayrollSummary.PaymentCodeDataTable paymentCodeTable = dataSet.PaymentCode;
                            DataSet.Payroll_EEOverallPayrollSummary.PaymentCodeRow       paymentCodeRow   = paymentCodeTable.NewPaymentCodeRow();
                            paymentCodeRow.EmpID           = empInfo.EmpID;
                            paymentCodeRow.PaymentCodeID   = pFundERPaymentCode.PaymentCodeID;
                            paymentCodeRow.PaymentCode     = pFundERPaymentCode.PaymentCode;
                            paymentCodeRow.PaymentCodeDesc = pFundERPaymentCode.PaymentCode;
                            paymentCodeTable.Rows.Add(paymentCodeRow);
                        }
                        catch
                        {
                        }
                        try
                        {
                            DataSet.Payroll_EEOverallPayrollSummary.GrandTotalPaymentCodeDataTable paymentCodeTable = dataSet.GrandTotalPaymentCode;
                            if (paymentCodeTable.Select("PaymentCodeID=" + pFundERPaymentCode.PaymentCodeID.ToString()).Length <= 0)
                            {
                                DataSet.Payroll_EEOverallPayrollSummary.GrandTotalPaymentCodeRow paymentCodeRow = paymentCodeTable.NewGrandTotalPaymentCodeRow();
                                paymentCodeRow.PaymentCodeID   = pFundERPaymentCode.PaymentCodeID;
                                paymentCodeRow.PaymentCode     = pFundERPaymentCode.PaymentCode;
                                paymentCodeRow.PaymentCodeDesc = pFundERPaymentCode.PaymentCode;
                                paymentCodeTable.Rows.Add(paymentCodeRow);
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                if (reportDocument == null)
                {
                    reportDocument = new ReportTemplate.Report_Payroll_EEOverallPaymentSummary();
                    //reportDocument.Load(@"ReportTemplate\Report_Payroll_DiscrepancyList.rpt");
                }
                else
                {
                }



                return(base.GenerateReport());
            }
            else
            {
                return(null);
            }
        }
コード例 #29
0
        public override CrystalDecisions.CrystalReports.Engine.ReportDocument GenerateReport()
        {
            DataSet.Payroll_NetPaymentList dataSet = new DataSet.Payroll_NetPaymentList();

            if (ByAutoPay)
            {
                DataSet.Payroll_NetPaymentList.PaymentMethodRow payMethodRow = dataSet.PaymentMethod.NewPaymentMethodRow();
                payMethodRow.PayMethodCode = "A";
                payMethodRow.PayMethodDesc = "Autopay";
                dataSet.PaymentMethod.AddPaymentMethodRow(payMethodRow);
            }

            if (ByCheque)
            {
                DataSet.Payroll_NetPaymentList.PaymentMethodRow payMethodRow = dataSet.PaymentMethod.NewPaymentMethodRow();
                payMethodRow.PayMethodCode = "Q";
                payMethodRow.PayMethodDesc = "Cheque";
                dataSet.PaymentMethod.AddPaymentMethodRow(payMethodRow);
            }
            if (ByCash)
            {
                DataSet.Payroll_NetPaymentList.PaymentMethodRow payMethodRow = dataSet.PaymentMethod.NewPaymentMethodRow();
                payMethodRow.PayMethodCode = "C";
                payMethodRow.PayMethodDesc = "Cash";
                dataSet.PaymentMethod.AddPaymentMethodRow(payMethodRow);
            }
            if (ByOthers)
            {
                DataSet.Payroll_NetPaymentList.PaymentMethodRow payMethodRow = dataSet.PaymentMethod.NewPaymentMethodRow();
                payMethodRow.PayMethodCode = "O";
                payMethodRow.PayMethodDesc = "Others";
                dataSet.PaymentMethod.AddPaymentMethodRow(payMethodRow);
            }
            foreach (EEmpPersonalInfo empInfo in EmpList)
            {
                if (EEmpPersonalInfo.db.select(dbConn, empInfo))
                {
                    DataSet.Payroll_NetPaymentList.employeedetailRow row = dataSet.employeedetail.NewemployeedetailRow();

                    {
                        EEmpPositionInfo posInfo = AppUtils.GetLastPositionInfo(dbConn, empInfo.EmpID);

                        if (posInfo != null)
                        {
                            ECompany company = new ECompany();
                            company.CompanyID = posInfo.CompanyID;
                            if (ECompany.db.select(dbConn, company))
                            {
                                row.CompanyCode = company.CompanyCode;
                                row.CompanyID   = company.CompanyID;
                                row.CompanyName = company.CompanyName;
                            }
                            else
                            {
                                row.CompanyCode = string.Empty;
                                row.CompanyID   = 0;
                                row.CompanyName = "-";
                            }
                            row.EmpPosEffFr = posInfo.EmpPosEffFr;
                            row.EmpPosEffTo = posInfo.EmpPosEffTo;
                            //posInfo.EmploymentTypeID
                            row.EmpPosID    = posInfo.EmpPosID;
                            row.LeavePlanID = posInfo.LeavePlanID;
                            row.PayGroupID  = posInfo.PayGroupID;
                            EPosition position = new EPosition();
                            position.PositionID = posInfo.PositionID;
                            if (EPosition.db.select(dbConn, position))
                            {
                                row.PositionCode = position.PositionCode;
                                row.PositionDesc = position.PositionDesc;
                                row.PositionID   = position.PositionID;
                            }
                            else
                            {
                                row.PositionCode = string.Empty;
                                row.PositionDesc = "-";
                                row.PositionID   = 0;
                            }

                            row.RankID      = posInfo.RankID;
                            row.Remark      = empInfo.Remark;
                            row.StaffTypeID = posInfo.StaffTypeID;
                            //posInfo.YebPlanID;

                            ArrayList HierarchyLevelList = EHierarchyLevel.db.select(dbConn, new DBFilter());
                            foreach (EHierarchyLevel hLevel in HierarchyLevelList)
                            {
                                if (hLevel.HLevelSeqNo < 4 && hLevel.HLevelSeqNo > 0)
                                {
                                    DBFilter empHierarchyFilter = new DBFilter();
                                    empHierarchyFilter.add(new Match("EmpPosID", posInfo.EmpPosID));
                                    empHierarchyFilter.add(new Match("HLevelID", hLevel.HLevelID));

                                    ArrayList empHierarchyList = EEmpHierarchy.db.select(dbConn, empHierarchyFilter);

                                    if (empHierarchyList.Count > 0)
                                    {
                                        EEmpHierarchy empHierarchy = (EEmpHierarchy)empHierarchyList[0];

                                        EHierarchyElement hElement = new EHierarchyElement();
                                        hElement.HElementID = empHierarchy.HElementID;
                                        EHierarchyElement.db.select(dbConn, hElement);

                                        row["HierarchyCode" + hLevel.HLevelSeqNo] = hElement.HElementCode;
                                        row["HierarchyDesc" + hLevel.HLevelSeqNo] = hElement.HElementDesc;
                                    }
                                }
                            }
                        }
                        else
                        {
                            row.CompanyCode  = string.Empty;
                            row.CompanyID    = 0;
                            row.CompanyName  = "-";
                            row.PositionCode = string.Empty;
                            row.PositionDesc = "-";
                            row.PositionID   = 0;
                        }
                    }

                    row.EmpAlias                 = empInfo.EmpAlias;
                    row.EmpChiFullName           = empInfo.EmpChiFullName;
                    row.EmpCorAddr               = empInfo.EmpCorAddr;
                    row.EmpDateOfBirth           = empInfo.EmpDateOfBirth;
                    row.EmpDateOfJoin            = empInfo.EmpDateOfJoin;
                    row.EmpEmail                 = empInfo.EmpEmail;
                    row.EmpEngOtherName          = empInfo.EmpEngOtherName;
                    row.EmpEngSurname            = empInfo.EmpEngSurname;
                    row.EmpEngFullName           = empInfo.EmpEngFullName;
                    row.EmpGender                = empInfo.EmpGender;
                    row.EmpHKID                  = empInfo.EmpHKID;
                    row.EmpHomePhoneNo           = empInfo.EmpHomePhoneNo;
                    row.EmpID                    = empInfo.EmpID;
                    row.EmpMaritalStatus         = empInfo.EmpMaritalStatus;
                    row.EmpMobileNo              = empInfo.EmpMobileNo;
                    row.EmpNationality           = empInfo.EmpNationality;
                    row.EmpNo                    = empInfo.EmpNo;
                    row.EmpNoticePeriod          = empInfo.EmpNoticePeriod;
                    row.EmpNoticeUnit            = empInfo.EmpNoticeUnit;
                    row.EmpOfficePhoneNo         = empInfo.EmpOfficePhoneNo;
                    row.EmpPassportExpiryDate    = empInfo.EmpPassportExpiryDate;
                    row.EmpPassportIssuedCountry = empInfo.EmpPassportIssuedCountry;
                    row.EmpPassportNo            = empInfo.EmpPassportNo;
                    row.EmpPlaceOfBirth          = empInfo.EmpPlaceOfBirth;
                    row.EmpProbaLastDate         = empInfo.EmpProbaLastDate;
                    row.EmpProbaPeriod           = empInfo.EmpProbaPeriod;
                    row.EmpProbaUnit             = empInfo.EmpProbaUnit;
                    row.EmpResAddr               = empInfo.EmpResAddr;
                    row.EmpResAddrAreaCode       = empInfo.EmpResAddrAreaCode;
                    row.EmpServiceDate           = empInfo.EmpServiceDate;
                    row.EmpStatus                = empInfo.EmpStatus;


                    DBFilter empTermFilter = new DBFilter();
                    empTermFilter.add(new Match("EmpID", empInfo.EmpID));
                    ArrayList empTermList = EEmpTermination.db.select(dbConn, empTermFilter);
                    if (empTermList.Count > 0)
                    {
                        row.EmpTermLastDate = ((EEmpTermination)empTermList[0]).EmpTermLastDate;
                    }


                    dataSet.employeedetail.AddemployeedetailRow(row);



                    DBFilter empPayrollFilter = new DBFilter();
                    empPayrollFilter.add(new Match("EmpID", empInfo.EmpID));
                    OR orPayrollBatch = new OR();
                    foreach (EPayrollBatch payBatch in PayrollBatchList)
                    {
                        orPayrollBatch.add(new Match("PayBatchID", payBatch.PayBatchID));
                    }
                    empPayrollFilter.add(orPayrollBatch);

                    IN inEmpPayroll = new IN("EmpPayrollID", "Select EmpPayrollID from EmpPayroll", empPayrollFilter);

                    DBFilter autoPayPaymentRecordFilter = new DBFilter();
                    autoPayPaymentRecordFilter.add(inEmpPayroll);
                    autoPayPaymentRecordFilter.add("EmpAccID", true);
                    ArrayList autoPayPaymentRecords = EPaymentRecord.db.select(dbConn, autoPayPaymentRecordFilter);

                    foreach (EPaymentRecord paymentRecord in autoPayPaymentRecords)
                    {
                        DataSet.Payroll_NetPaymentList.PaymentRecordRow paymentRow = dataSet.PaymentRecord.NewPaymentRecordRow();
                        paymentRow.PayRecID        = paymentRecord.PayRecID;
                        paymentRow.EmpID           = empInfo.EmpID;
                        paymentRow.PayRecActAmount = paymentRecord.PayRecActAmount;
                        paymentRow.PayRecMethod    = paymentRecord.PayRecMethod;
                        paymentRow.EmpAccountNo    = string.Empty;

                        EEmpPayroll empPayroll = new EEmpPayroll();
                        empPayroll.EmpPayrollID = paymentRecord.EmpPayrollID;
                        if (EEmpPayroll.db.select(dbConn, empPayroll))
                        {
                            if (!empPayroll.EmpPayValueDate.Ticks.Equals(0))
                            {
                                paymentRow.EmpPayValueDate = empPayroll.EmpPayValueDate;
                            }
                        }

                        if (paymentRecord.PayRecMethod.Equals("A", StringComparison.CurrentCultureIgnoreCase))
                        {
                            //  Only Autopay payment show account no
                            EEmpBankAccount empBankAccount = new EEmpBankAccount();
                            empBankAccount.EmpBankAccountID = paymentRecord.EmpAccID;
                            if (EEmpBankAccount.db.select(dbConn, empBankAccount))
                            {
                                if (empBankAccount.EmpID.Equals(empInfo.EmpID))
                                {
                                    paymentRow.EmpAccountNo = empBankAccount.EmpBankCode + "-" + empBankAccount.EmpBranchCode + "-" + empBankAccount.EmpAccountNo;
                                    paymentRow.EmpAccID     = paymentRecord.EmpAccID;
                                }
                            }
                        }
                        dataSet.PaymentRecord.AddPaymentRecordRow(paymentRow);
                    }
                }
            }
            if (reportDocument == null)
            {
                reportDocument = new ReportTemplate.Report_Payroll_NetPaymentListByPaymentMethod();
            }
            else
            {
            }

            reportDocument.SetDataSource(dataSet);

            return(reportDocument);
        }
コード例 #30
0
    protected void Add_Click(object sender, EventArgs e)
    {
        //  Hard code set Currency to HKD
        CurrencyID.SelectedValue = "HKD";

        Repeater.EditItemIndex = -1;
        EPaymentRecord c = new EPaymentRecord();

        Hashtable values = new Hashtable();

        newBinding.toValues(values);

        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();


        db.validate(errors, values);

        if (!errors.isEmpty())
        {
            return;
        }


        db.parse(values, c);

        EEmpPayroll empPayroll = new EEmpPayroll();

        empPayroll.EmpPayrollID = c.EmpPayrollID;

        if (EEmpPayroll.db.select(dbConn, empPayroll))
        {
            if (c.PayRecMethod.Equals("A"))
            {
                if (c.EmpAccID == 0)
                {
                    EEmpBankAccount bankAccount = EEmpBankAccount.GetDefaultBankAccount(dbConn, empPayroll.EmpID);
                    if (bankAccount != null)
                    {
                        //c.EmpAccID = bankAccount.EmpBankAccountID;
                    }
                    else
                    {
                        errors.addError("EmpAccID", HROne.Translation.PageErrorMessage.ERROR_ACCOUNT_REQUIRED);
                    }
                }
            }
            if (!errors.isEmpty())
            {
                return;
            }


            c.PayRecCalAmount = 0;
            //c.PayRecNumOfDayAdj = 0;
            c.PayRecStatus = PaymentRecordStatus.PAYRECORDSTATUS_ACTIVE;
            if (EmpPayStatus.Value == "C")
            {
                c.PayRecType = PaymentRecordType.PAYRECORDTYPE_CONFIRM_ADJUSTMENT;
            }
            else
            {
                c.PayRecType = PaymentRecordType.PAYRECORDTYPE_TRIALRUN_ADJUSTMENT;
            }

            WebUtils.StartFunction(Session, m_FunctionCode, empPayroll.EmpID);
            db.insert(dbConn, c);
            WebUtils.EndFunction(dbConn);

            PaymentCodeID.SelectedIndex = 0;
            CurrencyID.SelectedIndex    = 0;
            PayRecActAmount.Text        = string.Empty;
            PayRecMethod.SelectedIndex  = 0;
            PayRecNumOfDayAdj.Text      = string.Empty;
            PayRecRemark.Text           = string.Empty;


            view = loadData(info, db, Repeater);
        }

        //Response.Redirect(Request.Url.LocalPath + "?" + Request.QueryString);
    }