Пример #1
0
        // #  --------------------   DBACTIONS ---------------------------
        private void addPayment()
        {
            if (lvManageRecord.CheckedItems.Count < 1)
            {
                frmOrPayDataEntry f = frmOrPayDataEntry.show_asAdd(new MsgHandler(RefreshData), this.lastOPNumber);
                if (f.hasUpdated)
                {
                    this.lastOPNumber = f.lastOPNumber;
                }
            }
            else
            {
                // instantiate an object of student
                Student st = new Student(lvManageRecord.CheckedItems[0].SubItems[1].Text);

                // pass values to form

                frmOrPayDataEntry.checkedItems = Payor.getCheckedItems(lvManageRecord);
                frmOrPayDataEntry.studentData  = st.studentData;


                frmOrPayDataEntry f = frmOrPayDataEntry.show_asAdd(new MsgHandler(RefreshData), this.lastOPNumber);

                if (f.hasUpdated)
                {
                    this.lastOPNumber = f.lastOPNumber;
                }
            }
        }
        //  "show as" functions

        public static void show_asAdd(frmOrPayManageData.MsgHandler msg)
        {
            dbAction       = "add";
            modRefreshData = msg;

            frmOrPayDataEntry f = new frmOrPayDataEntry();

            if (studentData != null && checkedItems != null)
            {
                // hide text boxes

                f.tbFirstname.Visible  = false;
                f.tbLastname.Visible   = false;
                f.tbMiddlename.Visible = false;
            }


            f.showPayor(f);
        }
        //  "show as" functions
        public static void show_asAdd(frmOrPayManageData.MsgHandler msg)
        {
            dbAction = "add";
            modRefreshData = msg;

            frmOrPayDataEntry f = new frmOrPayDataEntry();

            if (studentData != null && checkedItems != null)
            {
                // hide text boxes

                f.tbFirstname.Visible = false;
                f.tbLastname.Visible = false;
                f.tbMiddlename.Visible = false;

            }

            f.showPayor(f);
        }
        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");
            }
        }
        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");
            }
        }