예제 #1
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                Database.Entities.tb_employees tbemployees = new Database.Entities.tb_employees();
                Business.EmployeesBusiness     busemployee = new Business.EmployeesBusiness();

                Database.Entities.tb_department tbdepartment  = new Database.Entities.tb_department();
                Business.DepartmentBusiness     busdepartment = new Business.DepartmentBusiness();

                Database.Entities.tb_function tbfunction  = new Database.Entities.tb_function();
                Business.FunctionBusiness     busfunction = new Business.FunctionBusiness();

                Database.Entities.tb_timecard tbtimecard  = new Database.Entities.tb_timecard();
                Business.TimeCardBusiness     bustimecard = new Business.TimeCardBusiness();

                Database.Entities.tb_financial tbfinancial  = new Database.Entities.tb_financial();
                Business.FinancialBusiness     busfinancial = new Business.FinancialBusiness();

                Database.Entities.tb_benefits tbbenefits  = new Database.Entities.tb_benefits();
                Business.BenefitsBusiness     busbenefits = new Business.BenefitsBusiness();

                Database.Entities.tb_bankaccount tbbank  = new Database.Entities.tb_bankaccount();
                Business.BankAccountBusiness     busbank = new Business.BankAccountBusiness();

                tbemployees.dt_hiring        = dtpContratação.Value.ToShortDateString();
                tbemployees.dt_resignation   = dtpDemissão.Value.ToShortDateString();
                tbdepartment.nm_department   = cboDepartamento.Text;
                tbfunction.nm_function       = cboCargo.Text;
                tbtimecard.hr_fixedInput     = mtxtInício.Text;
                tbtimecard.hr_fixedIntInput  = mtxtInícioIntervalo.Text;
                tbtimecard.hr_fixedIntOutput = mtxtTérminoIntervalo.Text;
                tbtimecard.hr_fixedOutput    = mtxtTérminoIntervalo.Text;
                tbfinancial.vl_grossSalary   = nudSalárioBruto.Value;
                tbbenefits.bt_food           = Convert.ToBoolean(chkValeAlimentação.Checked);
                tbbenefits.bt_meal           = Convert.ToBoolean(chkValeRefeição.Checked);
                tbbenefits.bt_lifeSafe       = Convert.ToBoolean(chkSeguroDeVida.Checked);
                tbbenefits.bt_transport      = Convert.ToBoolean(chkValeTransporte.Checked);
                tbbenefits.bt_planHealth     = Convert.ToBoolean(chkPlanoDeSáude.Checked);
                tbbenefits.bt_planDental     = Convert.ToBoolean(chkPlanoDental.Checked);
                tbbank.nm_bank       = txtNomeDoBanco.Text;
                tbbank.nr_account    = mtxtCódigoDoBanco.Text;
                tbbank.nr_agency     = Convert.ToInt32(mtxtAgênciaDoBanco.Text);
                tbbank.ds_typePerson = cboTipoDePessoa.Text;

                busemployee.Inserir1(tbemployees);
                busdepartment.Inserir(tbdepartment);
                busfunction.Inserir(tbfunction);
                bustimecard.Inserir(tbtimecard);
                busfinancial.Inserir(tbfinancial);
                busbenefits.Inserir(tbbenefits);
                busbank.Inserir(tbbank);

                MessageBox.Show("Funcionário cadastrado com sucesso");

                Model.EmployeesModel.firstName  = string.Empty;
                Model.EmployeesModel.lastName   = string.Empty;
                Model.EmployeesModel.RG         = string.Empty;
                Model.EmployeesModel.CPF        = string.Empty;
                Model.EmployeesModel.dependents = 0;
                Model.EmployeesModel.birth      = Convert.ToString(DateTime.Now);
                Model.EmployeesModel.CEP        = string.Empty;
                Model.EmployeesModel.note       = string.Empty;
                Model.EmployeesModel.address    = string.Empty;
                Model.EmployeesModel.email      = string.Empty;
                Model.EmployeesModel.cellphone  = string.Empty;
                Model.EmployeesModel.tellphone  = string.Empty;
                Model.EmployeesModel.password   = string.Empty;
                Model.EmployeesModel.manager    = Convert.ToBoolean(string.Empty);
                Model.EmployeesModel.employeer  = Convert.ToBoolean(string.Empty);
                Model.EmployeesModel.RH         = Convert.ToBoolean(string.Empty);
                Model.EmployeesModel.financial  = Convert.ToBoolean(string.Empty);
                Model.EmployeesModel.stock      = Convert.ToBoolean(string.Empty);
                Model.EmployeesModel.CRM        = Convert.ToBoolean(string.Empty);
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception)
            {
                MessageBox.Show("Ocorreu um erro!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
 public void Inserir(Database.Entities.tb_bankaccount bank)
 {
     db.Inserir(bank);
 }