protected void Page_Load(object sender, EventArgs e) { string type = Request.QueryString["type"]; this.type.Value = type; string qsid = Request.QueryString["qsid"].Trim(); this.qsid.Value = qsid; cfs.BLL.OT_QUESTION bll = new BLL.OT_QUESTION(); cfs.Model.OT_QUESTION model = new Model.OT_QUESTION(); switch (type) { case "ChoiceEdit": model = bll.GetModel(qsid); this.number.Value = model.QS_ID.ToString(); if (model.QS_CONTENT == null || model.QS_CONTENT.ToString().Trim() == "") { this.question.Value = ""; } else { this.question.Value = model.QS_CONTENT.ToString(); } if (model.QS_CHOICE_A == null || model.QS_CHOICE_A.ToString().Trim() == "") { this.ca.Value = ""; } else { this.ca.Value = model.QS_CHOICE_A.ToString(); } if (model.QS_CHOICE_B == null || model.QS_CHOICE_B.ToString().Trim() == "") { this.cb.Value = ""; } else { this.cb.Value = model.QS_CHOICE_B.ToString(); } if (model.QS_CHOICE_C == null || model.QS_CHOICE_C.ToString().Trim() == "") { this.cc.Value = ""; } else { this.cc.Value = model.QS_CHOICE_C.ToString(); } if (model.QS_CHOICE_D == null || model.QS_CHOICE_D.ToString().Trim() == "") { this.cd.Value = ""; } else { this.cd.Value = model.QS_CHOICE_D.ToString(); } if (model.QS_CHOICE_COR != null && model.QS_CHOICE_COR.ToString().Trim() != "") { switch (model.QS_CHOICE_COR) { case 1: this.answer1.Checked = true; break; case 2: this.answer2.Checked = true; break; case 3: this.answer3.Checked = true; break; case 4: this.answer4.Checked = true; break; default: break; } } if (model.QS_COR_EXPLAINATION == null || model.QS_COR_EXPLAINATION.ToString().Trim() == "") { this.explaination.Value = ""; } else { this.explaination.Value = model.QS_COR_EXPLAINATION.ToString(); } break; case "ChoiceDetail": model = bll.GetModel(qsid); this.number.Value = model.QS_ID.ToString(); if (model.QS_CONTENT == null || model.QS_CONTENT.ToString().Trim() == "") { this.question.Value = ""; this.question.Disabled = true; } else { this.question.Value = model.QS_CONTENT.ToString(); this.question.Disabled = true; } if (model.QS_CHOICE_A == null || model.QS_CHOICE_A.ToString().Trim() == "") { this.ca.Value = ""; this.ca.Disabled = true; } else { this.ca.Value = model.QS_CHOICE_A.ToString(); this.ca.Disabled = true; } if (model.QS_CHOICE_B == null || model.QS_CHOICE_B.ToString().Trim() == "") { this.cb.Value = ""; this.cb.Disabled = true; } else { this.cb.Value = model.QS_CHOICE_B.ToString(); this.cb.Disabled = true; } if (model.QS_CHOICE_C == null || model.QS_CHOICE_C.ToString().Trim() == "") { this.cc.Value = ""; this.cc.Disabled = true; } else { this.cc.Value = model.QS_CHOICE_C.ToString(); this.cc.Disabled = true; } if (model.QS_CHOICE_D == null || model.QS_CHOICE_D.ToString().Trim() == "") { this.cd.Value = ""; this.cd.Disabled = true; } else { this.cd.Value = model.QS_CHOICE_D.ToString(); this.cd.Disabled = true; } if (model.QS_CHOICE_COR != null && model.QS_CHOICE_COR.ToString().Trim() != "") { switch (model.QS_CHOICE_COR) { case 1: this.answer1.Checked = true; break; case 2: this.answer2.Checked = true; break; case 3: this.answer3.Checked = true; break; case 4: this.answer4.Checked = true; break; default: break; } this.answer1.Disabled = true; this.answer2.Disabled = true; this.answer3.Disabled = true; this.answer4.Disabled = true; } if (model.QS_COR_EXPLAINATION == null || model.QS_COR_EXPLAINATION.ToString().Trim() == "") { this.explaination.Value = ""; this.explaination.Disabled = true; } else { this.explaination.Value = model.QS_COR_EXPLAINATION.ToString(); this.explaination.Disabled = true; } break; default: break; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; /*----------------------题目操作接口—————————————————————————*/ string action = context.Request.Params["type"]; string qsid = context.Request.Params["qsid"]; cfs.Model.JSON jj; cfs.BLL.OT_QUESTION bll_q = new BLL.OT_QUESTION(); cfs.Model.OT_QUESTION model_q = new Model.OT_QUESTION(); cfs.BLL.OT_ESSAY bll_e = new BLL.OT_ESSAY(); cfs.Model.OT_ESSAY model_e = new cfs.Model.OT_ESSAY(); JavaScriptSerializer jss = new JavaScriptSerializer(); switch (action) { case "TranslationDetail": break; case "TranslationAdd": //调用存储过程生成ES_ID model_e.ES_CONTENT = context.Request.Form["question"]; model_e.ES_ANSWER = context.Request.Form["answer"]; model_e.ES_CTIME = System.DateTime.Now; if (bll_e.Add(model_e)) { jj = new Model.JSON() { statusCode = "200", message = "新增成功", navTabId = "Translation", rel = "", callbackType = "closeCurrent" }; } else { jj = new Model.JSON() { statusCode = "300", message = "新增失败", navTabId = "Translation", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; case "TranslationEdit": model_e = bll_e.GetModel(qsid); model_e.ES_CONTENT = context.Request.Form["question"]; model_e.ES_ANSWER = context.Request.Form["answer"]; model_e.ES_CTIME = System.DateTime.Now; if (bll_e.Update(model_e)) { jj = new Model.JSON() { statusCode = "200", message = "编辑成功", navTabId = "Translation", rel = "", callbackType = "closeCurrent" }; } else { jj = new Model.JSON() { statusCode = "300", message = "编辑失败", navTabId = "Translation", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; case "TranlationDelete": if (bll_e.Delete(qsid)) { jj = new Model.JSON() { statusCode = "200", message = "删除成功", navTabId = "Translation", rel = "", callbackType = "" }; } else { jj = new Model.JSON() { statusCode = "300", message = "删除失败", navTabId = "Translation", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; case "CompositionDetail": break; case "CompositionAdd": //调用存储过程生成ES_ID model_e.ES_TITLE = context.Request.Form["question_title"]; model_e.ES_CONTENT = context.Request.Form["question_content"]; model_e.ES_ANSWER = context.Request.Form["answer"]; model_e.ES_CTIME = System.DateTime.Now; if (bll_e.Add(model_e)) { jj = new Model.JSON() { statusCode = "200", message = "新增成功", navTabId = "Composition", rel = "", callbackType = "closeCurrent" }; } else { jj = new Model.JSON() { statusCode = "300", message = "新增失败", navTabId = "Composition", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; case "CompositionEdit": model_e = bll_e.GetModel(qsid); model_e.ES_TITLE = context.Request.Form["question_title"]; model_e.ES_CONTENT = context.Request.Form["question_content"]; model_e.ES_ANSWER = context.Request.Form["answer"]; model_e.ES_CTIME = System.DateTime.Now; if (bll_e.Update(model_e)) { jj = new Model.JSON() { statusCode = "200", message = "编辑成功", navTabId = "Composition", rel = "", callbackType = "closeCurrent" }; } else { jj = new Model.JSON() { statusCode = "300", message = "编辑失败", navTabId = "Composition", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; case "CompositionDelete": if (bll_e.Delete(qsid)) { jj = new Model.JSON() { statusCode = "200", message = "删除成功", navTabId = "Composition", rel = "", callbackType = "" }; } else { jj = new Model.JSON() { statusCode = "300", message = "删除失败", navTabId = "Composition", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; case "ChoiceDetail": break; case "ChoiceAdd": //调用存储过程生成QS_ID model_q.QS_CONTENT = context.Request.Form["question"]; model_q.QS_CHOICE_A = context.Request.Form["ca"]; model_q.QS_CHOICE_B = context.Request.Form["cb"]; model_q.QS_CHOICE_C = context.Request.Form["cc"]; model_q.QS_CHOICE_D = context.Request.Form["cd"]; model_q.QS_CHOICE_COR = Convert.ToInt32(context.Request.Form["answer"]); model_q.QS_COR_EXPLAINATION = context.Request.Form["explaination"]; model_q.QS_CTIME = System.DateTime.Now; if (bll_q.Add(model_q)) { jj = new Model.JSON() { statusCode = "200", message = "新增成功", navTabId = "Choice", rel = "", callbackType = "closeCurrent" }; } else { jj = new Model.JSON() { statusCode = "300", message = "新增失败", navTabId = "Choice", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; case "ChoiceEdit": model_q = bll_q.GetModel(qsid); model_q.QS_CONTENT = context.Request.Form["question"]; model_q.QS_CHOICE_A = context.Request.Form["ca"]; model_q.QS_CHOICE_B = context.Request.Form["cb"]; model_q.QS_CHOICE_C = context.Request.Form["cc"]; model_q.QS_CHOICE_D = context.Request.Form["cd"]; model_q.QS_CHOICE_COR = Convert.ToInt32(context.Request.Form["answer"]); model_q.QS_COR_EXPLAINATION = context.Request.Form["explaination"]; model_q.QS_CTIME = System.DateTime.Now; if (bll_q.Update(model_q)) { jj = new Model.JSON() { statusCode = "200", message = "编辑成功", navTabId = "Choice", rel = "", callbackType = "closeCurrent" }; } else { jj = new Model.JSON() { statusCode = "300", message = "编辑失败", navTabId = "Choice", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; case "ChoiceDelete": if (bll_q.Delete(qsid)) { jj = new Model.JSON() { statusCode = "200", message = "删除成功", navTabId = "Choice", rel = "", callbackType = "" }; } else { jj = new Model.JSON() { statusCode = "300", message = "删除失败", navTabId = "Choice", rel = "", callbackType = "" }; } context.Response.Write(jss.Serialize(jj)); break; default: break; } }