/// <summary> /// 获得数据列表 /// </summary> public List <Maticsoft.Model.CMS_Article> DataTableToList(DataTable dt) { List <Maticsoft.Model.CMS_Article> modelList = new List <Maticsoft.Model.CMS_Article>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Maticsoft.Model.CMS_Article model; for (int n = 0; n < rowsCount; n++) { model = new Maticsoft.Model.CMS_Article(); if (dt.Rows[n]["Id"].ToString() != "") { model.Id = int.Parse(dt.Rows[n]["Id"].ToString()); } if (dt.Rows[n]["ColumnId"].ToString() != "") { model.ColumnId = int.Parse(dt.Rows[n]["ColumnId"].ToString()); } model.Title = dt.Rows[n]["Title"].ToString(); model.Author = dt.Rows[n]["Author"].ToString(); if (dt.Rows[n]["PostDate"].ToString() != "") { model.PostDate = DateTime.Parse(dt.Rows[n]["PostDate"].ToString()); } if (dt.Rows[n]["IsPic"].ToString() != "") { if ((dt.Rows[n]["IsPic"].ToString() == "1") || (dt.Rows[n]["IsPic"].ToString().ToLower() == "true")) { model.IsPic = true; } else { model.IsPic = false; } } model.PicUrl = dt.Rows[n]["PicUrl"].ToString(); model.Body = dt.Rows[n]["Body"].ToString(); modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.CMS_Article model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.CMS_Article model) { return(dal.Add(model)); }