Пример #1
0
        public bool Delete(PathNode pathNode, string strResult)
        {
            strResult = string.Empty;
            bool result = false;
            var  p      = PathNodeRepository.GetQueryable().FirstOrDefault(pn => pn.ID == pathNode.ID);

            if (p != null)
            {
                try
                {
                    PathNodeRepository.Delete(p);
                    PathNodeRepository.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    strResult = "原因:已在使用";
                }
            }
            else
            {
                strResult = "原因:未找到当前需要删除的数据!";
            }
            return(result);
        }
Пример #2
0
        public object GetPathNode(int page, int rows, string queryString, string value)
        {
            string id = "", PathID = "";

            if (queryString == "ID")
            {
                id = value;
            }
            else
            {
                PathID = value;
            }
            IQueryable <PathNode> PathNodeQuery = PathNodeRepository.GetQueryable();
            int Id       = Convert.ToInt32(id);
            var PathNode = PathNodeQuery.Where(p => p.ID == Id)
                           .OrderBy(p => p.ID).AsEnumerable().
                           Select(p => new
            {
                p.ID,
                p.PathID,
                p.PositionID,
                p.PathNodeOrder,
            });
            int total = PathNode.Count();

            PathNode = PathNode.Skip((page - 1) * rows).Take(rows);
            return(new { total, rows = PathNode.ToArray() });
        }
Пример #3
0
        public object GetDetails(int page, int rows, PathNode pathNode)
        {
            //引入表
            IQueryable <PathNode> pathNodeQuery = PathNodeRepository.GetQueryable();
            IQueryable <Path>     pathQuery     = PathRepository.GetQueryable();
            IQueryable <Position> positionQuery = PositionRepository.GetQueryable();
            //关联表
            var pathNodeDetail = pathNodeQuery.Join(pathQuery,
                                                    pn => pn.PathID,
                                                    p => p.ID,
                                                    (pn, p) => new { pn.ID, pn.PathID, pn.PositionID, pn.PathNodeOrder, p.PathName })
                                 .Join(positionQuery,
                                       pn => pn.PositionID,
                                       p => p.ID,
                                       (pn, p) => new { pn.ID, pn.PathID, pn.PositionID, pn.PathNodeOrder, pn.PathName, p.PositionName })
                                 //.Where(p => p.PathName.Contains(PathName) && p.PositionName.Contains(PositionName))
                                 .OrderBy(p => p.ID);
            int total           = pathNodeDetail.Count();
            var pathNodeDetails = pathNodeDetail.Skip((page - 1) * rows).Take(rows);
            var pathNode_Detail = pathNodeDetails.ToArray().Select(p => new
            {
                p.ID,
                p.PathID,
                p.PathName,
                p.PositionID,
                p.PositionName,
                p.PathNodeOrder,
            });

            return(new { total, rows = pathNode_Detail.ToArray() });
        }
Пример #4
0
        public bool Save(PathNode pathNode, string strResult)
        {
            strResult = string.Empty;
            bool result = false;
            var  p      = PathNodeRepository.GetQueryable().FirstOrDefault(pn => pn.ID == pathNode.ID);

            if (p != null)
            {
                try
                {
                    p.PathID        = pathNode.PathID;
                    p.PositionID    = pathNode.PositionID;
                    p.PathNodeOrder = pathNode.PathNodeOrder;

                    PathNodeRepository.SaveChanges();
                    result = true;
                }
                catch (Exception ex)
                {
                    strResult = "原因:" + ex.Message;
                }
            }
            else
            {
                strResult = "原因:未找到当前需要修改的数据!";
            }
            return(result);
        }
Пример #5
0
        public System.Data.DataTable GetPathNode(int page, int rows, string id)
        {
            int t = -1;

            IQueryable <PathNode> pathNodeQuery = PathNodeRepository.GetQueryable();
            IQueryable <Path>     pathQuery     = PathRepository.GetQueryable();
            IQueryable <Position> positionQuery = PositionRepository.GetQueryable();

            var pathNode = pathNodeQuery.Join(pathQuery,
                                              pn => pn.PathID,
                                              p => p.ID,
                                              (pn, p) => new { pn.ID, pn.PathID, pn.PositionID, pn.PathNodeOrder, PathName = p.PathName })
                           .Join(positionQuery,
                                 pn => pn.PositionID,
                                 p => p.ID,
                                 (pn, p) => new { pn.ID, pn.PathID, pn.PositionID, pn.PathNodeOrder, pn.PathName, PositionName = p.PositionName })
                           //.Where(p => p.ID == PathID)
                           //  .Where(p => p.ID == t)
                           .OrderBy(p => p.ID).AsEnumerable()
                           .Select(p => new
            {
                p.ID,
                p.PathName,
                p.PositionName,
                p.PathNodeOrder,
            });

            try { t = Convert.ToInt32(id); }
            catch { t = -1; }
            finally
            {
                pathNode = pathNode.Where(p => p.ID == t)
                           .OrderBy(p => p.ID).AsEnumerable()
                           .Select(p => new
                {
                    p.ID,
                    p.PathName,
                    p.PositionName,
                    p.PathNodeOrder,
                });
            }
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("ID", typeof(string));
            dt.Columns.Add("路径名称", typeof(string));
            dt.Columns.Add("位置名称", typeof(string));
            dt.Columns.Add("路径节点顺序", typeof(string));
            foreach (var item in pathNode)
            {
                dt.Rows.Add
                (
                    item.ID,
                    item.PathName,
                    item.PositionName,
                    item.PathNodeOrder
                );
            }
            return(dt);
        }
Пример #6
0
        public bool Delete(int regionId)
        {
            var reg      = RegionRepository.GetQueryable().FirstOrDefault(s => s.ID == regionId);
            var position = PositionRepository.GetQueryable().FirstOrDefault(p => p.RegionID == regionId);
            var path     = PathRepository.GetQueryable().FirstOrDefault(pa => pa.TargetRegionID == regionId);
            var path1    = PathRepository.GetQueryable().FirstOrDefault(pa => pa.OriginRegionID == regionId);



            if (reg != null)
            {
                try
                {
                    if (position != null)
                    {
                        PositionRepository.Delete(position);
                        PositionRepository.SaveChanges();
                    }
                    if (path != null)
                    {
                        var pathNode = PathNodeRepository.GetQueryable().FirstOrDefault(p => p.PathID == path.ID);
                        if (pathNode != null)
                        {
                            PathNodeRepository.Delete(pathNode);
                            PathNodeRepository.SaveChanges();
                        }
                        PathRepository.Delete(path);
                        PathRepository.SaveChanges();
                    }
                    if (path1 != null)
                    {
                        var pathNode1 = PathNodeRepository.GetQueryable().FirstOrDefault(p => p.PathID == path1.ID);
                        if (pathNode1 != null)
                        {
                            PathNodeRepository.Delete(pathNode1);
                            PathNodeRepository.SaveChanges();
                        }
                        PathRepository.Delete(path1);
                        PathRepository.SaveChanges();
                    }
                    RegionRepository.Delete(reg);
                    RegionRepository.SaveChanges();
                }

                catch (Exception e)
                {
                }
            }
            else
            {
                return(false);
            }
            return(true);
        }
Пример #7
0
        public bool Save(PathNode pathNode)
        {
            IQueryable <Position> PositionQuery = PositionRepository.GetQueryable();
            var Position = PositionQuery.FirstOrDefault(p => p.ID == pathNode.PositionID);
            var PathNode = PathNodeRepository.GetQueryable().FirstOrDefault(pn => pn.ID == pathNode.ID);

            PathNode.PositionID    = pathNode.PositionID;
            PathNode.Position      = Position;
            PathNode.PathNodeOrder = pathNode.PathNodeOrder;
            PathNodeRepository.SaveChanges();
            return(true);
        }
Пример #8
0
        public object GetDetails(int page, int rows, string PathName, string PositionName, string PathNodeOrder)
        {
            //引入表
            IQueryable <PathNode> pathNodeQuery = PathNodeRepository.GetQueryable();
            IQueryable <Path>     pathQuery     = PathRepository.GetQueryable();
            IQueryable <Position> positionQuery = PositionRepository.GetQueryable();
            //关联表
            var pathNode = pathNodeQuery.Join(pathQuery,
                                              pn => pn.PathID,
                                              p => p.ID,
                                              (pn, p) => new { pn.ID, pn.PathID, pn.PositionID, pn.PathNodeOrder, p.PathName })
                           .Join(positionQuery,
                                 pn => pn.PositionID,
                                 p => p.ID,
                                 (pn, p) => new { pn.ID, pn.PathID, pn.PositionID, pn.PathNodeOrder, pn.PathName, p.PositionName })
                           .Where(p => p.PathName.Contains(PathName) && p.PositionName.Contains(PositionName))
                           .OrderBy(p => p.ID).AsEnumerable()
                           .Select(p => new
            {
                p.ID,
                p.PathID,
                p.PathName,
                p.PositionID,
                p.PositionName,
                p.PathNodeOrder,
            });
            int Order = -1;

            if (PathNodeOrder != "" && PathNodeOrder != null)
            {
                try { Order = Convert.ToInt32(PathNodeOrder); }
                catch { Order = -1; }
                finally {
                    pathNode = pathNode.Where(p => p.PathNodeOrder == Order)
                               .OrderBy(p => p.ID).AsEnumerable()
                               .Select(p => new
                    {
                        p.ID,
                        p.PathID,
                        p.PathName,
                        p.PositionID,
                        p.PositionName,
                        p.PathNodeOrder,
                    });
                }
            }
            int total = pathNode.Count();

            pathNode = pathNode.Skip((page - 1) * rows).Take(rows);
            return(new { total, rows = pathNode.ToArray() });
        }
Пример #9
0
        public bool Delete(PathNode pathNode)
        {
            var p = PathNodeRepository.GetQueryable().FirstOrDefault(pn => pn.ID == pathNode.ID);

            if (p != null)
            {
                PathNodeRepository.Delete(p);
                PathNodeRepository.SaveChanges();
            }
            else
            {
                return(false);
            }
            return(true);
        }
Пример #10
0
        public object GetDetails(string PathId)
        {
            IQueryable <PathNode> PathNodeQuery = PathNodeRepository.GetQueryable();
            int Path_ID  = Convert.ToInt32(PathId);
            var PathNode = PathNodeQuery.Where(p => p.PathID == Path_ID)
                           .OrderBy(p => p.PathNodeOrder).
                           Select(p => new
            {
                p.ID,
                p.PathID,
                p.Path.PathName,
                p.PositionID,
                p.Position.PositionName,
                p.PathNodeOrder
            });

            return(PathNode.ToArray());
        }
Пример #11
0
        public bool Delete(int pathId)
        {
            var pa       = PathRepository.GetQueryable().FirstOrDefault(p => p.ID == pathId);
            var pathnode = PathNodeRepository.GetQueryable().FirstOrDefault(p => p.PathID == pathId);

            if (pa != null)
            {
                PathNodeRepository.Delete(pathnode);
                PathNodeRepository.SaveChanges();

                PathRepository.Delete(pa);
                PathRepository.SaveChanges();
            }
            else
            {
                return(false);
            }
            return(true);
        }