private void btnDelete_Click(object sender, EventArgs e) { try { //checking that logged in user is no an admin if (sessions.userType != "A") { frmAuthenticate myA = new frmAuthenticate(); DialogResult access = myA.ShowDialog(); if (access == DialogResult.OK) { manageUsers myU = new manageUsers(); if (myU.adminAuth(myA.userName, myA.password) == true) { bzlTransactions myTrans = new bzlTransactions(); myTrans.tranId = this.txtRefNumber.Text; myTrans.accountId = this.txtEnrolId.Text; myTrans.DeleteTransacation(); if (myTrans.dacCrud == true) { this.txtTranDetails.Text = ""; this.txtAmount.Text = ""; manageControl myC = new manageControl(); managefeesBalance myFb = new managefeesBalance(); myFb.getBalance(this.txtEnrolId.Text, sessions.currTerm); this.refNumber = myC.useTranHeader(this.refNumber); this.txtRefNumber.Text = "ref" + this.refNumber.ToString(); this.txtCurBalance.Text = myFb.CurrentBal.ToString(); this.txtOpenBal.Text = myFb.OpenBal.ToString(); this.txtPaid.Text = myFb.PaymentIn.ToString(); this.fillTrans(Convert.ToInt32(this.txtEnrolId.Text)); MessageBox.Show("transaction deleted success", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Failed to delete transaction", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("Invalid Adimin Credentials", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } else { DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this transaction", "Confirm Option", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.OK) { bzlTransactions myTrans = new bzlTransactions(); myTrans.tranId = this.txtRefNumber.Text; myTrans.DeleteTransacation(); myTrans.accountId = this.txtEnrolId.Text; if (myTrans.dacCrud == true) { MessageBox.Show("transaction deleted success", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Failed to delete transaction", "System Notification", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Failed to fillTrans() " + ex); } }
private void btnProcess_Click(object sender, EventArgs e) { try { var enId = this.txtEnrolId.Text; Double amount; var tranId = this.txtRefNumber.Text; var tranDate = this.txtTranDate.Value.ToShortDateString(); var details = this.txtTranDetails.Text; var payMethod = this.cmbPayTyp.Text; if (enId == "" || this.txtFname.Text == "") { MessageBox.Show("enrollment id invalid", "Input error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.txtEnrolId.Focus(); } else if (Double.TryParse(this.txtAmount.Text, out amount) == false) { MessageBox.Show("enrollment transaction amount", "Input error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.txtAmount.Focus(); } else if (payMethod == "") { MessageBox.Show("select payment method", "Input error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.txtAmount.Focus(); } else { bzlTransactions myTran = new bzlTransactions(); myTran.accountId = enId; myTran.transAmount = amount; myTran.tranId = tranId; myTran.tranDate = tranDate; myTran.tranDetails = details; myTran.tranType = "F"; myTran.payMethod = payMethod; myTran.adminId = sessions.userId; myTran.term = sessions.currTerm; myTran.period = sessions.curPeriod; myTran.payFees(); if (myTran.dacCrud == true) { manageControl myC = new manageControl(); managefeesBalance myFb = new managefeesBalance(); myFb.getBalance(enId, sessions.currTerm); this.refNumber = myC.useTranHeader(this.refNumber); this.txtRefNumber.Text = "ref" + this.refNumber.ToString(); this.txtCurBalance.Text = myFb.CurrentBal.ToString(); this.txtOpenBal.Text = myFb.OpenBal.ToString(); this.txtPaid.Text = myFb.PaymentIn.ToString(); this.fillTrans(Convert.ToInt32(enId)); // invoiceParams.Add(this.txtFname.Text + " "+this.txtLastName.Text); MessageBox.Show("transaction processing complete", "system notfication", MessageBoxButtons.OK, MessageBoxIcon.Information); this.printInvoice(); } else { MessageBox.Show("failed to process transaction", "system notfication", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } catch (Exception ex) { MessageBox.Show("failed in btnProcess_Click() " + ex, "system error"); } }