/// <summary> /// 添加设置 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AddMSForumSet(MSForumSet model) { string sql = @"INSERT INTO [MS_ForumSet] ([ID],[FTitle],[Visit],[LogoImg],[BackImg],[Fstate],[AddTime]) VALUES (@ID,@FTitle,@Visit,@LogoImg,@BackImg,@Fstate,@AddTime)"; System.Data.SqlClient.SqlParameter[] paras = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@ID", model.ID), new System.Data.SqlClient.SqlParameter("@FTitle", model.FTitle), new System.Data.SqlClient.SqlParameter("@Visit", (model.Visit == 0?0:model.Visit)), new System.Data.SqlClient.SqlParameter("@LogoImg", model.LogoImg), new System.Data.SqlClient.SqlParameter("@BackImg", model.BackImg), new System.Data.SqlClient.SqlParameter("@Fstate", (model.Fstate == 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); } }
/// <summary> /// 更新论坛设置 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateMSForumSet(MSForumSet model) { string safeslq = ""; safeslq = "UPDATE MS_ForumSet SET "; if (model.FTitle != null && model.FTitle != "") { safeslq += "FTitle='" + model.FTitle + "',"; } if (model.LogoImg != null && model.LogoImg.ToString() != "") { safeslq += "LogoImg='" + model.LogoImg + "',"; } if (model.BackImg != null && model.BackImg.ToString() != "") { safeslq += "BackImg='" + model.BackImg + "',"; } safeslq += " Fstate=" + (model.Fstate == 1 ? 1 : 0) + " "; safeslq += " where ID='" + model.ID + "'"; int rowsAffected = DbHelperSQL.ExecuteSql(safeslq.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
void showdetailinfo() { MSForumSetDAL ForumDal = new MSForumSetDAL(); DataSet ds = ForumDal.GetMSForumSetDetail(strID); MSForumSet ForumModel = DataConvert.DataRowToModel <MSForumSet>(ds.Tables[0].Rows[0]); Ftitle.Text = ForumModel.FTitle; if (ForumModel.BackImg != null && ForumModel.BackImg != "") { img0.Src = "../../Comment/" + ForumModel.BackImg; oldimg = ForumModel.BackImg; } if (ForumModel.LogoImg != null && ForumModel.LogoImg != "") { img1.Src = "../../Comment/" + ForumModel.LogoImg; oldlogoimg = ForumModel.LogoImg; } if (strAction == "show") { this.btnReset.Visible = false; this.btnSave.Visible = false; } }
protected void btnSave_Click(object sender, EventArgs e) { MSForumSetDAL ForumDal = new MSForumSetDAL(); if (Session["strLoginName"].ToString() != null && Session["strLoginName"].ToString() != "") { if (Ftitle.Text.Trim() != null && Ftitle.Text.Trim() != "") { //上传图像 string strIconFileName = string.Empty; //图像路径 string strIconSaveFileName = string.Empty; //网址路径 try { if (this.file0.PostedFile.FileName == "") { strIconSaveFileName = ""; } else { if (!System.IO.Directory.Exists(Server.MapPath("~") + @"/Comment/ForumImg")) { System.IO.Directory.CreateDirectory(Server.MapPath("~") + @"/Comment/ForumImg"); } string orignalName = this.file0.PostedFile.FileName; //获取客户机上传文件的文件名 string extendName = orignalName.Substring(orignalName.LastIndexOf(".")); //获取扩展名 if (extendName != ".gif" && extendName != ".jpg" && extendName != ".jpeg" && extendName != ".png") { MessageBox.Show(this, "文件格式有误!"); return; }//检查文件格式 string newName = "backimg" + String.Format("{0}_{1}{2}", DateTime.Now.Millisecond, file0.PostedFile.ContentLength, extendName);//对文件进行重命名 strIconFileName = String.Format(@"{0}Comment/ForumImg/{1}", Server.MapPath("~"), newName); strIconSaveFileName = String.Format(@"ForumImg/{0}", newName); file0.PostedFile.SaveAs(strIconFileName); if (oldimg.Trim() != null && oldimg.Trim() != "" && oldimg.Trim().ToLower() != "forumimg/2.png") { System.IO.File.Delete(String.Format(@"{0}Comment/{1}", Server.MapPath("~"), oldimg)); } } } catch (Exception ex) { MessageBox.Show(this, "上传发生错误!原因是:" + ex.ToString()); } //上传logo string strlogoFileName = string.Empty; //图像路径 string strlogoSaveFileName = string.Empty; //网址路径 try { if (this.file1.PostedFile.FileName == "") { if (oldlogoimg != null && oldlogoimg != "") { strlogoSaveFileName = oldlogoimg; } else { strlogoSaveFileName = ""; } } else { if (!System.IO.Directory.Exists(Server.MapPath("~") + @"/Comment/ForumImg")) { System.IO.Directory.CreateDirectory(Server.MapPath("~") + @"/Comment/ForumImg"); } string orignalName = this.file1.PostedFile.FileName; //获取客户机上传文件的文件名 string extendName = orignalName.Substring(orignalName.LastIndexOf(".")); //获取扩展名 if (extendName != ".gif" && extendName != ".jpg" && extendName != ".jpeg" && extendName != ".png") { MessageBox.Show(this, "文件格式有误!"); return; }//检查文件格式 string newName = "logo" + String.Format("{0}_{1}{2}", DateTime.Now.Millisecond, file1.PostedFile.ContentLength, extendName);//对文件进行重命名 strlogoFileName = String.Format(@"{0}Comment/ForumImg/{1}", Server.MapPath("~"), newName); strlogoSaveFileName = String.Format(@"ForumImg/{0}", newName); file1.PostedFile.SaveAs(strlogoFileName); if (oldlogoimg.Trim() != null && oldlogoimg.Trim() != "" && oldlogoimg.Trim().ToLower() != "forumimg/2.png") { System.IO.File.Delete(String.Format(@"{0}Comment/{1}", Server.MapPath("~"), oldlogoimg)); } } } catch (Exception ex) { MessageBox.Show(this, "上传发生错误!原因是:" + ex.ToString()); } MSForumSet ForumModel = new MSForumSet(); ForumModel.ID = strID; ForumModel.FTitle = Ftitle.Text; ForumModel.Fstate = 0; if (strlogoSaveFileName.Trim() == null || strlogoSaveFileName.Trim() == "") { strlogoSaveFileName = "ForumImg/2.png"; } ForumModel.LogoImg = strlogoSaveFileName; if (strIconSaveFileName.Trim() != null || strIconSaveFileName.Trim() != "") { ForumModel.BackImg = strIconSaveFileName; } if (ForumDal.UpdateMSForumSet(ForumModel)) { MessageBox.Show(this, "操作成功!"); } else { MessageBox.Show(this, "操作失败!"); } } else { MessageBox.Show(this, "请输入相应标题!"); } } else { return; } }
void GetTopicList() { #region ---------------论坛详细---------------------- MSForumSetDAL ForumDal = new MSForumSetDAL(); MSForumTopicDAL topicDal = new MSForumTopicDAL(); MSForumSet ForumModel = new MSForumSet(); string pagetitle = string.Empty; int topicCount = 0; int forumvisit = 0; DataSet ForumDs = ForumDal.GetMSForumSetDetail(strfid); if (ForumDs != null && ForumDs.Tables.Count > 0 && ForumDs.Tables[0].Rows.Count > 0) { ForumModel = DataConvert.DataRowToModel <MSForumSet>(ForumDs.Tables[0].Rows[0]); pagetitle = ForumModel.FTitle; forumvisit = ForumModel.Visit; } try { topicCount = Convert.ToInt32(topicDal.GetMSForumTopicCount(strfid)); } catch (Exception) { topicCount = 0; } forumvisit = forumvisit + 1; if (strUID != null && strUID != "") { ForumDal.UpdateForumVist(forumvisit, strfid); } #endregion #region --------------获取帖子列表------------------ List <TopicModelList> topicModellist = new List <TopicModelList>(); DataSet topiclistds = topicDal.GetMSForumTopicList(" and a.fid='" + strfid + "' ", 0); if (topiclistds != null && topiclistds.Tables.Count > 0 && topiclistds.Tables[0].Rows.Count > 0) { foreach (DataRow row in topiclistds.Tables[0].Rows) { TopicModelList topicmodel = DataConvert.DataRowToModel <TopicModelList>(row); if (topicmodel.NickName == null || topicmodel.NickName == "" || topicmodel.NickName.Length < 1) { topicmodel.NickName = "游客"; } if (topicmodel.HeadImg == null || topicmodel.HeadImg == "") { topicmodel.HeadImg = "images/2.png"; } string msg = topicmodel.TopicDesc; msg = JQDialog.GetTextFromHTML(msg); if (msg.Length > 250) { msg = msg.ToString().Substring(0, 100) + "..."; } topicmodel.TopicDesc = msg; topicModellist.Add(topicmodel); } } #endregion string text = System.IO.File.ReadAllText(Server.MapPath("HtmlPage/index.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); context.TempData["errorscript"] = errorscript; context.TempData["uid"] = strUID; context.TempData["title"] = pagetitle; context.TempData["ForumDetail"] = ForumModel; context.TempData["topicCount"] = topicCount; context.TempData["topiclist"] = topicModellist; context.TempData["forumvisit"] = forumvisit; context.TempData["footer"] = "奥琦微商易"; t.Render(Response.Output); }