protected void Page_Load(object sender, EventArgs e) { if (null != Common.Common.NoHtml(Request.QueryString["action"])) { strAction = Common.Common.NoHtml(Request.QueryString["action"]); } if (null != Common.Common.NoHtml(Request.QueryString["id"])) { strID = Common.Common.NoHtml(Request.QueryString["id"]); } MSForumSetDAL forumDal = new MSForumSetDAL(); switch (strAction) { case "del": if (forumDal.UpdateMSForumSetState(strID)) { strMessage = "操作成功!"; } else { strMessage = "操作失败!"; } break; } Response.Write(strMessage); Response.End(); }
const string vsKey = "searchCriteria"; //ViewState key /// <summary> /// 页面加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["strLoginName"].ToString() != null && Session["strLoginName"].ToString() != "" && Session["strLoginName"].ToString().ToLower().Trim() == "vyigo") { ddlforumlist.Items.Clear(); MSForumSetDAL ForumListDal = new MSForumSetDAL(); DataSet ds = new DataSet(); ds = ForumListDal.GetMSForumSetList(""); DataTable dt = ds.Tables[0]; DataRow dr = ds.Tables[0].NewRow(); dr["ID"] = ""; dr["FTitle"] = "--请选择相关主题--"; dt.Rows.InsertAt(dr, 0); ddlforumlist.DataSource = ds.Tables[0].DefaultView; ddlforumlist.DataTextField = "FTitle"; ddlforumlist.DataValueField = "ID"; ddlforumlist.DataBind(); AspNetPager1.CurrentPageIndex = 1; string s = ""; ViewState[vsKey] = s; LoadData(s); } else { return; } } }
/// <summary> /// 加载数据 /// </summary> /// <param name="strWhere">条件</param> void LoadData(string strWhere) { MSForumSetDAL ForumDal = new MSForumSetDAL(); DataSet ds = ForumDal.GetMSForumSetList(strWhere); DataView dv = ds.Tables[0].DefaultView; AspNetPager1.RecordCount = dv.Count; PagedDataSource pds = new PagedDataSource(); pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; pds.PageSize = AspNetPager1.PageSize; Repeater1.DataSource = pds; Repeater1.DataBind(); }
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); }