123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Bowin.Common.JSON;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using Bowin.Web.Controls.Mvc;
- using EMIS.CommonLogic.TeachingMaterial;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- using EMIS.ViewModel.TeachingMaterial;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.Utility;
- namespace EMIS.Web.Controllers.TeachingMaterial
- {
- [Authorization]
- public class StudentsOrderController : Controller
- {
- public IStudentsOrderServices StudentsOrderServices { get; set; }
- public ISchoolYearServices SchoolYearServices { get; set; }
- [HttpGet]
- public ActionResult List()
- {
- //默认当前学年
- var schoolYear = SchoolYearServices.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 teachingMaterialID = pararms.getExtraGuid("TeachingMaterialDropdown");
- var grademajorID = pararms.getExtraGuid("ComboGridGrademajor");
- Guid? campusID = pararms.getExtraGuid("CampusDropdown");
- Guid? collegeID = pararms.getExtraGuid("CollegeDropdown");
- int? years = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
- int? standardID = pararms.getExtraInt("StandardDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDropdown");
- Guid? coursematerialID = pararms.getExtraGuid("CourseDropdown");
- int? courseCategoryID = pararms.getExtraInt("CourseTypeDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("CourseTypeDropdown");
- Guid? schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");//学年学期
- int? isOrdered = pararms.getExtraInt("OrderedDropdown");
- return base.Json(StudentsOrderServices.GetStudentsOrderViewGrid(configuretView, campusID, collegeID, years, grademajorID,
- coursematerialID, courseCategoryID, isOrdered, schoolyearID,teachingMaterialID, (int)pararms.page, (int)pararms.rows));
- }
- [HttpGet]
- public ActionResult EditTeachingMaterialPool()
- {
- ViewData["IsOrdered"] = Request.Params["IsOrdered"].ToString();
- return View();
- }
- [HttpPost]
- public ActionResult EditTeachingMaterialPool(EditTeachingMaterPoolView jsonData)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- var studentsOrderIDs = jsonData.StudentsOrderID.Split(',').Select(x => Guid.Parse(x)).ToList();
- var teachingMaterialPoolIDs = jsonData.TeachingMaterialPoolID.Split(',').Select(x => Guid.Parse(x)).ToList();
- var specialtyPlanIDs = jsonData.SpecialtyPlanID.Split(',').Select(x => Guid.Parse(x)).ToList();
- StudentsOrderServices.SpecifiedTeachingMaterialPool(studentsOrderIDs, teachingMaterialPoolIDs, specialtyPlanIDs, user.UserID);
- return base.Json("指定成功");
- }
- catch (Exception ex)
- {
- return base.Json("指定失败,原因:" + ex.Message);
- }
- }
- [HttpGet]
- public ActionResult CreatePlan()
- {
- var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true).SchoolyearID;
- ViewData["schoolYear"] = schoolYear;
- return View();
- }
- [HttpPost]
- public ActionResult CreatePlan(Guid schoolyearID)
- {
- try
- {
- schoolyearID = new Guid(Request.Form["SchoolyearDropdown"]);
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- StudentsOrderServices.CreateStudentOrder(schoolyearID, user.UserID);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "生成成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "生成失败,原因:" + ex.Message + "!"
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="roleID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string specialtyPlanIDs)
- {
- try
- {
- var specialtyPlanIDList = specialtyPlanIDs.Split(',').Select(x => Guid.Parse(x)).ToList();
- StudentsOrderServices.DeleteStudentsOrders(specialtyPlanIDList);
- return base.Json("删除成功");
- }
- catch (Exception ex)
- {
- return base.Json("删除失败,原因:" + ex.Message + "!");
- }
- }
- /// <summary>
- /// 确认征订
- /// </summary>
- /// <param name="roleID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult ComfirmOrder(string specialtyPlanIDs)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- var specialtyPlanIDList = specialtyPlanIDs.Split(',').Select(x => Guid.Parse(x)).ToList();
- StudentsOrderServices.ComfirmStudentOrder(specialtyPlanIDList, user.UserID);
- return base.Json("征订成功");
- }
- catch (Exception ex)
- {
- return base.Json("征订失败,原因:" + ex.Message + "!");
- }
- }
- /// <summary>
- /// 预加设置
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult BatchSetPreAddedValue()
- {
- StudentsOrderView studentsOrderView;
- studentsOrderView = new StudentsOrderView()
- {
- PreIncreaseQty = 5
- };
- return View(studentsOrderView);
- }
- /// <summary>
- /// 预加设置
- /// </summary>
- /// <param name="orderJsonStr"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult BatchSetPreAddedValue(string orderJsonStr)
- {
- try
- {
- orderJsonStr = Request.Form["hid_JsonStr"];
- string PreIncreaseQty = Request.Form["PreIncreaseQty"];
- if (orderJsonStr != null)
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- var addTeacherList = orderJsonStr.JsonToObject<List<StudentsOrderView>>();
- StudentsOrderServices.BatchUpdatePreAddedValue(addTeacherList, Convert.ToInt32(PreIncreaseQty), user.UserID);
- }
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存失败,原因:" + ex.Message + "!"
- });
- }
- }
- /// <summary>
- /// 征订设置
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult ChangeOrderQty()
- {
- StudentsOrderView studentsOrderView;
- studentsOrderView = new StudentsOrderView()
- {
- OrderQty = 0
- };
- return View(studentsOrderView);
- }
- [HttpPost]
- public ActionResult ChangeOrderQty(string orderJsonStr)
- {
- try
- {
- orderJsonStr = Request.Form["hid_JsonStr"];
- string OrderQty = Request.Form["OrderQty"];
- if (orderJsonStr != null)
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- var sutdentsOrderQtylist = orderJsonStr.JsonToObject<List<StudentsOrderView>>();
- StudentsOrderServices.UpdateOrderQty(sutdentsOrderQtylist, Convert.ToInt32(OrderQty), user.UserID);
- }
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存失败,原因:" + ex.Message + "!"
- });
- }
- }
- [HttpPost]
- public ActionResult Excel(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- //避开全选值
- var teachingMaterialID = Request.Form["TeachingMaterialDropdown"].ParseStrTo<Guid>();
- var grademajorID = Request.Form["ComboGridGrademajor"].ParseStrTo<Guid>();
- Guid? campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
- Guid? collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
- int? years = Request.Form["DictionarySchoolyear"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyear"].ParseStrTo<int>();
- int? standardID = Request.Form["StandardDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDropdown"].ParseStrTo<int>();
- Guid? coursematerialID = Request.Form["CourseDropdown"].ParseStrTo<Guid>();
- int? courseCategoryID = Request.Form["CourseTypeDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["CourseTypeDropdown"].ParseStrTo<int>();
- Guid? schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
- int? isOrdered = Request.Form["OrderedDropdown"].ParseStrTo<int>();
- NpoiExcelHelper neh = new NpoiExcelHelper();
- if (Request.Form["ExcelType"] == "1")
- {
- var dt = StudentsOrderServices.GetStudentsOrderViewExcle(configuretView, campusID, collegeID, years, grademajorID,
- coursematerialID, courseCategoryID, isOrdered, schoolyearID, teachingMaterialID).Select(x => new
- {
- x.SchoolyearCode,
- x.CollegeName,
- x.Years,
- x.GrademajorCode,
- x.GrademajorName,
- x.ClassNum,
- x.OrderQty,
- x.PreIncreaseQty,
- x.Count,
- x.StandardName,
- x.CourseCode,
- x.CourseName,
- x.CourseCategoryName,
- x.CourseTypeName,
- x.CourseQualityName,
- x.TeachingMaterialCode,
- x.TeachingMaterialName,
- x.IsOrderedName,
- x.CreateUserName,
- x.CreateTime
- }).ToTable();
- string[] liststring = { "学年学期", RSL.Get("College"), "年级", "年级专业代码", "年级专业", "学生人数", "征订数量","增加数量","总数",
- "专业名称","课程代码","课程名称","课程属性","课程类型","课程性质","教材编号",
- "教材名称","是否征订","创建人","创建时间"};
- neh.Export(dt, liststring, "学生征订计划");
- }
- else
- {
- var dt = StudentsOrderServices.GetStudentsOrderViewAggregateExcle(configuretView, campusID, collegeID, years, grademajorID,
- coursematerialID, courseCategoryID, isOrdered, schoolyearID,teachingMaterialID).Select(x => new
- {
- x.SchoolyearCode,
- x.CollegeName,
- x.GrademajorName,
- x.ClassNum,
- x.CourseName,
- x.TeachingMaterialCode,
- x.TeachingMaterialName,
- x.PublishTime,
- x.PublishName,
- x.Author,
- x.ISBN,
- x.Price,
- x.OrderQty,
- x.PreIncreaseQty,
- x.Count,
- x.TeachingMaterialTypeName
- }).ToTable();
- string[] liststring = { "学年学期", RSL.Get("College"), "年级专业", "学生数", "课程名称","教材编号", "教材名称", "版本时间",
- "出版单位","作者","ISBN","单价","征订数","预加数量","需用数","教材类型"};
- neh.Export(dt, liststring, "预订汇总");
- }
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/StudentsOrder/List").AddMenuParameter()
- });
- }
- /// <summary>
- /// 学生统计页面
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult StusdentStatisticalList()
- {
- return View();
- }
- /// <summary>
- /// 学生统计查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult StusdentStatisticalList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- Guid? campusID = pararms.getExtraGuid("CampusDropdown");
- Guid? collegeID = pararms.getExtraGuid("CollegeDropdown");
- Guid? schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");
- Guid? grademajorID = pararms.getExtraGuid("GrademajorDropdown");
- Guid? teachingMaterialPoolID = pararms.getExtraGuid("TeachingMaterialDropdown");
- Guid? coursematerialID = pararms.getExtraGuid("CourseDropdown");
- Guid? publishID = pararms.getExtraGuid("PublishDropdown");
- return base.Json(StudentsOrderServices.GetStudentsOrderStatisticalViewGrid(configuretView, schoolyearID, campusID, collegeID,
- grademajorID, teachingMaterialPoolID, coursematerialID, publishID, (int)pararms.page, (int)pararms.rows));
- }
- [HttpPost]
- public ActionResult StatisticalExcel(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- //Guid? campusID = pararms.getExtraGuid("CampusDropdown");
- //Guid? collegeID = pararms.getExtraGuid("CollegeDropdown");
- //Guid? schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");
- //Guid? grademajorID = pararms.getExtraGuid("GrademajorDropdown");
- //Guid? teachingMaterialPoolID = pararms.getExtraGuid("TeachingMaterialDropdown");
- //Guid? coursematerialID = pararms.getExtraGuid("CourseDropdown");
- //Guid? publishID = pararms.getExtraGuid("PublishDropdown");
-
-
- Guid? campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
- Guid? collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
- Guid? schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
- Guid? grademajorID = Request.Form["GrademajorDropdown"].ParseStrTo<Guid>();
- Guid? teachingMaterialPoolID = Request.Form["TeachingMaterialDropdown"].ParseStrTo<Guid>();
- Guid? coursematerialID = Request.Form["CourseDropdown"].ParseStrTo<Guid>();
- Guid? publishID = Request.Form["PublishDropdown"].ParseStrTo<Guid>();
- int? isOrdered = Request.Form["OrderedDropdown"].ParseStrTo<int>();
- NpoiExcelHelper neh = new NpoiExcelHelper();
- var dt = StudentsOrderServices.GetStudentsOrderStatisticalExcel(configuretView, schoolyearID, campusID, collegeID,
- grademajorID, teachingMaterialPoolID, coursematerialID, publishID).Select(x => new
- {
- x.SchoolyearCode,
- x.CollegeName,
- x.GrademajorName,
- x.ClassNum,
- x.TeachingMaterialCode,
- x.CourseName,
- x.ISBN,
- x.TeachingMaterialName,
- x.Price,
- x.PublishTime,
- x.PublishName,
- x.Author,
- x.OrderQty,
- x.PreIncreaseQty,
- x.Count
- }).ToTable();
- string[] liststring = { "学年学期", RSL.Get("College"), "年级专业", "学生人数","教材编号","课程名称",
- "ISBN","教材名称","单价","版本时间","出版单位","作者","征订数量","预加数量","总计"};
- neh.Export(dt, liststring, "学生征订统计");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/StudentsOrder/List").AddMenuParameter()
- });
- }
- }
- }
|