Beispiel #1
0
        private tb_employees ReadEmployees()
        {
            tb_employees emp = new tb_employees();

            emp.id_emp         = EmployeesModel.ID;
            emp.nm_firstName   = EmployeesModel.firstName;
            emp.nm_lastName    = EmployeesModel.lastName;
            emp.nr_rg          = EmployeesModel.RG.Contains(",") ? EmployeesModel.RG.Replace(",", ".") : EmployeesModel.RG;
            emp.nr_cpf         = EmployeesModel.CPF;
            emp.nr_dependents  = EmployeesModel.dependents;
            emp.ds_sex         = EmployeesModel.sex;
            emp.dt_birth       = EmployeesModel.birth;
            emp.ds_state       = EmployeesModel.state;
            emp.nr_cep         = EmployeesModel.CEP;
            emp.ds_address     = EmployeesModel.address;
            emp.ds_note        = EmployeesModel.note;
            emp.nr_cellphone   = EmployeesModel.cellphone;
            emp.nr_tellphone   = EmployeesModel.tellphone;
            emp.ds_email       = EmployeesModel.email;
            emp.pw_password    = EmployeesModel.password;
            emp.bt_manager     = EmployeesModel.manager;
            emp.bt_employee    = EmployeesModel.employeer;
            emp.bt_rh          = EmployeesModel.RH;
            emp.bt_provider    = EmployeesModel.Provider;
            emp.bt_financial   = EmployeesModel.financial;
            emp.bt_stock       = EmployeesModel.stock;
            emp.bt_crm         = EmployeesModel.CRM;
            emp.dt_hiring      = dtpContratação.Value.ToShortDateString();
            emp.dt_resignation = "01/01/9998";

            return(emp);
        }
Beispiel #2
0
 public void Remover(tb_employees emp, tb_deptfunction defu, tb_timecard ticd,
                     tb_financial fin, tb_benefits ben, tb_bankaccount bank, tb_discounts dis)
 {
     defuB.Remover(defu);
     ticdB.Remover(ticd);
     finB.Remover(fin);
     benB.Remover(ben);
     bankB.Remover(bank);
     disB.Remover(dis);
     db.Remover(emp);
 }
Beispiel #3
0
        private void LoadControls()
        {
            int id = EmployeesModel.ID;

            EmployeesDatabase    DBemp  = new EmployeesDatabase();
            DeptFunctionDatabase DBdefu = new DeptFunctionDatabase();
            TimeCardDatabase     DBticd = new TimeCardDatabase();
            FinancialDatabase    DBfin  = new FinancialDatabase();
            BenefitsDatabase     DBben  = new BenefitsDatabase();
            BankAccountDatabase  DBbank = new BankAccountDatabase();
            DiscountsDatabase    DBdis  = new DiscountsDatabase();

            tb_employees    emp  = DBemp.ConsultarPorID(id);
            tb_deptfunction defu = DBdefu.ConsultarPorID(id);
            tb_timecard     ticd = DBticd.ConsultarPorID(id);
            tb_financial    fin  = DBfin.ConsultarPorID(id);
            tb_benefits     ben  = DBben.ConsultarPorID(id);
            tb_bankaccount  bank = DBbank.ConsultarPorID(id);
            tb_discounts    dis  = DBdis.ConsultarPorID(id);

            if (emp == null)
            {
                return;
            }

            dtpContratação.Value       = Convert.ToDateTime(emp.dt_hiring);
            dtpDemissão.Value          = Convert.ToDateTime(emp.dt_resignation);
            cboDepartamento.Text       = defu.nm_department;
            cboCargo.Text              = defu.nm_function;
            nudSalárioBruto.Value      = fin.vl_grossSalary;
            chkValeTransporte.Checked  = ben.bt_transport;
            chkValeAlimentação.Checked = ben.bt_food;
            chkValeRefeição.Checked    = ben.bt_meal;
            chkSeguroDeVida.Checked    = ben.bt_lifeSafe;
            chkPlanoDeSáude.Checked    = ben.bt_planHealth;
            chkPlanoDental.Checked     = ben.bt_planDental;
            nudTarifa.Value            = Convert.ToDecimal(ben.vl_transport);
            nudValeAlimentação.Value   = Convert.ToDecimal(ben.vl_food);
            nudValeRefeição.Value      = Convert.ToDecimal(ben.vl_meal);
            nudSeguroDeVida.Value      = Convert.ToDecimal(ben.vl_lifeSafe);
            nudPlanoDeSáude.Value      = Convert.ToDecimal(ben.vl_planHealth);
            nudPlanoDental.Value       = Convert.ToDecimal(ben.vl_planDental);
            txtNomeDoBanco.Text        = bank.nm_bank;
            mtxtAgência.Text           = bank.nr_agency.ToString();
            mtxtConta.Text             = bank.nr_account;
            cboTipoDePessoa.Text       = bank.ds_typePerson;
            nudPensãoAlimentícia.Value = Convert.ToDecimal(dis.vl_foodPension);
            cboTipoDeSalário.Text      = fin.ds_typeSalary;
            mtxtEntrada.Text           = ticd.hr_fixedInput;
            mtxtSaída.Text             = ticd.hr_fixedOutput;
            mtxtInícioInt.Text         = ticd.hr_fixedIntInput;
            mtxtFinalInt.Text          = ticd.hr_fixedIntOutput;
        }
Beispiel #4
0
        private void Insirir(tb_employees emp, tb_deptfunction defu, tb_timecard ticd,
                             tb_financial fin, tb_benefits ben, tb_bankaccount bank, tb_discounts dis)
        {
            int id = db.Insirir(emp);

            defuB.Insirir(defu, id);
            ticdB.Insirir(ticd, id);
            finB.insirir(fin, id);
            benB.Insirir(ben, id);
            bankB.Insirir(bank, id);
            disB.insirir(dis, id);
        }
Beispiel #5
0
        private void Alterar(tb_employees emp, tb_deptfunction defu, tb_timecard ticd,
                             tb_financial fin, tb_benefits ben, tb_bankaccount bank, tb_discounts dis)
        {
            int id = EmployeesModel.ID;

            defuB.Alterar(defu, id);
            ticdB.Alterar(ticd, id);
            finB.Alterar(fin, id);
            benB.Alterar(ben, id);
            bankB.Alterar(bank, id);
            disB.Alterar(dis, id);
            db.Alterar(emp, id);
        }
Beispiel #6
0
        public string UpdateEmployee(tb_employees emp, tb_deptfunction defu, tb_timecard ticd,
                                     tb_financial fin, tb_benefits ben, tb_bankaccount bank, tb_discounts dis)
        {
            string error = string.Empty;

            if (error == string.Empty)
            {
                error = this.VericarParametros(emp);
            }

            if (error == string.Empty)
            {
                error = defuB.VericarParametros(defu);
            }

            if (error == string.Empty)
            {
                error = ticdB.VericarParametros(ticd);
            }

            if (error == string.Empty)
            {
                error = finB.VericarParametros(fin);
            }

            if (error == string.Empty)
            {
                error = benB.VericarParametros(ben);
            }

            if (error == string.Empty)
            {
                error = bankB.VericarParametros(bank);
            }

            if (error == string.Empty)
            {
                error = disB.VericarParametros(dis);
            }

            if (error == string.Empty)
            {
                this.Alterar(emp, defu, ticd, fin, ben, bank, dis);
                return("Alterado com sucesso!");
            }
            else
            {
                return(error);
            }
        }
Beispiel #7
0
 public bool Login(tb_employees emp)
 {
     if (emp.ds_email == string.Empty || emp.ds_email == "Email do usuário")
     {
         throw new ArgumentException("O campo email deve ser preenchido");
     }
     else if (emp.pw_password == string.Empty || emp.pw_password == "Senha do usuário")
     {
         throw new ArgumentException("O campo senha deve ser preenchido");
     }
     else
     {
         return(db.Login(emp));
     }
 }
Beispiel #8
0
        public string DeleteEmployee(int id)
        {
            tb_employees    emp  = ConsultarPorID(id);
            tb_deptfunction defu = defuB.ConsultarPorID(id);
            tb_timecard     ticd = ticdB.ConsultarPorID(id);
            tb_financial    fin  = finB.ConsultarPorID(id);
            tb_benefits     ben  = benB.ConsultarPorID(id);
            tb_bankaccount  bank = bankB.ConsultarPorID(id);
            tb_discounts    dis  = disB.ConsultarPorID(id);

            if (emp != null && defu != null && ticd != null && fin != null && ben != null && bank != null && dis != null)
            {
                this.Remover(emp, defu, ticd, fin, ben, bank, dis);
                return("Funcionário Removido com Sucesso!");
            }
            else
            {
                return("Funcionário Inexistente!");
            }
        }
Beispiel #9
0
        public string ImpostoDeRenda()
        {
            tb_financial financial = DB.tb_financial.First(t => t.id_emp == id);
            tb_employees tb        = DB.tb_employees.First(t => t.id_emp == id);

            double bruto    = Convert.ToDouble(financial.vl_grossSalary);
            double IR       = 00.00;
            double aliquota = 00.00;
            double dedução  = 00.00;

            if (bruto <= 1903.98)
            {
                aliquota = 0.0;
                dedução  = 0.0;
            }
            if (bruto >= 1903.99 && bruto <= 2826.65)
            {
                aliquota = 0.075;
                dedução  = 142.80;
            }
            if (bruto >= 2826.66 && bruto <= 3751.05)
            {
                aliquota = 0.15;
                dedução  = 354.80;
            }
            if (bruto >= 3751.06 && bruto <= 4664.68)
            {
                aliquota = 0.225;
                dedução  = 636.13;
            }
            if (bruto >= 4664.69)
            {
                aliquota = 0.275;
                dedução  = 869.36;
            }

            double dependentes = tb.nr_dependents * 189.59;

            IR = ((bruto - dependentes - inss) * aliquota) - dedução;
            return("R$ " + IR.ToString());
        }
Beispiel #10
0
 private void nudID_Leave(object sender, EventArgs e)
 {
     try
     {
         tb_employees emp = EB.ConsultarPorID(Convert.ToInt32(nudID.Value));
         if (emp != null)
         {
             txtNome.Text           = emp.nm_firstName;
             txtSobrenome.Text      = emp.nm_lastName;
             mtxtRG.Text            = emp.nr_rg;
             mtxtCPF.Text           = emp.nr_cpf;
             nudDependentes.Value   = emp.nr_dependents;
             cboSexo.Text           = emp.ds_sex == "M" ? "Masculino" : "Feminino";
             dtpNascimento.Value    = Convert.ToDateTime(emp.dt_birth);
             cboEstado.Text         = emp.ds_state;
             mtxtCEP.Text           = emp.nr_cep;
             txtEndereço.Text       = emp.ds_address;
             txtComplemento.Text    = emp.ds_note;
             mtxtCelular.Text       = emp.nr_cellphone;
             mtxtTelefone.Text      = emp.nr_tellphone;
             txtEmail.Text          = emp.ds_email;
             txtSenha.Text          = emp.pw_password;
             rdbFuncionário.Checked = Convert.ToBoolean(emp.bt_employee);
             rdbGerente.Checked     = Convert.ToBoolean(emp.bt_manager);
             chkCRM.Checked         = Convert.ToBoolean(emp.bt_crm);
             chkFornecedor.Checked  = Convert.ToBoolean(emp.bt_provider);
             chkEstoque.Checked     = Convert.ToBoolean(emp.bt_stock);
             chkRH.Checked          = Convert.ToBoolean(emp.bt_rh);
             chkFinanceiro.Checked  = Convert.ToBoolean(emp.bt_financial);
         }
         else
         {
             this.EmptyControls();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ocorreu um erro!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #11
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                tb_employees    emp  = this.ReadEmployees();
                tb_deptfunction defu = this.ReadDeptFunction();
                tb_timecard     ticd = this.ReadTimeCard();
                tb_financial    fin  = this.ReadFinancial();
                tb_benefits     ben  = this.ReadBenefits();
                tb_bankaccount  bank = this.ReadBankAccount();
                tb_discounts    dis  = this.ReadDiscounts();

                EmployeesBusiness EB  = new EmployeesBusiness();
                string            res = EB.UpdateEmployee(emp, defu, ticd, fin, ben, bank, dis);

                MessageBox.Show(res, "liriou's Burguer", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ocorreu um erro!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #12
0
        public string SalárioFamília()
        {
            tb_employees tb        = DB.tb_employees.First(t => t.id_emp == id);
            tb_financial financial = DB.tb_financial.First(t => t.id_emp == id);

            double bruto = Convert.ToDouble(financial.vl_grossSalary);
            double SF;

            if (bruto <= 907.77)
            {
                SF = tb.nr_dependents * 46.54;
            }
            else if (bruto > 907.77 && bruto < 1364.43)
            {
                SF = tb.nr_dependents * 32.80;
            }
            else
            {
                SF = 00.00;
            }

            SL = SL + SF;
            return("R$ " + SL.ToString());
        }
Beispiel #13
0
        public string VericarParametros(tb_employees emp)
        {
            if (emp.nm_firstName == string.Empty)
            {
                return("O campo nome deve ser preenchido!");
            }
            if (emp.nm_lastName == string.Empty)
            {
                return("O campo sobrenome deve ser preenchido!");
            }
            if (emp.nr_rg == string.Empty)
            {
                return("O campo RG deve ser preenchido!");
            }
            if (emp.nr_cpf == string.Empty)
            {
                return("O campo CPF deve ser preenchido!");
            }
            if (emp.ds_sex != "Masculino" && emp.ds_sex != "Feminino")
            {
                return("O campo sexo deve ser preenchido!");
            }
            if (emp.ds_sex == "Masculino")
            {
                emp.ds_sex = "M";
            }
            if (emp.ds_sex == "Feminino")
            {
                emp.ds_sex = "F";
            }
            if (emp.ds_state == string.Empty)
            {
                return("O campo estado deve ser preenchido!");
            }
            if (emp.nr_cep == string.Empty)
            {
                return("O campo CEP deve ser preenchido!");
            }
            if (emp.ds_address == string.Empty)
            {
                return("O campo endereço deve ser preenchido!");
            }
            if (emp.ds_email == string.Empty)
            {
                return("O campo email deve ser preenchido!");
            }
            if (emp.ds_email != string.Empty)
            {
                Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
                Match match = regex.Match(emp.ds_email);
                if (match.Success == false)
                {
                    return(emp.ds_email + " Não é um email válido");
                }
            }
            if (emp.pw_password == string.Empty)
            {
                return("O campo senha deve ser preenchido!");
            }
            if (emp.bt_employee == false && emp.bt_manager == false)
            {
                return("Escolha Funcionario ou Gerente!");
            }
            if (emp.bt_manager == true && emp.bt_employee == false)
            {
                emp.bt_crm       = true;
                emp.bt_provider  = true;
                emp.bt_financial = true;
                emp.bt_rh        = true;
                emp.bt_stock     = true;
            }

            return(string.Empty);
        }
Beispiel #14
0
        public tb_employees ConsultarPorID(int id)
        {
            tb_employees emp = db.ReturnEmployee(id);

            return(emp);
        }
Beispiel #15
0
        public string NomeCompleto()
        {
            tb_employees tb = DB.tb_employees.First(t => t.id_emp == id);

            return(tb.nm_firstName + " " + tb.nm_lastName);
        }
Beispiel #16
0
        public string Dependents()
        {
            tb_employees tb = DB.tb_employees.First(t => t.id_emp == id);

            return("Qtd " + tb.nr_dependents.ToString());
        }
Beispiel #17
0
 public void CarregarFuncionario(tb_employees employees)
 {
     this.employees = employees;
 }