/// <summary> /// 获得数据列表 /// </summary> public List <BookShop.Model.Cart> DataTableToList(DataTable dt) { List <BookShop.Model.Cart> modelList = new List <BookShop.Model.Cart>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { BookShop.Model.Cart model; for (int n = 0; n < rowsCount; n++) { model = new BookShop.Model.Cart(); if (dt.Rows[n]["Id"].ToString() != "") { model.Id = int.Parse(dt.Rows[n]["Id"].ToString()); } if (dt.Rows[n]["UserId"].ToString() != "") { int UserId = int.Parse(dt.Rows[n]["UserId"].ToString()); model.User = userServices.GetModel(UserId); } if (dt.Rows[n]["BookId"].ToString() != "") { int BookId = int.Parse(dt.Rows[n]["BookId"].ToString()); model.Book = bookServices.GetModel(BookId); } if (dt.Rows[n]["Count"].ToString() != "") { model.Count = int.Parse(dt.Rows[n]["Count"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(BookShop.Model.Cart model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BookShop.Model.Cart model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BookShop.Model.Cart model) { return(dal.Update(model)); }