Пример #1
0
        private void frmOPDetails_Load(object sender, EventArgs e)
        {
            OrderOfPayment OP = new OrderOfPayment();
            Dictionary <string, string> data = OP.getOPDataWOOR(OPNo);

            mtOPNo.Text       = "" + OPNo;
            mtPayor.Text      = data["Payor"];
            mtTotal.Text      = data["Amount"];
            mtDateIssued.Text = data["DateIssued"];
            mtPaid.Text       = OP.getPaymentStatus();
            mtOPType.Text     = OP.getOPType();
            this.ControlBox   = true;

            string[][] particulars = OP.getOrderOfPaymentItem(OPNo);
            new clsDB().Con().listViewTransferData(particulars, listView1);
        }
        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();
                    }
                }
            }
        }