Example #1
0
        //=============================================================================================================
        private void btExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult d = MessageBox.Show("Deseja excluir o registro?", "Aviso", MessageBoxButtons.YesNo);//confirmar antes de excluir
                //caso responder sim...
                if (d.ToString() == "Yes")
                {
                    DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao);//Recebe a string da conexão da classe DadosDaConexão

                    //bll possui o metodo para excluir
                    BLLCliente bll = new BLLCliente(cx);          //passa a string de conexao

                    bll.Excluir(Convert.ToInt32(txtCodigo.Text)); //retorna erro se este codigo ja estiver sendo utilizado como chave em outra tabela

                    this.LimpaTela();
                    this.alteraBotoes(1);

                    MessageBox.Show("Cadastro excluido com sucesso!");
                }
            }
            catch // sem o Exception, qualquer tipo de erro
            {
                MessageBox.Show("Impossível excluir o registro. \n O registro esta sendo utilizado em outro local.");
                this.alteraBotoes(3);
            }
        }
        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);
                        BLLCliente bll = new BLLCliente(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.LocalizarTodos();
                            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"); }
        }
Example #3
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")
         {
             BLLCliente bll = new BLLCliente();
             bll.Excluir(Convert.ToInt32(txtCodigo.Text));
             this.limpaTela();
             this.alteraBotoes(1);
         }
     }
     catch (Exception erro)
     {
         MessageBox.Show("Impossivel excluir o registro. \n O registro está sendo utilizado em outro local", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.alteraBotoes(3);
     }
 }
 private void btExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult d = MessageBox.Show("Deseja excluir o registro?", "Aviso", MessageBoxButtons.YesNo);
         if (d.ToString() == "Yes")
         {
             DALConexao cx  = new DALConexao(DadosDaConexao.StringDeConexao);
             BLLCliente bll = new BLLCliente(cx);
             bll.Excluir(Convert.ToInt32(txtCodigo.Text));
             this.LimpaTela();
             this.alteraBotoes(1);
         }
     }
     catch
     {
         MessageBox.Show("Impossível excluir o registro. \n O registro esta sendo utilizado em outro local.");
         this.alteraBotoes(3);
     }
 }
 private void btExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult d = MessageBox.Show("Deseja excluir o registro?", "Aviso", MessageBoxButtons.YesNo);
         if (d.ToString() == "Yes")
         {
             DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao);
             BLLCliente bll = new BLLCliente(cx);
             bll.Excluir(Convert.ToInt32(txtCodigo.Text));
             this.LimpaTela();
             this.alteraBotoes(1);
         }
     }
     catch
     {
         MessageBox.Show("Impossível excluir o registro. \n O registro esta sendo utilizado em outro local.");
         this.alteraBotoes(3);
     }
 }
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         //Aqui ele executa um diálogo perguntando se o usuário deseja ou não excluir o registro.
         if (MessageBox.Show("Deseja excluir o registro?", "Atenção", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             /*Caso "sim", é aberto a conexão com o banco e executado o método de excluir. */
             //Método de excluir sendo chamado.
             BLLCliente.Excluir(int.Parse(dgvCliente.CurrentRow.Cells[0].Value.ToString()));
             LimpaTela();
         }
     }
     catch
     {
         //Caso apresente algum erro. Será retornado esta mensagem.
         MessageBox.Show("Impossível excluir o registro. \n O registro está sendo utilizado em outro local");
     }
     Alterarbotoes(1);
 }
Example #7
0
        private void btExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult dialogResult = MessageBox.Show("Deseja realmente exlcuir o registro ?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dialogResult.ToString() == "Yes")
                {
                    DALConexao dalConexao = new DALConexao(DadosDaConexao.StringDeConexao);
                    BLLCliente bllCliente = new BLLCliente(dalConexao);
                    bllCliente.Excluir(Convert.ToInt32(txtCodigo.Text));

                    LimpaTela();
                    AlterarBotoes(1);
                }
            }
            catch
            {
                MessageBox.Show("Impossível excluir o registro.\nO registro esta sendo utilizado em outro local.");
                //AlterarBotoes(3);
            }
        }
Example #8
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            DialogResult mensagem = MetroFramework.MetroMessageBox.Show(this, "Deseja excluir realmente ?", "ATENÇÃO", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            try
            {
                if (mensagem.ToString() == "Yes")
                {
                    DALConexao conexao = new DALConexao(DadosDaConexao.StringDeConexao);
                    BLLCliente cliente = new BLLCliente(conexao);
                    cliente.Excluir(Convert.ToInt32(txtCodigo.Text));
                    this.limparTela();
                    this.alterarBotoes(1);
                    MetroFramework.MetroMessageBox.Show(this, "Daletado com sucesso ", "ATENÇAO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MetroFramework.MetroMessageBox.Show(this, "Imppossivel deletar esse registro " + ex.Message, "ATENÇAO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.alterarBotoes(3);
            }
        }
Example #9
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);
                    BLLCliente bll = new BLLCliente(cx);
                    bll.Excluir(Convert.ToInt32(txtCodigo.Text));
                    LimpaTela();
                    alteraBotoes();
                    txtNome.Focus();
                    Mensagem("CLIENTE EXCLUIDO ", Color.Blue);
                }
                catch (Exception erro)
                {
                    Erro("ERRO AO EXCLUIR O CLIENTE " + erro.Message);
                    alteraBotoes();
                }
            }
        }
        private void btExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                //leitura de dados
                DialogResult d = MessageBox.Show("Deseja excluir o cliente?", "Aviso", MessageBoxButtons.YesNo);

                if (d.ToString() == "Yes")
                {
                    // obj para gravar os dados no banco
                    DALConexao cx  = new DALConexao(DadosDaConexao.StringDeConexao);
                    BLLCliente bll = new BLLCliente(cx);
                    bll.Excluir(Convert.ToInt32(txtCodigo.Text));
                    this.limpaTela();
                    this.alteraBotoes(1);
                }
            }
            catch
            {
                MessageBox.Show("Não é possível excluir a categoria! \n A categoria está sendo utilizada em outro local.");
                this.alteraBotoes(3);
            }
        }