Ejemplo n.º 1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                CartInfo myCart = Controller.GetCart(PortalSettings.PortalId, CartId);
                if (myCart != null)
                {
                    List <CartProductInfo> myProducts = _controller.GetCartProducts(CartId);

                    TemplateControl tp = LoadControl("controls/TemplateControl.ascx") as TemplateControl;
                    tp.Key = "MiniCart";
                    string template = tp.GetTemplate((string)Settings["Template"]);

                    ModuleController objModules = new ModuleController();
                    ModuleInfo       cartModule = objModules.GetModuleByDefinition(PortalSettings.PortalId, "BBStore Cart");

                    Hashtable storeSettings = _controller.GetStoreSettings(PortalSettings.PortalId);
                    bool      showNetPrice  = (storeSettings["ShowNetpriceInCart"].ToString() == "0");
                    decimal   total         = myCart.OrderTotal + myCart.AdditionalTotal;

                    if (showNetPrice == false)
                    {
                        total += myCart.OrderTax + myCart.AdditionalTax;
                    }

                    decimal productCount = 0;
                    foreach (CartProductInfo cp in myProducts)
                    {
                        productCount += cp.Quantity;
                    }
                    template = template.Replace("[PRODUCTS]", productCount.ToString("f0"));
                    template = template.Replace("[TOTAL]", total.ToString("f2"));
                    template = template.Replace("[CURRENCY]", myCart.Currency);
                    template = template.Replace("[CARTLINK]", (cartModule == null ? "" : Globals.NavigateURL(cartModule.TabID)));
                    template = template.Replace("[CHECKOUTLINK]", (cartModule == null ? "" : Globals.NavigateURL(cartModule.TabID, "", "action=checkout")));

                    ltrMiniCart.Text = template;
                }
            }
            catch (Exception exc)
            {
                //Module failed to load
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 2
0
        //public ContactAddressInfo ContactAddress
        //{
        //    get
        //    {
        //        if (_contactAddress != null)
        //            return _contactAddress;

        //        if (Request.Cookies["ContactAddress"] != null)
        //        {
        //            ContactAddressInfo contact = (ContactAddressInfo) VfpInterop.DeserializeFromBase64String(Request.Cookies["ContactAddress"].Value);
        //            if (contact != null && contact.Lastname != null)
        //               _contactAddress = contact;
        //        }
        //        return null;
        //    }
        //    set
        //    {
        //        _contactAddress = value;
        //        string strVal = VfpInterop.SerializeToBase64String(value);
        //        if (Response.Cookies["ContactAddress"] != null)
        //            Response.Cookies["ContactAddress"].Value = strVal;
        //        else
        //        {
        //            HttpCookie cookie = new HttpCookie("ContactAddress");
        //            cookie.Value = strVal;
        //            Response.Cookies.Add(cookie);
        //        }
        //    }
        //}
        #endregion

        #region Event Handlers
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsConfigured)
                {
                    string message = Localization.GetString("Configure.Message", this.LocalResourceFile);
                    DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, message, ModuleMessage.ModuleMessageType.YellowWarning);
                    pnlContactView.Visible = false;
                }
                else
                {
                    TemplateControl tp = LoadControl("controls/TemplateControl.ascx") as TemplateControl;
                    tp.Key    = "Contact";
                    _template = tp.GetTemplate((string)Settings["ProductTemplate"]);

                    if (!Page.IsPostBack)
                    {
                        ListController          ListController = new ListController();
                        ListEntryInfoCollection Countries      = ListController.GetListEntryInfoCollection("Country");


                        Hashtable storeSettings = Controller.GetStoreSettings(PortalId);

                        ddlCountry.DataSource     = Countries;
                        ddlCountry.DataTextField  = "Text";
                        ddlCountry.DataValueField = "Value";
                        ddlCountry.DataBind();

                        if (!String.IsNullOrEmpty((string)storeSettings["VendorCountry"]))
                        {
                            ddlCountry.SelectedValue = (string)storeSettings["VendorCountry"];
                        }

                        // Prefill data if logged in user
                        ContactAddressInfo contactAddress = null;
                        if (Request.Cookies["ContactAddress"] != null)
                        {
                            contactAddress = (ContactAddressInfo)VfpInterop.DeserializeFromBase64String(Request.Cookies["ContactAddress"].Value);
                        }

                        if (contactAddress == null)
                        {
                            if (Request.IsAuthenticated)
                            {
                                UserInfo usr = UserController.GetUserById(PortalId, UserId);
                                if (usr != null)
                                {
                                    txtContactCompany.Text    = (usr.Profile.GetPropertyValue("Company") ?? "");
                                    txtContactPrefix.Text     = (usr.Profile.GetPropertyValue("Prefix") ?? "");
                                    txtContactFirstname.Text  = (usr.FirstName ?? "");
                                    txtContactLastname.Text   = (usr.LastName ?? "");
                                    txtContactUnit.Text       = (usr.Profile.GetPropertyValue("Unit") ?? "");
                                    txtContactStreet.Text     = (usr.Profile.Street ?? "");
                                    txtContactRegion.Text     = (usr.Profile.GetPropertyValue("Region") ?? "");
                                    txtContactPostalcode.Text = (usr.Profile.PostalCode ?? "");
                                    txtContactCity.Text       = (usr.Profile.City ?? "");
                                    if (ddlCountry.Items.FindByText(usr.Profile.Country ?? "") != null)
                                    {
                                        ddlCountry.Items.FindByText(usr.Profile.Country ?? "").Selected = true;
                                    }
                                    txtContactTelephone.Text = (usr.Profile.Telephone ?? "");
                                    txtContactFax.Text       = (usr.Profile.Fax ?? "");
                                    txtContactEmail.Text     = (usr.Email ?? "");
                                }
                            }
                        }
                        else
                        {
                            txtContactCompany.Text    = contactAddress.Company;
                            txtContactPrefix.Text     = contactAddress.Prefix;
                            txtContactFirstname.Text  = contactAddress.Firstname;
                            txtContactLastname.Text   = contactAddress.Lastname;
                            txtContactUnit.Text       = contactAddress.Unit;
                            txtContactStreet.Text     = contactAddress.Street;
                            txtContactRegion.Text     = contactAddress.Region;
                            txtContactPostalcode.Text = contactAddress.PostalCode;
                            txtContactCity.Text       = contactAddress.City;
                            if (ddlCountry.Items.FindByText(contactAddress.Country) != null)
                            {
                                ddlCountry.Items.FindByText(contactAddress.Country).Selected = true;
                            }
                            txtContactTelephone.Text = contactAddress.Telephone;
                            txtContactFax.Text       = contactAddress.Fax;
                            txtContactEmail.Text     = contactAddress.Email;
                            txtContactCell.Text      = contactAddress.Cell;
                        }
                    }
                    string requiredText = Localization.GetString("Required.Validator", this.LocalResourceFile);
                    bool   required;

                    trCompany.Visible      = Convert.ToBoolean(Settings["ShowCompany"]);
                    lblContactCompany.Text = Localization.GetString("lblContactCompany.Text", this.LocalResourceFile) +
                                             (Convert.ToBoolean(Settings["MandCompany"]) ? " *" : "");
                    txtContactCompany.TextChanged += txt_TextChanged;
                    required = Convert.ToBoolean(Settings["MandCompany"]);
                    valContactCompany.Visible = required;
                    if (required)
                    {
                        valContactCompany.Text     = requiredText;
                        txtContactCompany.CssClass = "dnnFormRequired";
                    }

                    trPrefix.Visible      = Convert.ToBoolean(Settings["ShowPrefix"]);
                    lblContactPrefix.Text = Localization.GetString("lblContactPrefix.Text", this.LocalResourceFile) +
                                            (Convert.ToBoolean(Settings["MandPrefix"]) ? " *" : "");
                    txtContactPrefix.TextChanged += txt_TextChanged;
                    required = Convert.ToBoolean(Settings["MandPrefix"]);
                    valContactPrefix.Visible = required;
                    if (required)
                    {
                        valContactPrefix.Text     = requiredText;
                        txtContactPrefix.CssClass = "dnnFormRequired";
                    }

                    trFirstname.Visible      = Convert.ToBoolean(Settings["ShowFirstname"]);
                    lblContactFirstname.Text = Localization.GetString("lblContactFirstname.Text", this.LocalResourceFile) +
                                               (Convert.ToBoolean(Settings["MandFirstname"]) ? " *" : "");
                    txtContactFirstname.TextChanged += txt_TextChanged;
                    required = Convert.ToBoolean(Settings["MandFirstname"]);
                    valContactFirstname.Visible = required;
                    if (required)
                    {
                        valContactFirstname.Text     = requiredText;
                        txtContactFirstname.CssClass = "dnnFormRequired";
                    }

                    trLastname.Visible      = Convert.ToBoolean(Settings["ShowLastname"]);
                    lblContactLastname.Text = Localization.GetString("lblContactLastname.Text", this.LocalResourceFile) +
                                              (Convert.ToBoolean(Settings["MandLastname"]) ? " *" : "");
                    txtContactLastname.TextChanged += txt_TextChanged;
                    required = Convert.ToBoolean(Settings["MandLastname"]);
                    valContactLastname.Visible = required;
                    if (required)
                    {
                        valContactLastname.Text     = requiredText;
                        txtContactLastname.CssClass = "dnnFormRequired";
                    }

                    trStreet.Visible      = Convert.ToBoolean(Settings["ShowStreet"]);
                    lblContactStreet.Text = Localization.GetString("lblContactStreet.Text", this.LocalResourceFile) +
                                            (Convert.ToBoolean(Settings["MandStreet"]) ? " *" : "");
                    txtContactStreet.TextChanged += txt_TextChanged;
                    required = Convert.ToBoolean(Settings["MandStreet"]);
                    valContactStreet.Visible = required;
                    if (required)
                    {
                        valContactStreet.Text     = requiredText;
                        txtContactStreet.CssClass = "dnnFormRequired";
                    }

                    trRegion.Visible      = Convert.ToBoolean(Settings["ShowRegion"]);
                    lblContactRegion.Text = Localization.GetString("lblContactRegion.Text", this.LocalResourceFile) +
                                            (Convert.ToBoolean(Settings["MandRegion"]) ? " *" : "");
                    txtContactRegion.TextChanged += txt_TextChanged;
                    required = Convert.ToBoolean(Settings["MandRegion"]);
                    valContactRegion.Visible = required;
                    if (required)
                    {
                        valContactRegion.Text     = requiredText;
                        txtContactRegion.CssClass = "dnnFormRequired";
                    }

                    trCity.Visible            = Convert.ToBoolean(Settings["ShowCity"]);
                    lblContactPostalcode.Text = Localization.GetString("lblContactPostalcode.Text", this.LocalResourceFile) +
                                                (Convert.ToBoolean(Settings["MandCity"]) ? " *" : "");
                    txtContactCity.TextChanged += txt_TextChanged;
                    required = Convert.ToBoolean(Settings["MandCity"]);
                    valContactCity.Visible = required;
                    if (required)
                    {
                        valContactCity.Text     = requiredText;
                        txtContactCity.CssClass = "dnnFormRequired";
                    }

                    trCountry.Visible      = Convert.ToBoolean(Settings["ShowCountry"]);
                    lblContactCountry.Text = Localization.GetString("lblContactCountry.Text", this.LocalResourceFile) +
                                             (Convert.ToBoolean(Settings["MandCountry"]) ? " *" : "");
                    ddlCountry.TextChanged += txt_TextChanged;
                    required = Convert.ToBoolean(Settings["MandCountry"]);
                    valContactCountry.Visible = required;
                    if (required)
                    {
                        valContactCountry.Text = requiredText;
                        ddlCountry.CssClass    = "dnnFormRequired";
                    }

                    trPhone.Visible          = Convert.ToBoolean(Settings["ShowPhone"]);
                    lblContactTelephone.Text = Localization.GetString("lblContactTelephone.Text", this.LocalResourceFile) +
                                               (Convert.ToBoolean(Settings["MandPhone"]) ? " *" : "");
                    txtContactTelephone.TextChanged += txt_TextChanged;
                    required = Convert.ToBoolean(Settings["MandPhone"]);
                    valContactTelephone.Visible = required;
                    if (required)
                    {
                        valContactTelephone.Text     = requiredText;
                        txtContactTelephone.CssClass = "dnnFormRequired";
                    }

                    trCell.Visible      = Convert.ToBoolean(Settings["ShowCell"]);
                    lblContactCell.Text = Localization.GetString("lblContactCell.Text", this.LocalResourceFile) +
                                          (Convert.ToBoolean(Settings["MandCell"]) ? " *" : "");
                    txtContactCell.TextChanged += txt_TextChanged;
                    required = Convert.ToBoolean(Settings["MandCell"]);
                    valContactCell.Visible = required;
                    if (required)
                    {
                        valContactCell.Text     = requiredText;
                        txtContactCell.CssClass = "dnnFormRequired";
                    }

                    trFax.Visible      = Convert.ToBoolean(Settings["ShowFax"]);
                    lblContactFax.Text = Localization.GetString("lblContactFax.Text", this.LocalResourceFile) +
                                         (Convert.ToBoolean(Settings["MandFax"]) ? " *" : "");
                    txtContactFax.TextChanged += txt_TextChanged;
                    required = Convert.ToBoolean(Settings["MandFax"]);
                    valContactFax.Visible = required;
                    if (required)
                    {
                        valContactFax.Text     = requiredText;
                        txtContactFax.CssClass = "dnnFormRequired";
                    }

                    trEmail.Visible      = Convert.ToBoolean(Settings["ShowEmail"]);
                    lblContactEmail.Text = Localization.GetString("lblContactEmail.Text", this.LocalResourceFile) +
                                           (Convert.ToBoolean(Settings["MandEmail"]) ? " *" : "");
                    txtContactEmail.TextChanged += txt_TextChanged;
                    required = Convert.ToBoolean(Settings["MandEmail"]);
                    valContactEmail.Visible = required;
                    if (required)
                    {
                        valContactEmail.Text     = requiredText;
                        txtContactEmail.CssClass = "dnnFormRequired";
                    }


                    Products = Controller.GetContactProductsByCartId(PortalId, CartId, CurrentLanguage);
                    if (Products.Count > 0)
                    {
                        lstProducts.DataSource = Products;
                        lstProducts.DataBind();
                    }
                    else
                    {
                        lstProducts.Visible = false;
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 3
0
        private void MailRequest(ContactAddressInfo contactAddress)
        {
            Hashtable storeSettings = Controller.GetStoreSettings(PortalId);

            string storeEmail    = (string)storeSettings["StoreEmail"] ?? "";
            string storeName     = (string)storeSettings["StoreName"] ?? "";
            string storeReplyTo  = (string)storeSettings["StoreReplyTo"] ?? "";
            string storeAdmin    = (string)storeSettings["StoreAdmin"] ?? "";
            string vendorName    = (string)storeSettings["VendorName"] ?? "";
            string vendorStreet1 = (string)storeSettings["VendorStreet1"] ?? "";
            string vendorStreet2 = (string)storeSettings["VendorStreet2"] ?? "";
            string vendorZip     = (string)storeSettings["VendorZip"] ?? "";
            string vendorCity    = (string)storeSettings["VendorCity"] ?? "";
            string shippingType  = (string)storeSettings["ShippingType"] ?? "";
            string headerMessage = Localization.GetString("EmailHeader.Message", this.LocalResourceFile);
            string footerMessage = Localization.GetString("EmailFooter.Message", this.LocalResourceFile);

            TemplateControl tp = LoadControl("controls/TemplateControl.ascx") as TemplateControl;

            tp.Key = "Request";
            string template = tp.GetTemplate((string)(Settings["Template"] ?? "Request"));

            template = template.Replace("[BBSTORE-VENDORIMAGE]",
                                        (PortalSettings.LogoFile != string.Empty ? "<img src=\"cid:Logo\" />" : ""));


            template = template.Replace("[BBSTORE-HEADERMESSAGE]", headerMessage);

            template = template.Replace("[BBSTORE-ORDERTEXT]", Localization.GetString("EmailOrder.Text", this.LocalResourceFile));
            template = template.Replace("[BBSTORE-INFOTEXT]", Localization.GetString("EmailInfo.Text", this.LocalResourceFile));
            template = template.Replace("[BBSTORE-ADDRESSINFOTEXT]", Localization.GetString("EmailAddressInfo.Text", this.LocalResourceFile));

            template = template.Replace("[BBSTORE-PRODUCTSTEXT]", Localization.GetString("EmailProducts.Text", this.LocalResourceFile));
            template = template.Replace("[BBSTORE-COMMENTSTEXT]", Localization.GetString("EmailComments.Text", this.LocalResourceFile));
            template = template.Replace("[BBSTORE-FIRMATEXT]", Localization.GetString("EmailCompany.Text", this.LocalResourceFile));
            template = template.Replace("[BBSTORE-NAMETEXT]", Localization.GetString("EmailName.Text", this.LocalResourceFile));
            template = template.Replace("[BBSTORE-ADDRESSTEXT]", Localization.GetString("EmailAddress.Text", this.LocalResourceFile));
            template = template.Replace("[BBSTORE-CITYTEXT]", Localization.GetString("EmailCity.Text", this.LocalResourceFile));
            template = template.Replace("[BBSTORE-ZIPTEXT]", Localization.GetString("EmailZip.Text", this.LocalResourceFile));
            template = template.Replace("[BBSTORE-COUNTRYTEXT]", Localization.GetString("EmailCountry.Text", this.LocalResourceFile));
            template = template.Replace("[BBSTORE-PHONETEXT]", Localization.GetString("EmailPhone.Text", this.LocalResourceFile));
            template = template.Replace("[BBSTORE-FAXTEXT]", Localization.GetString("EmailFax.Text", this.LocalResourceFile));
            template = template.Replace("[BBSTORE-EMAILTEXT]", Localization.GetString("EmailEmail.Text", this.LocalResourceFile));
            template = template.Replace("[BBSTORE-CELLTEXT]", Localization.GetString("EmailCell.Text", this.LocalResourceFile));

            template = template.Replace("[BBSTORE-REQUESTNOTEXT]", Localization.GetString("EmailRequestNo.Text", this.LocalResourceFile));
            template = template.Replace("[BBSTORE-REQUESTDATETEXT]", Localization.GetString("EmailRequestDate.Text", this.LocalResourceFile));
            template = template.Replace("[BBSTORE-REQUESTNO]", contactAddress.ContactAddressId.ToString());
            template = template.Replace("[BBSTORE-REQUESTDATE]", DateTime.Now.Date.ToString("D"));

            template = template.Replace("[BBSTORE-REQCOMPANY]", contactAddress.Company);
            template = template.Replace("[BBSTORE-REQNAME]", (contactAddress.Prefix + " " + contactAddress.Firstname + " " + contactAddress.Lastname).Trim());
            template = template.Replace("[BBSTORE-REQSTREET]", (contactAddress.Street + " " + contactAddress.Unit).Trim());
            template = template.Replace("[BBSTORE-REQCITY]", contactAddress.City);
            template = template.Replace("[BBSTORE-REQZIP]", contactAddress.PostalCode);
            template = template.Replace("[BBSTORE-REQCOUNTRY]", contactAddress.Country);
            template = template.Replace("[BBSTORE-REQPHONE]", contactAddress.Telephone);
            template = template.Replace("[BBSTORE-REQCELL]", contactAddress.Cell);
            template = template.Replace("[BBSTORE-REQFAX]", contactAddress.Fax);
            template = template.Replace("[BBSTORE-REQEMAIL]", contactAddress.Email);

            template = template.Replace("[BBSTORE-VENDORNAME]", vendorName);
            template = template.Replace("[BBSTORE-VENDORSTREET1]", vendorStreet1);
            template = template.Replace("[BBSTORE-VENDORSTREET2]", vendorStreet2);
            template = template.Replace("[BBSTORE-VENDORZIP]", vendorZip);
            template = template.Replace("[BBSTORE-VENDORCITY]", vendorCity);

            string requestItems = "<tr class=\"Normal\" style=\"background-color:#ECECEC\">" +
                                  "  <th style=\"vertical-align:top;text-align:left\">" + Localization.GetString("ItemNo.Header", this.LocalResourceFile) + "</th>" +
                                  "  <th style=\"vertical-align:top;text-align:left\">" + Localization.GetString("Product.Header", this.LocalResourceFile) + "</th>" +
                                  "</tr>";

            string productTemplate = "<tr class=\"Normal\" style=\"[STYLE]\">" +
                                     "  <td style=\"vertical-align:top;text-align:left\">[PRODUCTITEMNO]</td>" +
                                     "  <td style=\"vertical-align:top;text-align:left\">[PRODUCTNAME]<br><span style=\"font-size:10px\">[PRODUCTSHORTDESCRIPTION]</span></td>" +
                                     "</tr>";

            int loop = 0;

            foreach (SimpleProductInfo product in Products)
            {
                requestItems += productTemplate;
                string artname = product.Name.Trim();
                requestItems = requestItems.Replace("[PRODUCTNAME]", product.Name.Trim());
                requestItems = requestItems.Replace("[PRODUCTITEMNO]", product.ItemNo.Trim());
                requestItems = requestItems.Replace("[PRODUCTSHORTDESCRIPTION]", product.ShortDescription);
                if (loop % 2 == 0)
                {
                    requestItems = requestItems.Replace("[STYLE]", "background-color:#F8F8F8");
                }
                else
                {
                    requestItems = requestItems.Replace("[STYLE]", "background-color:#FFFFFF");
                }
                loop++;
            }
            template = template.Replace("[BBSTORE-REQUESTITEMS]", requestItems);

            template = template.Replace("[BBSTORE-COMMENT]", txtRequest.Text);
            template = template.Replace("[BBSTORE-FOOTERMESSAGE]", footerMessage);

            try
            {
                // http://www.systemnetmail.com

                MailMessage mail = new MailMessage();

                //set the addresses
                string smtpServer         = DotNetNuke.Entities.Host.Host.SMTPServer;
                string smtpAuthentication = DotNetNuke.Entities.Host.Host.SMTPAuthentication;

                string smtpUsername = DotNetNuke.Entities.Host.Host.SMTPUsername;
                string smtpPassword = DotNetNuke.Entities.Host.Host.SMTPPassword;

                mail.From = new MailAddress("\"" + storeName.Trim() + "\" <" + storeEmail.Trim() + ">");
                mail.To.Add(contactAddress.Email);
                if (storeAdmin != string.Empty)
                {
                    mail.To.Add(storeAdmin.Trim());
                }
                if (storeReplyTo != string.Empty)
                {
                    mail.ReplyTo = new MailAddress(storeReplyTo.Trim());
                }

                //set the content
                mail.Subject = ((string)Settings["EmailSubject"]).Replace("[REQUESTNO]", contactAddress.ContactAddressId.ToString());

                AlternateView av1      = AlternateView.CreateAlternateViewFromString(template, null, "text/html");
                string        logoFile = MapPath(PortalSettings.HomeDirectory + PortalSettings.LogoFile);

                if (PortalSettings.LogoFile != string.Empty && File.Exists(logoFile))
                {
                    LinkedResource linkedResource = new LinkedResource(logoFile);
                    linkedResource.ContentId             = "Logo";
                    linkedResource.ContentType.Name      = logoFile;
                    linkedResource.ContentType.MediaType = "image/jpeg";
                    av1.LinkedResources.Add(linkedResource);
                }
                mail.AlternateViews.Add(av1);
                mail.IsBodyHtml = true;

                SmtpClient emailClient = new SmtpClient(smtpServer);
                if (smtpAuthentication == "1")
                {
                    System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential(smtpUsername, smtpPassword);
                    emailClient.UseDefaultCredentials = false;
                    emailClient.Credentials           = SMTPUserInfo;
                }
                emailClient.Send(mail);
            }
            catch (SmtpException sex)
            {
                Exceptions.LogException(sex);
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
            }
        }
Ejemplo n.º 4
0
        private Control RenderItem(SimpleProductInfo product)
        {
            bool showNetPrice = (StoreSettings.Count > 0) && ((string)StoreSettings["ShowNetpriceInCart"] == "0");

            decimal unitCost         = product.UnitCost;
            decimal originalUnitCost = product.OriginalUnitCost;
            decimal taxPercent       = product.TaxPercent;

            decimal price         = 0.00m;
            decimal originalPrice = 0.00m;
            string  tax           = "";

            if (showNetPrice)
            {
                price         = unitCost + (ProductOptionSelect != null ? ProductOptionSelect.PriceAlteration : 0.00m);
                originalPrice = originalUnitCost + (ProductOptionSelect != null ? ProductOptionSelect.PriceAlteration : 0.00m);
                tax           = Localization.GetString("ExcludeTax.Text", this.LocalResourceFile);
            }
            else
            {
                price         = decimal.Round((unitCost + (ProductOptionSelect != null ? ProductOptionSelect.PriceAlteration : 0.00m)) * (100 + taxPercent) / 100, 2);
                originalPrice = decimal.Round((originalUnitCost + (ProductOptionSelect != null ? ProductOptionSelect.PriceAlteration : 0.00m)) * (100 + taxPercent) / 100, 2);
                tax           = Localization.GetString("IncludeTax.Text", this.LocalResourceFile);
            }

            string template;
            int    imageWidth = 200;

            TemplateControl tp = LoadControl("controls/TemplateControl.ascx") as TemplateControl;

            tp.Key   = "ProductList";
            template = tp.GetTemplate((string)Settings["Template"]);

            //Template = ProductTemplate;

            template = template.Replace("[ITEMNO]", product.ItemNo);
            template = template.Replace("[PRODUCTSHORTDESCRIPTION]", product.ShortDescription);
            template = template.Replace("[PRODUCTDESCRIPTION]", product.ProductDescription);
            template = template.Replace("[TITLE]", product.Name);
            template = template.Replace("[IMAGEURL]", product.Image);

            if (product.HideCost)
            {
                template = template.Replace("[PRICE]", Localization.GetString("AskOffer.Text", this.LocalResourceFile));
            }
            else
            {
                template = template.Replace("[PRICE]", String.Format("{0:n2}", price));
            }

            if (originalPrice > price && !product.HideCost)
            {
                template = template.Replace("[ORIGINALPRICE]", String.Format("{0:n2} {1}", originalPrice, Currency));
            }
            else
            {
                template = template.Replace("[ORIGINALPRICE]", "");
            }

            if (!product.HideCost)
            {
                template = template.Replace("[CURRENCY]", Currency);
            }
            else
            {
                template = template.Replace("[CURRENCY]", "");
            }


            if (taxPercent > 0.00m && !product.HideCost)
            {
                template = template.Replace("[TAX]", String.Format(tax, taxPercent));
            }
            else
            {
                template = template.Replace("[TAX]", "");
            }

            if (product.UnitId > -1)
            {
                UnitInfo unit = Controller.GetUnit(product.UnitId, CurrentLanguage);
                template = template.Replace("[UNIT]", unit.Symbol);
            }
            else
            {
                template = template.Replace("[UNIT]", "");
            }


            int linkCnt = 0;

            while (template.Contains("[LINK]"))
            {
                linkCnt++;
                template = template.ReplaceFirst("[LINK]", "<asp:Literal ID=\"ltrLink" + linkCnt.ToString() + "\" runat=\"server\" />");
            }

            if (template.IndexOf("[IMAGE") > -1)
            {
                if (template.IndexOf("[IMAGE:") > -1)
                {
                    string width = template.Substring(template.IndexOf("[IMAGE:") + 7);
                    width = width.Substring(0, width.IndexOf("]"));
                    if (Int32.TryParse(width, out imageWidth) == false)
                    {
                        imageWidth = 200;
                    }
                    template = template.Replace("[IMAGE:" + width + "]", "<asp:PlaceHolder ID=\"phimgProduct\" runat=\"server\" />");
                }
                else
                {
                    template = template.Replace("[IMAGE]", "<asp:PlaceHolder ID=\"phimgProduct\" runat=\"server\" />");
                }
            }
            while (template.IndexOf("[RESOURCE:") > -1)
            {
                string resKey = template.Substring(template.IndexOf("[RESOURCE:") + 10);
                resKey   = resKey.Substring(0, resKey.IndexOf("]"));
                template = template.Replace("[RESOURCE:" + resKey + "]", Localization.GetString(resKey, this.LocalResourceFile));
            }


            while (template.IndexOf("[FEATURE:") > -1)
            {
                string token = template.Substring(template.IndexOf("[FEATURE:") + 9);
                token = token.Substring(0, token.IndexOf("]"));
                string prop = token.Substring(token.IndexOf(".") + 1);
                token = token.Substring(0, token.IndexOf(".")).ToUpper();

                string value             = "";
                FeatureGridValueInfo fgv = Controller.GetFeatureGridValueByProductAndToken(PortalId, product.SimpleProductId, CurrentLanguage, token);
                if (fgv != null)
                {
                    PropertyInfo p = fgv.GetType().GetProperty(prop);
                    if (p != null && p.CanRead)
                    {
                        value = p.GetValue(fgv, null).ToString();
                    }
                }
                template = template.Replace("[FEATURE:" + token + "." + prop + "]", value);
            }

            Control ctrl = ParseControl(template);

            for (int i = 1; i < linkCnt + 1; i++)
            {
                Literal ltrLink = FindControlRecursive(ctrl, "ltrLink" + i.ToString()) as Literal;
                if (ltrLink != null)
                {
                    int productModuleTabId = Convert.ToInt32(Settings["ProductModulePage"] ?? TabId.ToString());
                    ltrLink.Text = Globals.NavigateURL(productModuleTabId, "", "productid=" + product.SimpleProductId.ToString());
                }
            }

            PlaceHolder phimgProduct = FindControlRecursive(ctrl, "phimgProduct") as PlaceHolder;

            if (phimgProduct != null && product.Image != null)
            {
                string fileName =
                    PortalSettings.HomeDirectoryMapPath.Replace(HttpContext.Current.Request.PhysicalApplicationPath, "") +
                    product.Image.Replace('/', '\\');

                imgProduct = new GeneratedImage();
                imgProduct.ImageHandlerUrl = "~/BBImageHandler.ashx";
                if (imageWidth > 0)
                {
                    imgProduct.Parameters.Add(new ImageParameter()
                    {
                        Name = "Width", Value = imageWidth.ToString()
                    });
                }
                imgProduct.Parameters.Add(new ImageParameter()
                {
                    Name = "File", Value = fileName
                });
                // TODO: Watermark
                //if (false)
                //{
                //    imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkText", Value = Localization.GetString("Sold.Text", this.LocalResourceFile) });
                //    imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkFontFamily", Value = "Verdana" });
                //    imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkFontColor", Value = "Red" });
                //    imgProduct.Parameters.Add(new ImageParameter() { Name = "WatermarkFontSize", Value = "20" });
                //}
                phimgProduct.Controls.Add(imgProduct);
            }

            return(ctrl);
        }