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(); } /// /// 列表查询 /// /// /// [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 + "!" }); } } /// /// 删除 /// /// /// [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 + "!"); } } /// /// 确认征订 /// /// /// [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 + "!"); } } /// /// 预加设置 /// /// [HttpGet] public ActionResult BatchSetPreAddedValue() { StudentsOrderView studentsOrderView; studentsOrderView = new StudentsOrderView() { PreIncreaseQty = 5 }; return View(studentsOrderView); } /// /// 预加设置 /// /// /// [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>(); 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 + "!" }); } } /// /// 征订设置 /// /// [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>(); 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(); var grademajorID = Request.Form["ComboGridGrademajor"].ParseStrTo(); Guid? campusID = Request.Form["CampusDropdown"].ParseStrTo(); Guid? collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); int? years = Request.Form["DictionarySchoolyear"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyear"].ParseStrTo(); int? standardID = Request.Form["StandardDropdown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDropdown"].ParseStrTo(); Guid? coursematerialID = Request.Form["CourseDropdown"].ParseStrTo(); int? courseCategoryID = Request.Form["CourseTypeDropdown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["CourseTypeDropdown"].ParseStrTo(); Guid? schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo(); int? isOrdered = Request.Form["OrderedDropdown"].ParseStrTo(); 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() }); } /// /// 学生统计页面 /// /// [HttpGet] public ActionResult StusdentStatisticalList() { return View(); } /// /// 学生统计查询 /// /// /// [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? collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); Guid? schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo(); Guid? grademajorID = Request.Form["GrademajorDropdown"].ParseStrTo(); Guid? teachingMaterialPoolID = Request.Form["TeachingMaterialDropdown"].ParseStrTo(); Guid? coursematerialID = Request.Form["CourseDropdown"].ParseStrTo(); Guid? publishID = Request.Form["PublishDropdown"].ParseStrTo(); int? isOrdered = Request.Form["OrderedDropdown"].ParseStrTo(); 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() }); } } }