123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Central.Control.Domain;
- using MES.Production.Service.IService;
- using Ant.Service.Common;
- using Ant.Service.Common.Enums;
- using ChangFa.Machinery.WebPage.Controllers;
- namespace ChangFa.Machinery.WebPage.Areas.ComManage.Controllers
- {
- /// <summary>
- /// 快速导航控制器
- /// </summary>
- public class WinIndexController : BaseController
- {
- #region 声明容器
- /// <summary>
- /// 快速导航
- /// </summary>
- IWinIndexManage WinIndexManage { get; set; }
- #endregion
- #region 公共变量
- #endregion
- #region 基本视图
- /// <summary>
- /// 快速导航列表
- /// </summary>
- public ActionResult Index()
- {
- var result = this.WinIndexManage.LoadAll(null).OrderBy(p => p.SHOWORDER).ToList();
- return View(result);
- }
- /// <summary>
- /// 详情
- /// </summary>
- public ActionResult Detail(string id)
- {
- var entity = this.WinIndexManage.Get(p => p.ID == id) ?? new COM_INDEX();
- return View(entity);
- }
- /// <summary>
- /// 保存
- /// </summary>
- public ActionResult Save(COM_INDEX entity)
- {
- var json = new JsonHelper() { Status = "n", Msg = "保存成功" };
- bool isEdit = true;
- if (entity != null)
- {
- entity.COLOR = Request["COLOR"] ?? "";
- entity.BACKGROUNDCOLOR = Request["BACKGROUNDCOLOR"] ?? "";
- var _entity = new COM_INDEX();
- _entity = entity;
- //添加
- if (string.IsNullOrEmpty(entity.ID))
- {
- _entity.ID = Guid.NewGuid().ToString();
- isEdit = false;
- }
- //判断是否重名
- if (!this.WinIndexManage.IsExist(p => p.TITLE == _entity.TITLE && p.ID != _entity.ID))
- {
- if (this.WinIndexManage.SaveOrUpdate(entity, isEdit))
- {
- json.Status = "y";
- }
- else
- {
- json.Msg = "保存失败";
- }
- }
- else
- {
- json.Msg = "导航" + _entity.TITLE + "已存在,不能重复添加";
- }
- }
- else
- {
- json.Msg = "未找到需要保存的记录";
- }
- return Json(json);
- }
- /// <summary>
- /// 移除
- /// </summary>
- public ActionResult Delete(string idlist)
- {
- var json = new JsonHelper() { Msg = "删除成功", Status = "n" };
- try
- {
- if (!string.IsNullOrEmpty(idlist))
- {
- var idlist1 = idlist.Trim(',').Split(',').ToList();
- this.WinIndexManage.Delete(p => idlist1.Contains(p.ID));
- json.Status = "y";
- }
- else
- {
- json.Msg = "未找到要删除的记录";
- }
- WriteLog(enumOperator.Remove, "删除快速导航,结果:" + json.Msg,enumLog4net.WARN);
- }
- catch (Exception e) { WriteLog(enumOperator.Remove, "删除快速导航出现异常", e); }
- return Json(json);
- }
- #endregion
- #region 其他调用
- /// <summary>
- /// 首页快速导航按钮
- /// </summary>
- public ActionResult GetCenterIndex()
- {
- var json = new JsonHelper() { Status = "n" };
- var num = (Request["num"] ?? "") == "" ? 5 : int.Parse(Request["num"].ToString());
- try
- {
- json.Data = this.WinIndexManage.LoadAll(null).OrderBy(p => p.SHOWORDER).Take(num).ToList();
- json.Status = "y";
- }
- catch { }
- return Json(json);
- }
- #endregion
- #region 帮助方法
- #endregion
- }
- }
|