protected void btnOK_Click(object sender, EventArgs e) { if ((User)Session["User"] == null) { this.FreeTextBox1.Enabled = false; this.classid.Enabled = false; this.contenttitle.Enabled = false; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请登录后发帖!')</script>"); return; } if (contenttitle.Text.Trim().Length == 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('标题不能为空!')</script>"); return; } if (FreeTextBox1.Text.Trim().Length == 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('内容不能为空!')</script>"); return; } LBBS.Model.Content content = new LBBS.Model.Content(); User user = (User)Session["User"];//如何保存当前UID ContentClass contentclass = (ContentClass)CCManager.GetContentclassById(Convert.ToInt32(classid.SelectedValue)); content.Title = contenttitle.Text.Trim(); content.Contentclass = contentclass; content.Contentery = FreeTextBox1.Text; content.Createdon = Convert.ToDateTime(DateTime.Now.ToString("")); content.Repliedon = Convert.ToDateTime(DateTime.Now.ToString("")); content.Replycount = 0; content.Isclose = "已审核"; content.User = user;//关联表数据设定 if (ContentManager.addContent(content) > 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('增加成功!');</script>"); return; } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('增加失败!');</script>"); return; } }
protected void btnOK_Click(object sender, EventArgs e) { if (Session["UserID"] != null) { if (FreeTextBox1.Text.Trim().Length == 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('内容不能为空!')</script>"); return; } LBBS.Model.Content content = ContentManager.GetContentByID1(Convert.ToInt32(Request.QueryString["topicid"])); ContentReply contentreply = new ContentReply(); User user = (User)Session["User"]; user.Userid = Convert.ToInt32(Session["UserID"]); //int userid= int.Parse(Session["UserID"].ToString()); contentreply.Recontentery = FreeTextBox1.Text; contentreply.Createon = Convert.ToDateTime(DateTime.Now.ToString("")); contentreply.User = user;//关联表数据设定 contentreply.Content = content; if (ReManager.addReply(contentreply) > 0) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('回复成功!')</script>"); Response.Redirect("TopicContent.aspx?topicid=" + topicid + ""); return; } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('回复失败!');</script>"); return; } } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('你还未登录,请先登录!')</script>"); return; } }