123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.CommonLogic.DQPSystem;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using EMIS.ViewModel.DQPSystem;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- using Bowin.Common.Exceptions;
- namespace EMIS.Web.Controllers.DQPSystem
- {
- [Authorization]
- public class SOCDetailController : Controller
- {
- //
- // GET: /SOCDetail/
- public ISOCDetailServices SOCDetailServices { get; set; }
- public ActionResult List()
- {
- return View();
- }
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
- var coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo");
- var collegeID = pararms.getExtraGuid("CollegeComboGrid");
- var staffID = pararms.getExtraGuid("StaffDropdown");
- var result = SOCDetailServices.GetSOCDetailViewGrid(configuretView, schoolyearID, coursematerialID, collegeID, staffID, (int)pararms.page, (int)pararms.rows);
- return Json(result);
- }
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
- var coursematerialID = Request.Form["CoursematerialIDDropdownGridBo"].ParseStrTo<Guid>();
- var collegeID = Request.Form["CollegeComboGrid"].ParseStrTo<Guid>();
- var staffID = Request.Form["StaffDropdown"].ParseStrTo<Guid>();
- var socDetailIDString = Request.Form["SelectedID"];
- var socDetailIDList = socDetailIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
- var dt = SOCDetailServices.GetSOCDetailViewList(configuretView, schoolyearID, coursematerialID, collegeID, staffID, socDetailIDList)
- .Select(x => new
- {
- x.SchoolyearCode,
- x.CourseCode,
- x.CourseName,
- x.StudentCount,
- x.Name,
- x.Credit,
- x.Weight,
- x.IsGroupStr,
- x.StartTimeStr,
- x.EndTimeStr
- }).ToTable();
- string[] liststring = { "学年学期", "课程代码", "课程名称", "学生人数", "成果名称", "成果学分", "成果权重", "是否分组", "开始上传时间", "截止上传时间" };
- neh.Export(dt, liststring, "课程SOC明细" + DateTime.Now.ToString("yyyyMMdd"));
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功。"
- });
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="minorConditionID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? SOCDetailID)
- {
- SOCDetailView SOCDetailView = new SOCDetailView();
- if (SOCDetailID.HasValue && SOCDetailID != Guid.Empty)
- {
- SOCDetailView = SOCDetailServices.GetSOCDetailView(SOCDetailID);
- }
- return View(SOCDetailView);
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="graduationConditionView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(SOCDetailView SOCDetailView)
- {
- try
- {
- var count = Session.Count;
- List<FileUploadView> filelist = new List<FileUploadView>();
- for (int i = 0; i < count; i++)
- {
- var file = Session[i];
- if (file.GetType() == typeof(List<FileUploadView>))
- {
- filelist = (List<FileUploadView>)file;
- }
- }
- SOCDetailServices.SOCDetailEdit(SOCDetailView, filelist);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message + "。"
- });
- }
- }
- public ActionResult Delete(string SOCDetailIDs)
- {
- try
- {
- List<Guid?> list = new List<Guid?>();
- for (int i = 0; i < SOCDetailIDs.Split(',').Length; i++)
- {
- if (!string.IsNullOrEmpty(SOCDetailIDs.Split(',')[i]))
- {
- Guid SOCDetailID = new Guid(SOCDetailIDs.Split(',')[i]);
- list.Add(SOCDetailID);
- }
- }
- SOCDetailServices.SOCDetailDelete(list);
- return this.Json("删除成功!");
- }
- catch (Exception ex)
- {
- string mge = ex.Message;
- System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
- if (num != null)
- {
- if (num.Number == 547)
- mge = "请先删除所有关联的数据(SOC分组、SOC学生成果、SOC学生成绩等)。";
- }
- return base.Json("删除失败,原因:" + mge);
- }
- }
- [HttpGet]
- public ActionResult Upload(Guid? detailID)
- {
- SOCDetailView SOCDetailView = new SOCDetailView();
- SOCDetailView.SOCDetailID = detailID.Value;
- return View(SOCDetailView);
- }
- [HttpPost]
- public ActionResult Upload(SOCDetailView SOCDetailView)
- {
- return Json("上传成功");
- //try
- //{
- // var count = Session.Count;
- // List<FileUploadView> filelist = new List<FileUploadView>();
- // for (int i = 0; i < count; i++)
- // {
- // var file = Session[i];
- // filelist = (List<FileUploadView>)file;
- // }
- // SOCDetailServices.SOCDetailAttachmentSave(SOCDetailView.SOCDetailID, filelist);
- // return this.Json("上传成功!");
- //}
- //catch (Exception ex)
- //{
- // return this.Json("上传成功,原因:" + ex.Message);
- //}
- }
- [HttpPost]
- public ActionResult GetAttachmentList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var socDetailID = pararms.getExtraGuid("hidSOCDetailID");
- return base.Json(SOCDetailServices.GetSOCDetailAttachmentViewList(configuretView, socDetailID, (int)pararms.page, (int)pararms.rows));
- }
- }
- }
|