/// <summary> /// 根据DataTable转换成List对象数组 /// </summary> public List <MultiColorPen.Model.base_caragentinfo> DataTableToList(DataTable dt) { List <MultiColorPen.Model.base_caragentinfo> modelList = new List <MultiColorPen.Model.base_caragentinfo>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { MultiColorPen.Model.base_caragentinfo model; for (int n = 0; n < rowsCount; n++) { model = new MultiColorPen.Model.base_caragentinfo(); if (dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } model.caragentcode = dt.Rows[n]["caragentcode"].ToString(); model.caragenttype = dt.Rows[n]["caragenttype"].ToString(); model.caragentname = dt.Rows[n]["caragentname"].ToString(); if (dt.Rows[n]["isenable"].ToString() != "") { model.isenable = int.Parse(dt.Rows[n]["isenable"].ToString()); } model.address = dt.Rows[n]["address"].ToString(); model.phone = dt.Rows[n]["phone"].ToString(); model.avatar = dt.Rows[n]["avatar"].ToString(); model.wechaturl = dt.Rows[n]["wechaturl"].ToString(); if (dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } model.remark = dt.Rows[n]["remark"].ToString(); if (dt.Rows[n]["createtime"].ToString() != "") { model.createtime = DateTime.Parse(dt.Rows[n]["createtime"].ToString()); } model.createman = dt.Rows[n]["createman"].ToString(); if (dt.Rows[n]["updatetime"].ToString() != "") { model.updatetime = DateTime.Parse(dt.Rows[n]["updatetime"].ToString()); } model.updateman = dt.Rows[n]["updateman"].ToString(); modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(MultiColorPen.Model.base_caragentinfo model) { return(dal.Update(model) ? 1 : 0); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(MultiColorPen.Model.base_caragentinfo model) { return(dal.Add(model) ? 1 : 0); }