123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using Bowin.Web.Controls.Mvc;
- using EMIS.CommonLogic.MinorManage.MinorPlanManage;
- using EMIS.ViewModel.MinorManage.MinorPlanManage;
- using Bowin.Common.JSON;
- using Bowin.Common.Utility;
- using Bowin.Common.Exceptions;
- using EMIS.Utility;
- using Bowin.Common.Data;
- using EMIS.CommonLogic.Students;
- namespace EMIS.Web.Controllers.MinorManage.MinorPlanManage
- {
- [Authorization]
- public class MinorPlanApplyController : Controller
- {
- //
- // GET: /MinorPlanApply/
- public IMinorPlanApplyServices minorPlanApplyServices { get; set; }
- public Lazy<IStudentsServices> StudentfileServices { get; set; }
- public ActionResult List()
- {
- return View();
- }
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
- var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
- var collegeID = pararms.getExtraGuid("CollegeDropdown");
- var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
- return this.Json(minorPlanApplyServices.GetMinorPlanApplyViewGrid(configuretView, yearID, standardID, collegeID, approvalStatus,(int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 获取未申请过的辅修课程
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult StandardAndMinorSpecialtyCourseViewList(QueryParamsModel pararms)
- {
- var yearID = pararms.getExtraInt("YearID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YearID");
- var standardID = pararms.getExtraInt("StandardID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardID");
- return this.Json(minorPlanApplyServices.StandardAndMinorSpecialtyCourseViewGrid(yearID, standardID,(int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 获取申请过的辅修课程
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult existStandardAndMinorSpecialtyCourseViewList(QueryParamsModel pararms)
- {
- var GradeMinorApplicationID = Request["GradeMinorApplicationID"].ParseStrTo<Guid>();
- return this.Json(minorPlanApplyServices.existStandardAndMinorSpecialtyCourseViewGrid(GradeMinorApplicationID, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 获取不存在辅修计划的课程
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult MinorPlanApplyChoiceList()
- {
- MinorPlanApplyView minorPlanApplyView = new MinorPlanApplyView();
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var dataRange = StudentfileServices.Value.GetDataRange();
- ViewBag.DataRange = dataRange;
- minorPlanApplyView.CollegeID=curUser.CollegeID;
-
- minorPlanApplyView.HandleModeID = 1;
- minorPlanApplyView.IsNeedMaterial = true;
- return View(minorPlanApplyView);
- }
- /// <summary>
- /// 批量添加
- /// </summary>
- /// <param name="planApplicationView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult MinorPlanApplyChoiceList(MinorPlanApplyView minorPlanApplyView)
- {
- try
- {
- var minorSpecialCourseViewList = Request["MinorSpecialtyCourse"].JsonToObject<List<MinorPlanApplyView>>();
- if (minorSpecialCourseViewList.Count > 0)
- {
- minorPlanApplyServices.MinorPlanAdd(minorPlanApplyView, minorSpecialCourseViewList);
- //specialtyPlanServices.SpecialtyPlanAdd(specialtyPlanView, specialCourseViewList);
- }
- else
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,请选择要添加的专业课程。"
- });
- }
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 修改辅修计划的课程
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? GradeMinorApplicationIDs)
- {
- MinorPlanApplyView minorPlanApplyView = new MinorPlanApplyView();
- minorPlanApplyView=minorPlanApplyServices.GetMinorPlanApplyView(GradeMinorApplicationIDs);
- var dataRange = StudentfileServices.Value.GetDataRange();
- ViewBag.DataRange = dataRange;
- minorPlanApplyView.HandleModeID = 1;
- minorPlanApplyView.IsNeedMaterial = true;
- return View(minorPlanApplyView);
- }
- /// <summary>
- /// 修改辅修计划的课程
- /// </summary>
- /// <param name="planApplicationView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(MinorPlanApplyView minorPlanApplyView)
- {
- try
- {
- var minorSpecialCourseViewList = DataGrid.GetTableData<MinorPlanApplyView>("dgStandardAndMinorSpecialtyCourseViewList");
- if (minorSpecialCourseViewList.Count > 0)
- {
- minorPlanApplyServices.MinorPlanEdit(minorPlanApplyView, minorSpecialCourseViewList);
- //specialtyPlanServices.SpecialtyPlanAdd(specialtyPlanView, specialCourseViewList);
- }
- else
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,请选择要添加的专业课程。"
- });
- }
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 修改辅修计划的课程
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult CopyAdd(Guid? GradeMinorApplicationIDs)
- {
- MinorPlanApplyView minorPlanApplyView = new MinorPlanApplyView();
- minorPlanApplyView = minorPlanApplyServices.GetMinorPlanApplyView(GradeMinorApplicationIDs);
- var dataRange = StudentfileServices.Value.GetDataRange();
- ViewBag.DataRange = dataRange;
- return View(minorPlanApplyView);
- }
- /// <summary>
- /// 修改辅修计划的课程
- /// </summary>
- /// <param name="planApplicationView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CopyAdd(MinorPlanApplyView minorPlanApplyView)
- {
- try
- {
- var minorSpecialCourseViewList = DataGrid.GetTableData<MinorPlanApplyView>("dgStandardAndMinorSpecialtyCourseViewList");
- if (minorSpecialCourseViewList.Count > 0)
- {
- minorPlanApplyView.GradeMinorApplicationID = null;
- minorPlanApplyServices.MinorPlanEdit(minorPlanApplyView, minorSpecialCourseViewList);
- //specialtyPlanServices.SpecialtyPlanAdd(specialtyPlanView, specialCourseViewList);
- }
- else
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,请选择要添加的专业课程。"
- });
- }
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- //年级复制
- public ActionResult CopyByGrade()
- {
- var dataRange = StudentfileServices.Value.GetDataRange();
- ViewBag.DataRange = dataRange;
- return View();
- }
- [HttpPost]
- public ActionResult CopyByGrade(MinorPlanApplyView minorPlanApplyView)
- {
- try
- {
- string Success = minorPlanApplyServices.SpecialtyPlanCopyByGrade(minorPlanApplyView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = Success
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "复制失败:" + ex.Message
- });
- }
- }
- //年级复制
- public ActionResult AddCourse(int? YearID, int StandardID)
- {
- return View();
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="MinorCourseIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string GradeMinorApplicationIDs)
- {
- try
- {
- List<Guid?> list = new List<Guid?>();
- for (int i = 0; i < GradeMinorApplicationIDs.Split(',').Length; i++)
- {
- string id = GradeMinorApplicationIDs.Split(',')[i];
- if (!string.IsNullOrEmpty(id))
- {
- Guid GradeMinorApplicationID = new Guid(id);
- list.Add(GradeMinorApplicationID);
- }
- }
- minorPlanApplyServices.GradeMinorApplicationDelete(list);
- return base.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 base.Json("删除失败,原因:" + mge);
- }
- }
- /// <summary>
- /// 提交申请
- /// </summary>
- /// <param name="GradeMinorApplicationIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult SubmitPlanApplication(string GradeMinorApplicationIDs, string statusNames)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- List<Guid> list = new List<Guid>();
- for (int i = 0; i < GradeMinorApplicationIDs.Split(',').Length; i++)
- {
- if (!string.IsNullOrEmpty(GradeMinorApplicationIDs.Split(',')[i]))
- {
- Guid GradeMinorApplicationID = new Guid(GradeMinorApplicationIDs.Split(',')[i]);
- list.Add(GradeMinorApplicationID);
- }
- }
- List<string> status = new List<string>();
- for (int i = 0; i < statusNames.Split(',').Length; i++)
- {
- if (!string.IsNullOrEmpty(statusNames.Split(',')[i]))
- {
- string statusName = statusNames.Split(',')[i];
- status.Add(statusName);
- }
- }
- if (minorPlanApplyServices.GetStandardID_MinorPlanApplication_MinorSpecialtyPlanCount(list) > 0)
- {
- return Json("提交申请失败,请检查您提交的数据是否已存在专业计划不能重复提交申请!");
- }
- minorPlanApplyServices.SubmitPlanApplicationApply(list, user.UserID, status, "");
- return this.Json("成功");
- }
- catch (Exception ex)
- {
- return this.Json("提交申请失败,原因:" + ex.Message);
- }
- }
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- var GradeMinorApplicationID = Request.Form["GradeMinorApplicationID"];
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
- var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
- var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
- var approvalStatus = Request.Form["GrademinorStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["GrademinorStatusDictionaryDropDown"].ParseStrTo<int>();
- List<Guid?> GradeMinorApplicationIDList = new List<Guid?>();
- if (GradeMinorApplicationID != "")
- {
- GradeMinorApplicationIDList = GradeMinorApplicationID.SplitIDString();
- }
- else
- {
- GradeMinorApplicationIDList = null;
- }
- var dt = minorPlanApplyServices.GetMinorPlanApplyViewList(configuretView, yearID, standardID, collegeID, approvalStatus, GradeMinorApplicationIDList).Select(x => new
- {
- x.YearID,
- x.StandardCode,
- x.StandardName,
- x.CollegeName,
- x.StudentLimit,
- x.CreateTime,
- x.CreateUserName,
- x.ApprovalStatusName
- }).ToTable();
- string[] liststring = { "年级", "专业代码", "专业名称", RSL.Get("College"), "人数上限","申请时间",
- "申请人","状态"};
- neh.Export(dt, liststring, "辅修申请信息");
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功。"
- });
- }
- }
- }
|