Esempio n. 1
0
        protected void OnButtonAddDeliveryPointsClicked(object sender, EventArgs e)
        {
            var filter = new DeliveryPointJournalFilterViewModel
            {
                Counterparty = Entity.Counterparty
            };
            var dpFactory = new DeliveryPointJournalFactory(filter);
            var dpJournal = dpFactory.CreateDeliveryPointByClientJournal();

            dpJournal.SelectionMode           = JournalSelectionMode.Multiple;
            dpJournal.OnEntitySelectedResult += OnDeliveryPointJournalObjectSelected;
            TabParent.AddSlaveTab(this, dpJournal);
        }
        protected override void ConfigureWithUow()
        {
            nomenclatureEntry.SetEntityAutocompleteSelectorFactory(
                new NomenclatureAutoCompleteSelectorFactory <Nomenclature, NomenclaturesJournalViewModel>(
                    ServicesConfig.CommonServices, new NomenclatureFilterViewModel(), new CounterpartyJournalFactory(),
                    new NomenclatureRepository(new NomenclatureParametersProvider(new ParametersProvider())), new UserRepository()));

            nomenclatureEntry.ChangedByUser += NomenclatureEntryOnChangedByUser;

            entryClient.SetEntityAutocompleteSelectorFactory(new DefaultEntityAutocompleteSelectorFactory <Counterparty, CounterpartyJournalViewModel, CounterpartyJournalFilterViewModel>(ServicesConfig.CommonServices));
            var dpFactory = new DeliveryPointJournalFactory(_deliveryPointJournalFilter);

            evmeDeliveryPoint.SetEntityAutocompleteSelectorFactory(dpFactory.CreateDeliveryPointByClientAutocompleteSelectorFactory());
            evmeDeliveryPoint.Changed += (sender, args) => OnRefiltered();

            var userHasOnlyAccessToWarehouseAndComplaints =
                ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("user_have_access_only_to_warehouse_and_complaints") &&
                !ServicesConfig.CommonServices.UserService.GetCurrentUser(UoW).IsAdmin;

            if (userHasOnlyAccessToWarehouseAndComplaints)
            {
                evmeDeliveryPoint.CanEditReference = false;
            }
        }
Esempio n. 3
0
        void ConfigureDlg()
        {
            if (StoreDocumentHelper.CheckAllPermissions(UoW.IsNew, WarehousePermissions.WriteoffEdit, Entity.WriteoffWarehouse))
            {
                FailInitialize = true;
                return;
            }

            var editing = StoreDocumentHelper.CanEditDocument(WarehousePermissions.WriteoffEdit, Entity.WriteoffWarehouse);

            evmeEmployee.IsEditable = textComment.Editable = editing;
            writeoffdocumentitemsview1.Sensitive = editing && (Entity.WriteoffWarehouse != null || Entity.Client != null);

            textComment.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();
            labelTimeStamp.Binding.AddBinding(Entity, e => e.DateString, w => w.LabelProp).InitializeFromSource();

            var clientFactory = new CounterpartyJournalFactory();

            evmeCounterparty.SetEntityAutocompleteSelectorFactory(clientFactory.CreateCounterpartyAutocompleteSelectorFactory());
            evmeCounterparty.Binding.AddBinding(Entity, e => e.Client, w => w.Subject).InitializeFromSource();
            evmeCounterparty.Changed += OnReferenceCounterpartyChanged;

            ySpecCmbWarehouses.ItemsList = StoreDocumentHelper.GetRestrictedWarehousesList(UoW, WarehousePermissions.WriteoffEdit);
            ySpecCmbWarehouses.Binding.AddBinding(Entity, e => e.WriteoffWarehouse, w => w.SelectedItem).InitializeFromSource();
            ySpecCmbWarehouses.ItemSelected += (sender, e) => {
                writeoffdocumentitemsview1.Sensitive = editing && (Entity.WriteoffWarehouse != null || Entity.Client != null);
            };

            var dpFactory = new DeliveryPointJournalFactory(_deliveryPointJournalFilterViewModel);

            evmeDeliveryPoint.SetEntityAutocompleteSelectorFactory(dpFactory.CreateDeliveryPointByClientAutocompleteSelectorFactory());
            evmeDeliveryPoint.CanEditReference = false;
            evmeDeliveryPoint.Binding.AddBinding(Entity, e => e.DeliveryPoint, w => w.Subject).InitializeFromSource();

            var userHasOnlyAccessToWarehouseAndComplaints =
                ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("user_have_access_only_to_warehouse_and_complaints") &&
                !ServicesConfig.CommonServices.UserService.GetCurrentUser(UoW).IsAdmin;

            if (userHasOnlyAccessToWarehouseAndComplaints)
            {
                evmeEmployee.CanEditReference = false;
            }

            var employeeFactory = new EmployeeJournalFactory();

            evmeEmployee.SetEntityAutocompleteSelectorFactory(employeeFactory.CreateWorkingEmployeeAutocompleteSelectorFactory());
            evmeEmployee.Binding.AddBinding(Entity, e => e.ResponsibleEmployee, w => w.Subject).InitializeFromSource();
            comboType.ItemsEnum         = typeof(WriteoffType);
            evmeDeliveryPoint.Sensitive = evmeCounterparty.Sensitive = (UoWGeneric.Root.Client != null);
            comboType.EnumItemSelected += (object sender, Gamma.Widgets.ItemSelectedEventArgs e) => {
                ySpecCmbWarehouses.Sensitive = WriteoffType.warehouse.Equals(comboType.SelectedItem);
                evmeDeliveryPoint.Sensitive  = WriteoffType.counterparty.Equals(comboType.SelectedItem) && UoWGeneric.Root.Client != null;
                evmeCounterparty.Sensitive   = WriteoffType.counterparty.Equals(comboType.SelectedItem);
            };
            //FIXME Списание с контрагента не реализовано. Поэтому блокирует выбор типа списания.
            comboType.Sensitive    = false;
            comboType.SelectedItem = UoWGeneric.Root.Client != null ?
                                     WriteoffType.counterparty :
                                     WriteoffType.warehouse;

            writeoffdocumentitemsview1.DocumentUoW = UoWGeneric;

            Entity.ObservableItems.ElementAdded   += (aList, aIdx) => ySpecCmbWarehouses.Sensitive = !Entity.ObservableItems.Any();
            Entity.ObservableItems.ElementRemoved += (aList, aIdx, aObject) => ySpecCmbWarehouses.Sensitive = !Entity.ObservableItems.Any();
            ySpecCmbWarehouses.Sensitive           = editing && !Entity.Items.Any();

            var permmissionValidator =
                new EntityExtendedPermissionValidator(PermissionExtensionSingletonStore.GetInstance(), _employeeRepository);

            Entity.CanEdit =
                permmissionValidator.Validate(
                    typeof(WriteoffDocument), ServicesConfig.UserService.CurrentUserId, nameof(RetroactivelyClosePermission));

            if (!Entity.CanEdit && Entity.TimeStamp.Date != DateTime.Now.Date)
            {
                ySpecCmbWarehouses.Binding.AddFuncBinding(Entity, e => e.CanEdit, w => w.Sensitive).InitializeFromSource();
                evmeCounterparty.Sensitive           = false;
                evmeDeliveryPoint.Sensitive          = false;
                comboType.Sensitive                  = false;
                evmeEmployee.Sensitive               = false;
                textComment.Sensitive                = false;
                writeoffdocumentitemsview1.Sensitive = false;

                buttonSave.Sensitive = false;
            }
            else
            {
                Entity.CanEdit = true;
            }
        }
Esempio n. 4
0
        void ConfigureDlg()
        {
            enumStatus.Sensitive         = enumType.Sensitive = false;
            enumStatusEditable.Sensitive = true;
            notebook1.ShowTabs           = false;
            notebook1.CurrentPage        = 0;

            enumcomboWithSerial.ItemsEnum = typeof(ServiceClaimEquipmentSerialType);
            enumcomboWithSerial.Binding.AddBinding(Entity, e => e.WithSerial, w => w.SelectedItem).InitializeFromSource();
            enumStatus.ItemsEnum = typeof(ServiceClaimStatus);
            enumStatus.Binding.AddBinding(Entity, e => e.Status, w => w.SelectedItem).InitializeFromSource();
            enumType.ItemsEnum = typeof(ServiceClaimType);
            enumType.Binding.AddBinding(Entity, e => e.ServiceClaimType, w => w.SelectedItem).InitializeFromSource();
            enumPaymentType.ItemsEnum = typeof(PaymentType);
            enumPaymentType.Binding.AddBinding(Entity, e => e.Payment, w => w.SelectedItem).InitializeFromSource();

            checkRepeated.Binding.AddBinding(Entity, e => e.RepeatedService, w => w.Active).InitializeFromSource();
            dataNumber.Binding.AddBinding(Entity, e => e.Id, w => w.LabelProp, new IdToStringConverter()).InitializeFromSource();
            labelTotalPrice.Binding.AddFuncBinding(Entity, e => e.TotalPrice.ToString("C"), w => w.LabelProp).InitializeFromSource();
            datePickUpDate.Binding.AddBinding(Entity, e => e.ServiceStartDate, w => w.Date).InitializeFromSource();
            textReason.Binding.AddBinding(Entity, e => e.Reason, w => w.Buffer.Text).InitializeFromSource();
            textKit.Binding.AddBinding(Entity, e => e.Kit, w => w.Buffer.Text).InitializeFromSource();
            textDiagnosticsResult.Binding.AddBinding(Entity, e => e.DiagnosticsResult, w => w.Buffer.Text).InitializeFromSource();

            var clientFactory = new CounterpartyJournalFactory();

            evmeClient.SetEntityAutocompleteSelectorFactory(clientFactory.CreateCounterpartyAutocompleteSelectorFactory());
            evmeClient.Binding.AddBinding(Entity, e => e.Counterparty, w => w.Subject).InitializeFromSource();
            evmeClient.Changed += OnReferenceCounterpartyChanged;

            var employeeFactory = new EmployeeJournalFactory();

            evmeEngineer.SetEntityAutocompleteSelectorFactory(employeeFactory.CreateWorkingEmployeeAutocompleteSelectorFactory());
            evmeEngineer.Binding.AddBinding(Entity, e => e.Engineer, w => w.Subject).InitializeFromSource();

            yentryEquipmentReplacement.ItemsQuery = _equipmentRepository.AvailableOnDutyEquipmentQuery();
            yentryEquipmentReplacement.SetObjectDisplayFunc <Equipment> (e => e.Title);
            yentryEquipmentReplacement.Binding
            .AddBinding(UoWGeneric.Root, serviceClaim => serviceClaim.ReplacementEquipment, widget => widget.Subject)
            .InitializeFromSource();

            evmeDeliveryPoint.Sensitive = (UoWGeneric.Root.Counterparty != null);
            evmeDeliveryPoint.Binding.AddBinding(Entity, e => e.DeliveryPoint, w => w.Subject).InitializeFromSource();
            evmeDeliveryPoint.Changed += OnReferenceDeliveryPointChanged;
            var dpFactory = new DeliveryPointJournalFactory();

            dpFactory.SetDeliveryPointJournalFilterViewModel(_deliveryPointJournalFilterViewModel);
            evmeDeliveryPoint.SetEntityAutocompleteSelectorFactory(dpFactory.CreateDeliveryPointByClientAutocompleteSelectorFactory());

            referenceNomenclature.ItemsQuery = _nomenclatureRepository.NomenclatureOfItemsForService();
            referenceNomenclature.Binding.AddBinding(Entity, e => e.Nomenclature, w => w.Subject).InitializeFromSource();

            referenceEquipment.SubjectType = typeof(Equipment);
            referenceEquipment.Sensitive   = (UoWGeneric.Root.Nomenclature != null);
            referenceEquipment.Binding.AddBinding(Entity, e => e.Equipment, w => w.Subject).InitializeFromSource();

            treePartsAndServices.ItemsDataSource = UoWGeneric.Root.ObservableServiceClaimItems;
            treeHistory.ItemsDataSource          = UoWGeneric.Root.ObservableServiceClaimHistory;

            treePartsAndServices.ColumnsConfig = FluentColumnsConfig <ServiceClaimItem> .Create()
                                                 .AddColumn("Номенклатура").SetDataProperty(node => node.Nomenclature != null ? node.Nomenclature.Name : "-")
                                                 .AddColumn("Кол-во").AddNumericRenderer(node => node.Count)
                                                 .Adjustment(new Adjustment(0, 0, 1000000, 1, 100, 0))
                                                 .AddSetter((c, node) => c.Digits = node.Nomenclature.Unit == null ? 0 : (uint)node.Nomenclature.Unit.Digits)
                                                 .AddSetter((c, i) => c.Editable  = isEditable)
                                                 .WidthChars(10)
                                                 .AddColumn("Цена").AddNumericRenderer(node => node.Price).Digits(2)
                                                 .AddTextRenderer(node => CurrencyWorks.CurrencyShortName, false)
                                                 .AddColumn("Сумма").AddNumericRenderer(node => node.Total).Digits(2)
                                                 .AddTextRenderer(node => CurrencyWorks.CurrencyShortName, false)
                                                 .Finish();

            treeHistory.ColumnsConfig = FluentColumnsConfig <ServiceClaimHistory> .Create()
                                        .AddColumn("Дата").SetDataProperty(node => node.Date.ToShortDateString())
                                        .AddColumn("Время").SetDataProperty(node => node.Date.ToString("HH:mm"))
                                        .AddColumn("Статус").SetDataProperty(node => node.Status.GetEnumTitle())
                                        .AddColumn("Сотрудник").SetDataProperty(node => node.Employee == null ? " - " : node.Employee.FullName)
                                        .AddColumn("Комментарий").SetDataProperty(node => node.Comment)
                                        .Finish();

            UoWGeneric.Root.ObservableServiceClaimItems.ElementChanged += (aList, aIdx) => FixPrice(aIdx [0]);
            configureAvailableNextStatus();
            Entity.PropertyChanged += Entity_PropertyChanged;

            if (UoWGeneric.Root.ServiceClaimType == ServiceClaimType.JustService)
            {
                evmeDeliveryPoint.Visible          = false;
                labelDeliveryPoint.Visible         = false;
                yentryEquipmentReplacement.Visible = false;
                labelReplacement.Visible           = false;
            }
            datePickUpDate.IsEditable = Entity.InitialOrder == null;
            Menu menu            = new Menu();
            var  menuItemInitial = new MenuItem("Перейти к начальному заказу");

            menuItemInitial.Sensitive  = Entity.InitialOrder != null;
            menuItemInitial.Activated += MenuInitialOrderActivated;
            menu.Add(menuItemInitial);
            var menuItemFinal = new MenuItem("Перейти к финальному заказу");

            menuItemFinal.Sensitive  = Entity.FinalOrder != null;
            menuItemFinal.Activated += MenuFinalOrderActivated;
            menu.Add(menuItemFinal);
            menuActions.Menu = menu;
            menu.ShowAll();
        }
Esempio n. 5
0
        private void ConfigureDlg()
        {
            var orderOrganizationProviderFactory = new OrderOrganizationProviderFactory();

            _organizationProvider           = orderOrganizationProviderFactory.CreateOrderOrganizationProvider();
            _counterpartyContractRepository = new CounterpartyContractRepository(_organizationProvider);
            _counterpartyContractFactory    = new CounterpartyContractFactory(_organizationProvider, _counterpartyContractRepository);

            buttonReportByClient.Sensitive = Entity.Counterparty != null;
            buttonReportByDP.Sensitive     = Entity.DeliveryPoint != null;

            comboboxImpotanceType.ItemsEnum = typeof(ImportanceDegreeType);
            comboboxImpotanceType.Binding.AddBinding(Entity, s => s.ImportanceDegree, w => w.SelectedItemOrNull).InitializeFromSource();
            TaskStateComboBox.ItemsEnum = typeof(CallTaskStatus);
            TaskStateComboBox.Binding.AddBinding(Entity, s => s.TaskState, w => w.SelectedItemOrNull).InitializeFromSource();
            IsTaskCompleteButton.Binding.AddBinding(Entity, s => s.IsTaskComplete, w => w.Active).InitializeFromSource();
            IsTaskCompleteButton.Label += Entity.CompleteDate?.ToString("dd / MM / yyyy  HH:mm");
            deadlineYdatepicker.Binding.AddBinding(Entity, s => s.EndActivePeriod, w => w.Date).InitializeFromSource();
            ytextviewComments.Binding.AddBinding(Entity, s => s.Comment, w => w.Buffer.Text).InitializeFromSource();
            yentryTareReturn.ValidationMode = ValidationType.numeric;
            yentryTareReturn.Binding.AddBinding(Entity, s => s.TareReturn, w => w.Text, new IntToStringConverter()).InitializeFromSource();

            textViewCommentAboutClient.Binding
            .AddFuncBinding(Entity, e => e.Counterparty != null ? e.Counterparty.Comment : "",
                            w => w.Buffer.Text).InitializeFromSource();
            vboxOldComments.Visible = true;

            var employeeFilterViewModel = new EmployeeFilterViewModel {
                RestrictCategory = EmployeeCategory.office
            };
            var employeeJournalFactory = new EmployeeJournalFactory(employeeFilterViewModel);

            entryAttachedEmployee.SetEntityAutocompleteSelectorFactory(employeeJournalFactory.CreateEmployeeAutocompleteSelectorFactory());
            entryAttachedEmployee.Binding.AddBinding(Entity, e => e.AssignedEmployee, w => w.Subject).InitializeFromSource();

            var deliveryPointJournalFactory = new DeliveryPointJournalFactory(_deliveryPointJournalFilterViewModel);

            entityVMEntryDeliveryPoint
            .SetEntityAutocompleteSelectorFactory(deliveryPointJournalFactory.CreateDeliveryPointAutocompleteSelectorFactory());
            entityVMEntryDeliveryPoint.Binding.AddBinding(Entity, s => s.DeliveryPoint, w => w.Subject).InitializeFromSource();

            var counterpartyJournalFactory = new CounterpartyJournalFactory();

            entityVMEntryCounterparty
            .SetEntityAutocompleteSelectorFactory(counterpartyJournalFactory.CreateCounterpartyAutocompleteSelectorFactory());
            entityVMEntryCounterparty.Binding.AddBinding(Entity, s => s.Counterparty, w => w.Subject).InitializeFromSource();

            ClientPhonesView.ViewModel          = new PhonesViewModel(_phoneRepository, UoW, ContactParametersProvider.Instance);
            ClientPhonesView.ViewModel.ReadOnly = true;

            DeliveryPointPhonesView.ViewModel          = new PhonesViewModel(_phoneRepository, UoW, ContactParametersProvider.Instance);
            DeliveryPointPhonesView.ViewModel.ReadOnly = true;

            if (Entity.Counterparty != null)
            {
                if (_deliveryPointJournalFilterViewModel != null)
                {
                    _deliveryPointJournalFilterViewModel.Counterparty = Entity.Counterparty;
                }
            }

            UpdateAddressFields();
        }