Пример #1
0
        public SetBillsReport(IUnitOfWorkFactory unitOfWorkFactory)
        {
            this.Build();

            UoW = unitOfWorkFactory.CreateWithoutRoot();

            daterangepickerOrderCreation.StartDate = DateTime.Now;
            daterangepickerOrderCreation.EndDate   = DateTime.Now;
            ybuttonCreateReport.Clicked           += (sender, e) => { OnUpdate(true); };
            ybuttonCreateReport.TooltipText        = $"Формирует отчет по заказам в статусе '{OrderStatus.WaitForPayment.GetEnumTitle()}'";

            entrySubdivision.SetEntityAutocompleteSelectorFactory(
                new EntityAutocompleteSelectorFactory <SubdivisionsJournalViewModel>(typeof(Subdivision),
                                                                                     () => {
                var filter = new SubdivisionFilterViewModel();
                var employeeAutoCompleteSelectorFactory =
                    new DefaultEntityAutocompleteSelectorFactory <Employee, EmployeesJournalViewModel, EmployeeFilterViewModel>(
                        ServicesConfig.CommonServices);

                return(new SubdivisionsJournalViewModel(
                           filter,
                           unitOfWorkFactory,
                           ServicesConfig.CommonServices,
                           employeeAutoCompleteSelectorFactory
                           ));
            })
                );
        }
 public SubdivisionJournalViewModel(IUnitOfWorkFactory unitOfWorkFactory,
                                    IInteractiveService interactiveService,
                                    INavigationManager navigationManager,
                                    ILifetimeScope autofacScope,
                                    IDeleteEntityService deleteEntityService           = null,
                                    ICurrentPermissionService currentPermissionService = null
                                    ) : base(unitOfWorkFactory, interactiveService, navigationManager, deleteEntityService, currentPermissionService)
 {
     AutofacScope  = autofacScope;
     JournalFilter = Filter = AutofacScope.Resolve <SubdivisionFilterViewModel>(
         new TypedParameter(typeof(JournalViewModelBase), this));
 }
Пример #3
0
        private void ConfigureDlg()
        {
            yentryName.Binding
            .AddBinding(ViewModel.Entity, e => e.Name, (widget) => widget.Text)
            .InitializeFromSource();

            yentryNumbering.Binding
            .AddBinding(ViewModel.Entity, e => e.Numbering, (widget) => widget.Text)
            .InitializeFromSource();

            #region ParentEntityviewmodelentry
            ParentEntityviewmodelentry.SetEntityAutocompleteSelectorFactory(ViewModel.ExpenseCategoryAutocompleteSelectorFactory);
            ParentEntityviewmodelentry.Binding.AddBinding(ViewModel.Entity, s => s.Parent, w => w.Subject).InitializeFromSource();
            ParentEntityviewmodelentry.CanEditReference = true;
            #endregion


            #region SubdivisionEntityviewmodelentry
            //Это создается тут, а не в ExpenseCategoryViewModel потому что EmployeesJournalViewModel и EmployeeFilterViewModel нет в ViewModels
            var employeeSelectorFactory =
                new DefaultEntityAutocompleteSelectorFactory
                <Employee, EmployeesJournalViewModel, EmployeeFilterViewModel>(ServicesConfig.CommonServices);

            var filter = new SubdivisionFilterViewModel()
            {
                SubdivisionType = SubdivisionType.Default
            };

            SubdivisionEntityviewmodelentry.SetEntityAutocompleteSelectorFactory(
                new EntityAutocompleteSelectorFactory <SubdivisionsJournalViewModel>(typeof(Subdivision), () => {
                return(new SubdivisionsJournalViewModel(
                           filter,
                           UnitOfWorkFactory.GetDefaultFactory,
                           ServicesConfig.CommonServices,
                           employeeSelectorFactory
                           ));
            })
                );
            SubdivisionEntityviewmodelentry.Binding.AddBinding(ViewModel.Entity, s => s.Subdivision, w => w.Subject).InitializeFromSource();
            #endregion

            ycheckArchived.Binding.AddBinding(ViewModel, e => e.IsArchive, w => w.Active).InitializeFromSource();



            yenumTypeDocument.ItemsEnum = typeof(ExpenseInvoiceDocumentType);
            yenumTypeDocument.Binding.AddBinding(ViewModel.Entity, e => e.ExpenseDocumentType, w => w.SelectedItem).InitializeFromSource();

            buttonSave.Clicked   += (sender, e) => { ViewModel.SaveAndClose(); };
            buttonCancel.Clicked += (sender, e) => { ViewModel.Close(false, QS.Navigation.CloseSource.Cancel); };
        }
Пример #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;
            }
        }
Пример #5
0
        protected override void ConfigureWithUow()
        {
            yEnumCMBGuilty.ItemsEnum             = typeof(GuiltyTypes);
            enumCMBUndeliveryStatus.ItemsEnum    = typeof(UndeliveryStatus);
            enumCMBUndeliveryStatus.SelectedItem = UndeliveryStatus.InProcess;
            yEnumCMBActionWithInvoice.ItemsEnum  = typeof(ActionsWithInvoice);
            ySpecCMBinProcessAt.ItemsList        = ySpecCMBGuiltyDep.ItemsList = EmployeeRepository.Subdivisions(UoW);

            refOldOrder.RepresentationModel = new OrdersVM(new OrdersFilter(UoW));
            refOldOrder.CanEditReference    = ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("can_delete");

            var driversFilter = new EmployeeFilterViewModel();

            driversFilter.SetAndRefilterAtOnce(
                x => x.RestrictCategory = EmployeeCategory.driver,
                x => x.Status           = EmployeeStatus.IsWorking
                );
            refDriver.RepresentationModel = new EmployeesVM(driversFilter);

            refClient.RepresentationModel = new CounterpartyVM(new CounterpartyFilter(UoW));
            entityVMEntryDeliveryPoint.SetEntityAutocompleteSelectorFactory(
                new DefaultEntityAutocompleteSelectorFactory <DeliveryPoint, DeliveryPointJournalViewModel, DeliveryPointJournalFilterViewModel>(ServicesConfig.CommonServices));

            var authorsFilter = new EmployeeFilterViewModel();

            authorsFilter.SetAndRefilterAtOnce(
                x => x.RestrictCategory = EmployeeCategory.office,
                x => x.Status           = EmployeeStatus.IsWorking
                );
            refOldOrderAuthor.RepresentationModel = refUndeliveryAuthor.RepresentationModel = new EmployeesVM(authorsFilter);

            dateperiodOldOrderDate.StartDateOrNull = DateTime.Today.AddMonths(-1);
            dateperiodOldOrderDate.EndDateOrNull   = DateTime.Today.AddMonths(1);
            chkProblematicCases.Toggled           += (sender, e) => {
                if (chkProblematicCases.Active)
                {
                    yEnumCMBGuilty.SelectedItemOrNull = null;
                    ySpecCMBGuiltyDep.Visible         = lblGuiltyDep.Visible = false;
                }
                yEnumCMBGuilty.Sensitive = !chkProblematicCases.Active;
                OnRefiltered();
            };

            //Подразделение
            var employeeSelectorFactory =
                new DefaultEntityAutocompleteSelectorFactory
                <Employee, EmployeesJournalViewModel, EmployeeFilterViewModel>(ServicesConfig.CommonServices);

            var filter = new SubdivisionFilterViewModel()
            {
                SubdivisionType = SubdivisionType.Default
            };


            AuthorSubdivisionEntityviewmodelentry.SetEntityAutocompleteSelectorFactory(
                new EntityAutocompleteSelectorFactory <SubdivisionsJournalViewModel>(
                    typeof(Subdivision),
                    () => new SubdivisionsJournalViewModel(
                        filter,
                        UnitOfWorkFactory.GetDefaultFactory,
                        ServicesConfig.CommonServices,
                        employeeSelectorFactory
                        )
                    )
                );

            AuthorSubdivisionEntityviewmodelentry.Changed += AuthorSubdivisionEntityviewmodelentryOnChanged;
        }
Пример #6
0
        private void ConfigureDlg()
        {
            #region EntityViewModelEntry

            //Автор
            var currentEmployee = ViewModel.CurrentEmployee;
            AuthorEntityviewmodelentry.SetEntityAutocompleteSelectorFactory(
                new EntityAutocompleteSelectorFactory <EmployeesJournalViewModel>(typeof(Employee),
                                                                                  () =>
            {
                var employeeFilter = new EmployeeFilterViewModel
                {
                    Status = EmployeeStatus.IsWorking,
                };
                return(new EmployeesJournalViewModel(
                           employeeFilter,
                           UnitOfWorkFactory.GetDefaultFactory,
                           ServicesConfig.CommonServices));
            })
                );
            AuthorEntityviewmodelentry.Binding.AddBinding(ViewModel.Entity, x => x.Author, w => w.Subject)
            .InitializeFromSource();

            if (ViewModel.IsNewEntity)
            {
                ViewModel.Entity.Author = currentEmployee;
            }

            AuthorEntityviewmodelentry.Sensitive = false;

            //Подразделение
            var employeeSelectorFactory =
                new DefaultEntityAutocompleteSelectorFactory
                <Employee, EmployeesJournalViewModel, EmployeeFilterViewModel>(ServicesConfig.CommonServices);

            var filter = new SubdivisionFilterViewModel()
            {
                SubdivisionType = SubdivisionType.Default
            };

            SubdivisionEntityviewmodelentry.SetEntityAutocompleteSelectorFactory(
                new EntityAutocompleteSelectorFactory <SubdivisionsJournalViewModel>(
                    typeof(Subdivision),
                    () => new SubdivisionsJournalViewModel(
                        filter,
                        UnitOfWorkFactory.GetDefaultFactory,
                        ServicesConfig.CommonServices,
                        employeeSelectorFactory
                        )
                    )
                );
            SubdivisionEntityviewmodelentry.Binding
            .AddBinding(
                ViewModel.Entity,
                s => s.Subdivision,
                w => w.Subject)
            .InitializeFromSource();
            SubdivisionEntityviewmodelentry.Sensitive = false;
            ViewModel.Entity.Subdivision = currentEmployee.Subdivision;

            //Причина расхода
            ExpenseCategoryEntityviewmodelentry
            .SetEntityAutocompleteSelectorFactory(ViewModel.ExpenseCategoryAutocompleteSelectorFactory);

            ExpenseCategoryEntityviewmodelentry.Binding.AddBinding(
                ViewModel.Entity,
                s => s.ExpenseCategory,
                w => w.Subject)
            .InitializeFromSource();

            ExpenseCategoryEntityviewmodelentry.CanEditReference = true;

            #endregion EntityViewModelEntry

            #region Combo

            //Организация
            speccomboOrganization.SetRenderTextFunc <Organization>(s => s.Name);
            var orgList = ViewModel.UoW.Session.QueryOver <Organization>().List();
            speccomboOrganization.ItemsList = orgList;
            speccomboOrganization.Binding.AddBinding(
                ViewModel.Entity,
                x => x.Organization,
                x => x.SelectedItem)
            .InitializeFromSource();

            if (speccomboOrganization.SelectedItem == null)
            {
                speccomboOrganization.SelectedItem = orgList.First();
            }

            //Смена ролей для админов
            comboIfAdminRoleChooser.ItemsEnum = typeof(UserRole);
            comboIfAdminRoleChooser.Binding.AddBinding(
                ViewModel,
                e => CashRequestViewModel.savedUserRole,
                w => w.SelectedItem).InitializeFromSource();
            comboIfAdminRoleChooser.SelectedItem = ViewModel.UserRole;
            comboIfAdminRoleChooser.Visible      = ViewModel.IsAdminPanelVisible;
            ybtnAdminRoleRemember.Visible        = ViewModel.IsAdminPanelVisible;
            ybtnAdminRoleRemember.Clicked       += (sender, args) => { ViewModel.RememberRole(comboIfAdminRoleChooser.SelectedItem); };

            #endregion

            #region TextEntry

            //Пояснение
            yentryExplanation.Binding
            .AddBinding(
                ViewModel.Entity,
                e => e.Explanation,
                (widget) => widget.Text)
            .InitializeFromSource();

            //Основание
            yentryGround.Binding
            .AddBinding(
                ViewModel.Entity,
                e => e.Basis,
                (widget) => widget.Buffer.Text)
            .InitializeFromSource();
            yentryGround.WrapMode = WrapMode.Word;

            //Причина отмены
            yentryCancelReason.Binding
            .AddBinding(
                ViewModel.Entity,
                e => e.CancelReason,
                (widget) => widget.Buffer.Text)
            .InitializeFromSource();
            yentryCancelReason.WrapMode = WrapMode.Word;


            //Причина отправки на пересогласование
            yentryReasonForSendToReapproval.Binding
            .AddBinding(
                ViewModel.Entity,
                e => e.ReasonForSendToReappropriate,
                (widget) => widget.Buffer.Text)
            .InitializeFromSource();
            yentryReasonForSendToReapproval.WrapMode = WrapMode.Word;


            #endregion TextEntry

            #region Buttons

            ybtnAccept.Clicked += (sender, args) =>
            {
                ViewModel.AcceptCommand.Execute();
            };
            ybtnApprove.Clicked += (sender, args) => ViewModel.ApproveCommand.Execute();
            ybtnCancel.Clicked  += (sender, args) => ViewModel.CancelCommand.Execute();
            //Передать на выдачу
            ybtnConveyForResults.Clicked += (sender, args) => ViewModel.ConveyForResultsCommand.Execute();
            //Отправить на пересогласование
            ybtnReturnForRenegotiation.Clicked += (sender, args) => ViewModel.ReturnToRenegotiationCommand.Execute();

            ybtnGiveSumm.Clicked += (sender, args) => ViewModel.GiveSumCommand.Execute();
            ybtnGiveSumm.Binding.AddBinding(ViewModel, vm => vm.CanGiveSum, w => w.Visible).InitializeFromSource();
            ybtnGiveSumm.Sensitive = ViewModel.Entity.ObservableSums.Any(x => x.Expense == null);


            ybtnAddSumm.Clicked    += (sender, args) => ViewModel.AddSumCommand.Execute();
            ybtnEditSum.Clicked    += (sender, args) => ViewModel.EditSumCommand.Execute();
            ybtnDeleteSumm.Clicked += (sender, args) => ViewModel.DeleteSumCommand.Execute();
            ybtnEditSum.Binding.AddBinding(ViewModel, vm => vm.CanEditSumSensitive, w => w.Sensitive).InitializeFromSource();

            //Visible
            ybtnAccept.Binding.AddBinding(ViewModel, vm => vm.CanAccept, w => w.Visible).InitializeFromSource();
            ybtnApprove.Binding.AddBinding(ViewModel, vm => vm.CanApprove, w => w.Visible).InitializeFromSource();
            ybtnCancel.Binding.AddBinding(ViewModel, vm => vm.CanCancel, w => w.Visible).InitializeFromSource();
            ybtnConveyForResults.Binding.AddBinding(ViewModel, vm => vm.CanConveyForResults, w => w.Visible).InitializeFromSource();
            ybtnReturnForRenegotiation.Binding.AddBinding(ViewModel, vm => vm.CanReturnToRenegotiation, w => w.Visible).InitializeFromSource();
            ybtnDeleteSumm.Binding.AddBinding(ViewModel, vm => vm.CanDeleteSum, w => w.Visible).InitializeFromSource();
            ybtnEditSum.Visible   = false;
            buttonSave.Clicked   += (sender, args) => ViewModel.AfterSaveCommand.Execute();
            buttonCancel.Clicked += (s, e) => { ViewModel.Close(false, QS.Navigation.CloseSource.Cancel); };

            #endregion Buttons

            #region Editibility

            yentryCancelReason.Binding.AddBinding(ViewModel, vm => vm.CanEditOnlyCoordinator, w => w.Sensitive).InitializeFromSource();
            ExpenseCategoryEntityviewmodelentry.Binding.AddBinding(ViewModel, vm => vm.ExpenseCategorySensitive, w => w.Sensitive).InitializeFromSource();
            speccomboOrganization.Binding.AddBinding(ViewModel, vm => vm.CanEditOnlyinStateNAGandRoldFinancier, w => w.Sensitive).InitializeFromSource();

            #endregion Editibility

            #region Visibility

            labelBalansOrganizations.Visible  = ViewModel.VisibleOnlyForFinancer;
            ylabelBalansOrganizations.Visible = ViewModel.VisibleOnlyForFinancer;

            speccomboOrganization.Visible  = ViewModel.VisibleOnlyForFinancer;
            labelcomboOrganization.Visible = ViewModel.VisibleOnlyForFinancer;

            labelCategoryEntityviewmodelentry.Binding.AddBinding(ViewModel, vm => vm.ExpenseCategoryVisibility, w => w.Visible);
            ExpenseCategoryEntityviewmodelentry.Binding.AddBinding(ViewModel, vm => vm.ExpenseCategoryVisibility, w => w.Visible);

            yentryReasonForSendToReapproval.Visible = ViewModel.VisibleOnlyForStatusUpperThanCreated;
            labelReasonForSendToReapproval.Visible  = ViewModel.VisibleOnlyForStatusUpperThanCreated;

            yentryCancelReason.Visible = ViewModel.VisibleOnlyForStatusUpperThanCreated;
            labelCancelReason.Visible  = ViewModel.VisibleOnlyForStatusUpperThanCreated;

            if (ViewModel.Entity.State == CashRequest.States.New)
            {
                hseparator1.Visible = false;
                hseparator2.Visible = false;
                hseparator3.Visible = false;
            }

            #endregion Visibility

            ConfigureTreeView();

            ycheckHaveReceipt.Binding.AddBinding(
                ViewModel.Entity,
                e => e.HaveReceipt,
                w => w.Active)
            .InitializeFromSource();

            ylabelBalansOrganizations.Text = ViewModel.LoadOrganizationsSums();

            ylabelRole.Binding.AddFuncBinding(
                ViewModel,
                vm => vm.UserRole.GetEnumTitle(),
                w => w.Text
                ).InitializeFromSource();
            ylabelStatus.Binding.AddBinding(
                ViewModel,
                vm => vm.StateName,
                w => w.Text
                ).InitializeFromSource();
            ylabelStatus.Text = ViewModel.Entity.State.GetEnumTitle();

            if (ViewModel.Entity.State == CashRequest.States.Closed)
            {
                ytreeviewSums.Sensitive                   = false;
                ybtnAddSumm.Sensitive                     = false;
                ybtnAccept.Sensitive                      = false;
                ybtnApprove.Sensitive                     = false;
                ybtnCancel.Sensitive                      = false;
                ybtnDeleteSumm.Sensitive                  = false;
                ybtnEditSum.Sensitive                     = false;
                ybtnGiveSumm.Sensitive                    = false;
                ybtnConveyForResults.Sensitive            = false;
                ybtnReturnForRenegotiation.Sensitive      = false;
                speccomboOrganization.Sensitive           = false;
                yentryExplanation.Sensitive               = false;
                yentryGround.Sensitive                    = false;
                yentryCancelReason.Sensitive              = false;
                yentryReasonForSendToReapproval.Sensitive = false;
            }
        }
 public SubdivisionJournalFactory(SubdivisionFilterViewModel filterViewModel = null)
 {
     _filterViewModel = filterViewModel;
 }