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