private void ConfigureSubdivision()
        {
            if (ViewModel.CanManageDriversAndForwarders && !ViewModel.CanManageOfficeWorkers)
            {
                var entityentrySubdivision = new EntityViewModelEntry();
                entityentrySubdivision.SetEntityAutocompleteSelectorFactory(
                    ViewModel.SubdivisionJournalFactory.CreateLogisticSubdivisionAutocompleteSelectorFactory(
                        ViewModel.EmployeeJournalFactory.CreateEmployeeAutocompleteSelectorFactory()));
                entityentrySubdivision.Binding
                .AddBinding(ViewModel.Entity, e => e.Subdivision, w => w.Subject)
                .AddBinding(ViewModel, vm => vm.CanEditEmployee, w => w.Sensitive)
                .InitializeFromSource();
                hboxSubdivision.Add(entityentrySubdivision);
                hboxSubdivision.ShowAll();
                return;
            }

            var entrySubdivision = new yEntryReference();

            entrySubdivision.SubjectType = typeof(Subdivision);
            entrySubdivision.Binding
            .AddBinding(ViewModel.Entity, e => e.Subdivision, w => w.Subject)
            .AddBinding(ViewModel, vm => vm.CanEditEmployee, w => w.Sensitive)
            .InitializeFromSource();
            hboxSubdivision.Add(entrySubdivision);
            hboxSubdivision.ShowAll();

            if (!ViewModel.CanManageOfficeWorkers && !ViewModel.CanManageDriversAndForwarders)
            {
                entrySubdivision.Sensitive = false;
            }
        }
        private void Configure()
        {
            if (ViewModel.UserHasOnlyAccessToWarehouseAndComplaints)
            {
                var warehouseEntry = new EntityViewModelEntry();
                warehouseEntry.SetEntityAutocompleteSelectorFactory(ViewModel.WarehouseSelectorFactory);
                warehouseEntry.Binding.AddSource(ViewModel)
                .AddBinding(vm => vm.Warehouse, w => w.Subject)
                .AddBinding(vm => vm.CanChangeWarehouse, w => w.Sensitive)
                .InitializeFromSource();

                warehouseEntry.Show();
                yhboxWarehouse.Add(warehouseEntry);
            }
            else
            {
                var warehouseCombo = new ySpecComboBox();
                warehouseCombo.SetRenderTextFunc <Warehouse>(x => x.Name);
                warehouseCombo.Binding.AddSource(ViewModel)
                .AddBinding(vm => vm.AvailableWarehouses, w => w.ItemsList)
                .AddBinding(vm => vm.Warehouse, w => w.SelectedItem)
                .AddBinding(ViewModel, vm => vm.CanChangeWarehouse, w => w.Sensitive)
                .InitializeFromSource();

                warehouseCombo.Show();
                yhboxWarehouse.Add(warehouseCombo);
            }

            checkShowArchive.Binding.AddBinding(ViewModel, vm => vm.ShowArchive, w => w.Active).InitializeFromSource();
            checkShowArchive.Binding.AddBinding(ViewModel, vm => vm.CanChangeShowArchive, w => w.Sensitive).InitializeFromSource();
        }
Beispiel #3
0
        private void Configure()
        {
            var warehouseEntry = new EntityViewModelEntry();

            warehouseEntry.SetEntityAutocompleteSelectorFactory(ViewModel.WarehouseSelectorFactory);
            warehouseEntry.Binding.AddSource(ViewModel)
            .AddBinding(vm => vm.Warehouse, w => w.Subject)
            .AddBinding(vm => vm.CanChangeWarehouse, w => w.Sensitive)
            .InitializeFromSource();

            warehouseEntry.Show();
            yhboxWarehouse.Add(warehouseEntry);

            checkShowArchive.Binding.AddBinding(ViewModel, vm => vm.ShowArchive, w => w.Active).InitializeFromSource();
            checkShowArchive.Binding.AddBinding(ViewModel, vm => vm.CanChangeShowArchive, w => w.Sensitive).InitializeFromSource();
        }
Beispiel #4
0
        private void ConfigureSubdivision()
        {
            if (canManageDriversAndForwarders && !canManageOfficeWorkers)
            {
                var entityentrySubdivision = new EntityViewModelEntry();
                entityentrySubdivision.SetEntityAutocompleteSelectorFactory(
                    new EntityAutocompleteSelectorFactory <SubdivisionsJournalViewModel>(typeof(Subdivision), () => {
                    var filter             = new SubdivisionFilterViewModel();
                    filter.SubdivisionType = SubdivisionType.Logistic;
                    IEntityAutocompleteSelectorFactory employeeSelectorFactory =
                        new DefaultEntityAutocompleteSelectorFactory
                        <Employee, EmployeesJournalViewModel, EmployeeFilterViewModel>(ServicesConfig.CommonServices);
                    return(new SubdivisionsJournalViewModel(
                               filter,
                               UnitOfWorkFactory.GetDefaultFactory,
                               ServicesConfig.CommonServices,
                               employeeSelectorFactory
                               ));
                })
                    );
                entityentrySubdivision.Binding.AddBinding(Entity, e => e.Subdivision, w => w.Subject).InitializeFromSource();
                hboxSubdivision.Add(entityentrySubdivision);
                hboxSubdivision.ShowAll();
                return;
            }

            var entrySubdivision = new yEntryReference();

            entrySubdivision.SubjectType = typeof(Subdivision);
            entrySubdivision.Binding.AddBinding(Entity, e => e.Subdivision, w => w.Subject).InitializeFromSource();
            hboxSubdivision.Add(entrySubdivision);
            hboxSubdivision.ShowAll();

            if (!canManageOfficeWorkers && !canManageDriversAndForwarders)
            {
                entrySubdivision.Sensitive = false;
            }
        }
Beispiel #5
0
        private void DrawNewRow(Phone newPhone)
        {
            if (hBoxList?.FirstOrDefault() == null)
            {
                hBoxList = new List <HBox>();
            }

            HBox hBox = new HBox();

            var phoneDataCombo = new yListComboBox();

            phoneDataCombo.WidthRequest = 100;
            phoneDataCombo.SetRenderTextFunc((PhoneType x) => x.Name);
            phoneDataCombo.ItemsList = viewModel.PhoneTypes;
            phoneDataCombo.Binding.AddBinding(newPhone, e => e.PhoneType, w => w.SelectedItem).InitializeFromSource();
            phoneDataCombo.Binding.AddFuncBinding(viewModel, e => !e.ReadOnly, w => w.Sensitive).InitializeFromSource();
            hBox.Add(phoneDataCombo);
            hBox.SetChildPacking(phoneDataCombo, true, true, 0, PackType.Start);

            Label textPhoneLabel = new Label("+7");

            hBox.Add(textPhoneLabel);
            hBox.SetChildPacking(textPhoneLabel, false, false, 0, PackType.Start);

            var phoneDataEntry = new yValidatedEntry();

            phoneDataEntry.ValidationMode = ValidationType.phone;
            phoneDataEntry.Tag            = newPhone;
            phoneDataEntry.WidthRequest   = 110;
            phoneDataEntry.WidthChars     = 19;
            phoneDataEntry.Binding.AddBinding(newPhone, e => e.Number, w => w.Text).InitializeFromSource();
            phoneDataEntry.Binding.AddFuncBinding(viewModel, e => !e.ReadOnly, w => w.IsEditable).InitializeFromSource();
            hBox.Add(phoneDataEntry);
            hBox.SetChildPacking(phoneDataEntry, false, false, 0, PackType.Start);

            HandsetView handset = new HandsetView(newPhone.DigitsNumber);

            hBox.Add(handset);
            hBox.SetChildPacking(handset, false, false, 0, PackType.Start);

            var textAdditionalLabel = new Gtk.Label("доб.");

            hBox.Add(textAdditionalLabel);
            hBox.SetChildPacking(textAdditionalLabel, false, false, 0, PackType.Start);

            var additionalDataEntry = new yEntry();

            additionalDataEntry.WidthRequest = 40;
            additionalDataEntry.MaxLength    = 10;
            additionalDataEntry.Binding.AddBinding(newPhone, e => e.Additional, w => w.Text).InitializeFromSource();
            additionalDataEntry.Binding.AddFuncBinding(viewModel, e => !e.ReadOnly, w => w.IsEditable).InitializeFromSource();
            hBox.Add(additionalDataEntry);
            hBox.SetChildPacking(additionalDataEntry, false, false, 0, PackType.Start);

            var labelComment = new Label("коммент.:");

            hBox.Add(labelComment);
            hBox.SetChildPacking(labelComment, false, false, 0, PackType.Start);

            var entryComment = new yEntry();

            entryComment.MaxLength = 150;
            entryComment.Binding.AddBinding(newPhone, e => e.Comment, w => w.Text).InitializeFromSource();
            entryComment.Binding.AddFuncBinding(viewModel, e => !e.ReadOnly, w => w.IsEditable).InitializeFromSource();
            hBox.Add(entryComment);
            hBox.SetChildPacking(entryComment, true, true, 0, PackType.Start);

            if (ViewModel.RoboAtsCounterpartyNameSelectorFactory != null)
            {
                var labelName = new Label("имя:");
                hBox.PackStart(labelName, false, false, 0);

                var entityviewmodelentryName = new EntityViewModelEntry();
                entityviewmodelentryName.Binding.AddBinding(viewModel, vm => vm.CanEditCounterpartyName, w => w.CanEditReference)
                .InitializeFromSource();
                entityviewmodelentryName.Binding.AddBinding(newPhone, e => e.RoboAtsCounterpartyName, w => w.Subject)
                .InitializeFromSource();
                entityviewmodelentryName.Binding
                .AddFuncBinding(viewModel, vm => !vm.ReadOnly && vm.CanReadCounterpartyName, w => w.IsEditable).InitializeFromSource();
                entityviewmodelentryName.SetEntityAutocompleteSelectorFactory(ViewModel.RoboAtsCounterpartyNameSelectorFactory);
                entityviewmodelentryName.WidthRequest = 170;
                hBox.PackStart(entityviewmodelentryName, true, true, 0);
            }

            if (ViewModel.RoboAtsCounterpartyPatronymicSelectorFactory != null)
            {
                var labelPatronymic = new Label("отч.:");
                hBox.PackStart(labelPatronymic, false, false, 0);

                var entityviewmodelentryPatronymic = new EntityViewModelEntry();
                entityviewmodelentryPatronymic.Binding
                .AddBinding(viewModel, vm => vm.CanEditCounterpartyPatronymic, w => w.CanEditReference).InitializeFromSource();
                entityviewmodelentryPatronymic.Binding.AddBinding(newPhone, e => e.RoboAtsCounterpartyPatronymic, w => w.Subject)
                .InitializeFromSource();
                entityviewmodelentryPatronymic.Binding
                .AddFuncBinding(viewModel, vm => !vm.ReadOnly && vm.CanReadCounterpartyPatronymic, w => w.IsEditable)
                .InitializeFromSource();
                entityviewmodelentryPatronymic.SetEntityAutocompleteSelectorFactory(ViewModel.RoboAtsCounterpartyPatronymicSelectorFactory);
                entityviewmodelentryPatronymic.WidthRequest = 170;
                hBox.PackStart(entityviewmodelentryPatronymic, true, true, 0);
            }

            yButton deleteButton = new yButton();
            Image   image        = new Image();

            image.Pixbuf          = Stetic.IconLoader.LoadIcon(this, "gtk-delete", IconSize.Menu);
            deleteButton.Image    = image;
            deleteButton.Clicked += (sender, e) => viewModel.DeleteItemCommand.Execute(hBox.Data["phone"] as Phone);
            deleteButton.Binding.AddFuncBinding(viewModel, e => !e.ReadOnly, w => w.Sensitive).InitializeFromSource();
            hBox.Add(deleteButton);
            hBox.SetChildPacking(deleteButton, false, false, 0, PackType.Start);

            hBox.Data.Add("phone", newPhone);             //Для свзяки виджета и телефона
            hBox.ShowAll();

            vboxPhones.Add(hBox);
            vboxPhones.ShowAll();
            hBoxList.Add(hBox);
        }