Esempio n. 1
0
        public void carregaDataGrid()
        {
            Clfuncionario ObjAgenda = new Clfuncionario();

            dgvDadosFuncionario.DataSource            = ObjAgenda.Listar(txtdescricao.Text).Tables[0];
            dgvDadosFuncionario.Columns[0].HeaderText = ("Cod");
            dgvDadosFuncionario.Columns[1].HeaderText = ("Funcionario");
            dgvDadosFuncionario.Columns[2].HeaderText = ("Telefone");

            dgvDadosFuncionario.AutoResizeColumns();

            if (dgvDadosFuncionario.RowCount == 0)
            {
                btnconsultar.Enabled = false;
                btnalterar.Enabled   = false;
                btnpesquisar.Enabled = false;
                btnexcluir.Enabled   = false;
                MessageBox.Show("Não foram encontrado daos com a informação" + txtdescricao.Text, "VERIFICAR",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                dgvDadosFuncionario.DataSource = null;
                txtdescricao.Text = "";
                txtdescricao.Focus();
            }
            else
            {
                btnconsultar.Enabled = true;
                btnalterar.Enabled   = true;
                btnexcluir.Enabled   = true;
            }
        }
Esempio n. 2
0
        private void btnexcluir_Click(object sender, EventArgs e)
        {
            int msg;

            msg = Convert.ToInt32(MessageBox.Show("DESEJA EXCLUIR O REGISTRO?" +
                                                  Convert.ToString(dgvDadosFuncionario.CurrentRow.Cells[1].Value),
                                                  "E X C L U S Ã O", MessageBoxButtons.YesNo, MessageBoxIcon.Information));

            if (msg == 6)
            {
                Clfuncionario objAgenda = new Clfuncionario();
                objAgenda.CodFuncionario = Convert.ToInt32(dgvDadosFuncionario.CurrentRow.Cells[0].Value);
                objAgenda.ExcluirLogicamente();

                MessageBox.Show("Registro Excluído com Sucesso", " E X C L U S Ã O ",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            else
            {
                MessageBox.Show("OPERAÇÃO CANCELADA", "CANCELAMENTO E X C L U S Ã O ",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            carregarDataGrid();
        }
Esempio n. 3
0
        private void btnsalvar_Click(object sender, EventArgs e)
        {
            maskedcpf.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
            if (maskedcpf.Text == "")
            {
                MessageBox.Show("Informe um CPF!", "CPF", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (Validacoes.validarCPF(maskedcpf.Text))
                {
                    maskedcpf.TextMaskFormat = MaskFormat.IncludePromptAndLiterals;
                    try
                    {
                        if ((txtnome.Text == "") || (maskedtel.Text == "") || (txtn.Text == "") ||
                            (maskedcpf.Text == ""))
                        {
                            MessageBox.Show("Os campos com * são de preenchimento obrigatórios");
                        }
                        else
                        {
                            Clfuncionario funcionario = new Clfuncionario();
                            if (txtcod_funcionario.Text != "")
                            {
                                funcionario.CodFuncionario = Convert.ToInt32(txtcod_funcionario.Text);
                            }

                            funcionario.Nome        = txtnome.Text;
                            funcionario.DtNasc      = maskeddt_nasc.Text;
                            funcionario.Sexo        = combosexo.Text;
                            funcionario.CPF         = maskedcpf.Text.Replace(",", "-");
                            funcionario.RG          = maskedrg.Text;
                            funcionario.Logradouro  = txtlogradouro.Text;
                            funcionario.NumResid    = txtn.Text;
                            funcionario.Complemento = txtcomplemento.Text;
                            funcionario.CEP         = maskedcep.Text.Replace("-", "");
                            funcionario.Bairro      = txtbairro.Text;
                            funcionario.Cidade      = txtcidade.Text;
                            funcionario.UF          = txtuf.Text;
                            funcionario.Telefone    = maskedtel.Text.Replace("()", "-");
                            funcionario.Celular     = maskedcel.Text.Replace("()", "-");
                            funcionario.Email       = txtemail.Text;
                            funcionario.Cargo       = txtcargo.Text;

                            if (ObjOperacao == clnFuncoesGerais.Operacao.Inclusao)
                            {
                                funcionario.Gravar();
                                MessageBox.Show("Dados gravados com sucesso!!", "Item Novo " + txtnome.Text,
                                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else if (ObjOperacao == clnFuncoesGerais.Operacao.Alteracao)
                            {
                                funcionario.Alterar();
                                MessageBox.Show("Registro nº " + txtcod_funcionario.Text + "Alterado com sucesso",
                                                "Alteração", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Erro ao inserir Cliente\n" + ex.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Informe um CPF válido!", "CPF", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }