public DataTable MakeTable(string startindex, string endindex)
 {
     int sindex = Convert.ToInt32(startindex);
     int eindex = Convert.ToInt32(endindex);
     DataTable newdt = new DataTable();
     newdt.Columns.Add("id");
     newdt.Columns.Add("author");
     newdt.Columns.Add("province");
     newdt.Columns.Add("question");
     newdt.Columns.Add("questime");
     newdt.Columns.Add("reply");
     newdt.Columns.Add("replytime");
     DataTable ori = new QAManage().QueryCommentTable();
     if (eindex + 1 > ori.Rows.Count)
     {
         eindex = ori.Rows.Count - 1;
     }
     for (; sindex <= eindex; sindex++)
     {
         if (ori.Rows[sindex] == null)
             break;
         DataRow dtrow = newdt.NewRow();
         dtrow["id"] = ori.Rows[sindex]["id"].ToString();
         dtrow["author"] = ori.Rows[sindex]["author"].ToString();
         dtrow["province"] = ori.Rows[sindex]["province"].ToString();
         dtrow["question"] = ori.Rows[sindex]["question"].ToString();
         dtrow["questime"] = ori.Rows[sindex]["questime"].ToString();
         dtrow["reply"] = ori.Rows[sindex]["reply"].ToString();
         dtrow["replytime"] = ori.Rows[sindex]["replytime"].ToString();
         newdt.Rows.Add(dtrow);
     }
     return newdt;
 }
        private void RefreshEvent_Handler()
        {
            if (docdpl.Visible == true)
            {
                docdpl.Items.Clear();
                DataTable dt = new DocsManage().QueryDocss(pageid);
                int i = dt.Rows.Count;
                if (i > 0)
                {
                    for (int j = 0; j < i; j++)
                    {
                        docdpl.Items.Add(new ListItem(dt.Rows[j]["id"].ToString(), dt.Rows[j]["id"].ToString()));
                    }
                    docid = docdpl.SelectedValue;
                    DataTable ndt = new DocsManage().QueryDoc(docid);
                    TitleBox.Text = ndt.Rows[0]["title"].ToString();
                    tbContent.Text = ndt.Rows[0]["text"].ToString();
                    Docdl.SelectedIndex = (ndt.Rows[0]["actived"].ToString() == "True") ? 0 : 1;
                }

            }
            if (picnewsdpl.Visible == true)
            {
                picnewsdpl.Items.Clear();
                DataTable picnewsdt = new PicNewsManage().QueryAllPicNews();
                int indexlength = picnewsdt.Rows.Count;
                if (indexlength > 0)
                {
                    for (int i = 0; i < indexlength; i++)
                    {
                        picnewsdpl.Items.Add(new ListItem(picnewsdt.Rows[i]["id"].ToString(), picnewsdt.Rows[i]["id"].ToString()));
                    }
                    TitleBox.Visible = true;
                    TitleBox.Text = "123";
                    TitleBox.Text = (new PicNewsManage().QueryPicNews(picnewsdpl.SelectedValue)).Rows[0]["title"].ToString();
                    tbContent.Text = (new PicNewsManage().QueryPicNews(picnewsdpl.SelectedValue)).Rows[0]["details"].ToString();
                    OntopDpl.SelectedIndex = ((new PicNewsManage().QueryPicNews(picnewsdpl.SelectedValue)).Rows[0]["ontop"].ToString() == "True") ? 0 : 1;

                }
            }
            if (Functions.Text == "科院相册")
            {
                defaultuploadpath = "~/images/";
            }
            if (FileDpl.Visible == true)
            {
                FileDpl.Items.Clear();
                DataTable fdt = new FilesManage().QueryFileName();
                int count = fdt.Rows.Count;
                if (count > 0)
                {
                    for (int i = 0; i < count; i++)
                    {
                        FileDpl.Items.Add(new ListItem(fdt.Rows[i]["filename"].ToString(), fdt.Rows[i]["filename"].ToString()));
                    }
                    MessageLbl.Text = "";
                }
            }
            if (ConfirmReplace1.Visible == true)
            {
                imgb1.ImageUrl = "~/img/show1.png";
                imgb2.ImageUrl = "~/img/show2.png";
                imgb3.ImageUrl = "~/img/show3.png";
                MessageLbl.Text = "";
            }
            if (QA_Ignore.Visible == true)
            {
                DataTable dt = new QAManage().QueryComments();
                QAText.Text = dt.Rows[QADpl.SelectedIndex]["question"].ToString();
            }
        }
 protected void QA_Reply_Click(object sender, EventArgs e)
 {
     DataTable dts = new QAManage().QueryComments();
     if (dts.Rows.Count != 0)
     {
         string reply = QAReply.Text.Trim();
         bool i = new QAManage().Reply(reply, QADpl.SelectedValue.ToString());
         if (i == true)
             Response.Write("<script lang=javascript>alert('成功!')</script>");
         else
             Response.Write("<script lang=javascript>alert('失败!')</script>");
         DataTable dt = new QAManage().QueryComments();
         int count = dt.Rows.Count;
         QADpl.Items.Clear();
         if (count > 0)
         {
             for (int j = 0; j < count; j++)
             {
                 QADpl.Items.Add(new ListItem(dt.Rows[j]["author"].ToString(), dt.Rows[j]["id"].ToString()));
             }
             QADpl.SelectedIndex = 0;
             QAText.Text = dt.Rows[QADpl.SelectedIndex]["question"].ToString();
         }
         QAReply.Text = "";
         QAText.Text = "";
     }
     else
         Response.Write("<script lang=javascript>alert('尚未制定对应项,操作失败!')</script>");
 }
 protected void QADpl_SelectedIndexChanged(object sender, EventArgs e)
 {
     DataTable dt = new QAManage().QueryComments();
     QAText.Text = dt.Rows[QADpl.SelectedIndex]["question"].ToString();
 }
 protected void kswd_Click(object sender, EventArgs e)
 {
     InitializePage();
     RefreshButton.Visible = false;
     QA_Reply.Visible = true;
     QAText.Visible = true;
     QADpl.Visible = true;
     QAReply.Visible = true;
     Functions.Visible = true;
     QA_Ignore.Visible = true;
     QAText.Text = "暂时没有任何提问";
     Functions.Text = "考生问答";
     Instructions = "孩子们和家长们的提问,您可以在这里管理(审核、回复)。";
     DataTable dt = new QAManage().QueryComments();
     int count = dt.Rows.Count;
     if (count == 0)
     {
         ClientScript.RegisterStartupScript(this.GetType(), "", "alert('Error because of no questions detected!')", true);
     }
     if (count > 0)
     {
         QADpl.Items.Clear();
         for (int j = 0; j < count; j++)
         {
             QADpl.Items.Add(new ListItem(dt.Rows[j]["author"].ToString(), dt.Rows[j]["id"].ToString()));
         }
         QADpl.SelectedIndex = 0;
         QAText.Text = dt.Rows[QADpl.SelectedIndex]["question"].ToString();
     }
     if (QADpl.Text.ToString() == null || QADpl.Text.ToString() == "")
         RefreshButton.Visible = false;
     else
         RefreshButton.Visible = true;
 }
 protected void PostQA_Click(object sender, EventArgs e)
 {
     string studentname = name.Text.Trim();
     string province = prov.SelectedValue.ToString();
     string text = Text.Text.Trim();
     bool i = false;
     if (studentname == "" || text == "")
         Response.Write("<script lang=javascript>alert('警告:有项目为空!')</script>");
     else
         i = new QAManage().CreateQA(studentname, province, text);
     if (i == true)
     {
         Response.Write("<script lang=javascript>alert('成功')</script>");
         name.Text = "";
         studentname = "";
         text = "";
         Text.Text = "";
         Response.Write("<script lang=javascript>window.location='Comment.aspx';</script>");
     }
     else
         Response.Write("<script lang=javascript>alert('失败,未知错误!')</script>");
     name.Text = "";
     prov.SelectedIndex = 0;
     Text.Text = "";
     QARep.DataSource = new QAManage().QueryCommentTable();
     QARep.DataBind();
 }