private void lblVoltar_Click(object sender, EventArgs e)
        {
            frmTelaAdminFuncLista TelaAdmFuncLista = new frmTelaAdminFuncLista();

            this.Hide();
            TelaAdmFuncLista.Show();
        }
        private void frmTelaAdminEditarFunc_FormClosed(object sender, FormClosedEventArgs e)
        {
            frmTelaAdminFuncLista funclista = new frmTelaAdminFuncLista();

            funclista.Show();
            this.Hide();
        }
        private void lblSalvar_Click(object sender, EventArgs e)
        {
            if (txtNome1.Text == string.Empty || txtNovoSal.Text == string.Empty || txtSalAtual.Text == string.Empty)
            {
                MessageBox.Show("Por Favor preencha os campos vazios!!!", "Campos Vazios", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                if (txtNome1.Text == string.Empty)
                {
                    pctFunc.Visible = true;
                }

                if (txtNovoSal.Text == string.Empty)
                {
                    pctNovoSal.Visible = true;
                }

                if (txtSalAtual.Text == string.Empty)
                {
                    pctSalAtual.Visible = true;
                }
            }
            else
            {
                if (txtNovoSal.Text != string.Empty)
                {
                    DialogResult i = MessageBox.Show("Deseja realmente alterar o salario de " + func.Nome1_func + " ?", "Alterar salario", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                    if (i == DialogResult.Yes)
                    {
                        func.alterarSFunc(txtNovoSal.Text.Replace(",", "."), acessoVariaveis.FuncionarioS.ToString());

                        string acao = "EDITOU SALARIO", desc = "Administrador - " + acessoDadosLogado.Codigo.ToString();
                        string dt = DateTime.Now.ToString("dd/MM/yyyy"), hr = DateTime.Now.ToString("HH:mm:ss");
                        audiA.inserir(dt, hr, acessoDadosLogado.Codigo.ToString(), acao, desc);

                        MessageBox.Show("A alteração foi realizada com exito!!", "Alteração concluida", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        frmTelaAdminFuncLista funclista = new frmTelaAdminFuncLista();
                        funclista.Show();
                        this.Hide();
                    }
                }
                else
                {
                    MessageBox.Show("Digite um novo salario!!", "Salario", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Example #4
0
        private void lblCadastrar_Click(object sender, EventArgs e)
        {
            if (txtSalario.Text == string.Empty || txtNome1.Text == string.Empty || txtNome2.Text == string.Empty ||
                mskCelular.Text == string.Empty || txtEmail.Text == string.Empty ||
                mskCPF.Text == string.Empty || rdFem.Checked == false && rdMasc.Checked == false ||
                mskdCep.Text == string.Empty || txtBairro.Text == string.Empty ||
                txtEnd.Text == string.Empty || txtNum.Text == string.Empty || mskDataNasc.Text == string.Empty ||
                cmbPerg.Text == string.Empty || txtResp.Text == string.Empty)
            {
                MessageBox.Show("Por Favor preencha todos os campos!!", "Cadastrar Funcionário", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                if (txtSalario.Text == string.Empty)
                {
                    pctSalario.Visible = true;
                }

                if (txtNome1.Text == string.Empty)
                {
                    pctNome1.Visible = true;
                }

                if (txtNome2.Text == string.Empty)
                {
                    pctNome2.Visible = true;
                }

                if (mskCelular.Text == string.Empty)
                {
                    pctCelular.Visible = true;
                }

                if (txtEmail.Text == string.Empty)
                {
                    pctEmail.Visible = true;
                }

                if (mskCPF.Text == string.Empty)
                {
                    mskCPF.ForeColor = Color.Red;
                }

                if (rdFem.Checked == false && rdMasc.Checked == false)
                {
                    pctSexo.Visible = true;
                }

                if (mskdCep.Text == string.Empty)
                {
                    pctCEP.Visible = true;
                }

                if (txtBairro.Text == string.Empty)
                {
                    pctBairro.Visible = true;
                }

                if (txtEnd.Text == string.Empty)
                {
                    pctEnd.Visible = true;
                }

                if (txtNum.Text == string.Empty)
                {
                    pctNum.Visible = true;
                }

                if (mskDataNasc.Text == string.Empty)
                {
                    pctDataNasc.Visible = true;
                }

                if (cmbPerg.Text == string.Empty)
                {
                    pctPerg.Visible = true;
                }

                if (txtResp.Text == string.Empty)
                {
                    pctResp.Visible = true;
                }
            }
            else
            {
                if (rdMasc.Checked == true)
                {
                    sexo = "M";
                }
                if (rdFem.Checked == true)
                {
                    sexo = "F";
                }

                Random rdm   = new Random();
                string Chars = "abcdefghijklmnopqrstuvwxyz1234567890@#!?";
                string lma   = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                string lmi   = "abcdefghijklmnopqrstuvwxyz";
                string nu    = "1234567890";
                string ce    = "@#!?";

                string login = txtNome1.Text;
                login += nu[rdm.Next(0, nu.Length)].ToString();
                login += nu[rdm.Next(0, nu.Length)].ToString();
                login += ce[rdm.Next(0, ce.Length)].ToString();

                string senha = Chars[rdm.Next(0, Chars.Length)].ToString().ToUpper();
                senha += lma[rdm.Next(0, lma.Length)].ToString();
                senha += nu[rdm.Next(0, nu.Length)].ToString();
                senha += ce[rdm.Next(0, ce.Length)].ToString();
                senha += lmi[rdm.Next(0, lmi.Length)].ToString();
                senha += Chars[rdm.Next(0, Chars.Length)].ToString().ToUpper();
                senha += ce[rdm.Next(0, ce.Length)].ToString();
                senha += Chars[rdm.Next(0, Chars.Length)].ToString().ToUpper();

                perg = cmbPerg.Text;

                resp = txtResp.Text;

                #region CPF validação
                cpfTela = mskCPF.Text;
                if (func.cpf_pesq(cpfTela) == true)
                {
                    MessageBox.Show("CPF ja existente, digite outro!", "CPF", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (!validar.ValidaCPF.IsCpf(mskCPF.Text))
                {
                    MessageBox.Show("CPF invalido, digite outro!", "CNPJ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                #endregion

                #region Email validação
                emailTela = txtEmail.Text;

                if (!Classes.Validacao.ValidacaoEmail(emailTela))
                {
                    MessageBox.Show("Favor inserir um email valido");
                    return;
                }
                if (func.emailPesq(emailTela) == true)
                {
                    MessageBox.Show("Email ja existente, digite outro!", "Email", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                #endregion

                dataCad   = DateTime.Now;
                dataRecad = DateTime.Now;
                dataRecad = dataRecad.AddMonths(6);

                func.cadastrarFunc(login, senha, "0", "0", "0", txtNome1.Text, txtNome2.Text, mskDataNasc.Text, dataCad.ToString(), dataRecad.ToString(), mskCelular.Text, txtEmail.Text, mskCPF.Text,
                                   sexo, mskdCep.Text, txtBairro.Text, txtEnd.Text, txtNum.Text, txtComp.Text, txtSalario.Text, perg, resp, "0", "1");

                string acao = "CADASTRO FUNCIONARIO", desc = "Administrador - " + acessoDadosLogado.Codigo.ToString();
                string dt = DateTime.Now.ToString("dd/MM/yyyy"), hr = DateTime.Now.ToString("HH:mm:ss");
                audiA.inserir(dt, hr, acessoDadosLogado.Codigo.ToString(), acao, desc);

                Email.sendNewCadFunc(txtEmail.Text, txtNome1.Text, login, senha);

                MessageBox.Show("Funcionário cadastrado com sucesso! \r\n Seu Login: "******" \r\n Sua Senha: " + senha, "Cadastro", MessageBoxButtons.OK, MessageBoxIcon.Information);

                frmTelaAdminFuncLista frmadmf = new frmTelaAdminFuncLista();
                this.Hide();
                frmadmf.Show();
            }
        }