Esempio n. 1
0
        private void UpdatePaymentProvider()
        {
            List <SubscriberPaymentProviderInfo> lstSub = Controller.GetSubscriberPaymentProviders(PortalId, 0);
            List <PaymentProviderInfo>           lst    = Controller.GetPaymentProviders(CurrentLanguage);

            if (lst.Count == 0)
            {
                lst = Controller.GetPaymentProviders(DefaultLanguage);
            }
            if (lst.Count > 0)
            {
                foreach (PaymentProviderInfo pp in lst)
                {
                    Boolean isChecked = false;
                    string  paymentProviderProperties = "";
                    decimal cost        = 0.00m;
                    decimal costPercent = 0.0m;
                    decimal taxPercent  = 0.00m;
                    int     viewOrder   = 0;
                    string  role        = "";

                    //Is this Provider in the List for the Subscriber (Portal) ?
                    SubscriberPaymentProviderInfo Sub = lstSub.Find(sub => sub.PaymentProviderId == pp.PaymentProviderId);

                    CheckBox chk = Globals.FindControlRecursiveDown(phPayment, "chkEnabled" + pp.PaymentProviderId.ToString()) as CheckBox;
                    if (chk != null)
                    {
                        isChecked = chk.Checked;
                    }

                    TextBox txt = Globals.FindControlRecursiveDown(phPayment, "txtVieworder" + pp.PaymentProviderId.ToString()) as TextBox;
                    if (txt != null)
                    {
                        Int32.TryParse(txt.Text, out viewOrder);
                    }

                    PaymentProviderBase ppb = Globals.FindControlRecursiveDown(phPayment, "pp" + pp.PaymentProviderId.ToString()) as PaymentProviderBase;
                    if (ppb != null)
                    {
                        paymentProviderProperties = ppb.Properties;
                    }
                    TaxControl tax = Globals.FindControlRecursiveDown(phPayment, "txtPrice" + pp.PaymentProviderId.ToString()) as TaxControl;
                    if (tax != null)
                    {
                        cost = tax.Value;
                    }

                    txt = Globals.FindControlRecursiveDown(phPayment, "txtCostPercent" + pp.PaymentProviderId.ToString()) as TextBox;
                    if (txt != null)
                    {
                        decimal.TryParse(txt.Text, out costPercent);
                    }

                    txt = Globals.FindControlRecursiveDown(phPayment, "txtTaxPercent" + pp.PaymentProviderId.ToString()) as TextBox;
                    if (txt != null)
                    {
                        decimal.TryParse(txt.Text, out taxPercent);
                    }

                    DropDownList ddl = Globals.FindControlRecursiveDown(phPayment, "ddlUserRole" + pp.PaymentProviderId.ToString()) as DropDownList;
                    if (ddl != null && ddl.SelectedIndex > 0)
                    {
                        role = ddl.SelectedValue;
                    }

                    if (Sub == null)
                    {
                        Sub = new SubscriberPaymentProviderInfo();
                        Sub.PaymentProviderId = pp.PaymentProviderId;
                        Sub.PortalId          = PortalId;
                        Sub.Cost         = cost;
                        Sub.CostPercent  = costPercent;
                        Sub.SubscriberId = 0;
                        Sub.ViewOrder    = viewOrder;
                        Sub.IsEnabled    = isChecked;
                        Sub.Role         = role;
                        Sub.PaymentProviderProperties = paymentProviderProperties;
                        Sub.TaxPercent = taxPercent;
                        Controller.NewSubscriberPaymentProvider(Sub);
                    }
                    else
                    {
                        Sub.PaymentProviderId = pp.PaymentProviderId;
                        Sub.PortalId          = PortalId;
                        Sub.Cost         = cost;
                        Sub.CostPercent  = costPercent;
                        Sub.SubscriberId = 0;
                        Sub.ViewOrder    = viewOrder;
                        Sub.IsEnabled    = isChecked;
                        Sub.Role         = role;
                        Sub.PaymentProviderProperties = paymentProviderProperties;
                        Sub.TaxPercent = taxPercent;
                        Controller.UpdateSubscriberPaymentProvider(Sub);
                    }
                }
            }
        }
Esempio n. 2
0
        private void ShowPaymentProviders()
        {
            // Payment Providers
            List <PaymentProviderInfo> lst = Controller.GetPaymentProviders(CurrentLanguage);

            if (lst.Count == 0)
            {
                lst = Controller.GetPaymentProviders(DefaultLanguage);
            }
            if (lst.Count > 0)
            {
                // Lets populate thbe Usergroups into Collection
                RoleController RoleController = new RoleController();
                ArrayList      colArrayList   = RoleController.GetPortalRoles(PortalId);

                // Create a ListItemCollection to hold the Roles
                ListItemCollection colRoles = new ListItemCollection();

                // Add all defined Roles to the List
                foreach (RoleInfo Role in colArrayList)
                {
                    ListItem RoleListItem = new ListItem();
                    RoleListItem.Text  = Role.RoleName;
                    RoleListItem.Value = Role.RoleID.ToString();
                    colRoles.Add(RoleListItem);
                }
                ListItem SelectRoleListItem = new ListItem();
                SelectRoleListItem.Text  = Localization.GetString("SelectRole.Text", this.LocalResourceFile);
                SelectRoleListItem.Value = "-1";
                colRoles.Insert(0, SelectRoleListItem);

                // And now we need the Payment Provider for this subscriber (Portal)
                List <SubscriberPaymentProviderInfo> lstSub = Controller.GetSubscriberPaymentProviders(PortalId, 0);

                Table myTable = new Table();
                myTable.Attributes.Add("class", "dnnGrid");
                myTable.ID = "tblPaymentProvider";

                // First the header row
                TableHeaderRow  tr = new TableHeaderRow();
                TableHeaderCell th = new TableHeaderCell();
                th.Attributes.Add("class", "dnnGridHeader");

                LabelControl dnnLbl = LoadControl("~/controls/LabelControl.ascx") as LabelControl;
                dnnLbl.HelpText = Localization.GetString("ppEnabled.Help", this.LocalResourceFile);
                dnnLbl.Text     = Localization.GetString("ppEnabled.Header", this.LocalResourceFile);
                th.Controls.Add(dnnLbl);
                tr.Controls.Add(th);

                th = new TableHeaderCell();
                th.Attributes.Add("class", "dnnGridHeader");
                dnnLbl          = LoadControl("~/controls/LabelControl.ascx") as LabelControl;
                dnnLbl.Text     = Localization.GetString("Vieworder.Header", this.LocalResourceFile);
                dnnLbl.HelpText = Localization.GetString("Vieworder.Help", this.LocalResourceFile);
                th.Controls.Add(dnnLbl);
                tr.Controls.Add(th);

                th = new TableHeaderCell();
                th.Attributes.Add("class", "dnnGridHeader");
                dnnLbl          = LoadControl("~/controls/LabelControl.ascx") as LabelControl;
                dnnLbl.Text     = Localization.GetString("Paymentprovider.Header", this.LocalResourceFile);
                dnnLbl.HelpText = Localization.GetString("Paymentprovider.Help", this.LocalResourceFile);
                th.Controls.Add(dnnLbl);
                tr.Controls.Add(th);

                th = new TableHeaderCell();
                th.Attributes.Add("class", "dnnGridHeader");
                dnnLbl          = LoadControl("~/controls/LabelControl.ascx") as LabelControl;
                dnnLbl.Text     = Localization.GetString("Price.Header", this.LocalResourceFile);
                dnnLbl.HelpText = Localization.GetString("Price.Help", this.LocalResourceFile);
                th.Controls.Add(dnnLbl);
                tr.Controls.Add(th);

                th = new TableHeaderCell();
                th.Attributes.Add("class", "dnnGridHeader");
                dnnLbl          = LoadControl("~/controls/LabelControl.ascx") as LabelControl;
                dnnLbl.Text     = Localization.GetString("Tax.Header", this.LocalResourceFile);
                dnnLbl.HelpText = Localization.GetString("Tax.Help", this.LocalResourceFile);
                th.Controls.Add(dnnLbl);
                tr.Controls.Add(th);

                th = new TableHeaderCell();
                th.Attributes.Add("class", "dnnGridHeader");
                dnnLbl          = LoadControl("~/controls/LabelControl.ascx") as LabelControl;
                dnnLbl.Text     = Localization.GetString("Userrole.Header", this.LocalResourceFile);
                dnnLbl.HelpText = Localization.GetString("Userrole.Help", this.LocalResourceFile);
                th.Controls.Add(dnnLbl);
                tr.Controls.Add(th);

                myTable.Controls.Add(tr);

                // and next the Provider Rows
                TableRow  myRow;
                TableCell tblCell;
                int       i = 0;
                foreach (PaymentProviderInfo pp in lst)
                {
                    // Skip if no Control defined
                    if (pp.ProviderControl.Trim() == String.Empty)
                    {
                        continue;
                    }

                    i++;

                    //Is this Provider in the List for the Subscriber (Portal) ?
                    SubscriberPaymentProviderInfo Sub = lstSub.Find(sub => sub.PaymentProviderId == pp.PaymentProviderId);

                    bool   isChecked = (Sub != null && Sub.IsEnabled);
                    string itemStyle = (i % 2 == 1 ? "dnnGridItem" : "dnnGridAltItem");

                    myRow = new TableRow();

                    // The Checkbox cell (first Column)
                    tblCell = new TableCell();
                    tblCell.Attributes.Add("class", itemStyle);
                    CheckBox chk = new CheckBox();
                    chk.ID = "chkEnabled" + pp.PaymentProviderId.ToString();
                    chk.EnableViewState = true;
                    chk.Checked         = isChecked;
                    tblCell.Controls.Add(chk);
                    myRow.Controls.Add(tblCell);

                    // The Vieworder cell
                    tblCell = new TableCell();
                    tblCell.Attributes.Add("class", itemStyle);
                    TextBox txt = new TextBox();
                    txt.ID = "txtViewOrder" + pp.PaymentProviderId.ToString();
                    txt.EnableViewState = true;
                    txt.Columns         = 2;
                    if (Sub != null)
                    {
                        txt.Text = Sub.ViewOrder.ToString();
                    }
                    else
                    {
                        txt.Text = "0";
                    }
                    tblCell.Controls.Add(txt);
                    myRow.Controls.Add(tblCell);

                    // The PaymentProvider-Cell
                    tblCell = new TableCell();
                    tblCell.Attributes.Add("class", itemStyle);

                    PaymentProviderBase ctrl = this.LoadControl(@"~\DesktopModules\BBStore\Providers\Payment\" + pp.ProviderControl.Trim() + ".ascx") as PaymentProviderBase;
                    ctrl.DisplayMode     = ViewMode.Edit;
                    ctrl.Title           = pp.ProviderName;
                    ctrl.EnableViewState = true;
                    if (Sub != null)
                    {
                        ctrl.Properties = Sub.PaymentProviderProperties;
                        ctrl.Cost       = Sub.Cost;
                    }
                    ctrl.ID = "pp" + pp.PaymentProviderId.ToString();
                    tblCell.Controls.Add(ctrl);

                    myRow.Controls.Add(tblCell);


                    // We need to create the taxpercent control first (needed by TaxControl)
                    TextBox txtTaxPercent = new TextBox();
                    txtTaxPercent.ID = "txtTaxPercent" + pp.PaymentProviderId.ToString();
                    txtTaxPercent.EnableViewState = true;
                    txtTaxPercent.Columns         = 6;
                    if (Sub != null)
                    {
                        txtTaxPercent.Text = String.Format("{0:f1}", Sub.TaxPercent);
                    }
                    else
                    {
                        txtTaxPercent.Text = String.Format("{0:f1}", 0.00m);
                    }

                    // The Price cell
                    tblCell = new TableCell();
                    tblCell.Attributes.Add("class", itemStyle);

                    Label lbl = new Label();
                    lbl.Text = LocalizeString("lblCost.Text") + ": ";
                    tblCell.Controls.Add(lbl);

                    TaxControl txtPrice = LoadControl("Controls/TaxControl.ascx") as TaxControl;
                    txtPrice.ID = "txtPrice" + pp.PaymentProviderId.ToString();
                    txtPrice.EnableViewState = true;
                    txtPrice.Orientation     = "verticalhorizontal";
                    txtPrice.Mode            = "gross";
                    txtPrice.PercentControl  = txtTaxPercent;
                    if (Sub != null)
                    {
                        txtPrice.Value = Sub.Cost;
                    }
                    else
                    {
                        txtPrice.Value = 0.00m;
                    }
                    tblCell.Controls.Add(txtPrice);

                    tblCell.Controls.Add(new HtmlGenericControl("hr"));

                    lbl      = new Label();
                    lbl.Text = LocalizeString("lblCostPercent.Text") + ": ";
                    tblCell.Controls.Add(lbl);

                    TextBox txtCostPercent = new TextBox();
                    txtCostPercent.ID = "txtCostPercent" + pp.PaymentProviderId.ToString();
                    txtCostPercent.EnableViewState = true;
                    txtCostPercent.Columns         = 6;
                    if (Sub != null)
                    {
                        txtCostPercent.Text = String.Format("{0:f1}", Sub.CostPercent);
                    }
                    else
                    {
                        txtCostPercent.Text = String.Format("{0:f1}", 0.0m);
                    }

                    tblCell.Controls.Add(txtCostPercent);
                    myRow.Controls.Add(tblCell);

                    // The Tax cell
                    tblCell = new TableCell();
                    tblCell.Attributes.Add("class", itemStyle);
                    tblCell.Controls.Add(txtTaxPercent);
                    myRow.Controls.Add(tblCell);

                    // The RoleDropdown Column
                    tblCell = new TableCell();
                    tblCell.Attributes.Add("class", itemStyle);

                    DropDownList ddl = new DropDownList();
                    ddl.ID = "ddlUserRole" + pp.PaymentProviderId.ToString();
                    ddl.EnableViewState = true;
                    ddl.DataSource      = colRoles;
                    ddl.DataBind();
                    if (Sub != null)
                    {
                        ddl.SelectedValue = Sub.Role.ToString();
                    }
                    tblCell.Controls.Add(ddl);

                    myRow.Controls.Add(tblCell);

                    myTable.Controls.Add(myRow);
                }
                phPayment.Controls.Add(myTable);
            }
            else
            {
                string message = Localization.GetString("NoPaymentprovider.Message", this.LocalResourceFile);
                DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, message, ModuleMessage.ModuleMessageType.YellowWarning);
            }
        }