123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.ViewModel;
- using EMIS.CommonLogic.EducationManagement;
- using EMIS.Entities;
- using EMIS.ViewModel.EducationManagement;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- using Bowin.Web.Controls.Mvc;
- using EMIS.Web.Controls;
- using Bowin.Common.Exceptions;
- namespace EMIS.Web.Controllers.TeachingManagement
- {
- [Authorization]
- public class ClassGroupingController : Controller
- {
- public IClassGroupingServices classGroupingService { 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 className = pararms.getExtraString("ClassNameText").Trim();
- return this.Json(classGroupingService.GetClassGroupingGrid(configuretView,className, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="classGroupingID"></param>
- /// <returns></returns>
- public ActionResult Edit(Guid? classGroupingID)
- {
- ClassGroupingView classGroupingView = new ClassGroupingView();
- if (classGroupingID != null && classGroupingID != Guid.Empty)
- classGroupingView = classGroupingService.GetClassGroupingView(classGroupingID);
- else
- classGroupingView.IsEnable = true;
- return View(classGroupingView);
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="classGrouping"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(ClassGroupingView classGroupingView)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- EM_ClassGrouping classGrouping = null;
- var settingsList = DataGrid.GetTableData<ClassGroupingSettingsView>("dgClassGroupingSettingsList");
- classGroupingView.TeachingModeIDs = new List<string>();
- var isDuplicate = classGroupingService.IsNameDuplicate(classGroupingView.ClassName, classGroupingView.ClassGroupingID);
- if (isDuplicate)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:上课类型重复,请重新修改名称。"
- });
- }
- if (classGroupingView.ClassGroupingID == null || classGroupingView.ClassGroupingID == Guid.NewGuid())
- {
- classGrouping = new EM_ClassGrouping();
- classGrouping.ClassGroupingID = Guid.NewGuid();
- classGrouping.ClassName = classGroupingView.ClassName;
- classGrouping.Remarks = classGroupingView.Remarks;
- classGrouping.IsEnable = classGroupingView.IsEnable;
- classGrouping.RecordStatus = 1;
- classGrouping.CreateTime = DateTime.Now;
- classGrouping.CreateUserID = user.UserID;
- classGrouping.ModifyTime = DateTime.Now;
- classGrouping.ModifyUserID = user.UserID;
- classGroupingService.ClassGroupingAdd(classGrouping);
- foreach (var settings in settingsList)
- {
- if (settings.IsClassGrouping)
- classGroupingView.TeachingModeIDs.Add(settings.TeachingModeID.ToString());
- }
- if (classGroupingView.TeachingModeIDs != null)
- {
- classGroupingService.ClassGroupingSettingsAdd(classGrouping.ClassGroupingID, classGroupingView.TeachingModeIDs);
- }
- }
- else
- {
- classGrouping = classGroupingService.GetClassGrouping(classGroupingView.ClassGroupingID);
- classGrouping.ClassName = classGroupingView.ClassName;
- classGrouping.Remarks = classGroupingView.Remarks;
- classGrouping.IsEnable = classGroupingView.IsEnable;
- classGrouping.ModifyTime = DateTime.Now;
- classGrouping.ModifyUserID = user.UserID;
- classGroupingService.ClassGroupingUpdate(classGrouping);
- foreach (var settings in settingsList)
- {
- if (settings.IsClassGrouping)
- classGroupingView.TeachingModeIDs.Add(settings.TeachingModeID.ToString());
- }
- if (classGroupingView.TeachingModeIDs != null)
- {
- classGroupingService.ClassGroupingSettingsAdd(classGrouping.ClassGroupingID, classGroupingView.TeachingModeIDs);
- }
- }
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message + "!"
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="coursematerialIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string classGroupingIDs)
- {
- try
- {
- List<Guid?> list = new List<Guid?>();
- for (int i = 0; i < classGroupingIDs.Split(',').Length; i++)
- {
- string id = classGroupingIDs.Split(',')[i];
- if (!string.IsNullOrEmpty(id))
- {
- Guid classGroupingID = new Guid(id);
- list.Add(classGroupingID);
- }
- }
- classGroupingService.ClassGroupingDelete(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="specialtyCourseID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult TeachingModeType(Guid? classGroupingID)
- {
- List<string> list = new List<string>();
- if (classGroupingID.HasValue && classGroupingID != Guid.Empty)
- list = classGroupingService.GetTeachingMode(classGroupingID);
- return base.Json(list);
- }
- /// <summary>
- /// 获取授课方式是否分班列表
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult ClassGroupingSettingsView(QueryParamsModel pararms)
- {
- var classGroupingID = Request.QueryString["classGroupingID"] == "" ? Guid.Empty : new Guid(Request.QueryString["classGroupingID"]);
- return this.Json(classGroupingService.GetClassGroupingSettingsViewGrid(classGroupingID));
- }
- /// <summary>
- /// 获取上课类型列表
- /// </summary>
- [HttpPost]
- public ActionResult ClassGroupingDropdownListBanid(DropdownListBindType? bindType)
- {
- List<DropdownListItem> list = new List<DropdownListItem>();
- list = classGroupingService.GetAvailableClassGroupingViewList().Select(x => new DropdownListItem { Text = x.ClassName, Value = x.ClassGroupingID.ToString() }).ToList();
- DropdownListBindType dbt = bindType == null ? DropdownListBindType.PleaseSelect : bindType.Value;
- DropdownList.FormatDropdownItemList(dbt, list);
- return base.Json(list);
- }
- }
- }
|