/// <summary>
        /// Populates the type of the payment.
        /// </summary>
        void PopulatePaymentType()
        {
            IBilling             BillingManager = (IBilling)ObjectFactory.CreateInstance("BusinessProcess.SCM.BBilling, BusinessProcess.SCM");
            List <PaymentMethod> paymentMethods = BillingManager.GetPaymentMethods("");

            PaymentConfigHelper.RefreshSection();
            if (paymentMethods != null)
            {
                int i = 0;
                for (i = 0; i < paymentMethods.Count(); i++)//PaymentMethod e in paymentMethods)
                {
                    PaymentMethod e    = paymentMethods[i];
                    string        name = e.Name;

                    if (PaymentConfigHelper.PaymethodExists(name))
                    {
                        try
                        {
                            string _thishandler = PaymentConfigHelper.GetHandlerNameByPayMethod(name);
                            e.MethodDescription = PaymentConfigHelper.PayElementDescription(name);
                            if (!string.IsNullOrEmpty(_thishandler))
                            {
                                e.Handler            = _thishandler;
                                e.HandlerDescription = PaymentConfigHelper.HandlerDescription(_thishandler);
                                e.ControlName        = PaymentConfigHelper.HandlerControlName(_thishandler);
                            }
                        }
                        catch { }
                    }
                }
                gridPaymentType.DataSource = paymentMethods;
                gridPaymentType.DataBind();
            }
        }
        /// <summary>
        /// Populates the payment plugins.
        /// </summary>
        private void PopulatePaymentPlugins()
        {
            List <string> _handlers = PaymentConfigHelper.Handlers();

            ddlHandler.ClearSelection();
            ddlHandler.Items.Clear();
            ddlHandler.Items.Add(new ListItem("Select...", ""));
            foreach (string handlerName in _handlers)
            {
                string controlName = PaymentConfigHelper.HandlerControlName(handlerName);
                string description = PaymentConfigHelper.HandlerDescription(handlerName);
                ddlHandler.Items.Add(new ListItem(handlerName, handlerName));
            }
        }
        /// <summary>
        /// Buttons the proceed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void buttonProceed_Click(object sender, EventArgs e)
        {
            string paymethod = ddlPaymentMode.SelectedItem.Text;

            //List<IQCare.CustomReportConfig.PayMethodElement> lx =
            //       IQCare.CustomReportConfig.PaymentMethodConfig.PayMethodAvailable;
            //PayMethodElement selectedElement = IQCare.CustomReportConfig.PaymentMethodConfig.GetPayMethodConfigElement(paymethod);

            string selectedHandler = PaymentConfigHelper.GetHandlerNameByPayMethod(paymethod);
            string controlName     = PaymentConfigHelper.HandlerControlName(selectedHandler);

            if (string.IsNullOrEmpty(controlName))
            {
                return;
            }
            controlName = ("~/billing/" + controlName);

            PaymentMethod payMode = new PaymentMethod()
            {
                ID = Convert.ToInt32(ddlPaymentMode.SelectedValue), Name = paymethod
            };
            Decimal SelectedAmountToPay = 0;

            foreach (GridViewRow gridRow in this.grdPayItems.Rows)
            {
                if (gridRow.RowType == DataControlRowType.DataRow)
                {
                    CheckBox chk    = gridRow.FindControl("chkBxItem") as CheckBox;
                    decimal  amount = decimal.Parse(grdPayItems.DataKeys[gridRow.RowIndex].Values["amount"].ToString());
                    if (chk != null && chk.Checked)
                    {
                        SelectedAmountToPay += amount;
                    }
                    else
                    {
                        gridRow.BackColor = Color.White;
                    }
                }
            }
            ;
            if (SelectedAmountToPay == 0)
            {
                SelectedAmountToPay = this.AmountDue;
            }
            Hashtable ht = new Hashtable()
            {
                { "ControlName", controlName },
                { "AmountDue", this.AmountDue },
                { "BillAmount", this.BillAmount },
                { "BillLocationId", Convert.ToInt32(HLocationID.Value) },
                { "PatientID", this.PatientID },
                { "UserID", this.UserID },
                { "BillID", this.BillID },
                { "PaymentMode", new PaymentMethod()
                  {
                      ID = Convert.ToInt32(ddlPaymentMode.SelectedValue), Name = paymethod
                  } },
                { "AmountToPay", SelectedAmountToPay }
            };

            Session["PayControl"] = ht;
            this.AddPayControl(ht);

            //  ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Highlightor", "highlight();", true);
        }