/// <summary> /// removeProduct函数的功能:访问数据库的购物车表根据买家账户和商品ID移除购物车表中的记录(删) /// </summary> /// <param name="cart">购物车对象</param> public void removeProduct(cart_Entity cart) { var results = buyerDB.cart_T.Where(r => r.b_account == cart.B_account && r.p_Id == cart.P_Id).Select(r => r); buyerDB.cart_T.DeleteAllOnSubmit(results); buyerDB.SubmitChanges(); }
/// <summary> /// ReturnInformOfCart函数的功能:返回购物车中的信息 /// </summary> /// <param name="Baccount">买家账号</param> /// <returns>返回的是根据买家账号来查询购物车信息的Linq查询结果的集合</returns> public object ReturnInformOfCart(string Baccount) { cart_Entity C = new cart_Entity(); C.B_account = Baccount; return(Date.Return_Cart(C)); }
/// <summary> /// DeleteFromCartByBuyer函数的功能:根据买家的账号删除个人购物车的所有记录 /// </summary> /// <param name="account">买家账号</param> public void DeleteFromCartByBuyer(string account) { cart_Entity C = new cart_Entity(); C.B_account = account; Date.removeProductByBuyer(C); }
/// <summary> /// DeleteFromCart函数的功能:从购物车中移除商品 /// </summary> /// <param name="account">买家账号</param> /// <param name="id">商品ID</param> public void DeleteFromCart(string account, int id) { cart_Entity C = new cart_Entity(); C.B_account = account; C.P_Id = id; Date.removeProduct(C); }
//--购物车模块-- /// <summary> /// InsertToCart函数的功能:向购物车中添加商品 /// </summary> /// <param name="Baccount">买家账号</param> /// <param name="Saccount">卖家账号</param> /// <param name="name">商品名称</param> /// <param name="id">商品ID</param> /// <param name="price">商品价格</param> /// <param name="num">商品数量</param> public void InsertToCart(string Baccount, string Saccount, string name, int id, double price, int num) { cart_Entity C = new cart_Entity(); C.B_account = Baccount; C.S_account = Saccount; C.P_name = name; C.P_Id = id; C.P_price = price; C.P_num = num; // Date.addProduct(C); }
/// <summary> /// UpdateInformationOfCart函数的功能:根据买家账号修改购物车信息(改) /// </summary> /// <param name="cart">购物车对象</param> public void UpdateInformationOfCart(cart_Entity cart) { var results = buyerDB.cart_T.Where(c => c.b_account == cart.B_account).Select(c => c); if (results.Count() > 0) { foreach (cart_T c in results) { c.s_account = cart.S_account;; c.s_storeName = cart.S_storeName; c.p_Id = cart.P_Id; c.p_name = cart.P_name; c.p_price = (decimal)cart.P_price; c.p_num = cart.P_num; } buyerDB.SubmitChanges(); } }
/// <summary> /// Return_Cart函数的功能:访问数据库的购物车表根据买家账户查询记录(查) /// </summary> /// <param name="cart">购物车对象</param> /// <returns>LINQ查询结果的集合</returns> public object Return_Cart(cart_Entity cart) { var results = buyerDB.cart_T.Where(c => c.b_account == cart.B_account).Select(c => c); return((object)results); }