123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.ViewModel;
- using EMIS.CommonLogic.ScoreManage;
- using EMIS.ViewModel.ScoreManage;
- using EMIS.Entities;
- using Bowin.Web.Controls.Mvc;
- using Bowin.Common.JSON;
- using Bowin.Common.Exceptions;
- namespace EMIS.Web.Controllers.ScoreManage
- {
- [Authorization]
- public class GradePointFormulaController : Controller
- {
- public IGradePointFormulaServices gradePointFormulaServices { get; set; }
- //
- // GET: /GradePointFormula/
- public ActionResult List()
- {
- return View();
- }
- /// <summary>
- /// 绩点公式设置列表
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- string name = pararms.getExtraString("textName");
- return Json(gradePointFormulaServices.GetGradePointFormulaGrid(name, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="gradePointFormulaID"></param>
- /// <returns></returns>
- public ActionResult Edit(Guid? gradePointFormulaID)
- {
- GradePointFormulaView gradePointFormulaView = new GradePointFormulaView();
- if (gradePointFormulaID != null && gradePointFormulaID.Value != Guid.Empty)
- {
- ER_GradePointFormula gradePointFormula = gradePointFormulaServices.GetGradePointFormula(gradePointFormulaID);
- if (gradePointFormula != null)
- {
- gradePointFormulaView.Name = gradePointFormula.Name;
- gradePointFormulaView.GradePointlimit = gradePointFormula.GradePointlimit;
- gradePointFormulaView.GradePointFloor = gradePointFormula.GradePointFloor;
- }
- }
- return View(gradePointFormulaView);
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="gradePointFormulaView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(GradePointFormulaView gradePointFormulaView)
- {
- try
- {
- gradePointFormulaServices.GradePointFormulaAdd(gradePointFormulaView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存失败,原因:" + ex.Message + "!"
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="gradePointFormulaIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string gradePointFormulaIDs)
- {
- try
- {
- List<Guid> list = new List<Guid>();
- for (int i = 0; i < gradePointFormulaIDs.Split(',').Length; i++)
- {
- string id = gradePointFormulaIDs.Split(',')[i];
- if (!string.IsNullOrEmpty(id))
- {
- Guid gradePointFormulaID = new Guid(id);
- list.Add(gradePointFormulaID);
- }
- }
- gradePointFormulaServices.GradePointFormulaDelete(list);
- return 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 this.Json("删除失败,原因:" + mge);
- }
- }
- /// <summary>
- /// 绑定下拉
- /// </summary>
- /// <param name="bindType"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GradePointFormulaDataBind(DropdownListBindType? bindType)
- {
- List<DropdownListItem> list = gradePointFormulaServices.GetGradePointFormulaList("").Select(x => new DropdownListItem { Text = x.Name, Value = x.GradePointFormulaID.ToString() }).ToList();
- DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
- DropdownList.FormatDropdownItemList(dbt, list);
- return base.Json(list);
- }
- /// <summary>
- /// 绑定下拉
- /// </summary>
- /// <param name="bindType"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GradePointFormulaDataJsonBind(DropdownListBindType? bindType)
- {
- List<DropdownListItem> list = gradePointFormulaServices.GetGradePointFormulaList("").Select(x => new DropdownListItem { Text = x.Name, Value = new GradePointView { GradePointFormulaID = x.GradePointFormulaID, Name = x.Name, GradePointlimit = x.GradePointlimit, GradePointFloor = x.GradePointFloor }.ToJson() }).ToList();
- DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
- DropdownList.FormatDropdownItemList(dbt, list);
- return base.Json(list);
- }
- }
- }
|