123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462 |
- 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 EMIS.CommonLogic.TeachingMaterial;
- using Bowin.Web.Controls.Mvc;
- using EMIS.ViewModel.TeachingMaterial;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- using EMIS.ViewModel.WorkflowManage;
- using EMIS.CommonLogic.CalendarManage;
- using Newtonsoft.Json;
- using EMIS.Utility;
- namespace EMIS.Web.Controllers.TeachingMaterial
- {
- [Authorization]
- public class TeachersOrderController : Controller
- {
- public ITeachersOrderServices TeachersOrderServices { get; set; }
- public ITeachersOrderExamineServices TeachersOrderExamineServices { get; set; }
- public ISchoolYearServices schoolYearServices { get; set; }
- /// <summary>
- /// 征订申请页面列表查询
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult List()
- {
- //默认加载当前校历下学年学期的下一个学期
- var schoolYearView = schoolYearServices.GetSchoolYearIsCurrent(true);
- var schoolyear = schoolYearServices.GetSchoolYearViewListAfterCurrent().OrderBy(x => x.Code).Where(x => x.Value > schoolYearView.Value).FirstOrDefault();
- ViewBag.SchoolYearID = schoolyear.SchoolYearID;
- return View();
- }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- //避开全选值
- Guid? publishID = null;
- Guid? coursematerialID = null;
- publishID = pararms.getExtraGuid("PublishDropdown");
- coursematerialID = pararms.getExtraGuid("CourseDropdown");
- var schoolYearID = pararms.getExtraGuid("SchoolYearDropdown");
- var collegeID = pararms.getExtraGuid("CollegeDropdown");
- var approvalStatus = pararms.getExtraInt("StatusDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StatusDropdown");
- return base.Json(TeachersOrderServices.GetTeachersOrderViewGrid(configuretView, schoolYearID, collegeID, coursematerialID, publishID, approvalStatus, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 编辑页面
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? teachersOrderID)
- {
- TeachersOrderView TeachersOrderView;
- if (teachersOrderID != null && teachersOrderID != Guid.Empty)
- {
- TeachersOrderView = null;
- TeachersOrderView = TeachersOrderServices.GetSingleTeachersOrder(teachersOrderID.Value);
- }
- else
- {
- TeachersOrderView = new TeachersOrderView()
- {
- TeachersOrderID = Guid.Empty
- };
- }
- return View(TeachersOrderView);
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="TeachersOrderID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(TeachersOrderView teachersOrderView)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- TeachersOrderView teachersOrder = new TeachersOrderView();
- if (teachersOrderView.TeachersOrderID != null)
- {
- TeachersOrderServices.EditTeachersOrder(teachersOrderView, user.UserID);
- }
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存失败,原因:" + ex.Message + "!"
- });
- }
- }
- [HttpPost]
- public ActionResult TeachersSave(string orderJson, TeachersOrderView teachersOrderView)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- orderJson = Request.Form["hid_orderJsonStr"];
- var collegeID = user.CollegeID;//获取当前登录用户对应的院系所
- if (collegeID == null)
- {
- throw new Exception("该用户没有对应的" + RSL.Get("College") + ",请联系相关人员!");
- }
- var orderList = orderJson.JsonToObject<List<TeachingMaterialPoolView>>();
- List<TeachersOrderView> teachersOrderList = new List<TeachersOrderView>();
- orderList.ForEach(x =>
- {
- TeachersOrderView order = new TeachersOrderView
- {
- TeachingMaterialPoolID = x.TeachingMaterialPoolID,
- SchoolyearID = teachersOrderView.SchoolyearID,
- CollegeID = collegeID == null ? Guid.Empty : collegeID,
- OrderQty = x.OrderQty,
- OrderUserID = user.UserID,
- OrderDate = DateTime.Now,
- OrderDesc = teachersOrderView.OrderDesc
- };
- teachersOrderList.Add(order);
- });
- TeachersOrderServices.AddTeachersOrder(teachersOrderList, user.UserID);
- //return base.Json("征订成功");
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存失败,原因:" + ex.Message + "!"
- });
- }
- }
- /// <summary>
- /// 提交申请
- /// </summary>
- /// <param name="TeachersOrderIDs">申请征订ID</param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult SubmitTeachersOrder(string TeachersOrderIDs)
- {
- try
- {
- List<Guid> list = new List<Guid>();
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- for (int i = 0; i < TeachersOrderIDs.Split(',').Length; i++)
- {
- string id = TeachersOrderIDs.Split(',')[i];
- if (!string.IsNullOrEmpty(id))
- {
- Guid TeachersOrderID = new Guid(id);
- list.Add(TeachersOrderID);
- }
- }
- TeachersOrderServices.SubmitTeachersOrder(list, user.UserID, "");
- return base.Json("成功");
- }
- catch (Exception ex)
- {
- return base.Json("失败,原因:" + ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="teachersOrderIDs">征订ID</param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string teachersOrderIDs)
- {
- try
- {
- List<Guid> list = new List<Guid>();
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- for (int i = 0; i < teachersOrderIDs.Split(',').Length; i++)
- {
- string id = teachersOrderIDs.Split(',')[i];
- if (!string.IsNullOrEmpty(id))
- {
- Guid specialtyApplyID = new Guid(id);
- list.Add(specialtyApplyID);
- }
- }
- TeachersOrderServices.DeleteTeachersOrder(list);
- return base.Json("删除成功");
- }
- catch (Exception ex)
- {
- return base.Json("删除失败,原因:" + ex.Message);
- }
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- //避开全选值
- Guid? publishID = null;
- Guid? coursematerialID = null;
- publishID = Request.Form["PublishDropdown"].ParseStrTo<Guid>();
- coursematerialID = Request.Form["CourseDropdown"].ParseStrTo<Guid>();
- Guid? schoolYearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
- Guid? collegeID = Request.Form["CollegeDropdownListBanids"].ParseStrTo<Guid>();
- int? approvalStatus = Request.Form["StatusDropdown"].ParseStrTo<int>();
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- if (Request.Form["ExcelType"] == "1")
- {
- var dt = TeachersOrderServices.GetTeachersOrderViewList(configuretView, schoolYearID, collegeID, coursematerialID, publishID, approvalStatus).Select(x => new
- {
- x.SchoolyearName,
- x.TeachingMaterialCode,
- x.CoursematerialCode,
- x.CoursematerialName,
- x.CoursematerialLevelName,
- x.CoursematerialTypeName,
- x.ISBN,
- x.TeachingMaterialName,
- x.PublishTime,
- x.PublishName,
- x.Author,
- x.OrderQty,
- x.OrderUserName,
- x.CollegeName,
- x.OrderDate,
- x.OrderDesc,
- x.ApproveStatusName
- }).ToTable();
- string[] liststring = { "学年学期","教材编号","课程代码","课程名称","课程级别","课程科类","ISBN","教材名称"
- ,"版本时间","出版单位","作者","征订数量","征订人",RSL.Get("College"),"征订日期","征订说明","审核状态 "};
- neh.Export(dt, liststring, "征订申请信息");
- }
- else
- {
- var dt = TeachersOrderServices.GetTeachersOrderViewList(configuretView, schoolYearID, collegeID, coursematerialID, publishID, approvalStatus).Select(x => new
- {
- x.SchoolyearName,
- x.CollegeName,
- x.CoursematerialName,
- x.TeachingMaterialCode,
- x.TeachingMaterialName,
- x.Price,
- x.ISBN,
- x.PublishTime,
- x.PublishName,
- x.Author,
- x.OrderQty,
- x.OrderUserName
- }).ToTable();
- string[] liststring = { "学年学期",RSL.Get("College"),"课程名称","教材编号","教材名称","单价","ISBN","版本时间","出版单位"
- ,"作者","征订数量","征订人"};
- neh.Export(dt, liststring, "征订申请预订汇总导出");
- }
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/TeachersOrder/List").AddMenuParameter()
- });
- }
- /// <summary>
- /// 页面数据增加
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Add(Guid? teachersOrderID)
- {
- TeachersOrderView TeachersOrderView;
- if (teachersOrderID != null && teachersOrderID != Guid.Empty)
- {
- TeachersOrderView = null;
- TeachersOrderView = TeachersOrderServices.GetSingleTeachersOrder(teachersOrderID.Value);
- }
- else
- {
- TeachersOrderView = new TeachersOrderView()
- {
- SchoolyearID = schoolYearServices.GetSchoolYearIsCurrent(true).SchoolyearID,//默认当前学年
- TeachersOrderID = Guid.Empty
- };
- }
- EMIS.Entities.CF_Schoolyear schoolyear = schoolYearServices.GetSchoolYearIsCurrent(true);
- if (schoolyear != null)
- ViewData["SchoolyearID"] = schoolyear.SchoolyearID;
- return View(TeachersOrderView);
- }
- /// <summary>
- /// 页面数据增加
- /// </summary>
- /// <param name="TeachersOrderID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Add(TeachersOrderView teachersOrderView)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- TeachersOrderServices.EditTeachersOrder(teachersOrderView, user.UserID);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message + "!"
- });
- }
- }
- [HttpGet]
- public ActionResult AuditStatusView(Guid? teachersOrderID)
- {
- List<DropdownListItem> list = new List<DropdownListItem>();
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- TeachersOrderView teachersOrderView = new TeachersOrderView();
- if (teachersOrderID.HasValue)
- teachersOrderView = TeachersOrderExamineServices.GetTeachersOrderExamineView(teachersOrderID);
- List<ActionView> listAction = TeachersOrderExamineServices.GetAuditingActionView((Guid)teachersOrderID, user.UserID);
- foreach (var item in listAction)
- {
- DropdownListItem dli = new DropdownListItem { Text = item.ActionName, Value = item.ToJson() };
- list.Add(dli);
- }
- ViewData["listAction"] = list;
- ViewData["endStatus"] = TeachersOrderServices.GetCorrectEndStatus();
- return View(teachersOrderView);
- }
- [HttpPost]
- public ActionResult AuditStatusView(TeachersOrderView teachersOrderView)
- {
- try
- {
- List<Guid> list = new List<Guid>();
- string action = Request.Form["ddlAction"];
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- ActionView actionView = action.JsonToObject<ActionView>();
- string comment = Request.Form["txtOpinioncomment"];
- list.Add(teachersOrderView.TeachersOrderID);
- TeachersOrderExamineServices.ApproveTeachersOrderExamine(list, user.UserID, actionView, comment);
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "审核成功!",
- url = Url.Content("~/TeachersOrderExamine/List").AddMenuParameter()
- });
- }
- catch (Exception ex)
- {
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "审核失败,原因:" + ex.Message,
- url = Url.Content("~/TeachersOrderExamine/List").AddMenuParameter()
- });
- }
- }
- [HttpGet]
- public ActionResult GetTeachingMaterialPoolList()
- {
- ViewData["SchoolyearID"] = Guid.Empty;
- return View();
- }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetTeachingMaterialPoolList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- //避开全选值
- Guid? publishID = null;
- Guid? coursematerialID = null;
- Guid? teachingMaterialID = null;
- bool? isLate = false;
- teachingMaterialID = pararms.getExtraGuid("TeachingMaterialDropdown");
- publishID = pararms.getExtraGuid("PublishDropdown");
- coursematerialID = pararms.getExtraGuid("CourseDropdown");
- var schoolyearID = pararms.getExtraGuid("SchoolyearID");
- if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- return base.Json(TeachersOrderServices.GetTeachersOrderOrTeachingMaterialPoolViewGrid(configuretView, teachingMaterialID, coursematerialID, isLate, user.CollegeID, schoolyearID, (int)pararms.page, (int)pararms.rows));
- }
- [HttpGet]
- public ActionResult DetailList()
- {
- ViewData["TeachersOrderID"] = Request.Params["TeachersOrderID"];
- return View();
- }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult DetailList(QueryParamsModel pararms)
- {
- Guid? teachersOrderID = new Guid(Request.Params["teachersOrderID"]);
- return base.Json(TeachersOrderServices.GetTeachersOrderDetailViewList(teachersOrderID, (int)pararms.page, (int)pararms.rows));
- }
- }
- }
|