ProductsList.aspx.cs
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:2k
源码类别:

Email客户端

开发平台:

Visual C++

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using ShopCart;
  12. public partial class ProductsList : PageBase
  13. {
  14.     UserInfoClass ucObj = new UserInfoClass();
  15.     String login;
  16.     protected void Page_Load(object sender, EventArgs e)
  17.     {
  18.         if (Session["Login"] != null)
  19.         {
  20.             login = Session["Login"].ToString();
  21.         }
  22.         else {
  23.             Response.Redirect("Default.aspx");
  24.         }
  25.          
  26.     }
  27.     //绑定市场价格
  28.     public string GetMKPStr(string P_Str_MarketPrice)
  29.     {
  30.         return ucObj.VarStr(P_Str_MarketPrice, 2);
  31.     }
  32.     //绑定会员价格
  33.     public string GetMBPStr(string P_Str_MemberPrice)
  34.     {
  35.         return ucObj.VarStr(P_Str_MemberPrice, 2);
  36.     }
  37.     //当购买商品时,获取商品信息
  38.     public SaveSubGoodsClass GetSubGoodsInformation(DataListCommandEventArgs e, DataList DLName)
  39.     {
  40.         //获取购物车中的信息
  41.         SaveSubGoodsClass Goods = new SaveSubGoodsClass();
  42.         Goods.GoodsID = int.Parse(DLName.DataKeys[e.Item.ItemIndex].ToString());
  43.         string GoodsStyle = e.CommandArgument.ToString();
  44.         int index = GoodsStyle.IndexOf("|");
  45.         if (index < -1 || index + 1 >= GoodsStyle.Length)
  46.             return Goods;
  47.         Goods.GoodsWeight = float.Parse(GoodsStyle.Substring(0, index));
  48.         Goods.MemberPrice = float.Parse(GoodsStyle.Substring(index + 1));
  49.         return (Goods);
  50.     }
  51.     public void AddShopCart(DataListCommandEventArgs e, DataList DLName)
  52.     {
  53.         if (login == null)
  54.         {
  55.             Response.Write("<script>alert('对不起,你没有登陆,不能购买物品');</script>");
  56.         }
  57.         else
  58.         {
  59.             SaveSubGoodsClass Goods = null;
  60.             Goods = GetSubGoodsInformation(e, DLName);
  61.             ucObj.AddShopCart(Goods.GoodsID, Goods.MemberPrice, System.Convert.ToInt32(login), Goods.GoodsWeight);
  62.             Response.Redirect("Cart.aspx");
  63.         }
  64.     }
  65.     protected void DLrefinement_ItemCommand1(object source, DataListCommandEventArgs e)
  66.     {
  67.         AddShopCart(e, DLrefinement);
  68.     }
  69. }