示例#1
0
        /// <summary>
        /// 更新或新建物料组
        /// </summary>
        /// <param name="category">物料组</param>
        /// <returns></returns>
        private ItemSmallCategory UpdateOrAdd(ItemSmallCategory category)
        {
            var existCategory = FindCategoryByCode(category.Code);

            if (existCategory != null)
            {
                existCategory.Name = category.Name;
                existCategory.Code = category.Code;
            }
            else
            {
                existCategory = category;
            }

            var existMidCategory = CreateMediumCategory(category);

            var existBigCategory = CreateLargeCategory(category);

            InvOrgIdExtension.SetInvOrgId(existBigCategory, PlatformEnvironment.InvOrgId);
            RF.Save(existBigCategory);

            InvOrgIdExtension.SetInvOrgId(existMidCategory, PlatformEnvironment.InvOrgId);
            existMidCategory.LargeCategoryId = existBigCategory.Id;
            RF.Save(existMidCategory);

            InvOrgIdExtension.SetInvOrgId(existCategory, PlatformEnvironment.InvOrgId);
            existCategory.MediumCategoryId = existMidCategory.Id;
            RF.Save(existCategory);

            return(existCategory);
        }
示例#2
0
        public virtual void ReceivePurchase(PurchaseGroup purchase, string code)
        {
            try
            {
                using (var trans = RF.TransactionScope(BDEntityDataProvider.ConnectionStringName))
                {
                    var existOrganization = DomainControllerFactory.Create <PurchaseGroupController>().GetPurchaseGroupByCode(purchase.Code) ?? purchase;
                    var userModel         = DomainControllerFactory.Create <UserController>().FetchBy("", purchase.Name).FirstOrDefault() as User;
                    if (userModel != null)
                    {
                        existOrganization.BuyerId = userModel.Id;
                    }
                    existOrganization.Code  = purchase.Code;
                    existOrganization.Name  = purchase.Code;
                    existOrganization.Phone = purchase.Phone;
                    existOrganization.Fax   = purchase.Fax;

                    //
                    InvOrgIdExtension.SetInvOrgId(existOrganization, PlatformEnvironment.InvOrgId);
                    RF.Save(existOrganization);

                    trans.Complete();
                }
            }
            catch (Exception e)
            {
                throw new Exception("采购组基础主数据 下载异常:" + e.Message);
            }
        }
        public virtual void ReceiveMoveReason(Reasons reason, string code)
        {
            try
            {
                if (reason == null)
                {
                    throw new ArgumentNullException("reason");
                }
                using (var trans = RF.TransactionScope(BDEntityDataProvider.ConnectionStringName))
                {
                    Reasons model       = DomainControllerFactory.Create <ReasonsController>().GetReason(reason.Name, reason.MoveType) as Reasons;
                    var     existReason = model ?? reason;
                    //existReason.Name = reason.Name;
                    existReason.Description = reason.Description;
                    existReason.ReasonsType = ReasonsType.MOVER;
                    //
                    InvOrgIdExtension.SetInvOrgId(existReason, PlatformEnvironment.InvOrgId);
                    RF.Save(existReason);

                    trans.Complete();
                }
            }
            catch (Exception e)
            {
                throw new Exception("移动原因数据下载异常:" + e);
            }
        }
示例#4
0
        public virtual void SaveOrUpdateCost(Factory factory, string code)
        {
            try
            {
                // SetInvOrgIdByCorporation(inv_org);
                using (var trans = RF.TransactionScope(BDEntityDataProvider.ConnectionStringName))
                {
                    var existFactory = (DomainControllerFactory.Create <FactoryController>().GetList(new FactoryCriteria()
                    {
                        Code = factory.Code
                    }).Concrete()).FirstOrDefault() ?? factory;

                    factory = existFactory;

                    InvOrgIdExtension.SetInvOrgId(factory, PlatformEnvironment.InvOrgId);
                    RF.Save(factory);

                    trans.Complete();
                }
            }
            catch (Exception e)
            {
                throw new Exception("成本中心数据下载异常:" + e.Message);
            }
        }
示例#5
0
        private ItemSmallCategory UpdateOrAddExt(ItemSmallCategory category)
        {
            var existMidCategory = CreateMediumCategory(category);

            var existBigCategory = CreateLargeCategory(category);

            InvOrgIdExtension.SetInvOrgId(existBigCategory, PlatformEnvironment.InvOrgId);
            RF.Save(existBigCategory);

            InvOrgIdExtension.SetInvOrgId(existMidCategory, PlatformEnvironment.InvOrgId);
            existMidCategory.LargeCategoryId = existBigCategory.Id;
            RF.Save(existMidCategory);

            category.MediumCategoryId = existMidCategory.Id;

            return(category);
        }
        public virtual void SaveOrUpdateCustomer(Customer customer, string Code)
        {
            try
            {
                //if (corporation.IsNullOrWhiteSpace()) throw new ArgumentNullException("corporation");
                //SetInvOrgIdByCorporation(corporation);
                using (var trans = RF.TransactionScope(BDEntityDataProvider.ConnectionStringName))
                {
                    //获取客户
                    var criteria = new CustomerCriteria()
                    {
                        PagingInfo = new PagingInfo(1, int.MaxValue)
                    };
                    criteria.Code = customer.Code;
                    var existCustomer = DomainControllerFactory.Create <CustomerController>()
                                        .GetList(criteria).Concrete().FirstOrDefault() ?? customer;

                    //ItemExtendsion.SetErpUpdate(item, item.UpdateDate);
                    existCustomer.Name      = customer.Name;
                    existCustomer.SalesArea = customer.SalesArea;

                    //customer.PersistenceStatus = existCustomer.PersistenceStatus;
                    //customer.Id = existCustomer.Id;
                    //organization.DataSource = EumDataSource.ERP;

                    InvOrgIdExtension.SetInvOrgId(customer, PlatformEnvironment.InvOrgId);
                    RF.Save(existCustomer);

                    trans.Complete();
                }
            }
            catch (Exception e)
            {
                throw new Exception("客户基础主数据下载异常:" + e.Message);
            }
        }
示例#7
0
        public virtual void SaveOrUpdateWarehouse(Warehouse warehouse, string code)
        {
            try
            {
                //if (corporation.IsNullOrWhiteSpace()) throw new ArgumentNullException("invOrg");
                //SetInvOrgIdByCorporation(corporation);
                using (var trans = RF.TransactionScope(BDEntityDataProvider.ConnectionStringName))
                {
                    var factory = DomainControllerFactory.Create <OrganizationController>().GetOrganizationList(new OrganizationCriteria {
                        Code = warehouse.Factory.Code
                    }).FirstOrDefault() as Organization;
                    if (factory == null)
                    {
                        throw new Exception("不存在工厂:" + warehouse.Factory.Code);
                    }
                    ////获取仓库
                    var existWarehouse = DomainControllerFactory.Create <WarehouseController>()
                                         .GetWarehouseList(new WarehouseCriteria {
                        Code = warehouse.Code
                    }).Concrete().FirstOrDefault() ?? warehouse;

                    existWarehouse.Name      = warehouse.Name;
                    existWarehouse.FactoryId = factory.Id;
                    //warehouse.PersistenceStatus = existWarehouse.PersistenceStatus;
                    //organization.DataSource = EumDataSource.ERP;

                    InvOrgIdExtension.SetInvOrgId(existWarehouse, PlatformEnvironment.InvOrgId);
                    RF.Save(existWarehouse);
                    trans.Complete();
                }
            }
            catch (Exception e)
            {
                throw new Exception("仓库基础主数据下载异常:" + e.Message);
            }
        }
示例#8
0
 public virtual void SaveOrUpdateOrg(Organization org, string orgCode)
 {
     try
     {
         //if (corporation.IsNullOrWhiteSpace()) throw new ArgumentNullException("invOrg");
         //SetInvOrgIdByCorporation(invOrg);
         using (var trans = RF.TransactionScope(BDEntityDataProvider.ConnectionStringName))
         {
             var ctl  = DomainControllerFactory.Create <OrganizationController>();
             var corp = ctl.GetOrganizationByType(OrganizationType.Group, null, null).Concrete().FirstOrDefault();
             if (corp == null)
             {
                 throw new ValidationException("缺少公司(集团)信息".Translate());
             }
             Organization existOrg = null;
             if (org.LevelId == 1)
             {
                 existOrg = ctl.GetOrganizationByType(OrganizationType.Group, null, org.Code).Concrete().FirstOrDefault() ?? org;
             }
             else
             {
                 //获取工厂
                 existOrg            = ctl.GetOrganizationByType(OrganizationType.Plant, null, org.Code).Concrete().FirstOrDefault() ?? org;
                 existOrg.TreeParent = corp;
             }
             existOrg.Name = org.Name;
             InvOrgIdExtension.SetInvOrgId(existOrg, PlatformEnvironment.InvOrgId);
             RF.Save(existOrg);
             trans.Complete();
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }