예제 #1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (AppLogic.AppConfigBool("GoNonSecureAgain"))
            {
                GoNonSecureAgain();
            }

            ProductID      = CommonLogic.QueryStringUSInt("ProductID");
            CategoryID     = CommonLogic.QueryStringUSInt("CategoryID");
            SectionID      = CommonLogic.QueryStringUSInt("SectionID");
            ManufacturerID = CommonLogic.QueryStringUSInt("ManufacturerID");
            DistributorID  = CommonLogic.QueryStringUSInt("DistributorID");
            GenreID        = CommonLogic.QueryStringUSInt("GenreID");
            VectorID       = CommonLogic.QueryStringUSInt("VectorID");

            int IsProductExist = 0;


            String ActualSEName = string.Empty;

            using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
            {
                dbconn.Open();
                using (IDataReader rs = DB.GetRS(string.Format("select * from Product a with (NOLOCK) inner join (select a.ProductID, b.StoreID from Product a with (nolock) left join ProductStore b " +
                                                               "with (NOLOCK) on a.ProductID = b.ProductID) b on a.ProductID = b.ProductID where Deleted=0 and a.ProductID={0} and ({1}=0 or StoreID={2})", +
                                                               ProductID, CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowProductFiltering") == true, 1, 0), AppLogic.StoreID()), dbconn))
                {
                    if (!rs.Read())
                    {
                        HttpContext.Current.Server.Transfer("pagenotfound.aspx");
                    }
                    else
                    {
                        bool published = DB.RSFieldBool(rs, "Published");

                        if (!published)
                        {
                            HttpContext.Current.Server.Transfer("pagenotfound.aspx");
                        }

                        if (AppLogic.AppConfigBool("ProductPageOutOfStockRedirect"))
                        {
                            bool trackInventoryBySizeAndColor = AppLogic.ProductTracksInventoryBySizeAndColor(ProductID);
                            bool outOfStock = AppLogic.ProbablyOutOfStock(ProductID, AppLogic.GetProductsDefaultVariantID(ProductID), trackInventoryBySizeAndColor, "Product");

                            if (outOfStock)
                            {
                                HttpContext.Current.Server.Transfer("pagenotfound.aspx");
                            }
                        }
                    }

                    String SENameINURL = CommonLogic.QueryStringCanBeDangerousContent("SEName");
                    ActualSEName = SE.MungeName(DB.RSField(rs, "SEName"));
                    if (ActualSEName != SENameINURL)
                    {
                        String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);

                        string QStr  = "?";
                        bool   first = true;
                        for (int i = 0; i < Request.QueryString.Count; i++)
                        {
                            string key = Request.QueryString.GetKey(i);
                            if ((key.Equals("productid", StringComparison.InvariantCultureIgnoreCase)) == false && (key.Equals("sename", StringComparison.InvariantCultureIgnoreCase)) == false)
                            {
                                if (!first)
                                {
                                    QStr += "&";
                                }
                                QStr += key + "=" + Request.QueryString[i];
                                first = false;
                            }
                        }
                        if (QStr.Length > 1)
                        {
                            NewURL += QStr;
                        }

                        HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                        Response.Status = "301 Moved Permanently";
                        Response.AddHeader("Location", NewURL);
                        HttpContext.Current.Response.End();
                    }


                    #region Vortx Mobile Xml Package Modification
                    m_XmlPackage = Vortx.MobileFramework.MobileXmlPackageController.XmlPackageHook(DB.RSField(rs, "XmlPackage").ToLowerInvariant(), ThisCustomer);
                    #endregion
                    IsAKit = DB.RSFieldBool(rs, "IsAKit");
                    //this part of code is written for kit products. there is no xml package which supports them.
                    if (IsAKit)
                    {
                        IsAKit = false;
                    }
                    //end
                    if (m_XmlPackage.Length == 0)
                    {
                        if (IsAKit)
                        {
                            m_XmlPackage = AppLogic.ro_DefaultProductKitXmlPackage; // provide a default
                        }
                        else
                        {
                            m_XmlPackage = AppLogic.ro_DefaultProductXmlPackage; // provide a default
                        }
                    }
                    RequiresReg = DB.RSFieldBool(rs, "RequiresRegistration");
                    ProductName = DB.RSFieldByLocale(rs, "Name", ThisCustomer.LocaleSetting);
                    //Get Customer Funds/Blue BuksPoint and Set BluBuks Point on popup.1 is id for BluBuks


                    int pvariantid = AppLogic.GetProductsDefaultVariantID(ProductID);
                    //Check if product already exist in shopping cart
                    SqlParameter[] spa = { DB.CreateSQLParameter("@CustomerID", SqlDbType.Int, 4, ThisCustomer.CustomerID, ParameterDirection.Input),
                                           DB.CreateSQLParameter("@ProductID",  SqlDbType.Int, 4, ProductID,               ParameterDirection.Input),
                                           DB.CreateSQLParameter("@VariantID",  SqlDbType.Int, 4, pvariantid,              ParameterDirection.Input),
                                           DB.CreateSQLParameter("@StoreID",    SqlDbType.Int, 4, ThisCustomer.StoreID,    ParameterDirection.Input),
                                           DB.CreateSQLParameter("@IsExist",    SqlDbType.Int, 4, null,                    ParameterDirection.Output) };
                    IsProductExist         = DB.ExecuteStoredProcInt("dbo.aspdnsf_IsProductExistsinShoppingCart", spa);
                    hdnIsProductExist.Text = IsProductExist.ToString();
                    hdnProductID.Text      = ProductID.ToString();
                    hdnVariantID.Text      = pvariantid.ToString();
                    hdnCustomerID.Text     = ThisCustomer.CustomerID.ToString();

                    //end check if product already exist in shopping cart

                    //Apply fund
                    decimal pvprice = AppLogic.GetVariantPrice(pvariantid);
                    hdnButtonName.Text    = "AddToCartButton_" + ProductID + "_" + pvariantid;
                    hdncustomerlevel.Text = Convert.ToString(ThisCustomer.CustomerLevelID);
                    Decimal productcategoryfund = Convert.ToDecimal(hdnProductFundAmount.Text);
                    Decimal productprice        = Convert.ToDecimal(pvprice);
                    CustomerFunds = AuthenticationSSO.GetCustomerFund(ThisCustomer.CustomerID);
                    if (CustomerFunds.Count > 0)
                    {
                        //BluBucks
                        CustomerFund tempBluBucksfund = CustomerFunds.Find(x => x.FundID == Convert.ToInt32(FundType.BLUBucks));
                        if (tempBluBucksfund != null)
                        {
                            BluBuksPoints           = CustomerFunds.Find(x => x.FundID == 1).AmountAvailable.ToString();
                            hdnBluBucktsPoints.Text = Math.Round(Convert.ToDecimal(BluBuksPoints), 2).ToString();
                            ppointscount.InnerText  = "You have " + Math.Round(Convert.ToDecimal(BluBuksPoints), 2) + " BLU™ Bucks you can use to purchase items.";
                        }
                        else
                        {
                            BluBuksPoints           = "0".ToString();
                            hdnBluBucktsPoints.Text = Math.Round(Convert.ToDecimal(BluBuksPoints), 2).ToString();
                            ppointscount.InnerText  = "You have " + Math.Round(Convert.ToDecimal(BluBuksPoints), 2) + " BLU™ Bucks you can use to purchase items.";
                        }

                        //Category Fund
                        hdnProductFundID.Text = Convert.ToString(DB.RSFieldInt(rs, "FundID"));
                        if (hdnProductFundID.Text.Trim() != "" && hdnProductFundID.Text != "0")
                        {
                            CustomerFund tempfund = CustomerFunds.Find(x => x.FundID == Convert.ToInt32(hdnProductFundID.Text));
                            if (tempfund != null)
                            {
                                hdnProductFundAmount.Text = tempfund.AmountAvailable.ToString();
                                hdnFundName.Text          = tempfund.FundName;
                                productcategoryfund       = Convert.ToDecimal(hdnProductFundAmount.Text);
                            }
                            else
                            {
                                tempfund = CustomerFunds.Find(x => x.FundID == Convert.ToInt32(FundType.SOFFunds));//for sales rep
                                if (tempfund != null)
                                {
                                    hdnProductFundAmount.Text = tempfund.AmountAvailable.ToString();
                                    hdnFundName.Text          = tempfund.FundName;
                                    productcategoryfund       = Convert.ToDecimal(hdnProductFundAmount.Text);
                                }
                                else
                                {
                                    hdnProductFundAmount.Text = "0";
                                    productcategoryfund       = Convert.ToDecimal("0.00");
                                }
                                hdnProductFundID.Text = "2";
                            }
                        }
                        else
                        {
                            CustomerFund tempfund = CustomerFunds.Find(x => x.FundID == Convert.ToInt32(FundType.SOFFunds));//for sales rep
                            if (tempfund != null)
                            {
                                hdnProductFundAmount.Text = tempfund.AmountAvailable.ToString();
                                hdnFundName.Text          = tempfund.FundName;
                                productcategoryfund       = Convert.ToDecimal(hdnProductFundAmount.Text);
                                hdnProductFundID.Text     = "2";
                            }
                            else
                            {
                                hdnProductFundAmount.Text = "0";
                                productcategoryfund       = Convert.ToDecimal("0.00");
                            }
                        }

                        hdnproductprice.Text = productprice.ToString().Replace("$", "").Replace(",", "").Replace(" ", "");
                        if (this.IsPostBack)
                        {
                            hdnquantity.Text = Request.Form["Quantity_1_1"];
                        }
                        else
                        {
                            hdnquantity.Text = "1";
                        }

                        if (String.IsNullOrEmpty(hdnquantity.Text) || String.IsNullOrWhiteSpace(hdnquantity.Text))
                        {
                            hdnquantity.Text = "0";
                        }
                        productprice = productprice * Convert.ToInt32(hdnquantity.Text);
                        if (productcategoryfund < productprice)
                        {
                            productprice = productprice - productcategoryfund;
                            hdnProductFundAmountUsed.Text = (Convert.ToDecimal(productcategoryfund)).ToString();
                        }
                        else
                        {
                            productcategoryfund           = productcategoryfund - productprice;
                            hdnProductFundAmountUsed.Text = (Convert.ToDecimal(productprice)).ToString();
                            productprice        = 0;
                            txtBluBuksUsed.Text = productprice.ToString();
                        }
                        hdnpricewithfund.Text = productprice.ToString();
                        //End apply fund
                        //End
                    }
                    else
                    {
                        hdnpricewithfund.Text   = productprice.ToString();
                        hdnBluBucktsPoints.Text = "0";
                        ppointscount.InnerText  = "You have " + Math.Round(Convert.ToDecimal(0.00), 2) + " BLU™ Bucks you can use to purchase your items.";
                    }

                    CategoryHelper     = AppLogic.LookupHelper("Category", 0);
                    SectionHelper      = AppLogic.LookupHelper("Section", 0);
                    ManufacturerHelper = AppLogic.LookupHelper("Manufacturer", 0);
                    DistributorHelper  = AppLogic.LookupHelper("Distributor", 0);
                    GenreHelper        = AppLogic.LookupHelper("Genre", 0);
                    VectorHelper       = AppLogic.LookupHelper("Vector", 0);

                    String SEName = String.Empty;
                    if (DB.RSFieldByLocale(rs, "SETitle", ThisCustomer.LocaleSetting).Length == 0)
                    {
                        SETitle = Security.HtmlEncode(AppLogic.AppConfig("StoreName") + " - " + ProductName);
                    }
                    else
                    {
                        SETitle = DB.RSFieldByLocale(rs, "SETitle", ThisCustomer.LocaleSetting);
                    }
                    if (DB.RSFieldByLocale(rs, "SEDescription", ThisCustomer.LocaleSetting).Length == 0)
                    {
                        SEDescription = Security.HtmlEncode(ProductName);
                    }
                    else
                    {
                        SEDescription = DB.RSFieldByLocale(rs, "SEDescription", ThisCustomer.LocaleSetting);
                    }
                    if (DB.RSFieldByLocale(rs, "SEKeywords", ThisCustomer.LocaleSetting).Length == 0)
                    {
                        SEKeywords = Security.HtmlEncode(ProductName);
                    }
                    else
                    {
                        SEKeywords = DB.RSFieldByLocale(rs, "SEKeywords", ThisCustomer.LocaleSetting);
                    }
                    SENoScript = DB.RSFieldByLocale(rs, "SENoScript", ThisCustomer.LocaleSetting);
                }
            }

            //Log all views of unknown and registered customer
            if (AppLogic.AppConfigBool("DynamicRelatedProducts.Enabled") || AppLogic.AppConfigBool("RecentlyViewedProducts.Enabled"))
            {
                ThisCustomer.LogProductView(ProductID);
            }

            if (IsAKit && !Vortx.MobileFramework.MobileHelper.isMobile())
            {
                Server.Transfer(ResolveClientUrl("~/kitproduct.aspx"), true);
                return;
            }
            else if (IsAKit && Vortx.MobileFramework.MobileHelper.isMobile())
            {
                Server.Transfer(ResolveClientUrl("~/mobilekitproduct.aspx"), true);
                return;
            }

            CategoryName     = CategoryHelper.GetEntityName(CategoryID, ThisCustomer.LocaleSetting);
            SectionName      = SectionHelper.GetEntityName(SectionID, ThisCustomer.LocaleSetting);
            ManufacturerName = ManufacturerHelper.GetEntityName(ManufacturerID, ThisCustomer.LocaleSetting);
            DistributorName  = DistributorHelper.GetEntityName(DistributorID, ThisCustomer.LocaleSetting);
            GenreName        = GenreHelper.GetEntityName(GenreID, ThisCustomer.LocaleSetting);
            VectorName       = VectorHelper.GetEntityName(VectorID, ThisCustomer.LocaleSetting);

            if (ManufacturerID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = ManufacturerID.ToString();
                Profile.LastViewedEntityInstanceName = ManufacturerName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (DistributorID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_DistributorEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = DistributorID.ToString();
                Profile.LastViewedEntityInstanceName = DistributorName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (GenreID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_GenreEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = GenreID.ToString();
                Profile.LastViewedEntityInstanceName = GenreName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (VectorID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_VectorEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = VectorID.ToString();
                Profile.LastViewedEntityInstanceName = VectorName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (CategoryID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = CategoryID.ToString();
                Profile.LastViewedEntityInstanceName = CategoryName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (SectionID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = SectionID.ToString();
                Profile.LastViewedEntityInstanceName = SectionName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }



            SourceEntity             = Profile.LastViewedEntityName;
            SourceEntityInstanceName = Profile.LastViewedEntityInstanceName;
            SourceEntityID           = int.Parse(CommonLogic.IIF(CommonLogic.IsInteger(Profile.LastViewedEntityInstanceID), Profile.LastViewedEntityInstanceID, "0"));

            // validate that source entity id is actually valid for this product:
            if (SourceEntityID != 0)
            {
                String sqlx = string.Format("select count(*) as N from productentity a with (nolock) inner join (select distinct a.entityid, a.EntityType from productentity a with (nolock) left join EntityStore b with (nolock) " +
                                            "on a.EntityID = b.EntityID where ({0} = 0 or StoreID = {1})) b on a.EntityID = b.EntityID and a.EntityType=b.EntityType where ProductID = {2} and a.EntityID = {3} and a.EntityType = {4}"
                                            , CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), ProductID, SourceEntityID, DB.SQuote(SourceEntity));
                if (DB.GetSqlN(sqlx) == 0)
                {
                    SourceEntityID = 0;
                }
            }

            // we had no entity context coming in, try to find a category context for this product, so they have some context if possible:
            if (SourceEntityID == 0)
            {
                SourceEntityID = EntityHelper.GetProductsFirstEntity(ProductID, EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName);
                if (SourceEntityID > 0)
                {
                    CategoryID   = SourceEntityID;
                    CategoryName = CategoryHelper.GetEntityName(CategoryID, ThisCustomer.LocaleSetting);

                    Profile.LastViewedEntityName         = EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName;
                    Profile.LastViewedEntityInstanceID   = CategoryID.ToString();
                    Profile.LastViewedEntityInstanceName = CategoryName;

                    SourceEntity             = EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName;
                    SourceEntityInstanceName = CategoryName;
                }
            }

            // we had no entity context coming in, try to find a section context for this product, so they have some context if possible:
            if (SourceEntityID == 0)
            {
                SourceEntityID = EntityHelper.GetProductsFirstEntity(ProductID, EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName);
                if (SourceEntityID > 0)
                {
                    SectionID   = SourceEntityID;
                    SectionName = CategoryHelper.GetEntityName(SectionID, ThisCustomer.LocaleSetting);

                    Profile.LastViewedEntityName         = EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName;
                    Profile.LastViewedEntityInstanceID   = SectionID.ToString();
                    Profile.LastViewedEntityInstanceName = SectionName;

                    SourceEntity             = EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName;
                    SourceEntityInstanceName = SectionName;
                }
            }

            // we had no entity context coming in, try to find a Manufacturer context for this product, so they have some context if possible:
            if (SourceEntityID == 0)
            {
                SourceEntityID = EntityHelper.GetProductsFirstEntity(ProductID, EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName);
                if (SourceEntityID > 0)
                {
                    ManufacturerID   = SourceEntityID;
                    ManufacturerName = CategoryHelper.GetEntityName(ManufacturerID, ThisCustomer.LocaleSetting);

                    Profile.LastViewedEntityName         = EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName;
                    Profile.LastViewedEntityInstanceID   = ManufacturerID.ToString();
                    Profile.LastViewedEntityInstanceName = ManufacturerName;

                    SourceEntity             = EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName;
                    SourceEntityInstanceName = ManufacturerName;
                }
            }

            // build up breadcrumb if we need:
            SectionTitle = Breadcrumb.GetProductBreadcrumb(ProductID, ProductName, SourceEntity, SourceEntityID, ThisCustomer);
            //Reset LastViewedEntityInstanceID to zero if no entities are mapped to the product so the left nav will render properly.
            if (SourceEntityID <= 0)
            {
                HttpContext.Current.Profile.SetPropertyValue("LastViewedEntityInstanceID", "0");
            }

            if (RequiresReg && !ThisCustomer.IsRegistered)
            {
                m_PageOutput       += "<b>" + AppLogic.GetString("showproduct.aspx.1", SkinID, ThisCustomer.LocaleSetting) + "</b><a href=\"signin.aspx?returnurl=" + CommonLogic.GetThisPageName(false) + "?ProductID=" + ProductID.ToString() + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING").Trim().Length > 0, "&" + Security.HtmlEncode(Security.UrlEncode(CommonLogic.ServerVariables("QUERY_STRING"))), String.Empty) + "\">" + AppLogic.GetString("showproduct.aspx.2", SkinID, ThisCustomer.LocaleSetting) + "</a> " + AppLogic.GetString("showproduct.aspx.3", SkinID, ThisCustomer.LocaleSetting);
                m_PageOutputCustom += "<b>" + AppLogic.GetString("showproduct.aspx.1", SkinID, ThisCustomer.LocaleSetting) + "</b><a href=\"signin.aspx?returnurl=" + CommonLogic.GetThisPageName(false) + "?ProductID=" + ProductID.ToString() + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING").Trim().Length > 0, "&" + Security.HtmlEncode(Security.UrlEncode(CommonLogic.ServerVariables("QUERY_STRING"))), String.Empty) + "\">" + AppLogic.GetString("showproduct.aspx.2", SkinID, ThisCustomer.LocaleSetting) + "</a> " + AppLogic.GetString("showproduct.aspx.3", SkinID, ThisCustomer.LocaleSetting);
            }
            else
            {
                AppLogic.eventHandler("ViewProductPage").CallEvent("&ViewProductPage=true");

                // check if the postback was caused by an addtocart button
                if (this.IsPostBack && this.IsAddToCartPostBack)
                {
                    HandleAddToCart();
                    return;
                }

                DB.ExecuteSQL("update product set Looks=Looks+1 where ProductID=" + ProductID.ToString());

                m_PageOutput       = "<!-- XmlPackage: " + m_XmlPackage + " -->\n";
                m_PageOutputCustom = "<!-- XmlPackage: " + m_XmlPackage + " -->\n";
                if (m_XmlPackage.Length == 0)
                {
                    m_PageOutput       += "<p><b><font color=red>XmlPackage format was chosen, but no XmlPackage was specified!</font></b></p>";
                    m_PageOutputCustom += "<p><b><font color=red>XmlPackage format was chosen, but no XmlPackage was specified!</font></b></p>";
                }
                else
                {
                    using (XmlPackage2 p = new XmlPackage2(m_XmlPackage, ThisCustomer, SkinID, "", "EntityName=" + SourceEntity + "&EntityID=" + SourceEntityID.ToString() + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING").IndexOf("cartrecid") != -1, "&cartrecid=" + CommonLogic.QueryStringUSInt("cartrecid").ToString(), "&showproduct=1"), String.Empty, true))
                    {
                        m_PageOutput += AppLogic.RunXmlPackage(p, base.GetParser, ThisCustomer, SkinID, true, true);

                        if (p.SectionTitle != "")
                        {
                            SectionTitle = p.SectionTitle;
                        }
                        if (p.SETitle != "")
                        {
                            SETitle = p.SETitle;
                        }
                        if (p.SEDescription != "")
                        {
                            SEDescription = p.SEDescription;
                        }
                        if (p.SEKeywords != "")
                        {
                            SEKeywords = p.SEKeywords;
                        }
                        if (p.SENoScript != "")
                        {
                            SENoScript = p.SENoScript;
                        }
                    }
                    //Get add to cart button for popup
                    using (XmlPackage2 p = new XmlPackage2("product.SimpleProductCustom.xml.config", ThisCustomer, SkinID, "", "EntityName=" + SourceEntity + "&EntityID=" + SourceEntityID.ToString() + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING").IndexOf("cartrecid") != -1, "&cartrecid=" + CommonLogic.QueryStringUSInt("cartrecid").ToString(), "&showproduct=1"), String.Empty, true))
                    {
                        m_PageOutputCustom = AppLogic.RunXmlPackage(p, base.GetParser, ThisCustomer, SkinID, true, true);
                        LiteralCustom.Text = m_PageOutputCustom;
                    }
                }
            }
            if (!this.IsPostBack)
            {
                litOutput.Text = m_PageOutput;
            }

            GetParentCategory();
            if (!string.IsNullOrEmpty(SourceEntityInstanceName) && !string.IsNullOrEmpty(parentCategoryID))
            {
                parentCategoryName = CategoryHelper.GetEntityName(Convert.ToInt32(parentCategoryID), ThisCustomer.LocaleSetting);

                ((System.Web.UI.WebControls.HyperLink)Master.FindControl("lnkCategory")).Text        = parentCategoryName;
                ((System.Web.UI.WebControls.HyperLink)Master.FindControl("lnkCategory")).NavigateUrl = "~/c-" + parentCategoryID + "-" + parentCategoryName.Replace(" ", "-") + ".aspx";

                ((System.Web.UI.WebControls.Label)Master.FindControl("lblSperator")).Text = ">>";

                ((System.Web.UI.WebControls.HyperLink)Master.FindControl("lnkSubCategory")).Text        = SourceEntityInstanceName;
                ((System.Web.UI.WebControls.HyperLink)Master.FindControl("lnkSubCategory")).NavigateUrl = "~/c-" + SourceEntityID + "-" + SourceEntityInstanceName.Replace(" ", "-") + ".aspx";
            }

            //get fund BluBucks Percentage
            BudgetPercentageRatio FundPercentage = AuthenticationSSO.GetBudgetPercentageRatio(ThisCustomer.CustomerLevelID, Convert.ToInt32(parentCategoryID));
            hdnBudgetPercentValue.Text = FundPercentage.BudgetPercentageValue.ToString();
            ppercentage.InnerText      = "You can pay for up to " + hdnBudgetPercentValue.Text + "% of this item's cost with BLU™ Bucks.";
            hdnProductCategoryID.Text  = parentCategoryID.ToString();
            LstInventories             = JsonConvert.SerializeObject(AppLogic.LstInventory);
            hdnInventory.Text          = JsonConvert.SerializeObject(AppLogic.LstInventory);
        }
예제 #2
0
        private void SetupProductDefaults()
        {
            String ActualSEName = string.Empty;

            using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
            {
                dbconn.Open();
                using (IDataReader rs = DB.GetRS("select * from Product  with (NOLOCK)  where Deleted=0 and ProductID=" + ProductID.ToString(), dbconn))
                {
                    if (!rs.Read())
                    {
                        HttpContext.Current.Server.Transfer("pagenotfound.aspx");
                    }
                    else
                    {
                        bool a = DB.RSFieldBool(rs, "Published");
                        if (!a)
                        {
                            HttpContext.Current.Server.Transfer("pagenotfound.aspx");
                        }
                    }

                    String SENameINURL = CommonLogic.QueryStringCanBeDangerousContent("SEName");
                    ActualSEName = SE.MungeName(DB.RSField(rs, "SEName"));
                    if (ActualSEName != SENameINURL)
                    {
                        String NewURL = AppLogic.GetStoreHTTPLocation(false) + SE.MakeProductLink(ProductID, ActualSEName);

                        string QStr  = "?";
                        bool   first = true;
                        for (int i = 0; i < Request.QueryString.Count; i++)
                        {
                            string key = Request.QueryString.GetKey(i);
                            if ((key.Equals("productid", StringComparison.InvariantCultureIgnoreCase)) == false && (key.Equals("sename", StringComparison.InvariantCultureIgnoreCase)) == false)
                            {
                                if (!first)
                                {
                                    QStr += "&";
                                }
                                QStr += key + "=" + Request.QueryString[i].ToString();
                                first = false;
                            }
                        }
                        if (QStr.Length > 1)
                        {
                            NewURL += QStr;
                        }

                        HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                        Response.Status = "301 Moved Permanently";
                        Response.AddHeader("Location", NewURL);
                        HttpContext.Current.Response.End();
                    }

                    m_XmlPackage = DB.RSField(rs, "XmlPackage").ToLowerInvariant();
                    IsAKit       = DB.RSFieldBool(rs, "IsAKit");
                    if (m_XmlPackage.Length == 0)
                    {
                        if (IsAKit)
                        {
                            m_XmlPackage = AppLogic.ro_DefaultProductKitXmlPackage; // provide a default
                        }
                        else
                        {
                            m_XmlPackage = AppLogic.ro_DefaultProductXmlPackage; // provide a default
                        }
                    }
                    RequiresReg = DB.RSFieldBool(rs, "RequiresRegistration");
                    ProductName = DB.RSFieldByLocale(rs, "Name", ThisCustomer.LocaleSetting);

                    CategoryHelper     = AppLogic.LookupHelper("Category", 0);
                    SectionHelper      = AppLogic.LookupHelper("Section", 0);
                    ManufacturerHelper = AppLogic.LookupHelper("Manufacturer", 0);
                    DistributorHelper  = AppLogic.LookupHelper("Distributor", 0);
                    GenreHelper        = AppLogic.LookupHelper("Genre", 0);
                    VectorHelper       = AppLogic.LookupHelper("Vector", 0);

                    String SEName = String.Empty;
                    if (DB.RSFieldByLocale(rs, "SETitle", ThisCustomer.LocaleSetting).Length == 0)
                    {
                        SETitle = Security.HtmlEncode(AppLogic.AppConfig("StoreName") + " - " + ProductName);
                    }
                    else
                    {
                        SETitle = DB.RSFieldByLocale(rs, "SETitle", ThisCustomer.LocaleSetting);
                    }
                    if (DB.RSFieldByLocale(rs, "SEDescription", ThisCustomer.LocaleSetting).Length == 0)
                    {
                        SEDescription = Security.HtmlEncode(ProductName);
                    }
                    else
                    {
                        SEDescription = DB.RSFieldByLocale(rs, "SEDescription", ThisCustomer.LocaleSetting);
                    }
                    if (DB.RSFieldByLocale(rs, "SEKeywords", ThisCustomer.LocaleSetting).Length == 0)
                    {
                        SEKeywords = Security.HtmlEncode(ProductName);
                    }
                    else
                    {
                        SEKeywords = DB.RSFieldByLocale(rs, "SEKeywords", ThisCustomer.LocaleSetting);
                    }
                    SENoScript = DB.RSFieldByLocale(rs, "SENoScript", ThisCustomer.LocaleSetting);
                }
            }

            //Log all views of unknown and registered customer
            if (AppLogic.AppConfigBool("DynamicRelatedProducts.Enabled") || AppLogic.AppConfigBool("RecentlyViewedProducts.Enabled"))
            {
                ThisCustomer.LogProductView(ProductID);
            }

            CategoryName     = CategoryHelper.GetEntityName(CategoryID, ThisCustomer.LocaleSetting);
            SectionName      = SectionHelper.GetEntityName(SectionID, ThisCustomer.LocaleSetting);
            ManufacturerName = ManufacturerHelper.GetEntityName(ManufacturerID, ThisCustomer.LocaleSetting);
            DistributorName  = DistributorHelper.GetEntityName(DistributorID, ThisCustomer.LocaleSetting);
            GenreName        = GenreHelper.GetEntityName(GenreID, ThisCustomer.LocaleSetting);
            VectorName       = VectorHelper.GetEntityName(VectorID, ThisCustomer.LocaleSetting);

            String SourceEntityInstanceName = String.Empty;

            if (ManufacturerID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = ManufacturerID.ToString();
                Profile.LastViewedEntityInstanceName = ManufacturerName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (DistributorID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_DistributorEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = DistributorID.ToString();
                Profile.LastViewedEntityInstanceName = DistributorName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (GenreID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_GenreEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = GenreID.ToString();
                Profile.LastViewedEntityInstanceName = GenreName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (VectorID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_VectorEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = VectorID.ToString();
                Profile.LastViewedEntityInstanceName = VectorName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (CategoryID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = CategoryID.ToString();
                Profile.LastViewedEntityInstanceName = CategoryName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (SectionID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = SectionID.ToString();
                Profile.LastViewedEntityInstanceName = SectionName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }

            SourceEntity             = Profile.LastViewedEntityName;
            SourceEntityInstanceName = Profile.LastViewedEntityInstanceName;
            SourceEntityID           = int.Parse(CommonLogic.IIF(CommonLogic.IsInteger(Profile.LastViewedEntityInstanceID), Profile.LastViewedEntityInstanceID, "0"));

            // validate that source entity id is actually valid for this product:
            if (SourceEntityID != 0)
            {
                String sqlx = "select count(*) as N from dbo.productentity with (NOLOCK) where ProductID=" + ProductID.ToString() + " and EntityID=" + SourceEntityID.ToString() + " and EntityType = " + DB.SQuote(SourceEntity);
                if (DB.GetSqlN(sqlx) == 0)
                {
                    SourceEntityID = 0;
                }
            }

            // we had no entity context coming in, try to find a category context for this product, so they have some context if possible:
            if (SourceEntityID == 0)
            {
                SourceEntityID = EntityHelper.GetProductsFirstEntity(ProductID, EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName);
                if (SourceEntityID > 0)
                {
                    CategoryID   = SourceEntityID;
                    CategoryName = CategoryHelper.GetEntityName(CategoryID, ThisCustomer.LocaleSetting);

                    Profile.LastViewedEntityName         = EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName;
                    Profile.LastViewedEntityInstanceID   = CategoryID.ToString();
                    Profile.LastViewedEntityInstanceName = CategoryName;

                    SourceEntity             = EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName;
                    SourceEntityInstanceName = CategoryName;
                }
            }

            // we had no entity context coming in, try to find a section context for this product, so they have some context if possible:
            if (SourceEntityID == 0)
            {
                SourceEntityID = EntityHelper.GetProductsFirstEntity(ProductID, EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName);
                if (SourceEntityID > 0)
                {
                    SectionID   = SourceEntityID;
                    SectionName = CategoryHelper.GetEntityName(SectionID, ThisCustomer.LocaleSetting);

                    Profile.LastViewedEntityName         = EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName;
                    Profile.LastViewedEntityInstanceID   = SectionID.ToString();
                    Profile.LastViewedEntityInstanceName = SectionName;

                    SourceEntity             = EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName;
                    SourceEntityInstanceName = SectionName;
                }
            }

            // we had no entity context coming in, try to find a Manufacturer context for this product, so they have some context if possible:
            if (SourceEntityID == 0)
            {
                SourceEntityID = EntityHelper.GetProductsFirstEntity(ProductID, EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName);
                if (SourceEntityID > 0)
                {
                    ManufacturerID   = SourceEntityID;
                    ManufacturerName = CategoryHelper.GetEntityName(ManufacturerID, ThisCustomer.LocaleSetting);

                    Profile.LastViewedEntityName         = EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName;
                    Profile.LastViewedEntityInstanceID   = ManufacturerID.ToString();
                    Profile.LastViewedEntityInstanceName = ManufacturerName;

                    SourceEntity             = EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName;
                    SourceEntityInstanceName = ManufacturerName;
                }
            }

            // build up breadcrumb if we need:
            SectionTitle = Breadcrumb.GetProductBreadcrumb(ProductID, ProductName, SourceEntity, SourceEntityID, ThisCustomer);
        }
예제 #3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (AppLogic.AppConfigBool("GoNonSecureAgain"))
            {
                SkinBase.GoNonSecureAgain();
            }

            _itemCounter   = "ProductID".ToQueryString().TryParseIntUsLocalization().Value;
            CategoryID     = "CategoryID".ToQueryString();
            DepartmentID   = "DepartmentID".ToQueryString();
            ManufacturerID = "ManufacturerID".ToQueryString();

            _itemCode = AppLogic.GetItemCodeByCounter(_itemCounter);

            var eCommerceProductInfoView = AppLogic.GetProductInfoViewForShowProduct(DB.SQuote(_itemCode),
                                                                                     DB.SQuote(ThisCustomer.LocaleSetting),
                                                                                     DB.SQuote(InterpriseHelper.ConfigInstance.UserCode),
                                                                                     DB.SQuote(InterpriseHelper.ConfigInstance.WebSiteCode),
                                                                                     DB.SQuote(Localization.DateTimeStringForDB(DateTime.Now)),
                                                                                     DB.SQuote(ThisCustomer.ProductFilterID),
                                                                                     DB.SQuote(ThisCustomer.ContactCode));

            int sessionLifetime = AppLogic.AppConfigUSInt("ViewedProductsSessionLifetime");

            if (sessionLifetime == null)
            {
                sessionLifetime = 60;
            }

            if (ThisCustomer.ContactCode == "")
            {
                RequireCustomerRecord();
            }

            //DateTime expirationdatetime = DateTime.Now.AddMinutes(-sessionLifetime);
            //string updatevieweditems =
            //        string.Format("exec UpdateEcommerceViewedItems @ExpirationDate = {0}, @WebSiteCode = {1}, @ContactCode = {2}, @ItemCode = {3}, @CurrentDate = {4}, @SessionID = {5}",
            //        DB.SQuote(Localization.DateTimeStringForDB(expirationdatetime)),
            //        DB.SQuote(InterpriseHelper.ConfigInstance.WebSiteCode),
            //        DB.SQuote(ThisCustomer.ContactCode),
            //        DB.SQuote(_itemCode),
            //        DB.SQuote(Localization.DateTimeStringForDB(DateTime.Now)),
            //        ThisCustomer.CurrentSessionID);
            //DB.ExecuteSQL(updatevieweditems);

            string itemDescription = string.Empty;

            if (eCommerceProductInfoView == null)
            {
                Response.Redirect(SE.MakeDriverLink("ProductNotFound"));
            }

            if (eCommerceProductInfoView.CheckOutOption)
            {
                Response.Redirect(SE.MakeDriverLink("ProductNotFound"));
            }

            if (eCommerceProductInfoView.IsCBN == false && AppLogic.IsCBNMode())
            {
                Response.Redirect(SE.MakeDriverLink("MobileProductNotFound"));
            }

            string SENameINURL  = "SEName".ToQueryStringDecode();
            string ActualSEName = eCommerceProductInfoView.ItemDescription.ToMungeName().ToUrlEncode().ToSubString(90);

            if (string.IsNullOrEmpty(ActualSEName))
            {
                ActualSEName = eCommerceProductInfoView.ItemName.ToMungeName().ToUrlEncode().ToSubString(90);
            }

            if (ActualSEName != SENameINURL)
            {
                string NewURL    = AppLogic.GetStoreHTTPLocation(false) + SE.MakeProductLink(_itemCounter.ToString(), ActualSEName);
                string QStr      = "?";
                var    keyvalues = Request.QueryString
                                   .ToPairs()
                                   .Where(q => q.Key == "productid" && q.Key == "sename")
                                   .Select(q => string.Join("=", new[] { q.Key, q.Value + "&" }))
                                   .ToArray();
                QStr += string.Join("", keyvalues);
                if (QStr.Length > 1)
                {
                    NewURL += QStr;
                }

                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }

            m_XmlPackage = eCommerceProductInfoView.MobileXmlPackage.ToLowerInvariant();

            IsAKit   = eCommerceProductInfoView.IsAKit.TryParseBool();
            IsMatrix = eCommerceProductInfoView.IsMatrix.TryParseBool();

            if (m_XmlPackage.Length == 0)
            {
                if (IsAKit)
                {
                    m_XmlPackage = AppLogic.MobileDefaultProductKitXmlPackage; // provide a default
                }
                else if (IsMatrix)
                {
                    m_XmlPackage = AppLogic.MobileDefaultProductMatrixXmlPackage; // provide a default
                }
                else
                {
                    m_XmlPackage = AppLogic.MobileDefaultProductXmlPackage; // provide a default
                }
            }

            RequiresReg = eCommerceProductInfoView.RequiresRegistration;
            ProductName = XmlCommon.GetLocaleEntry(eCommerceProductInfoView.ItemDescription, ThisCustomer.LocaleSetting, true);

            CategoryHelper     = AppLogic.LookupHelper(base.EntityHelpers, DomainConstants.LOOKUP_HELPER_CATEGORIES);
            SectionHelper      = AppLogic.LookupHelper(base.EntityHelpers, DomainConstants.LOOKUP_HELPER_DEPARTMENT);
            ManufacturerHelper = AppLogic.LookupHelper(base.EntityHelpers, DomainConstants.LOOKUP_HELPER_MANUFACTURERS);

            itemDescription = eCommerceProductInfoView.ItemDescription;
            if (string.IsNullOrEmpty(itemDescription))
            {
                itemDescription = ProductName;
            }

            string seITitleTemp = XmlCommon.GetLocaleEntry(eCommerceProductInfoView.SETitle, ThisCustomer.LocaleSetting, true);

            SETitle = string.IsNullOrEmpty(seITitleTemp) ? (AppLogic.AppConfig("StoreName") + " - " + itemDescription).ToHtmlEncode() : seITitleTemp;

            string seDescription = XmlCommon.GetLocaleEntry(eCommerceProductInfoView.SEDescription, ThisCustomer.LocaleSetting, true);

            SEDescription = string.IsNullOrEmpty(seDescription) ? ProductName.ToHtmlEncode() : seDescription;

            string seKeywords = XmlCommon.GetLocaleEntry(eCommerceProductInfoView.SEKeywords, ThisCustomer.LocaleSetting, true);

            SEKeywords = string.IsNullOrEmpty(seKeywords) ? ProductName.ToHtmlEncode() : seKeywords;

            SENoScript = XmlCommon.GetLocaleEntry(eCommerceProductInfoView.SENoScript, ThisCustomer.LocaleSetting, true);

            CategoryName = (CategoryHelper.GetEntityField(CategoryID, "Description", ThisCustomer.LocaleSetting) != String.Empty) ?
                           CategoryHelper.GetEntityField(CategoryID, "Description", ThisCustomer.LocaleSetting) :
                           CategoryHelper.GetEntityName(CategoryID, ThisCustomer.LocaleSetting);

            SectionName = (SectionHelper.GetEntityField(DepartmentID, "Description", ThisCustomer.LocaleSetting) != String.Empty) ?
                          SectionHelper.GetEntityField(DepartmentID, "Description", ThisCustomer.LocaleSetting) :
                          SectionHelper.GetEntityName(DepartmentID, ThisCustomer.LocaleSetting);

            ManufacturerName = (ManufacturerHelper.GetEntityField(ManufacturerID, "Description", ThisCustomer.LocaleSetting) != String.Empty) ?
                               ManufacturerHelper.GetEntityField(ManufacturerID, "Description", ThisCustomer.LocaleSetting) :
                               ManufacturerHelper.GetEntityName(ManufacturerID, ThisCustomer.LocaleSetting);

            if (ManufacturerID.Length != 0)
            {
                CookieTool.Add("LastViewedEntityName", "Manufacturer", new TimeSpan(1, 0, 0, 0, 0));
                CookieTool.Add("LastViewedEntityInstanceID", ManufacturerID.ToString(), new TimeSpan(1, 0, 0, 0, 0));
                CookieTool.Add("LastViewedEntityInstanceName", ManufacturerName, new TimeSpan(1, 0, 0, 0, 0));
                String NewURL = AppLogic.GetStoreHTTPLocation(false) + SE.MakeProductLink(_itemCounter.ToString(), _itemCode);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (CategoryID.Length != 0)
            {
                CookieTool.Add("LastViewedEntityName", "Category", new TimeSpan(1, 0, 0, 0, 0));
                CookieTool.Add("LastViewedEntityInstanceID", CategoryID.ToString(), new TimeSpan(1, 0, 0, 0, 0));
                CookieTool.Add("LastViewedEntityInstanceName", CategoryName, new TimeSpan(1, 0, 0, 0, 0));
                string NewURL = AppLogic.GetStoreHTTPLocation(false) + SE.MakeProductLink(_itemCounter.ToString(), _itemCode);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (DepartmentID.Length != 0)
            {
                var cookierExpires = new TimeSpan(1, 0, 0, 0, 0);
                CookieTool.Add("LastViewedEntityName", "Department", cookierExpires);
                CookieTool.Add("LastViewedEntityInstanceID", DepartmentID.ToString(), cookierExpires);
                CookieTool.Add("LastViewedEntityInstanceName", SectionName, cookierExpires);

                String NewURL = AppLogic.GetStoreHTTPLocation(false) + SE.MakeProductLink(_itemCounter.ToString(), _itemCode);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }

            SourceEntity = CommonLogic.CookieCanBeDangerousContent("LastViewedEntityName", true);
            string SourceEntityInstanceName = CommonLogic.CookieCanBeDangerousContent("LastViewedEntityInstanceName", true);

            SourceEntityID = CommonLogic.CookieCanBeDangerousContent("LastViewedEntityInstanceID", true);

            // validate that source entity id is actually valid for this product:
            if (SourceEntityID.Length != 0)
            {
                var alE = AppLogic.GetProductEntityList(_itemCode, SourceEntity);
                if (alE.Any(i => i == SourceEntityID.TryParseIntUsLocalization()))
                {
                    SourceEntityID = string.Empty;
                }
            }

            if (SourceEntityID.Length != 0)
            {
                PickupBreadCrumb(ref SourceEntity, ref SourceEntityInstanceName, ref SourceEntityID, false);
            }
            else
            {
                PickupBreadCrumb(ref SourceEntity, ref SourceEntityInstanceName, ref SourceEntityID, true);
            }

            AppLogic.LogEvent(ThisCustomer.CustomerCode, 10, _itemCounter.ToString());
        }
예제 #4
0
        /// <summary>
        /// Load the product from database to a list
        /// </summary>
        private void LoadProducts()
        {
            try
            {
                // load Product
                using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                {
                    con.Open();

                    int  hideProductsWithLessThanThisInventoryLevel = AppLogic.AppConfigNativeInt("HideProductsWithLessThanThisInventoryLevel");
                    bool hideProducts = hideProductsWithLessThanThisInventoryLevel != -1;

                    // Use this query, as it's faster unless HideProductsWithLessThanThisInventoryLevel appconfig != -1
                    string sql = "SELECT ProductID,Name,SEName, Description FROM Product with (NOLOCK) WHERE Deleted = 0 and Published =1 and Getdate() between IsNull(availablestartdate,'1/1/1900') and IsNull(availablestopdate,'1/1/2999')";

                    if (hideProducts)
                    {
                        sql  = "SELECT  Product.ProductID, Product.Name, Product.SEName, Product.Description, Product.TrackInventoryBySizeAndColor, ProductVariant.VariantID, ProductVariant.Inventory";
                        sql += " FROM  Product with (NOLOCK) INNER JOIN";
                        sql += " ProductVariant ON Product.ProductID = ProductVariant.ProductID where ProductVariant.IsDefault = 1 and Product.Deleted = 0 and Product.Published =1 and Getdate() between IsNull(Product.availablestartdate,'1/1/1900') and IsNull(Product.availablestopdate,'1/1/2999')";
                    }

                    using (IDataReader rs = DB.GetRS(sql, con))
                    {
                        while (rs.Read())
                        {
                            if (hideProducts)
                            {
                                bool trackInventoryBySizeAndColor = DB.RSFieldBool(rs, "TrackInventoryBySizeAndColor");
                                int  variantId = DB.RSFieldInt(rs, "VariantID");
                                int  inventoryOfDefaultVariant = DB.RSFieldInt(rs, "Inventory");

                                // We must filter the suggested product if HideProductsWithLessThanThisInventoryLevel appconfig != -1
                                // based on the inventory of default variant of the product.
                                if (inventoryOfDefaultVariant < hideProductsWithLessThanThisInventoryLevel && !trackInventoryBySizeAndColor)
                                {
                                    continue;
                                }

                                // We must filter the suggested product if HideProductsWithLessThanThisInventoryLevel appconfig != -1
                                // and TrackInventoryBySizeAndColor is true based on total quantity of the attribute for variant
                                if (trackInventoryBySizeAndColor && MustFilter(variantId, hideProductsWithLessThanThisInventoryLevel))
                                {
                                    continue;
                                }
                            }

                            int    productID   = DB.RSFieldInt(rs, "productID");
                            string name        = DB.RSFieldByLocale(rs, "Name", Localization.GetDefaultLocale());
                            string seName      = DB.RSFieldByLocale(rs, "SeName", Localization.GetDefaultLocale());
                            string title       = string.Empty;
                            string description = DB.RSFieldByLocale(rs, "Description", Localization.GetDefaultLocale());
                            string url         = SE.MakeProductLink(productID, seName);

                            _resources.Add(new MobileResource(name, url, description, title));
                        }
                    }
                }
            }
            catch
            {
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (Page.IsValid)
            {
                String        FromAddress = txtFromAddress.Text;
                String        ToAddress   = txtToAddress.Text;
                String        BotAddress  = AppLogic.AppConfig("ReceiptEMailFrom");
                String        Subject     = AppLogic.AppConfig("StoreName") + " - " + SE.MungeName(ProductName);
                StringBuilder Body        = new StringBuilder(4096);

                List <XmlPackageParam> runtimeParams = new List <XmlPackageParam>();
                runtimeParams.Add(new XmlPackageParam("Subject", Subject));
                runtimeParams.Add(new XmlPackageParam("ItemCode", ItemCode));
                runtimeParams.Add(new XmlPackageParam("UserCode", InterpriseHelper.ConfigInstance.UserCode));

                Body.Append(
                    AppLogic.RunXmlPackage(
                        "notification.emailproduct.xml.config",
                        null,
                        ThisCustomer,
                        SkinID,
                        string.Empty,
                        runtimeParams,
                        false,
                        false
                        )
                    );

                try
                {
                    //get email account information assigned to this website
                    string[] defaultemailacctinfo = InterpriseHelper.GetStoreEmailAccountInfo();
                    string   fromemailacccode     = defaultemailacctinfo[0];

                    if (fromemailacccode.IsNullOrEmptyTrimmed())
                    {
                        emailproduct_aspx_8.Text = AppLogic.GetString("emailproduct.aspx.24", SkinID, ThisCustomer.LocaleSetting);
                    }
                    else
                    {
                        AppLogic.SendMail(Subject, Body.ToString(), true, BotAddress, BotAddress, ToAddress, ToAddress, String.Empty, AppLogic.AppConfig("MailMe_Server"));
                        emailproduct_aspx_8.Text = AppLogic.GetString("emailproduct.aspx.8", SkinID, ThisCustomer.LocaleSetting);
                    }
                }

                catch (Exception ex)
                {
                    emailproduct_aspx_8.Text = String.Format(AppLogic.GetString("emailproduct.aspx.9", SkinID, ThisCustomer.LocaleSetting), CommonLogic.GetExceptionDetail(ex, "<br>"));
                }

                pnlSuccess.Visible          = true;
                pnlRequireReg.Visible       = false;
                pnlEmailToFriend.Visible    = false;
                ReturnToProduct.Text        = AppLogic.GetString("emailproduct.aspx.10", SkinID, ThisCustomer.LocaleSetting);
                ReturnToProduct.NavigateUrl = SE.MakeProductLink(productID.ToString(), SEName);
            }
            else
            {
                InitializePageContent();
            }
        }
예제 #6
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (AppLogic.AppConfigBool("GoNonSecureAgain"))
            {
                SkinBase.GoNonSecureAgain();
            }

            ProductID      = CommonLogic.QueryStringUSInt("ProductID");
            CategoryID     = CommonLogic.QueryStringUSInt("CategoryID");
            SectionID      = CommonLogic.QueryStringUSInt("SectionID");
            ManufacturerID = CommonLogic.QueryStringUSInt("ManufacturerID");
            DistributorID  = CommonLogic.QueryStringUSInt("DistributorID");
            GenreID        = CommonLogic.QueryStringUSInt("GenreID");
            VectorID       = CommonLogic.QueryStringUSInt("VectorID");

            if (ProductID == 0)
            {
                if (IsAddToCartPostBack)
                {
                    int    PackID                 = 0;
                    int    packProductID          = 0;
                    int    packVariantID          = 0;
                    int    packQuantity           = 0;
                    int    packProductTypeID      = 0;
                    bool   FromCart               = false;
                    int    packCartRecID          = 0;
                    String ChosenColor            = String.Empty;
                    String ChosenColorSKUModifier = String.Empty;
                    String ChosenSize             = String.Empty;
                    String ChosenSizeSKUModifier  = String.Empty;
                    String color      = string.Empty;
                    String size       = string.Empty;
                    String TextOption = CommonLogic.FormCanBeDangerousContent("TextOption");


                    for (int i = 0; i <= HttpContext.Current.Request.Form.Count - 1; i++)
                    {
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("ProductID", StringComparison.InvariantCultureIgnoreCase))
                        {
                            packProductID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent("__EVENTARGUMENT").Split('_')[1]);
                        }
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("VariantID", StringComparison.InvariantCultureIgnoreCase))
                        {
                            packVariantID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent("__EVENTARGUMENT").Split('_')[2]);
                        }

                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("PackID", StringComparison.InvariantCultureIgnoreCase))
                        {
                            PackID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]));
                            if (CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]).Contains(",") && PackID == 0)
                            {
                                PackID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]).Split(',')[0]);
                            }
                        }

                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("Quantity", StringComparison.InvariantCultureIgnoreCase) && !HttpContext.Current.Request.Form.Keys[i].StartsWith("Quantity_vldt", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (Localization.ParseUSInt(HttpContext.Current.Request.Form.Keys[i].Split('_')[2]) == packVariantID)
                            {
                                packQuantity = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]));
                            }
                        }
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("CartRecID", StringComparison.InvariantCultureIgnoreCase))
                        {
                            packCartRecID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]));
                        }
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("Color", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (Localization.ParseUSInt(HttpContext.Current.Request.Form.Keys[i].Split('_')[2]) == packVariantID)
                            {
                                color = CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]).ToString();
                            }
                        }
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("Size", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (Localization.ParseUSInt(HttpContext.Current.Request.Form.Keys[i].Split('_')[2]) == packVariantID)
                            {
                                size = CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]).ToString();
                            }
                        }
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("ProductTypeID", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (Localization.ParseUSInt(HttpContext.Current.Request.Form.Keys[i].Split('_')[2]) == packVariantID)
                            {
                                packProductTypeID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]));
                            }
                        }
                    }


                    ThisCustomer.RequireCustomerRecord();
                    if (packQuantity == 0)
                    {
                        packQuantity = 1;
                    }
                    FromCart = (packCartRecID > 0);

                    if (color.Length != 0)
                    {
                        String[] ColorSel = color.Split(',');
                        try
                        {
                            ChosenColor = ColorSel[0];
                        }
                        catch { }
                        try
                        {
                            ChosenColorSKUModifier = ColorSel[1];
                        }
                        catch { }
                    }
                    if (ChosenColor.Length != 0)
                    {
                        ThisCustomer.ThisCustomerSession["ChosenColor"] = ChosenColor;
                    }


                    if (size.Length != 0)
                    {
                        String[] SizeSel = size.Split(',');
                        try
                        {
                            ChosenSize = SizeSel[0];
                        }
                        catch { }
                        try
                        {
                            ChosenSizeSKUModifier = SizeSel[1];
                        }
                        catch { }
                    }
                    if (ChosenSize.Length != 0)
                    {
                        ThisCustomer.ThisCustomerSession["ChosenSize"] = ChosenSize;
                    }

                    if (packQuantity > 0)
                    {
                        // add to custom cart:
                        if (FromCart)
                        {
                            CustomCart.AddItem(PackID, packProductID, packVariantID, packQuantity, ChosenColor, ChosenColorSKUModifier, ChosenSize, ChosenSizeSKUModifier, packCartRecID, ThisCustomer, CartTypeEnum.ShoppingCart);
                        }
                        else
                        {
                            CustomCart cart = new CustomCart(ThisCustomer, PackID, 1, CartTypeEnum.ShoppingCart);
                            cart.AddItem(packProductID, packVariantID, packQuantity, ChosenColor, ChosenColorSKUModifier, ChosenSize, ChosenSizeSKUModifier);
                        }
                    }

                    if (CommonLogic.QueryStringCanBeDangerousContent("UpdateCartPack") == "")
                    {
                        String url = "pb.aspx?type=" + packProductTypeID.ToString() + "&PackID=" + PackID.ToString() + "&ProductID=" + packProductID.ToString() + "&cartrecid=" + packCartRecID;

                        Response.Redirect(url + CommonLogic.IIF(FromCart, "?cartrecid=" + packCartRecID.ToString(), ""));
                        Response.Redirect(url);
                    }
                    else
                    {
                        Response.Redirect(ResolveClientUrl("~/shoppingcart.aspx"));
                    }
                }
            }
            String ActualSEName = string.Empty;

            using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
            {
                dbconn.Open();
                using (IDataReader rs = DB.GetRS(string.Format("select * from Product a with (NOLOCK) inner join (select a.ProductID, b.StoreID from Product a with (nolock) left join ProductStore b " +
                                                               "with (NOLOCK) on a.ProductID = b.ProductID) b on a.ProductID = b.ProductID where Deleted=0 and a.ProductID={0} and ({1}=0 or StoreID={2})", +
                                                               ProductID, CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowProductFiltering") == true, 1, 0), AppLogic.StoreID()), dbconn))
                {
                    if (!rs.Read())
                    {
                        Response.Redirect(SE.MakeDriverLink("ProductNotFound"));
                    }
                    else
                    {
                        bool a = DB.RSFieldBool(rs, "Published");
                        if (!a)
                        {
                            Response.Redirect(SE.MakeDriverLink("ProductNotFound"));
                        }
                    }

                    String SENameINURL = CommonLogic.QueryStringCanBeDangerousContent("SEName");
                    ActualSEName = SE.MungeName(DB.RSField(rs, "SEName"));
                    if (ActualSEName != SENameINURL)
                    {
                        String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);

                        string QStr  = "?";
                        bool   first = true;
                        for (int i = 0; i < Request.QueryString.Count; i++)
                        {
                            string key = Request.QueryString.GetKey(i);
                            if ((key.Equals("productid", StringComparison.InvariantCultureIgnoreCase)) == false && (key.Equals("sename", StringComparison.InvariantCultureIgnoreCase)) == false)
                            {
                                if (!first)
                                {
                                    QStr += "&";
                                }
                                QStr += key + "=" + Request.QueryString[i];
                                first = false;
                            }
                        }
                        if (QStr.Length > 1)
                        {
                            NewURL += QStr;
                        }

                        HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                        Response.Status = "301 Moved Permanently";
                        Response.AddHeader("Location", NewURL);
                        HttpContext.Current.Response.End();
                    }


                    #region Vortx Mobile Xml Package Modification
                    m_XmlPackage = Vortx.MobileFramework.MobileXmlPackageController.XmlPackageHook(DB.RSField(rs, "XmlPackage").ToLowerInvariant(), ThisCustomer);
                    #endregion
                    IsAKit  = DB.RSFieldBool(rs, "IsAKit");
                    IsAPack = DB.RSFieldBool(rs, "IsAPack");
                    if (m_XmlPackage.Length == 0)
                    {
                        if (IsAKit)
                        {
                            m_XmlPackage = AppLogic.ro_DefaultProductKitXmlPackage; // provide a default
                        }
                        else if (IsAPack)
                        {
                            m_XmlPackage = AppLogic.ro_DefaultProductPackXmlPackage; // provide a default
                        }
                        else
                        {
                            m_XmlPackage = AppLogic.ro_DefaultProductXmlPackage; // provide a default
                        }
                    }
                    RequiresReg = DB.RSFieldBool(rs, "RequiresRegistration");
                    ProductName = DB.RSFieldByLocale(rs, "Name", ThisCustomer.LocaleSetting);

                    CategoryHelper     = AppLogic.LookupHelper("Category", 0);
                    SectionHelper      = AppLogic.LookupHelper("Section", 0);
                    ManufacturerHelper = AppLogic.LookupHelper("Manufacturer", 0);
                    DistributorHelper  = AppLogic.LookupHelper("Distributor", 0);
                    GenreHelper        = AppLogic.LookupHelper("Genre", 0);
                    VectorHelper       = AppLogic.LookupHelper("Vector", 0);

                    String SEName = String.Empty;
                    if (DB.RSFieldByLocale(rs, "SETitle", ThisCustomer.LocaleSetting).Length == 0)
                    {
                        SETitle = Security.HtmlEncode(AppLogic.AppConfig("StoreName") + " - " + ProductName);
                    }
                    else
                    {
                        SETitle = DB.RSFieldByLocale(rs, "SETitle", ThisCustomer.LocaleSetting);
                    }
                    if (DB.RSFieldByLocale(rs, "SEDescription", ThisCustomer.LocaleSetting).Length == 0)
                    {
                        SEDescription = Security.HtmlEncode(ProductName);
                    }
                    else
                    {
                        SEDescription = DB.RSFieldByLocale(rs, "SEDescription", ThisCustomer.LocaleSetting);
                    }
                    if (DB.RSFieldByLocale(rs, "SEKeywords", ThisCustomer.LocaleSetting).Length == 0)
                    {
                        SEKeywords = Security.HtmlEncode(ProductName);
                    }
                    else
                    {
                        SEKeywords = DB.RSFieldByLocale(rs, "SEKeywords", ThisCustomer.LocaleSetting);
                    }
                    SENoScript = DB.RSFieldByLocale(rs, "SENoScript", ThisCustomer.LocaleSetting);
                }
            }

            //Log all views of unknown and registered customer
            if (!AppLogic.ProductIsMLExpress() && (AppLogic.AppConfigBool("DynamicRelatedProducts.Enabled") || AppLogic.AppConfigBool("RecentlyViewedProducts.Enabled")))
            {
                ThisCustomer.LogProductView(ProductID);
            }

            if (IsAKit && !Vortx.MobileFramework.MobileHelper.isMobile())
            {
                Server.Transfer(ResolveClientUrl("~/kitproduct.aspx"), true);
                return;
            }
            else if (IsAKit && Vortx.MobileFramework.MobileHelper.isMobile())
            {
                Server.Transfer(ResolveClientUrl("~/mobilekitproduct.aspx"), true);
                return;
            }

            CategoryName     = CategoryHelper.GetEntityName(CategoryID, ThisCustomer.LocaleSetting);
            SectionName      = SectionHelper.GetEntityName(SectionID, ThisCustomer.LocaleSetting);
            ManufacturerName = ManufacturerHelper.GetEntityName(ManufacturerID, ThisCustomer.LocaleSetting);
            DistributorName  = DistributorHelper.GetEntityName(DistributorID, ThisCustomer.LocaleSetting);
            GenreName        = GenreHelper.GetEntityName(GenreID, ThisCustomer.LocaleSetting);
            VectorName       = VectorHelper.GetEntityName(VectorID, ThisCustomer.LocaleSetting);

            String SourceEntityInstanceName = String.Empty;

            if (ManufacturerID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = ManufacturerID.ToString();
                Profile.LastViewedEntityInstanceName = ManufacturerName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (DistributorID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_DistributorEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = DistributorID.ToString();
                Profile.LastViewedEntityInstanceName = DistributorName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (GenreID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_GenreEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = GenreID.ToString();
                Profile.LastViewedEntityInstanceName = GenreName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (VectorID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_VectorEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = VectorID.ToString();
                Profile.LastViewedEntityInstanceName = VectorName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (CategoryID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = CategoryID.ToString();
                Profile.LastViewedEntityInstanceName = CategoryName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (SectionID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = SectionID.ToString();
                Profile.LastViewedEntityInstanceName = SectionName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }

            SourceEntity             = Profile.LastViewedEntityName;
            SourceEntityInstanceName = Profile.LastViewedEntityInstanceName;
            SourceEntityID           = int.Parse(CommonLogic.IIF(CommonLogic.IsInteger(Profile.LastViewedEntityInstanceID), Profile.LastViewedEntityInstanceID, "0"));

            // validate that source entity id is actually valid for this product:
            if (SourceEntityID != 0)
            {
                String sqlx = string.Format("select count(*) as N from productentity a with (nolock) inner join (select distinct a.entityid, a.EntityType from productentity a with (nolock) left join EntityStore b with (nolock) " +
                                            "on a.EntityID = b.EntityID where ({0} = 0 or StoreID = {1})) b on a.EntityID = b.EntityID and a.EntityType=b.EntityType where ProductID = {2} and a.EntityID = {3} and a.EntityType = {4}"
                                            , CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), ProductID, SourceEntityID, DB.SQuote(SourceEntity));
                if (DB.GetSqlN(sqlx) == 0)
                {
                    SourceEntityID = 0;
                }
            }

            // we had no entity context coming in, try to find a category context for this product, so they have some context if possible:
            if (SourceEntityID == 0)
            {
                SourceEntityID = EntityHelper.GetProductsFirstEntity(ProductID, EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName);
                if (SourceEntityID > 0)
                {
                    CategoryID   = SourceEntityID;
                    CategoryName = CategoryHelper.GetEntityName(CategoryID, ThisCustomer.LocaleSetting);

                    Profile.LastViewedEntityName         = EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName;
                    Profile.LastViewedEntityInstanceID   = CategoryID.ToString();
                    Profile.LastViewedEntityInstanceName = CategoryName;

                    SourceEntity             = EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName;
                    SourceEntityInstanceName = CategoryName;
                }
            }

            // we had no entity context coming in, try to find a section context for this product, so they have some context if possible:
            if (SourceEntityID == 0)
            {
                SourceEntityID = EntityHelper.GetProductsFirstEntity(ProductID, EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName);
                if (SourceEntityID > 0)
                {
                    SectionID   = SourceEntityID;
                    SectionName = CategoryHelper.GetEntityName(SectionID, ThisCustomer.LocaleSetting);

                    Profile.LastViewedEntityName         = EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName;
                    Profile.LastViewedEntityInstanceID   = SectionID.ToString();
                    Profile.LastViewedEntityInstanceName = SectionName;

                    SourceEntity             = EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName;
                    SourceEntityInstanceName = SectionName;
                }
            }

            // we had no entity context coming in, try to find a Manufacturer context for this product, so they have some context if possible:
            if (SourceEntityID == 0)
            {
                SourceEntityID = EntityHelper.GetProductsFirstEntity(ProductID, EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName);
                if (SourceEntityID > 0)
                {
                    ManufacturerID   = SourceEntityID;
                    ManufacturerName = CategoryHelper.GetEntityName(ManufacturerID, ThisCustomer.LocaleSetting);

                    Profile.LastViewedEntityName         = EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName;
                    Profile.LastViewedEntityInstanceID   = ManufacturerID.ToString();
                    Profile.LastViewedEntityInstanceName = ManufacturerName;

                    SourceEntity             = EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName;
                    SourceEntityInstanceName = ManufacturerName;
                }
            }

            // build up breadcrumb if we need:
            SectionTitle = Breadcrumb.GetProductBreadcrumb(ProductID, ProductName, SourceEntity, SourceEntityID, ThisCustomer);
            //Reset LastViewedEntityInstanceID to zero if no entities are mapped to the product so the left nav will render properly.
            if (SourceEntityID <= 0)
            {
                HttpContext.Current.Profile.SetPropertyValue("LastViewedEntityInstanceID", "0");
            }

            if (RequiresReg && !ThisCustomer.IsRegistered)
            {
                m_PageOutput += "<br/><br/><br/><br/><b>" + AppLogic.GetString("showproduct.aspx.1", SkinID, ThisCustomer.LocaleSetting) + "</b><br/><br/><br/><a href=\"signin.aspx?returnurl=" + CommonLogic.GetThisPageName(false) + "?ProductID=" + ProductID.ToString() + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING").Trim().Length > 0, "&" + Security.HtmlEncode(Security.UrlEncode(CommonLogic.ServerVariables("QUERY_STRING"))), String.Empty) + "\">" + AppLogic.GetString("showproduct.aspx.2", SkinID, ThisCustomer.LocaleSetting) + "</a> " + AppLogic.GetString("showproduct.aspx.3", SkinID, ThisCustomer.LocaleSetting);
            }
            else
            {
                AppLogic.eventHandler("ViewProductPage").CallEvent("&ViewProductPage=true");

                // check if the postback was caused by an addtocart button
                if (this.IsPostBack && this.IsAddToCartPostBack)
                {
                    HandleAddToCart();
                    return;
                }

                DB.ExecuteSQL("update product set Looks=Looks+1 where ProductID=" + ProductID.ToString());

                m_PageOutput = "<!-- XmlPackage: " + m_XmlPackage + " -->\n";
                if (m_XmlPackage.Length == 0)
                {
                    m_PageOutput += "<p><b><font color=red>XmlPackage format was chosen, but no XmlPackage was specified!</font></b></p>";
                }
                else
                {
                    using (XmlPackage2 p = new XmlPackage2(m_XmlPackage, ThisCustomer, SkinID, "", "EntityName=" + SourceEntity + "&EntityID=" + SourceEntityID.ToString() + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING").IndexOf("cartrecid") != -1, "&cartrecid=" + CommonLogic.QueryStringUSInt("cartrecid").ToString(), "&showproduct=1"), String.Empty, true))
                    {
                        m_PageOutput += AppLogic.RunXmlPackage(p, base.GetParser, ThisCustomer, SkinID, true, true);
                        if (p.SectionTitle != "")
                        {
                            SectionTitle = p.SectionTitle;
                        }
                        if (p.SETitle != "")
                        {
                            SETitle = p.SETitle;
                        }
                        if (p.SEDescription != "")
                        {
                            SEDescription = p.SEDescription;
                        }
                        if (p.SEKeywords != "")
                        {
                            SEKeywords = p.SEKeywords;
                        }
                        if (p.SENoScript != "")
                        {
                            SENoScript = p.SENoScript;
                        }
                    }
                }
            }
            litOutput.Text = m_PageOutput;
        }
예제 #7
0
        /// <summary>
        /// Assign the Datasource items into the controls.
        /// </summary>
        /// <param name="cItem"></param>
        private void AssignDataSourceContentToControls(CartItem cItem)
        {
            //Product Image
            if (LineItemDescriptionSettings.ShowPicsInCart)
            {
                imgProductPic.ImageUrl = cItem.ProductPicURL;
                if (cItem.SEAltText != null)
                {
                    imgProductPic.AlternateText = XmlCommon.GetLocaleEntry(cItem.SEAltText, Customer.Current.LocaleSetting, false);
                }
            }

            //Product Name
            lnkProductName.Text = cItem.ProductName + cItem.ChosenColorSKUModifier + cItem.ChosenSizeSKUModifier;

            lnkProductName.Attributes["class"] = "black-color";
            if (LineItemDescriptionSettings != null)
            {
                if (LineItemDescriptionSettings.LinkToProductPageInCart && !cItem.IsSystem && !cItem.IsAuctionItem)
                {
                    lnkProductName.NavigateUrl = SE.MakeProductLink(cItem.ProductID, "");
                }

                if (!this.IsMiniCart)
                {
                    //SKU
                    if (!cItem.IsSystem)
                    {
                        if (LineItemDescriptionSettings.SKUCaption != null)
                        {
                            lblSKUCaption.Text = LineItemDescriptionSettings.SKUCaption;
                        }
                        lblSKU.Text = cItem.SKU;
                    }

                    //GiftRegistry
                    if (cItem.GiftRegistryForCustomerID != 0)
                    {
                        if (LineItemDescriptionSettings.GiftRegistryCaption != null)
                        {
                            lblGiftRegistryCaption.Text = LineItemDescriptionSettings.GiftRegistryCaption;
                        }
                        lblGiftRegistry.Text = string.Format(lblGiftRegistryCaption.Text, cItem.GiftRegistryDisplayName);
                    }

                    //Size
                    if (cItem.ChosenSize.Length != 0)
                    {
                        lblSizeCaption.Text = cItem.SizeOptionPrompt;
                        lblSize.Text        = cItem.ChosenSizeDisplayFormat;
                    }

                    //Color
                    if (cItem.ChosenColor.Length != 0)
                    {
                        lblColorCaption.Text = cItem.ColorOptionPrompt;
                        lblColor.Text        = cItem.ChosenColorDisplayFormat;
                    }

                    //Shipping display
                    cItem.ShowMultiShipAddressUnderItemDescription = LineItemDescriptionSettings.ShowMultiShipAddressUnderItemDescription;
                    lblShipping.Text = cItem.LineItemShippingDisplay;


                    //Text Option
                    if (cItem.TextOption.Length != 0)
                    {
                        lblTextOptionCaption.Text = cItem.TextOptionPrompt;
                        ltTextOption.Text         = cItem.TextOptionDisplayFormat;
                    }

                    //Recurring
                    if (cItem.IsRecurring && cItem.RecurringDisplay.Length != 0)
                    {
                        lblRecurring.Text = cItem.RecurringDisplay;
                    }

                    //Item Notes
                    if (LineItemDescriptionSettings.AllowShoppingCartItemNotes &&
                        !cItem.IsSystem &&
                        cItem.ThisShoppingCart.CartType == CartTypeEnum.ShoppingCart &&
                        !DisAllowItemNotes)
                    {
                        txtItemNotes.ReadOnly    = !AllowEdit;
                        lblItemNotesCaption.Text = LineItemDescriptionSettings.ItemNotesCaption;
                        txtItemNotes.Columns     = LineItemDescriptionSettings.ItemNotesColumns;
                        txtItemNotes.Rows        = LineItemDescriptionSettings.ItemNotesRows;
                        txtItemNotes.Text        = cItem.Notes;
                    }

                    var discountResult = cItem.ThisShoppingCart.DiscountResults.Where(dr => dr.DiscountedItems.Any(di => di.ShoppingCartRecordId == cItem.ShoppingCartRecordID)).FirstOrDefault();
                    if (discountResult != null)
                    {
                        lblPromotionHeading.Text = discountResult.Promotion.UsageText;
                    }
                }
            }
        }
        private void DoSubmit()
        {
            Page.Validate();
            if (Page.IsValid)
            {
                string FromAddress = txtFromAddress.Text;
                string ToAddress   = txtToAddress.Text;
                string BotAddress  = AppLogic.AppConfig("ReceiptEMailFrom");
                string Subject     = AppLogic.AppConfig("StoreName") + " - " + SE.MungeName(ProductName);
                var    Body        = new StringBuilder(4096);

                var runtimeParams = new List <XmlPackageParam>();
                runtimeParams.Add(new XmlPackageParam("Subject", Subject));
                runtimeParams.Add(new XmlPackageParam("ItemCode", ItemCode));
                runtimeParams.Add(new XmlPackageParam("UserCode", InterpriseHelper.ConfigInstance.UserCode));

                Body.Append(
                    AppLogic.RunXmlPackage(
                        "notification.emailproduct.xml.config",
                        null,
                        ThisCustomer,
                        SkinID,
                        string.Empty,
                        runtimeParams,
                        false,
                        false
                        )
                    );

                try
                {
                    if (AppLogic.AppConfig("MailMe_Server").Trim() != string.Empty)
                    {
                        AppLogic.SendMail(Subject, Body.ToString(), true, BotAddress, BotAddress, ToAddress, ToAddress, "", AppLogic.AppConfig("MailMe_Server"));
                        emailproduct_aspx_8.Text = AppLogic.GetString("emailproduct.aspx.8", SkinID, ThisCustomer.LocaleSetting);
                        pnlSuccess.Visible       = true;
                        pnlRequireReg.Visible    = false;
                        pnlEmailToFriend.Visible = false;
                    }
                    else
                    {
                        emailproduct_aspx_8.Text = AppLogic.GetString("emailproduct.aspx.24", SkinID, ThisCustomer.LocaleSetting);
                        pnlSuccess.Visible       = true;
                        pnlRequireReg.Visible    = false;
                        pnlEmailToFriend.Visible = false;
                    }
                    //mobile added design
                    divEmailBody.Visible = false;
                }
                catch (Exception ex)
                {
                    emailproduct_aspx_8.Text = string.Format(AppLogic.GetString("emailproduct.aspx.9", SkinID, ThisCustomer.LocaleSetting), CommonLogic.GetExceptionDetail(ex, "<br>"));
                    pnlSuccess.Visible       = true;
                    pnlRequireReg.Visible    = false;
                    pnlEmailToFriend.Visible = false;
                }
                ReturnToProduct.Text        = AppLogic.GetString("emailproduct.aspx.10", SkinID, ThisCustomer.LocaleSetting);
                ReturnToProduct.NavigateUrl = SE.MakeProductLink(productID.ToString(), SEName);
            }
            else
            {
                InitializePageContent();
            }
        }