示例#1
0
        private void deleteDeductionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UnpostDeductions unpostDeductions = new UnpostDeductions(userId);

            unpostDeductions.MdiParent = this;
            unpostDeductions.Show();
        }
示例#2
0
        private void btnSingleUnpost_Click(object sender, EventArgs e)
        {
            int memberID;

            if (dtGrdSingleDeductions.SelectedRows.Count > 0)
            {
                selDeductionId      = Convert.ToInt16(dtGrdSingleDeductions.SelectedRows[0].Cells[0].Value.ToString());
                selDelMonth         = dtGrdSingleDeductions.SelectedRows[0].Cells[1].Value.ToString();
                selDelYear          = Convert.ToInt16(dtGrdSingleDeductions.SelectedRows[0].Cells[2].Value.ToString());
                memberID            = Convert.ToInt16(dtGrdSingleDeductions.SelectedRows[0].Cells[3].Value.ToString());
                selDedTransactionId = dtGrdSingleDeductions.SelectedRows[0].Cells[8].Value.ToString();

                //MessageBox.Show("ID: " + selDeductionId.ToString() + "Month: " + selDelMonth.ToString() + " Year: " + selDelYear.ToString() + "MemberID: " + memberID.ToString() + "TransactionID: " + selDedTransactionId);
            }
            else
            {
                MessageBox.Show("Choose a Member Deduction Record to Delete", "Unpost Deduction", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            DialogResult res = MessageBox.Show("Do you wish to Unpost the Selected Record?", "Unpost", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                SqlConnection conn = ConnectDB.GetConnection();
                SqlCommand    cmd  = conn.CreateCommand();


                try
                {
                    conn.Open();
                    SqlTransaction sqlTrans = conn.BeginTransaction();
                    cmd.CommandType = CommandType.Text;
                    cmd.Transaction = sqlTrans;

                    Cl_UnpostDeductions deletePosting = new Cl_UnpostDeductions();
                    string savingsDelStatus           = deletePosting.unpostSavingsDeductions(conn, cmd, memberID, selDedTransactionId);
                    string loanDelStatus             = deletePosting.unpostLoansDeduction(conn, cmd, memberID, selDedTransactionId);
                    string deductionDelStatus        = deletePosting.unpostDeductions(conn, cmd, memberID, selDedTransactionId, selDelMonth, selDelYear);
                    string deductionDetailsDelStatus = deletePosting.unpostDeductionDetails(conn, cmd, memberID, selDedTransactionId);

                    //MessageBox.Show("Savings Status: " + savingsDelStatus + "\nLoans Status: " + loanDelStatus + "\nDeductions: " + deductionDelStatus + "\nDeduction Detials: " + deductionDetailsDelStatus);

                    if ((Convert.ToInt16(savingsDelStatus) != 0) || (Convert.ToInt16(deductionDetailsDelStatus) != 0) || (Convert.ToInt16(deductionDelStatus) != 0))
                    {
                        sqlTrans.Commit();
                        ActivityLog.logActivity(UserId, "Unpost Deduction - Single", "Unpost Deduction for MemberID:" + memberID + " for " + selDelMonth + " " + selDelYear);
                        MessageBox.Show("Selected record has been Successfully Deleted.", "Unpost Deduction", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        UnpostDeductions unpostDeductions = new UnpostDeductions(UserId);
                        unpostDeductions.MdiParent = this.ParentForm;
                        unpostDeductions.Show();
                        this.Close();
                    }
                    else
                    {
                        sqlTrans.Rollback();
                        MessageBox.Show("An error has occurred.", "Unpost Deduction", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    conn.Close();
                }
            }
        }
示例#3
0
        private void btnBulkUnpost_Click(object sender, EventArgs e)
        {
            if (dtGrdBulkDeductions.SelectedRows.Count > 0)
            {
                selDeductionId = Convert.ToInt16(dtGrdBulkDeductions.SelectedRows[0].Cells[0].Value.ToString());
                selDelMonth    = dtGrdBulkDeductions.SelectedRows[0].Cells[1].Value.ToString();
                selDelYear     = Convert.ToInt16(dtGrdBulkDeductions.SelectedRows[0].Cells[2].Value.ToString());
                //MessageBox.Show("ID: " + selDeductionId.ToString() + "Month: " + selDelMonth.ToString() + " Year: " + selDelYear.ToString());
            }
            else
            {
                MessageBox.Show("Choose a Deduction Record to Delete", "Unpost Deduction", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            DialogResult res = MessageBox.Show("Do you wish to Unpost the Selected Deduction?", "Unpost Deduction", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                SqlConnection conn = ConnectDB.GetConnection();
                SqlCommand    cmd;


                try
                {
                    conn.Open();
                    SqlTransaction sqlTrans = conn.BeginTransaction();
                    cmd             = conn.CreateCommand();
                    cmd.CommandType = CommandType.Text;
                    cmd.Transaction = sqlTrans;
                    cmd.CommandText = "Select distinct d.TransactionID from Deductions d " +
                                      "inner join MonthByName m on m.MonthID=d.Month " +
                                      "where m.month='" + selDelMonth + "' And d.Year=" + selDelYear;

                    SqlDataReader reader = cmd.ExecuteReader();
                    selDeductionTransactionDel.Clear();
                    while (reader.Read())
                    {
                        selDeductionTransactionDel.Add(reader["TransactionID"].ToString());
                    }
                    reader.Close();

                    //MessageBox.Show(selDeductionTransactionDel.Count.ToString());

                    Cl_UnpostDeductions deletePosting = new Cl_UnpostDeductions();
                    string savingsDelStatus           = deletePosting.unpostSavingsDeductions(conn, cmd, selDeductionTransactionDel);
                    string loanDelStatus             = deletePosting.unpostLoansDeduction(conn, cmd, selDeductionTransactionDel);
                    string deductionDelStatus        = deletePosting.unpostDeductions(conn, cmd, selDeductionTransactionDel, selDelMonth, selDelYear);
                    string deductionDetailsDelStatus = deletePosting.unpostDeductionDetails(conn, cmd, selDeductionTransactionDel);
                    string deductionDatesDelStatus   = deletePosting.unpostDeductionDates(conn, cmd, selDelMonth, selDelYear);

                    //MessageBox.Show("Savings Status: " + savingsDelStatus + "\nLoans Status: " + loanDelStatus + "\nDeductions: " + deductionDelStatus + "\nDeduction Detials: " + deductionDetailsDelStatus);

                    if ((Convert.ToInt16(deductionDelStatus) != 0) && (Convert.ToInt16(deductionDetailsDelStatus) != 0) && (Convert.ToInt16(deductionDelStatus) != 0))
                    {
                        sqlTrans.Commit();
                        ActivityLog.logActivity(UserId, "Unpost Deduction - Bulk", "Unpost Deduction Record ID:" + selDeductionId + " for " + selDelMonth + " " + selDelYear);
                        MessageBox.Show("Selected record has been Successfully Deleted.", "Unpost Deduction", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        UnpostDeductions unpostDeductions = new UnpostDeductions(UserId);
                        unpostDeductions.MdiParent = this.ParentForm;
                        unpostDeductions.Show();
                        this.Close();
                    }
                    else
                    {
                        sqlTrans.Rollback();
                        MessageBox.Show("An error has occurred.", "Unpost Deduction", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    conn.Close();
                }
            }
        }