123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Bowin.Web.Controls.Mvc;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- using Bowin.Common.JSON;
- using EMIS.Web.Controls;
- using EMIS.ViewModel;
- using EMIS.ViewModel.StudentManage.OnlineChecking;
- using EMIS.CommonLogic.StudentManage.OnlineChecking;
- namespace EMIS.Web.Controllers.StudentManage.OnlineChecking
- {
- [Authorization]
- public class OpenObjectController : Controller
- {
- public Lazy<IOpenObjectServices> OpenObjectServices { get; set; }
- /// <summary>
- /// 学生开放对象页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- return View();
- }
- /// <summary>
- /// 学生开放对象页面列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
- var schoolyearNumID = pararms.getExtraInt("DictionarySchoolyearNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyearNum");
- var dateRange = pararms.getExtraDateTime("txtDateRange");
- return base.Json(OpenObjectServices.Value.GetStudentEditObjectViewGrid(configuretView, educationID, schoolyearNumID, dateRange, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="studentEditObjectID"></param>
- /// <returns></returns>
- public ActionResult CopyAdd(Guid studentEditObjectID)
- {
- OpenObjectView openObjectView = new OpenObjectView();
- openObjectView = OpenObjectServices.Value.GetStudentEditObjectView(studentEditObjectID);
- return View("Edit", openObjectView);
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="openObjectView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CopyAdd(OpenObjectView openObjectView)
- {
- openObjectView.StudentEditObjectsID = Guid.Empty;
- return this.Edit(openObjectView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="studentEditObjectID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? studentEditObjectID)
- {
- OpenObjectView openObjectView = new OpenObjectView();
- if (studentEditObjectID.HasValue && studentEditObjectID != Guid.Empty)
- {
- openObjectView = OpenObjectServices.Value.GetStudentEditObjectView(studentEditObjectID);
- }
- else
- {
- openObjectView.Starttime = DateTime.Now;
- openObjectView.Endtime = DateTime.Now.AddMonths(1);
- }
- return View(openObjectView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="openObjectView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(OpenObjectView openObjectView)
- {
- try
- {
- OpenObjectServices.Value.StudentEditObjectEdit(openObjectView);
- 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 OpenObjectBatchAdd()
- {
- OpenObjectView openObjectView = new OpenObjectView();
- openObjectView.Starttime = DateTime.Now;
- openObjectView.Endtime = DateTime.Now.AddMonths(1);
- return View(openObjectView);
- }
- /// <summary>
- /// 开放对象信息批量新增
- /// </summary>
- /// <param name="openObjectView"></param>
- /// <returns></returns>
- public ActionResult OpenObjectBatchAdd(OpenObjectView openObjectView)
- {
- try
- {
- var schoolyearNumIDList = Request["schoolyearNumIDList"].JsonToObject<List<int?>>();
- string result = OpenObjectServices.Value.StudentEditObjectBatchAdd(schoolyearNumIDList, openObjectView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "新增成功" + result + "。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "新增失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 查询对应的未新增开放学年信息DictionaryItemView
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult SchoolyearNumNoAddList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var educationID = pararms.getExtraInt("EducationID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("EducationID");
- return base.Json(OpenObjectServices.Value.GetSchoolyearNumNoAddGrid(configuretView, educationID, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="studentEditObjectIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string studentEditObjectIDs)
- {
- try
- {
- List<Guid?> list = studentEditObjectIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
- OpenObjectServices.Value.StudentEditObjectDelete(list);
- return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
- }
- catch (Exception ex)
- {
- return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + ex.Message });
- }
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
- var schoolyearNumID = Request.Form["DictionarySchoolyearNum"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyearNum"].ParseStrTo<int>();
- var dateRange = Request.Form["txtDateRange"].ParseStrTo<DateTime>();
- var dt = OpenObjectServices.Value.GetStudentEditObjectViewList(configuretView, educationID, schoolyearNumID, dateRange)
- .Select(x => new
- {
- x.EducationName,
- x.SchoolyearNumName,
- Starttime = x.Starttime == null ? null : x.Starttime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
- Endtime = x.Endtime == null ? null : x.Endtime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
- x.Remark,
- x.CreateUserName,
- x.ModifyUserName,
- ModifyTime = x.ModifyTime == null ? null : x.ModifyTime.Value.ToString("yyyy-MM-dd HH:mm:ss")
- }).ToTable();
- string[] liststring = {
- "培养层次", "开放学年", "开始时间", "结束时间", "备注", "创建人", "修改人", "修改时间"
- };
- neh.Export(dt, liststring, "开放对象信息" + DateTime.Now.ToString("yyyyMMdd"));
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功。"
- });
- }
- }
- }
|