Beispiel #1
0
        public string Delete(int id)
        {
            conn.Open();
            var trans = conn.BeginTransaction();

            try
            {
                BairroDao bairroDao = new BairroDao(conn, trans);
                if (bairroDao.GetAsExist(id))
                {
                    bairroDao.Delete(id);

                    trans.Commit();
                    return("Sucesso");
                }
                else
                {
                    return("Erro ao Excluir Bairro, bairro não Encontrado");
                }
            }
            catch (Exception e)
            {
                trans.Rollback();
                throw new Exception(e.Message);
            }
            finally
            {
                conn.Close();
            }
        }
Beispiel #2
0
        private void btnexcluir_Click(object sender, System.EventArgs e)
        {
            if (String.IsNullOrEmpty(txtbaicodi.Text))
            {
                MessageBox.Show("Preencha o código!");
                return;
            }

            if (!edicao)
            {
                MessageBox.Show("Não é possível excluir algo que não existe!");
                return;
            }

            BairroDao.Delete(int.Parse(txtbaicodi.Text));
            this.limpar();
        }