private void btnSave_Click(object sender, EventArgs e) { if (lvDataEntryOP.Items.Count > 0) { double total = double.Parse(lbTotal.Text); if (total > 0 && (!string.IsNullOrEmpty(tbFirstname.Text) && !string.IsNullOrEmpty(tbLastname.Text))) { OrderOfPayment OP = null; StudentAccount SAccount = new StudentAccount(); Dictionary <string, float> amountPerParticular = SAccount.getAmountPerParticular(lvDataEntryOP, 2); string payor = tbFirstname.Text.Replace("'", "''") + " " + tbMiddlename.Text + " " + tbLastname.Text; int orderOfPaymentType = 0; try { orderOfPaymentType = int.Parse((mrbUndergrad.Checked) ? mrbUndergrad.Tag.ToString() : (mrbMasteral.Checked) ? mrbMasteral.Tag.ToString() : (mrbFiduciary.Checked) ? mrbFiduciary.Tag.ToString() : (mrbBtr.Checked) ? mrbBtr.Tag.ToString() : (mrbIGD.Checked) ? mrbIGD.Tag.ToString() : "0"); paymentType = (mtrbCash.Checked) ? mtrbCash.Tag.ToString() : (mtrbCheck.Checked) ? mtrbCheck.Tag.ToString() : "0"; } catch (Exception ex) { MessageBox.Show(ex.Message); } // check payment type // check if has student ID int studentID = 0; if (lbStudID.Text != "[ Student ID ]") { studentID = int.Parse(lbStudID.Text); } string purpose = "Other Fees"; // Purpose if (isTuitionFee) { purpose = "Tuition Fee/Misc"; } // has check details if (Payor.validateCheckDetails(mtbBankName.Text, mtbCheckNo.Text, mtdCheckDate.Value.ToShortDateString(), mtbCheckAmount.Text) && mtrbCheck.Checked) { OP = new OrderOfPayment(float.Parse(tAmount.Text), int.Parse(tPaymentOrNo.Text), dtOrDate.Value.ToShortDateString(), purpose, payor, studentID, tbRemarks.Text, mtbBankName.Text, mtbCheckNo.Text, mtdCheckDate.Value.ToShortDateString(), float.Parse(mtbCheckAmount.Text), orderOfPaymentType); } else if (mtrbCash.Checked) { OP = new OrderOfPayment(float.Parse(tAmount.Text), int.Parse(tPaymentOrNo.Text), dtOrDate.Value.ToShortDateString(), purpose, payor, studentID, tbRemarks.Text, null, null, null, 0, orderOfPaymentType); } else { MessageBox.Show("There are some fields missing!"); } // final validation if (OP != null) { if (OP.createOP()) { OP.addOPItem(int.Parse(tPaymentOrNo.Text), amountPerParticular, orderOfPaymentType); MessageBox.Show("Successful! \n \t Please Proceed to Payment"); Dictionary <string, string> OPData = OP.getOPDataWOOR(int.Parse(tPaymentOrNo.Text)); ePrinting print = new ePrinting(OPData); print.ePrint("OP"); this.hasUpdated = true; this.lastOPNumber = int.Parse(tPaymentOrNo.Text); this.Dispose(); // frmOrPayDataEntry temp = new frmOrPayDataEntry(this.lastOPNumber++); //temp.ShowDialog(); } } } else { MessageBox.Show("Invalid Input / Missing Field"); } } else { MessageBox.Show("Please add an item"); } }
private void btnSave_Click(object sender, EventArgs e) { // instantiate student object try { if (!Helper.strIsEmpty(tAmount.Text, true)) { Student st = new Student(listView1.Items[0].SubItems[1].Text); string course = st.course(); // temporary conditioning to check if a student is masteral or undergrad int OPType = (course.StartsWith("B")) ? 2 : 3; Dictionary <string, float> amountPerParticular = SAccount.getAmountPerParticular(listView1, 3, "tuition/msc"); if (amountPerParticular["Tuition Fee"] > 0 && amountPerParticular["Tuition Fee"] > float.Parse(tAmount.Text)) { amountPerParticular["Tuition Fee"] = float.Parse(tAmount.Text) - float.Parse(lbMscFee.Text); } // validation bool isValid = false; string paymentType = (isFullPayment) ? "full" : "partial"; bool isCheck = false; if (mtrbCheck.Checked) { isCheck = true; } else if (mtrbCash.Checked) { isCheck = false; } // check if NSTP is selected string NSTP = (mtrbCWTS.Checked) ? mtrbCWTS.Text : (mtrbROTC.Checked) ? mtrbROTC.Text : null; if (string.IsNullOrEmpty(NSTP) && hasNSTP) { isValid = false; MessageBox.Show("Please select NSTP Type"); return; } isValid = StudentAccount.validateAmout(paymentType, float.Parse(lbTotal.Text), float.Parse(tAmount.Text), float.Parse(lbTuitionFee.Text), float.Parse(lbMscFee.Text), isCheck); if (isValid) { // ---------------- FINAL PROCEDURE ------------------- if (isValid) { OrderOfPayment OP = null; if (Payor.validateCheckDetails(mtbBankName.Text, mtbCheckNo.Text, mtdCheckDate.Value.ToShortDateString(), mtbCheckAmount.Text) && mtrbCheck.Checked) { OP = new OrderOfPayment(float.Parse(tAmount.Text), int.Parse(tPaymentOrNo.Text), dtOrDate.Value.ToShortDateString(), "Tuition Fee/Misc", studentData[3] + ' ' + studentData[4] + ' ' + studentData[2], int.Parse(studentData[0]), "", mtbBankName.Text, mtbCheckNo.Text, mtdCheckDate.Value.ToShortDateString(), float.Parse(mtbCheckAmount.Text)); } else if (mtrbCash.Checked) { OP = new OrderOfPayment(float.Parse(tAmount.Text), int.Parse(tPaymentOrNo.Text), dtOrDate.Value.ToShortDateString(), "Tuition Fee/Misc", studentData[3] + ' ' + studentData[4] + ' ' + studentData[2], int.Parse(studentData[0])); } else { MessageBox.Show("There are some fields missing!"); } // validated if (OP != null) { if (OP.createOP()) { OP.addOPItem(int.Parse(tPaymentOrNo.Text), amountPerParticular, OPType, NSTP); MessageBox.Show("Successful! \n \t Please Proceed to Payment"); Dictionary <string, string> OPData = OP.getOPDataWOOR(int.Parse(tPaymentOrNo.Text)); ePrinting print = new ePrinting(OPData); print.ePrint("OP"); Close(); } } } } } else { MessageBox.Show("Please select "); } } catch (Exception ex) { MessageBox.Show("There are some fields missing", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }