Exemplo n.º 1
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult mensagem = MessageBox.Show("Desaja excluir o registro?", "Aviso", MessageBoxButtons.YesNo);

                if (mensagem.ToString().Equals("Yes"))
                {
                    DALConexao con = new DALConexao(DadosConexao.StringConexao);

                    BLLCategoria c = new BLLCategoria(con);

                    c.Excluir(Convert.ToInt32(txtCodigo.Text));

                    this.LimparCampos();

                    this.AlteraBotoes(1);
                }
            }
            catch
            {
                MessageBox.Show("Erro ao excluir registro");

                this.AlteraBotoes(3);
            }
        }
        //===============================================================================================================================
        private void btExcluir_Click(object sender, EventArgs e) // aula 09
        {
            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
                    BLLCategoria bll = new BLLCategoria(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 btExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult d = MessageBox.Show("Deseja realmente excluir o registro?", "Aviso", MessageBoxButtons.YesNo);
         if (d.ToString() == "Yes")
         {
             DALConexao   cx  = new DALConexao(DadosDaConexao.StringDaConexao);
             BLLCategoria bll = new BLLCategoria(cx);
             bll.Excluir(Convert.ToInt32(txtCodigo.Text));
             this.LimpaTela();
             this.alteraBotoes(1);
         }
     } catch
     {
         MessageBox.Show("Não foi possível realizar a exclusão do registro. \n O registro está sendo utilizado.");
         this.alteraBotoes(3);
     }
 }
Exemplo n.º 4
0
 private void btnExcluir_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);
             BLLCategoria bll = new BLLCategoria(cx);
             bll.Excluir(Convert.ToInt32(txtCodigo.Text));
             this.LimpaTela();
             this.alterarBotoes(1);
         }
     }catch
     {
         MessageBox.Show("Impossível excluir o registro. \n O Registro Está sendo Utilizado em outro Local.");
         this.alterarBotoes(3);
     }
 }
Exemplo n.º 5
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")
         {
             BLLCategoria bll = new BLLCategoria();
             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);
     }
 }
Exemplo n.º 6
0
 //Método do botão excluir (Método criado na camada DAL)
 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.
             BLLCategoria.Excluir(int.Parse(dgvCategoria.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);
     }
 }
Exemplo n.º 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);
                    BLLCategoria _bllCategoria = new BLLCategoria(_dalConexao);
                    _bllCategoria.Excluir(Convert.ToInt32(txtCodigo.Text));
                    this.AlterarBotoes(2);
                    this.LimpaTela();
                }
            }
            catch
            {
                MessageBox.Show("Impossível excluir o registro.\nO registro esta sendo utilizado em outro local.");
                AlterarBotoes(3);
            }
        }
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult d = MessageBox.Show("Deseja excluir a categoria '" + txtDescricao.Text + "'?", "Aviso", MessageBoxButtons.YesNo);
         if (d.ToString() == "Yes")
         {
             DALConexao   cx  = new DALConexao(DadosConexao.StringConexao);
             BLLCategoria bll = new BLLCategoria(cx);
             bll.Excluir(Convert.ToInt32(txtSequencia.Text));
             this.LimpaTela();
             this.alteraBotoes(1);
             this.alteraCampos("False");
         }
     }
     catch
     {
         MessageBox.Show("Impossível excluir o registro. \n O registro está sendo utilizado em outro local.");
         this.alteraBotoes(3);
     }
 }
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult resultado = MetroFramework.MetroMessageBox.Show(this, "Deseja excluir o registro? ", "AVISO", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
         if (resultado.ToString() == "Yes")
         {
             DALConexao   conexao   = new DALConexao(DadosDaConexao.StringDeConexao);
             BLLCategoria categoria = new BLLCategoria(conexao);
             categoria.Excluir(Convert.ToInt32(txtCodigo.Text));
             this.limparTela();
             this.alterarBotoes(1);
             MetroFramework.MetroMessageBox.Show(this, "Excluido com sucesso! ", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MetroFramework.MetroMessageBox.Show(this, "Impossivel excluir o registro. \n O resistro esta sendo utilizado em outro local " + ex.Message, "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.alterarBotoes(3);
     }
 }
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult d = MessageBox.Show("Deseja excluir o registro?", "Aviso", MessageBoxButtons.YesNo);
         //chamado 3: usuário reclamou que não estava excluindo o cadastro, o erro ocorreu porque no if de validação da exlusão estava
         //"SIM" e não "YES" e a palavra em português não era reconhecida.
         if (d.ToString() == "Yes")
         {
             DALConexao   cx  = new DALConexao(DadosDaConexao.StringDeConexao);
             BLLCategoria bll = new BLLCategoria(cx);
             bll.Excluir(Convert.ToInt32(txtCodigo.Text));
             this.LimpaTela();
             this.AlteraBotoes(1);
         }
     }
     catch
     {
         MessageBox.Show("Impossível excluir esse registro. \nO registro está sendo utilizado em outro local.");
         this.AlteraBotoes(3);
     }
 }
Exemplo n.º 11
0
        private void btnExcluirCategoria_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Você tem certeza que deseja remover esse item?", "Remover item", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                DALConexao   cx  = new DALConexao(DadosdaConexao.StringDeConexao);
                BLLCategoria bll = new BLLCategoria(cx);
                bll.Excluir(Convert.ToInt32(codigo));

                MessageBox.Show("Categoria excluida com sucesso!");

                inputInserirCategoria.Text   = String.Empty;
                gridViewCategoria.DataSource = bll.Localizar(inputInserirCategoria.Text);

                btnSalvarCategoria.Visible  = false;
                btnExcluirCategoria.Visible = false;
                btnInserirCategoria.Visible = true;
            }
            else
            {
                MessageBox.Show("Item não removido", "Remover item", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 12
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);
                    BLLCategoria bll = new BLLCategoria(cx);
                    bll.Excluir(Convert.ToInt32(txtCodigo.Text));
                    Mensagem("CATEGORIA EXCLUIDA ", Color.Blue);
                }
                catch (SqlException)
                {
                    Erro("ERRO AO EXCLUIR A CATEGORIA POIS ESTA SENDO UTILIZADA EM OUTRO REGISTRO ");
                }
                LimpaTela();
                alteraBotoes();
                txtNome.Focus();
            }
        }
Exemplo n.º 13
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")
                {
                    //Objeto para grvar os dado no banco de dados
                    DALConexao   cx  = new DALConexao(DadosDaConexao.StringDeConexao);
                    BLLCategoria bll = new BLLCategoria(cx);

                    bll.Excluir(Convert.ToInt32(txtCodigo.Text));
                    this.LimpaTela();
                    this.alteraBotes(1);
                }
            }
            catch
            {
                MessageBox.Show("Impossivél excluir o registro.  \n o registro esta sendo utilizado em outro local");
                this.alteraBotes(3);
            }
        }
Exemplo n.º 14
0
        private void btExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                //leitura de dados
                DialogResult d = MessageBox.Show("Deseja excluir a categoria?", "Aviso", MessageBoxButtons.YesNo);

                if (d.ToString() == "Yes")
                {
                    // obj para gravar os dados no banco
                    DALConexao   cx  = new DALConexao(DadosDaConexao.StringDeConexao);
                    BLLCategoria bll = new BLLCategoria(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);
            }
        }
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult d = MessageBox.Show("Deseja Excluir o registro?", "Aviso", MessageBoxButtons.YesNo);
                if (d.ToString() == "Yes")
                {
                    //obj para gravar os dados no banco
                    DALConexao   cnx          = new DALConexao(DadosDaConexao.StringDeConexao);
                    BLLCategoria bllCategoria = new BLLCategoria(cnx);

                    bllCategoria.Excluir(Convert.ToInt32(txtCodigo.Text));
                    MessageBox.Show("Cadastro excluido");
                    this.LimpaTela();
                    this.alteraBotoes(1);
                }
            }
            catch
            {
                MessageBox.Show("Impossivel excluir o registro.\n O registro esta sendo utilizado em outro local.");
                this.alteraBotoes(3);
            }
        }