Exemplo n.º 1
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (txtDelete.Text.Trim() == "")
            {
                MessageBox.Show("Please type the required string !", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (txtDelete.Text != "DELETE MY ACCOUNT")
            {
                MessageBox.Show("Confirmation string is wrong ! Remember to use capslock. ", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (txtDelete.Text == "DELETE MY ACCOUNT")
            {
                try
                {
                    using (var transdao = new TransactionDAO())
                    {
                        transdao.DeleteAllTransactionsByID(user.ID);
                    }
                    using (var userdao = new UserDAO())
                    {
                        userdao.Delete(user);
                    }

                    MessageBox.Show("Account Deleted !", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Boolean = true;
                    this.Close();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }