private void setupQuestionTable() { tcQuestionTable.Controls.Clear(); Table table = new Table(); tcQuestionTable.Controls.Add(table); table.CellSpacing = 0; table.CellPadding = 2; table.BorderStyle = BorderStyle.Solid; table.BorderWidth = Unit.Pixel(1); table.BorderColor = System.Drawing.Color.Black; table.GridLines = GridLines.Both; table.Width = Unit.Percentage(100); //建立Table的CSS table.CssClass = "header1_table"; //依照QuestionMode決定取出此組別的選擇題 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++) { //取得QuestionType string strQuestionType = "1"; strQuestionType = dsQuestionList.Tables[0].Rows[i]["cQuestionType"].ToString(); //取得QID string strQID = ""; strQID = dsQuestionList.Tables[0].Rows[i]["cQID"].ToString(); //取得問題的SQL DataSet dsQuestion = null; if (hfSymptoms.Value == "All") { strSQL = mySQL.getQuestion(strQID); } else { strSQL = mySQL.getQuestionBySymptoms(strQID, hfSymptoms.Value); } dsQuestion = sqldb.getDataSet(strSQL); if (dsQuestion.Tables[0].Rows.Count > 0) { //建立問題的內容 TableRow trQuestion = new TableRow(); table.Rows.Add(trQuestion); intQuestionIndex += 1; //問題的CheckBox // TableCell tcCheckBox = new TableCell(); // trQuestion.Cells.Add(tcCheckBox); // tcCheckBox.Width = Unit.Pixel(25); // // CheckBox chQuestion = new CheckBox(); // tcCheckBox.Controls.Add(chQuestion); // tcCheckBox.Attributes.Add("onclick","ShowbtnDelete();"); // string strID = ""; // strID = "ch-" + dsQuestion.Tables[0].Rows[0]["cQID"].ToString(); // // chQuestion.ID = strID; //問題的題號 TableCell tcQuestionNum = new TableCell(); trQuestion.Cells.Add(tcQuestionNum); tcQuestionNum.Width = Unit.Pixel(25); tcQuestionNum.Text = "Q" + intQuestionIndex.ToString() + ": "; //問題的內容 string strQuestion = ""; strQuestion = dsQuestion.Tables[0].Rows[0]["cQuestion"].ToString(); TableCell tcQuestion = new TableCell(); trQuestion.Cells.Add(tcQuestion); tcQuestion.Text = strQuestion; //建立問題的CSS trQuestion.Attributes.Add("Class", "header1_table_first_row"); //建立選項 strSQL = mySQL.getAllSelections(strQID); DataSet dsSelection = sqldb.getDataSet(strSQL); if (dsSelection.Tables[0].Rows.Count > 0) { for (int j = 0; j < dsSelection.Tables[0].Rows.Count; j++) { //Seq string strSeq = ""; strSeq = dsSelection.Tables[0].Rows[j]["sSeq"].ToString(); //Selection string strSelection = ""; strSelection = dsSelection.Tables[0].Rows[j]["cSelection"].ToString(); //bCaseSelect bool bCaseSelect = false; bCaseSelect = Convert.ToBoolean(dsSelection.Tables[0].Rows[j]["bCaseSelect"]); TableRow trSelection = new TableRow(); table.Rows.Add(trSelection); //是否為建議選項 TableCell tcSuggest = new TableCell(); trSelection.Cells.Add(tcSuggest); HtmlImage imgSuggest = new HtmlImage(); tcSuggest.Controls.Add(imgSuggest); if (bCaseSelect == true) { imgSuggest.Src = "/Hints/Summary/Images/smiley4.gif"; } else { imgSuggest.Src = "/Hints/Summary/Images/smiley11.gif"; } //選項編號 // TableCell tcSelectionNum = new TableCell(); // trSelection.Cells.Add(tcSelectionNum); // tcSelectionNum.Text = Convert.ToString((j+1)) + "."; //選項內容 TableCell tcSelection = new TableCell(); trSelection.Cells.Add(tcSelection); tcSelection.Text = strSelection; //Empty TableCell // TableCell tcEmpty = new TableCell(); // trSelection.Cells.Add(tcEmpty); //建立選項的CSS if ((Convert.ToInt32(strSeq) % 2) != 0) { trSelection.Attributes.Add("Class", "header1_tr_odd_row"); } else { trSelection.Attributes.Add("Class", "header1_tr_even_row"); } } } else { //此問題沒有選項 } dsSelection.Dispose(); //Modify and Delete 按鈕的TableRow TableRow trModify = new TableRow(); table.Rows.Add(trModify); //建立修改問題的Button TableCell tcModify = new TableCell(); trModify.Cells.Add(tcModify); tcModify.Attributes["align"] = "right"; tcModify.ColumnSpan = 2; //問題的分數 Label lbQuestionGrade = new Label(); tcModify.Controls.Add(lbQuestionGrade); string strQuestionGrade = AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevel_SELECT_Grade(strQID); if (strQuestionGrade != "-1") { lbQuestionGrade.Text = "Question Grade:" + strQuestionGrade + " "; } //問題的難易度 Label lbQuestionLevel = new Label(); tcModify.Controls.Add(lbQuestionLevel); int iQuestionLevel = AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevelValue(strQID); if (iQuestionLevel != -1) { lbQuestionLevel.Text = "Question Level:" + AuthoringTool.QuestionEditLevel.QuestionLevel.QuestionLevelName_SELECT_LevelName(iQuestionLevel) + " "; } Button btnModifySelection = new Button(); tcModify.Controls.Add(btnModifySelection); btnModifySelection.ID = "btnModifySelection-" + strQID; btnModifySelection.Text = "Modify"; btnModifySelection.Click += new EventHandler(btnModifySelection_Click); btnModifySelection.Style["width"] = "150px"; //建立間隔 Label lblCell = new Label(); tcModify.Controls.Add(lblCell); lblCell.Text = " "; Button btnDeleteSelection = new Button(); tcModify.Controls.Add(btnDeleteSelection); btnDeleteSelection.ID = "btnDeleteSelection-" + strQID; btnDeleteSelection.Text = "Delete"; btnDeleteSelection.Click += new EventHandler(btnDeleteSelection_Click); btnDeleteSelection.Style["width"] = "150px"; //建立Space TableRow trSpace = new TableRow(); trSpace.Style.Add("background-color", "#EBECED"); table.Rows.Add(trSpace); TableCell tcSpace = new TableCell(); tcSpace.ColumnSpan = 2; tcSpace.Style.Add("height", "7px"); trSpace.Cells.Add(tcSpace); } else { //此問題沒有選項 } dsQuestion.Dispose(); } } else { //此問卷沒有任何選擇題的情況 trQuestionTable.Style["display"] = "none"; } dsQuestionList.Dispose(); }