//发帖 protected void Button1_Click(object sender, EventArgs e) { BBS bbs = new BBS(); bbs.BBS_Title1 = txtTitle1.Text.Trim(); bbs.BBS_Users_Name1 = Session["username"].ToString(); bbs.BBS_Time1 = DateTime.Now; bbs.BBS_Content1 = txtContent.Text; bbs.BBS_Class1 = DropDownList_occ.SelectedItem.Text; bbs.BBS_Cream1 = "否"; bbs.BBS_Img1 = @"~/Img_BBS/" + FileUpload_img.PostedFile.FileName; try { if (BBSBll.addbbs(bbs) == 1) { txtContent.Text = ""; txtTitle1.Text = ""; BindBBS(); Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('发布成功!');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(object), "alert", "<script>alert('发布失败!');</script>"); } } catch (Exception ex) { Response.Write("错误原因:" + ex.Message); } }
protected void Bindtiezi() { DataTable tz = BBSBll.top5cream(); if (tz != null) { jinghua.DataSource = tz; jinghua.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { //查询有关各职业帖子数量. num.Text = BBSBll.bbs_num().ToString(); num1.Text = BBSBll.class_num("德鲁伊").ToString(); num2.Text = BBSBll.class_num("猎人").ToString(); num3.Text = BBSBll.class_num("法师").ToString(); num4.Text = BBSBll.class_num("圣骑士").ToString(); num5.Text = BBSBll.class_num("牧师").ToString(); num6.Text = BBSBll.class_num("战士").ToString(); num7.Text = BBSBll.class_num("潜行者").ToString(); num8.Text = BBSBll.class_num("萨满祭祀").ToString(); num9.Text = BBSBll.class_num("术士").ToString(); CKFinder.FileBrowser fileBrowser = new CKFinder.FileBrowser(); fileBrowser.BasePath = "../ckfinder/"; //设置CKFinder的基路径 fileBrowser.SetupCKEditor(txtContent); Bindjinghua(); //绑定帖子内容 int id; if (!IsPostBack) { flag = true; if (Request.QueryString["bbsid"] != null) { id = Convert.ToInt32(Request.QueryString["bbsid"].ToString()); SqlDataReader dt = BBSBll.selectbbs(id); dt.Read(); if (dt != null) { txtTitle.Text = dt[1].ToString().Trim(); txtTime.Text = string.Format("{0:yyyy-MM-dd hh:mm}", dt[2]); Content.Text = dt[4].ToString(); Image1.ImageUrl = dt[3].ToString().Trim(); txtClass.Text = dt[7].ToString().Trim(); txtName.Text = dt[5].ToString().Trim(); } BingBC(); //显示总共多少评论 Label1.Text = BBS_CommentBll.num(id).ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { BindView(); int id; if (!IsPostBack) { try { if (Request.QueryString["bbsid"] != null) { id = Convert.ToInt32(Request.QueryString["bbsid"].ToString()); if (BBSBll.deletebbs(id) == 1) { BindView(); Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('删除成功!');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('删除失败!');</script>"); } } if (Request.QueryString["jhid"] != null) { id = Convert.ToInt32(Request.QueryString["jhid"].ToString()); if (BBSBll.jinghu(id) == 1) { BindView(); Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('设置成功!');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('设置失败!');</script>"); } } } catch (Exception ex) { Response.Write("错误原因:" + ex.Message); } } }
//设置精华帖子 protected void btn_Click(object sender, EventArgs e) { Button bt = (Button)sender; int id = Int32.Parse((bt.Parent.FindControl("HiddenField1") as HiddenField).Value); try { if (BBSBll.jinghu(id) == 1) { BindView(); Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('设置成功!');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('设置失败!');</script>"); } } catch (Exception ex) { Response.Write("错误原因:" + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { //新闻评论回复删除操作 int id; if (!IsPostBack) { try { if (Request.QueryString["ncid"] != null) { id = Convert.ToInt32(Request.QueryString["ncid"].ToString()); if (News_CommentaryBll.news_deletenc(id) == 1) { loginover.Visible = true; shuju.Visible = true; newscomment.Visible = true; Bindnc(); Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('删除成功!');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('删除删除失败!');</script>"); } } if (Request.QueryString["ncbid"] != null) { id = Convert.ToInt32(Request.QueryString["ncbid"].ToString()); if (News_Comment_BackBLL.deletencb(id) == 1) { loginover.Visible = true; shuju.Visible = true; newscommentback.Visible = true; Bindncb(); Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('删除成功!');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('删除删除失败!');</script>"); } } if (Request.QueryString["bbsid"] != null) { id = Convert.ToInt32(Request.QueryString["bbsid"].ToString()); if (BBSBll.deletebbs(id) == 1) { loginover.Visible = true; shuju.Visible = true; userbbs.Visible = true; Bindbbs(); Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('删除成功!');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('删除失败!');</script>"); } } if (Request.QueryString["bcid"] != null) { id = Convert.ToInt32(Request.QueryString["bcid"].ToString()); if (BBS_CommentBll.deletebc(id) == 1) { loginover.Visible = true; shuju.Visible = true; bbscomment.Visible = true; Bindnbc(); Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('删除成功!');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('删除删除失败!');</script>"); } } if (Request.QueryString["bcbid"] != null) { id = Convert.ToInt32(Request.QueryString["bcbid"].ToString()); if (BBS_Comment_BackBll.deletebcb(id) == 1) { loginover.Visible = true; shuju.Visible = true; bbscomentback.Visible = true; Bindnbcb(); Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('删除成功!');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('删除删除失败!');</script>"); } } } catch (Exception ex) { Response.Write("错误原因:" + ex.Message); } } if (Session["username"] != null) { login.Visible = false; loginover.Visible = true; //如果用户名不为空,将用户信息绑定 SqlDataReader dt = UsersBll.select(Session["username"].ToString()); dt.Read(); Img.ImageUrl = dt[5].ToString(); name.Text = dt[1].ToString(); password.Text = dt[2].ToString(); password1.Text = dt[2].ToString(); Phone.Text = dt[3].ToString(); Sex.Text = dt[4].ToString(); } else { login.Visible = true; loginover.Visible = false; } if (loginover.Visible == true) { updateuser.Visible = true; //根据页面传值显示不同的数据 if (Request.QueryString["bbs"] != null || Request.QueryString["news"] != null || Request.QueryString["back"] != null) { updateuser.Visible = false; shuju.Visible = true; //新闻评论 if (Request.QueryString["news"] == "nc") { newscomment.Visible = true; Bindnc(); } //新闻评论回复 if (Request.QueryString["news"] == "ncb") { newscommentback.Visible = true; Bindncb(); } //发布帖子 if (Request.QueryString["bbs"] == "bbs") { userbbs.Visible = true; Bindbbs(); } //发布帖子下的评论 if (Request.QueryString["bbs"] == "bc") { bbscomment.Visible = true; Bindnbc(); } //发布帖子下评论的回复 if (Request.QueryString["bbs"] == "bcb") { bbscomentback.Visible = true; Bindnbcb(); } if (Request.QueryString["back"] == "bbs") { backbbs.Visible = true; Bindnbcb(); } } } }
//根据返回的职业分类绑定数据 protected void classBBS(string bbsclass) { BBSView.DataSource = BBSBll.classbbs(bbsclass); BBSView.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { //查询有关各职业帖子数量. num.Text = BBSBll.bbs_num().ToString(); num1.Text = BBSBll.class_num("德鲁伊").ToString(); num2.Text = BBSBll.class_num("猎人").ToString(); num3.Text = BBSBll.class_num("法师").ToString(); num4.Text = BBSBll.class_num("圣骑士").ToString(); num5.Text = BBSBll.class_num("牧师").ToString(); num6.Text = BBSBll.class_num("战士").ToString(); num7.Text = BBSBll.class_num("潜行者").ToString(); num8.Text = BBSBll.class_num("萨满祭祀").ToString(); num9.Text = BBSBll.class_num("术士").ToString(); CKFinder.FileBrowser fileBrowser = new CKFinder.FileBrowser(); fileBrowser.BasePath = "../ckfinder/"; //设置CKFinder的基路径 fileBrowser.SetupCKEditor(txtContent); lookbbs.Visible = true; addbbs.Visible = false; zuce.Visible = false; BindBBS(); Bindjinghua(); if (Request.QueryString["jh"] != null) { bindju(); } if (Request.QueryString["class"] != null) { classBBS(Request.QueryString["class"]); } if (Request.QueryString["ft"] != null) { lookbbs.Visible = false; zuce.Visible = false; addbbs.Visible = true; if (Session["username"] != null) { if (bool.Parse(Session["vip"].ToString()) == true) { Panel1.Visible = true; Panel2.Visible = false; } else { Panel2.Visible = true; } } else { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('请先登录!');</script>"); } } if (Request.QueryString["hy"] != null) { lookbbs.Visible = false; zuce.Visible = true; addbbs.Visible = false; if (Session["username"] != null) { if (bool.Parse(Session["vip"].ToString()) == true) { Panel3.Visible = true; } else { Panel5.Visible = true; } } else { Panel4.Visible = true; } } }
//模糊搜索帖子 protected void Button1_Click1(object sender, EventArgs e) { BBSView.DataSource = BBSBll.momuselect(txttitle.Text.Trim()); BBSView.DataBind(); }
//绑定前五的精华帖子 protected void Bindjinghua() { jinghua.DataSource = BBSBll.top5cream(); jinghua.DataBind(); }
//绑定全部精华帖 protected void bindju() { BBSView.DataSource = BBSBll.creambbs(); BBSView.DataBind(); }
//绑定全部帖子数据 protected void BindBBS() { BBSView.DataSource = BBSBll.allbbs(); BBSView.DataBind(); }
//绑定数据 //绑定数据 protected void BindView() { ListView1.DataSource = BBSBll.allbbs(); ListView1.DataBind(); }