Esempio n. 1
0
 public void SubmitForm(SpecialEntity specialEntity, string keyValue)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         if (service.IQueryable().Count(t => t.F_EnCode.Equals(specialEntity.F_EnCode) &&
                                        !t.F_Id.Equals(keyValue)) > 0)
         {
             throw new Exception("修改失败!操作的对象编号已存在。");
         }
         specialEntity.Modify(keyValue);
         service.Update(specialEntity);
     }
     else
     {
         if (service.IQueryable().Count(t => t.F_EnCode.Equals(specialEntity.F_EnCode)) > 0)
         {
             throw new Exception("添加失败!操作的对象编号已存在。");
         }
         if (specialEntity.F_DeleteMark == null)
         {
             specialEntity.F_DeleteMark = false;
         }
         specialEntity.Create();
         service.Insert(specialEntity);
     }
 }
Esempio n. 2
0
        public ActionResult List(string id, int pageIndex = 1)
        {
            SpecialEntity entity = specialApp.GetEntityByEnCode(id, a => a.F_EnabledMark == true);

            if (entity == null || !Validate.IsGuid(entity.F_Id))
            {
                return(RedirectToAction("index", "Specials"));
            }
            ViewBag.entity = entity;
            return(View());
        }
Esempio n. 3
0
 public void ChildSubList(List <SpecialEntity> List, SpecialEntity entity)
 {
     foreach (SpecialEntity item in List)
     {
         if ((item.F_ParentId + "").ToLower() == entity.F_Id.ToLower())
         {
             entity.subList.Add(item);
             ChildSubList(List, item);
         }
     }
 }
Esempio n. 4
0
        public override RouteData GetRouteData(HttpContextBase httpContext)
        {
            var virtualPath = httpContext.Request.AppRelativeCurrentExecutionFilePath + httpContext.Request.PathInfo;//获取相对路径

            //~/zt   /mingren    /pagr-2
            virtualPath = virtualPath.Substring(2).Trim('/');
            if (!Validate.IsSpecialUrl(virtualPath))
            {
                return(null);
            }
            string[] virtualPathStr = virtualPath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            var      PageIndex = "1"; var ztId = "";

            if (virtualPathStr.Length == 1)
            {
                var data = new RouteData(this, new MvcRouteHandler());//声明一个RouteData,添加相应的路由值
                data.Values.Add("controller", "Specials");
                data.Values.Add("action", "index");
                return(data);
            }
            else if (virtualPathStr.Length == 3 || virtualPathStr.Length == 2)
            {
                if (virtualPathStr.Length == 3)
                {
                    ztId      = virtualPathStr[1];
                    PageIndex = virtualPathStr[2].Split('-').Last();
                }
                else if (virtualPathStr.Length == 2)
                {
                    ztId = virtualPathStr[1];
                }
                SpecialEntity entity = specialApp.GetEntityByEnCode(ztId, a => a.F_EnabledMark == true);
                if (entity == null || !Validate.IsGuid(entity.F_Id))
                {
                    throw new ArgumentNullException("Specials");
                }

                var data = new RouteData(this, new MvcRouteHandler());//声明一个RouteData,添加相应的路由值
                data.Values.Add("controller", "Specials");
                data.Values.Add("action", "list");
                data.Values.Add("id", entity.F_EnCode);
                data.Values.Add("pageIndex", PageIndex);
                return(data);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 5
0
        public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
        {
            var ztId = values["id"] as string;
            var Page = values["pageIndex"];

            if (values["pageIndex"] != null)
            {
                Page = values["pageIndex"].ToString();
            }
            if (Page == null)
            {
                Page = "1";
            }
            if (!values.ContainsKey("controller") || !values["controller"].ToString().Equals("Specials", StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }
            if (!values.ContainsKey("action") ||
                (!values["action"].ToString().Equals("Index", StringComparison.OrdinalIgnoreCase) &&
                 !values["action"].ToString().Equals("List", StringComparison.OrdinalIgnoreCase)))
            {
                return(null);
            }

            if (!string.IsNullOrEmpty(ztId))
            {
                SpecialEntity specialEntity = specialApp.GetEntityByEnCode(ztId, a => a.F_EnabledMark == true);
                if (specialEntity == null || !Validate.IsGuid(specialEntity.F_Id))
                {
                    throw new ArgumentNullException("Specials");
                }
                var path = "zt/" + specialEntity.F_EnCode;
                if (Page + "" != "1")
                {
                    path = path + "/page-" + Page;
                }
                return(new VirtualPathData(this, path.ToLowerInvariant()));
            }
            else
            {
                var path = "zt";
                return(new VirtualPathData(this, path.ToLowerInvariant()));
            }
        }
Esempio n. 6
0
 public ActionResult SubmitForm(SpecialEntity specialEntity, string keyValue)
 {
     specialApp.SubmitForm(specialEntity, keyValue);
     return(Success("操作成功。"));
 }