コード例 #1
0
        public Location CommitChanges()
        {
            if (BusinessDomain.AppConfiguration.AutoGenerateLocationCodes && string.IsNullOrWhiteSpace(code))
            {
                AutoGenerateCode();
            }

            if (!string.IsNullOrEmpty(groupName) && groupId <= 1)
            {
                LocationsGroup g = GroupBase <LocationsGroup> .EnsureByPath(groupName, LocationsGroup.Cache);

                groupId = g.Id;
            }

            BusinessDomain.DataAccessProvider.AddUpdateLocation(this,
                                                                BusinessDomain.AppConfiguration.DocumentNumbersPerLocation,
                                                                OperationNumberingInfo.RECOMMENDED_NUMBERS_PER_LOCATION);
            cache.Set(this);

            return(this);
        }
コード例 #2
0
        public User CommitChanges()
        {
            if (BusinessDomain.AppConfiguration.AutoGenerateUserCodes && string.IsNullOrWhiteSpace(code))
            {
                AutoGenerateCode();
            }

            if (!string.IsNullOrEmpty(groupName) && groupId <= 1)
            {
                UsersGroup g = GroupBase <UsersGroup> .EnsureByPath(groupName, UsersGroup.Cache);

                groupId = g.Id;
            }

            bool isNew = id < 0;

            BusinessDomain.DataAccessProvider.AddUpdateUser(this);
            cache.Set(this);

            if (isNew)
            {
                BusinessDomain.RestrictionTree.ResetLevelRestrictions(id, userLevel);
                BusinessDomain.RestrictionTree.SaveRestrictions();
            }

            if (lockedLocationIdDirty)
            {
                ConfigEntry.SaveValue(LOCKED_LOCATION_KEY, LockedLocationId, id);
                lockedLocationIdDirty = false;
            }

            if (lockedPartnerIdDirty)
            {
                ConfigEntry.SaveValue(LOCKED_PARTNER_KEY, LockedPartnerId, id);
                lockedPartnerIdDirty = false;
            }

            if (defaultPartnerIdDirty)
            {
                ConfigEntry.SaveValue(DEFAULT_PARTNER_KEY, DefaultPartnerId, id);
                defaultPartnerIdDirty = false;
            }

            if (defaultCompanyIdDirty)
            {
                ConfigEntry.SaveValue(DEFAULT_COMPANY_KEY, DefaultCompanyId, id);
                BusinessDomain.CurrentCompany = CompanyRecord.GetDefault();
                defaultCompanyIdDirty         = false;
            }

            if (hideItemsPurchasePriceDirty)
            {
                ConfigEntry.SaveValue(HIDE_ITEMS_PURCHASE_PRICE_KEY, HideItemsPurchasePrice, id);
                hideItemsPurchasePriceDirty = false;
            }

            if (hideItemsAvailabilityDirty)
            {
                ConfigEntry.SaveValue(HIDE_ITEMS_AVAILABILITY_KEY, HideItemsAvailability, id);
                hideItemsAvailabilityDirty = false;
            }

            if (allowZeroPricesDirty)
            {
                ConfigEntry.SaveValue(ALLOW_ZERO_PRICES_KEY, AllowZeroPrices, id);
                allowZeroPricesDirty = false;
            }

            if (BusinessDomain.LoggedUser.Id == id)
            {
                BusinessDomain.LoggedUser = this;
            }

            return(this);
        }