protected void Button1_Click(object sender, EventArgs e) { ModelTestQueston model = new ModelTestQueston(); model.sysnumber = Guid.NewGuid().ToString(); model.mainQuestionSysnumber = model.sysnumber; model.questionTitle = this.al.Value; model.questionType = "案例"; model.ifCourseQuestion = 1; model.courseId = this.courseId; model.Description = "案例"; model.Orner = "0"; model.categoryFlag = this.courseId; model.personFlag = GetTypes(); model.createPerson = this.UserName; model.categorypath = getCategoryPath(this.courseId); model.createTime = DateTime.Now; model.orderBy = 0; new BllTestQueston().Add(model); BindNews(0); //是否为案例标志 new NGShop.Bll.TableObject("T_Test_Queston").Util_UpdateBat("isAL=1", "sysnumber='" + model.sysnumber + "'"); ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('保存成功');location.href='ListQuestionDailog.aspx?courseId=" + this.courseId + "';</script>"); }
/// <summary> /// 获得新闻详细信息 /// </summary> protected void GetNewsInfo() { string answer = ""; string title = ""; string questionType = ""; string descript = ""; DataTable dt = GetQuestionType(_Nid, ref questionType, ref answer, ref title, ref descript); SetTableValue("ck", "txt", answer, dt, this.tb); hidAnswer.Value = answer; ddlType.SelectedValue = questionType; txtTitle.Text = title; txtDescription.Text = descript; ModelTestQueston model = new ModelTestQueston(); BllTestQueston bll = new BllTestQueston(); model = bll.GetModel(_Nid); if (model != null) { foreach (ListItem item in this.CheckBoxList1.Items) { if (model.personFlag != null && model.personFlag.IndexOf(item.Value) > -1) { item.Selected = true; } } if (model.categoryFlag != null && model.categoryFlag != "") { foreach (string categoryId in model.categoryFlag.Split(',')) { foreach (ListItem item in this.ddlPCategory.Items) { if (categoryId == item.Value) { item.Selected = true; } } } } this.ddlLevelPoint.SelectedValue = model.LevelPoint.ToString(); this.ddlPCategory_Show.Text = ShowCategorynames(model.categoryFlag); this.hidOrderBy.Text = model.orderBy.ToString(); this.mainSysnumber.Value = model.mainQuestionSysnumber; if (this.mainSysnumber.Value != "") { ClientScript.RegisterStartupScript(this.GetType(), "a", "<script>selectType()</script>"); this.div_al.InnerHtml = GetMainQuestionInfo(this.mainSysnumber.Value).questionTitle; this.div_al.Style["height"] = "100px"; //this.btn_al.Visible = false; } if (model.questionType == "案例") { ClientScript.RegisterStartupScript(this.GetType(), "b", "<script>$('#tr_options').hide();$('#tr_sh').hide();</script>"); } } }
protected void Button1_Click(object sender, EventArgs e) { ModelTestQueston model = new ModelTestQueston(); model.sysnumber = Guid.NewGuid().ToString(); model.questionTitle = this.al.Value; model.questionType = this.questionType; model.Description = ""; model.Orner = "0"; model.categoryFlag = ddlPCategory2.SelectedValue; model.personFlag = GetTypes(); model.createPerson = this.UserName; model.categorypath = getCategoryPath(ddlPCategory2.SelectedValue); model.createTime = DateTime.Now; model.orderBy = 0; new BllTestQueston().Add(model); BindNews(0); }
protected void btnAdd_Click(object sender, EventArgs e) { //Excel导入 string path = UploadFile(this.FileUpload1, "~/upload/excel/"); if (path == "") { ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('请选择要导入的Excel文件!');</script>"); return; } //Excel读取 string error = ""; DataSet dsExcel = GetExcelData(Server.MapPath(path), ref error); if (dsExcel == null) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('" + error.Replace("'", "’") + "');</script>"); return; } //Excel格式判读 if (dsExcel.Tables[0].Columns.Count < 5) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('Excel格式错误!');</script>"); return; } //开始导入 int totalNum = 0; int errorNum = 0; int exsitNum = 0; BllTestQueston bll = new BllTestQueston(); int sn = 1; foreach (DataRow row in dsExcel.Tables[0].Rows) { if (row[0].ToString().Trim() == "" || row[2].ToString().Trim() == "") { continue; } if (row[0].ToString().Trim() == "题型名称" || row[2].ToString().Trim() == "题目内容") { continue; } ModelTestQueston model = new ModelTestQueston(); model.sysnumber = Guid.NewGuid().ToString(); model.questionTitle = row[2].ToString().Trim().Replace("'", "’").Replace("\t", "").Replace("\r", "").Replace("\n", "").Replace("/", "∕").Replace("ˆ", "^").Trim(); model.questionType = row[0].ToString().Trim().Replace(" ", "").Replace("\t", "").Replace("\r", "").Replace("\n", "").Trim(); try { model.LevelPoint = decimal.Parse(row[1].ToString().Trim().Replace(" ", "").Replace("\t", "").Replace("\r", "").Replace("\n", "").Trim()); } catch { model.LevelPoint = 0; } model.Orner = "0"; //1属于每日一练表 0属于普通题目表; model.personFlag = ""; model.categoryFlag = this.courseId; model.categorypath = getCategoryPath(this.courseId); model.createTime = DateTime.Now; model.createPerson = "excel"; model.courseId = this.txtCourseId.Value.Trim(); model.Description = row[6].ToString().Trim().Replace(" ", "").Replace("\t", "").Replace("\r", "").Replace("\n", "").Replace("【解析】", "").Trim(); #region answer model.questionAnswer = row[5].ToString().Trim().ToUpper().Replace("##", ",").Replace("\t", "").Replace("\r", "").Replace("\n", "").Trim(); if (model.questionType == "判断题") { model.questionAnswer = (model.questionAnswer == "T") ? "A" : "B"; } model.questionAnswer = model.questionAnswer.Replace("A", "A,").Replace("B", "B,").Replace("C", "C,").Replace("D", "D,").Replace("E", "E,").Replace(",,", ","); #endregion model.orderBy = sn; model.shFlag = int.Parse(this.ddlSH.SelectedValue); //重复判断 if (this.txtCourseId.Value.Trim() != "") { if (bll.GetList("questionTitle='" + model.questionTitle + "' and courseId='" + this.txtCourseId.Value.Trim() + "'").Tables[0].Rows.Count > 0) { exsitNum++; continue; } } else { if (bll.GetList("questionTitle='" + model.questionTitle + "' and questionType='" + model.questionType + "' and categorypath='" + model.categorypath + "'").Tables[0].Rows.Count > 0) { exsitNum++; continue; } } if (bll.Add(model) > 0) { sn++; if (model.questionType == "判断题") { AddQuestionAnswer(model.sysnumber, "A", "对", 1); AddQuestionAnswer(model.sysnumber, "B", "错", 2); } else { string[] answerArr = row[4].ToString().Trim().Split(new string[] { "##" }, StringSplitOptions.None); string strA = answerArr.Length >= 1 ? answerArr[0].Trim() : ""; string strB = answerArr.Length >= 2 ? answerArr[1].Trim() : ""; string strC = answerArr.Length >= 3 ? answerArr[2].Trim() : ""; string strD = answerArr.Length >= 4 ? answerArr[3].Trim() : ""; string strE = answerArr.Length >= 5 ? answerArr[4].Trim() : ""; if (strA != "") { AddQuestionAnswer(model.sysnumber, "A", strA, 1); } if (strB != "") { AddQuestionAnswer(model.sysnumber, "B", strB, 2); } if (strC != "") { AddQuestionAnswer(model.sysnumber, "C", strC, 3); } if (strD != "") { AddQuestionAnswer(model.sysnumber, "D", strD, 4); } if (strE != "") { AddQuestionAnswer(model.sysnumber, "E", strE, 5); } } totalNum++; if (this.courseId != "" && this.sjid != "") { AddIntoSJ(this.sjid, model.sysnumber); } //课后练习 } else { errorNum++; } } Response.Write("<script>alert('成功导入" + totalNum + "条数据[失败" + errorNum + "条][重复" + exsitNum + "条],重复信息不导入!');window.close();</script>"); }
/// <summary> /// 确定提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { string strError = Validates(); if (strError != "") { //JSUtility.Alert(strError); return; } model.LevelPoint = decimal.Parse(this.ddlLevelPoint.SelectedValue); model.ifCourseQuestion = 1; model.questionTitle = this.txtTitle.Text.Trim(); model.questionType = ddlType.SelectedValue; model.Description = txtDescription.Text; model.Orner = "0"; //1属于每日一练表 0属于普通题目表; model.categoryFlag = GetCategorys(); model.personFlag = GetTypes(); model.createPerson = this.UserName; model.categorypath = getCategoryPath(model.categoryFlag); model.createTime = DateTime.Now; model.orderBy = Int32.Parse(this.hidOrderBy.Text.Trim()); if (this.courseId != "") { model.courseId = this.courseId; } if (this.mainSysnumber.Value != "") { model.isSubQuestion = 1; model.mainQuestionSysnumber = this.mainSysnumber.Value; model.personFlag = GetMainQuestionInfo(model.mainQuestionSysnumber).personFlag; } else { model.isSubQuestion = 0; model.mainQuestionSysnumber = ""; } if (_Nid != "") { string typeFlag = ""; string answers = ""; string title = ""; string answer = ""; string descript = ""; DataTable dt = GetQuestionType(_Nid, ref typeFlag, ref answers, ref title, ref descript); SubUpdate(_Nid, this.tb, "ck", "txt", ref answer); model.sysnumber = _Nid; model.questionAnswer = answer; #region 原数据 ModelTestQueston modelOld = bll.GetModel(_Nid); if (modelOld != null) { model.courseId = modelOld.courseId; } #endregion bll.Update(model); SaveSH(model.sysnumber); if (this.mainSysnumber.Value != "") { EditSameGroup(this.mainSysnumber.Value); } //跳转控制 if (Request["from"] != null && Request["from"] == "course") { Response.Write("<script>alert('题目修改成功');</script>"); } else { //状态 if (Session["NewsStatus_Hashtable"] != null) { Hashtable hTable = (Hashtable)Session["NewsStatus_Hashtable"]; hTable["ReadSessionStatus"] = "1"; Session["NewsStatus_Hashtable"] = hTable; } Response.Write("<script>alert('题目修改成功');</script>"); } } else { model.sysnumber = Guid.NewGuid().ToString(); string questionAnser = ""; Sub(model.sysnumber, tb, "ck", "txt", ref questionAnser); model.questionAnswer = questionAnser; bll.Add(model); SaveSH(model.sysnumber); //加入所属试卷 AddIntoSJ(this.sjid, model.sysnumber); Response.Write("<script>alert('题目添加成功,请继续添加');location.href='AddQuestions.aspx?courseId=" + this.courseId + "'</script>"); } }