Example #1
0
        /// <summary>
        /// 根据仓库编码获取生成的库区编码
        /// </summary>
        /// <param name="wareCode">仓库编码</param>
        /// <returns></returns>
        public object GetAreaCode(string wareCode)
        {
            string areaCodeStr = "";
            IQueryable <CMD_AREA> areaQuery = CMDAreaRepository.GetQueryable();
            var areaCode = areaQuery.Where(a => a.WAREHOUSE_CODE == wareCode).Max(a => a.AREA_CODE);

            if (areaCode == string.Empty || areaCode == null)
            {
                areaCodeStr = wareCode + "-01";
            }
            else
            {
                int i = Convert.ToInt32(areaCode.ToString().Substring(wareCode.Length, 2));
                i++;
                string newcode = i.ToString();
                if (newcode.Length <= 2)
                {
                    for (int j = 0; j < 2 - i.ToString().Length; j++)
                    {
                        newcode = "0" + newcode;
                    }
                    areaCodeStr = wareCode + "-" + newcode;
                }
            }
            return(areaCodeStr);
        }
Example #2
0
        public object GetWareArea()
        {
            var            warehouses = CMDWarehouseRepository.GetQueryable().AsEnumerable();
            HashSet <Tree> wareSet    = new HashSet <Tree>();

            foreach (var warehouse in warehouses)//仓库
            {
                Tree wareTree = new Tree();
                wareTree.id         = warehouse.WAREHOUSE_CODE;
                wareTree.text       = "仓库:" + warehouse.WAREHOUSE_CODE;
                wareTree.state      = "open";
                wareTree.attributes = "ware";

                var areas = CMDAreaRepository.GetQueryable().Where(a => a.CMD_WAREHOUSE.WAREHOUSE_CODE == warehouse.WAREHOUSE_CODE)
                            .OrderBy(a => a.AREA_CODE).Select(a => a);
                HashSet <Tree> areaSet = new HashSet <Tree>();
                foreach (var area in areas)//库区
                {
                    Tree areaTree = new Tree();
                    areaTree.id         = area.AREA_CODE;
                    areaTree.text       = "库区:" + area.AREA_NAME;
                    areaTree.state      = "open";
                    areaTree.attributes = "area";
                    areaSet.Add(areaTree);
                }
                wareTree.children = areaSet.ToArray();
                wareSet.Add(wareTree);
            }
            return(wareSet.ToArray());
        }
Example #3
0
        /// <summary>
        /// 查询参数Code查询库区信息
        /// </summary>
        /// <param name="areaCode">库区Code</param>
        /// <returns></returns>
        public object FindArea(string areaCode)
        {
            IQueryable <CMD_AREA> areaQuery = CMDAreaRepository.GetQueryable();
            var area = areaQuery.Where(a => a.AREA_CODE == areaCode).OrderBy(b => b.AREA_CODE).AsEnumerable().Select(b => new { b.AREA_CODE, b.AREA_NAME, b.WAREHOUSE_CODE, b.MEMO });

            return(area.First(a => a.AREA_CODE == areaCode));
        }
Example #4
0
        public bool Save(CMD_AREA area)
        {
            var areaSave  = CMDAreaRepository.GetQueryable().FirstOrDefault(a => a.AREA_CODE == area.AREA_CODE);
            var warehouse = CMDWarehouseRepository.GetQueryable().FirstOrDefault(w => w.WAREHOUSE_CODE == area.WAREHOUSE_CODE);

            areaSave.AREA_CODE      = area.AREA_CODE;
            areaSave.AREA_NAME      = area.AREA_NAME;
            areaSave.WAREHOUSE_CODE = area.WAREHOUSE_CODE;
            areaSave.MEMO           = area.MEMO;

            CMDAreaRepository.SaveChanges();
            return(true);
        }
Example #5
0
        public object GetDetails(string warehouseCode, string areaCode)
        {
            IQueryable <CMD_AREA> areaQuery = CMDAreaRepository.GetQueryable();
            var area = areaQuery.OrderBy(b => b.AREA_CODE).AsEnumerable().Select(b => new { b.AREA_CODE, b.AREA_NAME, b.WAREHOUSE_CODE, b.MEMO });

            if (warehouseCode != null && warehouseCode != string.Empty)
            {
                area = area.Where(a => a.WAREHOUSE_CODE == warehouseCode).OrderBy(a => a.AREA_CODE).Select(a => a);
            }
            if (areaCode != null && areaCode != string.Empty)
            {
                area = area.Where(a => a.AREA_CODE == areaCode).OrderBy(a => a.AREA_CODE).Select(a => a);
            }
            return(area.ToArray());
        }
Example #6
0
        public bool Delete(string areaCode)
        {
            var area = CMDAreaRepository.GetQueryable()
                       .FirstOrDefault(a => a.AREA_CODE == areaCode);

            if (area != null)
            {
                CMDAreaRepository.Delete(area);
                CMDAreaRepository.SaveChanges();
            }
            else
            {
                return(false);
            }
            return(true);
        }
Example #7
0
        public object GetDetail(string type, string id)
        {
            IQueryable <CMD_AREA>  areaQuery  = CMDAreaRepository.GetQueryable();
            IQueryable <CMD_SHELF> shelfQuery = CMDShelfRepository.GetQueryable();
            IQueryable <CMD_CELL>  cellQuery  = CMDCellRepository.GetQueryable();
            var area = areaQuery.OrderBy(b => b.AREA_CODE).AsEnumerable().Select(b => new { b.AREA_CODE, b.AREA_NAME, b.WAREHOUSE_CODE, b.MEMO });

            if (type == "shelf")
            {
                var areaCode = shelfQuery.Where(s => s.SHELF_CODE == id).Select(s => new{ s.AREA_CODE }).ToArray();
                area = area.Where(a => a.AREA_CODE == areaCode[0].AREA_CODE);
            }
            else if (type == "cell")
            {
                var areaCode = cellQuery.Where(c => c.CELL_CODE == id).Select(c => new { c.AREA_CODE }).ToArray();
                area = area.Where(a => a.AREA_CODE == areaCode[0].AREA_CODE);
            }
            else if (type == "area")
            {
                area = area.Where(a => a.AREA_CODE == id);
            }
            return(area.ToArray());
        }
Example #8
0
        public object GetDetail(int page, int rows, string type, string id)
        {
            IQueryable <CMD_WAREHOUSE> wareQuery  = CMDWarehouseRepository.GetQueryable();
            IQueryable <CMD_SHELF>     shelfQuery = CMDShelfRepository.GetQueryable();
            IQueryable <CMD_AREA>      areaQuery  = CMDAreaRepository.GetQueryable();
            IQueryable <CMD_CELL>      cellQuery  = CMDCellRepository.GetQueryable();
            var warehouse = wareQuery.OrderBy(b => b.WAREHOUSE_CODE).AsEnumerable().Select(b => new { b.WAREHOUSE_CODE });

            if (type == "ware")
            {
                warehouse = warehouse.Where(w => w.WAREHOUSE_CODE == id);
            }
            else if (type == "area")
            {
                var WarehouseCode = areaQuery.Where(a => a.AREA_CODE == id).Select(a => new { a.WAREHOUSE_CODE }).ToArray();
                warehouse = warehouse.Where(w => w.WAREHOUSE_CODE == WarehouseCode[0].WAREHOUSE_CODE);
            }
            else if (type == "shelf")
            {
                var WarehouseCode = shelfQuery.Where(s => s.SHELF_CODE == id).Select(s => new { s.WAREHOUSE_CODE }).ToArray();
                warehouse = warehouse.Where(w => w.WAREHOUSE_CODE == WarehouseCode[0].WAREHOUSE_CODE);
            }
            else if (type == "cell")
            {
                var WarehouseCode = cellQuery.Where(c => c.CELL_CODE == id).Select(c => new { c.WAREHOUSE_CODE }).ToArray();
                warehouse = warehouse.Where(w => w.WAREHOUSE_CODE == WarehouseCode[0].WAREHOUSE_CODE);
            }
            else
            {
                warehouse = warehouse.Select(w => w);
            }
            int total = warehouse.Count();

            warehouse = warehouse.Skip((page - 1) * rows).Take(rows);
            return(new { total, rows = warehouse.ToArray() });
        }