123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.ViewModel;
- using EMIS.ViewModel.ChargeManage.ChargeSituation;
- using EMIS.CommonLogic.ChargeManage.ChargeSituation;
- using EMIS.Web.Controls;
- using Bowin.Common.Exceptions;
- using Bowin.Common.Utility;
- using Bowin.Web.Controls.Mvc;
- using Bowin.Common.Data;
- using EMIS.Utility;
- namespace EMIS.Web.Controllers.ChargeManage.ChargeSituation
- {
- [Authorization]
- public class ChargeProjectController : Controller
- {
- public IChargeProjectServices ChargeProjectService { 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);
- return base.Json(ChargeProjectService.GetChargeProjectViewGrid(configuretView,(int)pararms.page, (int)pararms.rows));
-
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="chargeProjectID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? chargeProjectID)
- {
- ChargeProjectView chargeProjectView = new ChargeProjectView();
- if (chargeProjectID.HasValue && chargeProjectID != Guid.Empty)
- {
- chargeProjectView = ChargeProjectService.GetChargeProjectView(chargeProjectID);
- }
- return View(chargeProjectView);
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="chargeProjectView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(ChargeProjectView chargeProjectView)
- {
- try
- {
- ChargeProjectService.ChargeProjectAdd(chargeProjectView);
-
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message + "。"
- });
- }
- }
- /// <summary>
- /// 详情页面
- /// </summary>
- /// <param name="chargeProjectID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Details(Guid? chargeProjectID)
- {
- ChargeProjectView chargeProjectView = new ChargeProjectView();
- if (chargeProjectID.HasValue && chargeProjectID != Guid.Empty)
- {
- chargeProjectView = ChargeProjectService.GetChargeProjectDetailsView(chargeProjectID);
- }
- return View(chargeProjectView);
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="ChargeProjectIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string ChargeProjectIDs)
- {
- try
- {
- List<Guid> list = new List<Guid>();
- for (int i = 0; i < ChargeProjectIDs.Split(',').Length; i++)
- {
- string id = ChargeProjectIDs.Split(',')[i];
- if (!string.IsNullOrEmpty(id))
- {
- Guid chargeProjectID = new Guid(id);
- list.Add(chargeProjectID);
- }
- }
- ChargeProjectService.ChargeProjectDelete(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="chargeProjectID"></param>
- /// <param name="chrageProjectName"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Verification(Guid? chargeProjectID, string chrageProjectName)
- {
- return Json(ChargeProjectService.GetVerification(chargeProjectID, chrageProjectName));
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel(ChargeProjectView pararms)
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var dt = ChargeProjectService.GetChargeProjectViewList(configuretView).Select(x => new
- {
- x.ChrageProjectName,
- x.Remark
- }).ToTable();
- string[] liststring = { "收费项目", "备注" };
- neh.Export(dt, liststring, "收费项目信息" + DateTime.Now.ToString("yyyyMMdd"));
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功。"
- });
- }
- }
- }
|