protected void Delete_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();

        EAttendanceFormula c = new EAttendanceFormula();

        c.AttendanceFormulaID = CurID;
        if (EAttendanceFormula.db.select(dbConn, c))
        {
            DBFilter attendancePlanFilter = new DBFilter();
            attendancePlanFilter.add(new Match("AttendancePlanOTFormula", c.AttendanceFormulaID));
            attendancePlanFilter.add(new Match("AttendancePlanLateFormula", c.AttendanceFormulaID));
            ArrayList attendancePlanList = EAttendancePlan.db.select(dbConn, attendancePlanFilter);
            if (attendancePlanList.Count > 0)
            {
                errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_CODE_USED_BY_EMPLOYEE, new string[] { HROne.Common.WebUtility.GetLocalizedString("AttendanceFormula Code"), c.AttendanceFormulaCode }));
                foreach (EAttendancePlan attendancePlan in attendancePlanList)
                {
                    errors.addError("- " + attendancePlan.AttendancePlanCode + ", " + attendancePlan.AttendancePlanDesc);
                }
                errors.addError(HROne.Translation.PageErrorMessage.ERROR_ACTION_ABORT);
                return;
            }
            else
            {
                WebUtils.StartFunction(Session, FUNCTION_CODE);
                db.delete(dbConn, c);
                WebUtils.EndFunction(dbConn);
            }
        }
        HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "Attendance_Formula_List.aspx");
    }
Exemplo n.º 2
0
    protected bool loadObject()
    {
        obj = new EAttendanceFormula();
        bool isNew = WebFormWorkers.loadKeys(db, obj, DecryptedRequest);

        if (!db.select(dbConn, obj))
        {
            return(false);
        }

        Hashtable values = new Hashtable();

        db.populate(obj, values);
        binding.toControl(values);

        return(true);
    }
    protected bool loadObject()
    {
        obj = new EAttendanceFormula();
        bool isNew = WebFormWorkers.loadKeys(db, obj, DecryptedRequest);

        if (!db.select(dbConn, obj))
        {
            return(false);
        }

        FixOTPanel.Visible   = false;
        FormulaPanel.Visible = false;
        if (obj.AttendanceFormulaType.Equals(EAttendanceFormula.FORMULATYPE_CODE_BY_FORMULA))
        {
            FormulaPanel.Visible = true;
        }
        else if (obj.AttendanceFormulaType.Equals(EAttendanceFormula.FORMULATYPE_CODE_FIX_RATE))
        {
            FixOTPanel.Visible = true;
        }

        if (string.IsNullOrEmpty(obj.AttendanceFormulaRoundingRule))
        {
            AttendanceFormulaDecimalPlace.Visible = false;
        }
        else
        if (obj.AttendanceFormulaRoundingRule.Equals(Values.ROUNDING_RULE_NO_ROUND))
        {
            AttendanceFormulaDecimalPlace.Visible     = false;
            AttendanceFormulaDecimalPlaceDesc.Visible = false;
        }
        else
        {
            AttendanceFormulaDecimalPlace.Visible     = true;
            AttendanceFormulaDecimalPlaceDesc.Visible = true;
        }


        Hashtable values = new Hashtable();

        db.populate(obj, values);
        binding.toControl(values);

        return(true);
    }
Exemplo n.º 4
0
        //public static double GetHourlyRate(DatabaseConnection dbConn, int AttendanceFormulaID, int DefaultPayrollFormulaID, int EmpID, double totalPeriodPayment, double totalDailyPayment, double totalHourlyPayment, DateTime PayPeriodAttnFr, DateTime PayPeriodTo, int numOfPeriodPerYear, DateTime AttendanceRecordDate, bool IsOverrideHourlyPayment, double OverrideHoulyAmount, double RosterCodeWorkHourPerDay, out string hourlyRateRemark)
        //{
        //    return GetHourlyRate(dbConn, AttendanceFormulaID, DefaultPayrollFormulaID, EmpID, totalPeriodPayment, totalDailyPayment, totalHourlyPayment, PayPeriodAttnFr, PayPeriodTo, numOfPeriodPerYear, AttendanceRecordDate, IsOverrideHourlyPayment, OverrideHoulyAmount, 1, RosterCodeWorkHourPerDay, out hourlyRateRemark);
        //}
        public static double GetHourlyRate(DatabaseConnection dbConn, int AttendanceFormulaID, int DefaultPayrollFormulaID, int EmpID, double totalPeriodPayment, double totalDailyPayment, double totalHourlyPayment, DateTime PayPeriodAttnFr, DateTime PayPeriodTo, int numOfPeriodPerYear, DateTime AttendanceRecordDate, bool IsOverrideHourlyPayment, double OverrideHoulyAmount, double ratio, double RosterCodeWorkHourPerDay, out string hourlyRateRemark)
        {
            hourlyRateRemark = string.Empty;

            double             hourlyRate        = 0;
            EAttendanceFormula attendanceFormula = new EAttendanceFormula();

            attendanceFormula.AttendanceFormulaID = AttendanceFormulaID;
            if (!EAttendanceFormula.db.select(dbConn, attendanceFormula))
            {
                return(0);
            }
            if (attendanceFormula.AttendanceFormulaType.Equals(EAttendanceFormula.FORMULATYPE_CODE_FIX_RATE))
            {
                hourlyRate       = attendanceFormula.AttendanceFormulaFixedRate * ratio;
                hourlyRateRemark = hourlyRate.ToString("$#,##0.00##");
            }
            else if (attendanceFormula.AttendanceFormulaType.Equals(EAttendanceFormula.FORMULATYPE_CODE_BY_FORMULA))
            {
                bool   IsDAW     = false;
                double dailyRate = HROne.Payroll.PayrollFormula.DailyProrataCaluclation(dbConn, attendanceFormula.AttendanceFormulaPayFormID, DefaultPayrollFormulaID, EmpID, totalPeriodPayment, PayPeriodAttnFr, PayPeriodTo, numOfPeriodPerYear, AttendanceRecordDate, out hourlyRateRemark, out IsDAW);
                if (!IsDAW)
                {
                    if (dailyRate.Equals(0))
                    {
                        hourlyRateRemark = totalDailyPayment.ToString("$#,##0.00##");
                        dailyRate        = totalDailyPayment;
                    }
                    else if (!totalDailyPayment.Equals(0))
                    {
                        hourlyRateRemark = "(" + hourlyRateRemark + " + " + totalDailyPayment.ToString("$#,##0.00##") + ")";
                        dailyRate       += totalDailyPayment;
                    }
                }
                double hourlyPaymentRate = 0;
                if (totalHourlyPayment != 0)
                {
                    if (IsOverrideHourlyPayment)
                    {
                        hourlyPaymentRate = OverrideHoulyAmount;
                    }
                    else
                    {
                        hourlyPaymentRate = totalHourlyPayment;
                    }
                }

                if (dailyRate.Equals(0) || attendanceFormula.AttendanceFormulaWorkHourPerDay.Equals(0))
                {
                    hourlyRateRemark = hourlyPaymentRate.ToString("$#,##0.00##") + (ratio.Equals(1) ? string.Empty : (" x " + ratio.ToString()));
                    hourlyRate       = hourlyPaymentRate * ratio;
                }
                else
                {
                    double prorataHourlyRate = dailyRate / attendanceFormula.AttendanceFormulaWorkHourPerDay;                                                                                                 // *ratio;
                    string prorataRemark     = hourlyRateRemark + (attendanceFormula.AttendanceFormulaWorkHourPerDay.Equals(1) ? string.Empty : (" / " + attendanceFormula.AttendanceFormulaWorkHourPerDay)); // +(ratio.Equals(1) ? string.Empty : (" x " + ratio.ToString()));

                    if (RosterCodeWorkHourPerDay > 0 && attendanceFormula.AttendanceFormulaIsUseRosterCodeForDefaultWorkHourPerDay)
                    {
                        prorataHourlyRate = dailyRate / RosterCodeWorkHourPerDay;                                                                        // *ratio;
                        prorataRemark     = hourlyRateRemark + (RosterCodeWorkHourPerDay.Equals(1) ? string.Empty : (" / " + RosterCodeWorkHourPerDay)); // +(ratio.Equals(1) ? string.Empty : (" x " + ratio.ToString()));
                    }
                    if (hourlyPaymentRate != 0 && !IsDAW)
                    {
                        prorataRemark = "(" + prorataRemark + " + " + hourlyPaymentRate.ToString("$#,##0.00##") + ")";
                        //+ (ratio.Equals(1) ? string.Empty : (" x " + ratio.ToString())) + ")";
                        prorataHourlyRate = prorataHourlyRate + hourlyPaymentRate;
                    }
                    if (ratio != 1)
                    {
                        prorataRemark     += " x " + ratio.ToString();
                        prorataHourlyRate *= ratio;
                    }
                    if (attendanceFormula.AttendanceFormulaDecimalPlace < 9)
                    {
                        if (!string.IsNullOrEmpty(attendanceFormula.AttendanceFormulaRoundingRule))
                        {
                            //  To prevent unexpected value of RoundingRule change the original value of FormulaRemark,
                            //  All re-assign value of FormulaRemark should be done inside the condition.
                            if (attendanceFormula.AttendanceFormulaRoundingRule.Equals(Values.ROUNDING_RULE_ROUND_DOWN))
                            {
                                prorataHourlyRate = HROne.CommonLib.GenericRoundingFunctions.RoundingDown(prorataHourlyRate, attendanceFormula.AttendanceFormulaDecimalPlace, attendanceFormula.AttendanceFormulaDecimalPlace);
                                //prorataRemark = prorataHourlyRate.ToString("0." + string.Empty.PadLeft(attendanceFormula.AttendanceFormulaDecimalPlace, '0'));
                            }
                            else if (attendanceFormula.AttendanceFormulaRoundingRule.Equals(Values.ROUNDING_RULE_ROUND_UP))
                            {
                                prorataHourlyRate = HROne.CommonLib.GenericRoundingFunctions.RoundingUp(prorataHourlyRate, attendanceFormula.AttendanceFormulaDecimalPlace, attendanceFormula.AttendanceFormulaDecimalPlace);
                                //prorataRemark = prorataHourlyRate.ToString("0." + string.Empty.PadLeft(attendanceFormula.AttendanceFormulaDecimalPlace, '0'));
                            }
                            else if (attendanceFormula.AttendanceFormulaRoundingRule.Equals(Values.ROUNDING_RULE_ROUND_TO))
                            {
                                prorataHourlyRate = HROne.CommonLib.GenericRoundingFunctions.RoundingTo(prorataHourlyRate, attendanceFormula.AttendanceFormulaDecimalPlace, attendanceFormula.AttendanceFormulaDecimalPlace);
                                //prorataRemark = prorataHourlyRate.ToString("0." + string.Empty.PadLeft(attendanceFormula.AttendanceFormulaDecimalPlace, '0'));
                            }
                        }
                    }
                    hourlyRateRemark = prorataRemark;
                    hourlyRate       = prorataHourlyRate;
                }
            }
            return(hourlyRate);
        }
Exemplo n.º 5
0
    protected void Save_Click(object sender, EventArgs e)
    {
        EAttendanceFormula c = new EAttendanceFormula();

        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, "AttendanceFormulaCode"))
        {
            return;
        }



        if (AttendanceFormulaType.SelectedValue.Equals(EAttendanceFormula.FORMULATYPE_CODE_BY_FORMULA))
        {
            if (c.AttendanceFormulaPayFormID <= 0)
            {
                errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_FIELD_REQUIRED, new string[] { HROne.Common.WebUtility.GetLocalizedString("Formula for Daily Prorata") }));
            }
            if (c.AttendanceFormulaWorkHourPerDay <= 0)
            {
                errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_FIELD_REQUIRED, new string[] { HROne.Common.WebUtility.GetLocalizedString("Work hour per day") }));
            }
            if (string.IsNullOrEmpty(c.AttendanceFormulaRoundingRule))
            {
                errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_FIELD_REQUIRED, new string[] { lblRoundingRule.Text }));
            }
        }
        else if (AttendanceFormulaType.SelectedValue.Equals(EAttendanceFormula.FORMULATYPE_CODE_FIX_RATE))
        {
        }

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

        WebUtils.StartFunction(Session, FUNCTION_CODE);

        if (CurID < 0)
        {
            //            Utils.MarkCreate(Session, c);

            db.insert(dbConn, c);
            CurID = c.AttendanceFormulaID;
            //            url = Utils.BuildURL(-1, CurID);
        }
        else
        {
            //            Utils.Mark(Session, c);
            db.update(dbConn, c);
        }
        WebUtils.EndFunction(dbConn);
        HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "Attendance_Formula_View.aspx?AttendanceFormulaID=" + CurID);
    }