Ejemplo n.º 1
0
        private void btnConfirmPay_Click(object sender, EventArgs e)
        {
            bool ok = true;

            errP.Clear();
            foreach (DataRow dr in dtPayToday.Rows)
            {
                MyTrans myTrans = new MyTrans();

                errP.Clear();

                drTrans = dsKaizen.Tables["Trans"].Rows.Find(dr[0].ToString());

                try
                {
                    myTrans.CustID = txtCustID.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtCustID, MyEx.toString());
                }

                try
                {
                    myTrans.TransOn = DateTime.Parse(dr[2].ToString());
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(btnConfirmPay, MyEx.toString());
                }

                try
                {
                    myTrans.TransTotal = Convert.ToDouble(drTrans["TransTotal"].ToString());
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(btnConfirmPay, MyEx.toString());
                }
                try
                {
                    myTrans.BalOwed = 0.00;
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(btnConfirmPay, MyEx.toString());
                }

                try
                {
                    if (ok)
                    {
                        drTrans.BeginEdit();
                        drTrans["CustID"]      = myTrans.CustID;
                        drTrans["TransDate"]   = myTrans.TransOn;
                        drTrans["TransTotal"]  = myTrans.TransTotal;
                        drTrans["BalanceOwed"] = myTrans.BalOwed;

                        if (myTrans.BalOwed <= 0)
                        {
                            drTrans["Paid"] = 'Y';
                        }
                        else
                        {
                            drTrans["Paid"] = 'N';
                        }

                        drTrans.EndEdit();
                        daTrans.Update(dsKaizen, "Trans");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error !", MessageBoxButtons.AbortRetryIgnore,
                                    MessageBoxIcon.Error);
                }

                MyPayment myPayment = new MyPayment();

                getPaysnum();

                try
                {
                    myPayment.PayID = "PY-" + (seperateNumber(findPayID) + 1).ToString();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(btnConfirmPay, MyEx.toString());
                }

                try
                {
                    myPayment.TransID = dr[0].ToString();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(btnConfirmPay, MyEx.toString());
                }

                try
                {
                    myPayment.PayAmount = Convert.ToDouble(dr[1].ToString());
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(btnConfirmPay, MyEx.toString());
                }

                try
                {
                    myPayment.PayDate = DateTime.Today;
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(btnConfirmPay, MyEx.toString());
                }


                if (ok)
                {
                    drPayment              = dsKaizen.Tables["Payments"].NewRow();
                    drPayment["PayID"]     = myPayment.PayID;
                    drPayment["TransID"]   = myPayment.TransID;
                    drPayment["PayAmount"] = myPayment.PayAmount;
                    drPayment["PayDate"]   = myPayment.PayDate;



                    dsKaizen.Tables["Payments"].Rows.Add(drPayment);
                    daPayments.Update(dsKaizen, "Payments");
                }
                MessageBox.Show("Payment Taken", "Order");
                populateCustOutStandingTrans(txtCustID, dgvLoadTrans);
            }
        }
Ejemplo n.º 2
0
        private void btnPPay_Click(object sender, EventArgs e)
        {
            MyPayment myPayment = new MyPayment();
            bool      ok        = true;

            errP.Clear();

            try
            {
                myPayment.PayID = lblPPayInvID.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(lblPPayInvID, MyEx.toString());
            }

            try
            {
                myPayment.TransID = txtPPayTransID.Text.Trim();
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtPPayTransID, MyEx.toString());
            }

            try
            {
                myPayment.PayAmount = Convert.ToDouble(txtBPayTo.Text.Trim());
            }
            catch (MyException MyEx)
            {
                ok = false;
                errP.SetError(txtBPayTo, MyEx.toString());
            }
            catch (FormatException Formex)
            {
                ok = false;
                errP.SetError(txtBPayTo, "Please Enter a vaild number");
            }


            if (ok)
            {
                drPayment              = dsKaizen.Tables["Payments"].NewRow();
                drPayment["PayID"]     = myPayment.PayID;
                drPayment["TransID"]   = myPayment.TransID;
                drPayment["PayAmount"] = myPayment.PayAmount;
                drPayment["PayDate"]   = myPayment.PayDate;



                dsKaizen.Tables["Payments"].Rows.Add(drPayment);
                daPayments.Update(dsKaizen, "Payments");



                MyTrans myTrans = new MyTrans();

                errP.Clear();

                drTrans = dsKaizen.Tables["Trans"].Rows.Find(txtPPayTransID.Text);

                try
                {
                    myTrans.CustID = lblPPayCustNo.Text.Trim();
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtCustID, MyEx.toString());
                }

                try
                {
                    myTrans.TransOn = dtpPPay.Value;
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(dtpPPay, MyEx.toString());
                }

                try
                {
                    myTrans.TransTotal = Convert.ToDouble(lblPPayTot.Text.Trim());
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(lblPPayTot, MyEx.toString());
                }
                try
                {
                    myTrans.BalOwed = (Convert.ToDouble(lblPPayOut.Text.Trim())) - (Convert.ToDouble(txtBPayTo.Text.Trim()));
                }
                catch (MyException MyEx)
                {
                    ok = false;
                    errP.SetError(txtBPayTo, MyEx.toString());
                }

                try
                {
                    if (ok)
                    {
                        drTrans.BeginEdit();
                        drTrans["CustID"]      = myTrans.CustID;
                        drTrans["TransDate"]   = myTrans.TransOn;
                        drTrans["TransTotal"]  = myTrans.TransTotal;
                        drTrans["BalanceOwed"] = myTrans.BalOwed;

                        if (myTrans.BalOwed <= 0)
                        {
                            drTrans["Paid"] = 'Y';
                        }
                        else
                        {
                            drTrans["Paid"] = 'N';
                        }

                        drTrans.EndEdit();
                        daTrans.Update(dsKaizen, "Trans");

                        MessageBox.Show("Payment Taken", "Order");
                        clearMultiPayfrm();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex.TargetSite + "" + ex.Message, "Error !", MessageBoxButtons.AbortRetryIgnore,
                                    MessageBoxIcon.Error);
                }
            }
        }