private void btnSave_Click(object sender, EventArgs e) { bool hasPayment = false; if (float.Parse(tbAmount.Text) < float.Parse(lblAmountToPay.Text)) { MessageBox.Show(" Invalid Amount"); } else { string query = "SELECT SA.SeqNo, SA.StudID, SA.SemNo, SA.Particular, SA.Amount, ISNULL(SA.Payment,0), ISNULL(SA.Balance,0),OP.Amount FROM Student_Account as SA JOIN tbl_PayOrder as OP ON SA.StudID = OP.StudID WHERE OP.OPNo = "; int recordCount = new clsDB().Con().countRecord(query + orderOfPaymentNo); string[][] data = new string[recordCount][]; // if it is for Student Account if (recordCount > 0) { new clsDB().Con().SelectData(query + orderOfPaymentNo, data); StudentAccount sa = new StudentAccount(); Dictionary<string, string> studentAccountData = sa.getData(data); int tuitionSeqNo = int.Parse(studentAccountData["tuitionSeqNo"]); float mFee = float.Parse(studentAccountData["mFee"]); int StudID = int.Parse(studentAccountData["StudID"]); int semNo = int.Parse(studentAccountData["SemNo"]); if (StudentAccount.updatePayment(sa.seqNo, tuitionSeqNo, float.Parse(tbAmount.Text), StudID, mFee, semNo)) { hasPayment = true; } else { MessageBox.Show("There was an error!"); } } // if for Misc Fees and other payments else { hasPayment = true; } } // Final Procedure if (hasPayment) { string checkAmount = null, checkDate = null, checkNo = null, bankName = null, PaymentType = null ; OPData.TryGetValue("CheckAmount", out checkAmount); OPData.TryGetValue("CheckNo", out checkNo); OPData.TryGetValue("CheckDate", out checkDate); OPData.TryGetValue("BankName", out bankName); OPData.TryGetValue("PaymentType", out PaymentType); clsCollection col = new clsCollection(orderOfPaymentNo, int.Parse(OrderOfPayment.getLastORNo()), dtORDate.Value.ToShortDateString(), float.Parse(tbAmount.Text), OPData["Payor"].Replace("'","''"), checkNo,bankName, checkDate, float.Parse(checkAmount), int.Parse(PaymentType)); if (OP.updateOP(int.Parse(tbORNo.Text), orderOfPaymentNo)) if (col.create()) { OP.paidOP(orderOfPaymentNo); col.addCollectionItem(); string[][] particularsAmount = OP.getOrderOfPaymentItem(orderOfPaymentNo); OPData["collectionDate"] = dtORDate.Value.ToShortDateString(); int currOrNumber = int.Parse(OrderOfPayment.getLastORNo()) - 1; OPData["ORNumber"] = ""+currOrNumber; ePrinting print = new ePrinting(OPData, particularsAmount); // temporary fix for OTHER Payment if (OPData["Purpose"] == "Other Fees") print.isOtherPayment = true; print.ePrint("OR"); Close(); } } }
private void btnSave_Click(object sender, EventArgs e) { if (lvDataEntryOP.Items.Count > 0) { float total = float.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),int.Parse(paymentType)); } 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, int.Parse(paymentType)); 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.Dispose(); frmOrPayDataEntry temp = new frmOrPayDataEntry(); temp.ShowDialog(); } } } else { MessageBox.Show("Invalid Input / Missing Field"); } } else { MessageBox.Show("Please add an item"); } }