/// <summary> /// 删除数据 /// </summary> /// <param name="paraTb_Checkitem"></param> /// <returns>true:删除成功,false:不存在该记录</returns> public bool deleteMode(tb_CheckItem paraTb_Checkitem) { if (paraTb_Checkitem == null) throw new ArgumentNullException("paraTb_Checkitem"); try { var query = from p in _context.tb_CheckItem where p.ID == paraTb_Checkitem.ID select p; if (query.ToList().Count < 1) { return false; } else { foreach (var model in query.ToList()) { if (!_context.IsAttached(model)) _context.tb_CheckItem.Attach(model); _context.tb_CheckItem.DeleteObject(model); _context.SaveChanges(); } return true; } } catch (Exception ex) { throw ex; } }
/// <summary> /// 插入数据 /// </summary> /// <param name="paraTb_Checkitem"></param> /// <returns>true:插入成功,false:已存在该记录</returns> public bool addMode(tb_CheckItem paraTb_Checkitem) { if (paraTb_Checkitem == null) throw new ArgumentNullException("paraTb_Checkitem"); try { var query = from p in _context.tb_CheckItem where p.ID == paraTb_Checkitem.ID select p; if (query.ToList().Count() > 0) { return false; } else { _context.tb_CheckItem.AddObject(paraTb_Checkitem); _context.SaveChanges(); return true; } } catch (Exception ex) { throw ex; } }
/// <summary> /// 从商品列表里面给购物车添加商品 /// </summary> /// <param name="checkOutID"></param> /// <param name="goodSupId"></param> /// <param name="superMarketID"></param> /// <returns></returns> public bool checkOutItemAddByGoodShow(string checkOutID, string goodSupId, string superMarketID) { tb_CheckItem checkItemModel = _baseControllerObject.checkItemDal.getModelByCheckoutidAndGoodsuperid(checkOutID, goodSupId); tb_GoodInfoToSuperMarket goodSpuerModel = _baseControllerObject.goodinfotosupermarketDal.getModelByGoodsuperid(goodSupId); if (goodSpuerModel == null) return false; if (checkItemModel == null) { //购物车里面增加字段 tb_CheckItem checkItem = new tb_CheckItem(); checkItem.CheckOutID = checkOutID; checkItem.GoodSuperId = Int32.Parse(goodSupId); checkItem.SuperMarketID = Int32.Parse(superMarketID); checkItem.GoodsSuperCount = 1; checkItem.GoodsSuperCost = goodSpuerModel.Cash; _baseControllerObject.checkItemDal.addMode(checkItem); } else { checkOutItemAddOrSub(checkOutID, goodSupId, 1, "+"); } return true; }
/// <summary> /// 更新数据 /// </summary> /// <param name="paraTb_Checkitem"></param> /// <returns>true:更新成功,false:更新数据失败,不存在该记录!</returns> public bool updateMode(tb_CheckItem paraTb_Checkitem) { if (paraTb_Checkitem == null) throw new ArgumentNullException("paraTb_Checkitem"); try { var oldEntity = (from p in _context.tb_CheckItem where p.ID == paraTb_Checkitem.ID select p).FirstOrDefault(); if (oldEntity == null) { return false; } else { _context.ApplyCurrentValues(oldEntity.GetType().Name, paraTb_Checkitem); _context.SaveChanges(); return true; } } catch (Exception ex) { throw ex; } }
/// <summary> /// 创建新的 tb_CheckItem 对象。 /// </summary> /// <param name="id">ID 属性的初始值。</param> public static tb_CheckItem Createtb_CheckItem(global::System.Int32 id) { tb_CheckItem tb_CheckItem = new tb_CheckItem(); tb_CheckItem.ID = id; return tb_CheckItem; }
/// <summary> /// 用于向 tb_CheckItem EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddTotb_CheckItem(tb_CheckItem tb_CheckItem) { base.AddObject("tb_CheckItem", tb_CheckItem); }