protected void btnSave_Click(object sender, EventArgs e) { if (Session["strLoginName"].ToString() != null && Session["strLoginName"].ToString() != "") { if (topictitle.Text.Trim() != null && topictitle.Text.Trim() != "") { MSForumTopicDAL topicDal = new MSForumTopicDAL(); MSForumTopic topicModel = new MSForumTopic(); topicModel.ID = strID; topicModel.TopicTitle = topictitle.Text;; topicModel.TopicDesc = hd_content.Value; topicModel.TopicState = 0; if (topicDal.UpdateMSForumTopic(topicModel)) { MessageBox.Show(this, "操作成功!"); } else { MessageBox.Show(this, "操作失败!"); } } else { MessageBox.Show(this, "请输入相应标题!"); } } else { return; } }
void showdetailinfo() { MSForumTopicDAL topicDal = new MSForumTopicDAL(); DataSet ds = topicDal.GetTopicDetail(strID); MSForumTopic topicModel = DataConvert.DataRowToModel <MSForumTopic>(ds.Tables[0].Rows[0]); topictitle.Text = topicModel.TopicTitle; hd_content.Value = topicModel.TopicDesc; MSForumTopicAtlasDAL AtlasDal = new MSForumTopicAtlasDAL(); DataSet atlasds = AtlasDal.GetMSFTAtlasList(" AND TID='" + strID + "' "); if (atlasds != null && atlasds.Tables.Count > 0 && atlasds.Tables[0].Rows.Count > 0) { topicaltaslist = ""; string atlasimg = ""; for (int i = 0; i < atlasds.Tables[0].Rows.Count; i++) { atlasimg = atlasds.Tables[0].Rows[i]["ImgUrl"].ToString(); topicaltaslist += "<img src=\"../../Comment/" + atlasimg + "\" />"; } } if (strAction == "show") { this.btnReset.Visible = false; this.btnSave.Visible = false; } }
/// <summary> /// 帖子更新 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateMSForumTopic(MSForumTopic model) { string safeslq = ""; safeslq = "UPDATE MS_ForumTopic SET "; if (model.UID != null && model.UID != "") { safeslq += "[UID]='" + model.UID + "',"; } if (model.FID != null && model.FID != "") { safeslq += "[FID]='" + model.FID + "',"; } if (model.TopicTitle != null && model.TopicTitle != "") { safeslq += "TopicTitle='" + model.TopicTitle + "',"; } if (model.TopicDesc != null && model.TopicDesc.ToString() != "") { safeslq += "TopicDesc='" + model.TopicDesc + "',"; } safeslq += " TopicState=" + (model.TopicState == 1 ? 1 : 0) + " "; safeslq += " where ID='" + model.ID + "'"; int rowsAffected = DbHelperSQL.ExecuteSql(safeslq.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 添加帖子 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AddMSForumTopic(MSForumTopic model) { string sql = @"INSERT INTO [MS_ForumTopic] ([ID],[FID],[UID],[TopicTitle],[TopicDesc],[TopicState],[Treview],[AddTime]) VALUES (@ID,@FID,@UID,@TopicTitle,@TopicDesc,@TopicState,@Treview,@AddTime)"; System.Data.SqlClient.SqlParameter[] paras = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@ID", model.ID), new System.Data.SqlClient.SqlParameter("@FID", model.FID), new System.Data.SqlClient.SqlParameter("@UID", model.UID), new System.Data.SqlClient.SqlParameter("@TopicTitle", model.TopicTitle), new System.Data.SqlClient.SqlParameter("@TopicDesc", model.TopicDesc), new System.Data.SqlClient.SqlParameter("@TopicState", (model.TopicState == 0?0:1)), new System.Data.SqlClient.SqlParameter("@Treview", (model.Treview == 1?1:0)), new System.Data.SqlClient.SqlParameter("@AddTime", DateTime.Now) }; int rowsAffected = DbHelperSQL.ExecuteSql(sql.ToString(), paras); if (rowsAffected > 0) { return(true); } else { return(false); } }
void getTemplate() { #region --------------帖子详细-------------------------- MSForumTopic TopicModel = new MSForumTopic(); MSForumTopicDAL TopicDel = new MSForumTopicDAL(); DataSet TopicDs = TopicDel.GetTopicDetail(strtid); if (null != TopicDs && TopicDs.Tables.Count > 0 && TopicDs.Tables[0].Rows.Count > 0) { TopicModel = DataConvert.DataRowToModel <MSForumTopic>(TopicDs.Tables[0].Rows[0]); } #endregion #region -----------帖子图集---------------- List <MSForumTopicAtlas> atlasModelList = new List <MSForumTopicAtlas>(); MSForumTopicAtlasDAL atlasDal = new MSForumTopicAtlasDAL(); DataSet altasDs = atlasDal.GetMSFTAtlasList(" and tid='" + strtid + "'"); if (altasDs != null && altasDs.Tables.Count > 0 && altasDs.Tables[0].Rows.Count > 0) { foreach (DataRow row in altasDs.Tables[0].Rows) { MSForumTopicAtlas atlasModel = DataConvert.DataRowToModel <MSForumTopicAtlas>(row); atlasModelList.Add(atlasModel); } } #endregion #region ---------点赞或喜欢------------ MSForumTopicLoveDAL lovelikeDal = new MSForumTopicLoveDAL(); string likecount = lovelikeDal.GetLoveOrLikeCount(strtid, "tlike").ToString(); string lovecount = lovelikeDal.GetLoveOrLikeCount(strtid, "tlove").ToString(); #endregion #region ---------评论列表以及图集信息------------ List <CommentListGetSet> commentModelList = new List <CommentListGetSet>(); MSForumCommentDAL commentDal = new MSForumCommentDAL(); DataSet commentDs = commentDal.GetCommentList(" and a.tid='" + strtid + "' "); List <MSForumTopicAtlas> commatlasModelList = new List <MSForumTopicAtlas>(); int commentcount = 0; if (commentDs != null && commentDs.Tables.Count > 0 && commentDs.Tables[0].Rows.Count > 0) { foreach (DataRow row in commentDs.Tables[0].Rows) { CommentListGetSet commentModel = DataConvert.DataRowToModel <CommentListGetSet>(row); string cmmid = commentModel.ID; if (commentModel.NickName == null || commentModel.NickName == "") { commentModel.NickName = "游客"; } #region ------------评论图集----------------------- DataSet commaltasDs = atlasDal.GetMSFTAtlasList(" and tid='comm" + cmmid + "'"); if (commaltasDs != null && commaltasDs.Tables.Count > 0 && commaltasDs.Tables[0].Rows.Count > 0) { foreach (DataRow commrow in commaltasDs.Tables[0].Rows) { MSForumTopicAtlas atlasModel = DataConvert.DataRowToModel <MSForumTopicAtlas>(commrow); commatlasModelList.Add(atlasModel); } } #endregion commentModelList.Add(commentModel); } } try { commentcount = commentDs.Tables[0].Rows.Count; } catch (Exception) { commentcount = 0; } #endregion string text = System.IO.File.ReadAllText(Server.MapPath("HtmlPage/commentlist.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); context.TempData["topicdetail"] = TopicModel; context.TempData["altaslist"] = atlasModelList; context.TempData["commentlist"] = commentModelList; context.TempData["commentatlaslist"] = commatlasModelList; context.TempData["commentcount"] = commentcount; context.TempData["errorscript"] = errorscript; context.TempData["likecount"] = likecount; context.TempData["lovecount"] = lovecount; context.TempData["fid"] = strfid; context.TempData["uid"] = strUid; context.TempData["footer"] = "奥琦微商易"; t.Render(Response.Output); }
void topicpublish() { string topicdesc = string.Empty; #region --------获取标题和内容--------------- try { topictitle = HttpContext.Current.Request.Form.Get("topictitle").ToString(); } catch (Exception) { topictitle = ""; } try { topicdesc = HttpContext.Current.Request.Form.Get("topicdeschidden").ToString(); } catch (Exception) { topicdesc = ""; } #endregion MSForumTopicDAL forumtopicDal = new MSForumTopicDAL(); MSForumTopic forumtopicModel = new MSForumTopic(); StreamReader rd = new StreamReader(Server.MapPath("emotion/key.txt")); string keyword = rd.ReadLine(); if (topictitle != null && topictitle != "") { topictitle = JQDialog.FilterKeyWord(topictitle, keyword); topictitle = JQDialog.GetTextFromHTML(topictitle); forumtopicModel.TopicTitle = topictitle; } if (topicdesc != null && topicdesc != "") { topicdesc = JQDialog.FilterKeyWord(topicdesc, keyword); topicdesc = JQDialog.GetTextFromHTML(topicdesc); forumtopicModel.TopicDesc = topicdesc; } if (!forumtopicDal.ExistMSForumTopic(topictitle, strfid, strUid)) { strTid = Guid.NewGuid().ToString("N").ToUpper(); forumtopicModel.ID = strTid; forumtopicModel.TopicState = 0; forumtopicModel.FID = strfid; forumtopicModel.Treview = 1; forumtopicModel.UID = strUid; SaveImages(); if (forumtopicDal.AddMSForumTopic(forumtopicModel)) { errorscript = JQDialog.alertOKMsgBox(5, "操作成功", "MyTopicList.aspx?fid=" + strfid, "succeed"); } else { errorscript = JQDialog.alertOKMsgBoxGoBack(5, "操作失败<br/>请核对后再操作!", true); } } else { errorscript = JQDialog.alertOKMsgBoxGoBack(5, "操作失败<br/>请核对后再操作!", true); } }