示例#1
0
        //  ProcessMatch method.
        static void ProcessMatch()
        {
            PaySum p = new PaySum();

            p.EmployeeNumber = employeeFile.Data.EmployeeNumber;
            if (!employeeFile.Data.PayType.Equals('S'))
            {
                float[] wkOne = new float[7];
                float[] wkTwo = new float[7];
                Array.Copy(timecardFile.Data.GetDecElapsedTimes(), 0, wkOne, 0, 7);
                Array.Copy(timecardFile.Data.GetDecElapsedTimes(), 7, wkTwo, 0, 7);

                float wkOneTotalHours   = PRLib.CalculateWeeklyHoursWorked(wkOne);
                float wkTwoTotalHours   = PRLib.CalculateWeeklyHoursWorked(wkTwo);
                float totalWeekendHours = 0;
                float shiftTwoHours     = 0;
                float shiftThreeHours   = 0;

                for (int i = 0; i < 14; i++)
                {
                    totalWeekendHours += PRLib.CalculateWeekendHours(
                        timecardFile.Data.GetDecClockInTimes(i), timecardFile.Data.GetDecClockOutTimes(i), ((i % 7) + 1).ToString()[0]);
                    shiftTwoHours += PRLib.CalculateShift(16.0f, 0.0f,
                                                          timecardFile.Data.GetDecClockInTimes(i), timecardFile.Data.GetDecClockOutTimes(i));

                    shiftThreeHours += PRLib.CalculateShift(0.0f, 8.0f,
                                                            timecardFile.Data.GetDecClockInTimes(i), timecardFile.Data.GetDecClockOutTimes(i));
                }

                p.WeekendHours  = totalWeekendHours;
                p.RegularHours  = PRLib.CalculateRegularHours(wkOneTotalHours) + PRLib.CalculateRegularHours(wkTwoTotalHours);
                p.OvertimeHours = PRLib.CalculateOvertimeHours(wkOneTotalHours) + PRLib.CalculateOvertimeHours(wkTwoTotalHours);
                p.Shift2Hours   = shiftTwoHours;
                p.Shift3Hours   = shiftThreeHours;
                paySumFile.Data = p;
                paySumFile.WriteRecord();


                //timecardFile.Data.DisplayData();
                //p.DisplayData();
                //p.RegularHours = PRLib.CalculateRegularHours();
                //timecardFile.Data.DisplayData();
            }
            else
            {
                p.RegularHours  = 80;
                p.WeekendHours  = 0;
                p.Shift2Hours   = 0;
                p.Shift3Hours   = 0;
                p.OvertimeHours = 0;
                paySumFile.Data = p;
                paySumFile.WriteRecord();
            }

            employeeFile.ReadRecord();
            timecardFile.ReadRecord();
        }
示例#2
0
        //  ProcessMatch method.
        static void ProcessMatch()
        {
            //  This is where you put the steps when both are equal.

            //paysumFile.Data.DisplayData();

            Earnings earn = new Earnings();

            earn.DepartmentNumber    = employeeFile.Data.DepartmentNumber;
            earn.EmployeeNumber      = employeeFile.Data.EmployeeNumber;
            earn.RegularHours        = paysumFile.Data.RegularHours;
            earn.OvertimeHours       = paysumFile.Data.OvertimeHours;
            earn.Shift2Hours         = paysumFile.Data.Shift2Hours;
            earn.Shift3Hours         = paysumFile.Data.Shift3Hours;
            earn.WeekendHours        = paysumFile.Data.WeekendHours;
            earn.RegularPay          = PRLib.CalculatePay(earn.RegularHours, employeeFile.Data.HourlyRate);
            earn.OvertimePay         = PRLib.CalculatePay(earn.OvertimeHours, employeeFile.Data.HourlyRate, 1.5f);
            earn.Shift2Pay           = GetShiftRate('2') * earn.Shift2Hours;
            earn.Shift3Pay           = GetShiftRate('3') * earn.Shift3Hours;
            earn.WeekendPay          = GetShiftRate('W') * earn.WeekendHours;
            earn.GrossPay            = PRLib.CalculateGrossPay(earn.RegularPay, earn.OvertimePay, earn.Shift2Pay, earn.Shift3Pay, earn.WeekendPay);
            earn.FederalWithholding  = PRLib.CalculateFederalWithholdingTax(earn.GrossPay, employeeFile.Data.TaxMaritalStatus, employeeFile.Data.NumExemptions);
            earn.SsWithholding       = PRLib.CalculateSocialSecurityTax(earn.GrossPay, employeeFile.Data.YtdGrossEarnings, employeeFile.Data.YtdSSTaxes);
            earn.MedicareWithholding = PRLib.CalculateMedicareTax(earn.GrossPay);
            earn.StateWithholding    = PRLib.CalculateStateTax(earn.GrossPay, employeeFile.Data.StateWithholdingPercentage);

            float deductionOne   = PRLib.CalculateDeduction(earn.GrossPay, employeeFile.Data.DeductionCodeOne, employeeFile.Data.DeductionValueOne);
            float deductionTwo   = 0;
            float deductionThree = 0;


            if (earn.GrossPay - deductionOne > 0)
            {
                deductionTwo = PRLib.CalculateDeduction(earn.GrossPay, employeeFile.Data.DeductionCodeTwo, employeeFile.Data.DeductionValueTwo);
                if (earn.GrossPay - (deductionOne + deductionTwo) >= 0)
                {
                    deductionThree = PRLib.CalculateDeduction(earn.GrossPay, employeeFile.Data.DeductionCodeThree, employeeFile.Data.DeductionValueThree);
                    if (earn.GrossPay - (deductionOne + deductionTwo + deductionThree) < 0)
                    {
                        deductionThree = 0;
                    }
                }
                else
                {
                    deductionTwo = 0;
                }
            }
            else
            {
                deductionOne = 0;
            }

            earn.TotalVoluntaryDeductions = deductionOne + deductionTwo + deductionThree;
            earn.NetPay      = PRLib.CalculateNetPay(earn.GrossPay, earn.FederalWithholding, earn.SsWithholding, earn.MedicareWithholding, deductionOne, deductionTwo, deductionThree);
            earn.CheckDate   = "5/5/2019";
            earn.CheckNumber = checkNumber;

            checkNumber++;

            earningsFile.Data = earn;
            earningsFile.WriteRecord();

            DisplayChecks.DisplayChecks.AddIDName(earn.EmployeeNumber, employeeFile.Data.FirstName + " " + employeeFile.Data.LastName);

            earn.DisplayData();
            Console.WriteLine("\n\n\n\n\n");

            employeeFile.ReadRecord();
            paysumFile.ReadRecord();
        }