コード例 #1
0
        public bool GeneratePayslip(bool simulate, int PayrollPeriod, int Year, Employee Empdvr, string User, ref string Msg, ref bool error)
        {
            string EmpNo = Empdvr.EmpNo.Trim();

            try
            {
                PayslipMaker payMaker = new PayslipMaker(PayrollPeriod, Year, Empdvr.Id, EmpNo, User, connection);
                if (!payMaker._erorr)
                {
                    try
                    {
                        Payslip payslip = payMaker.CreatePayslipFromTransactions();
                        if (payslip == null)
                        {
                            Msg   = "Payslip for [" + EmpNo.Trim() + "] not successful \n Error = See error log file";
                            error = true;
                            return(false);
                        }

                        string saveErr = string.Empty;
                        if (!SavePayslip(simulate, payslip, ref saveErr))
                        {
                            Msg   = "Payslip for [" + EmpNo.Trim() + "] not successful\n Error = " + saveErr;
                            error = true;
                            return(false);
                        }


                        Msg = "Payslip for [" + EmpNo.Trim() + "] Month [" + PayrollPeriod + "] Year [" + Year + "] successfuly completed";
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        Utils.ShowError(ex);
                        return(false);
                    }
                }
                else
                {
                    Msg   = "Payslip for [" + EmpNo.Trim() + "] not successful\n Error = " + payMaker._errMsg;
                    error = true;
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Utils.ShowError(ex);
                return(false);
            }
        }
コード例 #2
0
 private void btnCalculate_Click(object sender, EventArgs e)
 {
     try
     {
         decimal pay;
         if (!decimal.TryParse(txtTaxablePay.Text, out pay))
         {
             MessageBox.Show("Enter a valid taxable pay");
             return;
         }
         PayslipMaker pm    = new PayslipMaker(pay, connection);
         Payslip      pslip = pm.CreateAnonymousPayslip();
         dataGridViewTaxCalculator.DataSource = pslip.TaxBracketList;
         lblGrossTax.Text = pslip.GrossTax.ToString("C2");
     }
     catch (Exception ex)
     {
         Utils.ShowError(ex);
     }
 }