123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using EMIS.CommonLogic.ScoreManage;
- using Bowin.Web.Controls.Mvc;
- using EMIS.ViewModel.ScoreManage;
- using EMIS.ViewModel.Students;
- using Bowin.Common.Exceptions;
- using Bowin.Common.Utility;
- using EMIS.CommonLogic.CalendarManage;
- using Bowin.Common.Data;
- using EMIS.CommonLogic.Students;
- using EMIS.Utility;
- namespace EMIS.Web.Controllers.ScoreManage
- {
- [Authorization]
- public class ResitExaminationController : Controller
- {
- public Lazy<IFinalExaminationServices> finalExaminationServices { get; set; }
- public Lazy<IStudentsServices> StudentfileServices { get; set; }
- public Lazy<ISchoolYearServices> SchoolYearServices { get; set; }
- /// <summary>
- /// 补考设定页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- var schoolYear = SchoolYearServices.Value.GetSchoolYearIsCurrent(true);
- ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年
- return View();
- }
- /// <summary>
- /// 补考设定列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var collegeID = pararms.getExtraGuid("CollegeComboGrid");
- var departmentID = pararms.getExtraGuid("DepartmentComboGrid");
- var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid");
- var courseTypeID = pararms.getExtraInt("DictionaryCourseType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryCourseType");
- var examsCategoryID = pararms.getExtraInt("DictionaryExamsCategory") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryExamsCategory");
- var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
- var approvalStatus = pararms.getExtraInt("DictionaryScoreState") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryScoreState");
- var gradeYearID = pararms.getExtraInt("DictionaryGrade") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGrade");
- return Json(finalExaminationServices.Value.GetFinalExaminationViewGrid(configuretView, collegeID, departmentID, schoolyearID, coursematerialID, courseTypeID, examsCategoryID,
- (int)EMIS.ViewModel.CF_ExaminationType.ResitExamination, approvalStatus, gradeYearID, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="finalExaminationID"></param>
- /// <returns></returns>
- public ActionResult Edit(Guid? finalExamination, string aType)
- {
- FinalExaminationView finalExaminationView = new FinalExaminationView();
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var schoolYear = SchoolYearServices.Value.GetSchoolYearIsCurrent(true);
- if (finalExamination.HasValue)
- {
- finalExaminationView = finalExaminationServices.Value.GetFinalExaminationView(finalExamination);
- }
- else
- {
- finalExaminationView.CollegeID = curUser.CollegeID;
- finalExaminationView.SchoolyearID = schoolYear.SchoolyearID;
- finalExaminationView.GradeYearID = schoolYear.Years;
- finalExaminationView.ExamsCategoryID = (int)CF_ExamsCategory.Resit;
- finalExaminationView.ExaminationModeID = (int)CF_ExaminationMode.WrittenExam;
- finalExaminationView.ResultTypeID = (int)CF_ResultType.Percentage;
- finalExaminationView.TotalHours = 0;
- }
- if (aType == "add")
- {
- finalExaminationView.FinalExaminationID = null;
- }
- return View(finalExaminationView);
- }
- /// <summary>
- /// 新增/编辑
- /// </summary>
- /// <param name="finalExaminationView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(FinalExaminationView finalExaminationView)
- {
- try
- {
- finalExaminationView.ExaminationType = (int)EMIS.ViewModel.CF_ExaminationType.ResitExamination;
- var studentList = DataGrid.GetTableData<BaseStudentView>("dgStudentList");
- var ClassmajorID = finalExaminationView.ClassID;
- List<Guid?> ClassmajorIDList = new List<Guid?>();
- if (ClassmajorID != null)
- {
- ClassmajorIDList = ClassmajorID.SplitIDString();
- }
- finalExaminationServices.Value.FinalExaminationAdd(finalExaminationView, ClassmajorIDList);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 增加学生
- /// </summary>
- /// <param name="finalExaminationID"></param>
- /// <returns></returns>
- public ActionResult StudentEdit(Guid? finalExamination)
- {
- FinalExaminationView finalExaminationView = new FinalExaminationView();
- var schoolYear = SchoolYearServices.Value.GetSchoolYearIsCurrent(true);
- if (finalExamination.HasValue)
- {
- finalExaminationView = finalExaminationServices.Value.GetFinalExaminationView(finalExamination);
- }
- else
- {
- finalExaminationView.SchoolyearID = schoolYear.SchoolyearID;
- finalExaminationView.GradeYearID = schoolYear.Years;
- finalExaminationView.ExamsCategoryID = (int)CF_ExamsCategory.FinalExam;
- finalExaminationView.ExaminationModeID = (int)CF_ExaminationMode.WrittenExam;
- }
- return View(finalExaminationView);
- }
- /// <summary>
- /// 增加学生
- /// </summary>
- /// <param name="finalExaminationView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult StudentEdit(FinalExaminationView finalExaminationView)
- {
- try
- {
- finalExaminationView.ExaminationType = (int)EMIS.ViewModel.CF_ExaminationType.FinalExamination;
- var studentList = DataGrid.GetTableData<BaseStudentView>("dgStudentList");
- finalExaminationServices.Value.FinalExaminationStudentAdd(finalExaminationView.FinalExaminationID, studentList);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 添加学生
- /// </summary>
- /// <param name="finalExaminationID"></param>
- /// <returns></returns>
- public ActionResult StudentAdd(Guid? finalExamination, Guid? UserID)
- {
- FinalExaminationView finalExaminationView = new FinalExaminationView();
- finalExaminationView = finalExaminationServices.Value.GetFinalExaminationView(finalExamination);
- finalExaminationView.isAutoAdd = true;
- if (UserID != Guid.Empty && UserID != null)
- {
- var student = StudentfileServices.Value.GetStudentfileView((Guid)UserID);
- var StarttermID = finalExaminationServices.Value.GetFinalExaminationStudentForStudentAdd(finalExamination, UserID);
- var f = finalExaminationServices.Value.GetStarttermID(finalExamination, UserID);
- finalExaminationView.UserID = UserID;
- finalExaminationView.UserName = student.UserName;
- finalExaminationView.StarttermID = StarttermID.StarttermID;
- //如果是修改变成false
- finalExaminationView.isAutoAdd = false;
- }
- return View(finalExaminationView);
- }
- /// <summary>
- /// 添加学生
- /// </summary>
- /// <param name="finalExaminationID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult StudentAdd(FinalExaminationView finalExaminationView)
- {
- try
- {
- finalExaminationServices.Value.StudentAdd(finalExaminationView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="finalExaminationIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string finalExaminationIDs)
- {
- try
- {
- List<Guid?> list = new List<Guid?>();
- for (int i = 0; i < finalExaminationIDs.Split(',').Length; i++)
- {
- if (!string.IsNullOrEmpty(finalExaminationIDs.Split(',')[i]))
- {
- Guid FinalExaminationID = new Guid(finalExaminationIDs.Split(',')[i]);
- list.Add(FinalExaminationID);
- }
- }
- finalExaminationServices.Value.FinalExaminationDelete(list);
- return this.Json("删除成功!");
- }
- catch (Exception ex)
- {
- string mge = ex.Message;
- System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
- if (num != null)
- {
- if (num.Number == 547)
- mge = "请先删除所有关联的数据!";
- }
- return this.Json("删除失败,原因:" + mge);
- }
- }
- /// <summary>
- /// 删除学生
- /// </summary>
- /// <param name="finalExaminationIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult StudentDelete(Guid finalExaminationID, string UserIDs)
- {
- try
- {
- List<Guid?> list = new List<Guid?>();
- for (int i = 0; i < UserIDs.Split(',').Length; i++)
- {
- if (!string.IsNullOrEmpty(UserIDs.Split(',')[i]))
- {
- Guid FinalExaminationID = new Guid(UserIDs.Split(',')[i]);
- list.Add(FinalExaminationID);
- }
- }
- finalExaminationServices.Value.FinalExaminationStudentDelete(finalExaminationID, list);
- return this.Json("删除成功!");
- }
- catch (Exception ex)
- {
- string mge = ex.Message;
- System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
- if (num != null)
- {
- if (num.Number == 547)
- mge = "请先删除所有关联的数据!";
- }
- return this.Json("删除失败,原因:" + mge);
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="schoolYearID"></param>
- /// <returns></returns>
- public ActionResult GenerateFinalExaminationEdit(Guid? schoolYearID)
- {
- var schoolYear = SchoolYearServices.Value.GetSchoolYearViewBeforeCurrent();
- ViewBag.SchoolYearID = schoolYear == null ? DropdownList.PLEASE_SELECT.ToString() : schoolYear.SchoolYearID.ToString();
- return View();
- }
- /// <summary>
- /// 期末补考生成,按兵良要求,加上院系所、年级、专业下拉条件 增加班级条件
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GenerateFinalExaminationEdit()
- {
- try
- {
- var schoolYearID = Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
- var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
- var gradeID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
- var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
- var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo<Guid>();
- finalExaminationServices.Value.GenerateResitExamination(schoolYearID, collegeID, gradeID, standardID, classmajorID);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "生成成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "生成失败:" + ex.Message
- });
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="schoolYearID"></param>
- /// <returns></returns>
- public ActionResult GenerateResitExaminationEdit(Guid? schoolYearID)
- {
- var schoolYear = SchoolYearServices.Value.GetSchoolYearIsCurrent(true);
- ViewBag.SchoolYearID = schoolYear == null ? DropdownList.PLEASE_SELECT.ToString() : schoolYear.SchoolyearID.ToString();
- return View();
- }
- /// <summary>
- /// 毕业补考生成
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GenerateResitExaminationEdit()
- {
- try
- {
- //var year = Request.Form["ddlYear"].ParseStrTo<int>();
- var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
- var year = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
- var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
- var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo<Guid>();
- var learnSystem = Request.Form["DictionaryLearnSystem"].ParseStrTo<decimal>();
- finalExaminationServices.Value.GenerateGraduationExam(year, collegeID, standardID, classmajorID, learnSystem);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "生成成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "生成失败:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 学生成绩录入名单
- /// </summary>
- /// <returns></returns>
- public ActionResult StudentList(Guid? finalExaminationID)
- {
- ViewBag.FinalExaminationID = finalExaminationID;
- return View();
- }
- /// <summary>
- /// 补考设定学生成绩录入名单
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult ResitExaminationStudentList()
- {
- var finalExaminationID = Request["finalExaminationID"].ParseStrTo<Guid>();
- return Json(finalExaminationServices.Value.GetFinalExaminationStudent(finalExaminationID));
- }
- ///// <summary>
- ///// 添加学生
- ///// </summary>
- ///// <param name="finalExaminationID"></param>
- ///// <param name="userIDs"></param>
- ///// <returns></returns>
- //[HttpPost]
- //public ActionResult ResitExaminationStudentAdd(Guid? finalExaminationID, string userIDs)
- //{
- // try
- // {
- // List<Guid> list = new List<Guid>();
- // for (int i = 0; i < userIDs.Split(',').Length; i++)
- // {
- // if (!string.IsNullOrEmpty(userIDs.Split(',')[i]))
- // {
- // Guid userID = new Guid(userIDs.Split(',')[i]);
- // list.Add(userID);
- // }
- // }
- // finalExaminationServices.Value.FinalExaminationStudentAdd(finalExaminationID, list);
- // return Json("成功");
- // }
- // catch (Exception ex)
- // {
- // return Json("增加学生失败,原因:" + ex.Message);
- // }
- //}
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var FinalExaminationID = Request.Form["FinalExaminationID"];
- var collegeID = Request.Form["CollegeComboGrid"].ParseStrTo<Guid>();
- var departmentID = Request.Form["DepartmentComboGrid"].ParseStrTo<Guid>();
- var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo<Guid>();
- var courseTypeID = Request.Form["DictionaryCourseType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseType"].ParseStrTo<int>();
- var examsCategoryID = Request.Form["DictionaryExamsCategory"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryExamsCategory"].ParseStrTo<int>();
- var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
- var approvalStatus = Request.Form["DictionaryScoreState"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryScoreState"].ParseStrTo<int>();
- var gradeYearID = Request.Form["DictionaryGrade"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo<int>();
- List<Guid?> FinalExaminationIDList = new List<Guid?>();
- if (FinalExaminationID != "")
- {
- FinalExaminationIDList = FinalExaminationID.SplitIDString();
- }
- else
- {
- FinalExaminationIDList = null;
- }
- var dt = finalExaminationServices.Value.GetFinalExaminationViewList_Excel(configuretView, collegeID, departmentID, schoolyearID, coursematerialID, courseTypeID, examsCategoryID,
- (int)EMIS.ViewModel.CF_ExaminationType.ResitExamination, approvalStatus, gradeYearID, FinalExaminationIDList).Select(x => new
- {
- x.SchoolyearCode,
- x.GradeYearID,
- x.ClassName,
- x.CourseCode,
- x.CourseName,
- x.CourseTypeName,
- x.Credit,
- x.ExamsCategoryName,
- x.CreatorUserNo,
- x.CreatorUserName,
- x.EntryDeadlineTime,
- x.StudentCount,
- x.SAPunlogStudentCount,
- x.ApprovalStatusName
- }).ToTable();
- string[] liststring = { "学年学期", "年级", "录入班级名称", "课程代码", "课程名称","课程类型","学分", "考试性质","录入人编号", "录入人姓名",
- "录入截止日期","学生数","未录入人数","状态" };
- neh.Export(dt, liststring, "补考设定信息");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Action("List").AddMenuParameter()
- });
- }
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult StudentDetails_Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var FinalExaminationID = Request.Form["FinalExaminationID"];
- var collegeID = Request.Form["CollegeComboGrid"].ParseStrTo<Guid>();
- var departmentID = Request.Form["DepartmentComboGrid"].ParseStrTo<Guid>();
- var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo<Guid>();
- var courseTypeID = Request.Form["DictionaryCourseType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseType"].ParseStrTo<int>();
- var examsCategoryID = Request.Form["DictionaryExamsCategory"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryExamsCategory"].ParseStrTo<int>();
- var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
- var approvalStatus = Request.Form["DictionaryScoreState"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryScoreState"].ParseStrTo<int>();
- var gradeYearID = Request.Form["DictionaryGrade"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo<int>();
- List<Guid?> FinalExaminationIDList = new List<Guid?>();
- if (FinalExaminationID != "")
- {
- FinalExaminationIDList = FinalExaminationID.SplitIDString();
- }
- else
- {
- FinalExaminationIDList = null;
- }
- var dt = finalExaminationServices.Value.GetFinalExaminationStudentDetailsList(configuretView, collegeID, departmentID, schoolyearID, coursematerialID, courseTypeID, examsCategoryID,
- (int)EMIS.ViewModel.CF_ExaminationType.ResitExamination, approvalStatus, gradeYearID, FinalExaminationIDList).Select(x => new
- {
- x.SchoolyearCode,
- x.ClassName,
- x.CourseCode,
- x.CourseName,
- x.CourseTypeName,
- x.Credit,
- x.ExamsCategoryName,
- x.LoginID,
- x.UserName,
- x.CollegeName,
- x.Year,
- x.StandardName,
- x.ClassmajorName,
- }).ToTable();
- string[] liststring = { "学年学期","录入班级", "课程代码", "课程名称", "课程类型","学分","考试性质", "学号","姓名",RSL.Get("College"),
- "年级","专业名称","班级名称" };
- neh.Export(dt, liststring, "成绩录入学生名单" + DateTime.Now.ToString("yyyyMMdd"));
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Action("List").AddMenuParameter()
- });
- }
- /// <summary>
- /// 查找默认开课学期
- /// </summary>
- /// <param name="finalExaminationIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetStarttermID(Guid? finalExaminationID, Guid? UserID)
- {
- var value = finalExaminationServices.Value.GetStarttermID(finalExaminationID, UserID);
- return Json(value);
- }
- /// <summary>
- /// 查找默认开课学期
- /// </summary>
- /// <param name="finalExaminationIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Verification(Guid? finalExaminationID, Guid? UserID)
- {
- var Student = finalExaminationServices.Value.GetFinalExaminationStudentForStudentAdd(finalExaminationID, UserID);
- if (Student == null)
- {
- return base.Json("不存在");
- }
- else
- {
- return base.Json("存在");
- }
- }
- }
- }
|