예제 #1
0
        /// <summary>
        /// 查看详细
        /// </summary> SMLOGService.AddEntity
        /// <param name="id"></param>
        /// <returns></returns>
        //[SupportFilter]
        public ActionResult Details(int id)
        {
            SMMENUTB item = SMMENUTBService.LoadEntities(m => m.ID == id).FirstOrDefault();

            item.STATE = item.STATE == "Y" ? "启用" : "禁用";

            return(View(item));
        }
        //[SupportFilter]
        public ActionResult Delete(FormCollection collection)
        {
            string     returnValue = string.Empty;
            List <int> lists       = collection["query"].GetString().ToIntList();

            int[] deleteIds = lists.ToArray();

            if (deleteIds != null && deleteIds.Length > 0)
            {
                SMLOG OperLog = new SMLOG {
                    OPERATION_TYPE = "D", FUNC_CODE = "900003", USER_ID = UserId, CLASSNAME = ClassName + strDelete
                };

                if (deleteIds.Length == 1)
                {
                    int menuId = deleteIds[0];
                    var entity = SMMENUTBService.LoadEntities(m => m.ID == menuId).FirstOrDefault();
                    if (SMMENUTBService.Delete(entity))
                    {
                        OperLog.REMARK = "菜单Id:" + deleteIds[0] + Suggestion.DeleteSucceed;
                        SMLOGService.AddEntity(OperLog);//写入日志

                        return(Json("OK"));
                    }
                    else
                    {
                        OperLog.REMARK = "菜单Id:" + deleteIds[0] + Suggestion.DeleteSucceed;
                    }
                    SMLOGService.AddEntity(OperLog);//写入日志
                }

                #region 批量删除

                //if (_menuService.DeleteCollection(ref validationErrors, deleteIds))
                //{
                //    OperLog.REMARK = "菜单信息的Id:" + string.Join(",", deleteIds) + Suggestion.DeleteSucceed;
                //    SMLOGService.AddEntity(OperLog);//写入日志

                //    return Json("OK");
                //}
                //else
                //{
                //    if (validationErrors != null && validationErrors.Count > 0)
                //    {
                //        validationErrors.All(a =>
                //        {
                //            returnValue += a.ErrorMessage;
                //            return true;
                //        });
                //    }
                //    OperLog.REMARK = "菜单信息的Id:" + string.Join(",", deleteIds) + Suggestion.DeleteFail + " " + returnValue;
                //    SMLOGService.AddEntity(OperLog);//写入日志
                //}
                #endregion
            }
            return(Json(returnValue));
        }
        /// <summary>
        /// 首次创建
        /// </summary>
        /// <returns></returns>
        public ActionResult Create(int?id)
        {
            if (id != null)
            {
                SMMENUTB entityId = SMMENUTBService.LoadEntities(m => m.ID == id).FirstOrDefault();
                if (entityId != null)
                {
                    SMFUNCTB entity = new SMFUNCTB();
                    entity.SysMenuId = id + '&' + entityId.NAME;
                    return(View(entity));
                }
            }

            return(View());
        }
        /// <summary>
        /// 首次编辑
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        //[SupportFilter]
        public ActionResult Edit(int id)
        {
            SMMENUTB item = SMMENUTBService.LoadEntities(m => m.ID == id).FirstOrDefault();

            return(View(item));
        }