Exemplo n.º 1
0
        private void deleteWithdrawalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DeleteWithdrawal deleteWithdrawal = new DeleteWithdrawal(userId);

            deleteWithdrawal.MdiParent = this;
            deleteWithdrawal.Show();
        }
Exemplo n.º 2
0
        private void ExecuteDeleteOps(string savingsID)
        {
            SqlConnection conn = ConnectDB.GetConnection();

            try
            {
                conn.Open();
                SqlTransaction sqlTrans = conn.BeginTransaction();

                SqlCommand cmd = conn.CreateCommand();
                cmd.Transaction = sqlTrans;

                string strQuery1 = "Delete from SavingsWithdrawal where savingsID='" + savingsID + "'";
                string strQuery2 = "Delete from Savings where savingsID='" + savingsID + "'";

                cmd.CommandType = CommandType.Text;
                cmd.CommandText = strQuery1;

                int rowAffected = cmd.ExecuteNonQuery();

                if (rowAffected > 0)
                {
                    cmd.CommandText = strQuery2;
                    rowAffected     = cmd.ExecuteNonQuery();
                    if (rowAffected > 0)
                    {
                        sqlTrans.Commit();
                        MessageBox.Show("The Selected Record has been deleted.", "Withdrawal", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        string logMessage = "Withdrawal Record DELETED with Savings ID: " + savingsID + ", Savings Type: " + savingsType + ", Amount: " + withdrawalAmt;
                        ActivityLog.logActivity(UserId, "Withdrawal", logMessage);

                        DeleteWithdrawal deleteWithdrawal = new DeleteWithdrawal(UserId);
                        deleteWithdrawal.MdiParent = this.ParentForm;
                        deleteWithdrawal.Show();
                        this.Close();
                    }
                    else
                    {
                        sqlTrans.Rollback();
                        MessageBox.Show("An error occurred! Operation has been aborted.", "Withdrawal", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    sqlTrans.Rollback();
                    MessageBox.Show("An error occurred! Operation has been aborted.", "Withdrawal", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
        }