예제 #1
0
파일: Resource.cs 프로젝트: zxl881203/src
        public static IList <Resource> GetAll()
        {
            List <Resource> list = new List <Resource>();

            using (pm2Entities entities = new pm2Entities())
            {
                foreach (var typef in from r in entities.Res_Resource select new { Id = r.ResourceId, TypeId = r.Res_ResourceType.ResourceTypeId, Code = r.ResourceCode, Name = r.ResourceName, Brand = r.Brand, TaxRate = r.TaxRate, Specification = r.Specification, TechnicalParam = r.TechnicalParameter, UnitId = r.Res_Unit.UnitId, TypeAttributeId = r.Res_Attribute.AttributeId, Series = r.Series, User = r.InputUser, Date = r.InputDate })
                {
                    Resource item = new Resource {
                        Id                 = typef.Id,
                        ResourceType       = ResType.GetById(typef.TypeId),
                        Code               = typef.Code,
                        Name               = typef.Name,
                        Brand              = typef.Brand,
                        TaxRate            = typef.TaxRate,
                        Specification      = typef.Specification,
                        TechnicalParameter = typef.TechnicalParam,
                        ResourceUnit       = ResUnit.GetById(typef.UnitId),
                        TypeAttribute      = ResTypeAttribute.GetById(typef.TypeAttributeId),
                        Series             = typef.Series,
                        Prices             = GetPrices(typef.Id),
                        InputUser          = typef.User,
                        InputDate          = typef.Date
                    };
                    list.Add(item);
                }
            }
            return(list);
        }
예제 #2
0
 public static void Update(ResTypeAttribute typeAttr)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         Res_Attribute attribute = (from attr in entities.Res_Attribute
                                    where attr.AttributeId == typeAttr.Id
                                    select attr).FirstOrDefault <Res_Attribute>();
         if (attribute == null)
         {
             throw new Exception("找不到需要修改的类别属性");
         }
         attribute.AttributeName = typeAttr.Name;
         entities.SaveChanges();
     }
 }
예제 #3
0
        public static IList <ResTypeAttribute> GetAll()
        {
            IList <ResTypeAttribute> list = new List <ResTypeAttribute>();

            using (pm2Entities entities = new pm2Entities())
            {
                foreach (var type in (from a in entities.Res_Attribute select new { AttributeId = a.AttributeId, AttributeName = a.AttributeName, InputUser = a.InputUser, InputDate = a.InputDate, ResourceTypeId = a.Res_ResourceType.ResourceTypeId }).ToList())
                {
                    ResTypeAttribute item = new ResTypeAttribute {
                        Id           = type.AttributeId,
                        Name         = type.AttributeName,
                        InputUser    = type.InputUser,
                        ResourceType = ResType.GetById(type.ResourceTypeId)
                    };
                    list.Add(item);
                }
            }
            return(list);
        }
예제 #4
0
 public static void Add(ResTypeAttribute typeAttr)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         Res_Attribute attribute = new Res_Attribute {
             AttributeId   = typeAttr.Id,
             AttributeName = typeAttr.Name,
             InputUser     = typeAttr.InputUser,
             InputDate     = typeAttr.InputDate
         };
         Res_ResourceType type = (from rt in entities.Res_ResourceType
                                  where rt.ResourceTypeId == typeAttr.ResourceType.Id
                                  select rt).FirstOrDefault <Res_ResourceType>();
         if (type == null)
         {
             throw new Exception("不能确定其所属类别");
         }
         attribute.Res_ResourceType = type;
         entities.SaveChanges();
     }
 }
예제 #5
0
        public static ResTypeAttribute GetById(string id)
        {
            ResTypeAttribute attribute = new ResTypeAttribute();

            using (pm2Entities entities = new pm2Entities())
            {
                var type = (from a in entities.Res_Attribute
                            where a.AttributeId == id
                            select new { AttributeId = a.AttributeId, AttributeName = a.AttributeName, InputUser = a.InputUser, InputDate = a.InputDate, ResourceTypeId = a.Res_ResourceType.ResourceTypeId }).FirstOrDefault();
                if (type != null)
                {
                    attribute.Id        = id;
                    attribute.Name      = type.AttributeName;
                    attribute.InputUser = type.InputUser;
                    attribute.InputDate = type.InputDate;
                    ResType byId = ResType.GetById(type.ResourceTypeId);
                    attribute.ResourceType = byId;
                    return(attribute);
                }
                return(null);
            }
        }
예제 #6
0
파일: Resource.cs 프로젝트: zxl881203/src
 public static Resource Create(string id, ResType resType, string code, string name, string brand, decimal?taxRate, string specification, string modelNumber, string technicalParam, ResUnit resUnit, ResTypeAttribute typeAttr, string series, IDictionary <ResPriceType, decimal?> prices, string user, DateTime?date, int?supplierId)
 {
     if (string.IsNullOrEmpty(id))
     {
         throw new ArgumentException("资源Id", "资源Id不能为空");
     }
     if (resType == null)
     {
         throw new ArgumentException("资源类型", "资源类型不能为空");
     }
     if (string.IsNullOrEmpty(code))
     {
         throw new ArgumentException("资源编号", "资源名称不能为空");
     }
     return(new Resource {
         Id = id, ResourceType = resType, Code = code, Name = name, Brand = brand, TaxRate = taxRate, Specification = specification, ModelNumber = modelNumber, TechnicalParameter = technicalParam, ResourceUnit = resUnit, TypeAttribute = typeAttr, Series = series, Prices = prices, InputUser = user, InputDate = date, SupplierId = supplierId
     });
 }