public P10ReportMaker(DAL.Employer _employer, bool current, int Yr, string Conn)
        {
            try
            {
                //initialization
                if (string.IsNullOrEmpty(Conn))
                {
                    throw new ArgumentNullException("Conn");
                }
                connection = Conn;

                db  = new SBPayrollDBEntities(connection);
                rep = new Repository(connection);

                _year    = Yr;
                _current = current;

                employer = _employer;

                fileLogo = employer.Logo;
                slogan   = employer.Slogan;
            }
            catch (Exception ex)
            {
                error = true;
                Utils.ShowError(ex);
            }
        }
        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();
            }
        }
Beispiel #3
0
        public NSSFReportBuilder(DAL.Employer employer, bool current, int period, int year, string Conn)
        {
            try
            {
                //initialization
                if (string.IsNullOrEmpty(Conn))
                {
                    throw new ArgumentNullException("connection");
                }
                connection = Conn;

                db  = new SBPayrollDBEntities(connection);
                rep = new Repository(connection);

                _year     = year;
                _period   = period;
                _current  = current;
                _employer = employer;

                fileLogo = _employer.Logo;
                slogan   = _employer.Slogan;
            }
            catch (Exception ex)
            {
                error = true;
                Utils.ShowError(ex);
            }
        }
Beispiel #4
0
        public BankTransferMaker2(DAL.Employer _employer, bool current, int period, int year, string Conn)
        {
            try
            {
                if (string.IsNullOrEmpty(Conn))
                {
                    throw new ArgumentNullException("Conn");
                }
                connection = Conn;

                db  = new SBPayrollDBEntities(connection);
                rep = new Repository(connection);

                _year    = year;
                _current = current;
                _period  = period;
                employer = _employer;

                fileLogo = rep.SettingLookup("COMPANYLOGO");
                slogan   = rep.SettingLookup("COMPANYSLOGAN");
            }
            catch (Exception ex)
            {
                error = true;
                Utils.ShowError(ex);
            }
        }
        private void cboEmployer_SelectedIndexChanged(object sender, EventArgs e)
        {
            bindingSourceEmployees.DataSource = null;
            if (cboEmployer.SelectedIndex != -1)
            {
                try
                {
                    DAL.Employer _employer = (DAL.Employer)cboEmployer.SelectedItem;

                    if (chkInActive.Checked)
                    {
                        ApplyFilter();
                        //var _employees = from em in rep.GetAllEmployees()
                        //                 where em.EmployerId == _employer.Id
                        //                 where em.IsDeleted == false
                        //                 select em;
                        //bindingSourceEmployees.DataSource = _employees;
                        //groupBox2.Text = bindingSourceEmployees.Count.ToString();
                        //foreach (DataGridViewRow row in dataGridViewEmployees.Rows)
                        //{
                        //    dataGridViewEmployees.Rows[dataGridViewEmployees.Rows.Count - 1].Selected = true;
                        //    int nRowIndex = dataGridViewEmployees.Rows.Count - 1;
                        //    bindingSourceEmployees.Position = nRowIndex;
                        //}
                    }
                    else
                    {
                        ApplyFilter();
                        //var _employees = from em in rep.GetAllEmployees()
                        //                 where em.EmployerId == _employer.Id
                        //                 where em.IsActive == true
                        //                 where em.IsDeleted == false
                        //                 select em;
                        //bindingSourceEmployees.DataSource = _employees;
                        //groupBox2.Text = bindingSourceEmployees.Count.ToString();
                        //foreach (DataGridViewRow row in dataGridViewEmployees.Rows)
                        //{
                        //    dataGridViewEmployees.Rows[dataGridViewEmployees.Rows.Count - 1].Selected = true;
                        //    int nRowIndex = dataGridViewEmployees.Rows.Count - 1;
                        //    bindingSourceEmployees.Position = nRowIndex;
                        //}
                    }
                }
                catch (Exception ex)
                {
                    Utils.ShowError(ex);
                }
            }
        }
        public EditEmployer(DAL.Employer employer, 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);

            _employer = employer;
        }
Beispiel #7
0
        public DepartmentsReportModelBuilder(DAL.Employer employer, string Conn)
        {
            if (string.IsNullOrEmpty(Conn))
            {
                throw new ArgumentNullException("connection");
            }
            connection = Conn;

            db  = new SBPayrollDBEntities(connection);
            rep = new Repository(connection);

            _employer = employer;

            fileLogo = _employer.Logo;
            slogan   = _employer.Slogan;
        }
        public P10AReportMaker(DAL.Employer employer, bool _current, int Yr, string Conn)
        {
            //initialization
            if (string.IsNullOrEmpty(Conn))
            {
                throw new ArgumentNullException("connection");
            }
            connection = Conn;

            db  = new SBPayrollDBEntities(connection);
            rep = new Repository(connection);

            current   = _current;
            _employer = employer;
            _year     = Yr;

            fileLogo = _employer.Logo;
            slogan   = _employer.Slogan;
        }
        public BankBranchTransferModelBuilder1(DAL.Employer employer, bool current, int period, int year, string Conn)
        {
            if (string.IsNullOrEmpty(Conn))
            {
                throw new ArgumentNullException("connection");
            }
            connection = Conn;

            db  = new SBPayrollDBEntities(connection);
            rep = new Repository(connection);

            _year     = year;
            _current  = current;
            _period   = period;
            _employer = employer;

            fileLogo = _employer.Logo;
            slogan   = _employer.Slogan;
        }
Beispiel #10
0
        public NetSalaryReportMaker(DAL.Employer employer, bool current, int year, int period, string Conn)
        {
            //initialize
            if (string.IsNullOrEmpty(Conn))
            {
                throw new ArgumentNullException("connection");
            }
            connection = Conn;

            db  = new SBPayrollDBEntities(connection);
            rep = new Repository(connection);

            _year     = year;
            _period   = period;
            _current  = current;
            _employer = employer;

            fileLogo = _employer.Logo;
            slogan   = _employer.Slogan;
        }
        public LoanRepaymentScheduleModelBuilder(DAL.Employer employer, bool current, DAL.Payroll payroll, 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;
            _employer = employer;

            fileLogo = _employer.Logo;
            slogan   = _employer.Slogan;
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridViewEmployer.SelectedRows.Count != 0)
                {
                    DAL.Employer emp = (DAL.Employer)bindingSourceEmployer.Current;

                    var _Employeesquery = from em in rep.GetAllActiveEmployees()
                                          where em.EmployerId == emp.Id
                                          where em.IsDeleted == false
                                          select em;
                    List <Employee> _Employees = _Employeesquery.ToList();

                    var _EmployerBanksquery = from em in db.EmployerBanks
                                              select em;
                    List <EmployerBank> _EmployerBanks = _EmployerBanksquery.ToList();

                    if (_Employees.Count > 0)
                    {
                        MessageBox.Show("There is an Employee Associated with this Employer.\n Delete the Employee First!", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (_EmployerBanks.Count > 0)
                    {
                        MessageBox.Show("There is an Employer Bank Associated with this Employer.\n Delete the Employer Bank First!", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        if (DialogResult.Yes == MessageBox.Show("Are you sure you want to delete Employer\n" + emp.Name.Trim().ToUpper(), "Confirm Delete", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                        {
                            rep.DeleteEmployer(emp);
                            RefreshGrid();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowError(ex);
            }
        }
 private void btnEdit_Click(object sender, EventArgs e)
 {
     try
     {
         if (dataGridViewEmployer.SelectedRows.Count != 0)
         {
             DAL.Employer       emp = (DAL.Employer)bindingSourceEmployer.Current;
             Forms.EditEmployer f   = new EditEmployer(emp, connection)
             {
                 Owner = this
             };
             f.Text = emp.Name.ToString().Trim().ToUpper();
             f.CheckForDefaultBank();
             f.Show();
         }
     }
     catch (Exception ex)
     {
         Utils.ShowError(ex);
     }
 }
Beispiel #14
0
        public NSSFReportBuilder(bool current, int period, int year, string Conn)
        {
            try
            {
                //initialization
                if (string.IsNullOrEmpty(Conn))
                {
                    throw new ArgumentNullException("connection");
                }
                connection = Conn;

                db  = new SBPayrollDBEntities(connection);
                rep = new Repository(connection);

                _year    = year;
                _period  = period;
                _current = current;

                SetResourcePath();

                fileLogo = rep.SettingLookup("COMPANYLOGO");
                slogan   = rep.SettingLookup("COMPANYSLOGAN");

                _employer = rep.GetEmployer();

                if (_employer != null)
                {
                    fileLogo = _employer.Logo;
                    slogan   = _employer.Slogan;
                }
            }
            catch (Exception ex)
            {
                error = true;
                Utils.ShowError(ex);
            }
        }
Beispiel #15
0
 public bool ShowNSSF(DAL.Employer _employer, string app, NSSFReportModel nssfreportmodel, string sFilePDF)
 {
     bRet = false;
     try
     {
         if ("pdf".Equals(app.ToLower()))
         {
             NSSFPDFBuilder payPdfMaker = new NSSFPDFBuilder(_employer, nssfreportmodel, sFilePDF, connection);
             payPdfMaker.GetPDF();
             return(true);
         }
         else
         {
             NSSFExcelBuilder pe = new NSSFExcelBuilder(nssfreportmodel, sFilePDF);
             pe.GetExcel();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Utils.ShowError(ex);
         return(false);
     }
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (IsEmployeeTransactionValid())
            {
                try
                {
                    var _employerquery = (from ep in db.Employers
                                          select ep).FirstOrDefault();
                    DAL.Employer _Employer = _employerquery;

                    EmployeeTransaction et = new EmployeeTransaction();
                    decimal             _amount;
                    if (!string.IsNullOrEmpty(txtAmount.Text) && decimal.TryParse(txtAmount.Text, out _amount))
                    {
                        et.Amount = decimal.Parse(txtAmount.Text.Trim());
                    }
                    et.PostDate   = DateTime.Today;
                    et.EmployeeId = employee.Id;
                    if (employee.EmpNo != null)
                    {
                        et.EmpNo = employee.EmpNo;
                    }
                    if (cbItemId.SelectedIndex != -1)
                    {
                        et.ItemId = cbItemId.SelectedValue.ToString();
                    }
                    et.Recurrent           = chkRecurrent.Checked;
                    et.Processed           = false;
                    et.InitialAmount       = 0M;
                    et.AccumulativePayment = 0M;
                    et.Enabled             = true;
                    et.TrackYTD            = chkTrackYTD.Checked;
                    et.CreatedBy           = _User;
                    et.LastChangeDate      = DateTime.Today;
                    et.LastChangedBy       = _User;
                    if (_Employer.AuthorizedSignatory != null)
                    {
                        et.AuthorizedBy = _Employer.AuthorizedSignatory;
                    }
                    et.AuthorizeDate = DateTime.Today;
                    decimal _YTDAmount;
                    if (!string.IsNullOrEmpty(txtYTDAmount.Text) && decimal.TryParse(txtYTDAmount.Text, out _YTDAmount))
                    {
                        et.Balance = _YTDAmount;
                    }
                    et.ShowYTDInPayslip = chkShowYTDinPayslip.Checked;

                    if (db.EmployeeTransactions.Any(i => i.EmpNo == et.EmpNo && i.ItemId == et.ItemId))
                    {
                        MessageBox.Show("Employee Transaction for item \n" + et.ItemId + "Exists!", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    if (!db.EmployeeTransactions.Any(i => i.EmpNo == et.EmpNo && i.ItemId == et.ItemId))
                    {
                        db.EmployeeTransactions.AddObject(et);
                        db.SaveChanges();
                    }

                    EditEmployee f = (EditEmployee)this.Owner;
                    f.GridRefresh();
                    this.Close();
                }
                catch (Exception ex)
                {
                    Utils.ShowError(ex);
                }
            }
        }
 private IQueryable <DAL.Employee> CreateFilter(IQueryable <DAL.Employee> _employees)
 {
     //none
     if (string.IsNullOrEmpty(txtEmpNo.Text) &&
         string.IsNullOrEmpty(txtSurName.Text) && string.IsNullOrEmpty(txtOtherNames.Text) && string.IsNullOrEmpty(txtDepartment.Text) && cboEmployer.SelectedIndex != -1)
     {
         DAL.Employer _employer = (DAL.Employer)cboEmployer.SelectedItem;
         _employees = (from ep in rep.GetAllActiveEmployees()
                       where ep.EmployerId == _employer.Id
                       where ep.IsDeleted == false
                       select ep).AsQueryable();
         return(_employees);
     }
     //all
     if (!string.IsNullOrEmpty(txtEmpNo.Text) &&
         !string.IsNullOrEmpty(txtSurName.Text) && !string.IsNullOrEmpty(txtOtherNames.Text) && !string.IsNullOrEmpty(txtDepartment.Text) && cboEmployer.SelectedIndex != -1)
     {
         DAL.Employer _employer   = (DAL.Employer)cboEmployer.SelectedItem;
         string       _EmpNo      = txtEmpNo.Text;
         string       _SurName    = txtSurName.Text;
         string       _OtherNames = txtOtherNames.Text;
         string       _Department = txtDepartment.Text;
         _employees = (from ep in rep.GetAllActiveEmployees()
                       join dp in db.Departments on ep.DepartmentId equals dp.Id
                       where ep.EmpNo.StartsWith(_EmpNo)
                       where ep.Surname.StartsWith(_SurName)
                       where ep.EmployerId == _employer.Id
                       where ep.OtherNames.StartsWith(_OtherNames)
                       where dp.Description.StartsWith(_Department)
                       where ep.IsDeleted == false
                       where dp.IsDeleted == false
                       select ep).AsQueryable();
         return(_employees);
     }
     //empno
     if (!string.IsNullOrEmpty(txtEmpNo.Text) &&
         string.IsNullOrEmpty(txtSurName.Text) && string.IsNullOrEmpty(txtOtherNames.Text) && string.IsNullOrEmpty(txtDepartment.Text) && cboEmployer.SelectedIndex != -1)
     {
         DAL.Employer _employer = (DAL.Employer)cboEmployer.SelectedItem;
         string       _EmpNo    = txtEmpNo.Text;
         _employees = (from ep in rep.GetAllActiveEmployees()
                       where ep.EmpNo.StartsWith(_EmpNo)
                       where ep.EmployerId == _employer.Id
                       where ep.IsDeleted == false
                       select ep).AsQueryable();
         return(_employees);
     }
     //surname
     if (string.IsNullOrEmpty(txtEmpNo.Text) &&
         !string.IsNullOrEmpty(txtSurName.Text) && string.IsNullOrEmpty(txtOtherNames.Text) && string.IsNullOrEmpty(txtDepartment.Text) && cboEmployer.SelectedIndex != -1)
     {
         DAL.Employer _employer = (DAL.Employer)cboEmployer.SelectedItem;
         string       _SurName  = txtSurName.Text;
         _employees = (from ep in rep.GetAllActiveEmployees()
                       where ep.Surname.StartsWith(_SurName)
                       where ep.EmployerId == _employer.Id
                       where ep.IsDeleted == false
                       select ep).AsQueryable();
         return(_employees);
     }
     //othernames
     if (string.IsNullOrEmpty(txtEmpNo.Text) &&
         string.IsNullOrEmpty(txtSurName.Text) && !string.IsNullOrEmpty(txtOtherNames.Text) && string.IsNullOrEmpty(txtDepartment.Text) && cboEmployer.SelectedIndex != -1)
     {
         DAL.Employer _employer   = (DAL.Employer)cboEmployer.SelectedItem;
         string       _OtherNames = txtOtherNames.Text;
         _employees = (from ep in rep.GetAllActiveEmployees()
                       where ep.OtherNames.StartsWith(_OtherNames)
                       where ep.EmployerId == _employer.Id
                       where ep.IsDeleted == false
                       select ep).AsQueryable();
         return(_employees);
     }
     //departments
     if (string.IsNullOrEmpty(txtEmpNo.Text) &&
         string.IsNullOrEmpty(txtSurName.Text) && string.IsNullOrEmpty(txtOtherNames.Text) && !string.IsNullOrEmpty(txtDepartment.Text) && cboEmployer.SelectedIndex != -1)
     {
         DAL.Employer _employer   = (DAL.Employer)cboEmployer.SelectedItem;
         string       _Department = txtDepartment.Text;
         _employees = (from ep in rep.GetAllActiveEmployees()
                       join dp in db.Departments on ep.DepartmentId equals dp.Id
                       where dp.Description.StartsWith(_Department)
                       where ep.EmployerId == _employer.Id
                       where ep.IsDeleted == false
                       where dp.IsDeleted == false
                       select ep).AsQueryable();
         return(_employees);
     }
     //empno and surname
     if (!string.IsNullOrEmpty(txtEmpNo.Text) &&
         !string.IsNullOrEmpty(txtSurName.Text) && string.IsNullOrEmpty(txtOtherNames.Text) && string.IsNullOrEmpty(txtDepartment.Text) && cboEmployer.SelectedIndex != -1)
     {
         DAL.Employer _employer = (DAL.Employer)cboEmployer.SelectedItem;
         string       _EmpNo    = txtEmpNo.Text;
         string       _SurName  = txtSurName.Text;
         _employees = (from ep in rep.GetAllActiveEmployees()
                       where ep.EmpNo.StartsWith(_EmpNo)
                       where ep.Surname.StartsWith(_SurName)
                       where ep.EmployerId == _employer.Id
                       where ep.IsDeleted == false
                       select ep).AsQueryable();
         return(_employees);
     }
     //empno and othernames
     if (!string.IsNullOrEmpty(txtEmpNo.Text) &&
         string.IsNullOrEmpty(txtSurName.Text) && !string.IsNullOrEmpty(txtOtherNames.Text) && string.IsNullOrEmpty(txtDepartment.Text) && cboEmployer.SelectedIndex != -1)
     {
         DAL.Employer _employer   = (DAL.Employer)cboEmployer.SelectedItem;
         string       _EmpNo      = txtEmpNo.Text;
         string       _OtherNames = txtOtherNames.Text;
         _employees = (from ep in rep.GetAllActiveEmployees()
                       where ep.EmpNo.StartsWith(_EmpNo)
                       where ep.EmployerId == _employer.Id
                       where ep.OtherNames.StartsWith(_OtherNames)
                       where ep.IsDeleted == false
                       select ep).AsQueryable();
         return(_employees);
     }
     //empno and departments
     if (!string.IsNullOrEmpty(txtEmpNo.Text) &&
         string.IsNullOrEmpty(txtSurName.Text) && string.IsNullOrEmpty(txtOtherNames.Text) && !string.IsNullOrEmpty(txtDepartment.Text) && cboEmployer.SelectedIndex != -1)
     {
         DAL.Employer _employer   = (DAL.Employer)cboEmployer.SelectedItem;
         string       _EmpNo      = txtEmpNo.Text;
         string       _Department = txtDepartment.Text;
         _employees = (from ep in rep.GetAllActiveEmployees()
                       join dp in db.Departments on ep.DepartmentId equals dp.Id
                       where dp.IsDeleted == false
                       where ep.EmpNo.StartsWith(_EmpNo)
                       where dp.Description.StartsWith(_Department)
                       where ep.IsDeleted == false
                       where ep.EmployerId == _employer.Id
                       select ep).AsQueryable();
         return(_employees);
     }
     //surname and othernames
     if (string.IsNullOrEmpty(txtEmpNo.Text) &&
         !string.IsNullOrEmpty(txtSurName.Text) && !string.IsNullOrEmpty(txtOtherNames.Text) && string.IsNullOrEmpty(txtDepartment.Text) && cboEmployer.SelectedIndex != -1)
     {
         DAL.Employer _employer   = (DAL.Employer)cboEmployer.SelectedItem;
         string       _SurName    = txtSurName.Text;
         string       _OtherNames = txtOtherNames.Text;
         _employees = (from ep in rep.GetAllActiveEmployees()
                       where ep.Surname.StartsWith(_SurName)
                       where ep.OtherNames.StartsWith(_OtherNames)
                       where ep.EmployerId == _employer.Id
                       where ep.IsDeleted == false
                       select ep).AsQueryable();
         return(_employees);
     }
     //surname and departments
     if (string.IsNullOrEmpty(txtEmpNo.Text) &&
         !string.IsNullOrEmpty(txtSurName.Text) && string.IsNullOrEmpty(txtOtherNames.Text) && !string.IsNullOrEmpty(txtDepartment.Text) && cboEmployer.SelectedIndex != -1)
     {
         DAL.Employer _employer   = (DAL.Employer)cboEmployer.SelectedItem;
         string       _SurName    = txtSurName.Text;
         string       _Department = txtDepartment.Text;
         _employees = (from ep in rep.GetAllActiveEmployees()
                       join dp in db.Departments on ep.DepartmentId equals dp.Id
                       where ep.Surname.StartsWith(_SurName)
                       where dp.IsDeleted == false
                       where dp.Description.StartsWith(_Department)
                       where ep.EmployerId == _employer.Id
                       where ep.IsDeleted == false
                       select ep).AsQueryable();
         return(_employees);
     }
     //othernames and departments
     if (string.IsNullOrEmpty(txtEmpNo.Text) &&
         string.IsNullOrEmpty(txtSurName.Text) && !string.IsNullOrEmpty(txtOtherNames.Text) && !string.IsNullOrEmpty(txtDepartment.Text) && cboEmployer.SelectedIndex != -1)
     {
         DAL.Employer _employer   = (DAL.Employer)cboEmployer.SelectedItem;
         string       _OtherNames = txtOtherNames.Text;
         string       _Department = txtDepartment.Text;
         _employees = (from ep in rep.GetAllActiveEmployees()
                       join dp in db.Departments on ep.DepartmentId equals dp.Id
                       where ep.OtherNames.StartsWith(_OtherNames)
                       where dp.Description.StartsWith(_Department)
                       where ep.EmployerId == _employer.Id
                       where dp.IsDeleted == false
                       where ep.IsDeleted == false
                       select ep).AsQueryable();
         return(_employees);
     }
     //empno and surname and othernames
     if (!string.IsNullOrEmpty(txtEmpNo.Text) &&
         !string.IsNullOrEmpty(txtSurName.Text) && !string.IsNullOrEmpty(txtOtherNames.Text) && string.IsNullOrEmpty(txtDepartment.Text) && cboEmployer.SelectedIndex != -1)
     {
         DAL.Employer _employer   = (DAL.Employer)cboEmployer.SelectedItem;
         string       _EmpNo      = txtEmpNo.Text;
         string       _SurName    = txtSurName.Text;
         string       _OtherNames = txtOtherNames.Text;
         _employees = (from ep in rep.GetAllActiveEmployees()
                       where ep.EmployerId == _employer.Id
                       where ep.EmpNo.StartsWith(_EmpNo)
                       where ep.Surname.StartsWith(_SurName)
                       where ep.OtherNames.StartsWith(_OtherNames)
                       where ep.IsDeleted == false
                       select ep).AsQueryable();
         return(_employees);
     }
     //empno and surname and departments
     if (!string.IsNullOrEmpty(txtEmpNo.Text) &&
         !string.IsNullOrEmpty(txtSurName.Text) && string.IsNullOrEmpty(txtOtherNames.Text) && !string.IsNullOrEmpty(txtDepartment.Text) && cboEmployer.SelectedIndex != -1)
     {
         DAL.Employer _employer   = (DAL.Employer)cboEmployer.SelectedItem;
         string       _EmpNo      = txtEmpNo.Text;
         string       _SurName    = txtSurName.Text;
         string       _Department = txtDepartment.Text;
         _employees = (from ep in rep.GetAllActiveEmployees()
                       join dp in db.Departments on ep.DepartmentId equals dp.Id
                       where ep.EmpNo.StartsWith(_EmpNo)
                       where ep.EmployerId == _employer.Id
                       where ep.Surname.StartsWith(_SurName)
                       where dp.Description.StartsWith(_Department)
                       where ep.IsDeleted == false
                       where dp.IsDeleted == false
                       select ep).AsQueryable();
         return(_employees);
     }
     //empno and othernames and departments
     if (!string.IsNullOrEmpty(txtEmpNo.Text) &&
         string.IsNullOrEmpty(txtSurName.Text) && !string.IsNullOrEmpty(txtOtherNames.Text) && !string.IsNullOrEmpty(txtDepartment.Text) && cboEmployer.SelectedIndex != -1)
     {
         DAL.Employer _employer   = (DAL.Employer)cboEmployer.SelectedItem;
         string       _EmpNo      = txtEmpNo.Text;
         string       _OtherNames = txtOtherNames.Text;
         string       _Department = txtDepartment.Text;
         _employees = (from ep in rep.GetAllActiveEmployees()
                       join dp in db.Departments on ep.DepartmentId equals dp.Id
                       where ep.EmpNo.StartsWith(_EmpNo)
                       where ep.EmployerId == _employer.Id
                       where ep.OtherNames.StartsWith(_OtherNames)
                       where dp.Description.StartsWith(_Department)
                       where ep.IsDeleted == false
                       where dp.IsDeleted == false
                       select ep).AsQueryable();
         return(_employees);
     }
     //surname and othernames and departments
     if (string.IsNullOrEmpty(txtEmpNo.Text) &&
         !string.IsNullOrEmpty(txtSurName.Text) && !string.IsNullOrEmpty(txtOtherNames.Text) && !string.IsNullOrEmpty(txtDepartment.Text) && cboEmployer.SelectedIndex != -1)
     {
         DAL.Employer _employer   = (DAL.Employer)cboEmployer.SelectedItem;
         string       _SurName    = txtSurName.Text;
         string       _OtherNames = txtOtherNames.Text;
         string       _Department = txtDepartment.Text;
         _employees = (from ep in rep.GetAllActiveEmployees()
                       join dp in db.Departments on ep.DepartmentId equals dp.Id
                       where ep.Surname.StartsWith(_SurName)
                       where ep.OtherNames.StartsWith(_OtherNames)
                       where ep.EmployerId == _employer.Id
                       where dp.Description.StartsWith(_Department)
                       where ep.IsDeleted == false
                       where dp.IsDeleted == false
                       select ep).AsQueryable();
         return(_employees);
     }
     return(_employees);
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (IsEmployerValid())
            {
                try
                {
                    DAL.Employer _employer = new DAL.Employer();
                    if (!string.IsNullOrEmpty(txtName.Text))
                    {
                        _employer.Name = Utils.ConvertFirstLetterToUpper(txtName.Text.ToString().Trim());
                    }
                    if (!string.IsNullOrEmpty(txtAddress1.Text))
                    {
                        _employer.Address1 = Utils.ConvertFirstLetterToUpper(txtAddress1.Text.ToString().Trim());
                    }
                    if (!string.IsNullOrEmpty(txtAddress2.Text))
                    {
                        _employer.Address2 = Utils.ConvertFirstLetterToUpper(txtAddress2.Text.ToString().Trim());
                    }
                    if (!string.IsNullOrEmpty(txtTelephone.Text))
                    {
                        _employer.Telephone = txtTelephone.Text.ToString().Trim();
                    }
                    if (!string.IsNullOrEmpty(txtPIN.Text))
                    {
                        _employer.PIN = txtPIN.Text.ToString().Trim();
                    }
                    if (!string.IsNullOrEmpty(txtEmail.Text))
                    {
                        _employer.Email = txtEmail.Text.ToString().Trim();
                    }
                    if (!string.IsNullOrEmpty(txtNHIF.Text))
                    {
                        _employer.NHIF = txtNHIF.Text.ToString().Trim();
                    }
                    if (!string.IsNullOrEmpty(txtNSSF.Text))
                    {
                        _employer.NSSF = txtNSSF.Text.ToString().Trim();
                    }
                    if (!string.IsNullOrEmpty(txtLogo.Text))
                    {
                        _employer.Logo = txtLogo.Text.ToString().Trim();
                    }
                    if (!string.IsNullOrEmpty(txtSlogan.Text))
                    {
                        _employer.Slogan = Utils.ConvertFirstLetterToUpper(txtSlogan.Text.ToString().Trim());
                    }
                    int banksortcode;
                    if (!string.IsNullOrEmpty(txtBankSortCode.Text) && int.TryParse(txtBankSortCode.Text, out banksortcode))
                    {
                        _employer.BankBranchSortCode = txtBankSortCode.Text;
                    }
                    if (!string.IsNullOrEmpty(txtAccountName.Text))
                    {
                        _employer.AccountName = Utils.ConvertFirstLetterToUpper(txtAccountName.Text.ToString().Trim());
                    }
                    if (!string.IsNullOrEmpty(txtAccountNo.Text))
                    {
                        _employer.AccountNo = Utils.ConvertFirstLetterToUpper(txtAccountNo.Text.ToString().Trim());
                    }
                    if (!string.IsNullOrEmpty(txtAuthSign.Text))
                    {
                        _employer.AuthorizedSignatory = Utils.ConvertFirstLetterToUpper(txtAuthSign.Text.ToString().Trim());
                    }
                    _employer.IsActive  = true;
                    _employer.IsDeleted = false;

                    if (db.Employers.Any(c => c.Name == _employer.Name))
                    {
                        MessageBox.Show("Employer with name " + _employer.Name + " Exists !", "SB Payroll", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    if (!db.Employers.Any(c => c.Name == _employer.Name))
                    {
                        int employerid = rep.AddEmployer(_employer);

                        foreach (var bank in _employerbanks)
                        {
                            bank.EmployerId = employerid;
                            rep.AddEmployerBank(bank);
                        }

                        Employer f = (Employer)this.Owner;
                        f.RefreshGrid();
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    Utils.ShowError(ex);
                }
            }
        }