Exemplo n.º 1
0
        protected void MyAnonymousAdvice_Button_Click(object sender, EventArgs e)
        {
            if (Session["UserInfo"] != null)
            {
                if (MyAdvice_TextBox.Text.Trim() == "")
                {
                    ScriptManager.RegisterStartupScript(Page, GetType(), "nocontent", "alert('请输入内容!');", true);
                    //HttpContext.Current.Response.Write("<script type='text/javascript'>alert('请输入内容!');location.href='/aspx/MyAdvice.aspx?CourseID=" + courseid + "'</script>");
                }
                else
                {
                    ArrayList shieldid   = new ArrayList();
                    ArrayList unshieldid = new ArrayList();
                    foreach (DataListItem item in Teacher_DataList.Items)
                    {
                        if (((HtmlInputCheckBox)item.FindControl("TemporaryID")).Checked)
                        {
                            unshieldid.Add(int.Parse(((TextBox)item.FindControl("UserID_TextBox")).Text));
                        }
                        else
                        {
                            shieldid.Add(int.Parse(((TextBox)item.FindControl("UserID_TextBox")).Text));
                        }
                    }
                    foreach (DataListItem item in TA_DataList.Items)
                    {
                        if (((HtmlInputCheckBox)item.FindControl("TemporaryID")).Checked)
                        {
                            unshieldid.Add(int.Parse(((TextBox)item.FindControl("UserID_TextBox")).Text));
                        }
                        else
                        {
                            shieldid.Add(int.Parse(((TextBox)item.FindControl("UserID_TextBox")).Text));
                        }
                    }
                    unshieldid.Add(0);
                    shieldid.Add(0);

                    MessageInfo myadvice = new MessageInfo();
                    myadvice.Anonymous  = 1;
                    myadvice.UnShieldID = (Int32[])unshieldid.ToArray(typeof(Int32));
                    myadvice.ShieldID   = (Int32[])shieldid.ToArray(typeof(Int32));
                    myadvice.UserID     = user.UserID;
                    myadvice.CourseID   = course.CourseID;
                    myadvice.Content    = MyAdvice_TextBox.Text;
                    myadvice.AddAdvice();

                    AllDataBind();
                    //Response.Redirect("/aspx/MyAdvice.aspx?CourseID=" + courseid + "");
                }
            }
        }