コード例 #1
0
        /// <summary>
        /// 將被勾選的問題自Question group中刪除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDeleteQuestion_ServerClick(object sender, ImageClickEventArgs e)
        {
            //取得此組別的選擇題(DataSet)
            string  strSQL         = mySQL.getGroupSelectionQuestion(Session["GroupID"].ToString());
            DataSet dsQuestionList = sqldb.getDataSet(strSQL);

            if (dsQuestionList.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dsQuestionList.Tables[0].Rows.Count; i++)
                {
                    //取得QID
                    string strQID = "";
                    try
                    {
                        strQID = dsQuestionList.Tables[0].Rows[i]["cQID"].ToString();
                    }
                    catch
                    {
                    }

                    //檢查此題目是否有被勾選
                    bool bCheck = false;
                    try
                    {
                        bCheck = ((CheckBox)(this.FindControl("Form1").FindControl("ch-" + strQID))).Checked;
                    }
                    catch
                    {
                        Response.Write("<span style='DISPLAY: none'>讀取" + strQID + "的CheckBox失敗</span>");
                    }

                    if (bCheck == true)
                    {
                        //如果有被勾選,則將資料自QuestionIndex , QuestionSelectionIndex , QuestionMode 刪除
                        mySQL.DeleteGeneralQuestion(strQID);
                    }
                }
            }
            else
            {
                //此組別沒有題目的情形
            }
            dsQuestionList.Dispose();

            tcQuestionTable.Controls.Clear();

            intQuestionIndex = 0;

            //建立Main table
            this.setupQuestionTable();
        }