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

            if (rowsCount > 0)
            {
                hm.Model.ad model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new hm.Model.ad();
                    if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    if (dt.Rows[n]["apId"] != null && dt.Rows[n]["apId"].ToString() != "")
                    {
                        model.apId = int.Parse(dt.Rows[n]["apId"].ToString());
                    }
                    if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "")
                    {
                        model.title = dt.Rows[n]["title"].ToString();
                    }
                    if (dt.Rows[n]["url"] != null && dt.Rows[n]["url"].ToString() != "")
                    {
                        model.url = dt.Rows[n]["url"].ToString();
                    }
                    if (dt.Rows[n]["pic"] != null && dt.Rows[n]["pic"].ToString() != "")
                    {
                        model.pic = dt.Rows[n]["pic"].ToString();
                    }
                    if (dt.Rows[n]["remark"] != null && dt.Rows[n]["remark"].ToString() != "")
                    {
                        model.remark = dt.Rows[n]["remark"].ToString();
                    }
                    if (dt.Rows[n]["startDate"] != null && dt.Rows[n]["startDate"].ToString() != "")
                    {
                        model.startDate = DateTime.Parse(dt.Rows[n]["startDate"].ToString());
                    }
                    if (dt.Rows[n]["endDate"] != null && dt.Rows[n]["endDate"].ToString() != "")
                    {
                        model.endDate = DateTime.Parse(dt.Rows[n]["endDate"].ToString());
                    }
                    if (dt.Rows[n]["orders"] != null && dt.Rows[n]["orders"].ToString() != "")
                    {
                        model.orders = int.Parse(dt.Rows[n]["orders"].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);
        }
Beispiel #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(hm.Model.ad model)
 {
     return(dal.Update(model));
 }
Beispiel #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(hm.Model.ad model)
 {
     return(dal.Add(model));
 }