Ejemplo n.º 1
0
        private void btnPay_Click(object sender, EventArgs e)
        {
            if (gvStudentList.CurrentRow == null)
            {
                return;
            }

            if (txtPayment.Text == String.Empty)
            {
                return;
            }
            else
            {
                if (double.Parse(txtPayment.Text) == 0)
                {
                    return;
                }
            }


            if (Student.RunningBalance == 0)
            {
                return;
            }


            if (GlobalClass.receiptFrom == null)
            {
                MessageBox.Show("Set Receipt Number First");
            }
            else
            {
                PaymentReceiptDetails prd = new PaymentReceiptDetails();

                if (Int32.Parse(GlobalClass.receiptCurrent) <= Int32.Parse(GlobalClass.receiptTo))
                {
                    int tempReceipt;

                    tempReceipt = Int32.Parse(GlobalClass.receiptCurrent);
                    MessageBox.Show("Receipt Number From:                           " + GlobalClass.receiptFrom + "\n" + "Receipt Number To:                                " + GlobalClass.receiptTo + "\n" + "Receipt Number For This Transaction: " + GlobalClass.receiptCurrent);


                    Boolean ret       = false;
                    string  message   = String.Empty;
                    string  StudentId = txtStudentID.Text.ToString();
                    Student = registrationService.GetStudent(StudentId, ref message);
                    float runningBalanceProv = float.Parse(txtPayment.Text);
                    float runningBalanceNew;
                    float runningBalanceOld = Student.RunningBalance;
                    runningBalanceNew = runningBalanceOld - runningBalanceProv;

                    if (runningBalanceNew < 0)
                    {
                        string balance = runningBalanceNew.ToString();
                        MessageBox.Show("Amount paid: " + runningBalanceProv + "\n" + "Change is: " + Math.Abs(runningBalanceNew));

                        prd.ORno        = tempReceipt;
                        prd.StudentID   = txtStudentID.Text;
                        prd.StudentName = Student.LastName + ", " + Student.FirstName + " " + Student.MiddleName.Substring(0, 1) + ".";
                        prd.Amount      = runningBalanceOld;
                        prd.ShowDialog();

                        if (prd.btnPushed == "Generate Receipt")
                        {
                            //Payment Table
                            Payment.ORNo          = tempReceipt;
                            Payment.StudentId     = txtStudentID.Text;
                            Payment.ReceivedFrom  = prd.ReceivedFrom;
                            Payment.TIN           = prd.TIN;
                            Payment.BusinessStyle = prd.BusinessStyle;
                            Payment.SettlementFor = prd.PartialFull;
                            Payment.PaidTo        = GlobalClass.user.UserId;
                            Payment.Cancelled     = false;
                            Payment.Amount        = prd.Amount;
                            Payment.PaidAt        = DateTime.Now.ToString();


                            txtPayment.Clear();
                            gvStudentList.DataSource = null;

                            //Payment Transaction
                            paymentService.CreatePayment(ref Payment, ref message);

                            //Receipt
                            tempReceipt = tempReceipt + 1;
                            GlobalClass.receiptCurrent = tempReceipt.ToString();

                            Student.RunningBalance = 0;
                            ret = registrationService.UpdateStudent(ref Student, ref message);
                            students.Add(Student);

                            if (students.Count == 2)
                            {
                                students.RemoveAt(0);
                                this.gvStudentList.DataSource = null;
                                this.gvStudentList.Rows.Clear();
                                this.gvStudentList.DataSource = students;
                            }
                            else
                            {
                                this.gvStudentList.DataSource = students;
                            }

                            gvStudentList.Update();
                            gvStudentList.Refresh();
                        }
                    }
                    else if (runningBalanceNew == 0)
                    {
                        string balance = runningBalanceNew.ToString();
                        MessageBox.Show("Amount paid: " + runningBalanceProv + "\n" + "Change is: " + Math.Abs(runningBalanceNew));


                        prd.ORno        = tempReceipt;
                        prd.StudentID   = txtStudentID.Text;
                        prd.StudentName = Student.LastName + ", " + Student.FirstName + " " + Student.MiddleName.Substring(0, 1) + ".";
                        prd.Amount      = float.Parse(txtPayment.Text);
                        prd.ShowDialog();

                        if (prd.btnPushed == "Generate Receipt")
                        {
                            //Payment Table
                            Payment.ORNo          = tempReceipt;
                            Payment.StudentId     = txtStudentID.Text;
                            Payment.ReceivedFrom  = prd.ReceivedFrom;
                            Payment.TIN           = prd.TIN;
                            Payment.BusinessStyle = prd.BusinessStyle;
                            Payment.SettlementFor = prd.PartialFull;
                            Payment.PaidTo        = GlobalClass.user.UserId;
                            Payment.Cancelled     = false;
                            Payment.Amount        = prd.Amount;
                            Payment.PaidAt        = DateTime.Now.ToString();



                            txtPayment.Clear();
                            gvStudentList.DataSource = null;


                            //Payment Transaction
                            paymentService.CreatePayment(ref Payment, ref message);


                            //Receipt
                            tempReceipt = tempReceipt + 1;
                            GlobalClass.receiptCurrent = tempReceipt.ToString();

                            Student.RunningBalance = 0;
                            ret = registrationService.UpdateStudent(ref Student, ref message);
                            students.Add(Student);
                            if (students.Count == 2)
                            {
                                students.RemoveAt(0);
                                this.gvStudentList.DataSource = null;
                                this.gvStudentList.Rows.Clear();
                                this.gvStudentList.DataSource = students;
                            }
                            else
                            {
                                this.gvStudentList.DataSource = students;
                            }

                            gvStudentList.Update();
                            gvStudentList.Refresh();
                        }
                    }
                    else
                    {
                        string balance = runningBalanceNew.ToString();
                        MessageBox.Show("Amount paid: " + runningBalanceProv + "\n" + "Current Balance is: " + Math.Abs(runningBalanceNew));


                        prd.ORno        = tempReceipt;
                        prd.StudentID   = txtStudentID.Text;
                        prd.StudentName = Student.LastName + ", " + Student.FirstName + " " + Student.MiddleName.Substring(0, 1) + ".";
                        prd.Amount      = float.Parse(txtPayment.Text);
                        prd.ShowDialog();

                        if (prd.btnPushed == "Generate Receipt")
                        {
                            //Payment Table
                            Payment.ORNo          = tempReceipt;
                            Payment.StudentId     = txtStudentID.Text;
                            Payment.ReceivedFrom  = prd.ReceivedFrom;
                            Payment.TIN           = prd.TIN;
                            Payment.BusinessStyle = prd.BusinessStyle;
                            Payment.SettlementFor = prd.PartialFull;
                            Payment.PaidTo        = GlobalClass.user.UserId;
                            Payment.Cancelled     = false;
                            Payment.Amount        = prd.Amount;
                            Payment.PaidAt        = DateTime.Now.ToString();



                            txtPayment.Clear();
                            gvStudentList.DataSource = null;

                            //Payment Transaction
                            paymentService.CreatePayment(ref Payment, ref message);

                            //Receipt
                            tempReceipt = tempReceipt + 1;
                            GlobalClass.receiptCurrent = tempReceipt.ToString();

                            Student.RunningBalance = runningBalanceNew;
                            ret = registrationService.UpdateStudent(ref Student, ref message);
                            students.Add(Student);
                            if (students.Count == 2)
                            {
                                students.RemoveAt(0);
                                this.gvStudentList.DataSource = null;
                                this.gvStudentList.Rows.Clear();
                                this.gvStudentList.DataSource = students;
                            }
                            else
                            {
                                this.gvStudentList.DataSource = students;
                            }

                            gvStudentList.Update();
                            gvStudentList.Refresh();
                        }
                    }

                    if (prd.btnPushed == "Cancel")
                    {
                        if (ret)
                        {
                            MessageBox.Show("Saved Successfully");
                        }
                        else
                        {
                            MessageBox.Show("Error Saving");
                        }
                    }
                    GlobalClass.WindowStatusPaymentDetails = false;
                }
                else
                {
                    MessageBox.Show("No More Receipt");
                }
            }
        }
Ejemplo n.º 2
0
        private void btnPay_Click(object sender, EventArgs e)
        {
            if (gvStudentList.CurrentRow == null)
                return;

            if (txtPayment.Text == String.Empty)
                return;
            else
            {
                if (double.Parse(txtPayment.Text) == 0)
                    return;
            }


            if (Student.RunningBalance == 0)
                return;
            

            if (GlobalClass.receiptFrom == null)
            {
                MessageBox.Show("Set Receipt Number First");
            }
            else
            {
                PaymentReceiptDetails prd = new PaymentReceiptDetails();

                if (Int32.Parse(GlobalClass.receiptCurrent) <= Int32.Parse(GlobalClass.receiptTo))
                {
                    int tempReceipt;

                    tempReceipt = Int32.Parse(GlobalClass.receiptCurrent);
                    MessageBox.Show("Receipt Number From:                           " + GlobalClass.receiptFrom + "\n" + "Receipt Number To:                                " + GlobalClass.receiptTo + "\n" + "Receipt Number For This Transaction: " + GlobalClass.receiptCurrent);


                    Boolean ret = false;
                    string message = String.Empty;
                    string StudentId = txtStudentID.Text.ToString();
                    Student = registrationService.GetStudent(StudentId, ref message);
                    float runningBalanceProv = float.Parse(txtPayment.Text);
                    float runningBalanceNew;
                    float runningBalanceOld = Student.RunningBalance;
                    runningBalanceNew = runningBalanceOld - runningBalanceProv;

                    if (runningBalanceNew < 0)
                    {
                        
                        string balance = runningBalanceNew.ToString();
                        MessageBox.Show("Amount paid: " + runningBalanceProv + "\n" + "Change is: " + Math.Abs(runningBalanceNew));

                        prd.ORno = tempReceipt;
                        prd.StudentID = txtStudentID.Text;
                        prd.StudentName = Student.LastName + ", " + Student.FirstName + " " + Student.MiddleName.Substring(0, 1) + ".";
                        prd.Amount = runningBalanceOld;
                        prd.ShowDialog();

                        if (prd.btnPushed == "Generate Receipt")
                        {
                            //Payment Table
                            Payment.ORNo = tempReceipt;
                            Payment.StudentId = txtStudentID.Text;
                            Payment.ReceivedFrom = prd.ReceivedFrom;
                            Payment.TIN = prd.TIN;
                            Payment.BusinessStyle = prd.BusinessStyle;
                            Payment.SettlementFor = prd.PartialFull;
                            Payment.PaidTo = GlobalClass.user.UserId;
                            Payment.Cancelled = false;
                            Payment.Amount = prd.Amount;
                            Payment.PaidAt = DateTime.Now.ToString();


                            txtPayment.Clear();
                            gvStudentList.DataSource = null;

                            //Payment Transaction
                            paymentService.CreatePayment(ref Payment, ref message);

                            //Receipt
                            tempReceipt = tempReceipt + 1;
                            GlobalClass.receiptCurrent = tempReceipt.ToString();

                            Student.RunningBalance = 0;
                            ret = registrationService.UpdateStudent(ref Student, ref message);
                            students.Add(Student);

                            if (students.Count == 2)
                            {
                                students.RemoveAt(0);
                                this.gvStudentList.DataSource = null;
                                this.gvStudentList.Rows.Clear();
                                this.gvStudentList.DataSource = students;
                            }
                            else
                            {
                                this.gvStudentList.DataSource = students;
                            }

                            gvStudentList.Update();
                            gvStudentList.Refresh();

                        }
                        
                        
                    }
                    else if (runningBalanceNew == 0)
                    {
                         string balance = runningBalanceNew.ToString();
                        MessageBox.Show("Amount paid: " + runningBalanceProv + "\n" + "Change is: " + Math.Abs(runningBalanceNew));


                        prd.ORno = tempReceipt;
                        prd.StudentID = txtStudentID.Text;
                        prd.StudentName = Student.LastName + ", " + Student.FirstName + " " + Student.MiddleName.Substring(0, 1) + ".";
                        prd.Amount = float.Parse(txtPayment.Text);
                        prd.ShowDialog();

                        if (prd.btnPushed == "Generate Receipt")
                        {
                            //Payment Table
                            Payment.ORNo = tempReceipt;
                            Payment.StudentId = txtStudentID.Text;
                            Payment.ReceivedFrom = prd.ReceivedFrom;
                            Payment.TIN = prd.TIN;
                            Payment.BusinessStyle = prd.BusinessStyle;
                            Payment.SettlementFor = prd.PartialFull;
                            Payment.PaidTo = GlobalClass.user.UserId;
                            Payment.Cancelled = false;
                            Payment.Amount = prd.Amount;
                            Payment.PaidAt = DateTime.Now.ToString();

                           

                            txtPayment.Clear();
                            gvStudentList.DataSource = null;


                            //Payment Transaction
                            paymentService.CreatePayment(ref Payment, ref message);


                            //Receipt
                            tempReceipt = tempReceipt + 1;
                            GlobalClass.receiptCurrent = tempReceipt.ToString();

                            Student.RunningBalance = 0;
                            ret = registrationService.UpdateStudent(ref Student, ref message);
                            students.Add(Student);
                            if (students.Count == 2)
                            {
                                students.RemoveAt(0);
                                this.gvStudentList.DataSource = null;
                                this.gvStudentList.Rows.Clear();
                                this.gvStudentList.DataSource = students;
                            }
                            else
                            {
                                this.gvStudentList.DataSource = students;
                            }

                            gvStudentList.Update();
                            gvStudentList.Refresh();
                        }
                    }
                    else
                    {
                       string balance = runningBalanceNew.ToString();
                        MessageBox.Show("Amount paid: " + runningBalanceProv + "\n" + "Current Balance is: " + Math.Abs(runningBalanceNew));


                        prd.ORno = tempReceipt;
                        prd.StudentID = txtStudentID.Text;
                        prd.StudentName = Student.LastName + ", " + Student.FirstName + " " + Student.MiddleName.Substring(0, 1) + ".";
                        prd.Amount = float.Parse(txtPayment.Text);
                        prd.ShowDialog();

                        if (prd.btnPushed == "Generate Receipt")
                        {
                            //Payment Table
                            Payment.ORNo = tempReceipt;
                            Payment.StudentId = txtStudentID.Text;
                            Payment.ReceivedFrom = prd.ReceivedFrom;
                            Payment.TIN = prd.TIN;
                            Payment.BusinessStyle = prd.BusinessStyle;
                            Payment.SettlementFor = prd.PartialFull;
                            Payment.PaidTo = GlobalClass.user.UserId;
                            Payment.Cancelled = false;
                            Payment.Amount = prd.Amount;
                            Payment.PaidAt = DateTime.Now.ToString();

                            

                            txtPayment.Clear();
                            gvStudentList.DataSource = null;

                            //Payment Transaction
                            paymentService.CreatePayment(ref Payment, ref message);

                            //Receipt
                            tempReceipt = tempReceipt + 1;
                            GlobalClass.receiptCurrent = tempReceipt.ToString();

                            Student.RunningBalance = runningBalanceNew;
                            ret = registrationService.UpdateStudent(ref Student, ref message);
                            students.Add(Student);
                            if (students.Count == 2)
                            {
                                students.RemoveAt(0);
                                this.gvStudentList.DataSource = null;
                                this.gvStudentList.Rows.Clear();
                                this.gvStudentList.DataSource = students;
                            }
                            else
                            {
                                this.gvStudentList.DataSource = students;
                            }

                            gvStudentList.Update();
                            gvStudentList.Refresh();
                        }

                    }

                    if (prd.btnPushed == "Cancel")
                    {
                        if (ret)
                            MessageBox.Show("Saved Successfully");
                        else
                            MessageBox.Show("Error Saving");
                    }
                    GlobalClass.WindowStatusPaymentDetails = false;
                }
                else
                {
                    MessageBox.Show("No More Receipt");
                }
            }
        }