using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.Web.Controls;
using EMIS.ViewModel;
using EMIS.ViewModel.EvaluationManage;
using Bowin.Common.Exceptions;
using Bowin.Web.Controls.Mvc;
using EMIS.CommonLogic.EvaluationManage;
namespace EMIS.Web.Controllers.EvaluationManage
{
///
/// 教师评价
///
[Authorization]
public class TeacherEvaluationController : Controller
{
public ITeacherEvaluationServices TeacherEvaluationServices { get; set; }
public IEvaluationTypeServices EvaluationTypeServices { get; set; }
public ActionResult List()
{
return View();
}
///
/// 列表查询
///
///
///
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
var configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var schoolYearID = pararms.getExtraGuid("SchoolYearDropdown"); //学年学期
var campusID = pararms.getExtraGuid("CampusDropdown"); //校区
var collegeID = pararms.getExtraGuid("CollegeDropdown"); //院系所
var openStatus = CheckIsSelectAll(pararms.getExtraInt("DictionaryOpenStatus")); //开放状态
var result = TeacherEvaluationServices.GetTeacherEvaluationViewGrid(configuretView, schoolYearID, campusID, collegeID, openStatus, (int)pararms.page, (int)pararms.rows);
return Json(result);
}
public ActionResult Edit(Guid? id)
{
var vm = new TeacherEvaluationView();
if (id != null && id != Guid.Empty)
vm = TeacherEvaluationServices.GetTeacherEvaluationView(id);
var evaluationType = EvaluationTypeServices.GetEvaluationType("学生评");
//var isView = (vm.EntityApprovalStatus.HasValue && vm.EntityApprovalStatus != (int)CF_DifferentDynamicStatus.NotSubmitted) ? true : false;
//ViewBag.IsView = isView;
ViewBag.EvaluationTypeId = evaluationType.EvaluationTypeID;
return View(vm);
}
///
/// 新增或更新
///
///
///
[HttpPost]
public ActionResult Edit(TeacherEvaluationView vm)
{
try
{
TeacherEvaluationServices.AddOrUpdateTeacherEvaluation(vm);
return RedirectToAction("MsgShow", "Common", new
{
msg = "保存成功!",
url = Url.Action("List").AddMenuParameter()
});
}
catch (Exception ex)
{
return RedirectToAction("MsgShow", "Common", new
{
msg = "保存失败!" + ex.Message,
url = Url.Action("List").AddMenuParameter()
});
}
}
///
/// 删除
///
///
///
[HttpPost]
public ActionResult Delete(string ids)
{
try
{
var list = ids.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => Guid.Parse(s)).ToList();
TeacherEvaluationServices.DeleteTeacherEvaluation(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 = "请先删除所有关联的数据,如:专业计划、选修计划等!";
mge = "请先删除所有关联的数据!";
}
return base.Json("删除失败,原因:" + mge);
}
}
///
/// 添加更新前验证
///
///
///
///
[HttpPost]
public ActionResult Verification(Guid? id, Guid? educationMissionClassID, Guid? tableID)
{
if (id.HasValue && id != Guid.Empty) //编辑状态
{
}
else //新增状态
{
}
return Json("成功");
}
protected static int? CheckIsSelectAll(int? argment)
{
return argment == DropdownList.SELECT_ALL ? null : argment;
}
}
}