Esempio n. 1
0
 protected void computePayroll(Object sender, EventArgs events)
 {
     try{
         double hours      = double.Parse(hoursWorkedInput.Text);
         double rate       = double.Parse(payRateInput.Text);
         int    dependents = int.Parse(dependentsComboBox.Text);
         bool   health     = false;
         if (yesRadioButton.Checked == true)
         {
             health = true;
         }
         string name      = string.Concat(firstnameinput.Text.ToString().ToUpper(), " ", secondnameinput.Text.ToString().ToUpper());
         double regular   = PayrollLogic.computeRegularPay(hours, rate);
         double overtime  = PayrollLogic.computeOvertimePay(hours, rate);
         double gross     = PayrollLogic.computeGrossPay(regular, overtime);
         double withhold  = PayrollLogic.computeWithholdTax(dependents, gross);
         double healthFee = PayrollLogic.computeHealth(dependents, health);
         double ssFee     = PayrollLogic.computeSocialSecurity(gross);
         double netPay    = PayrollLogic.computeNetPay(gross, withhold, healthFee, ssFee);
         nameOutput.Text           = name;
         regularPayOutput.Text     = string.Format("{0:F2}", regular);
         overtimePayOutput.Text    = string.Format("{0:F2}", overtime);
         grossPayOutput.Text       = string.Format("{0:F2}", gross);
         withholdTaxOutput.Text    = string.Format("{0:F2}", withhold);
         healthOutput.Text         = string.Format("{0:F2}", healthFee);
         socialSecutiryOutput.Text = string.Format("{0:F2}", ssFee);
         netPayOutput.Text         = string.Format("{0:F2}", netPay);
     }catch (Exception e) {
         MessageBox.Show("Error in input: Try Again!");
     }
 }