static int FirstSxNum = 0;/*声明变量,初始化为0,用于判断筛选条件是否改变*/ /// <summary> /// 加载科目列表信息 /// </summary> public void GetAllTestPaperInfo() { string testpaper = txtTestPaperName.Value.Trim() == "按试卷名、科目名模糊查找" ? "" : txtTestPaperName.Value.Trim(); if (testpaper != "按试卷名、科目名模糊查找" && testpaper != "" && FirstSxNum == 0) { page = 1; FirstSxNum = 1; } testPaperList = TbTestPaperManager.GetAllTestpaperByPage(len, page, testpaper); Count = TbTestPaperManager.GetAllTestpaperCount(testpaper).Rows.Count; if (Count % len == 0)//获得数据库数据整除len值,最大页面数为(Count/len)的商 { if (Count > 0) { Maxpage = Count / len; } else { Maxpage = 1; } } else { Maxpage = Count / len + 1;//获得数据库数据整除len值,最大页面数为(Count/len+1)的商 } }
protected void ButtonOK_Click(object sender, EventArgs e) { //if ((PublicClass.GetMinutes(Convert.ToDateTime(this.startTime.Text), Convert.ToDateTime(this.endTime.Text))) <= 0) //{ // this.Lbltime.Text = "开始时间必须大于结束时间"; // return; //} TbTestPaper testpaper = new TbTestPaper(); testpaper.SjName = this.sjnameid.Text; testpaper.KsTime = Convert.ToDateTime(this.startTime.Text); testpaper.JsTime = Convert.ToDateTime(this.endTime.Text); testpaper.Remark = this.textRemark.Text; DateTime CurrentDate = new DateTime(); CurrentDate = DateTime.Now; int time = DateTime.Compare(testpaper.KsTime, testpaper.JsTime); if (hidSjID.Value != "") { testpaper.SjID = int.Parse(this.hidSjID.Value); TbTestPaperManager.updateTestPaper(testpaper.SjName, testpaper.KsTime, testpaper.JsTime, testpaper.Remark, testpaper.SjID); this.hidSjID.Value = ""; } this.sjnameid.Text = ""; this.startTime.Text = ""; this.endTime.Text = ""; this.textRemark.Text = ""; GetAllTestPaperInfo(); }
/// <summary> /// 根据试卷ID查询对应详细信息 /// </summary> /// <param name="sjid"></param> public void GetEditTestPaper(int sjid) { TbTestPaper testpaper = TbTestPaperManager.GetAllSjInfo(sjid); string message = testpaper.SjID + "|" + testpaper.SjName + "|" + testpaper.KsTime + "|" + testpaper.JsTime + "|" + testpaper.Remark; Response.Write(message); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string action = Request["action"]; if (action != null && action.ToString().Equals("zfen")) { ZDfen = int.Parse(Request["score"].ToString()); } } //Tbt = new TbObjectiveTopic(); //声明答案类 //stu = new string[] { }; //保存主观题答案 //num = 0; //题号 //StrLive = new List<string>(); //保存标题所有内容 if (Request["KgtID"] != null) { Tbt = new TbObjectiveTopic(); //声明答案类 stu = new string[] { }; //保存主观题答案 num = 0; //题号 StrLive = new List <string>(); //保存标题所有内容 Tbt.KgtID = int.Parse(Request["KgtID"].ToString()); HttpCookie cookie = new HttpCookie("kgtid"); cookie.Value = Tbt.KgtID.ToString(); Request.Cookies.Add(cookie); } else { string kgtid = Request.Cookies["kgtid"].Value; Tbt.KgtID = int.Parse(kgtid); } Tbt.Zt = 2; DataTable dt = tbAnswerCardManager.getAnswerCardZgt(Tbt); if (dt.Rows.Count > 0) { stu = dt.Rows[0]["ZgtAnswer"].ToString().Split('︵'); //获得所有主观题答案 DataRow dtKgt = tbAnswerCardManager.getAnswerCard2(Tbt.KgtID).Rows[0]; //获得答题卡 string Sj = dtKgt["SjID"].ToString(); DataTable dtTx = TbQuestionTypesManager.GetAllQuestionTypesBySjid(int.Parse(Sj)); DataRow drTx = dtTx.Rows[dtTx.Rows.Count - 1]; if (drTx["TxName"].ToString() == "简答题") { int Zfen = int.Parse(dtTx.Rows[dtTx.Rows.Count - 1]["Txzf"].ToString()); //本试卷简答题总分 int TCount = int.Parse(dtTx.Rows[dtTx.Rows.Count - 1]["TxCount"].ToString()); //本试卷简答题个数 DataRow dtPaper = TbTestPaperManager.getOnePaperInfo(Sj).Rows[0]; Sj = dtPaper["SjName"].ToString(); StrLive.Add(Sj); //1 试卷名称 Sj = dtPaper["LsName"].ToString(); StrLive.Add(Sj); //2 老师名字 Sj = dtKgt["YhID"].ToString(); Sj = TbUserManager.GetAllUser(int.Parse(Sj)).Xh; //获得用户学号 StrLive.Add(Sj); //3 学生学号 StrLive.Add(Zfen.ToString()); //4简答题总分 } } }
protected void Page_Load(object sender, EventArgs e) { string sjName = ""; HttpCookie usercookie = Request.Cookies["nowloginuser"]; string url = PublicClass.CheckLogin(usercookie, ""); if (url != "") { Response.Redirect(url); } if (!IsPostBack) { string action = Request["action"]; if (action != null && action.ToString().Equals("Elspenvlaues")) { sjName = Request["sjName"].ToString(); } spannowtime.InnerText = "服务器时间:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); string user = usercookie.Value; Tobj.YhID = TbUserManager.GetStudentID(user); TbStudent tStudent = TbStudentManager.GetStudentByID(Tobj.YhID); testPaperList = TbTestPaperManager.GetAllTestpaperByPages(len, page, sjName, 2); Hello = tStudent.XsName; Elspen.Value = sjName; } }
/// <summary> /// 判断试卷是否存在 /// </summary> /// <param name="SjName"></param> public void CheckTestPaperNameIsExist(string SjName) { string sjID = Request["SjID"]; int testpapercount = TbTestPaperManager.GetTestPaperInfo(SjName); if (testpapercount > 0 && testpapercount.ToString() != sjID) { Response.Write("已存在"); } else { Response.Write("不存在"); } }
protected void Page_Load(object sender, EventArgs e) { Ls = new List <string>(); if (!IsPostBack) { if (Request["sjid"] != null) { SjID = Request["sjid"].ToString(); } } DataTable dtPaper = TbTestPaperManager.getOnePaperInfo(SjID); if (dtPaper != null) { drPaper = dtPaper.Rows[0]; DateTime Jstime = DateTime.Parse(drPaper["JsTime"].ToString()); //结束时间 DateTime Kstime = DateTime.Parse(drPaper["KsTime"].ToString()); //开始时间 int Min = PublicClass.GetMinutes(Kstime, Jstime); //间隔时间 Ls.Add(Min.ToString()); //Ls[0] = 剩余时间 分钟数 if (STimeMin == -1) { STimeMin = Min; } int Zfen = TbQuestionTypesManager.GetSumScoreBySjid(int.Parse(SjID)); Ls.Add(Zfen.ToString()); string KstrTime = drPaper["KsTime"].ToString(); KstrTime = KstrTime.Substring(KstrTime.LastIndexOf(' ')); Ls.Add(KstrTime); } HttpCookie ck = Request.Cookies["nowloginuser"]; string user = ck.Value;//获得当前登录用户用户名 int YhID = TbUserManager.GetStudentID(user); string XsName = TbStudentManager.GetStudentByID(YhID).XsName; Ls.Add(XsName); ScoreZt = TbScoreManager.getScore(YhID.ToString(), SjID).Zt; if (ScoreZt == 2) { //ScriptManager.RegisterStartupScript(Page, typeof(string), "3", "error()", true); Response.Write("<script>alert('本次考试已结束,请勿重复提交');</script>"); Response.Write("<script>window.close();</script>"); return; } }
/// <summary> /// 提交单击事件 //教师添加答案专用 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Tijiao_Click(object sender, EventArgs e) { GetPageAnswer(); if (add == "insert") { int i = tbAnswerCardManager.inserAnswer(Top, 0); i = TbTestPaperManager.UpPaperZt(Top.SjID.ToString(), 2); //修改试卷当前状态为 2(修改) add = "update"; } else if (add == "update") { int k = tbAnswerCardManager.UpdateAnswer(Top, 0); } Response.Redirect("../TestPaper/EditTestPaper.aspx"); //返回查看试卷页面 }
protected void Page_Load(object sender, EventArgs e) { HttpCookie usercookie = Request.Cookies["nowloginuser"]; string url = PublicClass.CheckLogin(usercookie, "main"); if (url != "") { Response.Write(url); return; } if (!IsPostBack) { string action = Request["action"]; string sjid = Request["sjid"]; if (action != null && sjid != null) { int id = int.Parse(sjid); if (action.Equals("delete")) { //删除服务器上面对应试卷的所有图片 foreach (DataRow row in TbImagesManager.GetImagesBySjid(id).Rows) { string path = Server.MapPath("images/" + row["Tpian"].ToString()); if (File.Exists(path)) { File.Delete(path); } } TbImagesManager.DeleteImageBySjid(id); TbQuestionTypesManager.DeleteQuestionTypesBySjid(id); TbTestPaperManager.DeleteTestpaperBySjid(id); } } GetAllTestPaperInfo(); } }
public static DataTable subjectList = new DataTable(); //定义一个Table表格,初始化为null. protected void Page_Load(object sender, EventArgs e) { HttpCookie usercookie = Request.Cookies["nowloginuser"]; string url = PublicClass.CheckLogin(usercookie, "main"); if (url != "") { Response.Write(url); return; } string Sub_Sc = Request["Sub_Sc"]; if (!IsPostBack) { ZyName.Items.Clear(); List <TbSpeciality> TbSpeciality = TbSpecialityManager.GetAllSpecialityList(); ZyName.DataSource = TbSpeciality; ZyName.DataTextField = "ZyName"; ZyName.DataValueField = "ZyID"; ZyName.DataBind(); ZyName.Items.Insert(0, new ListItem("请选择..", "0")); if (Sub_Sc != null) { int count = TbTestPaperManager.GetAllTestPaperIsExist(int.Parse(Sub_Sc)); if (count <= 0) { TbSubjectManager.Dele_Sub(int.Parse(Sub_Sc)); } else { Page.RegisterStartupScript("", "<script>alert('请先删除试卷信息!!')</script>"); } } Load_Subject(); //调用方法实现数据加载。 } }
/// <summary> /// 窗体加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { dt = new DataTable(); stu = new string[] { }; HttpCookie ck = Request.Cookies["nowloginuser"]; string user = ck.Value; //获得当前登录用户用户名 int YhID = TbUserManager.GetStudentID(user); string sjid = Request["SJID"]; //获得当前答案对应的试卷ID string Zt = Request["User"]; //获得当前登录用户状态 Top.SjID = int.Parse(sjid); //将试卷ID赋值给答题卡对象 Top.Remark = ""; //备注为空赋值给答题卡对象 Top.YhID = TbUserManager.GetStudentID(user); //将获得的用户ID赋值给答题卡对象 if (Zt == "1") { Top.Zt = int.Parse(Zt); //将状态赋值给题型表标示为答题卡状态 dt = tbAnswerCardManager.getAnswerCard2(Top); // 获得答题卡内老师答案 if (dt.Rows.Count == 0) { add = "insert"; } else { add = "update"; } } else { Top.Zt = 2; TbScore ts = new TbScore(); dt = tbAnswerCardManager.getAnswerCard2(Top, Top.YhID); // 获得答题卡内本学生答案 if (dt.Rows.Count > 0) { ts.KgtID = int.Parse(dt.Rows[0]["KgtID"].ToString()); Top.KgtID = ts.KgtID; } ts = TbScoreManager.getScore(ts); if (ts.Zt == 0) { add = "insert"; } else { add = "update"; stu = tbAnswerCardManager.getAnswerCardZgt(Top).Rows[0]["ZgtAnswer"].ToString().Split('︵'); //获得答题卡内本学生主观题答案 } } DataTable dtPaper = TbTestPaperManager.getOnePaperInfo(sjid); //根据试卷ID获得此试卷的全部基本信息 if (dtPaper.Rows.Count != 0) { drPaper = dtPaper.Rows[0]; } max = new int[4] { 0, 0, 0, 0 }; foreach (DataRow item in tbAnswerCardManager.DtAnswerMg(Top.SjID).Rows) { getMax(item["TxName"].ToString(), int.Parse(item["TxCount"].ToString())); //获得题型类型名,获得对应题型个数 } for (int i = 0; i < 4; i++) { Buju(strText[i], i); //生成答题卡 } }
protected void Button1_Click(object sender, EventArgs e) { string Load = this.txtName.Text; #region 将上传的word文档转换为图片并保存 try { //上传的Word文件的保存路径 string postpath = FileUpload1.PostedFile.FileName; if (!postpath.Contains(':') || !postpath.Contains('\\')) { lblFileMessage.Text = "请设置您当前浏览器:工具-internet选项-安全-自定义级别-将文件上传到服务器是包含本地路径!"; return; } this.FileUpload1.PostedFile.SaveAs(postpath); //保存上传的Word文档 TbTestPaper paper = new TbTestPaper(); paper.SjName = txtName.Text; //试卷名称 paper.LsName = Request.Cookies["nowloginuser"].Value; //当前用户 paper.KmID = int.Parse(ddlSubject.SelectedValue); //科目编号 paper.KsTime = DateTime.Parse(startTime.Value); //开始时间 paper.JsTime = DateTime.Parse(endTime.Value); //结束时间 paper.Remark = txtRemark.Text; //备注 sjid = TbTestPaperManager.AddPaper(paper); //添加后的试卷ID Word_Convert2Image(postpath); //调用转换函数 } catch (Exception ex) { TbTestPaperManager.DeleteTestpaperBySjid(sjid); lblSubMessage.Text = ex.Message; return; } #endregion if (sjid > 0) { string dxcount = txtdxcount.Text; //单选题数 string duocount = txtduocount.Text; //多选题数 string pdcount = txtpdcount.Text; //判断题数 string jdcount = txtjdcount.Text; //简答题数 TbQuestionTypes qtype = new TbQuestionTypes(); qtype.SjID = sjid; if (dxcount != "" && dxcount != "0") //添加单选题 { qtype.TxName = "单选题"; qtype.TxCount = int.Parse(dxcount); qtype.Txzf = int.Parse(txtdxzf.Text); TbQuestionTypesManager.AddQuestionType(qtype); } if (duocount != "" && duocount != "0") //添加多选题 { qtype.TxName = "多选题"; qtype.TxCount = int.Parse(duocount); qtype.Txzf = int.Parse(txtduozf.Text); TbQuestionTypesManager.AddQuestionType(qtype); } if (pdcount != "" && pdcount != "0") //添加判断题 { qtype.TxName = "判断题"; qtype.TxCount = int.Parse(pdcount); qtype.Txzf = int.Parse(txtpdzf.Text); TbQuestionTypesManager.AddQuestionType(qtype); } if (jdcount != "" && jdcount != "0") //添加简答题 { qtype.TxName = "简答题"; qtype.TxCount = int.Parse(jdcount); qtype.Txzf = int.Parse(txtjdzf.Text); TbQuestionTypesManager.AddQuestionType(qtype); } lblSubMessage.Text = "试卷生成成功!"; } }