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