コード例 #1
0
 private void btnDesativarTel_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvTelefone.Rows.Count > 0)
         {
             if (MessageBox.Show("Deseja realmente excluir o registro selecionado?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                 == DialogResult.Yes)
             {
                 Telefone telefone = telefonedata.obterTelefone(Convert.ToInt32(dgvTelefone.CurrentRow.Cells["idTelefone"].Value));
                 telefonedata.excluirTelefone(telefone);
                 carregarGridTelefone();
             }
         }
     }
     catch (NullReferenceException ex)
     {
         MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #2
0
 private void btnRemoverTelefone_Click(object sender, EventArgs e)
 {
     if (dgvTelefone.CurrentRow == null)
     {
         MessageBox.Show("Selecione um telefone para excluir!");
         return;
     }
     if (MessageBox.Show("Tem certeza que deseja excluir?", "Atenção", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         string erro = telefoneData.excluirTelefone((Telefone)dgvTelefone.CurrentRow.DataBoundItem);
         if (erro == null)
         {
             MessageBox.Show("Excluído com sucesso!");
         }
         else
         {
             MessageBox.Show("Ocorreu um erro: " + erro);
         }
         atualizarTelefone();
     }
 }
コード例 #3
0
        private void btnExcluirTelefone_Click(object sender, EventArgs e)
        {
            MessageBoxButtons botoes    = MessageBoxButtons.YesNo;
            DialogResult      resultado = MessageBox.Show("Você realmente deseja excluir este telefone?", "Confirmação de Exclusão", botoes, MessageBoxIcon.Stop);

            if (resultado == DialogResult.Yes)
            {
                if (obterTelefoneDaLista())
                {
                    string retorno = telefoneData.excluirTelefone(telefone);

                    if (retorno == null)
                    {
                        MessageBox.Show("Telefone excluido com sucesso!", "Sucesso");
                        limparFormTelefone();
                        atualizarListaDeTelefones();
                    }
                    else
                    {
                        MessageBox.Show("Erro ao excluir o telefone: " + retorno, "Erro");
                    }
                }
            }
        }