Exemplo n.º 1
0
        private void VerFuncionarios_Load(object sender, EventArgs e)
        {
            CrudFunc crudfunc = new CrudFunc(inicio);

            crudfunc.exibir(dataGridView1);
            rbCrescente.Checked = true;
        }
Exemplo n.º 2
0
        //btnEditar
        private void button4_Click_1(object sender, EventArgs e)
        {
            ValidacaoGeral validacaoGeral = new ValidacaoGeral();
            bool           checar         = validacaoGeral.validaDatagrid(this);

            if (checar)
            {
                CrudFunc crudfunc = new CrudFunc(inicio);
                cadfunc2 = new CadFunc("editar", linha, dataGridView1, inicio);
                crudfunc.MostrarEditar(linha, dataGridView1, cadfunc2);
            }
        }
Exemplo n.º 3
0
        //btnDeletar
        private void button1_Click(object sender, EventArgs e)
        {
            ValidacaoGeral validacaoGeral = new ValidacaoGeral();
            bool           checar         = validacaoGeral.validaDatagrid(this);
            CrudFunc       crudFunc       = new CrudFunc(inicio);

            LoginSistema loginSistema = new LoginSistema();
            // int id_funcLogado = loginSistema.getFuncByIdUser(usuario);
            int id_funcGrid = crudFunc.getIdFuncDoGrid(this);

            if (checar && (usuario != id_funcGrid))
            {
                CrudFunc crudfunc = new CrudFunc(inicio);
                crudfunc.deletarUsuario(linha, dataGridView1);
                crudfunc.Deletar(linha, dataGridView1);
            }
            else if (usuario == id_funcGrid)
            {
                MessageBox.Show("Não é possível deletar um funcionário logado", "Mensagem", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 4
0
        //btnEditar
        private void button1_Click_1(object sender, EventArgs e)
        {
            ValidacaoGeral validacaoGeral = new ValidacaoGeral();
            bool           checar1        = validacaoGeral.checarCamposVazios(this);
            bool           checar2        = validacaoGeral.contaCpf(this);
            bool           checar3        = validacaoGeral.contaRg(this);
            bool           checar4        = validacaoGeral.contaEmail(this);
            bool           checar5        = validacaoGeral.contarCamposCpf(txtCpf);
            bool           checar6        = validacaoGeral.contarCamposRg(txtRg);
            bool           checar7        = validacaoGeral.validaTelefone(txtTelRes1, txtTelRes2,
                                                                          txtTelCel1, txtTelCel2);
            bool checar8 = validacaoGeral.validaData(txtDataNasc);

            txtSal.Text = txtSal.Text.Replace(',', '.');
            bool checar9 = validacaoGeral.validaSalario(txtSal);


            if (checar1 && checar2 && checar3 && checar4 && checar5 && checar6 && checar7 && checar8 &&
                checar9)
            {
                CrudFunc crudfunc = new CrudFunc(this, inicio);

                crudfunc.editar(linha, dataGrid, txtNome, txtCpf, txtRg, txtDataNasc, txtTelRes1, txtTelRes2, txtTelCel1, txtTelCel2,
                                txtEmail, txtCargo, txtSal, txtEnd);
            }
            else
            {
                if (!checar1)
                {
                    MessageBox.Show("Campo(s) vazio(s)", "Mensagem", MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                }
                else
                {
                    if (!checar2)
                    {
                        MessageBox.Show("Esse CPF já está cadastrado", "Mensagem", MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                    if (!checar3)
                    {
                        MessageBox.Show("Esse RG já está cadastrado", "Mensagem", MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                    if (!checar4)
                    {
                        MessageBox.Show("Esse E-mail já está cadastrado", "Mensagem", MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                    if (!checar5)
                    {
                        MessageBox.Show("Preencha corretamente seu CPF", "Mensagem", MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                    if (!checar6)
                    {
                        MessageBox.Show("Preencha corretamente seu RG", "Mensagem", MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                    if (!checar7)
                    {
                        MessageBox.Show("Você deve registrar pelo menos 1 telefone completo", "Mensagem", MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                    if (!checar8)
                    {
                        MessageBox.Show("Data de nascimento inválida. Você deve ser maior de 18 anos",
                                        "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    if (!checar9)
                    {
                        MessageBox.Show("Caracteres inválidos no campo 'Salário'", "Mensagem",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Exemplo n.º 5
0
        //btnSalvar
        private void button1_Click(object sender, EventArgs e)
        {
            ValidacaoGeral validacaoGeral = new ValidacaoGeral();
            bool           checar1        = validacaoGeral.checarCamposVazios(this);
            bool           checar2        = validacaoGeral.validaCpf(this);
            bool           checar3        = validacaoGeral.validaRg(this);
            bool           checar4        = validacaoGeral.validaEmail(this);
            bool           checar5        = validacaoGeral.contarCamposCpf(txtCpf);
            bool           checar6        = validacaoGeral.contarCamposRg(txtRg);
            bool           checar7        = validacaoGeral.validaTelefone(txtTelRes1, txtTelRes2,
                                                                          txtTelCel1, txtTelCel2);
            bool checar8 = validacaoGeral.validaData(txtDataNasc);

            txtSal.Text = txtSal.Text.Replace(',', '.');
            bool checar9  = validacaoGeral.validaSalario(txtSal);
            bool checar10 = validacaoGeral.checaEmail(this);

            if (checar1 && checar2 && checar3 && checar4 && checar5 && checar6 && checar7 && checar8 &&
                checar9 && checar10)
            {
                CrudFunc crudfunc = new CrudFunc(menuStrip, inicio);

                bool valCad = crudfunc.cadastrar(txtNome, txtCpf, txtRg, txtDataNasc, txtTelRes1, txtTelRes2, txtTelCel1, txtTelCel2,
                                                 txtEmail, txtCargo, txtSal, txtEnd);
                if (valCad)
                {
                    crudfunc.ultimoIdCadastro = crudfunc.guardaIdCadastro(this.txtNome.Text, this.txtEmail.Text);

                    if (menuStrip)
                    {
                        this.Dispose();
                        CadUsuario user = new CadUsuario(crudfunc.ultimoIdCadastro, menuStrip, usuario, inicio);
                        user.MdiParent = inicio;
                        user.Show();
                    }
                    else if (cadFuncLogin == "Login")
                    {
                        this.Dispose();
                        CadUsuario user = new CadUsuario(crudfunc.ultimoIdCadastro, inicio);
                        user.Visible = true;
                    }
                    else if (verFuncionario == "verFuncionarios")
                    {
                        this.Dispose();
                        CadUsuario user = new CadUsuario(crudfunc.ultimoIdCadastro, "verFuncionarios", usuario,
                                                         inicio);
                        user.MdiParent = inicio;
                        user.Show();
                    }
                }
            }
            else
            {
                if (!checar1)
                {
                    MessageBox.Show("Campo(s) vazio(s)", "Mensagem", MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                }
                else
                {
                    if (!checar2)
                    {
                        MessageBox.Show("Esse CPF já está cadastrado", "Mensagem", MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                    if (!checar3)
                    {
                        MessageBox.Show("Esse RG já está cadastrado", "Mensagem", MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                    if (!checar4)
                    {
                        MessageBox.Show("Esse E-mail está incorreto", "Mensagem", MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                    if (!checar5)
                    {
                        MessageBox.Show("Preencha corretamente seu CPF", "Mensagem", MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                    if (!checar6)
                    {
                        MessageBox.Show("Preencha corretamente seu RG", "Mensagem", MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                    if (!checar7)
                    {
                        MessageBox.Show("Você deve registrar pelo menos 1 telefone completo", "Mensagem", MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                    }
                    if (!checar8)
                    {
                        MessageBox.Show("Data de nascimento inválida. Você deve ser maior de 18 anos",
                                        "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    if (!checar9)
                    {
                        MessageBox.Show("Caracteres inválidos no campo 'Salário'", "Mensagem",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    if (!checar10)
                    {
                        MessageBox.Show("Esse e-mail já está cadastrado, escolha outro", "Mensagem",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void button5_Click(object sender, EventArgs e)
        {
            CrudFunc crudfunc = new CrudFunc(inicio);

            crudfunc.exibir(dataGridView1);
        }