protected void Page_Load(object sender, EventArgs e) { Master.ShowLiControl(this.Page, "liFragment2"); //提交列表 if (Request["excellent"] != null || Request["studentNo"] != null) { DalOperationAboutSchoolWorks doas = new DalOperationAboutSchoolWorks(); if (Request["excellent"].ToString().Trim().Equals("true")) { doas.UpdateSchoolWorkByschoolWorkNofityIdAndStudentNo(Master.schoolworkNotifyId, Request["studentNo"].ToString().Trim(), 1);//设置为1:优秀实验 } else if (Request["excellent"].ToString().Trim().Equals("false")) { doas.UpdateSchoolWorkByschoolWorkNofityIdAndStudentNo(Master.schoolworkNotifyId, Request["studentNo"].ToString().Trim(), 0);//设置为0:非优秀实验 } } if (!CommonUtility.SafeCheckByParams<string>(Request["schoolworkNotifyId"], ref Master.schoolworkNotifyId)) { Javascript.GoHistory(-1, Page); return; } DataBindSchoolWorks(Master.schoolworkNotifyId); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Master.ShowLiControl(this.Page, "liFragment7"); //删除课程作业 int schoolworkNotifyId = 0; if (CommonUtility.SafeCheckByParams<string>(Request["schoolworkNotifyId"], ref schoolworkNotifyId)) { //DalOperationAboutCourseNotifyInfo dalOperationAboutCourseNotifyInfo = new DalOperationAboutCourseNotifyInfo(); if (Request["op"] == "delete") { DalOperationAboutSchoolWorks dalOperationAboutCourseResources = new DalOperationAboutSchoolWorks(); dalOperationAboutCourseResources.DeleteSchoolworkNotify(schoolworkNotifyId); } } UserCookiesInfo UserCookiesInfo = BllOperationAboutUser.GetUserCookiesInfo(); DalOperationAboutCourses DalOperationAboutCourses = new DalOperationAboutCourses(); DataSet coursesInfo = null; coursesInfo = DalOperationAboutCourses.GetCoursesInfo(Master.courseNo.ToString().Trim(),Master.classID,Master.termtag, "7"); dlstSchoolworkNotify.DataSource = coursesInfo.Tables[0]; dlstSchoolworkNotify.DataBind(); } }
//绑定提交作业列表 public void DataBindSchoolWorks(int schoolworkNotifyId) { DalOperationAboutSchoolWorks dalOperationAboutschoolwork = new DalOperationAboutSchoolWorks(); string studentName = txtNameSearch.Text; DataView dv = null; if ((txtlow.Text != null && txtlow.Text.Length > 0) || (txthigh.Text != null && txthigh.Text.Length > 0)) { float low = (txtlow.Text == null || txtlow.Text.Equals("")) ? float.MinValue : float.Parse(txtlow.Text.Trim()); float high = (txthigh.Text == null || txtlow.Text.Equals("")) ? float.MaxValue : float.Parse(txthigh.Text.Trim()); dv = dalOperationAboutschoolwork.FindSchoolWorksByschoolWorkNofityId(schoolworkNotifyId, studentName, low, high).Tables[0].DefaultView; } else { dv = dalOperationAboutschoolwork.FindSchoolWorksByschoolWorkNofityId(schoolworkNotifyId, studentName).Tables[0].DefaultView; } this.AspNetPager2.RecordCount = dv.Count; PagedDataSource pds = new PagedDataSource(); //定义一个PagedDataSource类来执行分页功 pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = pageIndex - 1; pds.PageSize = CommonUtility.pageSize; this.ddlstSchoolWork.DataSource = pds; this.ddlstSchoolWork.DataBind(); if (pds.Count > 0) { this.ddlstSchoolWork.ShowFooter = false; } }
protected void btnSchoolworkCommit_Click(object sender, EventArgs e) { int SchoolNotifyId = int.Parse(Request["schoolworkNotifyId"]); UserCookiesInfo UserCookiesInfo = BllOperationAboutUser.GetUserCookiesInfo(); SchoolWorks schoolwork = new SchoolWorks { updateTime = DateTime.Now, schoolWorkNofityId = SchoolNotifyId, studentNo = UserCookiesInfo.userNo, isCheck = false, isExcellent = false, remark = "", checkTime = DateTime.Now, excellentTime = DateTime.Now, }; if (hidAttachmentId.Value.CompareTo(string.Empty) != 0) { schoolwork.attachmentId = hidAttachmentId.Value; } else { Javascript.GoHistory(-1, "请上传附件!", Page); return; } DalOperationAboutSchoolWorks dalOperationAboutSchoolworks = new DalOperationAboutSchoolWorks(); dalOperationAboutSchoolworks.SubmitSchoolWork(schoolwork); Javascript.AlertAndRedirect("提交成功!", "CInfoSchoolwork.aspx?schoolworkNotifyId=" + schoolwork.schoolWorkNofityId + "&courseNo=" + Request["courseNo"] + "&classID=" + Server.UrlEncode(Server.UrlDecode(Request["classID"])) + "&termtag=" + Request["termtag"], Page); }
//提交批阅信息--评语和实验分数 protected void btnUpdate_Click(object sender, EventArgs e) { float score = 0; if (CommonUtility.SafeCheckByParams<string>(txtScore.Text.Trim(), ref score)) { if (!CommonUtility.CheckScoreScope(ref score)) { Javascript.Alert("请输入0-100之间的分数", Page); return; } int attachmentId = 0; if (hidAttachmentId.Value.Length != 0) { attachmentId = int.Parse(hidAttachmentId.Value); } DalOperationAboutSchoolWorks doasw = new DalOperationAboutSchoolWorks(); doasw.CheckSchoolWorkByschoolWorkId(int.Parse(Request["schoolWorkId"].Trim()), CommonUtility.JavascriptStringFilter(txtRemark.Text.Trim()), score.ToString(), attachmentId); if (isOnline == "1") { Response.Redirect("VSWorkNOnlineWorkSubed.aspx?page="+pageIndex+"&schoolworkNotifyId=" + Request["schoolworkNotifyId"] + "&courseNo=" + Request["courseNo"]+"&classId="+Server.UrlEncode(Server.UrlDecode(Request["classID"]))+"&termtag="+Request["termtag"]); } else if (isOnline == "0") { Response.Redirect("VSWorkNPaperWork.aspx?page=" + pageIndex + "&schoolworkNotifyId=" + Request["schoolworkNotifyId"] + "&courseNo=" + Request["courseNo"] + "&classId=" + Server.UrlEncode(Server.UrlDecode(Request["classID"])) + "&termtag=" + Request["termtag"]); } } else { Javascript.Alert("请输入数字!", Page); } }
public void DataBindSchoolWork(int schoolWorkId) { DalOperationAboutSchoolWorks doasw = new DalOperationAboutSchoolWorks(); DataTable dt = doasw.FindSchoolWorkSchoolWorkIdForCheck(schoolWorkId).Tables[0]; lblNo.Text = dt.Rows[0]["studentNo"].ToString().Trim(); lblName.Text = dt.Rows[0]["studentName"].ToString().Trim(); txtRemark.Text = dt.Rows[0]["remark"].ToString().Trim(); txtScore.Text = dt.Rows[0]["score"].ToString().Trim(); if (int.TryParse(dt.Rows[0]["returnAttachmentId"].ToString().Trim(), out attachmentIds)) { attachmentIds = int.Parse(dt.Rows[0]["returnAttachmentId"].ToString().Trim()); } }
protected void DataPaperWorkBind(int schoolworkNotifyId) { DalOperationAboutSchoolWorks dalOperationAboutschoolwork = new DalOperationAboutSchoolWorks(); DataView dv = dalOperationAboutschoolwork.FindAllSchoolWorksByschoolWorkNofityId(schoolworkNotifyId).Tables[0].DefaultView; this.AspNetPager3.RecordCount = dv.Count; PagedDataSource pds = new PagedDataSource(); //定义一个PagedDataSource类来执行分页功 pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = pageIndex - 1; pds.PageSize = CommonUtility.pageSize; this.dlstpaperwork.DataSource = pds; this.dlstpaperwork.DataBind(); }
//绑定未提交作业列表 public void DataBindNoSchoolWorks(int schoolworkNotifyId) { DalOperationAboutSchoolWorks dalOperationAboutschoolwork = new DalOperationAboutSchoolWorks(); string studentName = txtNameSearch.Text; DataView dv = dalOperationAboutschoolwork.FindNoSchoolWorksByschoolWorkNofityId(schoolworkNotifyId, studentName).Tables[0].DefaultView; this.AspNetPager1.RecordCount = dv.Count; PagedDataSource pds = new PagedDataSource(); //定义一个PagedDataSource类来执行分页功 pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = pageIndex - 1; pds.PageSize = CommonUtility.pageSize; ; this.dlSchoolWork.DataSource = pds; this.dlSchoolWork.DataBind(); if (pds.Count > 0) { this.dlSchoolWork.ShowFooter = false; } }
private void ShoolworkBind(string user, string courseNoTermTagClassID) { DalOperationAboutSchoolWorks dalw = new DalOperationAboutSchoolWorks(); DataSet dsschoolwork = dalw.GetSchoolWorksByStudentNo(user, courseNoTermTagClassID); dlstMySchoolworks.DataSource = dsschoolwork.Tables[0]; dlstMySchoolworks.DataBind(); }
protected void btnAddSchoolworkNotify_Click(object sender, EventArgs e) { if (txtTitle.Text.Trim().Length != 0) { UserCookiesInfo UserCookiesInfo = BllOperationAboutUser.GetUserCookiesInfo(); DateTime deadline_t = Convert.ToDateTime(datepicker.Value); if (deadline_t.CompareTo(DateTime.Now) > 0) { SchoolWorkNotify SchoolWorkNotify = new SchoolWorkNotify { schoolWorkNotifyTitle=CommonUtility.JavascriptStringFilter(txtTitle.Text), updateTime=DateTime.Now, schoolWorkNotifyContent = Textarea1.Value, deadline=deadline_t, courseNo = Request["courseNo"], isOnline = Convert.ToBoolean(ddltOnline.SelectedValue), attachmentIds = hidAttachmentId.Value, classID=Server.UrlDecode(Request["classID"].Trim()), termTag=Request["termtag"].Trim() }; using (TransactionScope scope = new TransactionScope()) { try { //添加课程作业并返回作业的自增长主键 DalOperationAboutCourses dalOperationAboutCourses = new DalOperationAboutCourses(); SchoolWorkNotify = dalOperationAboutCourses.AddSchoolworkNotify(SchoolWorkNotify); //添加了课程作业以后,往作业提交表中添加记录 DalOperationAboutSchoolWorks dalOperationAboutSchoolworks = new DalOperationAboutSchoolWorks(); //查询出选课学生记录 DataTable dt = dalOperationAboutCourses.FindStudentInfoByCourseNo(Request["courseNo"].ToString().Trim(),Server.UrlDecode(Request["classID"]),Request["termtag"]).Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { SchoolWorks schoolwork = new SchoolWorks { updateTime = DateTime.Now, schoolWorkNofityId = SchoolWorkNotify.schoolWorkNotifyId, studentNo = dt.Rows[i]["studentNo"].ToString().Trim(), isCheck = false, isExcellent = false, remark = "", checkTime = DateTime.Now, excellentTime = DateTime.Now, attachmentId = "0" }; dalOperationAboutSchoolworks.AddSchoolWork(schoolwork); } scope.Complete(); } catch (Exception ex) { MongoDBLog.LogRecord(ex); CommonUtility.RedirectUrl(); } } Javascript.RefreshParentWindow(Page); } else { Javascript.Alert("截止时间不能在当前时间之前", Page); } } else { Javascript.Alert("标题不能为空!", Page); } }
protected void Page_Load(object sender, EventArgs e) { Response.CacheControl = "no-cache"; if (!IsPostBack) { Javascript.ExcuteJavascriptCode("window.onbeforeunload= function(){if($.trim($('#hidOriginalAttachmentId').val())!=$.trim($('#hidAttachmentId').val())){return '温馨提示:作业数据可能未保存哟~(此为提示,并不代表您真正未保存作业数据,请在完成附件上传后点击提交,确保顺利提交作业)';}}", Page); HtmlControl liControl = (HtmlControl)Master.Master.FindControl("ContentPlaceHolder1").FindControl("liFragment9"); liControl.Visible = true; liControl.Attributes.Add("class", "ui-tabs-selected"); UserCookiesInfo UserCookiesInfo = BllOperationAboutUser.GetUserCookiesInfo(); int schoolworkNotifyId = 0; if (CommonUtility.SafeCheckByParams<String>(Request["schoolworkNotifyId"], ref schoolworkNotifyId)) { DalOperationAboutCourses dalOperationAboutCourses = new DalOperationAboutCourses(); DataSet dsSchoolworkNotify = dalOperationAboutCourses.GetSchoolworkNotifybyId(schoolworkNotifyId); dlstSchoolWork.DataSource = dsSchoolworkNotify.Tables[0]; dlstSchoolWork.DataBind(); bool isOnline = bool.Parse(dsSchoolworkNotify.Tables[0].Rows[0]["isOnline"].ToString()); DateTime deadline = Convert.ToDateTime(dsSchoolworkNotify.Tables[0].Rows[0]["deadline"].ToString()); DalOperationAboutSchoolWorks dalOperationAboutSchoolworks = new DalOperationAboutSchoolWorks(); int SchoolworkId = 0; bool checkOR = false; if (isOnline) { if (checkOR) { isSchoolcommitspan.InnerHtml += "已经批阅!"; btnSchoolworkCommit.Visible = false; return; } else if (deadline.CompareTo(DateTime.Now) <= 0) { isSchoolcommitspan.InnerHtml += "已过截止日期!"; btnSchoolworkCommit.Visible = false; return; } if (dalOperationAboutSchoolworks.SchoolworkIsCommit(UserCookiesInfo.userNo, schoolworkNotifyId, ref SchoolworkId, ref checkOR)) { DalOperationAboutSchoolWorks dalOperationAboutSchoolWorks1 = new DalOperationAboutSchoolWorks(); string attachementids = dalOperationAboutSchoolWorks1.GetSchoolWorkById(SchoolworkId).attachmentId.ToString(); hidAttachmentId.Value = attachementids; hidOriginalAttachmentId.Value = attachementids; isSchoolcommitspan.InnerHtml = "已提交作业文件列表<br /><br />" + this.GetSchoolAttachmentsURL(attachementids); } isSchoolcommitspan.InnerHtml += "<input id=\"Button3\" type=\"button\" value=\"点击添加一个附件,可添加多个\" onclick=\"addIframe(" + (int)FileFolderType.schoolWorks + ");\" /> <b>上传文件大小不超过</b>" + ConfigurationManager.AppSettings["uploadFileLimit"] + "<div id=\"iframes\"></div>"; } else { isSchoolcommitspan.InnerHtml += "此为书面作业,不需要在线提交!"; btnSchoolworkCommit.Visible = false; } } } }
public void ProcessRequest(HttpContext context) { CommonFunction.CheckUser(); context.Response.CacheControl = "no-cache"; string courseNo = context.Request["courseNo"]; string classId = context.Request["classID"].Trim(); string termtag = context.Request["termtag"].Trim(); //取得选课信息 DalOperationAboutCourses dalOperationAboutCourses = new DalOperationAboutCourses(); DataTable dt = dalOperationAboutCourses.FindStudentInfoFromStudentListAndCorrelation(courseNo, classId, termtag).Tables[0]; //取得实验提交表信息 DalOperationAboutExperimentResources doaer = new DalOperationAboutExperimentResources(); DataTable dtExp = doaer.FindExperimentResourcesByCourseNo(courseNo, classId, termtag).Tables[0]; //取得对应的CourseNo已布置的全部实验统计信息 DataTable dtExperiment = doaer.GetExperimentsResourcesByCourseNo(courseNo, classId, termtag).Tables[0]; //取得作业提交表信息 DalOperationAboutSchoolWorks doask = new DalOperationAboutSchoolWorks(); DataTable dtSchwork = doask.FindSchoolWorksByCourseNo(courseNo, classId, termtag).Tables[0]; //取得对应的CourseNo已布置的全部作业统计信息 DataTable dtSchNotify = doask.GetSchoolWorksByCourseNo(courseNo, classId, termtag).Tables[0]; StringBuilder sb = new StringBuilder(); HSSFWorkbook workbook = new HSSFWorkbook(); //创建Excel单元格样式 HSSFCellStyle cellStyle = workbook.CreateCellStyle(); cellStyle.Alignment = HSSFCellStyle.ALIGN_RIGHT; //创建WorkSheet HSSFSheet sheet = workbook.CreateSheet("成绩统计表"); int rowCount = dt.Rows.Count; sheet.CreateRow(0).CreateCell(0).SetCellValue("学生编号"); sheet.CreateRow(0).CreateCell(1).SetCellValue("学生姓名"); sheet.CreateRow(0).CreateCell(2).SetCellValue("课程编号"); for (int i = 0; i < dtExperiment.Rows.Count; i++) { sheet.CreateRow(0).CreateCell(i + 3).SetCellValue(dtExperiment.Rows[i]["experimentResourceTitle"].ToString().Trim()); } for (int j = 0; j < dtSchNotify.Rows.Count; j++) { sheet.CreateRow(0).CreateCell(j + 3 + dtExperiment.Rows.Count).SetCellValue(dtSchNotify.Rows[j]["schoolWorkNotifyTitle"].ToString().Trim()); } //填充每列的数据 string studentNo = null; for (int i = 0; i < dt.Rows.Count; i++) { sheet.CreateRow(i + 1).CreateCell(0).SetCellValue(dt.Rows[i]["studentNo"].ToString().Trim()); sheet.CreateRow(i + 1).CreateCell(1).SetCellValue(dt.Rows[i]["studentName"].ToString().Trim()); sheet.CreateRow(i + 1).CreateCell(2).SetCellValue(dt.Rows[i]["courseNo"].ToString().Trim()); studentNo = dt.Rows[i]["studentNo"].ToString().Trim(); //局部变量,指明学生所有的实验数和作业数 int studentExperimentsCount = 0; int studentSchoolWorksCount = 0; //添加实验列数据 for (int j = 0; j < dtExp.Rows.Count; j++) { if (studentNo.Equals(dtExp.Rows[j]["studentNo"].ToString().Trim())) { studentExperimentsCount += 1; sheet.CreateRow(i + 1).CreateCell(2 + studentExperimentsCount).SetCellValue(dtExp.Rows[j]["score"].ToString().Trim()); } } //添加作业列数据 for (int k = 0; k < dtSchwork.Rows.Count; k++) { if (studentNo.Equals(dtSchwork.Rows[k]["studentNo"].ToString().Trim())) { studentSchoolWorksCount += 1; sheet.CreateRow(i + 1).CreateCell(2 + studentSchoolWorksCount + studentExperimentsCount).SetCellValue(dtSchwork.Rows[k]["score"].ToString().Trim()); } } } IEnumerator rows = sheet.GetRowEnumerator(); while (rows.MoveNext()) { HSSFRow row = (HSSFRow)rows.Current; IEnumerator cols = row.GetCellEnumerator(); while (cols.MoveNext()) { HSSFCell cell = (HSSFCell)cols.Current; cell.CellStyle = cellStyle; } } string fileName = "成绩统计" + UploadFiles.DateTimeString(); if (!Directory.Exists(context.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["ScoreExcelPath"]))) { Directory.CreateDirectory(context.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["ScoreExcelPath"])); } System.IO.FileStream file = new System.IO.FileStream(HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["ScoreExcelPath"] + fileName + ".xls"), System.IO.FileMode.Create); workbook.Write(file); file.Dispose(); ////插入值 FileInfo DownloadFile = new FileInfo(context.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["ScoreExcelPath"] + fileName + ".xls")); context.Response.Clear(); context.Response.ClearHeaders(); context.Response.Buffer = false; Encoding code = Encoding.GetEncoding("gb2312"); context.Response.ContentEncoding = Encoding.UTF8; context.Response.HeaderEncoding = code;//这句很重要 context.Response.ContentType = "application/octet-stream"; context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls"); context.Response.AppendHeader("Content-Length", DownloadFile.Length.ToString()); context.Response.WriteFile(DownloadFile.FullName); if (File.Exists(context.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["ScoreExcelPath"] + fileName + ".xls"))) { File.Delete(context.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["ScoreExcelPath"] + fileName + ".xls")); } context.Response.Flush(); }