public StatementModelBuilder(DAL.Employer employer, bool current, int Yr, int period, int EmployeeId, string empNo, DAL.PayrollItem payrollitem, string Conn) { //initialize if (string.IsNullOrEmpty(Conn)) { throw new ArgumentNullException("connection"); } connection = Conn; db = new SBPayrollDBEntities(connection); rep = new Repository(connection); _current = current; _EmployeeId = EmployeeId; employee = rep.GetEmployee(_EmployeeId); _employer = employer; _ViewModel = new StatementModel(); _payrollitem = payrollitem; _year = Yr; _period = period; itemid = payrollitem.Id; fileLogo = _employer.Logo; slogan = _employer.Slogan; var et = rep.GetEmployeeTxn(employee.EmpNo, _payrollitem.Id); if (et.Count() > 0) { emptxn = et.First(); } }
private bool IsEmployeeTransactionValid() { bool no_error = true; if (cbItemId.SelectedIndex == -1) { errorProvider1.Clear(); //Clear all Error Messages errorProvider1.SetError(cbItemId, "Select a payroll Item!"); return(false); } if (string.IsNullOrEmpty(txtAmount.Text)) { errorProvider1.Clear(); errorProvider1.SetError(txtAmount, "Amount cannot be null!"); return(false); } decimal Amount; if (!decimal.TryParse(txtAmount.Text, out Amount)) { errorProvider1.Clear(); errorProvider1.SetError(txtAmount, "Amount must be Decimal!"); return(false); } decimal YTDAmount; if (!string.IsNullOrEmpty(txtYTDAmount.Text) && !decimal.TryParse(txtYTDAmount.Text, out YTDAmount)) { errorProvider1.Clear(); errorProvider1.SetError(txtYTDAmount, "Year To Date Amount must be Decimal!"); return(false); } if (cbItemId.SelectedIndex != -1) { DAL.PayrollItem _payrollitem = (DAL.PayrollItem)cbItemId.SelectedItem; switch (_payrollitem.ItemTypeId.Trim()) { case "LOAN": if (string.IsNullOrEmpty(txtYTDAmount.Text)) { errorProvider1.Clear(); errorProvider1.SetError(txtYTDAmount, "Year To Date Amount cannot be null for Loans!"); return(false); } if (!string.IsNullOrEmpty(txtYTDAmount.Text)) { decimal ytd = decimal.Parse(txtYTDAmount.Text); if (ytd > 0) { errorProvider1.Clear(); errorProvider1.SetError(txtYTDAmount, "Year To Date Amount must be set as Negative for Loans e.g -25000"); return(false); } } break; } } return(no_error); }
private void dataGridViewPayrollItems_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { if (dataGridViewPayrollItems.SelectedRows.Count != 0) { try { DAL.PayrollItem payrollitem = (DAL.PayrollItem)bindingSourcePayrollItems.Current; List <string> defaultItems = new List <string>() { "BASIC", "PAYE", "NSSF", "NHIF", "NON_CASH_BENEFIT", "HOURLY_PAY", "ADVANCE" }; if (defaultItems.Contains(payrollitem.Id.Trim())) { MessageBox.Show("Cannot Edit Default Payroll Item " + payrollitem.Id.Trim(), "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Forms.EditPayrollItem f = new EditPayrollItem(payrollitem, connection) { Owner = this }; f.Text = payrollitem.Id.ToString().Trim().ToUpper(); f.ShowDialog(); } } catch (Exception ex) { Utils.ShowError(ex); } } }
private void btnAdd_Click(object sender, EventArgs e) { if (Is_PayrollItemValid()) { try { DAL.PayrollItem pi = new DAL.PayrollItem(); if (!string.IsNullOrEmpty(txtPayrollItemId.Text)) { pi.Id = Utils.ConvertFirstLetterToUpper(txtPayrollItemId.Text.Trim()); pi.Description = Utils.ConvertFirstLetterToUpper(txtPayrollItemId.Text.Trim()); } if (cbItemType.SelectedIndex != -1) { pi.ItemTypeId = cbItemType.SelectedValue.ToString(); } if (cbTaxTracking.SelectedIndex != -1) { pi.TaxTrackingId = cbTaxTracking.SelectedValue.ToString(); } if (!string.IsNullOrEmpty(txtPayableTo.Text)) { pi.PayableTo = Utils.ConvertFirstLetterToUpper(txtPayableTo.Text.ToString().Trim()); } if (!string.IsNullOrEmpty(txtGlAccount.Text)) { pi.GLAccount = txtGlAccount.Text.Trim(); } int reference; if (!string.IsNullOrEmpty(txtReference.Text) && int.TryParse(txtReference.Text, out reference)) { pi.ReFField = int.Parse(txtReference.Text.Trim()); } pi.Enable = true; pi.Active = chkActive.Checked; pi.AddToPension = chkAddToPension.Checked; pi.DefaultItem = false; pi.IsDeleted = false; if (db.PayrollItems.Any(i => i.Id == pi.Id && i.IsDeleted == false)) { MessageBox.Show("Item Description Exist!", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (!db.PayrollItems.Any(i => i.Id == pi.Id && i.IsDeleted == false)) { db.AddToPayrollItems(pi); db.SaveChanges(); Forms.PayrollItems f = (Forms.PayrollItems) this.Owner; f.RefreshGrid(); this.Close(); } } catch (Exception ex) { Utils.ShowError(ex); } } }
public EditPayrollItem(DAL.PayrollItem pitem, string Conn) { InitializeComponent(); if (string.IsNullOrEmpty(Conn)) throw new ArgumentNullException("connection"); connection = Conn; de = new DataEntry(connection); db = new SBPayrollDBEntities(connection); rep = new Repository(connection); if (pitem == null) throw new ArgumentNullException("PayrollItem"); pi = pitem; }
private void btnViewDetails_Click(object sender, EventArgs e) { if (dataGridViewPayrollItems.SelectedRows.Count != 0) { try { DAL.PayrollItem payrollitem = (DAL.PayrollItem)bindingSourcePayrollItems.Current; Forms.EditPayrollItem f = new EditPayrollItem(payrollitem, connection) { Owner = this }; f.Text = payrollitem.Id.ToString().Trim().ToUpper(); f.DisableControls(); f.ShowDialog(); } catch (Exception ex) { Utils.ShowError(ex); } } }
private void btnDelete_Click(object sender, EventArgs e) { try { if (dataGridViewPayrollItems.SelectedRows.Count != 0) { DAL.PayrollItem payrollitem = (DAL.PayrollItem)bindingSourcePayrollItems.Current; var _employeewithpayrollitemsquery = from br in rep.GetEmployeesWithPayrollItemTransactions(payrollitem) select br; List <DAL.Employee> _employees = _employeewithpayrollitemsquery.ToList(); List <string> defaultItems = new List <string>() { "BASIC", "PAYE", "NSSF", "NHIF", "NON_CASH_BENEFIT", "HOURLY_PAY", "ADVANCE" }; if (defaultItems.Contains(payrollitem.Id.Trim())) { MessageBox.Show("Cannot Delete Default Payroll Item " + payrollitem.Id.Trim(), "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if ((_employees.Count > 0)) { MessageBox.Show("There is an Employee Associated with this Payroll Item\nDelete the Employee first!", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (DialogResult.Yes == MessageBox.Show("Are you sure you want to Delete Payroll Item\n " + payrollitem.Id.ToString().Trim().ToUpper(), "Confirm Delete", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)) { rep.DeletePayrollItem(payrollitem); RefreshGrid(); } } } catch (Exception ex) { Utils.ShowError(ex); } }
public SheduleModelBuilder(DAL.Employer employer, bool _current, DAL.Payroll payroll, DAL.PayrollItem payrollitem, string Conn) { //initialization if (string.IsNullOrEmpty(Conn)) { throw new ArgumentNullException("connection"); } connection = Conn; db = new SBPayrollDBEntities(connection); rep = new Repository(connection); current = _current; _year = payroll.Year; _period = payroll.Period; _payrollitem = payrollitem; _employer = employer; fileLogo = _employer.Logo; slogan = _employer.Slogan; }
private void cbItemId_SelectedIndexChanged(object sender, EventArgs e) { try { if ("HOURLY_PAY".Equals(cbItemId.Text.Trim())) { this.txtAmount.Enabled = false; HrlyPay f = new HrlyPay(employee, connection) { Owner = this }; f.OnEmployeeHrlyAmountChanged += new HrlyPay.HrlyAmountHandler(f_OnEmployeeHrlyAmountChanged); f.ShowDialog(this); } else if ("NON_CASH_BENEFIT".Equals(cbItemId.Text.Trim())) { this.txtAmount.Enabled = false; NonCashBenefits b = new NonCashBenefits(employee, connection) { Owner = this }; b.OnEmployeeBenefitAmountChanged += new NonCashBenefits.BenefitAmountHandler(b_OnEmployeeBenefitAmountChanged); b.ShowDialog(this); } else { this.txtAmount.Enabled = true; } if (cbItemId.SelectedIndex != -1) { DAL.PayrollItem _payrollitem = (DAL.PayrollItem)cbItemId.SelectedItem; switch (_payrollitem.ItemTypeId.Trim()) { case "LOAN": txtYTDAmount.Text = string.Empty; chkEnabled.Checked = true; chkRecurrent.Checked = true; chkShowYTDinPayslip.Checked = true; chkTrackYTD.Checked = true; break; case "SACCO": chkEnabled.Checked = true; chkRecurrent.Checked = true; chkShowYTDinPayslip.Checked = true; chkTrackYTD.Checked = true; break; default: chkEnabled.Checked = true; chkRecurrent.Checked = true; chkShowYTDinPayslip.Checked = true; chkTrackYTD.Checked = true; break; } } } catch (Exception ex) { Utils.ShowError(ex); } }