private void BtnExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvDados.SelectedRows.Count == 0)
                {
                    MessageBox.Show("Nenhum registro selecionado!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    DialogResult d = MessageBox.Show("Deseja excluir o Registro?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (d.ToString() == "Yes")
                    {
                        DALConexao cx  = new DALConexao(DadosDaConexao.StringDeConexao);
                        BLLUsuario bll = new BLLUsuario(cx);
                        bll.Excluir(Convert.ToInt32(dgvDados.CurrentRow.Cells[0].Value));
                        MessageBox.Show("Registro excluído com sucesso!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        if (chbPesqAtivos.Checked == true)
                        {
                            lbAtencao.Visible         = false;
                            dgvDados.DataSource       = bll.LocalizarAtivos(txtPesquisar.Text);
                            chbPesqAtivos.ForeColor   = Color.Black;
                            chbPesqInativos.ForeColor = Color.Black;
                        }
                        else if (chbPesqInativos.Checked == true)
                        {
                            lbAtencao.Visible         = false;
                            dgvDados.DataSource       = bll.LocalizarInativos(txtPesquisar.Text);
                            chbPesqAtivos.ForeColor   = Color.Black;
                            chbPesqInativos.ForeColor = Color.Black;
                        }

                        if (chbPesqAtivos.Checked == true && chbPesqInativos.Checked == true)
                        {
                            lbAtencao.Visible         = false;
                            dgvDados.DataSource       = bll.carregaGrid();
                            chbPesqAtivos.ForeColor   = Color.Black;
                            chbPesqInativos.ForeColor = Color.Black;
                        }
                        else if (chbPesqAtivos.Checked == false && chbPesqInativos.Checked == false)
                        {
                            lbAtencao.Visible         = true;
                            chbPesqAtivos.ForeColor   = Color.Red;
                            chbPesqInativos.ForeColor = Color.Red;
                            ((DataTable)dgvDados.DataSource).Rows.Clear();
                        }
                        dgvDados.ClearSelection();
                    }
                }
            }
            catch
            { MessageBox.Show("Impossivel excluir o registro. \n O registro esta sendo usado em outro local"); }
        }
Esempio n. 2
0
 //-------------------------------------------------------------------------------------------------------------------
 private void btExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult d = MessageBox.Show("Deseja excluir o registro?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (d.ToString() == "Yes")
         {
             BLLUsuario bll = new BLLUsuario();
             bll.Excluir(Convert.ToInt32(txtCodigo.Text));
             this.limpaTela();
             this.alteraBotoes(1);
         }
     }
     catch (Exception erro)
     {
         MessageBox.Show("Impossível excluir o registro. \n O registro esta sendo utilizado em outro local.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.alteraBotoes(3);
     }
 }
Esempio n. 3
0
 private void btExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult resultado = MessageBox.Show("Deseja realmente EXCLUIR o registro selecionado ?", "CONFIRMA EXCLUSÃO DE REGISTRO", MessageBoxButtons.YesNo);
         if (resultado.ToString() == "Yes")
         {
             DaoConexao cx  = new DaoConexao(DadosDeConexao.StringDeConexao);
             BLLUsuario bll = new BLLUsuario(cx);
             bll.Excluir(Convert.ToInt32(txtCodigo.Text));
             this.LimpaTela();
             this.alteraBotoes(1);
             MessageBox.Show("Registro exclído com sucesso !!", "SUCESSO NA EXCLUSÃO DE REGISTRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception erro)
     {
         MessageBox.Show("Impossível excluir o registro. \n O registro esta sendo vinculado em outra tabela!!!\n\n Contate o Admistrador do Sistema!!!\n\nErro Ocorrido:" + erro.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Esempio n. 4
0
 private void btExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult d = MessageBox.Show("Deseja excluir o registro?", "Aviso", MessageBoxButtons.YesNo);
         if (d.ToString() == "Yes")
         {
             DAOConexao cx  = new DAOConexao(DAOBanco.StringDeConexao);
             BLLUsuario bll = new BLLUsuario(cx);
             bll.Excluir(Convert.ToInt32(txtCodigo.Text));
             this.LimpaTela();
             this.alteraBotoes(1);
         }
     }
     catch
     {
         MessageBox.Show("Impossível excluir o registro. \n O registro está sendo utilizado em outro local.");
         this.alteraBotoes(3);
     }
 }
Esempio n. 5
0
 private void btExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult d = MessageBox.Show("DESEJA EXCLUIR O REGISTRO?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (d.ToString() == "Yes")
         {
             DALConexao cx  = new DALConexao(DadosDaConexao.StringDeConexao);
             BLLUsuario bll = new BLLUsuario(cx);
             bll.Excluir(Convert.ToInt32(txtCodigo.Text));
             LimpaTela();
             alterarBotoes(1, perInserir, perAlterar, perExcluir, perImprimir);
         }
     }
     catch (Exception erro)
     {
         MessageBox.Show("IMPOSSIVEL EXCLUIR O RESGISTRO ! \n O REGISTRO PODE ESTÁ VINCULADO EM OUTRAS TABELAS!\nERRO OCORRIDO:" +
                         erro.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
 private void btExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult d = MessageBox.Show("Deseja realmente excluir o usuário - " + txtNome.Text + "?", "Aviso", MessageBoxButtons.YesNo);
         if (d.ToString() == "Yes")
         {
             DALConexao cx  = new DALConexao(DadosDaConexao.StringDaConexao);
             BLLUsuario bll = new BLLUsuario(cx);
             bll.Excluir(Convert.ToInt32(txtIdUsuario.Text));
             this.LimpaCampos();
             this.alteraBotoes(1);
         }
     }
     catch
     {
         MessageBox.Show("Impossível excluir o registro. \n O registro está sendo utilizado em outro local.");
         this.alteraBotoes(3);
     }
 }
Esempio n. 7
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            DialogResult d = MessageBox.Show("Deseja realmente excluir o registro? ", "Aviso", MessageBoxButtons.YesNo);

            if (d.ToString() == "Yes")
            {
                try
                {
                    DALConexao cx  = new DALConexao(DadosDaConexao.StringDeConexão);
                    BLLUsuario bll = new BLLUsuario(cx);
                    bll.Excluir(Convert.ToInt32(txtCodigo.Text));
                    LimpaTela();
                    alteraBotoes();
                    txtNome.Focus();
                    Mensagem("USUÁRIO EXCLUIDO ", Color.Blue);
                }
                catch (Exception erro)
                {
                    Erro("ERRO AO EXCLUIR O USUÁRIO " + erro.Message);
                    alteraBotoes();
                }
            }
        }