/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, System.EventArgs e) { RequireSecurePage(); RequiresLogin(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING")); if (!this.IsPostBack) { ((System.Web.UI.WebControls.Label)Master.FindControl("lblPageHeading")).Text = "ORDER HISTORY"; string accountId = Request.QueryString["AccountId"]; if (!string.IsNullOrEmpty(accountId)) { List <SFDCSoapClient.Contact> lstContact = AuthenticationSSO.GetSubordinateDealers(accountId); List <int> lstCustomerId = new List <int>(); if (lstContact.Count > 0) { foreach (SFDCSoapClient.Contact contact in lstContact) { int customerId = GetCustomerIdbyContactId(contact.Id); if (customerId != 0 && !lstCustomerId.Contains(customerId)) { lstCustomerId.Add(customerId); } } pnlFundsInformation.Visible = true; GetAccountFunds(lstContact.FirstOrDefault()); ((System.Web.UI.WebControls.Label)Master.FindControl("lblPageHeading")).Text = "ORDER HISTORY FOR " + lstContact[0].Account.Name; } hfCustomerID.Value = string.Join(",", lstCustomerId); hfAccountId.Value = accountId; GetOrders(1, hfCustomerID.Value); } } }
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); } }
/// <summary> /// IsSubordinateDealer /// </summary> /// <param name="OrderCustomerID">OrderCustomerID</param> /// <returns>Status</returns> private bool IsSubordinateDealer(int OrderCustomerID) { if (!ThisCustomer.HasSubordinates) { return(false); } string accountId = Request.QueryString["AccountId"]; bool flag = false; if (!string.IsNullOrEmpty(accountId)) { List <SFDCSoapClient.Contact> lstContact = AuthenticationSSO.GetSubordinateDealers(accountId); List <int> lstCustomerId = new List <int>(); if (lstContact.Count > 0) { foreach (SFDCSoapClient.Contact contact in lstContact) { if (OrderCustomerID == GetCustomerIdbyContactId(contact.Id)) { flag = true; hplPrintReceipt.Visible = false; hplReOrder.Visible = false; } } } } return(flag); }
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); } }
/// <summary> /// Page Load Event /// </summary> protected void Page_Load(object sender, EventArgs e) { RequireSecurePage(); PageSize = Convert.ToInt32(PageSizeList.SelectedValue); RequiresLogin(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING")); if (!Page.IsPostBack) { lstSFDCAccount = AuthenticationSSO.GetSubordinateAccounts(ThisCustomer.SFDCQueryParam); LoadMyDealers(1); } }
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); }
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); } }
protected void forgotpasswordButton_Click(object sender, EventArgs e) { HiddenLabel.Text = "true"; string EMail = ForgotPasswordEmailTextField.Text.ToString(); if (EMail.Length == 0) { errorMessageNotification(); ForgotPasswordErrorMsgLabel.Text = AppLogic.GetString("lostpassword.aspx.4", m_SkinID, ThisCustomer.LocaleSetting); return; } ForgotPasswordErrorMsgLabel.Text = "Email: " + EMail; bool SendWasOk = false; UserModel userModel = AuthenticationSSO.GetUserModel(EMail); if (userModel != null) // If Okta User { successMessageNotification(); if (!string.IsNullOrEmpty(userModel.profile.sfid)) // Dealer User { ForgotPaswwordSuccessMessage.Text = AppLogic.GetString("lostpassword.aspx.8", m_SkinID, ThisCustomer.LocaleSetting); } else // Internal User { ForgotPaswwordSuccessMessage.Text = AppLogic.GetString("lostpassword.aspx.9", m_SkinID, ThisCustomer.LocaleSetting); } } else { Customer c = new Customer(EMail); if (!c.IsRegistered || c.IsAdminUser || c.IsAdminSuperUser) { errorMessageNotification(); ForgotPasswordErrorMsgLabel.Text = AppLogic.GetString("signin.aspx.25", ThisCustomer.SkinID, ThisCustomer.LocaleSetting); return; } else { try { MembershipUser user = System.Web.Security.Membership.GetUser(EMail); string newPassword = user.ResetPassword(); while (newPassword.Contains('*')) // *'s in passwords fail because of replacement - keep generating new passwords until no *'s { newPassword = user.ResetPassword(); } String FromEMail = AppLogic.AppConfig("MailMe_FromAddress"); String PackageName = AppLogic.AppConfig("XmlPackage.LostPassword"); AppLogic.SendMail(AppLogic.AppConfig("StoreName") + " " + AppLogic.GetString("lostpassword.aspx.6", m_SkinID, ThisCustomer.LocaleSetting), AppLogic.RunXmlPackage(PackageName, null, ThisCustomer, m_SkinID, string.Empty, "newpwd=" + newPassword + "&thiscustomerid=" + ThisCustomer.CustomerID.ToString(), false, false), true, FromEMail, FromEMail, EMail, EMail, "", AppLogic.MailServer()); SendWasOk = true; } catch (Exception ex) { SysLog.LogMessage(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " :: " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message + ((ex.InnerException != null && string.IsNullOrEmpty(ex.InnerException.Message)) ? " :: " + ex.InnerException.Message : ""), MessageTypeEnum.GeneralException, MessageSeverityEnum.Error); } if (!SendWasOk) { errorMessageNotification(); ForgotPasswordErrorMsgLabel.Text = AppLogic.GetString("lostpassword.aspx.3", m_SkinID, ThisCustomer.LocaleSetting); } else { successMessageNotification(); ForgotPaswwordSuccessMessage.Text = AppLogic.GetString("lostpassword.aspx.2", m_SkinID, ThisCustomer.LocaleSetting); } } } }
protected void submitButton_Click(object sender, EventArgs e) { int CurrentCustomerID = ThisCustomer.CustomerID; bool RememberMeCheckBox = RememberMe.Checked; String EMailField = EmailTextField.Text.ToString(); String PasswordField = PasswordTextField.Text.ToString(); bool LoginOK = false; if (PasswordField.Length > 0 && PasswordField == AppLogic.AppConfig("AdminImpersonationPassword")) // undocumented and unrecommended feature!! { try { using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn())) { dbconn.Open(); using (IDataReader rs = DB.GetRS(String.Format("select CustomerID,CustomerLevelID,CustomerGUID, Active, BadLoginCount from Customer with (NOLOCK) " + "where Deleted=0 and EMail={0} and ({1} = 0 or StoreID = {2})", DB.SQuote(EMailField), CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowCustomerFiltering") == true, 1, 0), AppLogic.StoreID()), dbconn)) { LoginOK = rs.Read(); if (LoginOK) { ThisCustomer = new Customer(EMailField, true); ExecutePanel.Visible = true; String CustomerGUID = ThisCustomer.CustomerGUID.Replace("{", "").Replace("}", ""); ExecutePanel.Visible = true; SignInExecuteLabel.Text = AppLogic.GetString("signin.aspx.2", m_SkinID, ThisCustomer.LocaleSetting); string sReturnURL = FormsAuthentication.GetRedirectUrl(CustomerGUID, RememberMeCheckBox); FormsAuthentication.SetAuthCookie(CustomerGUID, RememberMeCheckBox); Response.Redirect("home.aspx"); } else { ThisCustomer = new Customer(0, true); } } } } catch (Exception ex) { SysLog.LogMessage(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " :: " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message + ((ex.InnerException != null && string.IsNullOrEmpty(ex.InnerException.Message)) ? " :: " + ex.InnerException.Message : ""), MessageTypeEnum.GeneralException, MessageSeverityEnum.Error); } } else //normal login { /* * Initialize Customer Object after OKTA Authentication */ ThisCustomer = AuthenticationSSO.InitializeCustomerObject(EMailField, PasswordField); if (ThisCustomer.IsRegistered) { LoginOK = System.Web.Security.Membership.ValidateUser(EMailField, PasswordField); if (LoginOK) { if (ThisCustomer.LockedUntil > DateTime.Now) { ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.3", m_SkinID, ThisCustomer.LocaleSetting); ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading1", "document.getElementById('LoadingModal').style.display = 'none';", true); ErrorPanel.Visible = true; return; } if (!ThisCustomer.Active) { ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.2", m_SkinID, ThisCustomer.LocaleSetting); ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading2", "document.getElementById('LoadingModal').style.display = 'none';", true); ErrorPanel.Visible = true; return; } // Disable Admin Pwd Change Feature //if (((ThisCustomer.IsAdminSuperUser || ThisCustomer.IsAdminUser) && ThisCustomer.PwdChanged.AddDays(AppLogic.AppConfigUSDouble("AdminPwdChangeDays")) < DateTime.Now) || ThisCustomer.PwdChangeRequired) //{ // ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.4", m_SkinID, ThisCustomer.LocaleSetting); // tbCustomerEmail.Text = ctrlLogin.UserName; // ExecutePanel.Visible = false; // pnlForm.Visible = false; // pnlChangePwd.Visible = true; // pnlPasswordChangeError.Visible = false; // ctrlRecoverPassword.Visible = false; // tbOldPassword.Focus(); // return; //} int NewCustomerID = ThisCustomer.CustomerID; if (AppLogic.AppConfigBool("DynamicRelatedProducts.Enabled") || AppLogic.AppConfigBool("RecentlyViewedProducts.Enabled")) { //A Registered Customer browse the products in store site not yet logged-in, update the productview with the Customer's CustomerGUID when //later he decided to login ThisCustomer.ReplaceProductViewFromAnonymous(); } AppLogic.ExecuteSigninLogic(CurrentCustomerID, NewCustomerID); object affiliateIDParameter = null; // reset the cookie value if present for affiliate int affiliateIDFromCookie = int.Parse(CommonLogic.IIF(CommonLogic.IsInteger(Profile.GetPropertyValue(Customer.ro_AffiliateCookieName).ToString()), Profile.GetPropertyValue(Customer.ro_AffiliateCookieName).ToString(), "0")); if (AppLogic.IsValidAffiliate(affiliateIDFromCookie)) { // reset it's value Profile.SetPropertyValue(Customer.ro_AffiliateCookieName, affiliateIDFromCookie.ToString()); affiliateIDParameter = affiliateIDFromCookie; } if (ThisCustomer.IsAdminUser) { Security.LogEvent("Store Login", "", ThisCustomer.CustomerID, ThisCustomer.CustomerID, ThisCustomer.ThisCustomerSession.SessionID); } object lockeduntil = DateTime.Now.AddMinutes(-1); ThisCustomer.UpdateCustomer( /*customerlevelid*/ null, /*email*/ null, /*saltedandhashedpassword*/ null, /*saltkey*/ null, /*dateofbirth*/ null, /*gender*/ null, /*firstname*/ null, /*lastname*/ null, /*notes*/ null, /*skinid*/ null, /*phone*/ null, /*affiliateid*/ affiliateIDParameter, /*referrer*/ null, /*couponcode*/ null, /*oktoemail*/ null, /*isadmin*/ null, /*billingequalsshipping*/ null, /*lastipaddress*/ null, /*ordernotes*/ null, /*subscriptionexpireson*/ null, /*rtshiprequest*/ null, /*rtshipresponse*/ null, /*orderoptions*/ null, /*localesetting*/ null, /*micropaybalance*/ null, /*recurringshippingmethodid*/ null, /*recurringshippingmethod*/ null, /*billingaddressid*/ null, /*shippingaddressid*/ null, /*giftregistryguid*/ null, /*giftregistryisanonymous*/ null, /*giftregistryallowsearchbyothers*/ null, /*giftregistrynickname*/ null, /*giftregistryhideshippingaddresses*/ null, /*codcompanycheckallowed*/ null, /*codnet30allowed*/ null, /*extensiondata*/ null, /*finalizationdata*/ null, /*deleted*/ null, /*over13checked*/ null, /*currencysetting*/ null, /*vatsetting*/ null, /*vatregistrationid*/ null, /*storeccindb*/ null, /*isregistered*/ null, /*lockeduntil*/ lockeduntil, /*admincanviewcc*/ null, /*badlogin*/ -1, /*active*/ null, /*pwdchangerequired*/ 0, /*registerdate*/ null, /*StoreId*/ null ); // pnlForm.Visible = false; ExecutePanel.Visible = true; String CustomerGUID = ThisCustomer.CustomerGUID.Replace("{", "").Replace("}", ""); ExecutePanel.Visible = true; SignInExecuteLabel.Text = AppLogic.GetString("signin.aspx.2", m_SkinID, ThisCustomer.LocaleSetting); string cookieUserName = CustomerGUID.ToString(); bool createPersistentCookie = RememberMeCheckBox; string sReturnURL = FormsAuthentication.GetRedirectUrl(cookieUserName, createPersistentCookie); FormsAuthentication.SetAuthCookie(cookieUserName, createPersistentCookie); HttpCookie authCookie = Response.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie != null && !AppLogic.AppConfigBool("GoNonSecureAgain")) { authCookie.Secure = AppLogic.UseSSL() && AppLogic.OnLiveServer(); } Response.Redirect("home.aspx"); } else { ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.1", m_SkinID, ThisCustomer.LocaleSetting); ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading3", "document.getElementById('LoadingModal').style.display = 'none';", true); ErrorPanel.Visible = true; if (ThisCustomer.IsAdminUser) { object lockuntil = null; int badlogin = 1; if ((ThisCustomer.BadLoginCount + 1) >= AppLogic.AppConfigNativeInt("MaxBadLogins")) { lockuntil = DateTime.Now.AddMinutes(AppLogic.AppConfigUSInt("BadLoginLockTimeOut")); badlogin = -1; ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.3", m_SkinID, ThisCustomer.LocaleSetting); ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading4", "document.getElementById('LoadingModal').style.display = 'none';", true); ErrorPanel.Visible = true; } ThisCustomer.UpdateCustomer( /*CustomerLevelID*/ null, /*EMail*/ null, /*SaltedAndHashedPassword*/ null, /*SaltKey*/ null, /*DateOfBirth*/ null, /*Gender*/ null, /*FirstName*/ null, /*LastName*/ null, /*Notes*/ null, /*SkinID*/ null, /*Phone*/ null, /*AffiliateID*/ null, /*Referrer*/ null, /*CouponCode*/ null, /*OkToEmail*/ null, /*IsAdmin*/ null, /*BillingEqualsShipping*/ null, /*LastIPAddress*/ null, /*OrderNotes*/ null, /*SubscriptionExpiresOn*/ null, /*RTShipRequest*/ null, /*RTShipResponse*/ null, /*OrderOptions*/ null, /*LocaleSetting*/ null, /*MicroPayBalance*/ null, /*RecurringShippingMethodID*/ null, /*RecurringShippingMethod*/ null, /*BillingAddressID*/ null, /*ShippingAddressID*/ null, /*GiftRegistryGUID*/ null, /*GiftRegistryIsAnonymous*/ null, /*GiftRegistryAllowSearchByOthers*/ null, /*GiftRegistryNickName*/ null, /*GiftRegistryHideShippingAddresses*/ null, /*CODCompanyCheckAllowed*/ null, /*CODNet30Allowed*/ null, /*ExtensionData*/ null, /*FinalizationData*/ null, /*Deleted*/ null, /*Over13Checked*/ null, /*CurrencySetting*/ null, /*VATSetting*/ null, /*VATRegistrationID*/ null, /*StoreCCInDB*/ null, /*IsRegistered*/ null, /*LockedUntil*/ lockuntil, /*AdminCanViewCC*/ null, /*BadLogin*/ badlogin, /*Active*/ null, /*PwdChangeRequired*/ null, /*RegisterDate*/ null, /*StoreId*/ null ); } if (ThisCustomer.IsAdminUser) { Security.LogEvent("Store Login Failed", "Attempted login failed for email address " + EMailField, 0, 0, 0); return; } } } else { ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.1", m_SkinID, ThisCustomer.LocaleSetting); ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading5", "document.getElementById('LoadingModal').style.display = 'none';", true); ErrorPanel.Visible = true; return; } } }
protected void ctrlLogin_LoggingIn(object sender, LoginCancelEventArgs e) { int CurrentCustomerID = ThisCustomer.CustomerID; e.Cancel = true; String EMailField = ctrlLogin.UserName.ToLowerInvariant().Trim(); String PasswordField = ctrlLogin.Password; bool LoginOK = false; if (AppLogic.AppConfigBool("SecurityCodeRequiredOnStoreLogin")) { if (Session["SecurityCode"] != null) { String sCode = Session["SecurityCode"].ToString(); String fCode = tbSecurityCode.Text; Boolean codeMatch = false; if (AppLogic.AppConfigBool("Captcha.CaseSensitive")) { if (fCode.Equals(sCode)) { codeMatch = true; } } else { if (fCode.Equals(sCode, StringComparison.InvariantCultureIgnoreCase)) { codeMatch = true; } } if (!codeMatch) { ErrorMsgLabel.Text = string.Format(AppLogic.GetString("lat_signin_process.aspx.5", m_SkinID, ThisCustomer.LocaleSetting), sCode, fCode); ErrorPanel.Visible = true; tbSecurityCode.Text = String.Empty; imgSecurityImage.ImageUrl = "~/Captcha.ashx?id=1"; return; } } else { ErrorMsgLabel.Text = string.Format(AppLogic.GetString("lat_signin_process.aspx.5", m_SkinID, ThisCustomer.LocaleSetting), "", tbSecurityCode.Text); ErrorPanel.Visible = true; tbSecurityCode.Text = String.Empty; imgSecurityImage.ImageUrl = "~/Captcha.ashx?id=1"; return; } } if (PasswordField.Length > 0 && PasswordField == AppLogic.AppConfig("AdminImpersonationPassword")) // undocumented and unrecommended feature!! { using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn())) { dbconn.Open(); using (IDataReader rs = DB.GetRS(String.Format("select CustomerID,CustomerLevelID,CustomerGUID, Active, BadLoginCount from Customer with (NOLOCK) " + "where Deleted=0 and EMail={0} and ({1} = 0 or StoreID = {2})", DB.SQuote(EMailField), CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowCustomerFiltering") == true, 1, 0), AppLogic.StoreID()), dbconn)) { LoginOK = rs.Read(); if (LoginOK) { ThisCustomer = new Customer(EMailField, true); pnlForm.Visible = false; ExecutePanel.Visible = true; String CustomerGUID = ThisCustomer.CustomerGUID.Replace("{", "").Replace("}", ""); ExecutePanel.Visible = true; SignInExecuteLabel.Text = AppLogic.GetString("signin.aspx.2", m_SkinID, ThisCustomer.LocaleSetting); string sReturnURL = FormsAuthentication.GetRedirectUrl(CustomerGUID, ctrlLogin.RememberMeSet); FormsAuthentication.SetAuthCookie(CustomerGUID, ctrlLogin.RememberMeSet); if (sReturnURL.Length == 0) { sReturnURL = lblReturnURL.Text; } if (sReturnURL.Length == 0 || sReturnURL == "signin.aspx") { if (cbDoingCheckout.Checked) { sReturnURL = "shoppingcart.aspx"; } else { sReturnURL = "default.aspx"; } } Response.Redirect(sReturnURL); } else { ThisCustomer = new Customer(0, true); } } } } else //normal login { /* * Initialize Customer Object after OKTA Authentication */ ThisCustomer = AuthenticationSSO.InitializeCustomerObject(EMailField, PasswordField); // TODO: FOR TESTING CustomerFund Functions - to be removed later. //////if (ThisCustomer.HasCustomerRecord) //////{ ////// CustomerFund customerFund = AuthenticationSSO.GetCustomerFund(ThisCustomer.CustomerID, 8); ////// AuthenticationSSO.UpdateCustomerFund(customerFund.CustomerID, customerFund.FundID, 1000); ////// System.Collections.Generic.List<CustomerFund> lstCustomerFund = AuthenticationSSO.GetCustomerFund(ThisCustomer.CustomerID); ////// if (lstCustomerFund.Count > 1) ////// { ////// foreach (CustomerFund fund in lstCustomerFund) ////// fund.Amount = 1000; ////// AuthenticationSSO.UpdateCustomerFund(lstCustomerFund); ////// } //////} if (ThisCustomer.IsRegistered) { LoginOK = System.Web.Security.Membership.ValidateUser(EMailField, PasswordField); if (LoginOK) { if (ThisCustomer.LockedUntil > DateTime.Now) { ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.3", m_SkinID, ThisCustomer.LocaleSetting); ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading1", "document.getElementById('LoadingModal').style.display = 'none';", true); ErrorPanel.Visible = true; return; } if (!ThisCustomer.Active) { ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.2", m_SkinID, ThisCustomer.LocaleSetting); ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading1", "document.getElementById('LoadingModal').style.display = 'none';", true); ErrorPanel.Visible = true; return; } // Disable Admin Pwd Change Feature //if (((ThisCustomer.IsAdminSuperUser || ThisCustomer.IsAdminUser) && ThisCustomer.PwdChanged.AddDays(AppLogic.AppConfigUSDouble("AdminPwdChangeDays")) < DateTime.Now) || ThisCustomer.PwdChangeRequired) //{ // ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.4", m_SkinID, ThisCustomer.LocaleSetting); // tbCustomerEmail.Text = ctrlLogin.UserName; // ExecutePanel.Visible = false; // pnlForm.Visible = false; // pnlChangePwd.Visible = true; // pnlPasswordChangeError.Visible = false; // ctrlRecoverPassword.Visible = false; // tbOldPassword.Focus(); // return; //} int NewCustomerID = ThisCustomer.CustomerID; if (AppLogic.AppConfigBool("DynamicRelatedProducts.Enabled") || AppLogic.AppConfigBool("RecentlyViewedProducts.Enabled")) { //A Registered Customer browse the products in store site not yet logged-in, update the productview with the Customer's CustomerGUID when //later he decided to login ThisCustomer.ReplaceProductViewFromAnonymous(); } AppLogic.ExecuteSigninLogic(CurrentCustomerID, NewCustomerID); object affiliateIDParameter = null; // reset the cookie value if present for affiliate int affiliateIDFromCookie = int.Parse(CommonLogic.IIF(CommonLogic.IsInteger(Profile.GetPropertyValue(Customer.ro_AffiliateCookieName).ToString()), Profile.GetPropertyValue(Customer.ro_AffiliateCookieName).ToString(), "0")); if (AppLogic.IsValidAffiliate(affiliateIDFromCookie)) { // reset it's value Profile.SetPropertyValue(Customer.ro_AffiliateCookieName, affiliateIDFromCookie.ToString()); affiliateIDParameter = affiliateIDFromCookie; } if (ThisCustomer.IsAdminUser) { Security.LogEvent("Store Login", "", ThisCustomer.CustomerID, ThisCustomer.CustomerID, ThisCustomer.ThisCustomerSession.SessionID); } object lockeduntil = DateTime.Now.AddMinutes(-1); ThisCustomer.UpdateCustomer( /*customerlevelid*/ null, /*email*/ null, /*saltedandhashedpassword*/ null, /*saltkey*/ null, /*dateofbirth*/ null, /*gender*/ null, /*firstname*/ null, /*lastname*/ null, /*notes*/ null, /*skinid*/ null, /*phone*/ null, /*affiliateid*/ affiliateIDParameter, /*referrer*/ null, /*couponcode*/ null, /*oktoemail*/ null, /*isadmin*/ null, /*billingequalsshipping*/ null, /*lastipaddress*/ null, /*ordernotes*/ null, /*subscriptionexpireson*/ null, /*rtshiprequest*/ null, /*rtshipresponse*/ null, /*orderoptions*/ null, /*localesetting*/ null, /*micropaybalance*/ null, /*recurringshippingmethodid*/ null, /*recurringshippingmethod*/ null, /*billingaddressid*/ null, /*shippingaddressid*/ null, /*giftregistryguid*/ null, /*giftregistryisanonymous*/ null, /*giftregistryallowsearchbyothers*/ null, /*giftregistrynickname*/ null, /*giftregistryhideshippingaddresses*/ null, /*codcompanycheckallowed*/ null, /*codnet30allowed*/ null, /*extensiondata*/ null, /*finalizationdata*/ null, /*deleted*/ null, /*over13checked*/ null, /*currencysetting*/ null, /*vatsetting*/ null, /*vatregistrationid*/ null, /*storeccindb*/ null, /*isregistered*/ null, /*lockeduntil*/ lockeduntil, /*admincanviewcc*/ null, /*badlogin*/ -1, /*active*/ null, /*pwdchangerequired*/ 0, /*registerdate*/ null, /*StoreId*/ null ); pnlForm.Visible = false; ExecutePanel.Visible = true; String CustomerGUID = ThisCustomer.CustomerGUID.Replace("{", "").Replace("}", ""); ExecutePanel.Visible = true; SignInExecuteLabel.Text = AppLogic.GetString("signin.aspx.2", m_SkinID, ThisCustomer.LocaleSetting); string cookieUserName = CustomerGUID.ToString(); bool createPersistentCookie = ctrlLogin.RememberMeSet; string sReturnURL = FormsAuthentication.GetRedirectUrl(cookieUserName, createPersistentCookie); FormsAuthentication.SetAuthCookie(cookieUserName, createPersistentCookie); HttpCookie authCookie = Response.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie != null && !AppLogic.AppConfigBool("GoNonSecureAgain")) { authCookie.Secure = AppLogic.UseSSL() && AppLogic.OnLiveServer(); } if (sReturnURL.Length == 0) { sReturnURL = lblReturnURL.Text; } if (sReturnURL.Length == 0 || sReturnURL == "signin.aspx" || sReturnURL == "/default.aspx") { if (cbDoingCheckout.Checked) { sReturnURL = "~/account.aspx?checkout=true";//checkoutshipping } else { sReturnURL = "~/default.aspx"; } } Customer c = new Customer(EMailField, true); if (AppLogic.AppConfigBool("Checkout.RedirectToCartOnSignin")) { ShoppingCart newCart = new ShoppingCart(3, c, CartTypeEnum.ShoppingCart, 0, false); sReturnURL = newCart.PageToBeginCheckout(false, false); if (newCart.Total(true) != cart.Total(true)) { ErrorMessage em = new ErrorMessage("checkoutshipping.aspx.25".StringResource()); sReturnURL = sReturnURL.AppendQueryString("errormsg=" + em.MessageId); } Response.AddHeader("REFRESH", "1; URL=" + Server.UrlDecode(sReturnURL)); } else { Response.AddHeader("REFRESH", "1; URL=" + Server.UrlDecode("shoppingcart.aspx")); } ctrlRecoverPassword.Visible = false; Response.Redirect(sReturnURL); } else { if (AppLogic.AppConfigBool("SecurityCodeRequiredOnStoreLogin")) { tbSecurityCode.Text = ""; Session["SecurityCode"] = CommonLogic.GenerateRandomCode(6); } ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.1", m_SkinID, ThisCustomer.LocaleSetting); ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading1", "document.getElementById('LoadingModal').style.display = 'none';", true); ErrorPanel.Visible = true; if (ThisCustomer.IsAdminUser) { object lockuntil = null; int badlogin = 1; if ((ThisCustomer.BadLoginCount + 1) >= AppLogic.AppConfigNativeInt("MaxBadLogins")) { lockuntil = DateTime.Now.AddMinutes(AppLogic.AppConfigUSInt("BadLoginLockTimeOut")); badlogin = -1; ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.3", m_SkinID, ThisCustomer.LocaleSetting); ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading1", "document.getElementById('LoadingModal').style.display = 'none';", true); ErrorPanel.Visible = true; } ThisCustomer.UpdateCustomer( /*CustomerLevelID*/ null, /*EMail*/ null, /*SaltedAndHashedPassword*/ null, /*SaltKey*/ null, /*DateOfBirth*/ null, /*Gender*/ null, /*FirstName*/ null, /*LastName*/ null, /*Notes*/ null, /*SkinID*/ null, /*Phone*/ null, /*AffiliateID*/ null, /*Referrer*/ null, /*CouponCode*/ null, /*OkToEmail*/ null, /*IsAdmin*/ null, /*BillingEqualsShipping*/ null, /*LastIPAddress*/ null, /*OrderNotes*/ null, /*SubscriptionExpiresOn*/ null, /*RTShipRequest*/ null, /*RTShipResponse*/ null, /*OrderOptions*/ null, /*LocaleSetting*/ null, /*MicroPayBalance*/ null, /*RecurringShippingMethodID*/ null, /*RecurringShippingMethod*/ null, /*BillingAddressID*/ null, /*ShippingAddressID*/ null, /*GiftRegistryGUID*/ null, /*GiftRegistryIsAnonymous*/ null, /*GiftRegistryAllowSearchByOthers*/ null, /*GiftRegistryNickName*/ null, /*GiftRegistryHideShippingAddresses*/ null, /*CODCompanyCheckAllowed*/ null, /*CODNet30Allowed*/ null, /*ExtensionData*/ null, /*FinalizationData*/ null, /*Deleted*/ null, /*Over13Checked*/ null, /*CurrencySetting*/ null, /*VATSetting*/ null, /*VATRegistrationID*/ null, /*StoreCCInDB*/ null, /*IsRegistered*/ null, /*LockedUntil*/ lockuntil, /*AdminCanViewCC*/ null, /*BadLogin*/ badlogin, /*Active*/ null, /*PwdChangeRequired*/ null, /*RegisterDate*/ null, /*StoreId*/ null ); } if (ThisCustomer.IsAdminUser) { Security.LogEvent("Store Login Failed", "Attempted login failed for email address " + EMailField, 0, 0, 0); return; } } } else { ErrorMsgLabel.Text = AppLogic.GetString("lat_signin_process.aspx.1", m_SkinID, ThisCustomer.LocaleSetting); ScriptManager.RegisterStartupScript(this.Page, GetType(), "preventloading1", "document.getElementById('LoadingModal').style.display = 'none';", true); ErrorPanel.Visible = true; Session["SecurityCode"] = CommonLogic.GenerateRandomCode(6); tbSecurityCode.Text = ""; return; } } }