private void ExpandCustomerfund()
    {
        CustomerFund cf = new CustomerFund();
        int          customerLevelId = (int)UserType.BLUUNLIMITED;

        lstCustomerFund       = AuthenticationSSO.GetCustomerFund(ThisCustomer.CustomerID);
        lblCustomerLevel.Text = "Level: " + ((ThisCustomer.CustomerLevelID == customerLevelId) ? "Partners" : ThisCustomer.CustomerLevelName);
        lblDealerLevel.Text   = ((ThisCustomer.CustomerLevelID == customerLevelId) ? "Partners" : ThisCustomer.CustomerLevelName.Replace("BLU", ""));

        if (ThisCustomer.CustomerLevelID == (int)UserType.POTENTIAL)
        {
            lstCustomerFund.RemoveAll(x => x.FundID == (int)FundType.BLUBucks);
            hBluBucks.Visible = false;
        }
        else if (ThisCustomer.CustomerLevelID == (int)UserType.HOMEDEPOT || ThisCustomer.CustomerLevelID == (int)UserType.MENARDS || ThisCustomer.CustomerLevelID == (int)UserType.LOWES)
        {
            lstCustomerFund.RemoveAll(x => x.FundID == (int)FundType.BLUBucks);
            hBluBucks.Visible = false;
            dLogoBox.Visible  = false;
        }
        else
        {
            dLogoBox.Visible  = true;
            hBluBucks.Visible = true;
        }
        lstCustomerFund.RemoveAll(x => x.FundID == (int)FundType.SOFFunds);
        cf = lstCustomerFund.SingleOrDefault(x => x.FundID == (int)FundType.BLUBucks);
        //if (ThisCustomer.CustomerLevelID == (int)UserType.BLUUNLIMITED)
        //{
        //    if (cf != null)
        //    {
        //        lstCustomerFund.Clear();
        //        lstCustomerFund.Add(cf);
        //        rptCustomerFunds.DataSource = lstCustomerFund;
        //        rptCustomerFunds.DataBind();
        //    }
        //    else
        //    {
        //        lstCustomerFund.Clear();
        //        rptCustomerFunds.DataSource = lstCustomerFund;
        //        rptCustomerFunds.DataBind();
        //    }
        //    ExpandFunds.Visible = false;
        //    lnkHideFunds.Visible = false;
        //    return;
        //}
        if (cf != null)
        {
            lstCustomerFund.Remove(cf);
            GetFilteredCustomerFund(lstCustomerFund);
            lstCustomerFund.Clear();
            lstCustomerFund.Add(cf);
            rptCustomerFunds.DataSource = lstCustomerFund;
            rptCustomerFunds.DataBind();
        }
        else
        {
            GetFilteredCustomerFund(lstCustomerFund);
        }
    }
Exemple #2
0
 private void getCustomerfund()
 {
     if (ThisCustomer.CustomerLevelID == (int)UserType.SALESREPS || ThisCustomer.CustomerLevelID == (int)UserType.INTERNAL)
     {
         decimal SAFAmount = AuthenticationSSO.GetCustomerFund(ThisCustomer.CustomerID, (int)FundType.SOFFunds).AmountAvailable;
         lblSOF.Text = "Sales Funds = " + String.Format("{0:C}", SAFAmount);
     }
 }
        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);
        }
Exemple #4
0
        private void CalculateFundsForReOrder()
        {
            ShoppingCart cart = new ShoppingCart(ThisCustomer.SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);

            System.Collections.Generic.List <CustomerFund> CustomerFunds = AuthenticationSSO.GetCustomerFund(ThisCustomer.CustomerID, true);

            Decimal      BluBucksPercentage = AuthenticationSSO.GetBudgetPercentageRatio(ThisCustomer.CustomerLevelID, Convert.ToInt32(FundType.BLUBucks)).BudgetPercentageValue;
            CustomerFund BluBucksFund       = CustomerFunds.Find(x => x.FundID == Convert.ToInt32(FundType.BLUBucks));
            Decimal      BluBucksAvailable  = 0;

            if (BluBucksFund != null)
            {
                BluBucksAvailable = BluBucksFund.AmountAvailable;
            }

            foreach (CartItem cItem in cart.CartItems.ToArrayList())
            {
                String RecordID = cItem.ShoppingCartRecordID.ToString();
                int    FundID   = GetProductFundID(cItem.ProductID); //Get latest Fund ID of product , dont use fund id already assigned it may change

                if (cItem.GLcode == "3" || cItem.GLcode == "4")      //For no fund and capex category fund should not be applied
                {
                    FundID = 0;
                }

                Decimal Productprice = cItem.Price;
                int     Quantity     = cItem.Quantity;
                Decimal TotalPrice   = Convert.ToDecimal(Productprice * Quantity);



                //Apply Product Category Fund
                CustomerFund CategoryFund = CustomerFunds.Find(x => x.FundID == FundID);
                if (CategoryFund != null)
                {
                    Decimal CategoryFundAmountAvailable = CategoryFund.AmountAvailable;
                    if (CategoryFundAmountAvailable < TotalPrice)
                    {
                        TotalPrice             = TotalPrice - CategoryFundAmountAvailable;
                        cItem.CategoryFundUsed = CategoryFundAmountAvailable;
                    }
                    else
                    {
                        CategoryFundAmountAvailable = CategoryFundAmountAvailable - TotalPrice;
                        cItem.CategoryFundUsed      = TotalPrice;
                        TotalPrice = 0;
                    }
                    CustomerFunds.Find(x => x.FundID == FundID).AmountUsed = CustomerFunds.Find(x => x.FundID == FundID).AmountUsed + cItem.CategoryFundUsed;
                }
                else
                {
                    cItem.CategoryFundUsed = 0;
                    cItem.FundID           = 0;
                }
                //End Apply Product Category Fund

                //Apply BluBucks to this item based on available bucks and percentage ratio
                //CustomerFund BluBucksFund = CustomerFunds.Find(x => x.FundID == Convert.ToInt32(FundType.BLUBucks));
                cItem.BluBucksPercentageUsed = BluBucksPercentage;
                if (BluBucksAvailable > 0)
                {
                    Decimal amountTopaidbyBluBucks = Math.Round((TotalPrice * (BluBucksPercentage / 100)), 2);

                    if (BluBucksAvailable < amountTopaidbyBluBucks)
                    {
                        cItem.BluBuksUsed = BluBucksAvailable;
                        BluBucksAvailable = 0;
                    }
                    else
                    {
                        cItem.BluBuksUsed = amountTopaidbyBluBucks;
                        BluBucksAvailable = BluBucksAvailable - amountTopaidbyBluBucks;
                    }
                }
                else
                {
                    cItem.BluBuksUsed = 0;
                }
                //End Apply BluBucks

                cart.SetItemFundsUsed(cItem.ShoppingCartRecordID, cItem.CategoryFundUsed, cItem.BluBuksUsed, cItem.GLcode, BluBucksPercentage, cItem.SOFCode);
            }
        }