123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- 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.Entities;
- using EMIS.ViewModel.ScoreManage;
- using Bowin.Web.Controls.Mvc;
- using Bowin.Common.JSON;
- using Bowin.Common.Exceptions;
- namespace EMIS.Web.Controllers.ScoreManage
- {
- [Authorization]
- public class CreditFormulaController : Controller
- {
- public ICreditFormulaServices creditFormulaServices { get; set; }
- //
- // GET: /CreditFormula/
- public ActionResult List()
- {
- return View();
- }
- /// <summary>
- /// 查询列表
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- string name = pararms.getExtraString("textName");
- return Json(creditFormulaServices.GetCreditFormulaGrid(name, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="creditFormulaID"></param>
- /// <returns></returns>
- public ActionResult Edit(Guid? creditFormulaID)
- {
- CreditFormulaView creditFormulaView = new CreditFormulaView();
- if (creditFormulaID != null && creditFormulaID.Value != Guid.Empty)
- {
- ER_CreditFormula creditFormula = creditFormulaServices.GetCreditFormula(creditFormulaID);
- creditFormulaView.CreditFormulaID = creditFormula.CreditFormulaID;
- creditFormulaView.Name = creditFormula.Name;
- creditFormulaView.Scores = creditFormula.Scores;
- }
- return View(creditFormulaView);
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="creditFormula"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(CreditFormulaView creditFormulaView)
- {
- try
- {
- creditFormulaServices.CreditFormulaAdd(creditFormulaView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存失败,原因:" + ex.Message + "!"
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="creditFormulas"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string creditFormulaIDs)
- {
- try
- {
- List<Guid> list = new List<Guid>();
- for (int i = 0; i < creditFormulaIDs.Split(',').Length; i++)
- {
- string id = creditFormulaIDs.Split(',')[i];
- if (!string.IsNullOrEmpty(id))
- {
- Guid creditFormulaID = new Guid(id);
- list.Add(creditFormulaID);
- }
- }
- creditFormulaServices.CreditFormulaDelete(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 CreditFormulaDataBind(DropdownListBindType? bindType)
- {
- List<DropdownListItem> list = creditFormulaServices.GetCreditFormulaList("").Select(x => new DropdownListItem { Text = x.Name, Value = x.CreditFormulaID.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 CreditFormulaDataJsonBind(DropdownListBindType? bindType)
- {
- List<DropdownListItem> list = creditFormulaServices.GetCreditFormulaList("").Select(x => new DropdownListItem { Text = x.Name, Value = new ER_CreditFormula { CreditFormulaID = x.CreditFormulaID, Name = x.Name, Scores = x.Scores }.ToJson() }).ToList();
- DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
- DropdownList.FormatDropdownItemList(dbt, list);
- return base.Json(list);
- }
- }
- }
|