public UndeliveredOrdersJournalViewModel(UndeliveredOrdersFilterViewModel filterViewModel, IUnitOfWorkFactory unitOfWorkFactory,
                                                 ICommonServices commonServices, IGtkTabsOpener gtkDialogsOpener, IEmployeeJournalFactory driverEmployeeJournalFactory,
                                                 IEmployeeService employeeService, IUndeliveredOrdersJournalOpener undeliveryViewOpener, IOrderSelectorFactory orderSelectorFactory,
                                                 IUndeliveredOrdersRepository undeliveredOrdersRepository, IEmployeeSettings employeeSettings)
            : base(filterViewModel, unitOfWorkFactory, commonServices)
        {
            _gtkDlgOpener = gtkDialogsOpener ?? throw new ArgumentNullException(nameof(gtkDialogsOpener));
            _driverEmployeeJournalFactory = driverEmployeeJournalFactory ?? throw new ArgumentNullException(nameof(driverEmployeeJournalFactory));
            _employeeService             = employeeService ?? throw new ArgumentNullException(nameof(employeeService));
            _undeliveryViewOpener        = undeliveryViewOpener ?? throw new ArgumentNullException(nameof(undeliveryViewOpener));
            _orderSelectorFactory        = orderSelectorFactory ?? throw new ArgumentNullException(nameof(orderSelectorFactory));
            _undeliveredOrdersRepository =
                undeliveredOrdersRepository ?? throw new ArgumentNullException(nameof(undeliveredOrdersRepository));
            _employeeSettings = employeeSettings ?? throw new ArgumentNullException(nameof(employeeSettings));
            _commonServices   = commonServices ?? throw new ArgumentNullException(nameof(commonServices));

            _canCloseUndeliveries = commonServices.CurrentPermissionService.ValidatePresetPermission("can_close_undeliveries");

            TabName = "Журнал недовозов";

            UpdateOnChanges(
                typeof(UndeliveredOrder)
                );

            RegisterUndeliveredOrders();

            DataLoader.ItemsListUpdated      += (sender, e) => CurrentObjectChanged?.Invoke(this, new CurrentObjectChangedArgs(null));
            DataLoader.PostLoadProcessingFunc = BeforeItemsUpdated;

            FinishJournalConfiguration();
        }
Ejemplo n.º 2
0
 void Entity_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName == Entity.GetPropertyName(x => x.BaseLatitude) || e.PropertyName == Entity.GetPropertyName(x => x.BaseLongitude))
     {
         UpdateMapPosition();
         UpdateAddressOnMap();
     }
     CurrentObjectChanged?.Invoke(this, new CurrentObjectChangedArgs(Entity));
 }
Ejemplo n.º 3
0
        protected void OnReferenceCounterpartyChanged(object sender, EventArgs e)
        {
            CurrentObjectChanged?.Invoke(this, new CurrentObjectChangedArgs(Counterparty));
            FixNomenclatureAndEquipmentSensitivity();

            evmeDeliveryPoint.Sensitive = Entity.Counterparty != null;
            evmeDeliveryPoint.Subject   = null;
            if (Entity.Counterparty == null)
            {
                return;
            }

            _deliveryPointJournalFilterViewModel.Counterparty = Entity.Counterparty;
        }
Ejemplo n.º 4
0
        public void SetCurrentObject(object obj, object[] propertyProviders)
        {
            if (this.currentObject == obj)
            {
                return;
            }
            this.currentObject     = obj;
            this.propertyProviders = propertyProviders;
            UpdateTabs();
            Populate();

            if (CurrentObjectChanged != null)
            {
                CurrentObjectChanged.Invoke(this, EventArgs.Empty);
            }
        }
        public DeliveryPointViewModel(
            IUserRepository userRepository,
            IGtkTabsOpener gtkTabsOpener,
            IPhoneRepository phoneRepository,
            IContactsParameters contactsParameters,
            ICitiesDataLoader citiesDataLoader,
            IStreetsDataLoader streetsDataLoader,
            IHousesDataLoader housesDataLoader,
            INomenclatureJournalFactory nomenclatureSelectorFactory,
            NomenclatureFixedPriceController nomenclatureFixedPriceController,
            IDeliveryPointRepository deliveryPointRepository,
            IDeliveryScheduleSelectorFactory deliveryScheduleSelectorFactory,
            IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, ICommonServices commonServices,
            IRoboAtsCounterpartyJournalFactory roboAtsCounterpartyJournalFactory,
            Domain.Client.Counterparty client = null)
            : base(uowBuilder, unitOfWorkFactory, commonServices)
        {
            if (client != null && uowBuilder.IsNewEntity)
            {
                Entity.Counterparty = client;
            }
            else if (client == null && uowBuilder.IsNewEntity)
            {
                throw new ArgumentNullException(nameof(client), "Нельзя создать точку доставки без указания клиента");
            }

            if (phoneRepository == null)
            {
                throw new ArgumentNullException(nameof(phoneRepository));
            }

            if (contactsParameters == null)
            {
                throw new ArgumentNullException(nameof(contactsParameters));
            }

            if (nomenclatureFixedPriceController == null)
            {
                throw new ArgumentNullException(nameof(nomenclatureFixedPriceController));
            }

            _deliveryPointRepository = deliveryPointRepository ?? throw new ArgumentNullException(nameof(deliveryPointRepository));

            _gtkTabsOpener  = gtkTabsOpener ?? throw new ArgumentNullException(nameof(gtkTabsOpener));
            _userRepository = userRepository ?? throw new ArgumentNullException(nameof(userRepository));

            NomenclatureSelectorFactory =
                nomenclatureSelectorFactory ?? throw new ArgumentNullException(nameof(nomenclatureSelectorFactory));

            _fixedPricesModel = new DeliveryPointFixedPricesModel(UoW, Entity, nomenclatureFixedPriceController);
            PhonesViewModel   = new PhonesViewModel(phoneRepository, UoW, contactsParameters, roboAtsCounterpartyJournalFactory, CommonServices)
            {
                PhonesList    = Entity.ObservablePhones,
                DeliveryPoint = Entity,
                ReadOnly      = !CanEdit
            };

            CitiesDataLoader  = citiesDataLoader ?? throw new ArgumentNullException(nameof(citiesDataLoader));
            StreetsDataLoader = streetsDataLoader ?? throw new ArgumentNullException(nameof(streetsDataLoader));
            HousesDataLoader  = housesDataLoader ?? throw new ArgumentNullException(nameof(housesDataLoader));

            CanArchiveDeliveryPoint =
                commonServices.CurrentPermissionService.ValidatePresetPermission("can_arc_counterparty_and_deliverypoint");
            CanSetFreeDelivery            = commonServices.CurrentPermissionService.ValidatePresetPermission("can_set_free_delivery");
            CanEditOrderLimits            = commonServices.CurrentPermissionService.ValidatePresetPermission("user_can_edit_orders_limits");
            CanEditNomenclatureFixedPrice =
                commonServices.CurrentPermissionService.ValidatePresetPermission("can_edit_delivery_point_fixed_prices");

            DeliveryPointCategories =
                deliveryPointRepository?.GetActiveDeliveryPointCategories(UoW)
                ?? throw new ArgumentNullException(nameof(deliveryPointRepository));
            DeliveryScheduleSelectorFactory =
                deliveryScheduleSelectorFactory?.CreateDeliveryScheduleAutocompleteSelectorFactory()
                ?? throw new ArgumentNullException(nameof(deliveryScheduleSelectorFactory));

            _roboAtsCounterpartyJournalFactory = roboAtsCounterpartyJournalFactory ?? throw new ArgumentNullException(nameof(roboAtsCounterpartyJournalFactory));

            Entity.PropertyChanged += (sender, e) =>
            {
                switch (e.PropertyName)
                {                 // от этого события зависит панель цен доставки, которые в свою очередь зависят от района и, возможно, фиксов
                case nameof(Entity.District):
                    CurrentObjectChanged?.Invoke(this, new CurrentObjectChangedArgs(Entity));
                    break;
                }
            };
        }
        public ComplaintsJournalViewModel(
            IUnitOfWorkFactory unitOfWorkFactory,
            ICommonServices commonServices,
            IUndeliveriesViewOpener undeliveriesViewOpener,
            IEmployeeService employeeService,
            IEntityAutocompleteSelectorFactory employeeSelectorFactory,
            IEntityAutocompleteSelectorFactory counterpartySelectorFactory,
            IEntityAutocompleteSelectorFactory nomenclatureSelectorFactory,
            IRouteListItemRepository routeListItemRepository,
            ISubdivisionService subdivisionService,
            ComplaintFilterViewModel filterViewModel,
            IFilePickerService filePickerService,
            ISubdivisionRepository subdivisionRepository,
            IReportViewOpener reportViewOpener,
            IGtkTabsOpenerForRouteListViewAndOrderView gtkDialogsOpener,
            INomenclatureRepository nomenclatureRepository,
            IUserRepository userRepository
            ) : base(filterViewModel, unitOfWorkFactory, commonServices)
        {
            this.unitOfWorkFactory           = unitOfWorkFactory ?? throw new ArgumentNullException(nameof(unitOfWorkFactory));
            this.commonServices              = commonServices ?? throw new ArgumentNullException(nameof(commonServices));
            this.undeliveriesViewOpener      = undeliveriesViewOpener ?? throw new ArgumentNullException(nameof(undeliveriesViewOpener));
            this.employeeService             = employeeService ?? throw new ArgumentNullException(nameof(employeeService));
            this.employeeSelectorFactory     = employeeSelectorFactory ?? throw new ArgumentNullException(nameof(employeeSelectorFactory));
            this.counterpartySelectorFactory = counterpartySelectorFactory ?? throw new ArgumentNullException(nameof(counterpartySelectorFactory));
            this.nomenclatureSelectorFactory = nomenclatureSelectorFactory ?? throw new ArgumentNullException(nameof(nomenclatureSelectorFactory));
            this.filePickerService           = filePickerService ?? throw new ArgumentNullException(nameof(filePickerService));
            this.subdivisionRepository       = subdivisionRepository ?? throw new ArgumentNullException(nameof(subdivisionRepository));
            this.routeListItemRepository     = routeListItemRepository ?? throw new ArgumentNullException(nameof(routeListItemRepository));
            this.subdivisionService          = subdivisionService ?? throw new ArgumentNullException(nameof(subdivisionService));
            this.reportViewOpener            = reportViewOpener ?? throw new ArgumentNullException(nameof(reportViewOpener));
            this.gtkDlgOpener           = gtkDialogsOpener ?? throw new ArgumentNullException(nameof(gtkDialogsOpener));
            this.nomenclatureRepository = nomenclatureRepository ?? throw new ArgumentNullException(nameof(nomenclatureRepository));
            this.userRepository         = userRepository ?? throw new ArgumentNullException(nameof(userRepository));

            TabName = "Журнал рекламаций";

            RegisterComplaints();

            var threadLoader = DataLoader as ThreadDataLoader <ComplaintJournalNode>;

            threadLoader.MergeInOrderBy(x => x.Id, true);

            FinishJournalConfiguration();

            FilterViewModel.SubdivisionService = subdivisionService;
            FilterViewModel.EmployeeService    = employeeService;

            var currentUserSettings        = userRepository.GetUserSettings(UoW, commonServices.UserService.CurrentUserId);
            var defaultSubdivision         = currentUserSettings.DefaultSubdivision;
            var currentEmployeeSubdivision = employeeService.GetEmployeeForUser(UoW, commonServices.UserService.CurrentUserId).Subdivision;

            FilterViewModel.CurrentUserSubdivision = currentEmployeeSubdivision;

            if (FilterViewModel.SubdivisionService.GetOkkId() == currentEmployeeSubdivision.Id)
            {
                FilterViewModel.ComplaintStatus = ComplaintStatuses.Checking;
            }
            else
            {
                if (currentUserSettings.UseEmployeeSubdivision)
                {
                    FilterViewModel.Subdivision = currentEmployeeSubdivision;
                }
                else
                {
                    FilterViewModel.Subdivision = defaultSubdivision;
                }

                FilterViewModel.ComplaintStatus = currentUserSettings.DefaultComplaintStatus;
            }

            UpdateOnChanges(
                typeof(Complaint),
                typeof(ComplaintGuiltyItem),
                typeof(ComplaintResult),
                typeof(Subdivision),
                typeof(ComplaintDiscussion),
                typeof(DeliveryPoint),
                typeof(Fine),
                typeof(Order),
                typeof(RouteList),
                typeof(RouteListItem)
                );
            this.DataLoader.ItemsListUpdated += (sender, e) => CurrentObjectChanged?.Invoke(this, new CurrentObjectChangedArgs(null));

            DataLoader.PostLoadProcessingFunc = BeforeItemsUpdated;
        }