/// <summary> /// 添加文本事件 /// </summary> protected void AddText() { textMol.EventCate = Request.Form["EventName"];//事件类型 菜单 关注等 string EventId = Request.Form["EventId"]; DelEvent();//先删除 后添加 if (!string.IsNullOrEmpty(EventId)) { eventMol = eventBll.GetModel(Convert.ToInt32(EventId)); eventMol.msgType = 1; eventMol.flat1 = 1; //是否存在相应的消息事件 1代表已拥有 eventBll.Update(eventMol); //更新事假的消息类型 textMol.EventId = Convert.ToInt32(EventId); textMol.msgContent = CommonMethod.CheckParamThrow(Request.Form["msgContent"]); if (textBll.Add(textMol) != 0) { CommonMethod.Alert("操作成功!", "wei_MsgConfig.aspx?menuFid=" + Request.Form["fid"]); } else { CommonMethod.Alert("系统正忙,请稍后重试!"); } } else { CommonMethod.Alert("系统正忙,请稍后重试!"); } }
/// <summary> /// 添加图文事件 /// </summary> protected void AddNews() { newsMol.EventCate = Request.Form["EventName"];//事件类型 菜单 关注等 string EventId = Request.Form["EventId"]; DelEvent();//先删除 后添加 if (!string.IsNullOrEmpty(EventId)) { eventMol = eventBll.GetModel(Convert.ToInt32(EventId)); eventMol.msgType = 2; eventMol.flat1 = 1; //是否存在相应的消息事件 1代表已拥有 eventBll.Update(eventMol); //更新事假的消息类型 newsMol.EventId = Convert.ToInt32(EventId); newsMol.newsTitle = CommonMethod.CheckParamThrow(Request.Form["newsTitle"]); newsMol.newsDescription = CommonMethod.CheckParamThrow(Request.Form["newsDescription"]); newsMol.newsPicUrl = CommonMethod.CheckParamThrow(Request.Form["newsPicUrl"]); newsMol.newsUrl = CommonMethod.CheckParamThrow(Request.Form["newsUrl"]); if (newsBll.Add(newsMol) != 0) { CommonMethod.Alert("操作成功!", "wei_MsgConfig.aspx?menuFid=" + Request.Form["fid"]); } else { CommonMethod.Alert("系统正忙,请稍后重试!"); } } else { CommonMethod.Alert("系统正忙,请稍后重试!"); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BrnMall.Core.Model.YX_Event model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into YX_Event("); strSql.Append("EventName,msgType,keyValue,KeyWorld,remark1,remark2,remark3,flat1,flat2,remark4,remark5,remark6,flat7,flat8,RegTim1,RegTim2)"); strSql.Append(" values ("); strSql.Append("@EventName,@msgType,@keyValue,@KeyWorld,@remark1,@remark2,@remark3,@flat1,@flat2,@remark4,@remark5,@remark6,@flat7,@flat8,@RegTim1,@RegTim2)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@EventName", SqlDbType.VarChar, 32), new SqlParameter("@msgType", SqlDbType.Int, 4), new SqlParameter("@keyValue", SqlDbType.VarChar, 32), new SqlParameter("@KeyWorld", SqlDbType.NVarChar, 50), new SqlParameter("@remark1", SqlDbType.NVarChar, 500), new SqlParameter("@remark2", SqlDbType.NVarChar, 500), new SqlParameter("@remark3", SqlDbType.NText), new SqlParameter("@flat1", SqlDbType.Int, 4), new SqlParameter("@flat2", SqlDbType.Int, 4), new SqlParameter("@remark4", SqlDbType.NVarChar, 50), new SqlParameter("@remark5", SqlDbType.NVarChar, 50), new SqlParameter("@remark6", SqlDbType.NText), new SqlParameter("@flat7", SqlDbType.Int, 4), new SqlParameter("@flat8", SqlDbType.Int, 4), new SqlParameter("@RegTim1", SqlDbType.DateTime), new SqlParameter("@RegTim2", SqlDbType.DateTime) }; parameters[0].Value = model.EventName; parameters[1].Value = model.msgType; parameters[2].Value = model.keyValue; parameters[3].Value = model.KeyWorld; parameters[4].Value = model.remark1; parameters[5].Value = model.remark2; parameters[6].Value = model.remark3; parameters[7].Value = model.flat1; parameters[8].Value = model.flat2; parameters[9].Value = model.remark4; parameters[10].Value = model.remark5; parameters[11].Value = model.remark6; parameters[12].Value = model.flat7; parameters[13].Value = model.flat8; parameters[14].Value = model.RegTim1; parameters[15].Value = model.RegTim2; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 删除事件 并删除对应的消息 /// </summary> protected void weixinEventDel(string id) { if (!string.IsNullOrEmpty(id)) { mol = bll.GetModel(Convert.ToInt32(id)); string enentname = mol.EventName; int msgType = Convert.ToInt32(mol.msgType); string sql = ""; switch (msgType)//删除对应的消息 { case 1: sql = "delete from YX_text where EventId=" + id + " and EventCate='" + enentname + "'"; break; case 2: sql = "delete from YX_news where EventId=" + id + " and EventCate='" + enentname + "'"; break; case 3: sql = "delete from YX_image where EventId=" + id + " and EventCate='" + enentname + "'"; break; case 4: sql = "delete from YX_voice where EventId=" + id + " and EventCate='" + enentname + "'"; break; case 5: sql = "delete from YX_vedio where EventId=" + id + " and EventCate='" + enentname + "'"; break; case 6: sql = "delete from YX_music where EventId=" + id + " and EventCate='" + enentname + "'"; break; } imp.GetSqlCount(CommandType.Text, sql); if (bll.Delete(Convert.ToInt32(id))) { Response.Write("OK"); } else { Response.Write("NO"); } } else { Response.Write("NO"); } Response.End(); }
protected void Page_Load(object sender, EventArgs e) { (Master.FindControl("childmenu") as Label).Text = "配置微事件"; if (Request.Form["action"] == "text") { AddText(); return; } if (Request.Form["action"] == "news") { AddNews(); return; } if (!Page.IsPostBack) { loadMenus(Request.QueryString["msgtype"]); string Id = Request.QueryString["id"]; if (!string.IsNullOrEmpty(Id)) { eventMol = eventBll.GetModel(Convert.ToInt32(Id)); string eventType = eventMol.msgType.ToString(); switch (eventType) { case "1": dt_text = textBll.GetList(" EventId=" + Id + " and EventCate='" + eventMol.EventName + "'").Tables[0]; break; //文本 case "2": dt_News = newsBll.GetList(" EventId=" + Id + " and EventCate='" + eventMol.EventName + "'").Tables[0]; break; //图文 } if (dt_text.Rows.Count != 0) { textMol = textBll.GetModel(Convert.ToInt32(dt_text.Rows[0]["Id"])); } if (dt_News.Rows.Count != 0) { newsMol = newsBll.GetModel(Convert.ToInt32(dt_News.Rows[0]["Id"])); } } } }
/// <summary> /// 得到一个对象实体 /// </summary> public BrnMall.Core.Model.YX_Event GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,EventName,msgType,keyValue,KeyWorld,remark1,remark2,remark3,flat1,flat2,remark4,remark5,remark6,flat7,flat8,RegTim1,RegTim2 from YX_Event "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; BrnMall.Core.Model.YX_Event model = new BrnMall.Core.Model.YX_Event(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public BrnMall.Core.Model.YX_Event DataRowToModel(DataRow row) { BrnMall.Core.Model.YX_Event model = new BrnMall.Core.Model.YX_Event(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["EventName"] != null) { model.EventName = row["EventName"].ToString(); } if (row["msgType"] != null && row["msgType"].ToString() != "") { model.msgType = int.Parse(row["msgType"].ToString()); } if (row["keyValue"] != null) { model.keyValue = row["keyValue"].ToString(); } if (row["KeyWorld"] != null) { model.KeyWorld = row["KeyWorld"].ToString(); } if (row["remark1"] != null) { model.remark1 = row["remark1"].ToString(); } if (row["remark2"] != null) { model.remark2 = row["remark2"].ToString(); } if (row["remark3"] != null) { model.remark3 = row["remark3"].ToString(); } if (row["flat1"] != null && row["flat1"].ToString() != "") { model.flat1 = int.Parse(row["flat1"].ToString()); } if (row["flat2"] != null && row["flat2"].ToString() != "") { model.flat2 = int.Parse(row["flat2"].ToString()); } if (row["remark4"] != null) { model.remark4 = row["remark4"].ToString(); } if (row["remark5"] != null) { model.remark5 = row["remark5"].ToString(); } if (row["remark6"] != null) { model.remark6 = row["remark6"].ToString(); } if (row["flat7"] != null && row["flat7"].ToString() != "") { model.flat7 = int.Parse(row["flat7"].ToString()); } if (row["flat8"] != null && row["flat8"].ToString() != "") { model.flat8 = int.Parse(row["flat8"].ToString()); } if (row["RegTim1"] != null && row["RegTim1"].ToString() != "") { model.RegTim1 = DateTime.Parse(row["RegTim1"].ToString()); } if (row["RegTim2"] != null && row["RegTim2"].ToString() != "") { model.RegTim2 = DateTime.Parse(row["RegTim2"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BrnMall.Core.Model.YX_Event model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update YX_Event set "); strSql.Append("EventName=@EventName,"); strSql.Append("msgType=@msgType,"); strSql.Append("keyValue=@keyValue,"); strSql.Append("KeyWorld=@KeyWorld,"); strSql.Append("remark1=@remark1,"); strSql.Append("remark2=@remark2,"); strSql.Append("remark3=@remark3,"); strSql.Append("flat1=@flat1,"); strSql.Append("flat2=@flat2,"); strSql.Append("remark4=@remark4,"); strSql.Append("remark5=@remark5,"); strSql.Append("remark6=@remark6,"); strSql.Append("flat7=@flat7,"); strSql.Append("flat8=@flat8,"); strSql.Append("RegTim1=@RegTim1,"); strSql.Append("RegTim2=@RegTim2"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@EventName", SqlDbType.VarChar, 32), new SqlParameter("@msgType", SqlDbType.Int, 4), new SqlParameter("@keyValue", SqlDbType.VarChar, 32), new SqlParameter("@KeyWorld", SqlDbType.NVarChar, 50), new SqlParameter("@remark1", SqlDbType.NVarChar, 500), new SqlParameter("@remark2", SqlDbType.NVarChar, 500), new SqlParameter("@remark3", SqlDbType.NText), new SqlParameter("@flat1", SqlDbType.Int, 4), new SqlParameter("@flat2", SqlDbType.Int, 4), new SqlParameter("@remark4", SqlDbType.NVarChar, 50), new SqlParameter("@remark5", SqlDbType.NVarChar, 50), new SqlParameter("@remark6", SqlDbType.NText), new SqlParameter("@flat7", SqlDbType.Int, 4), new SqlParameter("@flat8", SqlDbType.Int, 4), new SqlParameter("@RegTim1", SqlDbType.DateTime), new SqlParameter("@RegTim2", SqlDbType.DateTime), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.EventName; parameters[1].Value = model.msgType; parameters[2].Value = model.keyValue; parameters[3].Value = model.KeyWorld; parameters[4].Value = model.remark1; parameters[5].Value = model.remark2; parameters[6].Value = model.remark3; parameters[7].Value = model.flat1; parameters[8].Value = model.flat2; parameters[9].Value = model.remark4; parameters[10].Value = model.remark5; parameters[11].Value = model.remark6; parameters[12].Value = model.flat7; parameters[13].Value = model.flat8; parameters[14].Value = model.RegTim1; parameters[15].Value = model.RegTim2; parameters[16].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }