/// <summary> /// 获得数据列表 /// </summary> public List <Light.Model.newsclass> DataTableToList(DataTable dt) { List <Light.Model.newsclass> modelList = new List <Light.Model.newsclass>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Light.Model.newsclass model; for (int n = 0; n < rowsCount; n++) { model = new Light.Model.newsclass(); if (dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } model.classname = dt.Rows[n]["newsclass"].ToString(); model.remark = dt.Rows[n]["remark"].ToString(); if (dt.Rows[n]["createman"].ToString() != "") { model.createman = int.Parse(dt.Rows[n]["createman"].ToString()); } if (dt.Rows[n]["createtime"].ToString() != "") { model.createtime = DateTime.Parse(dt.Rows[n]["createtime"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 获得数据列表 /// </summary> public List<Light.Model.newsclass> DataTableToList(DataTable dt) { List<Light.Model.newsclass> modelList = new List<Light.Model.newsclass>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Light.Model.newsclass model; for (int n = 0; n < rowsCount; n++) { model = new Light.Model.newsclass(); if(dt.Rows[n]["id"].ToString()!="") { model.id=int.Parse(dt.Rows[n]["id"].ToString()); } model.classname= dt.Rows[n]["newsclass"].ToString(); model.remark= dt.Rows[n]["remark"].ToString(); if(dt.Rows[n]["createman"].ToString()!="") { model.createman=int.Parse(dt.Rows[n]["createman"].ToString()); } if(dt.Rows[n]["createtime"].ToString()!="") { model.createtime=DateTime.Parse(dt.Rows[n]["createtime"].ToString()); } modelList.Add(model); } } return modelList; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Light.Model.newsclass model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(Light.Model.newsclass model) { dal.Add(model); }