private void BindData() { #region 组装查询条件 string whereStr = " group_id = " + (int)EnumCollection.examination_group.心理测试 + " and parent_id = " + this.chapter; //string whereStr = " 1 = 1 "; string _keywords = keywords.Replace("'", ""); if (!string.IsNullOrEmpty(_keywords)) { if (Utils.IsSafeSqlString(_keywords)) { whereStr += " and (name like '%" + _keywords + "%')"; } else { JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("questionnaire_list.aspx", "keywords={0}", "")); return; } } //if (this.chapter > 0) //{ // whereStr += " parent_id = " + this.chapter; //} #endregion Model.course_chapter ccModel = new BLL.course_chapter().GetModel(chapter); if (ccModel != null) { chapter_name = ccModel.name; Model.course_info course = new BLL.course_info().GetModel(ccModel.course_id); if (course != null) { course_name = course.name; } else { JscriptMsg("传递参数错误", "back"); return; } } else { JscriptMsg("传递参数错误", "back"); return; } this.page = RequestHelper.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.common_examination bll = new BLL.common_examination(); this.rptList.DataSource = bll.GetListByPage(whereStr, "ID DESC", this.page, this.pageSize); this.rptList.DataBind(); this.totalCount = bll.GetRecordCount(whereStr); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("questionnaire_list.aspx", "keywords={0}&page={1}&chapter={2}", this.keywords, "__id__", this.chapter + ""); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private bool DoAdd() { BLL.common_examination bll = new BLL.common_examination(); Model.common_examination model = new Model.common_examination(); model.group_id = (int)EnumCollection.examination_group.精品微课测验; model.name = Convert.ToString(txtname.Text); model.parent_id = this.chapter; model.nums = Convert.ToInt32(txtnums.Text); model.score = Convert.ToInt32(txtscore.Text); model.qrcode = ""; model.add_time = System.DateTime.Now; int row = bll.Add(model); if (row > 0) { addrow = row; model.id = row; model.qrcode = "/QrCode.aspx?type=test&id=" + row; bll.Update(model); AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加试卷信息,主键:" + row); //记录日志 return(true); } else { return(false); } }
private bool DoEdit(int id) { BLL.common_examination bll = new BLL.common_examination(); Model.common_examination model = bll.GetModel(this.id); model.group_id = (int)EnumCollection.examination_group.心理测试; model.name = Convert.ToString(txtname.Text); model.parent_id = this.chapter; model.nums = 0; model.score = 0; model.info = this.txtinfo.Text.Trim(); model.descript = this.txtdescript.Text.Trim(); model.qrcode = "/QrCode.aspx?type=quest&id=" + id; model.add_time = System.DateTime.Now; if (bll.Update(model)) { AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改问卷信息,主键:" + id); //记录日志 return(true); } else { return(false); } }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_common_examination", EnumCollection.ActionEnum.Modify.ToString()); //检查权限 BLL.common_examination bll = new BLL.common_examination(); Model.common_examination model = bll.GetModel(this.id); model.group_id = Convert.ToInt32(txtgroup_id.Text); model.name = Convert.ToString(txtname.Text); model.parent_id = Convert.ToInt32(txtparent_id.Text); model.nums = Convert.ToInt32(txtnums.Text); model.score = Convert.ToInt32(txtscore.Text); model.info = Convert.ToString(txtinfo.Text); model.descript = Convert.ToString(txtdescript.Text); model.qrcode = Convert.ToString(txtqrcode.Text); model.add_time = Convert.ToDateTime(txtadd_time.Text); if (bll.Update(model)) { AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改试卷信息信息,主键:" + id); //记录日志 JscriptMsg("修改试卷信息信息成功!", "Manage.aspx"); } else { JscriptMsg("保存过程中发生错误!", ""); } }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_common_examination", EnumCollection.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.common_examination bll = new BLL.common_examination(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { if (bll.Delete(id)) { sucCount += 1; } else { errorCount += 1; } } } AddAdminLog(EnumCollection.ActionEnum.Delete.ToString(), "删除试卷信息" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("questionnaire_list.aspx", "keywords={0}&chapter={1}", this.keywords, this.chapter + "")); }
private void BindData() { #region 组装查询条件 string whereStr = " 1 = 1 "; string _keywords = keywords.Replace("'", ""); if (!string.IsNullOrEmpty(_keywords)) { if (Utils.IsSafeSqlString(_keywords)) { whereStr += " and (Title like '%" + _keywords + "%')"; } else { JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("Manage.aspx", "keywords={0}", "")); return; } } #endregion this.page = RequestHelper.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.common_examination bll = new BLL.common_examination(); this.rptList.DataSource = bll.GetListByPage(whereStr, "ID DESC", this.page, this.pageSize); this.rptList.DataBind(); this.totalCount = bll.GetRecordCount(whereStr); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("Manage.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
protected void Page_Load(object sender, EventArgs e) { int id = RequestHelper.GetQueryInt("id"); Model.common_examination model = new BLL.common_examination().GetModel(id); if (model == null) { contents = ""; } else { contents = model.descript; } }
private void BindInfo() { BLL.common_examination bll = new BLL.common_examination(); Model.common_examination model = bll.GetModel(this.id); if (model == null) { JscriptMsg("信息不存在或已被删除!", "back"); return; } txtgroup_id.Text = model.group_id + ""; txtname.Text = model.name + ""; txtparent_id.Text = model.parent_id + ""; txtnums.Text = model.nums + ""; txtscore.Text = model.score + ""; txtinfo.Text = model.info + ""; txtdescript.Text = model.descript + ""; txtqrcode.Text = model.qrcode + ""; txtadd_time.Text = model.add_time + ""; }
private void ShowInfo(int _id) { BLL.common_examination bll = new BLL.common_examination(); Model.common_examination model = bll.GetModel(this.id); if (model == null) { JscriptMsg("信息不存在或已被删除!", "back"); return; } if (model == null) { JscriptMsg("信息不存在或已被删除!", "back"); return; } txtname.Text = model.name + ""; txtnums.Text = model.nums + ""; txtscore.Text = model.score + ""; }
private bool DoEdit(int id) { BLL.common_examination bll = new BLL.common_examination(); Model.common_examination model = bll.GetModel(this.id); model.group_id = (int)EnumCollection.examination_group.课堂作业; model.name = Convert.ToString(txtname.Text); model.parent_id = this.chapter; model.nums = Convert.ToInt32(txtnums.Text); model.score = Convert.ToInt32(txtscore.Text); model.qrcode = "/QrCode.aspx?type=test&id=" + id; model.add_time = System.DateTime.Now; if (bll.Update(model)) { addRow = model.id; AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改课堂作业信息,主键:" + id); //记录日志 return(true); } else { return(false); } }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_common_examination", EnumCollection.ActionEnum.Add.ToString()); //检查权限 #region string strError = string.Empty; if (txtgroup_id.Text.Trim() == "" || txtgroup_id.Text.Trim().Length > 4) { strError += "分组ID为空或超出长度![br]"; } if (txtname.Text.Trim() == "" || txtname.Text.Trim().Length > 50) { strError += "试卷名称为空或超出长度![br]"; } if (txtparent_id.Text.Trim() == "" || txtparent_id.Text.Trim().Length > 4) { strError += "主体ID为空或超出长度![br]"; } if (txtnums.Text.Trim() == "" || txtnums.Text.Trim().Length > 4) { strError += "试题数量为空或超出长度![br]"; } if (txtscore.Text.Trim() == "" || txtscore.Text.Trim().Length > 4) { strError += "总分为空或超出长度![br]"; } if (txtinfo.Text.Trim() == "" || txtinfo.Text.Trim().Length > 500) { strError += "描述为空或超出长度![br]"; } if (txtdescript.Text.Trim() == "" || txtdescript.Text.Trim().Length > 4000) { strError += "结果解析为空或超出长度![br]"; } if (txtqrcode.Text.Trim() == "" || txtqrcode.Text.Trim().Length > 255) { strError += "二维码为空或超出长度![br]"; } if (txtadd_time.Text.Trim() == "" || txtadd_time.Text.Trim().Length > 8) { strError += "创建时间为空或超出长度![br]"; } if (strError != string.Empty) { JscriptMsg(strError, "", "Error"); return; } #endregion Model.common_examination model = new Model.common_examination(); BLL.common_examination bll = new BLL.common_examination(); model.group_id = Convert.ToInt32(txtgroup_id.Text); model.name = Convert.ToString(txtname.Text); model.parent_id = Convert.ToInt32(txtparent_id.Text); model.nums = Convert.ToInt32(txtnums.Text); model.score = Convert.ToInt32(txtscore.Text); model.info = Convert.ToString(txtinfo.Text); model.descript = Convert.ToString(txtdescript.Text); model.qrcode = Convert.ToString(txtqrcode.Text); model.add_time = Convert.ToDateTime(txtadd_time.Text); int id = bll.Add(model); if (id > 0) { AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加试卷信息信息,主键:" + id); //记录日志 JscriptMsg("添加试卷信息信息成功!", "Manage.aspx", ""); } else { JscriptMsg("保存过程中发生错误!", ""); } }
private void SumScore(int exa_id, int uid) { int truth_count = 0; int score = 0; BLL.common_questions qBll = new BLL.common_questions(); BLL.answer_record arBll = new BLL.answer_record(); BLL.common_answers aBll = new BLL.common_answers(); Model.user_info user = new BLL.user_info().GetModel(uid); Model.common_examination exa = new BLL.common_examination().GetModel(exa_id); if (exa != null) { DataTable dt = arBll.GetList(" exa_id = " + exa_id + " and user_id = " + uid); foreach (DataRow item in dt.Rows) { #region 批改作业按老师选择对错为准 int is_truth = Convert.ToInt32(item["is_truth"]); if (is_truth == 1) { truth_count++; score += Convert.ToInt32(item["score"]); } #endregion #region 批改作业按答题记录为准 //int q_id = Convert.ToInt32(item["q_id"]); //string answer = item["answer"].ToString(); //Model.common_questions question = qBll.GetModel(q_id); //if (!string.IsNullOrEmpty(answer))//没有答题 //{ // if (question.type == (int)EnumCollection.questions_type.单选题 || question.type == (int)EnumCollection.questions_type.判断题) // { // Model.common_answers anModel = aBll.GetModel(Convert.ToInt32(answer)); // if (anModel.options == question.answer) // { // truth_count++; // score += Convert.ToInt32(item["score"]); // } // } // if (question.type == (int)EnumCollection.questions_type.多选题) // { // string[] ids = answer.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); // string anids = string.Empty; // foreach (string id in ids) // { // Model.common_answers anModel = aBll.GetModel(Convert.ToInt32(id)); // anids += anModel.options + ","; // } // if (question.answer == Utils.DelLastComma(anids)) // { // truth_count++; // score += Convert.ToInt32(item["score"]); // } // } // if (question.type == (int)EnumCollection.questions_type.填空题 || question.type == (int)EnumCollection.questions_type.主观题) // { // if (answer.Contains(question.answer)) // { // truth_count++; // score += Convert.ToInt32(item["score"]); // } // } //} #endregion } BLL.answer_result bll = new BLL.answer_result(); Model.answer_result model = bll.GetModel(" group_id = " + (int)EnumCollection.examination_group.课堂作业 + " and exa_id = " + exa_id + " and user_id = " + uid); if (model != null) { model.truth_num = truth_count; model.count = exa.nums; model.truth_ratio = Convert.ToDecimal((decimal)model.truth_num / (decimal)model.count) * 100; model.score = score; model.status = (int)EnumCollection.correcting_status.已批改; bll.Update(model); } else { model = new Model.answer_result(); model.group_id = (int)EnumCollection.examination_group.课堂作业; model.exa_id = exa_id; model.exa_title = exa.name; model.user_id = uid; model.avatar = user.avatar; model.nick_name = user.nick_name; model.use_min = 0; model.use_sec = 0; model.truth_num = truth_count; model.count = exa.nums; model.truth_ratio = 0; model.score = score; model.status = (int)EnumCollection.correcting_status.未批改; model.add_time = System.DateTime.Now; bll.Add(model); } } }
private void BindData() { BLL.course_chapter ccBll = new BLL.course_chapter(); Model.course_chapter chapter = ccBll.GetModel(this.chapter); if (chapter == null) { JscriptMsg("没有此节", "back"); return; } this.chapter_name = chapter.name; Model.course_chapter pModel = ccBll.GetModel(chapter.parent_id); if (pModel == null) { JscriptMsg("没有此章", "back"); return; } this.parent_name = pModel.name; Model.classroom_info ciModel = new BLL.classroom_info().GetModel(pModel.course_id); if (ciModel == null) { JscriptMsg("没有此课堂", "back"); return; } this.class_name = ciModel.name; Model.user_info user = new BLL.user_info().GetModel(" phone = '" + adminInfo.user_name + "' "); if (user == null) { JscriptMsg("没有此教师", "back"); return; } if (ciModel.user_id != user.id) { JscriptMsg("此课堂不属于你", "back"); return; } Model.common_examination exaModel = new BLL.common_examination().GetModel(this.exa_id); if (exaModel == null) { JscriptMsg("没有此作业", "back"); return; } this.examination = exaModel.name; #region 组装查询条件 string whereStr = " 1 = 1 "; DataTable dtids = new BLL.examination_question().GetList(" exa_id = " + this.exa_id); string ids = string.Empty; foreach (DataRow item in dtids.Rows) { ids += Convert.ToInt32(item["q_id"]) + ","; } ids = Utils.DelLastComma(ids); if (!string.IsNullOrEmpty(ids)) { whereStr += " and id in (" + ids + ") "; } string _keywords = keywords.Replace("'", ""); if (!string.IsNullOrEmpty(_keywords)) { if (Utils.IsSafeSqlString(_keywords)) { whereStr += " and (Title like '%" + _keywords + "%')"; } else { JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("currect_question_list.aspx", "keywords={0}", "")); return; } } if (this.type > 0) { this.ddlType.SelectedValue = this.type + ""; whereStr += " and type = " + this.type; } #endregion this.page = RequestHelper.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.common_questions bll = new BLL.common_questions(); this.rptList.DataSource = bll.GetListByPage(whereStr, "ID", this.page, this.pageSize); this.rptList.DataBind(); this.totalCount = bll.GetRecordCount(whereStr); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("currect_question_list.aspx", "keywords={0}&page={1}&type={2}", this.keywords, "__id__", this.type + ""); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private void GetQrCode(string type) { string str = string.Empty; string id = Request.QueryString["id"]; string logopath = string.Empty; bool is_logo = true; Model.course_info course = null; switch (type) { case "course": //课程 is_logo = true; course = new BLL.course_info().GetModel(Convert.ToInt32(id)); if (course != null) { str = WebPath + "/html/course_details.html?id=" + id; logopath = course.qrcode_logo; } else { return; } break; case "re": //资源 is_logo = true; Model.common_resource resource = new BLL.common_resource().GetModel(Convert.ToInt32(id)); if (resource != null) { course = new BLL.course_info().GetModel(" id = (select course_id from ybd_course_chapter where id = " + resource.data_id + ")"); if (course != null) { logopath = course.qrcode_logo; } switch (resource.type) { case (int)Appoa.Common.EnumCollection.resource_type.图文资源: if (resource.from_id == (int)EnumCollection.resource_from.精品微课) { str = WebPath + "/html/article_details.html?id=" + id; } else { str = WebPath + "/html/knowledge_details.html?id=" + id; } break; case (int)Appoa.Common.EnumCollection.resource_type.文档资源: resource.path = resource.path.Substring(0, resource.path.LastIndexOf('.')); //str = WebPath + resource.path + ".html"; str = WebPath + "/html/doc_detail.html?id=" + id; break; case (int)Appoa.Common.EnumCollection.resource_type.音频资源: str = WebPath + "/html/video_details.html?id=" + id; break; case (int)Appoa.Common.EnumCollection.resource_type.视频资源: str = WebPath + "/html/video_details.html?id=" + id; break; case (int)Appoa.Common.EnumCollection.resource_type.英文发音: str = WebPath + "/html/voice_detail.html?id=" + id; break; case (int)Appoa.Common.EnumCollection.resource_type.维模型: str = WebPath + "/html/3d.html?id=" + id; break; } } else { return; } break; case "test": //测验 Model.common_examination exam = new BLL.common_examination().GetModel(Convert.ToInt32(id)); if (exam != null) { str = WebPath + "/html/test.html?id=" + id; is_logo = true; //course = new BLL.course_info().GetModel(" id = (select course_id from ybd_course_chapter where id = " + exam.parent_id + ")"); //if (course != null) //{ // logopath = course.qrcode_logo; //} } else { return; } break; case "talk": //讨论 Model.common_article article = new BLL.common_article().GetModel(Convert.ToInt32(id)); if (article != null) { str = WebPath + "/html/discuss_details.html?id=" + id; is_logo = true; //course = new BLL.course_info().GetModel(" id = (select course_id from ybd_course_chapter where user_id = 0 and id = " + article.category_id + ")"); //if (course != null) //{ // logopath = course.qrcode_logo; //} } else { return; } break; case "quest": //心理测试 str = WebPath + "/html/questionnaire.html?id=" + id; break; case "classroom": //课堂 str = WebPath + "/html/join_class.html?id=" + id; break; } QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; qrCodeEncoder.QRCodeVersion = 0; qrCodeEncoder.QRCodeScale = 13; //将字符串生成二维码图片 Bitmap image = qrCodeEncoder.Encode(str, Encoding.Default); //保存为PNG到内存流 MemoryStream ms = new MemoryStream(); image.Save(ms, ImageFormat.Png); if (is_logo) { if (string.IsNullOrEmpty(logopath)) { Model.common_albums defaultlogo = new BLL.common_albums().GetModel(" group_id = " + (int)Appoa.Common.EnumCollection.img_group.系统默认二维码logo); if (defaultlogo != null) { logopath = defaultlogo.original_path; } else { logopath = "/html/images/Logo.png"; } } //logopath = "/html/images/Logo.png"; MemoryStream ms1 = new MemoryStream(); CombinImage(image, Server.MapPath("~" + logopath), 80).Save(ms1, System.Drawing.Imaging.ImageFormat.Png); //输出二维码图片 Response.ClearContent(); Response.ContentType = "image/Png"; Response.BinaryWrite(ms1.ToArray()); ms.Dispose(); ms1.Dispose(); Response.Flush(); Response.End(); } else { //输出二维码图片 Response.ClearContent(); Response.ContentType = "image/Png"; Response.BinaryWrite(ms.ToArray()); ms.Dispose(); Response.Flush(); Response.End(); } }