Example #1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <hm.Model.ed_product> DataTableToList(DataTable dt)
        {
            List <hm.Model.ed_product> modelList = new List <hm.Model.ed_product>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                hm.Model.ed_product model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new hm.Model.ed_product();
                    if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = int.Parse(dt.Rows[n]["ID"].ToString());
                    }
                    if (dt.Rows[n]["nodeId"] != null && dt.Rows[n]["nodeId"].ToString() != "")
                    {
                        model.nodeId = int.Parse(dt.Rows[n]["nodeId"].ToString());
                    }
                    if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "")
                    {
                        model.title = dt.Rows[n]["title"].ToString();
                    }
                    if (dt.Rows[n]["picSmall"] != null && dt.Rows[n]["picSmall"].ToString() != "")
                    {
                        model.picSmall = dt.Rows[n]["picSmall"].ToString();
                    }
                    if (dt.Rows[n]["picBig"] != null && dt.Rows[n]["picBig"].ToString() != "")
                    {
                        model.picBig = dt.Rows[n]["picBig"].ToString();
                    }
                    if (dt.Rows[n]["remark"] != null && dt.Rows[n]["remark"].ToString() != "")
                    {
                        model.remark = dt.Rows[n]["remark"].ToString();
                    }
                    if (dt.Rows[n]["isRecommend"] != null && dt.Rows[n]["isRecommend"].ToString() != "")
                    {
                        model.isRecommend = int.Parse(dt.Rows[n]["isRecommend"].ToString());
                    }
                    if (dt.Rows[n]["addTime"] != null && dt.Rows[n]["addTime"].ToString() != "")
                    {
                        model.addTime = DateTime.Parse(dt.Rows[n]["addTime"].ToString());
                    }
                    if (dt.Rows[n]["status"] != null && dt.Rows[n]["status"].ToString() != "")
                    {
                        model.status = int.Parse(dt.Rows[n]["status"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Example #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(hm.Model.ed_product model)
 {
     return(dal.Update(model));
 }
Example #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(hm.Model.ed_product model)
 {
     return(dal.Add(model));
 }