public Model_HelpCenter DataRowToModel(DataRow row) { Model_HelpCenter center = new Model_HelpCenter(); if (row != null) { if (row["help_id"] != null) { center.help_id = row["help_id"].ToString(); } if (row["help_title"] != null) { center.help_title = row["help_title"].ToString(); } if (row["help_content"] != null) { center.help_content = row["help_content"].ToString(); } if ((row["create_time"] != null) && (row["create_time"].ToString() != "")) { center.create_time = new DateTime?(DateTime.Parse(row["create_time"].ToString())); } if (row["create_userid"] != null) { center.create_userid = row["create_userid"].ToString(); } } return(center); }
public bool Add(Model_HelpCenter model) { StringBuilder builder = new StringBuilder(); builder.Append("insert into HelpCenter("); builder.Append("help_id,help_title,help_content,create_time,create_userid)"); builder.Append(" values ("); builder.Append("@help_id,@help_title,@help_content,@create_time,@create_userid)"); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@help_id", SqlDbType.NChar, 0x24), new SqlParameter("@help_title", SqlDbType.NVarChar, 200), new SqlParameter("@help_content", SqlDbType.Text), new SqlParameter("@create_time", SqlDbType.DateTime), new SqlParameter("@create_userid", SqlDbType.NChar, 0x24) }; cmdParms[0].Value = model.help_id; cmdParms[1].Value = model.help_title; cmdParms[2].Value = model.help_content; cmdParms[3].Value = model.create_time; cmdParms[4].Value = model.create_userid; return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0); }
protected void btnSave_Click(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(help_id)) { BLL_HelpCenter bll = new BLL_HelpCenter(); Model_HelpCenter model = new Model_HelpCenter(); model = bll.GetModel(help_id); model.help_title = this.txt_title.Text.TrimEnd(); model.help_content = this.txt_content.Value; model.create_time = DateTime.Now; if (bll.Update(model)) { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>$(function(){layer.ready(function(){layer.msg('修改成功', { time: 2000, icon: 1},function(){parent.loadData();parent.layer.close(index)})})})</script>"); } else { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>$(function(){layer.ready(function(){layer.msg('修改失败', { time: 2000, icon: 2})})})</script>"); return; } } else { BLL_HelpCenter bll = new BLL_HelpCenter(); Model_HelpCenter model = new Model_HelpCenter(); model.help_title = this.txt_title.Text.TrimEnd(); model.help_content = this.txt_content.Value; model.help_id = Guid.NewGuid().ToString(); model.create_time = DateTime.Now; model.create_userid = loginUser.SysUser_ID; if (bll.Add(model)) { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>$(function(){layer.ready(function(){layer.msg('添加成功', { time: 2000, icon: 1},function(){parent.loadData();parent.layer.close(index)})})})</script>"); } else { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>$(function(){layer.ready(function(){layer.msg('添加失败', { time: 2000, icon: 2})})})</script>"); return; } } } catch (Exception ex) { throw; } }
public bool Update(Model_HelpCenter model) { StringBuilder builder = new StringBuilder(); builder.Append("update HelpCenter set "); builder.Append("help_title=@help_title,"); builder.Append("help_content=@help_content,"); builder.Append("create_time=@create_time,"); builder.Append("create_userid=@create_userid"); builder.Append(" where help_id=@help_id "); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@help_title", SqlDbType.NVarChar, 200), new SqlParameter("@help_content", SqlDbType.Text), new SqlParameter("@create_time", SqlDbType.DateTime), new SqlParameter("@create_userid", SqlDbType.NChar, 0x24), new SqlParameter("@help_id", SqlDbType.NChar, 0x24) }; cmdParms[0].Value = model.help_title; cmdParms[1].Value = model.help_content; cmdParms[2].Value = model.create_time; cmdParms[3].Value = model.create_userid; cmdParms[4].Value = model.help_id; return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0); }
private void LoadData() { try { BLL_HelpCenter bll = new BLL_HelpCenter(); Model_HelpCenter model = new Model_HelpCenter(); model = bll.GetModel(help_id); if (model != null) { this.txt_title.Text = model.help_title; this.txt_content.Value = model.help_content; } } catch (Exception ex) { throw; } }
public List <Model_HelpCenter> DataTableToList(DataTable dt) { List <Model_HelpCenter> list = new List <Model_HelpCenter>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { Model_HelpCenter item = this.dal.DataRowToModel(dt.Rows[i]); if (item != null) { list.Add(item); } } } return(list); }
protected void LoadData() { try { BLL_HelpCenter bll = new BLL_HelpCenter(); Model_HelpCenter model = new Model_HelpCenter(); model = bll.GetModel(help_id); if (model != null) { this.ltl_content.Text = model.help_content; this.ltl_title.Text = model.help_title; this.ltl_titles.Text = model.help_title; ltlHtltel.Text = model.help_title; } } catch (Exception) { } }
public bool Add(Model_HelpCenter model) { return(this.dal.Add(model)); }
public bool Update(Model_HelpCenter model) { return(this.dal.Update(model)); }