Example #1
0
        /// <summary>
        /// 根据SN或者名称查询资产
        /// </summary>
        /// <param name="SNOrName">SN或者名称</param>
        /// <param name="Type">一级资产编号</param>
        /// <returns></returns>
        public DataTable QueryAssets(string SNOrName, string Type)
        {
            List <String> Types = new List <string>();

            if (String.IsNullOrEmpty(Type) == false)
            {
                Types.Add(Type);
                List <AssetsType> listType = _assetsTypeRepository.GetByParentTypeID(Type).AsNoTracking().ToList();
                foreach (AssetsType Row in listType)
                {
                    List <AssetsType> LastlistType = _assetsTypeRepository.GetByParentTypeID(Row.TYPEID).AsNoTracking().ToList();
                    foreach (AssetsType LastRow in LastlistType)
                    {
                        Types.Add(LastRow.TYPEID);
                    }
                    Types.Add(Row.TYPEID);
                }
            }

            var list   = _AssetsRepository.QueryAssets(SNOrName, Types).Where(a => a.ISINWAREHOUSE == 1).AsNoTracking();
            var result = from assetse in list
                         from location in SMOWMSDbContext.WHStorageLocations
                         from storageType in SMOWMSDbContext.WHStorageTypes
                         from wareHouse in SMOWMSDbContext.WareHouses
                         join type in SMOWMSDbContext.AssetsTypes on assetse.TYPEID equals type.TYPEID
                         where wareHouse.WAREID == assetse.WAREID && storageType.WAREID == assetse.WAREID && storageType.STID == assetse.STID && location.WAREID == assetse.WAREID && location.STID == assetse.STID && location.SLID == assetse.SLID
                         select new
            {
                ASSID         = assetse.ASSID,
                Image         = assetse.IMAGE,
                SLName        = wareHouse.NAME + "/" + storageType.NAME + "/" + location.NAME,
                Name          = assetse.NAME,
                Price         = assetse.PRICE,
                SN            = assetse.SN,
                TypeName      = type.NAME,
                Specification = assetse.SPECIFICATION
            };

            return(LINQToDataTable.ToDataTable(result));
        }
Example #2
0
        /// <summary>
        /// 根据SN或者名称或者部门或者状态查询资产
        /// </summary>
        /// <param name="SNOrName">SN或者名称</param>
        /// <param name="LocationId">区域</param>
        /// <param name="DepId">部门编号</param>
        /// <param name="Status">资产状态</param>
        /// <param name="Type">资产类型</param>
        /// <returns></returns>
        public DataTable QueryAssets(string SNOrName, string LocationId, string DepId, string Status, string Type)
        {
            List <String> Types = new List <string>();

            if (String.IsNullOrEmpty(Type) == false)
            {
                Types.Add(Type);
                List <AssetsType> listType = _assetsTypeRepository.GetByParentTypeID(Type).AsNoTracking().ToList();
                foreach (AssetsType Row in listType)
                {
                    List <AssetsType> LastlistType = _assetsTypeRepository.GetByParentTypeID(Row.TYPEID).AsNoTracking().ToList();
                    foreach (AssetsType LastRow in LastlistType)
                    {
                        Types.Add(LastRow.TYPEID);
                    }
                    Types.Add(Row.TYPEID);
                }
            }

            coreUser coreUser = _coreUserRepository.GetUser(SNOrName).FirstOrDefault();

            if (coreUser != null && String.IsNullOrEmpty(SNOrName) == false)
            {
                var result = _AssetsRepository.QueryAssets(coreUser.USER_ID, Types).AsNoTracking();
                if (!string.IsNullOrEmpty(LocationId))
                {
                    result = result.Where(a => a.LOCATIONID == LocationId);
                }
                if (!string.IsNullOrEmpty(Status))
                {
                    int statusId = Convert.ToInt32(Status);
                    result = result.Where(a => a.STATUS == statusId);
                }
                if (!string.IsNullOrEmpty(DepId))
                {
                    result = result.Where(a => a.DEPARTMENTID == DepId);
                }
                DataTable table = LINQToDataTable.ToDataTable(result);
                table.Columns.Add("StatusName");
                table.Columns.Add("DepName");
                foreach (DataRow row in table.Rows)
                {
                    Department dep = _departmentRepository.GetByID(row["DEPARTMENTID"].ToString()).FirstOrDefault();
                    row["StatusName"] = Enum.GetName(typeof(STATUS), row["Status"]);
                    if (dep != null)
                    {
                        row["DepName"] = dep.NAME;
                    }
                }
                return(table);
            }
            else
            {
                var result = _AssetsRepository.QueryAssets(SNOrName, Types).AsNoTracking();
                if (!string.IsNullOrEmpty(LocationId))
                {
                    result = result.Where(a => a.LOCATIONID == LocationId);
                }
                if (!string.IsNullOrEmpty(Status))
                {
                    int statusId = Convert.ToInt32(Status);
                    result = result.Where(a => a.STATUS == statusId);
                }
                if (!string.IsNullOrEmpty(DepId))
                {
                    result = result.Where(a => a.DEPARTMENTID == DepId);
                }
                DataTable table = LINQToDataTable.ToDataTable(result);
                table.Columns.Add("StatusName");
                table.Columns.Add("DepName");
                foreach (DataRow row in table.Rows)
                {
                    Department dep = _departmentRepository.GetByID(row["DEPARTMENTID"].ToString()).FirstOrDefault();
                    row["StatusName"] = Enum.GetName(typeof(STATUS), row["Status"]);
                    if (dep != null)
                    {
                        row["DepName"] = dep.NAME;
                    }
                }
                return(table);
            }
        }