private bool UpdateNewsReply(NewsReplyInfo reply) { StringBuilder builder = new StringBuilder(); builder.Append("update vshop_Reply set "); builder.Append("Keys=@Keys,"); builder.Append("MatchType=@MatchType,"); builder.Append("ReplyType=@ReplyType,"); builder.Append("MessageType=@MessageType,"); builder.Append("IsDisable=@IsDisable,"); builder.Append("LastEditDate=@LastEditDate,"); builder.Append("LastEditor=@LastEditor,"); builder.Append("Content=@Content,"); builder.Append("Type=@Type"); builder.Append(" where ReplyId=@ReplyId;delete from vshop_Message "); builder.Append(" where ReplyId=@ReplyId "); DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString()); this.database.AddInParameter(sqlStringCommand, "Keys", DbType.String, reply.Keys); this.database.AddInParameter(sqlStringCommand, "MatchType", DbType.Int32, (int) reply.MatchType); this.database.AddInParameter(sqlStringCommand, "ReplyType", DbType.Int32, (int) reply.ReplyType); this.database.AddInParameter(sqlStringCommand, "MessageType", DbType.Int32, (int) reply.MessageType); this.database.AddInParameter(sqlStringCommand, "IsDisable", DbType.Boolean, reply.IsDisable); this.database.AddInParameter(sqlStringCommand, "LastEditDate", DbType.DateTime, reply.LastEditDate); this.database.AddInParameter(sqlStringCommand, "LastEditor", DbType.String, reply.LastEditor); this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, ""); this.database.AddInParameter(sqlStringCommand, "Type", DbType.Int32, 2); this.database.AddInParameter(sqlStringCommand, "ReplyId", DbType.Int32, reply.Id); this.database.ExecuteNonQuery(sqlStringCommand); foreach (NewsMsgInfo info in reply.NewsMsg) { builder = new StringBuilder(); builder.Append("insert into vshop_Message("); builder.Append("ReplyId,Title,ImageUrl,Url,Description,Content)"); builder.Append(" values ("); builder.Append("@ReplyId,@Title,@ImageUrl,@Url,@Description,@Content)"); sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString()); this.database.AddInParameter(sqlStringCommand, "ReplyId", DbType.Int32, reply.Id); this.database.AddInParameter(sqlStringCommand, "Title", DbType.String, info.Title); this.database.AddInParameter(sqlStringCommand, "ImageUrl", DbType.String, info.PicUrl); this.database.AddInParameter(sqlStringCommand, "Url", DbType.String, info.Url); this.database.AddInParameter(sqlStringCommand, "Description", DbType.String, info.Description); this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, info.Content); this.database.ExecuteNonQuery(sqlStringCommand); } return true; }
private bool SaveNewsReply(NewsReplyInfo model) { int num; StringBuilder builder = new StringBuilder(); builder.Append("insert into vshop_Reply("); builder.Append("Keys,MatchType,ReplyType,MessageType,IsDisable,LastEditDate,LastEditor,Content,Type)"); builder.Append(" values ("); builder.Append("@Keys,@MatchType,@ReplyType,@MessageType,@IsDisable,@LastEditDate,@LastEditor,@Content,@Type)"); builder.Append(";select @@IDENTITY"); DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString()); this.database.AddInParameter(sqlStringCommand, "Keys", DbType.String, model.Keys); this.database.AddInParameter(sqlStringCommand, "MatchType", DbType.Int32, (int) model.MatchType); this.database.AddInParameter(sqlStringCommand, "ReplyType", DbType.Int32, (int) model.ReplyType); this.database.AddInParameter(sqlStringCommand, "MessageType", DbType.Int32, (int) model.MessageType); this.database.AddInParameter(sqlStringCommand, "IsDisable", DbType.Boolean, model.IsDisable); this.database.AddInParameter(sqlStringCommand, "LastEditDate", DbType.DateTime, model.LastEditDate); this.database.AddInParameter(sqlStringCommand, "LastEditor", DbType.String, model.LastEditor); this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, ""); this.database.AddInParameter(sqlStringCommand, "Type", DbType.Int32, 2); if (int.TryParse(this.database.ExecuteScalar(sqlStringCommand).ToString(), out num)) { foreach (NewsMsgInfo info in model.NewsMsg) { builder = new StringBuilder(); builder.Append("insert into vshop_Message("); builder.Append("ReplyId,Title,ImageUrl,Url,Description,Content)"); builder.Append(" values ("); builder.Append("@ReplyId,@Title,@ImageUrl,@Url,@Description,@Content)"); sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString()); this.database.AddInParameter(sqlStringCommand, "ReplyId", DbType.Int32, num); this.database.AddInParameter(sqlStringCommand, "Title", DbType.String, info.Title); this.database.AddInParameter(sqlStringCommand, "ImageUrl", DbType.String, info.PicUrl); this.database.AddInParameter(sqlStringCommand, "Url", DbType.String, info.Url); this.database.AddInParameter(sqlStringCommand, "Description", DbType.String, info.Description); this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, info.Content); this.database.ExecuteNonQuery(sqlStringCommand); } } return true; }
protected void btnCreate_Click(object sender, EventArgs e) { if ((!string.IsNullOrEmpty(this.Tbtitle.Text) && !string.IsNullOrEmpty(this.Tbdescription.Text)) && !string.IsNullOrEmpty(this.hdpic.Value)) { if (!string.IsNullOrEmpty(this.txtKeys.Text) && ReplyHelper.HasReplyKey(this.txtKeys.Text.Trim())) { this.ShowMsg("关键字重复!", false); } else { NewsReplyInfo reply = new NewsReplyInfo { IsDisable = !this.radDisable.SelectedValue }; if (this.chkKeys.Checked && !string.IsNullOrWhiteSpace(this.txtKeys.Text)) { reply.Keys = this.txtKeys.Text.Trim(); } if (this.chkKeys.Checked && string.IsNullOrWhiteSpace(this.txtKeys.Text)) { this.ShowMsg("你选择了关键字回复,必须填写关键字!", false); } else { reply.MatchType = this.radMatch.SelectedValue ? MatchType.Like : MatchType.Equal; reply.MessageType = MessageType.News; if (this.chkKeys.Checked) { reply.ReplyType |= ReplyType.Keys; } if (this.chkSub.Checked) { reply.ReplyType |= ReplyType.Subscribe; } if (this.chkNo.Checked) { reply.ReplyType |= ReplyType.NoMatch; } if (reply.ReplyType == ReplyType.None) { this.ShowMsg("请选择回复类型", false); } else if (string.IsNullOrEmpty(this.Tbtitle.Text)) { this.ShowMsg("请输入标题", false); } else if (string.IsNullOrEmpty(this.hdpic.Value)) { this.ShowMsg("请上传封面图", false); } else if (string.IsNullOrEmpty(this.Tbdescription.Text)) { this.ShowMsg("请输入摘要", false); } else if (string.IsNullOrEmpty(this.fkContent.Text) && string.IsNullOrEmpty(this.TbUrl.Text)) { this.ShowMsg("请输入内容或自定义链接", false); } else { NewsMsgInfo item = new NewsMsgInfo { Reply = reply, Content = this.fkContent.Text, Description = HttpUtility.HtmlEncode(this.Tbdescription.Text), PicUrl = this.hdpic.Value, Title = HttpUtility.HtmlEncode(this.Tbtitle.Text), Url = this.TbUrl.Text.Trim() }; reply.NewsMsg = new List<NewsMsgInfo>(); reply.NewsMsg.Add(item); if (ReplyHelper.SaveReply(reply)) { this.ShowMsg("添加成功", true); } else { this.ShowMsg("添加失败", false); } } } } } else { this.ShowMsg("您填写的信息不完整!", false); } }
public ReplyInfo ReaderBind(IDataReader dataReader) { ReplyInfo info = null; object obj2 = dataReader["MessageType"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { if (((MessageType) obj2) == MessageType.Text) { info = new TextReplyInfo(); } else { info = new NewsReplyInfo(); } } obj2 = dataReader["ReplyId"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.Id = (int) obj2; } info.Keys = dataReader["Keys"].ToString(); obj2 = dataReader["MatchType"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.MatchType = (MatchType) obj2; } obj2 = dataReader["ReplyType"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.ReplyType = (ReplyType) obj2; } obj2 = dataReader["MessageType"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.MessageType = (MessageType) obj2; } obj2 = dataReader["IsDisable"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.IsDisable = (bool) obj2; } obj2 = dataReader["LastEditDate"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.LastEditDate = (DateTime) obj2; } info.LastEditor = dataReader["LastEditor"].ToString(); obj2 = dataReader["ActivityId"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.ActivityId = (int) obj2; } return info; }
protected void Page_Load(object sender, EventArgs e) { this.radMatch.Items[0].Text = "模糊匹配"; this.radMatch.Items[1].Text = "精确匹配"; this.radDisable.Items[0].Text = "启用"; this.radDisable.Items[1].Text = "禁用"; this.chkNo.Enabled = ReplyHelper.GetMismatchReply() == null; this.chkSub.Enabled = ReplyHelper.GetSubscribeReply() == null; if (!this.chkNo.Enabled) { this.chkNo.ToolTip = "该类型已被使用"; } if (!this.chkSub.Enabled) { this.chkSub.ToolTip = "该类型已被使用"; } if (!string.IsNullOrEmpty(base.Request.QueryString["cmd"]) && !string.IsNullOrEmpty(base.Request.Form["MultiArticle"])) { string str = base.Request.Form["MultiArticle"]; List<ArticleList> list = JsonConvert.DeserializeObject<List<ArticleList>>(str); if ((list != null) && (list.Count > 0)) { NewsReplyInfo reply = new NewsReplyInfo { MessageType = MessageType.List, IsDisable = base.Request.Form["radDisable"] != "true" }; if (base.Request.Form["chkKeys"] == "true") { reply.Keys = base.Request.Form.Get("Keys"); } if (!string.IsNullOrWhiteSpace(reply.Keys) && ReplyHelper.HasReplyKey(reply.Keys)) { base.Response.Write("key"); base.Response.End(); } reply.MatchType = (base.Request.Form["radMatch"] == "true") ? MatchType.Like : MatchType.Equal; reply.ReplyType = ReplyType.None; if (base.Request.Form["chkKeys"] == "true") { reply.ReplyType |= ReplyType.Keys; } if (base.Request.Form["chkSub"] == "true") { reply.ReplyType |= ReplyType.Subscribe; } if (base.Request.Form["chkNo"] == "true") { reply.ReplyType |= ReplyType.NoMatch; } List<NewsMsgInfo> list2 = new List<NewsMsgInfo>(); foreach (ArticleList list3 in list) { if (list3.Status != "del") { NewsMsgInfo item = list3; if (item != null) { item.Reply = reply; list2.Add(item); } } } reply.NewsMsg = list2; if (ReplyHelper.SaveReply(reply)) { base.Response.Write("true"); base.Response.End(); } } } }