/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.configs.mail_template model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + databaseprefix + "mail_template set "); strSql.Append("title=@title,"); strSql.Append("call_index=@call_index,"); strSql.Append("maill_title=@maill_title,"); strSql.Append("content=@content"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar, 100), new SqlParameter("@call_index", SqlDbType.NVarChar, 50), new SqlParameter("@maill_title", SqlDbType.NVarChar, 100), new SqlParameter("@content", SqlDbType.NText), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.title; parameters[1].Value = model.call_index; parameters[2].Value = model.maill_title; parameters[3].Value = model.content; parameters[4].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.configs.mail_template model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + databaseprefix + "mail_template("); strSql.Append("title,call_index,maill_title,content)"); strSql.Append(" values ("); strSql.Append("@title,@call_index,@maill_title,@content)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar, 100), new SqlParameter("@call_index", SqlDbType.NVarChar, 50), new SqlParameter("@maill_title", SqlDbType.NVarChar, 100), new SqlParameter("@content", SqlDbType.NText) }; parameters[0].Value = model.title; parameters[1].Value = model.call_index; parameters[2].Value = model.maill_title; parameters[3].Value = model.content; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void ShowInfo(int _id) { BLL.configs.mail_template bll = new BLL.configs.mail_template(); Model.configs.mail_template model = bll.GetModel(_id); txtTitle.Text = model.title; txtCallIndex.Text = model.call_index; txtMailTitle.Text = model.maill_title; txtContent.Value = model.content; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.configs.mail_template GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,title,call_index,maill_title,content,is_sys from " + databaseprefix + "mail_template "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.configs.mail_template model = new Model.configs.mail_template(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "") { model.title = ds.Tables[0].Rows[0]["title"].ToString(); } if (ds.Tables[0].Rows[0]["call_index"] != null && ds.Tables[0].Rows[0]["call_index"].ToString() != "") { model.call_index = ds.Tables[0].Rows[0]["call_index"].ToString(); } if (ds.Tables[0].Rows[0]["maill_title"] != null && ds.Tables[0].Rows[0]["maill_title"].ToString() != "") { model.maill_title = ds.Tables[0].Rows[0]["maill_title"].ToString(); } if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "") { model.content = ds.Tables[0].Rows[0]["content"].ToString(); } if (ds.Tables[0].Rows[0]["is_sys"] != null && ds.Tables[0].Rows[0]["is_sys"].ToString() != "") { model.is_sys = int.Parse(ds.Tables[0].Rows[0]["is_sys"].ToString()); } return(model); } else { return(null); } }
private bool DoAdd() { Model.configs.mail_template model = new Model.configs.mail_template(); BLL.configs.mail_template bll = new BLL.configs.mail_template(); model.title = txtTitle.Text.Trim(); model.call_index = txtCallIndex.Text.Trim(); model.maill_title = txtMailTitle.Text.Trim(); model.content = txtContent.Value; if (bll.Add(model) > 0) { AddAdminLog(OSEnums.ActionEnum.Add.ToString(), "添加邮件模板:" + model.title); //记录日志 return true; } return false; }
private bool DoAdd() { Model.configs.mail_template model = new Model.configs.mail_template(); BLL.configs.mail_template bll = new BLL.configs.mail_template(); model.title = txtTitle.Text.Trim(); model.call_index = txtCallIndex.Text.Trim(); model.maill_title = txtMailTitle.Text.Trim(); model.content = txtContent.Value; if (bll.Add(model) > 0) { AddAdminLog(OSEnums.ActionEnum.Add.ToString(), "添加邮件模板:" + model.title); //记录日志 return(true); } return(false); }
private bool DoEdit(int _id) { bool result = false; BLL.configs.mail_template bll = new BLL.configs.mail_template(); Model.configs.mail_template model = bll.GetModel(_id); model.title = txtTitle.Text.Trim(); model.call_index = txtCallIndex.Text.Trim(); model.maill_title = txtMailTitle.Text.Trim(); model.content = txtContent.Value; if (bll.Update(model)) { AddAdminLog(OSEnums.ActionEnum.Edit.ToString(), "修改邮件模板:" + model.title); //记录日志 result = true; } return(result); }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public Model.configs.mail_template GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,title,call_index,maill_title,content,is_sys from " + databaseprefix + "mail_template "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = id; Model.configs.mail_template model = new Model.configs.mail_template(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "") { model.title = ds.Tables[0].Rows[0]["title"].ToString(); } if (ds.Tables[0].Rows[0]["call_index"] != null && ds.Tables[0].Rows[0]["call_index"].ToString() != "") { model.call_index = ds.Tables[0].Rows[0]["call_index"].ToString(); } if (ds.Tables[0].Rows[0]["maill_title"] != null && ds.Tables[0].Rows[0]["maill_title"].ToString() != "") { model.maill_title = ds.Tables[0].Rows[0]["maill_title"].ToString(); } if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "") { model.content = ds.Tables[0].Rows[0]["content"].ToString(); } if (ds.Tables[0].Rows[0]["is_sys"] != null && ds.Tables[0].Rows[0]["is_sys"].ToString() != "") { model.is_sys = int.Parse(ds.Tables[0].Rows[0]["is_sys"].ToString()); } return model; } else { return null; } }