protected void Button2_Click(object sender, EventArgs e) { string allQuestions = ""; DataTable dt = new TableObject("T_Test_Day").Util_GetList("*", "Sysnumber='" + _Nid + "'"); DataTable dtTM = new TableObject("T_Test_Queston").Util_GetList("*", "categoryFlag='" + dt.Rows[0]["chapterId"] + "'"); foreach (DataRow row in dtTM.Rows) { string questionSysnumber = row["sysnumber"].ToString(); allQuestions += questionSysnumber + ","; DataTable dtDA = new TableObject(" T_Question_AnswerItems").Util_GetList("*", "questionSysnumber='" + questionSysnumber + "'"); int orderby = 0; string rightDA = ""; foreach (DataRow rowDA in dtDA.Rows) { ModelTestQuestonAnswer modelTestA = new ModelTestQuestonAnswer(); modelTestA.sysnumber = rowDA["sysnumber"].ToString(); modelTestA.questionSysnumber = questionSysnumber; modelTestA.AnswerKey = GetENG(orderby); modelTestA.AnswerValue = rowDA["anserItemDesc"].ToString(); modelTestA.OrderBy = orderby; new DalTestQuestonAnswer().Add(modelTestA); orderby++; if (rowDA["isAnswer"].ToString() == "1") { rightDA += modelTestA.AnswerKey + ","; } } new TableObject("T_Test_Queston").Util_UpdateBat("questionAnswer='" + rightDA + "'", "sysnumber='" + rightDA + "'"); } new TableObject("T_Test_Day").Util_UpdateBat("Questions='" + allQuestions + "'", "Sysnumber='" + _Nid + "'"); }
private int AddQuestionAnswer(string questionSys, string key, string keyText, int orderby) { ModelTestQuestonAnswer modelTestA = new ModelTestQuestonAnswer(); modelTestA.sysnumber = Guid.NewGuid().ToString(); modelTestA.questionSysnumber = questionSys; modelTestA.AnswerKey = key.Trim().Replace("'", "’").Replace("\t", "").Replace("\r", "").Replace("\n", "").Trim(); modelTestA.AnswerValue = keyText.Trim().Replace("'", "’").Replace("\t", "").Replace("\r", "").Replace("\n", "").Trim(); modelTestA.OrderBy = orderby; return(new DalTestQuestonAnswer().Add(modelTestA)); }
private void AddQuestionAnswer(string questionSys, string questiongTitle, string isRight, int orderby) { ModelTestQuestonAnswer modelTestA = new ModelTestQuestonAnswer(); modelTestA.sysnumber = Guid.NewGuid().ToString(); modelTestA.questionSysnumber = questionSys; modelTestA.AnswerKey = questiongTitle; modelTestA.AnswerValue = isRight; modelTestA.OrderBy = orderby; new DalTestQuestonAnswer().Add(modelTestA); }