예제 #1
0
 private void ProcessPayrollNow(int period, int year, bool simulateRun)
 {
     try
     {
         pbStatus.Minimum = 0;
         pbStatus.Maximum = rep.GetAllActiveEmployees().Count();
         listBoxResults.Items.Clear();
         CPayroll cp = new CPayroll(_User, connection);
         //subscribe to the events
         cp.OnCompleteGeneratePayslip += new CPayroll.PayslipCompleteEventHandler(cp_OnCompleteGeneratePayslip);
         string sError = string.Empty;
         cp.RunPayroll(simulateRun, period, year, ref sError);
         de.MarkPayrollAsProcessed(period, year);
         if (sError != "")
         {
             Log.WriteToErrorLogFile(new Exception(sError));
         }
         ;
         MessageBox.Show("Successfully run", "SB Payroll");
         RefreshGrid();
     }
     catch (Exception ex)
     {
         Utils.ShowError(ex);
     }
 }
예제 #2
0
        private void btnClosePayroll_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridViewPayrolls.SelectedRows.Count != 0)
                {
                    DAL.Payroll pay = (DAL.Payroll)bindingSourcePayrolls.Current;
                    if (pay.Processed)
                    {
                        if (DialogResult.Yes == MessageBox.Show("Are you sure you want to Close this Payroll?", "Confirm Close", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                        {
                            // Todo close the payroll here
                            CPayroll cp = new CPayroll(_User, connection);
                            cp.ArchivePayroll(pay.Period, pay.Year);

                            // Todo code for removing record from the payslipmaster
                            RefreshGrid();
                        }
                    }
                    else
                    {
                        MessageBox.Show("You are not allowed to close a non Processed Payroll!", "SB Payroll");
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowError(ex);
            }
        }