private void btnChage_Click(object sender, EventArgs e) { if (this.btnChage.Text == "请登录方能兑换") { this.Page.Response.Redirect("/User/Login.aspx?ReturnUrl=" + HttpContext.Current.Request.RawUrl); } else if (HiContext.Current.User == null) { this.Page.Response.Redirect("/ResourceNotFound.aspx?errorMsg=" + Globals.UrlEncode("请登录后才能购买")); } else if (int.Parse(this.litNeedPoint.Text) <= int.Parse(this.litCurrentPoint.Text)) { ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(null, false, false, -1); if (shoppingCart != null && shoppingCart.LineGifts != null && shoppingCart.LineGifts.Count > 0) { foreach (ShoppingCartGiftInfo lineGift in shoppingCart.LineGifts) { if (lineGift.GiftId == this.giftId) { string str = string.Format("ShowMsg(\"{0}\", false);", "购物车中已存在该礼品,请删除购物车中已有的礼品或者下次兑换!"); if (!this.Page.ClientScript.IsClientScriptBlockRegistered("ServerMessageScript")) { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>"); } return; } } } if (ShoppingCartProcessor.AddGiftItem(this.giftId, 1, PromoteType.NotSet, this.isexemptionpostage)) { this.Page.Response.Redirect("/ShoppingCart", true); } } }
protected void shoppingCartPromoGiftList_ItemCommand(object sender, System.Web.UI.WebControls.RepeaterCommandEventArgs e) { if (e.CommandName.Equals("change")) { int num = System.Convert.ToInt32(e.CommandArgument.ToString()); if (num > 0) { ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (shoppingCart != null && shoppingCart.LineGifts != null && shoppingCart.LineGifts.Count > 0) { foreach (ShoppingCartGiftInfo current in shoppingCart.LineGifts) { if (current.GiftId == num) { this.ShowMessage("购物车中已存在该礼品,请删除购物车中已有的礼品或者下次兑换!", false); return; } } } int giftItemQuantity = ShoppingCartProcessor.GetGiftItemQuantity(PromoteType.SentGift); if (this.shoppingCartPromoGiftList.SumNum > giftItemQuantity) { ShoppingCartProcessor.AddGiftItem(num, 1, PromoteType.SentGift); this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("shoppingCart"), true); return; } this.ShowMessage("礼品兑换失败,您不能超过最多兑换数", false); } } }
protected void btnClearCart_Click(object sender, EventArgs e) { if (this.btnClearCart.Text == "请登录方能兑换" || HiContext.Current.User == null) { this.Page.Response.Redirect("Login.aspx?ReturnUrl=" + HttpContext.Current.Request.RawUrl, true); } else if (int.Parse(this.litNeedPoints.Text) <= int.Parse(this.litHasPoints.Text)) { ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(null, false, false, -1); if (shoppingCart != null && shoppingCart.LineGifts != null && shoppingCart.LineGifts.Count > 0) { foreach (ShoppingCartGiftInfo lineGift in shoppingCart.LineGifts) { if (lineGift.GiftId == this.giftId) { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "myscript", "<script>$(function(){alert_h(\"购物车中已存在该礼品,请删除购物车中已有的礼品或者下次兑换!\")});</script>"); return; } } } if (ShoppingCartProcessor.AddGiftItem(this.giftId, 1, PromoteType.NotSet, this.isExemptionPostage)) { this.Page.Response.Redirect("/WapShop/ShoppingCart", true); } } }
private void btnChage_Click(object sender, System.EventArgs e) { if (this.btnChage.Text == "请登录方能兑换") { this.Page.Response.Redirect(Globals.ApplicationPath + "/Login.aspx"); return; } if (HiContext.Current.User.UserRole != UserRole.Member) { this.Page.Response.Redirect(Globals.ApplicationPath + "/ResourceNotFound.aspx?errorMsg=" + Globals.UrlEncode("请登录后才能购买")); return; } if (int.Parse(this.litNeedPoint.Text) <= int.Parse(this.litCurrentPoint.Text)) { ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (shoppingCart != null && shoppingCart.LineGifts != null && shoppingCart.LineGifts.Count > 0) { foreach (ShoppingCartGiftInfo current in shoppingCart.LineGifts) { if (current.GiftId == this.giftId) { this.Page.Response.Redirect(Globals.ApplicationPath + "/ResourceNotFound.aspx?errorMsg=购物车中已存在该礼品,请删除购物车中已有的礼品或者下次兑换!"); return; } } } if (ShoppingCartProcessor.AddGiftItem(this.giftId, 1, PromoteType.NotSet)) { this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("shoppingCart"), true); } } }
protected void shoppingCartPromoGiftList_ItemCommand(object sender, System.Web.UI.WebControls.RepeaterCommandEventArgs e) { if (e.CommandName.Equals("change")) { int num = System.Convert.ToInt32(e.CommandArgument.ToString()); if (num > 0) { int giftItemQuantity = ShoppingCartProcessor.GetGiftItemQuantity(PromoteType.SentGift); if (this.shoppingCartPromoGiftList.SumNum > giftItemQuantity) { ShoppingCartProcessor.AddGiftItem(num, 1, PromoteType.SentGift); this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("shoppingCart"), true); } else { this.ShowMessage("礼品兑换失败,您不能超过最多兑换数", false); } } } }
/// <summary> /// 单击兑换按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buyButton_Click(object sender, EventArgs e) { //传递到购物车 ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (((shoppingCart != null) && (shoppingCart.LineGifts != null)) && (shoppingCart.LineGifts.Count > 0)) { foreach (ShoppingCartGiftInfo info2 in shoppingCart.LineGifts) { if (info2.GiftId == this.GiftId) { this.Page.Response.Redirect(Globals.ApplicationPath + "/ResourceNotFound.aspx?errorMsg=购物车中已存在该礼品,请删除购物车中已有的礼品或者下次兑换!"); return; } } } //获取数量 int buyNum = Convert.ToInt32(System.Web.HttpContext.Current.Request.Form.Get("buyNum")); if (ShoppingCartProcessor.AddGiftItem(this.GiftId, buyNum)) { this.Page.Response.Redirect("/Vshop/ShoppingCart.aspx"); } }
private void btnChage_Click(object sender, EventArgs e) { if ((HiContext.Current.User.UserRole != UserRole.Member) && (HiContext.Current.User.UserRole != UserRole.Underling)) { this.Page.Response.Redirect(Globals.ApplicationPath + "/ResourceNotFound.aspx?errorMsg=" + Globals.UrlEncode("请登录后才能购买")); } else if ((int.Parse(this.litNeedPoint.Text) <= int.Parse(this.litCurrentPoint.Text)) && ShoppingCartProcessor.AddGiftItem(this.giftId, 1, PromoteType.NotSet)) { this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("shoppingCart"), true); } }