protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (CommonUtility.SafeCheckByParams<string>(Request["experimentResourceId"], ref experimentResourceId)) { if (Request["courseNo"] == null) { Javascript.GoHistory(-1, Page); return; } DalOperationAboutExperimentResources DalOperationAboutExperimentResources = new DalOperationAboutExperimentResources(); experimentResources = DalOperationAboutExperimentResources.GetExperimentResourcesbyId(experimentResourceId); txtTitle.Text = experimentResources.experimentResourceTitle; Textarea1.Value = experimentResources.experimentResourceContent; datepicker.Value = experimentResources.deadLine.ToString("yyyy-MM-dd HH:mm:ss"); hidAttachmentId.Value = experimentResources.attachmentIds; if (experimentResources.attachmentIds.Length > 0) { DalOperationAttachments dalOperationAttachments = new DalOperationAttachments(); ltlAttachment.Text = dalOperationAttachments.GetAttachmentsList(experimentResources.attachmentIds, ref iframeCount, true,string.Empty); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Master.ShowLiControl(this.Page, "liFragment6"); //删除实验 int erid = 0; if (Request["op"] == "delete") { if (CommonUtility.SafeCheckByParams<string>(Request["experimentResourceId"], ref erid)) { DalOperationAboutExperimentResources daloAexper = new DalOperationAboutExperimentResources(); daloAexper.DelExperimentResources(erid); } } UserCookiesInfo UserCookiesInfo = BllOperationAboutUser.GetUserCookiesInfo(); DalOperationAboutCourses DalOperationAboutCourses = new DalOperationAboutCourses(); DataSet coursesInfo = null; coursesInfo = DalOperationAboutCourses.GetCoursesInfo(Master.courseNo.ToString().Trim(),Master.classID,Master.termtag, "6"); dlstExperimentResource.DataSource = coursesInfo.Tables[0]; dlstExperimentResource.DataBind(); } }
protected void btnEditExperimentResource_Click(object sender, EventArgs e) { if (txtTitle.Text.Trim().Length != 0) { UserCookiesInfo UserCookiesInfo = BllOperationAboutUser.GetUserCookiesInfo(); DateTime deadline_t = Convert.ToDateTime(datepicker.Value); ExperimentResources ExperimentResources = new ExperimentResources { courseNo = Request["courseNo"], experimentResourceTitle = CommonUtility.JavascriptStringFilter(txtTitle.Text), experimentResourceContent = Textarea1.Value, deadLine = deadline_t, updateTime = DateTime.Now, attachmentIds = hidAttachmentId.Value, experimentResourceId = (Request["experimentResourceId"] != null ? int.Parse(Request["experimentResourceId"]) : 0) }; DalOperationAboutExperimentResources DalOperationAboutExperimentResources = new DalOperationAboutExperimentResources(); DalOperationAboutExperimentResources.UpdateExperimentResources(ExperimentResources); Javascript.RefreshParentWindow("修改成功!", "CInfoExperimentResource.aspx?courseNo=" + ExperimentResources.courseNo, 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(); //设置实验资源ID int experimentResourceId = -1; if (CommonUtility.SafeCheckByParams<string>(Request["experimentResourceId"], ref experimentResourceId)) { DalOperationAboutExperimentResources DalOperationAboutExperimentResources = new DalOperationAboutExperimentResources(); DataSet dsExperimentResource = DalOperationAboutExperimentResources.GetExperimentResourcesById(experimentResourceId); dlstExperiment.DataSource = dsExperimentResource.Tables[0]; dlstExperiment.DataBind(); DateTime deadLine = Convert.ToDateTime(dsExperimentResource.Tables[0].Rows[0]["deadLine"].ToString()); DalOperationAboutExperiment DalOperationAboutExperiment = new DalOperationAboutExperiment(); int experimentId = 0; bool checkOR = false; if (checkOR) { experimentspan.InnerHtml += "已经批阅!"; btnExperiment.Visible = false; return; } else if (deadLine.CompareTo(DateTime.Now) <= 0) { experimentspan.InnerHtml += "已过截止日期!"; btnExperiment.Visible = false; return; } if (DalOperationAboutExperiment.ExperimentIsCommit(UserCookiesInfo.userNo, experimentResourceId, ref experimentId, ref checkOR)) { string attachmentids = DalOperationAboutExperiment.GetExperimentById(experimentId).attachmentId.ToString(); hidAttachmentId.Value = attachmentids; hidOriginalAttachmentId.Value = attachmentids; experimentspan.InnerHtml = "已提交实验文件列表<br/><br />" + GetSchoolAttachmentsURL(attachmentids); } experimentspan.InnerHtml += "<input id=\"Button3\" type=\"button\" value=\"点击添加一个附件,可添加多个\" onclick=\"addIframe(" + (int)FileFolderType.experiments + ");\" /> <b>上传文件大小不超过</b>" + ConfigurationManager.AppSettings["uploadFileLimit"] + "<div id=\"iframes\"></div>"; } } }
protected void Page_Load(object sender, EventArgs e) { if (Request["courseNo"] == null) { Javascript.GoHistory(-1, Page); return; } if (CommonUtility.SafeCheckByParams<string>(Request["experimentResourceId"], ref experimentResourceId)) { UserCookiesInfo UserCookiesInfo = BllOperationAboutUser.GetUserCookiesInfo(); DalOperationAboutExperimentResources DalOperationAboutExperimentResources = new DalOperationAboutExperimentResources(); ExperimentResources experimentResources = DalOperationAboutExperimentResources.GetExperimentResourcesbyId(experimentResourceId); } else { Javascript.GoHistory(-1, Page); } }
protected void Page_Load(object sender, EventArgs e) { Master.ShowLiControl(this.Page, "liFragment1"); if (CommonUtility.SafeCheckByParams<string>(Request["experimentResourceId"], ref Master.experimentResourceId)) { //提取实验信息(experimentResourceId) DalOperationAboutExperimentResources DalOperationAboutExperimentResources = new DalOperationAboutExperimentResources(); DataSet dsExperimentResources = DalOperationAboutExperimentResources.GetExperimentResourcesById(Master.experimentResourceId); dlstExperimentResource.DataSource = dsExperimentResources.Tables[0]; dlstExperimentResource.DataBind(); } else { Javascript.GoHistory(-1, Page); return; } }
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(); }
protected void btnAddExperimentResource_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) { ExperimentResources ExperimentResources = new ExperimentResources { courseNo = Request["courseNo"].Trim(), classID = Server.UrlDecode(Request["classID"].Trim()), termTag = Request["termtag"].Trim(), experimentResourceTitle = CommonUtility.JavascriptStringFilter(txtTitle.Text), experimentResourceContent = Textarea1.Value, deadLine = deadline_t, updateTime = DateTime.Now, attachmentIds = hidAttachmentId.Value }; //添加课程实验并返回作业的自增长主键 using (TransactionScope scope = new TransactionScope()) { DalOperationAboutExperimentResources DalOperationAboutExperimentResources = new DalOperationAboutExperimentResources(); ExperimentResources = DalOperationAboutExperimentResources.InsertExperimentResources(ExperimentResources); //添加了课程实验以后,往提交表中添加记录 //查询出选课学生记录 DalOperationAboutExperiment doae = new DalOperationAboutExperiment(); DalOperationAboutCourses dalOperationAboutCourses = new DalOperationAboutCourses(); 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++) { Experiments experiment = new Experiments { experimentResourceId = ExperimentResources.experimentResourceId, studentNo = dt.Rows[i]["studentNo"].ToString().Trim(), updateTime = DateTime.Now, checkTime = DateTime.Now, isExcellent = false, remark = "", excellentTime = DateTime.Now, attachmentId = "0" }; doae.InsertExperiment(experiment); } scope.Complete(); } Javascript.RefreshParentWindow("添加成功!", "CInfoExperimentResource.aspx?courseNo=" + Request["courseNo"]+"&classID="+Server.UrlEncode(Server.UrlDecode(Request["classID"]))+"&termtag="+Request["termtag"], Page); } else { Javascript.Alert("截止时间不能在当前时间之前", Page); } } else { Javascript.Alert("标题不能为空!", Page); } }