private void getold() { if (DDLgrade.Items.Count > 0 && DDLgrade.SelectedValue != "") { string hidstr = tcook.Hid.ToString(); string sgrade = DDLgrade.SelectedValue; if (LearnSite.Common.WordProcess.IsNum(sgrade)) { int Qobj = int.Parse(sgrade); LearnSite.BLL.QuizGrade bll = new LearnSite.BLL.QuizGrade(); LearnSite.Model.QuizGrade model = new LearnSite.Model.QuizGrade(); model = bll.GetModelByQobjQhid(Qobj, Int32.Parse(hidstr)); if (model != null) { Session[hidstr + "oldselect"] = model.Qclass; DDLOnly.SelectedValue = model.Qonly.ToString(); DDLMore.SelectedValue = model.Qmore.ToString(); DDLJudge.SelectedValue = model.Qjudge.ToString(); Quizpower.Checked = model.Qopen.Value; if (model.Qanswer != null) { Quizanswer.Checked = model.Qanswer.Value; } } } } }
private void listQuiz() { string Rnum = cook.Snum; int Qgrade = cook.Sgrade; int Qclass = cook.Sclass; LearnSite.Model.QuizGrade qmodel = new LearnSite.Model.QuizGrade(); LearnSite.BLL.QuizGrade qbll = new LearnSite.BLL.QuizGrade(); qmodel = qbll.GetModelByQobjRclass(Qgrade, Qclass); if (qmodel != null) { if (qmodel.Qopen.Value) { string selectclass = qmodel.Qclass; if (!string.IsNullOrEmpty(selectclass)) { bool isok = true; if (isok) { LearnSite.BLL.Quiz bll = new LearnSite.BLL.Quiz(); DataListonly.DataSource = bll.GetListByQtypeNum(0, qmodel.Qonly.Value, selectclass); DataListonly.DataBind(); DataListmore.DataSource = bll.GetListByQtypeNum(1, qmodel.Qmore.Value, selectclass); DataListmore.DataBind(); DataListjudge.DataSource = bll.GetListByQtypeNum(2, qmodel.Qjudge.Value, selectclass); DataListjudge.DataBind(); Btnquiz.Enabled = true; if (string.IsNullOrEmpty(qmodel.Qanswer.ToString())) { Session[Rnum + "quizQanswer"] = "false"; } else { Session[Rnum + "quizQanswer"] = qmodel.Qanswer.ToString(); } } selectclass = selectclass.Replace("'", ""); showscope.InnerHtml = Qgrade.ToString() + "年级试题范围:<br />" + selectclass.Replace(",", "<br />");//增加试题范围提示 } else { Labelmsg.Text = "老师没有选择试题范围!"; } } else { Btnquiz.Enabled = false; Labelmsg.Text = "测验暂停,请咨询老师开启!"; } } else { Btnquiz.Enabled = false; Labelmsg.Text = "请咨询老师设置本班测验!"; } }
protected void BtnSelect_Click(object sender, EventArgs e) { string hidstr = tcook.Hid.ToString(); string selectstr = SelectClass(); if (selectstr != "" && DDLgrade.SelectedValue != "") { int Qobj = int.Parse(DDLgrade.SelectedValue); LearnSite.BLL.QuizGrade bll = new LearnSite.BLL.QuizGrade(); LearnSite.Model.QuizGrade model = new LearnSite.Model.QuizGrade(); model.Qobj = Qobj; model.Qclass = selectstr; model.Qhid = Int32.Parse(hidstr); model.Qonly = Int32.Parse(DDLOnly.SelectedValue); model.Qmore = Int32.Parse(DDLMore.SelectedValue); model.Qjudge = Int32.Parse(DDLJudge.SelectedValue); model.Qopen = Quizpower.Checked; model.Qanswer = Quizanswer.Checked; string qid = bll.ExistsQobj(Qobj, Int32.Parse(hidstr)); if (qid != "") { model.Qid = Int32.Parse(qid); bll.Update(model);//如果存在则更新设置 } else { bll.Add(model);//如果不存在则添加设置 } string quizstr = "暂停"; if (Quizpower.Checked) { quizstr = "启用"; } Labelmsg.Text = "你给" + DDLgrade.SelectedValue + "年级选择的测验类型为:" + selectstr + "<br/><br/>单选题数:" + DDLOnly.SelectedValue + "多选题数:" + DDLMore.SelectedValue + "判断题数:" + DDLJudge.SelectedValue + "<br/><br/>当前年级测验开关状态:" + quizstr; } else { Labelmsg.Text = "提交选择失败!请至少选择一项"; } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(LearnSite.Model.QuizGrade model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(LearnSite.Model.QuizGrade model) { return(dal.Add(model)); }
/// <summary> /// 获得数据列表 /// </summary> public List <LearnSite.Model.QuizGrade> DataTableToList(DataTable dt) { List <LearnSite.Model.QuizGrade> modelList = new List <LearnSite.Model.QuizGrade>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { LearnSite.Model.QuizGrade model; for (int n = 0; n < rowsCount; n++) { model = new LearnSite.Model.QuizGrade(); if (dt.Rows[n]["Qid"].ToString() != "") { model.Qid = int.Parse(dt.Rows[n]["Qid"].ToString()); } if (dt.Rows[n]["Qobj"].ToString() != "") { model.Qobj = int.Parse(dt.Rows[n]["Qobj"].ToString()); } model.Qclass = dt.Rows[n]["Qclass"].ToString(); if (dt.Rows[n]["Qhid"].ToString() != "") { model.Qhid = int.Parse(dt.Rows[n]["Qhid"].ToString()); } if (dt.Rows[n]["Qonly"].ToString() != "") { model.Qonly = int.Parse(dt.Rows[n]["Qonly"].ToString()); } if (dt.Rows[n]["Qmore"].ToString() != "") { model.Qmore = int.Parse(dt.Rows[n]["Qmore"].ToString()); } if (dt.Rows[n]["Qjudge"].ToString() != "") { model.Qjudge = int.Parse(dt.Rows[n]["Qjudge"].ToString()); } if (dt.Rows[n]["Qopen"].ToString() != "") { if ((dt.Rows[n]["Qopen"].ToString() == "1") || (dt.Rows[n]["Qopen"].ToString().ToLower() == "true")) { model.Qopen = true; } else { model.Qopen = false; } } if (dt.Rows[n]["Qanswer"].ToString() != "") { if ((dt.Rows[n]["Qanswer"].ToString() == "1") || (dt.Rows[n]["Qanswer"].ToString().ToLower() == "true")) { model.Qanswer = true; } else { model.Qanswer = false; } } modelList.Add(model); } } return(modelList); }