using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.ViewModel;
using EMIS.Web.Controls;
using EMIS.CommonLogic.SchedulingManage.SchedulingSettings;
using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
using Bowin.Common.Exceptions;
namespace EMIS.Web.Controllers.SchedulingManage.SchedulingSettings
{
[Authorization]
public class CourseTimeHoursController : Controller
{
public ICourseTimeHoursServices ICourseTimeHoursServices { get; set; }
///
/// 学时转换页面
///
///
public ActionResult List()
{
return View();
}
///
/// 列表查询
///
///
///
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var year = pararms.getExtraInt("SchoolyearDictionaryDropDown");
var CoursesTimeID = pararms.getExtraGuid("TimeComboGrid");
return base.Json(ICourseTimeHoursServices.GetCoursesTimeViewGrid(configuretView, year, CoursesTimeID, (int)pararms.page, (int)pararms.rows));
}
public ActionResult Edit(Guid? CoursesTimeID)
{
CourseTimeHoursView CourseTimeHoursView = new CourseTimeHoursView();
if (CoursesTimeID.HasValue)
{
CourseTimeHoursView = ICourseTimeHoursServices.GetCourseTimeHoursView(CoursesTimeID);
}
return View(CourseTimeHoursView);
}
[HttpPost]
public ActionResult Edit(CourseTimeHoursView CourseTimeHoursView)
{
try
{
ICourseTimeHoursServices.save(CourseTimeHoursView);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存成功!"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "保存失败:" + ex.Message
});
}
}
[HttpPost]
public ActionResult Delete(string ids)
{
try
{
var list = ids.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => Guid.Parse(s)).ToList();
ICourseTimeHoursServices.Delete(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);
}
}
}
}