/// <summary> /// 傳回Paper_RandomNum的組別問題數目表格(不做動作) /// </summary> private Table setupQuestionNumTable(string strPaperID) { Table table = new Table(); table.Attributes.Add("Class", "TableName"); table.Style.Add("WIDTH", "100%"); table.CellSpacing = 0; table.CellPadding = 2; table.BorderWidth = Unit.Pixel(1); table.BorderStyle = BorderStyle.Solid; table.BorderColor = System.Drawing.Color.Black; SQLString mySQL = new SQLString(); DataReceiver myReceiver = new DataReceiver(); //從Paper_RandomQuestionNum取出此問卷的資料 SqlDB sqldb = new SqlDB(System.Configuration.ConfigurationSettings.AppSettings["connstr"]); string strSQL = mySQL.getPaper_RandomQuestionNum(strPaperID); DataSet dsQuestionNum = sqldb.getDataSet(strSQL); if (dsQuestionNum.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsQuestionNum.Tables[0].Rows.Count; i++) { //設定Table的Style string strStyle = "header1_tr_odd_row"; if ((i % 2) != 0) { strStyle = "header1_tr_odd_row"; } else { strStyle = "header1_tr_even_row"; } TableRow tr = new TableRow(); tr.CssClass = strStyle; table.Rows.Add(tr); //get GroupID string strGroupID = ""; try { strGroupID = dsQuestionNum.Tables[0].Rows[i]["cQuestionGroupID"].ToString(); } catch { } //get Question number int intQuestionNum = 0; try { intQuestionNum = Convert.ToInt32(dsQuestionNum.Tables[0].Rows[i]["sQuestionNum"]); } catch { } //get 此組別全部的問題數目 int intQuestionCount = 0; if (strGroupID == "Specific") { strSQL = mySQL.getSpecificSelectionQuestion(strPaperID); } else { strSQL = mySQL.getGroupSelectionQuestion(strGroupID); } DataSet dsQuestionCount = sqldb.getDataSet(strSQL); try { intQuestionCount = dsQuestionCount.Tables[0].Rows.Count; } catch { } dsQuestionCount.Dispose(); //組別名稱 TableCell tcGroupName = new TableCell(); tr.Cells.Add(tcGroupName); string strGroupName = ""; if (strGroupID == "Specific") { strGroupName = "Specific questions"; } else { strGroupName = mySQL.getQuestionGroupName(strGroupID); } tcGroupName.Text = strGroupName; //問題個數 TableCell tcQuestionNum = new TableCell(); tr.Cells.Add(tcQuestionNum); TextBox txtQuestionNum = new TextBox(); tcQuestionNum.Controls.Add(txtQuestionNum); txtQuestionNum.ID = "txt" + strGroupID; txtQuestionNum.Text = intQuestionNum.ToString(); //此組別的問題總數 TableCell tcQuestionCount = new TableCell(); tr.Cells.Add(tcQuestionCount); tcQuestionCount.Text = intQuestionCount.ToString(); tcQuestionCount.Attributes.Add("Align", "Center"); //建立Title的TextArea TableRow trQuestionTitle = new TableRow(); table.Rows.Add(trQuestionTitle); TableCell tcTitle = new TableCell(); trQuestionTitle.Cells.Add(tcTitle); tcTitle.Attributes.Add("align", "right"); tcTitle.ColumnSpan = 3; //建立Question title的TextArea HtmlTextArea txtTitle = new HtmlTextArea(); tcTitle.Controls.Add(txtTitle); txtTitle.ID = "txtTitle" + strGroupID; txtTitle.Style.Add("WIDTH", "100%"); txtTitle.Rows = 5; txtTitle.Style.Add("DISPLAY", "none"); //取出此QuestionTitle的內容 txtTitle.InnerText = myReceiver.getQuestionTitle(strPaperID, strGroupID); //建立Question title button HtmlInputButton btnTitle = new HtmlInputButton("button"); tcTitle.Controls.Add(btnTitle); btnTitle.ID = "btnTitle" + strGroupID; btnTitle.Value = "Add a question title"; btnTitle.Attributes.Add("onclick", "showQuestionTitle('" + strGroupID + "')"); //建立間隔 Label lblCell0 = new Label(); lblCell0.Style.Add("WIDTH", "20px"); tcTitle.Controls.Add(lblCell0); //建立Empty row if (i < dsQuestionNum.Tables[0].Rows.Count - 1) { TableRow trEmpty = new TableRow(); table.Rows.Add(trEmpty); trEmpty.BackColor = System.Drawing.Color.White; TableCell tcEmpty1 = new TableCell(); trEmpty.Cells.Add(tcEmpty1); tcEmpty1.Style.Add("Height", "10px"); tcEmpty1.ColumnSpan = 3; } } //加入Table的Title TableRow trTitle = new TableRow(); table.Rows.AddAt(0, trTitle); trTitle.Attributes.Add("Class", "header1_table_first_row"); TableCell tcGroupTitle = new TableCell(); trTitle.Cells.Add(tcGroupTitle); tcGroupTitle.Text = "Question topic"; TableCell tcQuestionTitle = new TableCell(); trTitle.Cells.Add(tcQuestionTitle); tcQuestionTitle.Text = "Selected questions number"; TableCell tcQuestionCountTitle = new TableCell(); trTitle.Cells.Add(tcQuestionCountTitle); tcQuestionCountTitle.Text = "Maximum questions count"; } else { //沒有資料 } dsQuestionNum.Dispose(); return(table); }