Exemple #1
0
        /// <summary>
        /// Handles the ExecutePayment event of the payBillControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="CommandEventArgs"/> instance containing the event data.</param>
        void payBillControl_ExecutePayment(object sender, CommandEventArgs e)
        {
            // Hashtable payObject = e.CommandArgument as Hashtable;

            BillPaymentInfo paymentInfo = (BillPaymentInfo)e.CommandArgument;
            List <BillItem> items       = (List <BillItem>)paymentInfo.ItemsToPay;//["PayItems"];

            try
            {
                IBilling BManager = (IBilling)ObjectFactory.CreateInstance("BusinessProcess.Billing.BBilling, BusinessProcess.Billing");

                //DataTable table
                Receipt receipt = BManager.SavePatientBillPayments(this.PatientId, paymentInfo, this.UserId);

                //BManager.SavePatientBillPayments(this.PatientID, paymentInfo, null, this.UserID);
                bool printReceipt = paymentInfo.PrintReceipt;// Convert.ToBoolean(paymentInfo.Rows[0]["PrintReceipt"]);
                // Session["transactionID"] = transactionID;
                //Reciept print
                string theUrl;
                base.Session.Remove("ItemsToPay");
                base.Session.Remove("paymentInformation");
                base.Session.Remove("DiscountPlan");
                base.Session.Remove("totalbill");
                // DataRow row = table.Rows[0];
                string transactionID  = receipt.TransactionId.ToString(); // row["TransactionID"].ToString();
                string transactionRef = receipt.ReceiptNumber;            // row["TransactionReference"].ToString();
                ((IPayment)sender).Clear();

                if (printReceipt)
                {
                    //  base.Session["TransactionReceipt"] = receipt;
                    theUrl = string.Format("./frmBilling_Reciept.aspx?ReceiptTrxCode={0}&RePrint=false", transactionRef);
                    string theOrdScript;
                    theOrdScript  = "<script language='javascript' id='PrintReciept'>\n";
                    theOrdScript += "window.open('" + theUrl + "','Receipt','toolbars=no,location=no,directories=no,dependent=yes,top=100,left=30,maximize=no,resize=no,width=1000,height=800,scrollbars=yes');\n";
                    //  theOrdScript += "window.location.href = './frmBilling_ClientBill.aspx';\n";
                    theOrdScript += "</script>\n";
                    //  Page.ClientScript.RegisterStartupScript(this.GetType(), "PrintReciept", theOrdScript);
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "PrintReceipt", theOrdScript, false);
                }
                //
                this.DisplayMode("ITEMS");
                this.PopulateBillTransactions();
                UpdatePanel1.Update();
                upBill.Update();
                Session.Remove("PayControl");
                this.Init_page();
            }
            catch (Exception ex)
            {
                ((IPayment)sender).Clear();
                this.showErrorMessage(ref ex);
            }
        }
Exemple #2
0
 private void Child_Fetch(SafeDataReader dr)
 {
     LoadProperty(_Id, dr.GetInt32("paymentdetail"));
     LoadProperty(_Payment, dr.GetInt32("Payment"));
     LoadProperty(_Bill, BillPaymentInfo.Get(dr, _Bill.Name));
     LoadProperty(_PartialPayment, dr.GetDecimal("partialpayment"));
     LoadProperty(_AmountDue, dr.GetDecimal("amountdue"));
     LoadProperty(_AmountPaid, dr.GetDecimal("amountpaid"));
     LoadProperty(_PaymentType, dr.GetInt32("paymenttype"));
     LoadProperty(_BankName, dr.GetString("bank"));
     LoadProperty(_BankBranch, dr.GetString("branch"));
     LoadProperty(_RefNo, dr.GetString("refno"));
     LoadProperty(_RefDate, dr.GetSmartDate("refdate"));
     LoadProperty(_Comments, dr.GetString("comments"));
 }
Exemple #3
0
        /// <summary>
        /// Handles the Click event of the btnFinish control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnFinish_Click(object sender, EventArgs e)
        {
            try
            {
                BillPaymentInfo paymentInfo = (BillPaymentInfo)Session["paymentInformation"];

                IBilling BManager = (IBilling)ObjectFactory.CreateInstance("BusinessProcess.SCM.BBilling, BusinessProcess.SCM");
                //  DataTable _items = (DataTable)base.Session["ItemsToPay"];
                //  paymentInfo.Rows[0]["PrintReceipt"] = ckbPrintReciept.Checked;

                paymentInfo.PrintReceipt      = ckbPrintReciept.Checked;
                Session["paymentInformation"] = paymentInfo;

                this.OnPayExecute(this, new CommandEventArgs("Execute", paymentInfo));
            }
            catch (Exception ex)
            {
                this.showErrorMessage(ref ex);
            }
        }
Exemple #4
0
        /// <summary>
        /// Computes this instance.
        /// </summary>
        /// <exception cref="System.NotImplementedException"></exception>
        public void Compute()
        {
            valid = true;

            string strPaymentMode = this.PaymentMethodName;


            // isValidEntry = validateDropDownList(ddlAccounts);


            isValidEntry = validateTextBox(textReferenceNo);
            if (!isValidEntry)
            {
                return;
            }
            //  DataTable itemsToPay = this.initializeItemsToPay();
            decimal _amountToPay    = 0;
            decimal _amountTendered = 0;

            _amountToPay = Decimal.Parse(textAmountToPay.Text);

            BillPaymentInfo payObject = new BillPaymentInfo()
            {
                BillID          = this.BillID,
                LocationID      = this.BillLocationID,
                AmountPayable   = _amountToPay,
                Amount          = _amountToPay,
                TenderedAmount  = _amountTendered,
                ReferenceNumber = textReferenceNo.Text.Trim(),
                Deposit         = false,
                PaymentMode     = new PaymentMethod()
                {
                    ID = this.PaymentMethodID, Name = this.PaymentMethodName
                },
                ItemsToPay = null
            };

            base.Session["paymentInformation"] = payObject;
            {
                lblPaid.InnerText          = _amountTendered.ToString();
                labelPaymentType.InnerText = this.PaymentMethodName;
                labelAmountTopay.InnerText = _amountToPay.ToString();

                List <BillItem> itemsList = this._ItemsToPay;

                decimal _totalToPay = _amountToPay;

                if (itemsList != null && itemsList.Count > 0)
                {
                    _totalToPay = itemsList.Sum(i => i.Amount);
                }

                if (!this.HasTransaction && _totalToPay == _amountToPay)
                {
                    payObject.ItemsToPay = itemsList;
                }
                else
                {
                    if (this.BillPayOption == BillPaymentOptions.SelectItem)
                    {
                        payObject.ItemsToPay = itemsList;
                    }
                }
                if (this.AllowPartialPayment)
                {
                    _totalToPay = _amountToPay;
                }

                base.Session["paymentInformation"] = payObject;
                {
                    lblChange.InnerText  = "0";
                    panelFinish.Visible  = true;
                    btnFinish.Enabled    = true;
                    panelCompute.Visible = false;
                    //amount of bill pending after this transaction
                    Decimal amountAfterThisTransaction = this.AmountDue - _amountToPay;
                    labelAmountDue.InnerText = amountAfterThisTransaction.ToString();
                }
            };
        }
Exemple #5
0
        public BillPaymentInfo getBillPaymentID(string time, string vendorID, string accoundID)
        {
//            string response = new CommonApiController().ExtractXml(new ConstantValue().BILLPAYCHECKQUERY);
//            string response1 = new CommonApiController().ExtractXml(new ConstantValue().BILLPAYCREDITCARDQUERY);

            string id           = "";
            string crTime       = "";
            string strVendorID  = "";
            string strAccoundID = "";

            BillPaymentInfo info = new BillPaymentInfo();

            /*
             * XmlReader reader = XmlReader.Create(new StringReader(response));
             * while (reader.Read())
             * {
             *  if (reader.IsStartElement())
             *  {
             *      if (reader.ReadToFollowing("TxnID"))
             *      {
             *          id = reader.ReadElementContentAsObject().ToString();
             *      }
             *
             *      if (reader.ReadToFollowing("TimeCreated"))
             *      {
             *          crTime = reader.ReadElementContentAsObject().ToString();
             *      }
             *
             *      if (reader.ReadToFollowing("PayeeEntityRef"))
             *      {
             *          if (reader.ReadToFollowing("ListID"))
             *          {
             *              strVendorID = reader.ReadElementContentAsObject().ToString();
             *          }
             *      }
             *      if (reader.ReadToFollowing("APAccountRef"))
             *      {
             *          if (reader.ReadToFollowing("ListID"))
             *          {
             *              strAccoundID = reader.ReadElementContentAsObject().ToString();
             *          }
             *      }
             *
             *      if ((crTime == time) && (strVendorID == vendorID) && (strAccoundID == accoundID) && (id != null))
             *      {
             *          info.ID = id;
             *          info.PaymentType = new ConstantValue().BILLPAYMENTCHECKTYPE;
             *          return info;
             *      }
             *
             *  }
             * }
             *
             * reader = XmlReader.Create(new StringReader(response1));
             * while (reader.Read())
             * {
             *  if (reader.IsStartElement())
             *  {
             *      if (reader.ReadToFollowing("TxnID"))
             *      {
             *          id = reader.ReadElementContentAsObject().ToString();
             *      }
             *
             *      if (reader.ReadToFollowing("TimeCreated"))
             *      {
             *          crTime = reader.ReadElementContentAsObject().ToString();
             *      }
             *
             *      if (reader.ReadToFollowing("PayeeEntityRef"))
             *      {
             *          if (reader.ReadToFollowing("ListID"))
             *          {
             *              strVendorID = reader.ReadElementContentAsObject().ToString();
             *          }
             *      }
             *      if (reader.ReadToFollowing("APAccountRef"))
             *      {
             *          if (reader.ReadToFollowing("ListID"))
             *          {
             *              strAccoundID = reader.ReadElementContentAsObject().ToString();
             *          }
             *      }
             *
             *      if ((crTime == time) && (strVendorID == vendorID) && (strAccoundID == accoundID) && (id != null))
             *      {
             *          info.ID = id;
             *          info.PaymentType = new ConstantValue().BILLPAYMENTCREDITTYPE;
             *          return info;
             *      }
             *  }
             * }
             */
            return(info);
        }
Exemple #6
0
        /// <summary>
        /// Computes this instance.
        /// </summary>
        /// <exception cref="System.NotImplementedException"></exception>
        public void Compute()
        {
            valid = true;

            string strPaymentMode = this.PaymentMethodName;


            // isValidEntry = validateDropDownList(ddlAccounts);


            isValidEntry = validateTextBox(textReferenceNo);
            if (!isValidEntry)
            {
                return;
            }
            //  DataTable itemsToPay = this.initializeItemsToPay();
            decimal _amountToPay    = 0;
            decimal _amountTendered = 0;
            decimal _discount       = 0.0M;

            _amountToPay = decimal.Parse(textAmountToPay.Text);

            if (this.SelectedDiscountPlan != null)
            {
                _discount = _amountToPay / (1.00M - this.SelectedDiscountPlan.Rate) - _amountToPay;
            }


            BillPaymentInfo payObject = new BillPaymentInfo()
            {
                BillId     = this.BillId,
                LocationId = this.BillLocationId,
                //AmountPayable = _amountToPay,
                Amount          = _amountToPay,
                TenderedAmount  = _amountTendered,
                ReferenceNumber = textReferenceNo.Text.Trim(),
                Deposit         = false,
                PaymentMode     = new PaymentMethod()
                {
                    Id = this.PaymentMethodId, Name = this.PaymentMethodName
                },
                ChosenDiscountPlan = this.SelectedDiscountPlan,
                ItemsToPay         = null
            };

            base.Session["paymentInformation"] = payObject;
            {
                lblPaid.InnerText          = _amountTendered.ToString("F");
                labelPaymentType.InnerText = this.PaymentMethodName;
                labelAmountTopay.InnerText = _amountToPay.ToString("F");

                List <BillItem> itemsList = this._ItemsToPay;

                decimal _totalToPay = _amountToPay;


                if (this.SelectedDiscountPlan != null)
                {
                    _discount = payObject.CalculatedDiscount * payObject.Amount;
                }
                labelDiscountGiven.InnerText = _discount.ToString("F");

                if (itemsList != null && itemsList.Count > 0)
                {
                    _totalToPay = itemsList.Sum(i => i.Amount);
                }

                payObject.ItemsToPay = itemsList;

                //if (!this.HasTransaction && _totalToPay == _amountToPay)
                //{
                //    payObject.ItemsToPay = itemsList;
                //}
                //else
                //{
                //    if (this.BillPayOption == BillPaymentOptions.SelectItem)
                //    {
                //        payObject.ItemsToPay = itemsList;
                //    }
                //}
                if (this.AllowPartialPayment)
                {
                    _totalToPay = _amountToPay;
                }
                decimal _discountedToPay = payObject.AmountPayable;

                base.Session["paymentInformation"] = payObject;
                {
                    lblChange.InnerText  = "0";
                    panelFinish.Visible  = true;
                    btnFinish.Enabled    = true;
                    panelCompute.Visible = false;
                    //amount of bill pending after this transaction
                    decimal amountAfterThisTransaction = this.AmountDue - _amountToPay;
                    labelAmountDue.InnerText = amountAfterThisTransaction.ToString("F");
                }
            };
        }
Exemple #7
0
        /// <summary>
        /// Computes the paid amount.
        /// </summary>
        /// <param name="tenderedAmount">The total paid.</param>
        private void computePaidAmount(Decimal tenderedAmount, Decimal amountToPay)
        {
            lblPaid.InnerText          = tenderedAmount.ToString();
            labelPaymentType.InnerText = this.PaymentMethodName;
            labelAmountTopay.InnerText = amountToPay.ToString();

            List <BillItem> itemsList = this._ItemsToPay;

            decimal _totalToPay = amountToPay;

            BillPaymentInfo paymentInfo = (BillPaymentInfo)Session["paymentInformation"];

            if (itemsList != null && itemsList.Count > 0)
            {
                _totalToPay = itemsList.Sum(i => i.Amount);
            }



            if (!this.HasTransaction && _totalToPay == amountToPay)
            {
                paymentInfo.ItemsToPay = itemsList;
            }
            else
            {
                if (this.BillPayOption == BillPaymentOptions.SelectItem)
                {
                    paymentInfo.ItemsToPay = itemsList;
                }
            }
            if (this.AllowPartialPayment)
            {
                _totalToPay = amountToPay;
            }
            Session["paymentInformation"] = paymentInfo;
            //tendered less amount than the amount to be paid
            if (tenderedAmount < amountToPay || _totalToPay != amountToPay)
            {
                textTenderedAmount.BorderColor = System.Drawing.Color.Red;
                lblChange.InnerText            = "0";
                btnFinish.Enabled = false;
                return;
            }
            else
            {
                Decimal changeDue = tenderedAmount - amountToPay;

                if (this.PaymentMethodName != "Cash")//confirm that payment type is cash. change can only be given to cash payments
                {
                    lblChange.InnerText = "0";
                }
                else
                {
                    lblChange.InnerText = (Math.Abs(changeDue)).ToString();
                }
                //tblFinish.Visible = true;
                panelFinish.Visible = true;
                btnFinish.Enabled   = true;
                // tblCompute.Visible = false;
                panelCompute.Visible = false;
                //amount of bill pending after this transaction
                Decimal amountAfterThisTransaction = this.AmountDue - amountToPay;
                labelAmountDue.InnerText = amountAfterThisTransaction.ToString();
            }
        }
Exemple #8
0
        /// <summary>
        /// Computes this instance.
        /// </summary>
        /// <exception cref="System.NotImplementedException"></exception>
        public void Compute()
        {
            valid = true;

            string strPaymentMode = this.PaymentMethodName;

            if (strPaymentMode == "Cash")
            {
                isValidEntry = validateTextBox(textTenderedAmount);
            }

            //isValidEntry = validateDropDownList(ddlPaymentMode);

            if (strPaymentMode != "Cash" && strPaymentMode != "Deposit")
            {
                isValidEntry = validateTextBox(textReferenceNo);
            }
            if (!isValidEntry)
            {
                return;
            }
            //  DataTable itemsToPay = this.initializeItemsToPay();
            decimal _amountToPay    = 0;
            decimal _amountTendered = 0;

            _amountToPay = Decimal.Parse(textAmountToPay.Text);

            if (strPaymentMode == "Cash")
            {
                _amountTendered = Decimal.Parse(textTenderedAmount.Text);
            }

            BillPaymentInfo payObject = new BillPaymentInfo()
            {
                BillID          = this.BillID,
                LocationID      = this.BillLocationID,
                AmountPayable   = _amountToPay,
                Amount          = _amountToPay,
                TenderedAmount  = _amountTendered,
                ReferenceNumber = textReferenceNo.Text.Trim(),
                Deposit         = (this.PaymentMethodName == "Deposit"),
                PaymentMode     = new PaymentMethod()
                {
                    ID = this.PaymentMethodID, Name = this.PaymentMethodName
                },
                ItemsToPay = null
            };

            base.Session["paymentInformation"] = payObject;

            if (this.PaymentMethodName == "Deposit")
            {
                this.computePaidAmount(Convert.ToDecimal(labelAvailableDeposit.Text), _amountToPay);
                //theDR.SetField("IsDeposit", true);
            }
            else if (this.PaymentMethodName == "Cash")
            {
                this.computePaidAmount(_amountTendered, _amountToPay);
            }
            else //if (this.PaymentMethodName == "NHIF")
            {
                this.computePaidAmount(_amountToPay, _amountToPay);
            }
        }
        /// <summary>
        /// Computes the paid amount.
        /// </summary>
        /// <param name="tenderedAmount">The total paid.</param>
        private void computePaidAmount(decimal tenderedAmount, decimal amountToPay)
        {
            lblPaid.InnerText          = tenderedAmount.ToString("F");
            labelPaymentType.InnerText = this.PaymentMethodName;
            labelAmountTopay.InnerText = amountToPay.ToString("F");

            List <BillItem> itemsList = this._ItemsToPay;

            decimal _totalToPay = amountToPay;
            decimal _discount   = 0.0M;


            BillPaymentInfo paymentInfo = (BillPaymentInfo)Session["paymentInformation"];

            if (this.SelectedDiscountPlan != null)
            {
                _discount = paymentInfo.CalculatedDiscount * paymentInfo.Amount;
            }
            labelDiscountGiven.InnerText = _discount.ToString("F");
            if (itemsList != null && itemsList.Count > 0)
            {
                _totalToPay = itemsList.Sum(i => i.Amount) - _discount;
            }

            paymentInfo.ItemsToPay = itemsList;

            //if (!this.HasTransaction && _totalToPay == amountToPay)
            //{
            //    paymentInfo.ItemsToPay = itemsList;
            //}
            //else
            //{
            //    if (this.BillPayOption == BillPaymentOptions.SelectItem)
            //    {
            //        paymentInfo.ItemsToPay = itemsList;
            //    }
            //}
            if (this.AllowPartialPayment)
            {
                _totalToPay = amountToPay;
            }

            decimal _discountedToPay = paymentInfo.AmountPayable;

            //if (this.SelectedDiscountPlan != null)
            //{
            //    _discountedToPay =  ((1.0M - this.SelectedDiscountPlan.Rate) * _totalToPay);
            //}
            Session["paymentInformation"] = paymentInfo;
            //tendered less amount than the amount to be paid
            //if (tenderedAmount < amountToPay || _totalToPay != amountToPay)
            if (tenderedAmount < _discountedToPay || _discountedToPay != amountToPay)
            {
                textTenderedAmount.BorderColor = System.Drawing.Color.Red;
                lblChange.InnerText            = "0";
                btnFinish.Enabled = false;
                return;
            }
            else
            {
                // Decimal changeDue = tenderedAmount - amountToPay;
                decimal changeDue = tenderedAmount - _discountedToPay;
                if (this.PaymentMethodName != "Cash")//confirm that payment type is cash. change can only be given to cash payments
                {
                    lblChange.InnerText = "0";
                }
                else
                {
                    lblChange.InnerText = (Math.Abs(changeDue)).ToString("F");
                }
                //tblFinish.Visible = true;
                panelFinish.Visible = true;
                btnFinish.Enabled   = true;
                // tblCompute.Visible = false;
                panelCompute.Visible = false;
                //amount of bill pending after this transaction
                //Decimal amountAfterThisTransaction = this.AmountDue - amountToPay;
                decimal amountAfterThisTransaction = this.AmountDue - paymentInfo.Amount;
                labelAmountDue.InnerText = amountAfterThisTransaction.ToString("F");
            }
        }