123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Bowin.Web.Controls.Mvc;
- using EMIS.Utility;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.ViewModel.CalendarManage;
- using EMIS.Entities;
- using Bowin.Common.Exceptions;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- namespace EMIS.Web.Controllers.CalendarManage
- {
- [Authorization]
- public class SCalendarController : Controller
- {
- public ISCalendarServices SCalendarServices { 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);
- var activitiesType = pararms.getExtraInt("ActivitiesTypeDropdown");
- var timesSegment = pararms.getExtraInt("TimesSegmentDropdown");
- return base.Json(SCalendarServices.GetSCalendarViewGrid(configuretView, activitiesType, timesSegment, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 编辑页面
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? activitiesID)
- {
- SCalendarView scalendarView = new SCalendarView();
- if (activitiesID != null && activitiesID != Guid.Empty)
- scalendarView = SCalendarServices.GetSCalendarView(activitiesID);
- return View(scalendarView);
- }
- /// <summary>
- /// 新增或更新
- /// </summary>
- /// <param name="scalendarView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(SCalendarView scalendarView)
- {
- try
- {
- if (!scalendarView.ActivitiesID.HasValue || scalendarView.ActivitiesID == Guid.Empty)
- {
- SCalendarServices.SCalendarAdd(scalendarView);
- }
- else
- {
- SCalendarServices.SCalendarUpdate(scalendarView);
- }
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="activitiesIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string activitiesIDs)
- {
- try
- {
- List<Guid> list = new List<Guid>();
- for (int i = 0; i < activitiesIDs.Split(',').Length; i++)
- {
- string id = activitiesIDs.Split(',')[i];
- if (!string.IsNullOrEmpty(id))
- {
- Guid activitiesID = new Guid(id);
- list.Add(activitiesID);
- }
- }
- SCalendarServices.SCalendarDelete(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>
- /// 导出Excel
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- try
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var activitiesType = Request.Form["ActivitiesTypeDropdown"].ParseStrTo<int>();
- var timesSegment = Request.Form["TimesSegmentDropdown"].ParseStrTo<int>();
- var dt = SCalendarServices.GetSCalendarViewList(configuretView, activitiesType, timesSegment).Select(x => new
- {
- x.Name,
- ActivitiesTime = x.ActivitiesTime.Value.ToString("yyyy-MM-dd"),
- x.TimesSegmentName,
- x.ActivitiesTypeName,
- x.ActivitiesContent
- }).ToTable();
- string[] liststring = { "活动名称", "活动日期", "时间段", "活动类型", "活动内容" };
- neh.Export(dt, liststring, "校历管理信息");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/SCalendar/List").AddMenuParameter()
- });
- }
- catch (Exception ex)
- {
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出失败,原因:" + ex.Message + "!",
- url = Url.Content("~/SCalendar/List").AddMenuParameter()
- });
- }
- }
- }
- }
|