/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.feedback model) { StringBuilder strSql = new StringBuilder(); StringBuilder str1 = new StringBuilder(); //利用反射获得属性的所有公共属性 PropertyInfo[] pros = model.GetType().GetProperties(); List <SqlParameter> paras = new List <SqlParameter>(); strSql.Append("update " + databaseprefix + "feedback set "); foreach (PropertyInfo pi in pros) { //如果不是主键则追加sql字符串 if (!pi.Name.Equals("id")) { //判断属性值是否为空 if (pi.GetValue(model, null) != null && !pi.GetValue(model, null).ToString().Equals("")) { str1.Append(pi.Name + "=@" + pi.Name + ","); //声明参数 paras.Add(new SqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值 } } } strSql.Append(str1.ToString().Trim(',')); strSql.Append(" where id=@id "); paras.Add(new SqlParameter("@id", model.id)); return(DbHelperSQL.ExecuteSql(strSql.ToString(), paras.ToArray()) > 0); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.feedback model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + databaseprefix + "feedback("); strSql.Append("title,content,user_name,user_tel,user_qq,user_email,add_time,is_lock)"); strSql.Append(" values ("); strSql.Append("@title,@content,@user_name,@user_tel,@user_qq,@user_email,@add_time,@is_lock)"); OleDbParameter[] parameters = { new OleDbParameter("@title", OleDbType.VarChar, 100), new OleDbParameter("@content", OleDbType.VarChar), new OleDbParameter("@user_name", OleDbType.VarChar, 50), new OleDbParameter("@user_tel", OleDbType.VarChar, 30), new OleDbParameter("@user_qq", OleDbType.VarChar, 30), new OleDbParameter("@user_email", OleDbType.VarChar, 100), new OleDbParameter("@add_time", OleDbType.Date), new OleDbParameter("@is_lock", OleDbType.Integer, 4) }; parameters[0].Value = model.title; parameters[1].Value = model.content; parameters[2].Value = model.user_name; parameters[3].Value = model.user_tel; parameters[4].Value = model.user_qq; parameters[5].Value = model.user_email; parameters[6].Value = model.add_time; parameters[7].Value = model.is_lock; int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters); return(rows); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.feedback GetModel(int id) { StringBuilder strSql = new StringBuilder(); StringBuilder str1 = new StringBuilder(); Model.feedback model = new Model.feedback(); //利用反射获得属性的所有公共属性 PropertyInfo[] pros = model.GetType().GetProperties(); foreach (PropertyInfo p in pros) { str1.Append(p.Name + ",");//拼接字段 } strSql.Append("select top 1 " + str1.ToString().Trim(',')); strSql.Append(" from " + databaseprefix + "feedback"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; DataTable dt = DbHelperSQL.Query(strSql.ToString(), parameters).Tables[0]; if (dt.Rows.Count > 0) { return(DataRowToModel(dt.Rows[0])); } else { return(null); } }
private void ShowInfo(int _id) { BLL.feedback bll = new BLL.feedback(); model = bll.GetModel(_id); rblStatus.SelectedValue = model.is_lock.ToString(); txtReContent.Text = Utils.ToTxt(model.reply_content); txtBeiZhu.Text = model.beizhu; }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { BLL.feedback bll = new BLL.feedback(); model = bll.GetModel(this.id); model.reply_content = Utils.ToHtml(txtReContent.Text); model.reply_time = DateTime.Now; bll.Update(model); JscriptMsg("留言回复成功啦!", "index.aspx", "Success"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.feedback model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + databaseprefix + "feedback set "); strSql.Append("site_path=@site_path,"); strSql.Append("title=@title,"); strSql.Append("content=@content,"); strSql.Append("user_name=@user_name,"); strSql.Append("user_tel=@user_tel,"); strSql.Append("user_qq=@user_qq,"); strSql.Append("user_email=@user_email,"); strSql.Append("add_time=@add_time,"); strSql.Append("reply_content=@reply_content,"); strSql.Append("reply_time=@reply_time,"); strSql.Append("is_lock=@is_lock"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@site_path", SqlDbType.NVarChar, 100), new SqlParameter("@title", SqlDbType.NVarChar, 100), new SqlParameter("@content", SqlDbType.NText), new SqlParameter("@user_name", SqlDbType.NVarChar, 50), new SqlParameter("@user_tel", SqlDbType.NVarChar, 30), new SqlParameter("@user_qq", SqlDbType.NVarChar, 30), new SqlParameter("@user_email", SqlDbType.NVarChar, 100), new SqlParameter("@add_time", SqlDbType.DateTime), new SqlParameter("@reply_content", SqlDbType.NText), new SqlParameter("@reply_time", SqlDbType.DateTime), new SqlParameter("@is_lock", SqlDbType.TinyInt, 1), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.site_path; parameters[1].Value = model.title; parameters[2].Value = model.content; parameters[3].Value = model.user_name; parameters[4].Value = model.user_tel; parameters[5].Value = model.user_qq; parameters[6].Value = model.user_email; parameters[7].Value = model.add_time; parameters[8].Value = model.reply_content; parameters[9].Value = model.reply_time; parameters[10].Value = model.is_lock; parameters[11].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("plugin_feedback", DTEnums.ActionEnum.Reply.ToString()); //检查权限 BLL.feedback bll = new BLL.feedback(); model = bll.GetModel(this.id); model.reply_content = Utils.ToHtml(txtReContent.Text); model.reply_time = DateTime.Now; bll.Update(model); AddAdminLog(DTEnums.ActionEnum.Reply.ToString(), "回复留言插件内容:" + model.title); //记录日志 JscriptMsg("留言回复成功!", "index.aspx", "Success"); }
protected void btn_Submit_Click(object sender, EventArgs e) { BLL.feedback bll = new BLL.feedback(); model = bll.GetModel(this.id); model.is_lock = Utils.StrToInt(rblStatus.SelectedValue, 0); model.reply_content = Utils.ToHtml(txtReContent.Text); model.beizhu = Utils.ToHtml(txtBeiZhu.Text); bll.Update(model); AddAdminLog(TWEnums.ActionEnum.Reply.ToString(), "儲存留言內容:" + model.title); //記錄日誌 JscriptMsg("留言儲存成功!", "list.aspx"); }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("plugin_feedback", DTEnums.ActionEnum.Reply.ToString()); //检查权限 BLL.feedback bll = new BLL.feedback(); model = bll.GetModel(this.id); model.reply_content = Utils.ToHtml(txtReContent.Text); model.reply_time = DateTime.Now; bll.Update(model); AddAdminLog(DTEnums.ActionEnum.Reply.ToString(), "回复留言插件内容:" + model.title); //记录日志 JscriptMsg("留言回复成功!", "index.aspx"); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.feedback model) { int newId; using (OleDbConnection conn = new OleDbConnection(DbHelperOleDb.connectionString)) { conn.Open(); using (OleDbTransaction trans = conn.BeginTransaction()) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + databaseprefix + "feedback("); strSql.Append("site_path,title,content,user_name,user_tel,user_qq,user_email,add_time,is_lock)"); strSql.Append(" values ("); strSql.Append("@site_path,@title,@content,@user_name,@user_tel,@user_qq,@user_email,@add_time,@is_lock)"); OleDbParameter[] parameters = { new OleDbParameter("@site_path", OleDbType.VarChar, 100), new OleDbParameter("@title", OleDbType.VarChar, 100), new OleDbParameter("@content", OleDbType.VarChar), new OleDbParameter("@user_name", OleDbType.VarChar, 50), new OleDbParameter("@user_tel", OleDbType.VarChar, 30), new OleDbParameter("@user_qq", OleDbType.VarChar, 30), new OleDbParameter("@user_email", OleDbType.VarChar, 100), new OleDbParameter("@add_time", OleDbType.Date), new OleDbParameter("@is_lock", OleDbType.Integer, 4) }; parameters[0].Value = model.site_path; parameters[1].Value = model.title; parameters[2].Value = model.content; parameters[3].Value = model.user_name; parameters[4].Value = model.user_tel; parameters[5].Value = model.user_qq; parameters[6].Value = model.user_email; parameters[7].Value = model.add_time; parameters[8].Value = model.is_lock; DbHelperOleDb.ExecuteSql(conn, trans, strSql.ToString(), parameters); //取得新插入的ID newId = GetMaxId(conn, trans); trans.Commit(); } catch { trans.Rollback(); return(-1); } } } return(newId); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.feedback model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ax_feedback("); strSql.Append("title,content,user_name,user_tel,user_qq,user_email,add_time,reply_content,reply_time,is_lock)"); strSql.Append(" values ("); strSql.Append("@title,@content,@user_name,@user_tel,@user_qq,@user_email,@add_time,@reply_content,@reply_time,@is_lock)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar, 100), new SqlParameter("@content", SqlDbType.NText), new SqlParameter("@user_name", SqlDbType.NVarChar, 50), new SqlParameter("@user_tel", SqlDbType.NVarChar, 30), new SqlParameter("@user_qq", SqlDbType.NVarChar, 30), new SqlParameter("@user_email", SqlDbType.NVarChar, 100), new SqlParameter("@add_time", SqlDbType.DateTime), new SqlParameter("@reply_content", SqlDbType.NText), new SqlParameter("@reply_time", SqlDbType.DateTime), new SqlParameter("@is_lock", SqlDbType.TinyInt, 1) }; parameters[0].Value = model.title; parameters[1].Value = model.content; parameters[2].Value = model.user_name; parameters[3].Value = model.user_tel; parameters[4].Value = model.user_qq; parameters[5].Value = model.user_email; parameters[6].Value = model.add_time; parameters[7].Value = model.reply_content; parameters[8].Value = model.reply_time; parameters[9].Value = model.is_lock; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 将对象转换实体 /// </summary> public Model.feedback DataRowToModel(DataRow row) { Model.feedback model = new Model.feedback(); if (row != null) { //利用反射获得属性的所有公共属性 Type modelType = model.GetType(); for (int i = 0; i < row.Table.Columns.Count; i++) { //查找实体是否存在列表相同的公共属性 PropertyInfo proInfo = modelType.GetProperty(row.Table.Columns[i].ColumnName); if (proInfo != null && row[i] != DBNull.Value) { proInfo.SetValue(model, row[i], null);//用索引值设置属性值 } } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.feedback model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + databaseprefix + "feedback("); strSql.Append("site_path,title,content,user_name,user_tel,user_qq,user_email,add_time,is_lock)"); strSql.Append(" values ("); strSql.Append("@site_path,@title,@content,@user_name,@user_tel,@user_qq,@user_email,@add_time,@is_lock)"); strSql.Append(";select @@IDENTITY"); MySqlParameter[] parameters = { new MySqlParameter("@site_path", MySqlDbType.VarChar, 100), new MySqlParameter("@title", MySqlDbType.VarChar, 100), new MySqlParameter("@content", MySqlDbType.LongText), new MySqlParameter("@user_name", MySqlDbType.VarChar, 50), new MySqlParameter("@user_tel", MySqlDbType.VarChar, 30), new MySqlParameter("@user_qq", MySqlDbType.VarChar, 30), new MySqlParameter("@user_email", MySqlDbType.VarChar, 100), new MySqlParameter("@add_time", MySqlDbType.DateTime), new MySqlParameter("@is_lock", MySqlDbType.Int32, 4) }; parameters[0].Value = model.site_path; parameters[1].Value = model.title; parameters[2].Value = model.content; parameters[3].Value = model.user_name; parameters[4].Value = model.user_tel; parameters[5].Value = model.user_qq; parameters[6].Value = model.user_email; parameters[7].Value = model.add_time; parameters[8].Value = model.is_lock; object obj = DbHelperMySql.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.feedback model) { StringBuilder strSql = new StringBuilder(); StringBuilder str1 = new StringBuilder(); //数据字段 StringBuilder str2 = new StringBuilder(); //数据参数 //利用反射获得属性的所有公共属性 PropertyInfo[] pros = model.GetType().GetProperties(); List <SqlParameter> paras = new List <SqlParameter>(); strSql.Append("insert into " + databaseprefix + "feedback("); foreach (PropertyInfo pi in pros) { //如果不是主键则追加sql字符串 if (!pi.Name.Equals("id")) { //判断属性值是否为空 if (pi.GetValue(model, null) != null && !pi.GetValue(model, null).ToString().Equals("")) { str1.Append(pi.Name + ","); //拼接字段 str2.Append("@" + pi.Name + ","); //声明参数 paras.Add(new SqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值 } } } strSql.Append(str1.ToString().Trim(',')); strSql.Append(") values ("); strSql.Append(str2.ToString().Trim(',')); strSql.Append(") "); strSql.Append(";select @@IDENTITY;"); object obj = DbHelperSQL.GetSingle(strSql.ToString(), paras.ToArray()); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
//儲存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevelEdit("site_contact", "Edit"); //ChkAdminLevel("plugin_feedback", TWEnums.ActionEnum.Reply.ToString()); //檢查權限 Model.manager _admin = new Tea.Web.UI.ManagePage().GetAdminInfo(); BLL.feedback bll = new BLL.feedback(); model = bll.GetModel(this.id); model.reply_content = Utils.ToHtml(txtReContent.Text); model.reply_time = DateTime.Now; model.company = _admin.id; model.is_lock = Utils.StrToInt(rblStatus.SelectedValue, 0); model.beizhu = Utils.ToHtml(txtBeiZhu.Text); bll.Update(model); try { //if (model.is_lock == 2) //{ TWMail.sendMail(siteConfig.emailsmtp, siteConfig.emailssl, siteConfig.emailport, siteConfig.emailusername, siteConfig.emailpassword, siteConfig.emailnickname, siteConfig.emailfrom, model.user_email, model.title + ":回答", model.reply_content); TWMail.sendMail(siteConfig.emailsmtp, siteConfig.emailssl, siteConfig.emailport, siteConfig.emailusername, siteConfig.emailpassword, siteConfig.emailnickname, siteConfig.emailfrom, siteConfig.webmail, model.title + ":回答", model.reply_content); // } } catch (Exception eee) { } AddAdminLog(TWEnums.ActionEnum.Reply.ToString(), "回覆留言內容:" + model.title); //記錄日誌 JscriptMsg("留言回覆成功!", "list.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.feedback GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,site_path,title,content,user_name,user_tel,user_qq,user_email,add_time,reply_content,reply_time,is_lock"); strSql.Append(" from " + databaseprefix + "feedback "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.feedback model = new Model.feedback(); 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]["site_path"] != null && ds.Tables[0].Rows[0]["site_path"].ToString() != "") { model.site_path = ds.Tables[0].Rows[0]["site_path"].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]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "") { model.content = ds.Tables[0].Rows[0]["content"].ToString(); } if (ds.Tables[0].Rows[0]["user_name"] != null && ds.Tables[0].Rows[0]["user_name"].ToString() != "") { model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString(); } if (ds.Tables[0].Rows[0]["user_tel"] != null && ds.Tables[0].Rows[0]["user_tel"].ToString() != "") { model.user_tel = ds.Tables[0].Rows[0]["user_tel"].ToString(); } if (ds.Tables[0].Rows[0]["user_qq"] != null && ds.Tables[0].Rows[0]["user_qq"].ToString() != "") { model.user_qq = ds.Tables[0].Rows[0]["user_qq"].ToString(); } if (ds.Tables[0].Rows[0]["user_email"] != null && ds.Tables[0].Rows[0]["user_email"].ToString() != "") { model.user_email = ds.Tables[0].Rows[0]["user_email"].ToString(); } if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "") { model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString()); } if (ds.Tables[0].Rows[0]["reply_content"] != null && ds.Tables[0].Rows[0]["reply_content"].ToString() != "") { model.reply_content = ds.Tables[0].Rows[0]["reply_content"].ToString(); } if (ds.Tables[0].Rows[0]["reply_time"] != null && ds.Tables[0].Rows[0]["reply_time"].ToString() != "") { model.reply_time = DateTime.Parse(ds.Tables[0].Rows[0]["reply_time"].ToString()); } if (ds.Tables[0].Rows[0]["is_lock"] != null && ds.Tables[0].Rows[0]["is_lock"].ToString() != "") { model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public Model.feedback GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,title,content,user_name,user_tel,user_qq,user_email,add_time,reply_content,reply_time,is_lock from " + databaseprefix + "feedback "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = id; Model.feedback model = new Model.feedback(); 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]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "") { model.content = ds.Tables[0].Rows[0]["content"].ToString(); } if (ds.Tables[0].Rows[0]["user_name"] != null && ds.Tables[0].Rows[0]["user_name"].ToString() != "") { model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString(); } if (ds.Tables[0].Rows[0]["user_tel"] != null && ds.Tables[0].Rows[0]["user_tel"].ToString() != "") { model.user_tel = ds.Tables[0].Rows[0]["user_tel"].ToString(); } if (ds.Tables[0].Rows[0]["user_qq"] != null && ds.Tables[0].Rows[0]["user_qq"].ToString() != "") { model.user_qq = ds.Tables[0].Rows[0]["user_qq"].ToString(); } if (ds.Tables[0].Rows[0]["user_email"] != null && ds.Tables[0].Rows[0]["user_email"].ToString() != "") { model.user_email = ds.Tables[0].Rows[0]["user_email"].ToString(); } if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "") { model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString()); } if (ds.Tables[0].Rows[0]["reply_content"] != null && ds.Tables[0].Rows[0]["reply_content"].ToString() != "") { model.reply_content = ds.Tables[0].Rows[0]["reply_content"].ToString(); } if (ds.Tables[0].Rows[0]["reply_time"] != null && ds.Tables[0].Rows[0]["reply_time"].ToString() != "") { model.reply_time = DateTime.Parse(ds.Tables[0].Rows[0]["reply_time"].ToString()); } if (ds.Tables[0].Rows[0]["is_lock"] != null && ds.Tables[0].Rows[0]["is_lock"].ToString() != "") { model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString()); } return model; } else { return null; } }
private void feedback_add(HttpContext context) { StringBuilder strTxt = new StringBuilder(); BLL.feedback bll = new BLL.feedback(); Model.feedback model = new Model.feedback(); string _site_path = DTRequest.GetQueryString("site"); string _code = DTRequest.GetFormString("txtCode"); string _title = DTRequest.GetFormString("txtTitle"); string _content = DTRequest.GetFormString("txtContent"); string _user_name = DTRequest.GetFormString("txtUserName"); string _user_tel = DTRequest.GetFormString("txtUserTel"); string _user_qq = DTRequest.GetFormString("txtUserQQ"); string _user_email = DTRequest.GetFormString("txtUserEmail"); //检查站点目录 if (string.IsNullOrEmpty(_site_path)) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,网站传输参数有误!\"}"); return; } //校检验证码 if (string.IsNullOrEmpty(_code)) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入验证码!\"}"); return; } if (context.Session[DTKeys.SESSION_CODE] == null) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,验证码已过期!\"}"); return; } if (_code.ToLower() != (context.Session[DTKeys.SESSION_CODE].ToString()).ToLower()) { context.Response.Write("{\"status\":0, \"msg\":\"验证码与系统的不一致!\"}"); return; } if (string.IsNullOrEmpty(_content)) { context.Response.Write("{\"status\": 0, \"msg\": \"对不起,请输入留言的内容!\"}"); return; } model.site_path = Utils.DropHTML(_site_path); model.title = Utils.DropHTML(_title); model.content = Utils.ToHtml(_content); model.user_name = Utils.DropHTML(_user_name); model.user_tel = Utils.DropHTML(_user_tel); model.user_qq = Utils.DropHTML(_user_qq); model.user_email = Utils.DropHTML(_user_email); model.add_time = DateTime.Now; model.is_lock = 1; //不需要审核,请改为0 if (bll.Add(model) > 0) { //是否开启通知功能 if (config.bookmsg > 0 && config.receive != "") { switch (config.bookmsg) { case 1: DTcms.Model.sms_template smsModel = new DTcms.BLL.sms_template().GetModel(config.booktemplet); //取得短信内容 if (smsModel != null) { //替换模板内容 string smstxt = smsModel.content; smstxt = smstxt.Replace("{webname}", siteConfig.webname); smstxt = smstxt.Replace("{webtel}", siteConfig.webtel); smstxt = smstxt.Replace("{weburl}", siteConfig.weburl); smstxt = smstxt.Replace("{username}", model.user_name); smstxt = smstxt.Replace("{usertel}", model.user_tel); smstxt = smstxt.Replace("{userqq}", model.user_qq); smstxt = smstxt.Replace("{useremail}", model.user_email); smstxt = smstxt.Replace("{usertitle}", model.title); smstxt = smstxt.Replace("{usercontent}", model.content); //发送短信 string tipMsg = string.Empty; bool result = new DTcms.BLL.sms_message().Send(config.receive, smstxt, 1, out tipMsg); if (!result) { LogHelper.WriteLog("手机信息发送失败!"); } } break; case 2: //获得邮件内容 DTcms.Model.mail_template mailModel = new DTcms.BLL.mail_template().GetModel(config.booktemplet); if (mailModel != null) { //替换模板内容 string titletxt = mailModel.maill_title; string bodytxt = mailModel.content; titletxt = titletxt.Replace("{webname}", siteConfig.webname); titletxt = titletxt.Replace("{username}", model.user_name); bodytxt = bodytxt.Replace("{webname}", siteConfig.webname); bodytxt = bodytxt.Replace("{webtel}", siteConfig.webtel); bodytxt = bodytxt.Replace("{weburl}", siteConfig.weburl); bodytxt = bodytxt.Replace("{username}", model.user_name); bodytxt = bodytxt.Replace("{usertel}", model.user_tel); bodytxt = bodytxt.Replace("{userqq}", model.user_qq); bodytxt = bodytxt.Replace("{useremail}", model.user_email); bodytxt = bodytxt.Replace("{usertitle}", model.title); bodytxt = bodytxt.Replace("{usercontent}", model.content); //循环发送 string[] emailArr = config.receive.Split(','); foreach (string email in emailArr) { if (DTcms.Common.Utils.IsValidEmail(email)) { //发送邮件 try { DTMail.sendMail(siteConfig.emailsmtp, siteConfig.emailssl, siteConfig.emailusername, DESEncrypt.Decrypt(siteConfig.emailpassword, siteConfig.sysencryptstring), siteConfig.emailnickname, siteConfig.emailfrom, email, titletxt, bodytxt); } catch { LogHelper.WriteLog("邮件发送失败!"); } } } } break; } } context.Response.Write("{\"status\": 1, \"msg\": \"恭喜您,留言提交成功!\"}"); return; } context.Response.Write("{\"status\": 0, \"msg\": \"对不起,保存过程中发生错误!\"}"); return; }
private void ShowInfo(int _id) { BLL.feedback bll = new BLL.feedback(); model = bll.GetModel(_id); txtReContent.Text = Utils.ToTxt(model.reply_content); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.feedback model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.feedback model) { return(dal.Update(model)); }