/// <summary> /// 获得数据列表 /// </summary> public List <Maticsoft.Model.NewsInfo> DataTableToList(DataTable dt) { List <Maticsoft.Model.NewsInfo> modelList = new List <Maticsoft.Model.NewsInfo>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Maticsoft.Model.NewsInfo model; for (int n = 0; n < rowsCount; n++) { model = new Maticsoft.Model.NewsInfo(); if (dt.Rows[n]["NewsID"].ToString() != "") { model.NewsID = int.Parse(dt.Rows[n]["NewsID"].ToString()); } model.NewsTitle = dt.Rows[n]["NewsTitle"].ToString(); model.NewsKey = dt.Rows[n]["NewsKey"].ToString(); model.Write = dt.Rows[n]["Write"].ToString(); if (dt.Rows[n]["NewsTypeID"].ToString() != "") { model.NewsTypeID = int.Parse(dt.Rows[n]["NewsTypeID"].ToString()); } if (dt.Rows[n]["Fatime"].ToString() != "") { model.Fatime = DateTime.Parse(dt.Rows[n]["Fatime"].ToString()); } model.ImageURL = dt.Rows[n]["ImageURL"].ToString(); if (dt.Rows[n]["HitNum"].ToString() != "") { model.HitNum = int.Parse(dt.Rows[n]["HitNum"].ToString()); } model.NewsContent = dt.Rows[n]["NewsContent"].ToString(); modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.NewsInfo model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.NewsInfo model) { return(dal.Add(model)); }