コード例 #1
0
        protected void ComputePayroll_Click(object sender, EventArgs e)
        {
            RequestComputePayroll request = new RequestComputePayroll();
            DataTable             dt      = new DataTable();

            double BasicPay               = Convert.ToDouble(txtBasicPay.Text);
            double DailyRate              = ((BasicPay * 2) * 12) / 261;
            int    WorkingHrs             = 8;
            double PerHrRate              = DailyRate / WorkingHrs;
            double PerMinuteRate          = PerHrRate / 60;
            int    NoOfLate               = Convert.ToInt32(txtNoOfLate.Text);
            double LateDeductions         = PerMinuteRate * NoOfLate;
            int    NoOfAbsent             = Convert.ToInt32(txtNoOfAbsent.Text);
            double AbsentDeductions       = PerMinuteRate * NoOfAbsent;
            int    NoOfUndertime          = Convert.ToInt32(txtNoOfUndertime.Text);
            double UndertimeDeductions    = PerMinuteRate * NoOfUndertime;
            int    NightDifferentialHrs   = Convert.ToInt32(txtNightDiffHrs.Text);
            double TotalNightDifferential = PerHrRate * NightDifferentialHrs;
            double NightDifferential      = TotalNightDifferential * 0.10;
            double TransportAllowance     = Convert.ToDouble(txtTransportAllowance.Text);
            double MealAllowance          = Convert.ToDouble(txtMealAllowance.Text);
            double RiceSubsidy            = Convert.ToDouble(txtRiceSubsidy.Text);
            double Laundry          = Convert.ToDouble(txtLaundry.Text);
            double HolidayPay       = Convert.ToDouble(txtHolidayPay.Text);
            double Bonus            = Convert.ToDouble(txtBonus.Text);
            double MonthlyIncentive = Convert.ToDouble(txtMonthlyIncentive.Text);
            double GrossPay         = (BasicPay + NightDifferential + MonthlyIncentive +
                                       TransportAllowance) - (LateDeductions + AbsentDeductions - UndertimeDeductions);
            double TaxSSS                      = Convert.ToDouble(txtSSS.Text);
            double SSSContribution             = Convert.ToDouble(txtEmployerSSS.Text);
            double SSSTotalContribution        = TaxSSS + SSSContribution;
            double TaxPhilHealth               = Convert.ToDouble(txtPhilHealth.Text);
            double PhilHealthContribution      = Convert.ToDouble(txtEmployerPhilHealth.Text);
            double PhilHealthTotalContribution = TaxPhilHealth + PhilHealthContribution;
            double TaxSSSLoan                  = Convert.ToDouble(txtSSSLoan.Text);
            double TaxHDMF                     = Convert.ToDouble(txtHDMF.Text);
            double HDMFContribution            = Convert.ToDouble(txtEmployerHDMF.Text);
            double HDMFTotalContribution       = TaxHDMF + HDMFContribution;
            double TaxPagibigLoan              = Convert.ToDouble(txtPagibigLoan.Text);
            double TaxableIncome               = (GrossPay + HolidayPay + NightDifferential);
            string CivilStatus                 = DAT.GetCivilStatus(txtUserID.Text);
            double Bracket                     = 0.0;
            double Percent                     = 0.00;
            double BaseTax                     = 0.00;

            SortedDictionary <string, string> Exemptions = new SortedDictionary <string, string>();

            Exemptions.Add("1", (Math.Abs(TaxableIncome - 1)).ToString());
            Exemptions.Add("2", (Math.Abs(TaxableIncome - 4167)).ToString());
            Exemptions.Add("3", (Math.Abs(TaxableIncome - 5000)).ToString());
            Exemptions.Add("4", (Math.Abs(TaxableIncome - 6667)).ToString());
            Exemptions.Add("5", (Math.Abs(TaxableIncome - 10000)).ToString());
            Exemptions.Add("6", (Math.Abs(TaxableIncome - 15833)).ToString());
            Exemptions.Add("7", (Math.Abs(TaxableIncome - 25000)).ToString());
            Exemptions.Add("8", (Math.Abs(TaxableIncome - 45833)).ToString());
            //TODO: No .Next() function in .net 2.0

            switch (Exemptions.Last().Key)
            {
            case "1":
            {
                Bracket = 1;
                Percent = 0;
                BaseTax = 0;
                break;
            }

            case "2":
            {
                Bracket = 4167;
                Percent = 5;
                BaseTax = 0.00;
                break;
            }

            case "3":
            {
                Bracket = 5000;
                Percent = 0.10;
                BaseTax = 41.67;
                break;
            }

            case "4":
            {
                Bracket = 6667;
                Percent = 0.15;
                BaseTax = 208.33;
                break;
            }

            case "5":
            {
                Bracket = 10000;
                Percent = 0.20;
                BaseTax = 708.33;
                break;
            }

            case "6":
            {
                Bracket = 15833;
                Percent = 0.25;
                BaseTax = 1875;
                break;
            }

            case "7":
            {
                Bracket = 25000;
                Percent = 0.30;
                BaseTax = 4166.67;
                break;
            }

            case "8":
            {
                Bracket = 45833;
                Percent = 0.32;
                BaseTax = 10416.67;
                break;
            }
            }
            double WithHoldTax = (((TaxableIncome - Bracket) * Percent) + (BaseTax));
            double NetPay      = GrossPay + MealAllowance + Bonus + MonthlyIncentive + TransportAllowance + MealAllowance + RiceSubsidy + Laundry
                                 - TaxSSS - TaxPhilHealth - TaxSSSLoan - TaxHDMF - TaxPagibigLoan - WithHoldTax;

            request.UserID                 = int.Parse(txtUserID.Text);
            request.BasicPay               = BasicPay;
            request.DailyRate              = DailyRate;
            request.WorkingHrs             = WorkingHrs;
            request.PerHrRate              = PerHrRate;
            request.NoofMinuteLate         = NoOfLate;
            request.LateDeductions         = LateDeductions;
            request.NoDaysAbsent           = NoOfAbsent;
            request.AbsentDeductions       = AbsentDeductions;
            request.NoofMinuteUndertime    = NoOfUndertime;
            request.UndertimeDeductions    = UndertimeDeductions;
            request.NightDifferentialHrs   = NightDifferentialHrs;
            request.TotalNightDifferential = TotalNightDifferential;
            request.NightDifferential      = NightDifferential;
            request.TransportAllowance     = TransportAllowance;
            request.MealAllowance          = MealAllowance;
            request.Ricesubsidy            = RiceSubsidy;
            request.Laundry                = Laundry;
            request.HolidayPay             = HolidayPay;
            request.Bonus                       = Bonus;
            request.MonthlyIncentive            = MonthlyIncentive;
            request.GrossPay                    = GrossPay;
            request.TaxSSS                      = TaxSSS;
            request.SSSContribution             = SSSContribution;
            request.SSSTotalContribution        = SSSTotalContribution;
            request.TaxPhilHealth               = TaxPhilHealth;
            request.PhilHealthContribution      = PhilHealthContribution;
            request.PhilHealthTotalContribution = PhilHealthTotalContribution;
            request.TaxSSSLoan                  = TaxSSSLoan;
            request.TaxHDMF                     = TaxHDMF;
            request.HDMFContribution            = HDMFContribution;
            request.HDMFTotalContribution       = HDMFTotalContribution;
            request.TaxPagibigLoan              = TaxPagibigLoan;
            request.TaxableIncome               = TaxableIncome;
            request.WithHoldTax                 = WithHoldTax;
            request.PayrollDate                 = Calendar1.SelectedDate.ToString();
            request.NetPay                      = NetPay;

            if (OkayToGenerateMonth())
            {
                try
                {
                    DAT.ComputePayroll(request);
                    Response.Write("<script language='javascript'>alert('Compute Payroll Successfully!.')</script>");
                }
                catch (Exception ex)
                {
                    String jstring;
                    jstring = "<script language='javascript'>alert('Compute Payroll Failed!" + ex.Message + "')</script>";
                    Response.Write(jstring);
                }
            }