//发表新主题按钮(该主题是一个新区里面的主题,因此当我们要发表新主题时,应该是先获取新区的id号,根据id号来更改数据库中的内容) protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { //如果用户没有登陆 跳转到错误页面 if (Session["usernick"] == null) { Response.Redirect("ErrorMsg.aspx"); return; } //获得用户的经验值 int exp = Convert.ToInt32(Session["userLevel"]); localhost.Service myBBS = new localhost.Service(); //发表主题 int state = myBBS.AppearTitle(Session["username"].ToString(), titleTbx.Text.ToString(), contTbx.Text.ToString(), GetSection(Session["section"].ToString()), Session["usernick"].ToString(), exp); //若成功发表 用户经验值加1 if (state == 1) { lblMsg.Text = "发布成功"; //更新该分区讨论区的内容 DataSet titleListDS = myBBS.GetSortList(GetSection(Session["section"].ToString())); GridView1.DataSource = titleListDS.Tables["TitleList"].DefaultView; GridView1.DataBind(); titleTbx.Text = ""; contTbx.Text = ""; //经验值加1 Session["userLevel"] = exp + 1; } //否则显示发布失败 else { lblMsg.Text = "发布失败"; } return; }