/// <summary> /// 获得数据列表 /// </summary> public List <ROYcms.Ask.Model.ROYcms_question> DataTableToList(DataTable dt) { List <ROYcms.Ask.Model.ROYcms_question> modelList = new List <ROYcms.Ask.Model.ROYcms_question>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { ROYcms.Ask.Model.ROYcms_question model; for (int n = 0; n < rowsCount; n++) { model = new ROYcms.Ask.Model.ROYcms_question(); if (dt.Rows[n]["bh"].ToString() != "") { model.bh = int.Parse(dt.Rows[n]["bh"].ToString()); } model.title = dt.Rows[n]["title"].ToString(); model.content = dt.Rows[n]["content"].ToString(); model.tag = dt.Rows[n]["tag"].ToString(); if (dt.Rows[n]["status"].ToString() != "") { model.status = int.Parse(dt.Rows[n]["status"].ToString()); } if (dt.Rows[n]["reward"].ToString() != "") { model.reward = int.Parse(dt.Rows[n]["reward"].ToString()); } model.user_id = dt.Rows[n]["user_id"].ToString(); model.type_id = dt.Rows[n]["type_id"].ToString(); if (dt.Rows[n]["hits"].ToString() != "") { model.hits = int.Parse(dt.Rows[n]["hits"].ToString()); } if (dt.Rows[n]["star_time"].ToString() != "") { model.star_time = DateTime.Parse(dt.Rows[n]["star_time"].ToString()); } if (dt.Rows[n]["end_time"].ToString() != "") { model.end_time = DateTime.Parse(dt.Rows[n]["end_time"].ToString()); } model.ip = dt.Rows[n]["ip"].ToString(); if (dt.Rows[n]["switchs"].ToString() != "") { model.switchs = int.Parse(dt.Rows[n]["switchs"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(ROYcms.Ask.Model.ROYcms_question model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ROYcms.Ask.Model.ROYcms_question model) { return(dal.Add(model)); }