Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(BookShop.Model.OrderBook model)
 {
     dal.Update(model);
 }
Exemplo n.º 3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(BookShop.Model.OrderBook model)
 {
     return(dal.Add(model));
 }
Exemplo n.º 4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(BookShop.Model.OrderBook model)
 {
     return(dal.Update(model));
 }