protected void Page_Load(object sender, EventArgs e) { string name = ""; 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("Del")) { int kgtid = int.Parse(Request["kgtid"].ToString()); deleteGetTestPaperInfo(kgtid); } else if (action != null && action.ToString().Equals("vlaues")) { name = Request["sjName"].ToString(); } spannowtime.InnerText = "服务器时间:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); string user = usercookie.Value; yhid = TbUserManager.GetStudentID(user); testPaperScoreList = TbScoreManager.GetTestPaperScoreByYhid(yhid, name); sjName.Value = name; Hello = TbStudentManager.GetStudentByID(yhid).XsName; } }
/// <summary> /// 导出成绩 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnExprotScore_Click(object sender, EventArgs e) { string path = Server.MapPath("file") + "\\studentScoreList.xls"; if (File.Exists(path)) { File.Delete(path); } DataTable dataSource = new DataTable(); dataSource.Columns.Add("姓名", Type.GetType("System.String")); dataSource.Columns.Add("试卷", Type.GetType("System.String")); dataSource.Columns.Add("专业", Type.GetType("System.String")); dataSource.Columns.Add("科目", Type.GetType("System.String")); dataSource.Columns.Add("班级", Type.GetType("System.String")); dataSource.Columns.Add("成绩", Type.GetType("System.String")); DataTable nowDt; //当前成绩列表 if (maxPage > 0) { nowDt = TbScoreManager.GetScoreList(); } else { nowDt = scoreList; } foreach (DataRow row in nowDt.Rows) { DataRow dr = dataSource.NewRow(); dr["姓名"] = row["XsName"]; dr["试卷"] = row["SjName"]; dr["专业"] = row["ZyName"]; dr["科目"] = row["KmName"]; dr["班级"] = row["BjName"]; int score = 0; if (int.Parse(row["DxtScore"].ToString()) >= 0) { score += int.Parse(row["DxtScore"].ToString()); } if (int.Parse(row["DuoxtScore"].ToString()) >= 0) { score += int.Parse(row["DuoxtScore"].ToString()); } if (int.Parse(row["PdtScore"].ToString()) >= 0) { score += int.Parse(row["PdtScore"].ToString()); } if (int.Parse(row["ZgtScore"].ToString()) >= 0) { score += int.Parse(row["ZgtScore"].ToString()); } dr["成绩"] = score + "分"; dataSource.Rows.Add(dr); } PublicClass.SaveToFile(PublicClass.GetTable(dataSource, "学员成绩信息"), Server.MapPath("file") + "\\studentScoreList.xls"); Response.Redirect("file/studentScoreList.xls"); }
protected void ButTiJiao_Click(object sender, EventArgs e) { TbScore Ts = new TbScore(); Ts.KgtID = Tbt.KgtID; Ts.ZgtScore = ZDfen; Ts.Zt = 3; int i = TbScoreManager.UpdScroe(Ts, Ts.KgtID); i = tbAnswerCardManager.UpdateObjZt(Ts); Response.Redirect("EditAnswer.aspx"); }
protected void ddlSpec_SelectedIndexChanged(object sender, EventArgs e) { string specname = ddlSpec.SelectedItem.Text; if (specname.Equals("全部")) { GetScoreList(); } else { scoreList = TbScoreManager.GetScoreList(specname, 2); LoadData(specname, 2); count = scoreList.Rows.Count; maxPage = 0; } }
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; } }
protected void btnSubject_Click(object sender, EventArgs e) { string subjectname = hidSubject.Value; if (subjectname.Equals("全部")) { scoreList = scoreList = TbScoreManager.GetScoreList(ddlSpec.SelectedItem.Text, 2); LoadData(ddlSpec.SelectedItem.Text, 2); } else { scoreList = TbScoreManager.GetScoreList(subjectname, 3); LoadData(subjectname, 3); } count = scoreList.Rows.Count; maxPage = 0; }
private void GetScoreList() { scoreList = TbScoreManager.GetScoreList(len, page); count = TbScoreManager.GetScoreList().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 btnsx_Click(object sender, EventArgs e) { string specname = txtNameTest.Value.Trim(); if (specname == "按姓名、试卷名模糊查找" || specname == "") { if (ddlSpec.SelectedItem.Text.Equals("全部")) { GetScoreList(); LoadData("", 1); } } else { scoreList = TbScoreManager.GetScoreList(specname, 1); count = scoreList.Rows.Count; maxPage = 0; LoadData(specname, 1); } }
/// <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); //生成答题卡 } }
/// <summary> /// 根据客观题ID删除考卷信息 /// </summary> /// <param name="KgtID">客观题ID</param> public void deleteGetTestPaperInfo(int KgtID) { TbScoreManager.deleteScoreInfo(KgtID); TbResultManager.deleteResultInfo(KgtID); TbObjectiveTopicManager.deleteReviewTestPaperInfo(KgtID); }
/// <summary> /// 绑定图表 /// </summary> /// <param name="whereStr">当前筛选条件</param> /// <param name="type">1表示试卷名或姓名,2表示专业名,3表示科目名</param> public void LoadData(string whereStr, int type) { if (scoreList.Rows.Count > 0) { Chartlet1.AppearanceStyle = (FanG.Chartlet.AppearanceStyles)System.Enum.Parse(typeof(FanG.Chartlet.AppearanceStyles), "Bar_3D_Aurora_NoCrystal_NoGlow_NoBorder", true); DataTable classListTable = TbScoreManager.GetClassList(whereStr, type); ArrayList classList = new ArrayList(); foreach (DataRow classRow in classListTable.Rows) { classList.Add(classRow["BjName"]); } DataTable testpaperListTable = TbScoreManager.GetTestPaperList(whereStr, type); ArrayList testpaperList = new ArrayList(); foreach (DataRow testRow in testpaperListTable.Rows) { testpaperList.Add(testRow["SjName"]); } ArrayList[] DataArray = new ArrayList[testpaperList.Count]; for (int i = 0; i < DataArray.Length; i++) { DataArray[i] = new ArrayList(); int sjid = int.Parse(testpaperListTable.Rows[i]["SjiD"].ToString()); float sjZongScore = TbQuestionTypesManager.GetSumScoreBySjid(sjid); for (int j = 0; j < classList.Count; j++) { string nowClassName = classList[j].ToString(); float sumScore = 0; DataTable dtScorelist = TbScoreManager.GetScoreListBySjidAndClassname(sjid, nowClassName); if (dtScorelist.Rows.Count > 0) { foreach (DataRow row in dtScorelist.Rows) { float score = 0; if (float.Parse(row["DxtScore"].ToString()) > 0) { score += float.Parse(row["DxtScore"].ToString()); } if (float.Parse(row["DuoxtScore"].ToString()) > 0) { score += float.Parse(row["DuoxtScore"].ToString()); } if (float.Parse(row["PdtScore"].ToString()) > 0) { score += float.Parse(row["PdtScore"].ToString()); } if (float.Parse(row["ZgtScore"].ToString()) > 0) { score += float.Parse(row["ZgtScore"].ToString()); } sumScore += score; } float avgScore = sumScore / dtScorelist.Rows.Count; DataArray[i].Add(avgScore / sjZongScore * 100); } } } string title = ""; switch (type) { case 1: if (whereStr == "") { title = "全部"; } else { title = "筛选:" + whereStr; } break; case 2: title = "专业:" + whereStr; break; case 3: title = "科目:" + whereStr; break; } Chartlet1.ChartTitle.Text = title; Chartlet1.XLabels.UnitText = "班级/平均分"; Chartlet1.YLabels.UnitText = "总分"; Chartlet1.MaxValueY = 100; Chartlet1.InitializeData(DataArray, classList, testpaperList); } }