Пример #1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <BookShop.Model.Room> DataTableToList(DataTable dt)
        {
            List <BookShop.Model.Room> modelList = new List <BookShop.Model.Room>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                BookShop.Model.Room model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new BookShop.Model.Room();
                    if (dt.Rows[n]["RoomNum"].ToString() != "")
                    {
                        model.RoomNum = int.Parse(dt.Rows[n]["RoomNum"].ToString());
                    }
                    if (dt.Rows[n]["RoomType"].ToString() != "")
                    {
                        model.RoomType = int.Parse(dt.Rows[n]["RoomType"].ToString());
                    }
                    model.RoomState = dt.Rows[n]["RoomState"].ToString();
                    if (dt.Rows[n]["BedNum"].ToString() != "")
                    {
                        model.BedNum = int.Parse(dt.Rows[n]["BedNum"].ToString());
                    }
                    if (dt.Rows[n]["GustNum"].ToString() != "")
                    {
                        model.GustNum = int.Parse(dt.Rows[n]["GustNum"].ToString());
                    }
                    model.Description = dt.Rows[n]["Description"].ToString();
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Пример #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(BookShop.Model.Room model)
 {
     dal.Update(model);
 }
Пример #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(BookShop.Model.Room model)
 {
     dal.Add(model);
 }