示例#1
0
    protected void Repeater_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        HROne.Common.WebUtility.WebControlsLocalization(Session, e.Item.Controls);
        e.Item.FindControl("DeleteItem").Visible = IsAllowEdit;
        if (e.Item.ItemIndex == Repeater.EditItemIndex)
        {
            ebinding = new Binding(dbConn, db);
            ebinding.add((HtmlInputHidden)e.Item.FindControl("CostCenterID"));
            ebinding.add((TextBox)e.Item.FindControl("CostCenterCode"));
            ebinding.add((TextBox)e.Item.FindControl("CostCenterDesc"));
            ebinding.init(Request, Session);


            ECostCenter obj = new ECostCenter();
            db.toObject(((DataRowView)e.Item.DataItem).Row, obj);
            Hashtable values = new Hashtable();
            db.populate(obj, values);
            ebinding.toControl(values);
        }
        else
        {
            e.Item.FindControl("Edit").Visible = IsAllowEdit;
            HtmlInputHidden h = (HtmlInputHidden)e.Item.FindControl("CostCenterID");
            h.Value = ((DataRowView)e.Item.DataItem)["CostCenterID"].ToString();
        }
    }
示例#2
0
    protected void Repeater_ItemCommand(object source, DataListCommandEventArgs e)
    {
        Button b = (Button)e.CommandSource;



        if (b.ID.Equals("Edit"))
        {
            Repeater.EditItemIndex = e.Item.ItemIndex;
            view = loadData(info, db, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, false);
        }
        else if (b.ID.Equals("Cancel"))
        {
            Repeater.EditItemIndex = -1;
            view = loadData(info, db, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, true);
        }
        else if (b.ID.Equals("Save"))
        {
            ebinding = new Binding(dbConn, db);
            ebinding.add((HtmlInputHidden)e.Item.FindControl("CostCenterID"));
            ebinding.add((TextBox)e.Item.FindControl("CostCenterCode"));
            ebinding.add((TextBox)e.Item.FindControl("CostCenterDesc"));
            ebinding.init(Request, Session);


            ECostCenter obj    = new ECostCenter();
            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);
            if (!AppUtils.checkDuplicate(dbConn, db, obj, errors, "CostCenterCode"))
            {
                return;
            }

            WebUtils.StartFunction(Session, FUNCTION_CODE);
            db.update(dbConn, obj);
            WebUtils.EndFunction(dbConn);

            Repeater.EditItemIndex = -1;
            view = loadData(info, db, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, true);
        }
    }
示例#3
0
    protected void Add_Click(object sender, EventArgs e)
    {
        Repeater.EditItemIndex = -1;
        ECostCenter c = new ECostCenter();

        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 (!AppUtils.checkDuplicate(dbConn, db, c, errors, "CostCenterCode"))
        {
            return;
        }

        WebUtils.StartFunction(Session, FUNCTION_CODE);
        db.insert(dbConn, c);
        WebUtils.EndFunction(dbConn);

        CostCenterCode.Text = string.Empty;
        CostCenterDesc.Text = string.Empty;

        view = loadData(info, db, Repeater);
    }
示例#4
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);
                }
            }
        }
示例#5
0
    protected DataSet GenerateCND(int ProcessID, int PaymentCodeID, DateTime PaymentDate)
    {
        EPaymentCode m_paymentCode = EPaymentCode.GetObject(dbConn, PaymentCodeID);
        ECommissionAchievementImportBatch m_process = ECommissionAchievementImportBatch.GetObject(dbConn, ProcessID);

        DataSet   dataSet   = new DataSet();//export.GetDataSet();
        DataTable dataTable = new DataTable("ClaimsAndDeduction$");

        dataSet.Tables.Add(dataTable);

        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EMP_NO, typeof(string));
        dataTable.Columns.Add("English Name", typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EFFECTIVE_DATE, typeof(DateTime));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_CODE, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_BANK_ACCOUNT_NO, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_AMOUNT, typeof(double));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_NUM_OF_DAY_ADJUST, typeof(double));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REST_PAYMENT, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REMARK, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_COST_CENTER, typeof(string));

        DBFilter m_detailFilter = new DBFilter();

        m_detailFilter.add(new Match("CAImportBatchID", ProcessID));
        m_detailFilter.add("EmpID", true);

        foreach (ECommissionAchievement m_detail in ECommissionAchievement.db.select(dbConn, m_detailFilter))
        {
            DBFilter m_rpFilter = new DBFilter();
            OR       m_orDate   = new OR();

            m_orDate.add(new NullTerm("EmpRPEffTo"));
            m_orDate.add(new Match("EmpRPEffTo", ">=", m_detail.CAEffDate));

            m_rpFilter.add(m_orDate);
            m_rpFilter.add(new Match("EmpRPEffFr", "<=", m_detail.CAEffDate));
            m_rpFilter.add(new Match("EmpID", m_detail.EmpID));
            //m_rpFilter.add(new NullTerm("NOT EmpRPBasicSalary"));
            m_rpFilter.add(new Match("EmpRPBasicSalary", ">", 0));
            m_rpFilter.add(new Match("EmpRPFPS", "<", 100));
            m_rpFilter.add(new Match("EmpRPFPS", ">", 0));

            foreach (EEmpRecurringPayment m_empRP in EEmpRecurringPayment.db.select(dbConn, m_rpFilter))
            {
                double m_amount = m_empRP.EmpRPBasicSalary * m_detail.CAPercent / 100 - m_empRP.EmpRPAmount;
                string m_remarks;
                if (m_amount > 0 && Math.Abs(m_amount) >= 0.01)
                {
                    m_remarks = String.Format("({0}*{1}%) - {2}", m_empRP.EmpRPBasicSalary.ToString("#,##0.00"),
                                              m_detail.CAPercent.ToString("#,##0.00"),
                                              m_empRP.EmpRPAmount.ToString("#,##0.00"));

                    EEmpPersonalInfo m_empInfo = new EEmpPersonalInfo();
                    m_empInfo.EmpID = m_empRP.EmpID;
                    EEmpPersonalInfo.db.select(dbConn, m_empInfo);

                    DataRow m_row = dataTable.NewRow();
                    m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EMP_NO] = m_empInfo.EmpNo;
                    m_row["English Name"] = m_empInfo.EmpEngFullName;
                    m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EFFECTIVE_DATE] = PaymentDate;
                    m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_CODE]   = m_paymentCode.PaymentCode;
                    switch (m_empRP.EmpRPMethod)
                    {
                    case "A":
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Autopay";
                        break;

                    case "Q":
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Cheque";
                        break;

                    case "C":
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Cash";
                        break;

                    default:
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Other";
                        break;
                    }
                    m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_AMOUNT]            = Math.Round(m_amount, 2);
                    m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_NUM_OF_DAY_ADJUST] = 0; //DateTime.DaysInMonth(m_process.AsAtDate);
                    m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REST_PAYMENT]      = "No";
                    m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REMARK]            = m_remarks;

                    EEmpBankAccount m_bank = new EEmpBankAccount();
                    m_bank.EmpBankAccountID = m_empRP.EmpAccID;
                    if (EEmpBankAccount.db.select(dbConn, m_bank))
                    {
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_BANK_ACCOUNT_NO] = m_bank.EmpAccountNo;
                    }

                    ECostCenter m_costCenter = new ECostCenter();
                    m_costCenter.CostCenterID = m_empRP.CostCenterID;
                    if (ECostCenter.db.select(dbConn, m_costCenter))
                    {
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_COST_CENTER] = m_costCenter.CostCenterCode;
                    }
                    dataTable.Rows.Add(m_row);
                }
            }
        }
        return(dataSet);
    }
示例#6
0
    protected void Delete_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();

        ArrayList list = new ArrayList();

        foreach (DataListItem item in Repeater.Items)
        {
            CheckBox        c = (CheckBox)item.FindControl("DeleteItem");
            HtmlInputHidden h = (HtmlInputHidden)item.FindControl("CostCenterID");
            if (c.Checked)
            {
                ECostCenter obj = new ECostCenter();
                obj.CostCenterID = Int32.Parse(h.Value);
                list.Add(obj);
            }
        }
        foreach (ECostCenter obj in list)
        {
            if (ECostCenter.db.select(dbConn, obj))
            {
                {
                    DBFilter costAllocationDetailFilter = new DBFilter();
                    costAllocationDetailFilter.add(new Match("cad.CostCenterID", obj.CostCenterID));

                    DBFilter costAllocationFilter = new DBFilter();
                    costAllocationFilter.add(new IN("CostAllocationID", "SELECT DISTINCT cad.CostAllocationID FROM " + ECostAllocationDetail.db.dbclass.tableName + " cad", costAllocationDetailFilter));
                    costAllocationFilter.add("empid", true);
                    ArrayList CostAllocationList = ECostAllocation.db.select(dbConn, costAllocationFilter);
                    if (CostAllocationList.Count > 0)
                    {
                        int lastEmpID = 0;
                        errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_CODE_USED_BY_EMPLOYEE, new string[] { HROne.Common.WebUtility.GetLocalizedString("Cost Center Code"), obj.CostCenterCode }));
                        foreach (ECostAllocation costAllocation in CostAllocationList)
                        {
                            if (lastEmpID != costAllocation.EmpID)
                            {
                                EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
                                empInfo.EmpID = costAllocation.EmpID;
                                if (EEmpPersonalInfo.db.select(dbConn, empInfo))
                                {
                                    errors.addError("- " + empInfo.EmpNo + ", " + empInfo.EmpEngFullName);
                                    lastEmpID = costAllocation.EmpID;
                                }
                                else
                                {
                                    ECostAllocation.db.delete(dbConn, costAllocation);
                                }
                            }
                        }
                        errors.addError(HROne.Translation.PageErrorMessage.ERROR_ACTION_ABORT);
                        view = loadData(info, db, Repeater);
                        return;
                    }
                }
                {
                    DBFilter empCostCenterDetailFilter = new DBFilter();
                    empCostCenterDetailFilter.add(new Match("eccd.CostCenterID", obj.CostCenterID));

                    DBFilter empCostCenterFilter = new DBFilter();
                    empCostCenterFilter.add(new IN("EmpCostCenterID", "SELECT DISTINCT eccd.CostCenterID FROM " + EEmpCostCenterDetail.db.dbclass.tableName + " eccd", empCostCenterDetailFilter));
                    empCostCenterFilter.add("empid", true);
                    ArrayList empCostCenterList = EEmpCostCenter.db.select(dbConn, empCostCenterFilter);
                    if (empCostCenterList.Count > 0)
                    {
                        int lastEmpID = 0;
                        errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_CODE_USED_BY_EMPLOYEE, new string[] { HROne.Common.WebUtility.GetLocalizedString("Cost Center Code"), obj.CostCenterCode }));
                        foreach (EEmpCostCenter empCostCenter in empCostCenterList)
                        {
                            if (lastEmpID != empCostCenter.EmpID)
                            {
                                EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
                                empInfo.EmpID = empCostCenter.EmpID;
                                if (EEmpPersonalInfo.db.select(dbConn, empInfo))
                                {
                                    errors.addError("- " + empInfo.EmpNo + ", " + empInfo.EmpEngFullName);
                                    lastEmpID = empCostCenter.EmpID;
                                }
                                else
                                {
                                    EEmpCostCenter.db.delete(dbConn, empCostCenter);
                                }
                            }
                        }
                        errors.addError(HROne.Translation.PageErrorMessage.ERROR_ACTION_ABORT);
                        view = loadData(info, db, Repeater);
                        return;
                    }
                }
                if (errors.isEmpty())
                {
                    WebUtils.StartFunction(Session, FUNCTION_CODE);
                    db.delete(dbConn, obj);
                    WebUtils.EndFunction(dbConn);
                }
            }
        }
        view = loadData(info, db, Repeater);
    }
    protected void btnExport_Click(object sender, EventArgs e)
    {
        ArrayList list = WebUtils.SelectedRepeaterItemToBaseObjectList(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";
            HROne.Export.ExcelExport export = new HROne.Export.ExcelExport(exportFileName);
            DataSet dataSet = new DataSet();

            DataTable tmpDataTable = dataSet.Tables.Add(TABLE_NAME);
            tmpDataTable.Columns.Add(FIELD_EMP_NO, typeof(string));
            tmpDataTable.Columns.Add(FIELD_EMP_NAME, typeof(string));
            tmpDataTable.Columns.Add(FIELD_JOB_TITLE, typeof(string));
            tmpDataTable.Columns.Add(FIELD_FROM, typeof(DateTime));
            tmpDataTable.Columns.Add(FIELD_TO, typeof(DateTime));
            tmpDataTable.Columns.Add(FIELD_COST_CENTER, typeof(string));
            tmpDataTable.Columns.Add(FIELD_PERCENTAGE, typeof(double));

            foreach (EEmpPersonalInfo obj in list)
            {
                if (EEmpPersonalInfo.db.select(dbConn, obj))
                {
                    // get job title
                    string           empJobTitle     = null;
                    EEmpPositionInfo empPositionInfo = AppUtils.GetLastPositionInfo(dbConn, AppUtils.ServerDateTime().Date, obj.EmpID);
                    if (empPositionInfo != null)
                    {
                        EPosition position = new EPosition();
                        position.PositionID = empPositionInfo.PositionID;
                        if (EPosition.db.select(dbConn, position))
                        {
                            empJobTitle = position.PositionDesc;
                        }
                    }

                    DBFilter filter = new DBFilter();
                    filter.add(new Match("EmpID", obj.EmpID));

                    string m_year  = this.Year.Text;  // ((TextBox)EmployeeSearchControl1.AdditionElementControl.FindControl("Year")).Text;
                    string m_month = this.Month.Text; // ((DropDownList)EmployeeSearchControl1.AdditionElementControl.FindControl("Month")).SelectedValue;


                    filter.add(getEffRangeDBTerm(m_year, m_month, null));
                    ArrayList empCsts = EEmpCostCenter.db.select(dbConn, filter);

                    foreach (EEmpCostCenter empCostCenter in empCsts)
                    {
                        DBFilter empCstDetailFilter = new DBFilter();
                        empCstDetailFilter.add(new Match("EmpCostCenterID", empCostCenter.EmpCostCenterID));
                        ArrayList empCstDetailList = EEmpCostCenterDetail.db.select(dbConn, empCstDetailFilter);
                        foreach (EEmpCostCenterDetail detail in empCstDetailList)
                        {
                            DataRow row = tmpDataTable.NewRow();
                            row[FIELD_EMP_NO]   = obj.EmpNo;
                            row[FIELD_EMP_NAME] = obj.EmpEngFullNameWithAlias;
                            //for field Job Title
                            if (!string.IsNullOrEmpty(empJobTitle))
                            {
                                row[FIELD_JOB_TITLE] = empJobTitle;
                            }
                            //for fields From and To
                            row[FIELD_FROM] = empCostCenter.EmpCostCenterEffFr;
                            row[FIELD_TO]   = empCostCenter.EmpCostCenterEffTo;
                            //for field Cost Center
                            ECostCenter costCenter = new ECostCenter();
                            costCenter.CostCenterID = detail.CostCenterID;
                            if (ECostCenter.db.select(dbConn, costCenter))
                            {
                                row[FIELD_COST_CENTER] = costCenter.CostCenterDesc;//costCenter.CostCenterCode
                            }
                            //for field Percentage
                            row[FIELD_PERCENTAGE] = detail.EmpCostCenterPercentage;

                            //add row data to data table
                            tmpDataTable.Rows.Add(row);
                        }
                    }
                }
            }

            export.Update(dataSet);
            WebUtils.TransmitFile(Response, exportFileName, "CostCenterExportReport_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + ".xls", true);
            Response.End();
        }

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

        view = loadData(info, db, Repeater);
    }
    private DataSet GenerateBackpayTemplate(String schemeCode, int paymentCodeID, DateTime paymentDate)
    {
        //Dictionary<int, string> m_PaymentCodeList = new Dictionary<int, string>();
        //foreach (EPaymentCode o in EPaymentCode.db.select(dbConn, new DBFilter()))
        //{
        //    m_PaymentCodeList.Add(o.PaymentCodeID, o.PaymentCode);
        //}

        string m_paymentCode = (EPaymentCode.GetObject(dbConn, paymentCodeID)).PaymentCode;

        DataSet   dataSet   = new DataSet();//export.GetDataSet();
        DataTable dataTable = new DataTable("ClaimsAndDeduction$");

        dataSet.Tables.Add(dataTable);

        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EMP_NO, typeof(string));
        dataTable.Columns.Add("English Name", typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EFFECTIVE_DATE, typeof(DateTime));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_CODE, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_BANK_ACCOUNT_NO, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_AMOUNT, typeof(double));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_NUM_OF_DAY_ADJUST, typeof(double));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REST_PAYMENT, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REMARK, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_COST_CENTER, typeof(string));

        DBFilter m_payscaleFilter = new DBFilter();

        m_payscaleFilter.add(new NullTerm("ExpiryDate"));

        if (schemeCode != "")
        {
            m_payscaleFilter.add(new Match("SchemeCode", schemeCode));
        }

        m_payscaleFilter.add("EffectiveDate", false);

        foreach (EPayScaleMap m_latestPayscale in EPayScaleMap.db.select(dbConn, m_payscaleFilter))
        {
            DBFilter m_payPeriodFilter = new DBFilter();
            m_payPeriodFilter.add(new Match("PayPeriodFr", ">=", m_latestPayscale.EffectiveDate));
            m_payPeriodFilter.add(new Match("PayPeriodStatus", "=", EPayrollPeriod.PAYPERIOD_STATUS_PROCESSEND_FLAG));
            m_payPeriodFilter.add(WebUtils.AddRankFilter(Session, "EmpID", true));

            foreach (EPayrollPeriod m_payrollPeriod in EPayrollPeriod.db.select(dbConn, m_payPeriodFilter))
            {
                DBFilter m_empPayrollFilter = new DBFilter();
                m_empPayrollFilter.add(new Match("PayPeriodID", m_payrollPeriod.PayPeriodID));

                DBFilter m_paymentRecordFilter = new DBFilter();
                DBFilter m_paymentTypeFilter   = new DBFilter();
                DBFilter m_paymentCodeFilter   = new DBFilter();

                m_paymentTypeFilter.add(new Match("PaymentTypeCode", "BASICSAL"));
                m_paymentCodeFilter.add(new IN("PaymentTypeID", "SELECT PaymentTypeID FROM PaymentType", m_paymentTypeFilter));

                m_paymentRecordFilter.add(new Match("EmpRPIDforBP", ">", 0));
                m_paymentRecordFilter.add(new IN("EmpPayrollID", "SELECT EmpPayrollID FROM EmpPayroll", m_empPayrollFilter));
                m_paymentRecordFilter.add(new IN("PaymentCodeID", "SELECT PaymentCodeID FROM PaymentCode", m_paymentCodeFilter));

                foreach (EPaymentRecord m_payRecord in EPaymentRecord.db.select(dbConn, m_paymentRecordFilter))
                {
                    EEmpRecurringPayment m_empRP = EEmpRecurringPayment.GetObject(dbConn, m_payRecord.EmpRPIDforBP);

                    if (schemeCode != "")
                    {
                        if (m_empRP.SchemeCode == null || m_empRP.SchemeCode != schemeCode)
                        {
                            break;
                        }
                    }
                    decimal m_newSalary = GetPayScale(m_empRP);
                    string  m_remarks   = "";
                    double  m_amount    = 0;
                    if (m_newSalary > 0)
                    {
//                        m_amount = Math.Round((m_payRecord.PayRecActAmount / m_empRP.EmpRPAmount) * (System.Convert.ToDouble(m_newSalary) - m_empRP.EmpRPAmount), 2);

                        int m_daysInMonth = DateTime.DaysInMonth(m_payrollPeriod.PayPeriodFr.Year, m_payrollPeriod.PayPeriodFr.Month);
                        if (m_payRecord.PayRecNumOfDayAdj != m_daysInMonth)
                        {
                            m_amount = Math.Round((System.Convert.ToDouble(m_newSalary) - m_empRP.EmpRPAmount) * m_payRecord.PayRecNumOfDayAdj / m_daysInMonth, 2);

                            m_remarks = String.Format("Backpay {0}: ({1}-{2})*{3}/{4}.", m_payrollPeriod.PayPeriodFr.ToString("yyyy-MM"),
                                                      m_newSalary.ToString("#,##0.00"),
                                                      m_empRP.EmpRPAmount.ToString("#,##0.00"),
                                                      m_payRecord.PayRecNumOfDayAdj,
                                                      m_daysInMonth);
                        }
                        else
                        {
                            m_amount  = Math.Round((System.Convert.ToDouble(m_newSalary) - m_empRP.EmpRPAmount), 2);
                            m_remarks = String.Format("Backpay {0}: {1}-{2}.", m_payrollPeriod.PayPeriodFr.ToString("yyyy-MM"),
                                                      m_newSalary.ToString("#,##0.00"),
                                                      m_empRP.EmpRPAmount.ToString("#,##0.00"));
                        }
                        if (m_amount > 0)
                        {
                            EEmpPersonalInfo m_empInfo = new EEmpPersonalInfo();
                            m_empInfo.EmpID = m_empRP.EmpID;
                            EEmpPersonalInfo.db.select(dbConn, m_empInfo);

                            DataRow m_row = dataTable.NewRow();
                            m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EMP_NO] = m_empInfo.EmpNo;
                            m_row["English Name"] = m_empInfo.EmpEngFullName;
                            m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EFFECTIVE_DATE] = paymentDate;
                            m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_CODE]   = m_paymentCode;
                            switch (m_empRP.EmpRPMethod)
                            {
                            case "A":
                                m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Autopay";
                                break;

                            case "Q":
                                m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Cheque";
                                break;

                            case "C":
                                m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Cash";
                                break;

                            default:
                                m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Other";
                                break;
                            }
                            m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_AMOUNT]            = m_amount;
                            m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_NUM_OF_DAY_ADJUST] = 0;
                            m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REST_PAYMENT]      = "No";
                            m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REMARK]            = m_remarks;

                            EEmpBankAccount m_bank = new EEmpBankAccount();
                            m_bank.EmpBankAccountID = m_empRP.EmpAccID;
                            if (EEmpBankAccount.db.select(dbConn, m_bank))
                            {
                                m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_BANK_ACCOUNT_NO] = m_bank.EmpAccountNo;
                            }

                            ECostCenter m_costCenter = new ECostCenter();
                            m_costCenter.CostCenterID = m_empRP.CostCenterID;
                            if (ECostCenter.db.select(dbConn, m_costCenter))
                            {
                                m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_COST_CENTER] = m_costCenter.CostCenterCode;
                            }
                            dataTable.Rows.Add(m_row);
                        }
                    }
                }
            }
            break;  // handle only 1 effective date
        }
        return(dataSet);
    }
示例#9
0
    protected void btnExport_Click(object sender, EventArgs e)
    {
        startMonth = DateTime.Parse(Year.Text + "-" + Month.SelectedValue + "-1");
        tempMonth  = DateTime.Parse(Year2.Text + "-" + Month2.SelectedValue + "-1");
        endMonth   = tempMonth.AddMonths(1).AddDays(-1);

        int report_range_days = ((TimeSpan)(endMonth - startMonth)).Days + 1;

        if (report_range_days <= 0)
        {
            PageErrors errors = PageErrors.getErrors(db, Page.Master);
            errors.addError("Invalid Date Range Parameter: From-Date must be prior to To-Date");
            return;
        }

        peroid = "Period: " + startMonth.ToString("yyyy-MM-dd") + " to " + endMonth.ToString("yyyy-MM-dd");

        ArrayList list = WebUtils.SelectedRepeaterItemToBaseObjectList(db, Repeater, "ItemSelect");

        if (list.Count > 0)
        {
            string exportFileName = System.IO.Path.GetTempFileName();
            System.IO.File.Delete(exportFileName);
            exportFileName += ".xls";
            HROne.Export.ExcelExport export = new HROne.Export.ExcelExport(exportFileName);

            DataTable tmpDataTable = new DataTable(TABLE_NAME);
            tmpDataTable.Columns.Add(FIELD_COMPANY, typeof(string));
            tmpDataTable.Columns.Add(FIELD_DIVISION, typeof(string));
            tmpDataTable.Columns.Add(FIELD_DEPARTMENT, typeof(string));
            tmpDataTable.Columns.Add(FIELD_SECTION, typeof(string));
            tmpDataTable.Columns.Add(FIELD_EMP_NO, typeof(string));
            tmpDataTable.Columns.Add(FIELD_EMP_NAME, typeof(string));
            tmpDataTable.Columns.Add(FIELD_ALIAS, typeof(string));
            tmpDataTable.Columns.Add(FIELD_POSITION, typeof(string));
            tmpDataTable.Columns.Add(FIELD_FROM, typeof(DateTime));
            tmpDataTable.Columns.Add(FIELD_TO, typeof(DateTime));
            tmpDataTable.Columns.Add(FIELD_COST_CENTER, typeof(string));
            tmpDataTable.Columns.Add(FIELD_PERCENTAGE, typeof(double));

            foreach (EEmpPersonalInfo obj in list)
            {
                if (EEmpPersonalInfo.db.select(dbConn, obj))
                {
                    DBFilter filter = new DBFilter();
                    filter.add(new Match("EmpID", obj.EmpID));
                    ArrayList empCsts = EEmpCostCenter.db.select(dbConn, filter);

                    foreach (EEmpCostCenter empCostCenter in empCsts)
                    {
                        DBFilter empCstDetailFilter = new DBFilter();
                        empCstDetailFilter.add(new Match("EmpCostCenterID", empCostCenter.EmpCostCenterID));
                        ArrayList empCstDetailList = EEmpCostCenterDetail.db.select(dbConn, empCstDetailFilter);
                        foreach (EEmpCostCenterDetail detail in empCstDetailList)
                        {
                            DataRow row = tmpDataTable.NewRow();

                            EEmpPositionInfo empPos = AppUtils.GetLastPositionInfo(dbConn, AppUtils.ServerDateTime(), obj.EmpID);
                            if (empPos != null)
                            {
                                DBFilter positionFilter = new DBFilter();
                                positionFilter.add(new Match("PositionID", empPos.PositionID));
                                ArrayList positionList = EPosition.db.select(dbConn, positionFilter);
                                EPosition postion      = (EPosition)positionList[0];
                                row[FIELD_POSITION] = postion.PositionDesc;

                                ECompany company = new ECompany();
                                company.CompanyID = empPos.CompanyID;
                                if (ECompany.db.select(dbConn, company))
                                {
                                    row[FIELD_COMPANY] = company.CompanyName;
                                }
                                DBFilter empHierarchyFilter = new DBFilter();
                                empHierarchyFilter.add(new Match("EmpPosID", empPos.EmpPosID));
                                ArrayList empHierarchyList = EEmpHierarchy.db.select(dbConn, empHierarchyFilter);
                                foreach (EEmpHierarchy empHierarchy in empHierarchyList)
                                {
                                    EHierarchyElement hierarchyElement = new EHierarchyElement();
                                    hierarchyElement.HElementID = empHierarchy.HElementID;
                                    if (EHierarchyElement.db.select(dbConn, hierarchyElement))
                                    {
                                        if (hierarchyElement.HLevelID == 1)
                                        {
                                            row[FIELD_DEPARTMENT] = hierarchyElement.HElementDesc;
                                        }
                                        else if (hierarchyElement.HLevelID == 2)
                                        {
                                            row[FIELD_DIVISION] = hierarchyElement.HElementDesc;
                                        }
                                        else if (hierarchyElement.HLevelID == 3)
                                        {
                                            row[FIELD_SECTION] = hierarchyElement.HElementDesc;
                                        }
                                    }
                                }
                            }

                            row[FIELD_EMP_NO]   = obj.EmpNo;
                            row[FIELD_EMP_NAME] = obj.EmpEngFullName;
                            row[FIELD_ALIAS]    = obj.EmpAlias;

                            //Fields From and To
                            row[FIELD_FROM] = empCostCenter.EmpCostCenterEffFr;
                            row[FIELD_TO]   = empCostCenter.EmpCostCenterEffTo;

                            //Field Cost Center
                            ECostCenter costCenter = new ECostCenter();
                            costCenter.CostCenterID = detail.CostCenterID;
                            if (ECostCenter.db.select(dbConn, costCenter))
                            {
                                row[FIELD_COST_CENTER] = costCenter.CostCenterDesc;//costCenter.CostCenterCode
                            }

                            //Field average percentage
                            TimeSpan ts;
                            if ((empCostCenter.EmpCostCenterEffTo <= DateTime.Parse("0001-01-01")) && empCostCenter.EmpCostCenterEffFr < startMonth) // check EmpCostCenterEffTo is null and EmpCostCenterEffFr less than Date-Range-From
                            {
                                row[FIELD_FROM] = startMonth;
                                row[FIELD_TO]   = endMonth;
                                ts = endMonth - startMonth;
                            }
                            else if ((empCostCenter.EmpCostCenterEffTo <= DateTime.Parse("0001-01-01"))) // check EmpCostCenterEffTo is null, use Date-Range-To value
                            {
                                row[FIELD_TO] = endMonth;
                                ts            = endMonth - empCostCenter.EmpCostCenterEffFr;
                            }
                            else if (empCostCenter.EmpCostCenterEffFr < startMonth) // check EmpCostCenterEffFr less than Date-Range-From, use Date-Range-From value
                            {
                                row[FIELD_FROM] = startMonth;
                                ts = empCostCenter.EmpCostCenterEffTo - startMonth;
                            }
                            else
                            {
                                ts = empCostCenter.EmpCostCenterEffTo - empCostCenter.EmpCostCenterEffFr;
                            }
                            double day = ts.Days + 1;
                            row[FIELD_PERCENTAGE] = detail.EmpCostCenterPercentage * (day / report_range_days);

                            //add row data to data table
                            tmpDataTable.Rows.Add(row);
                        }
                    }
                }
            }
            GenerateExcelReport(tmpDataTable, exportFileName);

            WebUtils.TransmitFile(Response, exportFileName, "AverageCostCenterExportReport_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + ".xls", true);
            Response.End();
        }
        else
        {
            PageErrors errors = PageErrors.getErrors(db, Page.Master);
            errors.addError("Employee not selected");
        }

        //view = loadData(info, db, Repeater);
    }
    protected void btnExport_Click(object sender, EventArgs e)
    {
        ArrayList list = WebUtils.SelectedRepeaterItemToBaseObjectList(ECostAllocation.db, Repeater, "ItemSelect");

        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();
            DataTable dataTable = new DataTable("CostAllocation$");
            dataSet.Tables.Add(dataTable);
            dataTable.Columns.Add("Company", typeof(string));

            DBFilter  hierarchyLevelFilter    = new DBFilter();
            Hashtable hierarchyLevelHashTable = new Hashtable();
            hierarchyLevelFilter.add("HLevelSeqNo", true);
            ArrayList hierarchyLevelList = EHierarchyLevel.db.select(dbConn, hierarchyLevelFilter);
            foreach (EHierarchyLevel hlevel in hierarchyLevelList)
            {
                dataTable.Columns.Add(hlevel.HLevelDesc, typeof(string));
                hierarchyLevelHashTable.Add(hlevel.HLevelID, hlevel);
            }

            dataTable.Columns.Add("EmployeeID", typeof(string));
            dataTable.Columns.Add("EnglishName", typeof(string));
            dataTable.Columns.Add("ChineseName", typeof(string));
            dataTable.Columns.Add("PaymentCodeDesc", typeof(string));
            dataTable.Columns.Add("CostCenterCode", typeof(string));
            dataTable.Columns.Add("Amount", typeof(double));

            foreach (ECostAllocation obj in list)
            {
                if (ECostAllocation.db.select(dbConn, obj))
                {
                    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);

                        DataRow row = dataTable.NewRow();
                        row["EmployeeID"]  = empInfo.EmpNo;
                        row["EnglishName"] = empInfo.EmpEngFullName;;
                        row["ChineseName"] = empInfo.EmpChiFullName;
                        row["Company"]     = company.CompanyCode;

                        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))
                                {
                                    row[hierarchyLevel.HLevelDesc] = hierarchyElement.HElementCode;
                                }
                            }
                        }
                        EPaymentCode paymentCode = new EPaymentCode();
                        paymentCode.PaymentCodeID = detail.PaymentCodeID;
                        EPaymentCode.db.select(dbConn, paymentCode);
                        if (detail.CostAllocationDetailIsContribution)
                        {
                            row["PaymentCodeDesc"] = paymentCode.PaymentCodeDesc + "(Contribution)";
                        }
                        else
                        {
                            row["PaymentCodeDesc"] = paymentCode.PaymentCodeDesc;
                        }

                        ECostCenter costCenter = new ECostCenter();
                        costCenter.CostCenterID = detail.CostCenterID;
                        ECostCenter.db.select(dbConn, costCenter);
                        row["CostCenterCode"] = costCenter.CostCenterCode;
                        row["Amount"]         = detail.CostAllocationDetailAmount;

                        dataTable.Rows.Add(row);
                    }
                }
            }
            export.Update(dataSet);
            WebUtils.TransmitFile(Response, exportFileName, "CostALlocation" + (CostAllocationStatus.SelectedValue.Equals("T")?"Trial":"Confirm") + "_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + ".xls", true);
            return;
        }

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

        view = loadData(info, EEmpPayroll.db, Repeater);
    }
示例#11
0
        private ArrayList CreateCostAllocationRecordList(DateTime startDate, DateTime endDate, ArrayList empPosList, ArrayList empCostCenterList, int PaymentCodeID, double Amount, int PaymentRecordID, bool IsContribution, int overrideCostCenterID)
        {
            if (!Amount.Equals(0))
            {
                ArrayList costAllocationDetailList = 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.Ticks.Equals(0))
                    {
                        if (empPos.EmpPosEffTo < posEndDate)
                        {
                            if (empPos.EmpPosEffTo >= posStartDate)
                            {
                                posEndDate = empPos.EmpPosEffTo;
                            }
                            else
                            {
                                posEndDate = new DateTime();
                            }
                        }
                    }

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


                    ECostCenter overrideCostCenter = new ECostCenter();
                    overrideCostCenter.CostCenterID = overrideCostCenterID;
                    if (ECostCenter.db.select(dbConn, overrideCostCenter))
                    {
                        DateTime costStartDate = posStartDate;
                        DateTime costEndDate   = posEndDate;
                        int      numOfDays     = ((TimeSpan)costEndDate.AddDays(1).Subtract(costStartDate)).Days;
                        daysTotal += numOfDays;

                        ECostAllocationDetail costAllocDetail = new ECostAllocationDetail();
                        costAllocDetail.HierarchyElementList = new ArrayList();
                        costAllocDetail.CostCenterID         = overrideCostCenterID;
                        costAllocDetail.CostAllocationDetailRoundCalAmount = Amount * numOfDays * 100;
                        costAllocDetail.PaymentCodeID = PaymentCodeID;
                        costAllocDetail.PayRecID      = PaymentRecordID;
                        costAllocDetail.CompanyID     = empPos.CompanyID;
                        costAllocDetail.CostAllocationDetailIsContribution = IsContribution;
                        costAllocationDetailList.Add(costAllocDetail);

                        foreach (EEmpHierarchy empHierarchy in empHiererchyElementList)
                        {
                            ECostAllocationDetailHElement costAllocHierarchy = new ECostAllocationDetailHElement();
                            costAllocHierarchy.HElementID = empHierarchy.HElementID;
                            costAllocHierarchy.HLevelID   = empHierarchy.HLevelID;
                            costAllocHierarchy.RelatedCostAllocationDetailObject = costAllocDetail;
                            costAllocDetail.HierarchyElementList.Add(costAllocHierarchy);
                        }
                    }
                    else
                    {
                        //double percentagePaymentTotal = 0;


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

                            if (empCostCenter.EmpCostCenterEffFr > costStartDate)
                            {
                                costStartDate = empCostCenter.EmpCostCenterEffFr;
                            }

                            if (!empCostCenter.EmpCostCenterEffTo.Ticks.Equals(0))
                            {
                                if (empCostCenter.EmpCostCenterEffTo < costEndDate)
                                {
                                    if (empCostCenter.EmpCostCenterEffTo >= costStartDate)
                                    {
                                        costEndDate = empCostCenter.EmpCostCenterEffTo;
                                    }
                                    else
                                    {
                                        costEndDate = new DateTime();
                                    }
                                }
                            }

                            if (costStartDate > costEndDate)
                            {
                                continue;
                            }

                            int numOfDays = ((TimeSpan)costEndDate.AddDays(1).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.HierarchyElementList = new ArrayList();
                                costAllocDetail.CostCenterID         = empCostCenterDetail.CostCenterID;
                                costAllocDetail.CostAllocationDetailRoundCalAmount = Amount * numOfDays * empCostCenterDetail.EmpCostCenterPercentage;
                                costAllocDetail.PaymentCodeID = PaymentCodeID;
                                costAllocDetail.PayRecID      = PaymentRecordID;
                                costAllocDetail.CompanyID     = empPos.CompanyID;
                                costAllocDetail.CostAllocationDetailIsContribution = IsContribution;
                                costAllocationDetailList.Add(costAllocDetail);

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

                                percentageCostCenterTotal += empCostCenterDetail.EmpCostCenterPercentage;
                            }

                            if (Math.Round(Math.Abs(percentageCostCenterTotal - 100), 2, MidpointRounding.AwayFromZero) > 0)
                            {
                                throw new Exception(HROne.Common.WebUtility.GetLocalizedStringByCode(ERROR_TOTAL_PERCENTAGE_NOT_100, "Total percentage must be 100%.") + "(" + HROne.Common.WebUtility.GetLocalizedStringByCode("EmpNo", "Employee No") + ": {0})");
                            }
                        }
                    }
                }
                double totalCostAllocPayment = 0;

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

                double diff = Math.Round(Amount - totalCostAllocPayment, 2, MidpointRounding.AwayFromZero);
                if (Math.Abs(diff) >= 0.01 && costAllocationDetailList.Count > 0)
                {
                    if (diff > 0)
                    {
                        while (diff >= 0.01)
                        {
                            ECostAllocationDetail minCostAllocationDetail = null;
                            double minDiff = 1;
                            foreach (ECostAllocationDetail costAllocationDetail in costAllocationDetailList)
                            {
                                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 (diff <= -0.01)
                        {
                            ECostAllocationDetail maxCostAllocationDetail = null;
                            double maxDiff = -1;
                            foreach (ECostAllocationDetail costAllocationDetail in costAllocationDetailList)
                            {
                                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(costAllocationDetailList);


                return(costAllocationDetailList);
            }
            else
            {
                return(new ArrayList());
            }
            //ArrayList mpfRecordList = EMPFRecord.db.select(dbConn, paymentRecordFilter);

            //foreach (EMPFRecord mpfRecord in mpfRecordList)
            //{
            //    ArrayList costAllocationDetailListByMPFRecordMCEE = new ArrayList();
            //    ArrayList costAllocationDetailListByMPFRecordMCER = new ArrayList();
            //    ArrayList costAllocationDetailListByMPFRecordVCEE = new ArrayList();
            //    ArrayList costAllocationDetailListByMPFRecordVCER = 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 costAllocMCEEDetail = new ECostAllocationDetail();
            //                ECostAllocationDetail costAllocMCERDetail = new ECostAllocationDetail();
            //                ECostAllocationDetail costAllocVCEEDetail = new ECostAllocationDetail();
            //                ECostAllocationDetail costAllocVCERDetail = new ECostAllocationDetail();
            //                costAllocMCEEDetail.CostCenterID = empCostCenterDetail.CostCenterID;
            //                costAllocMCEEDetail.CostAllocationDetailRoundCalAmount = mpfRecord.MPFRecActMCEE * daysTotal * empCostCenterDetail.EmpCostCenterPercentage;
            //                costAllocMCEEDetail.PaymentCodeID = ((EPaymentCode)PayrollProcess.GetPaymentCodeByPaymentType(dbConn, "MPFEE")[0]).PaymentCode;
            //                costAllocMCEEDetail.PayRecID = mpfRecord.MPFRecordID;
            //                costAllocMCEEDetail.CompanyID = empPos.CompanyID;
            //                costAllocationDetailListByMPFRecordMCEE.Add(costAllocMCEEDetail);

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

            //                costAllocMCERDetail.CostCenterID = empCostCenterDetail.CostCenterID;
            //                costAllocMCERDetail.CostAllocationDetailRoundCalAmount = mpfRecord.MPFRecActMCER * daysTotal * empCostCenterDetail.EmpCostCenterPercentage;
            //                costAllocMCERDetail.PaymentCodeID = ((EPaymentCode)PayrollProcess.GetPaymentCodeByPaymentType(dbConn, "MPFER")[0]).PaymentCode;
            //                costAllocMCERDetail.PayRecID = mpfRecord.MPFRecordID;
            //                costAllocMCERDetail.CompanyID = empPos.CompanyID;
            //                costAllocationDetailListByMPFRecordMCER.Add(costAllocMCERDetail);

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

            //                costAllocVCEEDetail.CostCenterID = empCostCenterDetail.CostCenterID;
            //                costAllocVCEEDetail.CostAllocationDetailRoundCalAmount = mpfRecord.MPFRecActVCEE * daysTotal * empCostCenterDetail.EmpCostCenterPercentage;
            //                costAllocVCEEDetail.PaymentCodeID = ((EPaymentCode)PayrollProcess.GetPaymentCodeByPaymentType(dbConn, "TOPUPEE")[0]).PaymentCode;
            //                costAllocVCEEDetail.PayRecID = mpfRecord.MPFRecordID;
            //                costAllocVCEEDetail.CompanyID = empPos.CompanyID;
            //                costAllocationDetailListByMPFRecordVCEE.Add(costAllocVCEEDetail);

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

            //                costAllocVCERDetail.CostCenterID = empCostCenterDetail.CostCenterID;
            //                costAllocVCERDetail.CostAllocationDetailRoundCalAmount = mpfRecord.MPFRecActVCER * daysTotal * empCostCenterDetail.EmpCostCenterPercentage;
            //                costAllocVCERDetail.PaymentCodeID = ((EPaymentCode)PayrollProcess.GetPaymentCodeByPaymentType(dbConn, "TOPUPER")[0]).PaymentCode;
            //                costAllocVCERDetail.PayRecID = mpfRecord.MPFRecordID;
            //                costAllocVCERDetail.CompanyID = empPos.CompanyID;
            //                costAllocationDetailListByMPFRecordVCER.Add(costAllocVCERDetail);

            //                foreach (EEmpHierarchy empHierarchy in empHiererchyElementList)
            //                {
            //                    ECostAllocationDetailHElement costAllocHierarchy = new ECostAllocationDetailHElement();
            //                    costAllocHierarchy.HElementID = empHierarchy.HElementID;
            //                    costAllocHierarchy.HLevelID = empHierarchy.HLevelID;
            //                    costAllocHierarchy.RelatedCostAllocationDetailObject = costAllocVCERDetail;
            //                    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 totalCostAllocPaymentMCEE = 0;
            //    double totalCostAllocPaymentMCER = 0;
            //    double totalCostAllocPaymentVCEE = 0;
            //    double totalCostAllocPaymentVCER = 0;
            //    foreach (ECostAllocationDetail costAllocationDetail in costAllocationDetailListByMPFRecordMCEE)
            //    {
            //        costAllocationDetail.CostAllocationDetailRoundCalAmount = costAllocationDetail.CostAllocationDetailRoundCalAmount / (100 * daysTotal);
            //        costAllocationDetail.CostAllocationDetailAmount = Math.Round(costAllocationDetail.CostAllocationDetailRoundCalAmount, 2, MidpointRounding.AwayFromZero);
            //        totalCostAllocPaymentMCEE += costAllocationDetail.CostAllocationDetailAmount;
            //    }
            //    foreach (ECostAllocationDetail costAllocationDetail in costAllocationDetailListByMPFRecordMCER)
            //    {
            //        costAllocationDetail.CostAllocationDetailRoundCalAmount = costAllocationDetail.CostAllocationDetailRoundCalAmount / (100 * daysTotal);
            //        costAllocationDetail.CostAllocationDetailAmount = Math.Round(costAllocationDetail.CostAllocationDetailRoundCalAmount, 2, MidpointRounding.AwayFromZero);
            //        totalCostAllocPaymentMCER += costAllocationDetail.CostAllocationDetailAmount;
            //    }
            //    foreach (ECostAllocationDetail costAllocationDetail in costAllocationDetailListByMPFRecordVCEE)
            //    {
            //        costAllocationDetail.CostAllocationDetailRoundCalAmount = costAllocationDetail.CostAllocationDetailRoundCalAmount / (100 * daysTotal);
            //        costAllocationDetail.CostAllocationDetailAmount = Math.Round(costAllocationDetail.CostAllocationDetailRoundCalAmount, 2, MidpointRounding.AwayFromZero);
            //        totalCostAllocPaymentVCEE += costAllocationDetail.CostAllocationDetailAmount;
            //    }
            //    foreach (ECostAllocationDetail costAllocationDetail in costAllocationDetailListByMPFRecordVCER)
            //    {
            //        costAllocationDetail.CostAllocationDetailRoundCalAmount = costAllocationDetail.CostAllocationDetailRoundCalAmount / (100 * daysTotal);
            //        costAllocationDetail.CostAllocationDetailAmount = Math.Round(costAllocationDetail.CostAllocationDetailRoundCalAmount, 2, MidpointRounding.AwayFromZero);
            //        totalCostAllocPaymentVCER += costAllocationDetail.CostAllocationDetailAmount;
            //    }

            //    double diff = Math.Round(mpfRecord.PayRecActAmount - totalCostAllocPayment, 2, MidpointRounding.AwayFromZero);
            //    if (Math.Abs(diff) >= 0.01 && costAllocationDetailListByMPFRecord.Count > 0)
            //    {
            //        if (diff > 0)
            //        {
            //            while (Math.Abs(diff) >= 0.01)
            //            {
            //                ECostAllocationDetail minCostAllocationDetail = null;
            //                double minDiff = 1;
            //                foreach (ECostAllocationDetail costAllocationDetail in costAllocationDetailListByMPFRecord)
            //                {
            //                    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 costAllocationDetailListByMPFRecord)
            //                {
            //                    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(costAllocationDetailListByMPFRecord);
            //}
        }
    protected DataSet GenerateCND(int ProcessID, int PaymentCodeID, DateTime PaymentDate)
    {
        DateTime m_paymentDate = new DateTime();
        string   m_paymentCode = "";

        ESalaryIncrementBatch m_process = ESalaryIncrementBatch.GetObject(dbConn, ProcessID);

        DataSet   dataSet   = new DataSet();//export.GetDataSet();
        DataTable dataTable = new DataTable("ClaimsAndDeduction$");

        dataSet.Tables.Add(dataTable);

        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EMP_NO, typeof(string));
        dataTable.Columns.Add("English Name", typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EFFECTIVE_DATE, typeof(DateTime));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_CODE, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_BANK_ACCOUNT_NO, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_AMOUNT, typeof(double));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_NUM_OF_DAY_ADJUST, typeof(double));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REST_PAYMENT, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REMARK, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_COST_CENTER, typeof(string));

        DBFilter m_detailFilter = new DBFilter();

        m_detailFilter.add(new Match("BatchID", m_process.BatchID));
        m_detailFilter.add("DetailID", true);

        foreach (ESalaryIncrementBatchDetail m_detail in ESalaryIncrementBatchDetail.db.select(dbConn, m_detailFilter))
        {
            DBFilter m_rpFilter = new DBFilter();
            m_rpFilter.add(new Match("EmpRPID", m_detail.EmpRPID));
            //m_rpFilter.add(new IN("EmpRPID", "SELECT EmpRPID FROM PS_SalaryIncrementBatchDetail ", m_detailFilter));
            foreach (EEmpRecurringPayment m_empRP in EEmpRecurringPayment.db.select(dbConn, m_rpFilter))
            {
                DBFilter m_mapFilter = new DBFilter();
                m_mapFilter.add(new Match("SchemeCode", AppUtils.Encode(EPayScaleMap.db.getField("SchemeCode"), m_empRP.SchemeCode)));
                m_mapFilter.add(new Match("Point", m_detail.NewPoint));
                m_mapFilter.add(new NullTerm("ExpiryDate"));

                foreach (EPayScaleMap m_map in EPayScaleMap.db.select(dbConn, m_mapFilter))
                {
                    decimal m_newSalary = m_map.Salary;
                    string  m_remarks   = "";
                    double  m_amount    = System.Convert.ToDouble(m_newSalary) - m_empRP.EmpRPAmount;

                    if (Math.Abs(m_amount) > 0.01)
                    {
                        m_remarks = String.Format("Backpay {0}: {1}-{2}.", m_process.AsAtDate.ToString("yyyy-MM"),
                                                  m_newSalary.ToString("#,##0.00"),
                                                  m_empRP.EmpRPAmount.ToString("#,##0.00"));

                        EEmpPersonalInfo m_empInfo = new EEmpPersonalInfo();
                        m_empInfo.EmpID = m_empRP.EmpID;
                        EEmpPersonalInfo.db.select(dbConn, m_empInfo);

                        DataRow m_row = dataTable.NewRow();
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EMP_NO] = m_empInfo.EmpNo;
                        m_row["English Name"] = m_empInfo.EmpEngFullName;
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EFFECTIVE_DATE] = m_paymentDate;
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_CODE]   = m_paymentCode;
                        switch (m_empRP.EmpRPMethod)
                        {
                        case "A":
                            m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Autopay";
                            break;

                        case "Q":
                            m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Cheque";
                            break;

                        case "C":
                            m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Cash";
                            break;

                        default:
                            m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Other";
                            break;
                        }
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_AMOUNT]            = Math.Round(m_amount, 2);
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_NUM_OF_DAY_ADJUST] = 0; //DateTime.DaysInMonth(m_process.AsAtDate);
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REST_PAYMENT]      = "No";
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REMARK]            = m_remarks;

                        EEmpBankAccount m_bank = new EEmpBankAccount();
                        m_bank.EmpBankAccountID = m_empRP.EmpAccID;
                        if (EEmpBankAccount.db.select(dbConn, m_bank))
                        {
                            m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_BANK_ACCOUNT_NO] = m_bank.EmpAccountNo;
                        }

                        ECostCenter m_costCenter = new ECostCenter();
                        m_costCenter.CostCenterID = m_empRP.CostCenterID;
                        if (ECostCenter.db.select(dbConn, m_costCenter))
                        {
                            m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_COST_CENTER] = m_costCenter.CostCenterCode;
                        }
                        dataTable.Rows.Add(m_row);
                    }
                }
            }
        }
        return(dataSet);
    }
    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);
    }
示例#14
0
    protected void Save_Click(object sender, EventArgs e)
    {
        EEmpCostCenter c = new EEmpCostCenter();

        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 (c.EmpCostCenterEffTo.Ticks > 0 && c.EmpCostCenterEffTo < c.EmpCostCenterEffFr)
        {
            errors.addError("EmpCostCenterEffTo", HROne.Translation.PageErrorMessage.ERROR_DATE_TO_TOO_EARLY);
            return;
        }

        AND andTerms = new AND();

        andTerms.add(new Match("EmpCostCenterID", "<>", c.EmpCostCenterID));
        andTerms.add(new Match("EmpCostCenterEffFr", "<=", c.EmpCostCenterEffFr));
        EEmpCostCenter lastObj = (EEmpCostCenter)AppUtils.GetLastObj(dbConn, db, "EmpCostCenterEffFr", c.EmpID, andTerms);

        if (lastObj != null && (c.EmpCostCenterEffFr <= lastObj.EmpCostCenterEffTo || c.EmpCostCenterEffFr == lastObj.EmpCostCenterEffFr))
        {
            errors.addError("EmpCostCenterEffFr", HROne.Translation.PageErrorMessage.ERROR_DATE_FROM_OVERLAP);
            return;
        }

        DBFilter filter = new DBFilter();

        filter.add(new Match("EmpID", c.EmpID));
        filter.add(new Match("EmpCostCenterID", "<>", c.EmpCostCenterID));
        OR  or = new OR();
        AND and;

        and = new AND();
        and.add(new Match("EmpCostCenterEffFr", "<=", c.EmpCostCenterEffFr));
        and.add(new Match("EmpCostCenterEffTo", ">=", c.EmpCostCenterEffFr));
        or.add(and);
        // do not allow early terms without "TO" date
        if (c.EmpCostCenterEffTo.Ticks.Equals(0))
        {
            or.add(new Match("EmpCostCenterEffFr", ">", c.EmpCostCenterEffFr));
        }
        if (c.EmpCostCenterEffTo > DateTime.MinValue)
        {
            and = new AND();
            and.add(new Match("EmpCostCenterEffFr", "<=", c.EmpCostCenterEffTo));
            and.add(new Match("EmpCostCenterEffTo", ">=", c.EmpCostCenterEffTo));
            or.add(and);

            and = new AND();
            and.add(new Match("EmpCostCenterEffFr", ">=", c.EmpCostCenterEffFr));
            and.add(new Match("EmpCostCenterEffFr", "<=", c.EmpCostCenterEffTo));
            or.add(and);
        }
        filter.add(or);
        if (db.count(dbConn, filter) > 0)
        {
            errors.addError(HROne.Translation.PageErrorMessage.ERROR_TERMS_OVERLAP);
        }

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

        double    totalPercentage = 0;
        ArrayList selectedList    = new ArrayList();
        ArrayList unselectedList  = new ArrayList();

        foreach (RepeaterItem i in Repeater.Items)
        {
            CheckBox    cb      = (CheckBox)i.FindControl("ItemSelect");
            TextBox     textBox = (TextBox)i.FindControl("EmpCostCenterPercentage");
            ECostCenter o       = new ECostCenter();
            WebFormUtils.GetKeys(ECostCenter.db, o, cb);
            if (ECostCenter.db.select(dbConn, o))
            {
                double percentage = 0;
                if (!string.IsNullOrEmpty(textBox.Text.Trim()))
                {
                    if (double.TryParse(textBox.Text, out percentage))
                    {
                        EEmpCostCenterDetail empCostCenterDetail = new EEmpCostCenterDetail();
                        empCostCenterDetail.CostCenterID            = o.CostCenterID;
                        empCostCenterDetail.EmpCostCenterPercentage = percentage;
                        selectedList.Add(empCostCenterDetail);
                        totalPercentage += percentage;
                    }
                    else
                    {
                        errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_COSTCENTER_PERECNTAGE_NOT_NUMERIC, new string[] { o.CostCenterCode }));
                    }
                }
                else
                {
                    unselectedList.Add(o);
                }
            }
        }

        if (Math.Abs(Math.Round(totalPercentage, 2) - 100) >= 0.01)
        {
            errors.addError(HROne.Translation.PageErrorMessage.ERROR_TOTAL_PERCENTAGE_NOT_100);
        }

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

        WebUtils.StartFunction(Session, FUNCTION_CODE, c.EmpID);
        if (CurID < 0)
        {
//            Utils.MarkCreate(Session, c);

            db.insert(dbConn, c);
            CurID = c.EmpCostCenterID;
//            url = Utils.BuildURL(-1, CurID);
        }
        else
        {
//            Utils.Mark(Session, c);
            db.update(dbConn, c);
        }

        foreach (EEmpCostCenterDetail o in selectedList)
        {
            DBFilter costCenterDetailFilter = new DBFilter();
            costCenterDetailFilter.add(new Match("EmpCostCenterID", c.EmpCostCenterID));
            costCenterDetailFilter.add(new Match("CostCenterID", o.CostCenterID));
            ArrayList empCostCenterDetailList = EEmpCostCenterDetail.db.select(dbConn, costCenterDetailFilter);
            if (empCostCenterDetailList.Count == 0)
            {
                o.EmpCostCenterID = c.EmpCostCenterID;
                EEmpCostCenterDetail.db.insert(dbConn, o);
            }
            else
            {
                int count = 0;
                foreach (EEmpCostCenterDetail empCostCenterDetail in empCostCenterDetailList)
                {
                    if (count == 0)
                    {
                        empCostCenterDetail.EmpCostCenterPercentage = o.EmpCostCenterPercentage;
                        EEmpCostCenterDetail.db.update(dbConn, empCostCenterDetail);
                    }
                    else
                    {
                        EEmpCostCenterDetail.db.delete(dbConn, empCostCenterDetail);
                    }
                    count++;
                }
            }
        }

        foreach (ECostCenter o in unselectedList)
        {
            DBFilter costCenterDetailFilter = new DBFilter();
            costCenterDetailFilter.add(new Match("EmpCostCenterID", c.EmpCostCenterID));
            costCenterDetailFilter.add(new Match("CostCenterID", o.CostCenterID));
            ArrayList costCenterDetailList = EEmpCostCenterDetail.db.select(dbConn, costCenterDetailFilter);
            if (costCenterDetailList.Count != 0)
            {
                foreach (EEmpCostCenterDetail empCostCenterDetail in costCenterDetailList)
                {
                    EEmpCostCenterDetail.db.delete(dbConn, empCostCenterDetail);
                }
            }
        }


        if (lastObj != null)
        {
            if (lastObj.EmpCostCenterEffTo < lastObj.EmpCostCenterEffFr)
            {
                lastObj.EmpCostCenterEffTo = c.EmpCostCenterEffFr.AddDays(-1);
                db.update(dbConn, lastObj);
            }
        }
        WebUtils.EndFunction(dbConn);

        HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "Emp_CostCenter_View.aspx?EmpCostCenterID=" + CurID + "&EmpID=" + c.EmpID);
    }
示例#15
0
    private DataSet GenerateAttendanceRecordDataSet(ArrayList EmpInfoList, int PayperiodID)
    {
        DataSet   dataSet   = new DataSet();//export.GetDataSet();
        DataTable dataTable = new DataTable("ClaimsAndDeduction$");

        dataSet.Tables.Add(dataTable);

        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EMP_NO, typeof(string));
        dataTable.Columns.Add("English Name", typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EFFECTIVE_DATE, typeof(DateTime));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_CODE, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_BANK_ACCOUNT_NO, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_AMOUNT, typeof(double));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_NUM_OF_DAY_ADJUST, typeof(double));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REST_PAYMENT, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REMARK, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_COST_CENTER, typeof(string));

        AttendanceProcess attendanceProcess = new AttendanceProcess(dbConn);

        foreach (EEmpPersonalInfo empInfo in EmpInfoList)
        {
            DateTime dateFrom = new DateTime();
            DateTime dateTo   = new DateTime();

            if (EEmpPersonalInfo.db.select(dbConn, empInfo))
            {
                dateFrom = empInfo.EmpDateOfJoin;


                EPayrollPeriod payPeriod = new EPayrollPeriod();
                payPeriod.PayPeriodID = PayperiodID;
                if (EPayrollPeriod.db.select(dbConn, payPeriod))
                {
                    dateFrom = payPeriod.PayPeriodAttnFr;
                    dateTo   = payPeriod.PayPeriodAttnTo;

                    if (dateFrom < empInfo.EmpDateOfJoin)
                    {
                        dateFrom = empInfo.EmpDateOfJoin;
                    }

                    DBFilter empTermFilter = new DBFilter();
                    empTermFilter.add(new Match("EmpID", empInfo.EmpID));

                    ArrayList empTermList = EEmpTermination.db.select(dbConn, empTermFilter);
                    foreach (EEmpTermination empTerm in empTermList)
                    {
                        if (dateTo > empTerm.EmpTermLastDate)
                        {
                            dateTo = empTerm.EmpTermLastDate;
                        }
                    }

                    DBFilter empPosFilter = new DBFilter();
                    empPosFilter.add(new Match("EmpID", empInfo.EmpID));
                    empPosFilter.add(new Match("PayGroupID", payPeriod.PayGroupID));
                    empPosFilter.add(new Match("EmpPosEffFr", "<=", dateTo));
                    OR orEmpPosEffToTerm = new OR();
                    orEmpPosEffToTerm.add(new Match("EmpPosEffTo", ">=", dateFrom));
                    orEmpPosEffToTerm.add(new NullTerm("EmpPosEffTo"));
                    empPosFilter.add("EmpPosEffFr", false);
                    empPosFilter.add(orEmpPosEffToTerm);

                    ArrayList empPosList = EEmpPositionInfo.db.select(dbConn, empPosFilter);
                    foreach (EEmpPositionInfo currentEmpPos in empPosList)
                    {
                        DateTime payGroupDateFrom = dateFrom;
                        DateTime payGroupDateTo   = dateTo;

                        if (currentEmpPos.EmpPosEffFr > payGroupDateFrom)
                        {
                            payGroupDateFrom = currentEmpPos.EmpPosEffFr;
                        }

                        if (currentEmpPos.EmpPosEffTo < payGroupDateTo && !currentEmpPos.EmpPosEffTo.Ticks.Equals(0))
                        {
                            payGroupDateTo = currentEmpPos.EmpPosEffTo;
                        }

                        ArrayList paymentRecordList = attendanceProcess.AttendancePaymentTrialRun(empInfo.EmpID, payPeriod, payGroupDateFrom, payGroupDateTo);
                        foreach (EPaymentRecord paymentRecord in paymentRecordList)
                        {
                            DataRow row = dataTable.NewRow();
                            row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EMP_NO] = empInfo.EmpNo;
                            row["English Name"] = empInfo.EmpEngFullName;
                            row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EFFECTIVE_DATE] = dateTo;
                            if (currentEmpPos != null)
                            {
                                if (!currentEmpPos.EmpPosEffTo.Ticks.Equals(0))
                                {
                                    if (currentEmpPos.EmpPosEffTo < dateTo)
                                    {
                                        row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EFFECTIVE_DATE] = currentEmpPos.EmpPosEffTo;
                                    }
                                }
                            }

                            EPaymentCode payCode = new EPaymentCode();
                            payCode.PaymentCodeID = paymentRecord.PaymentCodeID;
                            if (EPaymentCode.db.select(dbConn, payCode))
                            {
                                row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_CODE] = payCode.PaymentCode;
                            }
                            if (paymentRecord.PayRecMethod.Equals("A"))
                            {
                                row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Autopay";
                            }
                            else if (paymentRecord.PayRecMethod.Equals("Q"))
                            {
                                row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Cheque";
                            }
                            else if (paymentRecord.PayRecMethod.Equals("C"))
                            {
                                row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Cash";
                            }
                            else
                            {
                                row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = string.Empty;
                            }

                            row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_AMOUNT]            = paymentRecord.PayRecActAmount;
                            row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_NUM_OF_DAY_ADJUST] = paymentRecord.PayRecNumOfDayAdj;
                            row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REST_PAYMENT]      = paymentRecord.PayRecIsRestDayPayment ? "Yes" : "No";

                            row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REMARK] = paymentRecord.PayRecRemark;

                            ECostCenter costCenter = new ECostCenter();
                            costCenter.CostCenterID = paymentRecord.CostCenterID;
                            if (ECostCenter.db.select(dbConn, costCenter))
                            {
                                row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_COST_CENTER] = costCenter.CostCenterCode;
                            }

                            dataTable.Rows.Add(row);
                        }
                    }
                }
            }
        }
        return(dataSet);
    }
    //protected void init_PaymentCodeDropdown()
    //{
    //    if (PaymentCode.Items.Count <= 0)
    //    {
    //        PaymentCode.Items.Add(new ListItem("Not Selected", "-1"));

    //        DBFilter m_filter = new DBFilter();
    //        m_filter.add("PaymentCode", true);

    //        foreach (EPaymentCode o in EPaymentCode.db.select(dbConn, m_filter))
    //        {
    //            PaymentCode.Items.Add(new ListItem(string.Format("{0} - {1}", o.PaymentCode, o.PaymentCodeDesc), o.PaymentCodeID.ToString()));
    //        }
    //    }
    //}

    protected DataSet GenerateCND(int ProcessID, DateTime PaymentDate)
    {
        EHitRateProcessImportBatch m_process = EHitRateProcessImportBatch.GetObject(dbConn, ProcessID);

        DataSet   dataSet   = new DataSet();//export.GetDataSet();
        DataTable dataTable = new DataTable("ClaimsAndDeduction$");

        dataSet.Tables.Add(dataTable);

        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EMP_NO, typeof(string));
        dataTable.Columns.Add("English Name", typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EFFECTIVE_DATE, typeof(DateTime));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_CODE, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_BANK_ACCOUNT_NO, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_AMOUNT, typeof(double));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_NUM_OF_DAY_ADJUST, typeof(double));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REST_PAYMENT, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REMARK, typeof(string));
        dataTable.Columns.Add(HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_COST_CENTER, typeof(string));

        DBFilter m_detailFilter = new DBFilter();

        m_detailFilter.add(new Match("HitRateProcessImportBatchID", ProcessID));
        m_detailFilter.add("EmpID", true);

        foreach (EHitRateProcess m_detail in EHitRateProcess.db.select(dbConn, m_detailFilter))
        {
            DBFilter m_rpFilter = new DBFilter();
            m_rpFilter.add(new NullTerm("EmpRPEffTo"));
            m_rpFilter.add(new Match("PayCodeID", m_detail.payCodeID));
            m_rpFilter.add(new Match("EmpID", m_detail.EmpID));
            m_rpFilter.add("EmpRPEffTo", true);

            ArrayList m_empRPList = EEmpRecurringPayment.db.select(dbConn, m_rpFilter);

            if (m_empRPList.Count > 0)
            {
                EEmpRecurringPayment m_empRP = (EEmpRecurringPayment)m_empRPList[0];

                double m_amount = m_empRP.EmpRPAmount * m_detail.HitRate / (double)100;
                string m_remarks;

//                if (m_amount > 0 && Math.Abs(m_amount) >= 0.01)
                {
                    m_remarks = String.Format("{0}*{1}%", m_empRP.EmpRPAmount.ToString("#,##0.00"),
                                              m_detail.HitRate.ToString("#,##0.00"));

                    EEmpPersonalInfo m_empInfo = new EEmpPersonalInfo();
                    m_empInfo.EmpID = m_empRP.EmpID;
                    EEmpPersonalInfo.db.select(dbConn, m_empInfo);

                    DataRow m_row = dataTable.NewRow();
                    m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EMP_NO] = m_empInfo.EmpNo;
                    m_row["English Name"] = m_empInfo.EmpEngFullName;
                    m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_EFFECTIVE_DATE] = PaymentDate;

                    EPaymentCode m_paymentCode = EPaymentCode.GetObject(dbConn, m_empRP.PayCodeID);
                    m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_CODE] = m_paymentCode.PaymentCode;

                    switch (m_empRP.EmpRPMethod)
                    {
                    case "A":
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Autopay";
                        break;

                    case "Q":
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Cheque";
                        break;

                    case "C":
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Cash";
                        break;

                    default:
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_PAYMENT_METHOD] = "Other";
                        break;
                    }
                    m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_AMOUNT]            = Math.Round(m_amount, 2);
                    m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_NUM_OF_DAY_ADJUST] = 0; //DateTime.DaysInMonth(m_process.AsAtDate);
                    m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REST_PAYMENT]      = "No";
                    m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_REMARK]            = m_remarks;

                    if (m_empRP.EmpAccID > 0)   // account number specified
                    {
                        EEmpBankAccount m_bank = new EEmpBankAccount();
                        m_bank.EmpBankAccountID = m_empRP.EmpAccID;
                        if (EEmpBankAccount.db.select(dbConn, m_bank))
                        {
                            m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_BANK_ACCOUNT_NO] = m_bank.EmpAccountNo;
                        }
                    }
                    //else
                    //{
                    //    // get default bank account
                    //    DBFilter m_bankAccFilter = new DBFilter();
                    //    m_bankAccFilter.add(new Match("EmpID", m_empRP.EmpID));
                    //    m_bankAccFilter.add(new Match("EmpAccDefault", true));
                    //    m_bankAccFilter.add("empBankAccountID", true);
                    //    ArrayList m_bankAccList = EEmpBankAccount.db.select(dbConn, m_bankAccFilter);
                    //    if (m_bankAccList.Count > 0)
                    //    {
                    //        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_BANK_ACCOUNT_NO] = ((EEmpBankAccount)m_bankAccList[0]).EmpAccountNo;
                    //    }
                    //}

                    ECostCenter m_costCenter = new ECostCenter();
                    m_costCenter.CostCenterID = m_empRP.CostCenterID;
                    if (ECostCenter.db.select(dbConn, m_costCenter))
                    {
                        m_row[HROne.Import.ImportClaimsAndDeductionsProcess.FIELD_COST_CENTER] = m_costCenter.CostCenterCode;
                    }
                    dataTable.Rows.Add(m_row);
                }
            }
        }
        return(dataSet);
    }
        public static DataTable Export(DatabaseConnection dbConn, ArrayList empList, bool IsIncludeCurrentPositionInfo, bool IsShowDescription, bool IsIncludeSyncID, DateTime ReferenceDateTime)
        {
            DataTable tmpDataTable = new DataTable(TABLE_NAME);

            //if (IsIncludeInternalID)
            //    tmpDataTable.Columns.Add(FIELD_INTERNAL_ID, typeof(string));
            tmpDataTable.Columns.Add(FIELD_EMP_NO, typeof(string));

            if (IsIncludeCurrentPositionInfo)
            {
                ImportEmpPersonalInfoProcess.AddEmployeeInfoHeader(tmpDataTable);
                ImportEmpPositionInfoProcess.AddEmployeePositionInfoHeader(dbConn, tmpDataTable);
            }

            tmpDataTable.Columns.Add(FIELD_FROM, typeof(DateTime));
            tmpDataTable.Columns.Add(FIELD_TO, typeof(DateTime));
            tmpDataTable.Columns.Add(FIELD_PAYMENT_CODE, typeof(string));
            if (ESystemParameter.getParameter(dbConn, ESystemParameter.PARAM_CODE_PAYSCALE_POINT_SYSTEM) == "Y")        // for WaiJe
            {
                tmpDataTable.Columns.Add(FIELD_SCHEME_CODE, typeof(string));
                tmpDataTable.Columns.Add(FIELD_CAPACITY, typeof(string));
                tmpDataTable.Columns.Add(FIELD_POINT, typeof(decimal));
            }

            if (ESystemParameter.getParameter(dbConn, ESystemParameter.PARAM_CODE_MONTHLY_ACHIEVEMENT_COMMISSION) == "Y")       // for F&V
            {
                tmpDataTable.Columns.Add(FIELD_BASIC_SALARY, typeof(decimal));
                tmpDataTable.Columns.Add(FIELD_FPS, typeof(decimal));
            }

            tmpDataTable.Columns.Add(FIELD_AMOUNT, typeof(double));
            tmpDataTable.Columns.Add(FIELD_UNIT, typeof(string));
            tmpDataTable.Columns.Add(FIELD_METHOD, typeof(string));
            tmpDataTable.Columns.Add(FIELD_ACCOUNT_NO, typeof(string));
            tmpDataTable.Columns.Add(FIELD_IS_NON_PAYROLL_ITEM, typeof(string));
            tmpDataTable.Columns.Add(FIELD_COST_CENTER, typeof(string));
            tmpDataTable.Columns.Add(FIELD_REMARK, typeof(string));
            if (IsIncludeSyncID)
            {
                tmpDataTable.Columns.Add(FIELD_SYNC_ID, typeof(string));
            }

            foreach (EEmpPersonalInfo empInfo in empList)
            {
                if (EEmpPersonalInfo.db.select(dbConn, empInfo))
                {
                    DBFilter filter = new DBFilter();
                    filter.add(new Match("EmpID", empInfo.EmpID));
                    filter.add(getCreateModifiedRecordsAfterDBTerm(ReferenceDateTime));
                    ArrayList list = EEmpRecurringPayment.db.select(dbConn, filter);
                    foreach (EEmpRecurringPayment empRecurringPayment in list)
                    {
                        DataRow row = tmpDataTable.NewRow();
                        //if (IsIncludeInternalID)
                        //    row[FIELD_INTERNAL_ID] = ToHexDecWithCheckDigit(empRecurringPayment.EmpRPID);
                        row[FIELD_EMP_NO] = empInfo.EmpNo;

                        if (IsIncludeCurrentPositionInfo)
                        {
                            ImportEmpPersonalInfoProcess.AddEmployeeInfo(dbConn, row, empInfo.EmpID);
                            ImportEmpPositionInfoProcess.AddEmployeePositionInfo(dbConn, row, empInfo.EmpID);
                        }

                        row[FIELD_FROM] = empRecurringPayment.EmpRPEffFr;
                        row[FIELD_TO]   = empRecurringPayment.EmpRPEffTo;

                        EPaymentCode paymentCode = new EPaymentCode();
                        paymentCode.PaymentCodeID = empRecurringPayment.PayCodeID;
                        if (EPaymentCode.db.select(dbConn, paymentCode))
                        {
                            row[FIELD_PAYMENT_CODE] = IsShowDescription ? paymentCode.PaymentCodeDesc : paymentCode.PaymentCode;
                        }


                        if (ESystemParameter.getParameter(dbConn, ESystemParameter.PARAM_CODE_PAYSCALE_POINT_SYSTEM) == "Y")        // for WaiJe
                        {
                            row[FIELD_SCHEME_CODE] = empRecurringPayment.SchemeCode;
                            row[FIELD_CAPACITY]    = empRecurringPayment.Capacity;
                            row[FIELD_POINT]       = empRecurringPayment.Point;
                        }

                        if (ESystemParameter.getParameter(dbConn, ESystemParameter.PARAM_CODE_MONTHLY_ACHIEVEMENT_COMMISSION) == "Y")       // for F&V
                        {
                            row[FIELD_BASIC_SALARY] = empRecurringPayment.EmpRPBasicSalary;
                            row[FIELD_FPS]          = empRecurringPayment.EmpRPFPS;
                        }

                        row[FIELD_AMOUNT] = empRecurringPayment.EmpRPAmount;
                        if (empRecurringPayment.EmpRPUnit.Equals("H"))
                        {
                            row[FIELD_UNIT] = "Hourly";
                        }
                        else if (empRecurringPayment.EmpRPUnit.Equals("D"))
                        {
                            row[FIELD_UNIT] = "Daily";
                        }
                        else if (empRecurringPayment.EmpRPUnit.Equals("P"))
                        {
                            row[FIELD_UNIT] = "Once per payroll cycle";
                        }

                        if (empRecurringPayment.EmpRPMethod.Equals("A"))
                        {
                            row[FIELD_METHOD] = "Autopay";
                            EEmpBankAccount empBankAccount = new EEmpBankAccount();
                            empBankAccount.EmpBankAccountID = empRecurringPayment.EmpAccID;
                            if (EEmpBankAccount.db.select(dbConn, empBankAccount))
                            {
                                row[FIELD_ACCOUNT_NO] = empBankAccount.EmpBankCode + "-" + empBankAccount.EmpBranchCode + "-" + empBankAccount.EmpAccountNo;
                            }
                        }
                        else if (empRecurringPayment.EmpRPMethod.Equals("Q"))
                        {
                            row[FIELD_METHOD] = "Cheque";
                        }
                        else if (empRecurringPayment.EmpRPMethod.Equals("C"))
                        {
                            row[FIELD_METHOD] = "Cash";
                        }
                        else
                        {
                            row[FIELD_METHOD] = "Others";
                        }



                        row[FIELD_IS_NON_PAYROLL_ITEM] = empRecurringPayment.EmpRPIsNonPayrollItem ? "Yes" : "No";


                        ECostCenter costCenter = new ECostCenter();
                        costCenter.CostCenterID = empRecurringPayment.CostCenterID;
                        if (ECostCenter.db.select(dbConn, costCenter))
                        {
                            row[FIELD_COST_CENTER] = IsShowDescription ? costCenter.CostCenterDesc : costCenter.CostCenterCode;
                        }

                        row[FIELD_REMARK] = empRecurringPayment.EmpRPRemark;
                        if (IsIncludeSyncID)
                        {
                            row[FIELD_SYNC_ID] = empRecurringPayment.SynID;
                        }

                        tmpDataTable.Rows.Add(row);
                    }
                }
            }
            if (IsIncludeCurrentPositionInfo)
            {
                ImportEmpPositionInfoProcess.RetriveHierarchyLevelHeader(dbConn, tmpDataTable);
            }
            return(tmpDataTable);
        }
        public static DataTable Export(DatabaseConnection dbConn, ArrayList empList, bool IsIncludeCurrentPositionInfo, bool IsShowDescription, bool IsIncludeSyncID, DateTime ReferenceDateTime)
        {
            DataTable tmpDataTable = new DataTable(TABLE_NAME);

            //if (IsIncludeInternalID)
            //    tmpDataTable.Columns.Add(FIELD_INTERNAL_ID, typeof(string));
            tmpDataTable.Columns.Add(FIELD_EMP_NO, typeof(string));

            if (IsIncludeCurrentPositionInfo)
            {
                ImportEmpPersonalInfoProcess.AddEmployeeInfoHeader(tmpDataTable);
                ImportEmpPositionInfoProcess.AddEmployeePositionInfoHeader(dbConn, tmpDataTable);
            }

            tmpDataTable.Columns.Add(FIELD_PAYMENT_CODE, typeof(string));
            tmpDataTable.Columns.Add(FIELD_AMOUNT, typeof(double));
            tmpDataTable.Columns.Add(FIELD_METHOD, typeof(string));
            tmpDataTable.Columns.Add(FIELD_ACCOUNT_NO, typeof(string));
            tmpDataTable.Columns.Add(FIELD_COST_CENTER, typeof(string));
            tmpDataTable.Columns.Add(FIELD_NUM_OF_DAY_ADJUST, typeof(double));
            tmpDataTable.Columns.Add(FIELD_REMARK, typeof(string));
            if (IsIncludeSyncID)
            {
                tmpDataTable.Columns.Add(FIELD_SYNC_ID, typeof(string));
            }

            foreach (EEmpPersonalInfo empInfo in empList)
            {
                if (EEmpPersonalInfo.db.select(dbConn, empInfo))
                {
                    DBFilter filter = new DBFilter();
                    filter.add(new Match("EmpID", empInfo.EmpID));
                    filter.add(getCreateModifiedRecordsAfterDBTerm(ReferenceDateTime));
                    ArrayList list = EEmpFinalPayment.db.select(dbConn, filter);
                    foreach (EEmpFinalPayment empFinalPayment in list)
                    {
                        DataRow row = tmpDataTable.NewRow();
                        //if (IsIncludeInternalID)
                        //    row[FIELD_INTERNAL_ID] = ToHexDecWithCheckDigit(empFinalPayment.EmpFinalPayID);
                        row[FIELD_EMP_NO] = empInfo.EmpNo;

                        if (IsIncludeCurrentPositionInfo)
                        {
                            ImportEmpPersonalInfoProcess.AddEmployeeInfo(dbConn, row, empInfo.EmpID);
                            ImportEmpPositionInfoProcess.AddEmployeePositionInfo(dbConn, row, empInfo.EmpID);
                        }

                        EPaymentCode paymentCode = new EPaymentCode();
                        paymentCode.PaymentCodeID = empFinalPayment.PayCodeID;
                        if (EPaymentCode.db.select(dbConn, paymentCode))
                        {
                            row[FIELD_PAYMENT_CODE] = IsShowDescription ? paymentCode.PaymentCodeDesc : paymentCode.PaymentCode;
                        }

                        row[FIELD_AMOUNT] = empFinalPayment.EmpFinalPayAmount;

                        if (empFinalPayment.EmpFinalPayMethod.Equals("A"))
                        {
                            row[FIELD_METHOD] = "Autopay";
                            EEmpBankAccount empBankAccount = new EEmpBankAccount();
                            empBankAccount.EmpBankAccountID = empFinalPayment.EmpAccID;
                            if (EEmpBankAccount.db.select(dbConn, empBankAccount))
                            {
                                row[FIELD_ACCOUNT_NO] = empBankAccount.EmpBankCode + "-" + empBankAccount.EmpBranchCode + "-" + empBankAccount.EmpAccountNo;
                            }
                        }
                        else if (empFinalPayment.EmpFinalPayMethod.Equals("Q"))
                        {
                            row[FIELD_METHOD] = "Cheque";
                        }
                        else if (empFinalPayment.EmpFinalPayMethod.Equals("C"))
                        {
                            row[FIELD_METHOD] = "Cash";
                        }
                        else
                        {
                            row[FIELD_METHOD] = "Others";
                        }

                        ECostCenter costCenter = new ECostCenter();
                        costCenter.CostCenterID = empFinalPayment.CostCenterID;
                        if (ECostCenter.db.select(dbConn, costCenter))
                        {
                            row[FIELD_COST_CENTER] = IsShowDescription ? costCenter.CostCenterDesc : costCenter.CostCenterCode;
                        }

                        row[FIELD_NUM_OF_DAY_ADJUST] = empFinalPayment.EmpFinalPayNumOfDayAdj;
                        row[FIELD_REMARK]            = empFinalPayment.EmpFinalPayRemark;
                        if (IsIncludeSyncID)
                        {
                            row[FIELD_SYNC_ID] = empFinalPayment.SynID;
                        }

                        tmpDataTable.Rows.Add(row);
                    }
                }
            }
            if (IsIncludeCurrentPositionInfo)
            {
                ImportEmpPositionInfoProcess.RetriveHierarchyLevelHeader(dbConn, tmpDataTable);
            }
            return(tmpDataTable);
        }
示例#19
0
        public static DataTable Export(DatabaseConnection dbConn, ArrayList empList, bool IsIncludeCurrentPositionInfo, bool IsShowDescription, bool IsIncludeSyncID, DateTime ReferenceDateTime)
        {
            DataTable tmpDataTable = new DataTable(TABLE_NAME);

            //if (IsIncludeInternalID)
            //    tmpDataTable.Columns.Add(FIELD_INTERNAL_ID, typeof(string));
            tmpDataTable.Columns.Add(FIELD_EMP_NO, typeof(string));

            if (IsIncludeCurrentPositionInfo)
            {
                ImportEmpPersonalInfoProcess.AddEmployeeInfoHeader(tmpDataTable);
                ImportEmpPositionInfoProcess.AddEmployeePositionInfoHeader(dbConn, tmpDataTable);
            }

            tmpDataTable.Columns.Add(FIELD_FROM, typeof(DateTime));
            tmpDataTable.Columns.Add(FIELD_TO, typeof(DateTime));
            if (IsIncludeSyncID)
            {
                tmpDataTable.Columns.Add(FIELD_SYNC_ID, typeof(string));
            }
            tmpDataTable.Columns.Add(FIELD_COST_CENTER + "1", typeof(string));
            tmpDataTable.Columns.Add(FIELD_PERCENTAGE + "1", typeof(double));
            tmpDataTable.Columns.Add(FIELD_COST_CENTER + "2", typeof(string));
            tmpDataTable.Columns.Add(FIELD_PERCENTAGE + "2", typeof(double));


            foreach (EEmpPersonalInfo empInfo in empList)
            {
                if (EEmpPersonalInfo.db.select(dbConn, empInfo))
                {
                    DBFilter filter = new DBFilter();
                    filter.add(new Match("EmpID", empInfo.EmpID));
                    filter.add(getCreateModifiedRecordsAfterDBTerm(ReferenceDateTime));
                    ArrayList list = EEmpCostCenter.db.select(dbConn, filter);
                    foreach (EEmpCostCenter empCostCenter in list)
                    {
                        DataRow row = tmpDataTable.NewRow();
                        //if (IsIncludeInternalID)
                        //    row[FIELD_INTERNAL_ID] = ToHexDecWithCheckDigit(empCostCenter.EmpCostCenterID);
                        row[FIELD_EMP_NO] = empInfo.EmpNo;

                        if (IsIncludeCurrentPositionInfo)
                        {
                            ImportEmpPersonalInfoProcess.AddEmployeeInfo(dbConn, row, empInfo.EmpID);
                            ImportEmpPositionInfoProcess.AddEmployeePositionInfo(dbConn, row, empInfo.EmpID);
                        }

                        row[FIELD_FROM] = empCostCenter.EmpCostCenterEffFr;
                        row[FIELD_TO]   = empCostCenter.EmpCostCenterEffTo;

                        DBFilter costCenterDetailFilter = new DBFilter();
                        costCenterDetailFilter.add(new Match("EmpCostCenterID", empCostCenter.EmpCostCenterID));
                        ArrayList costCenterDetailList = EEmpCostCenterDetail.db.select(dbConn, costCenterDetailFilter);
                        for (int i = 1; i <= costCenterDetailList.Count; i++)
                        {
                            EEmpCostCenterDetail empCostCenterDetail = (EEmpCostCenterDetail)costCenterDetailList[i - 1];
                            if (!tmpDataTable.Columns.Contains(FIELD_COST_CENTER + i))
                            {
                                tmpDataTable.Columns.Add(FIELD_COST_CENTER + i, typeof(string));
                            }

                            if (!tmpDataTable.Columns.Contains(FIELD_PERCENTAGE + i))
                            {
                                tmpDataTable.Columns.Add(FIELD_PERCENTAGE + i, typeof(double));
                            }

                            ECostCenter costCenter = new ECostCenter();
                            costCenter.CostCenterID = empCostCenterDetail.CostCenterID;
                            if (ECostCenter.db.select(dbConn, costCenter))
                            {
                                row[FIELD_COST_CENTER + i] = IsShowDescription ? costCenter.CostCenterDesc : costCenter.CostCenterCode;
                                row[FIELD_PERCENTAGE + i]  = empCostCenterDetail.EmpCostCenterPercentage;
                            }
                        }
                        if (IsIncludeSyncID)
                        {
                            row[FIELD_SYNC_ID] = empCostCenter.SynID;
                        }
                        tmpDataTable.Rows.Add(row);
                    }
                }
            }
            if (IsIncludeCurrentPositionInfo)
            {
                ImportEmpPositionInfoProcess.RetriveHierarchyLevelHeader(dbConn, tmpDataTable);
            }
            return(tmpDataTable);
        }
示例#20
0
        protected bool GetEmpRecurringPaymentInfo(int pEmpID, DateTime pSalaryMonth, out double pTargetSalary, out string pPayMethod, out string pBankAccountCode, out string pCostCenterCode)
        {
            DBFilter m_rpFilter = new DBFilter();
            OR       m_orDate   = new OR();

            m_orDate.add(new NullTerm("EmpRPEffTo"));
            m_orDate.add(new Match("EmpRPEffTo", ">=", pSalaryMonth));

            m_rpFilter.add(m_orDate);
            m_rpFilter.add(new Match("EmpRPEffFr", "<=", pSalaryMonth));
            m_rpFilter.add(new Match("EmpID", pEmpID));
            m_rpFilter.add(new Match("EmpRPBasicSalary", ">", 0));

            DBFilter m_payCodeFilter = new DBFilter();
            DBFilter m_payTypeFilter = new DBFilter();

            m_payTypeFilter.add(new Match("PaymentTypeCode", "BASICSAL"));
            m_payCodeFilter.add(new IN("PaymentTypeID", "SELECT PaymentTypeID FROM PaymentType", m_payTypeFilter));
            m_rpFilter.add(new IN("PayCodeID", "SELECT PaymentCodeID FROM PaymentCode", m_payCodeFilter));
            m_rpFilter.add("EmpRPID", false);

            ArrayList m_rpList = EEmpRecurringPayment.db.select(dbConn, m_rpFilter);

            pPayMethod       = "";
            pBankAccountCode = "";
            pCostCenterCode  = "";
            pTargetSalary    = 0;

            if (m_rpList.Count > 0)
            {
                EEmpRecurringPayment m_empRP = (EEmpRecurringPayment)m_rpList[0];

                pTargetSalary = m_empRP.EmpRPBasicSalary;

                switch (m_empRP.EmpRPMethod)
                {
                case "A":
                    pPayMethod = "Autopay";
                    break;

                case "Q":
                    pPayMethod = "Cheque";
                    break;

                case "C":
                    pPayMethod = "Cash";
                    break;

                default:
                    pPayMethod = "Other";
                    break;
                }

                EEmpBankAccount m_bank = new EEmpBankAccount();
                m_bank.EmpBankAccountID = m_empRP.EmpAccID;
                if (EEmpBankAccount.db.select(dbConn, m_bank))
                {
                    pBankAccountCode = m_bank.EmpAccountNo;
                }

                ECostCenter m_costCenter = new ECostCenter();
                m_costCenter.CostCenterID = m_empRP.CostCenterID;
                if (ECostCenter.db.select(dbConn, m_costCenter))
                {
                    pCostCenterCode = m_costCenter.CostCenterCode;
                }
            }
            return(true);
        }