private void CreateAddWriteoffItemCommand()
 {
     AddWriteoffItemCommand = new DelegateCommand(
         () => {
         var fuelTypeJournalViewModel = new SimpleEntityJournalViewModel <FuelType, FuelTypeViewModel>(x => x.Name,
                                                                                                       () => new FuelTypeViewModel(EntityUoWBuilder.ForCreate(), unitOfWorkFactory, commonServices),
                                                                                                       (node) => new FuelTypeViewModel(EntityUoWBuilder.ForOpen(node.Id), unitOfWorkFactory, commonServices),
                                                                                                       QS.DomainModel.UoW.UnitOfWorkFactory.GetDefaultFactory,
                                                                                                       commonServices
                                                                                                       );
         fuelTypeJournalViewModel.SetRestriction(() => {
             return(Restrictions.Not(Restrictions.In(Projections.Id(), Entity.ObservableFuelWriteoffDocumentItems.Select(x => x.FuelType.Id).ToArray())));
         });
         fuelTypeJournalViewModel.SelectionMode           = JournalSelectionMode.Single;
         fuelTypeJournalViewModel.OnEntitySelectedResult += (sender, e) => {
             var node = e.SelectedNodes.FirstOrDefault();
             if (node == null)
             {
                 return;
             }
             Entity.AddNewWriteoffItem(UoW.GetById <FuelType>(node.Id));
         };
         TabParent.AddSlaveTab(this, fuelTypeJournalViewModel);
     },
         () => CanEdit
         );
     AddWriteoffItemCommand.CanExecuteChangedWith(this, x => CanEdit);
 }
Exemplo n.º 2
0
        public CreateComplaintViewModel(Order order,
                                        IEntityUoWBuilder uowBuilder,
                                        IUnitOfWorkFactory unitOfWorkFactory,
                                        IEmployeeService employeeService,
                                        IEntityAutocompleteSelectorFactory counterpartySelectorFactory,
                                        ISubdivisionRepository subdivisionRepository,
                                        ICommonServices commonServices,
                                        INomenclatureRepository nomenclatureRepository,
                                        IUserRepository userRepository,
                                        IFilePickerService filePickerService,
                                        IOrderSelectorFactory orderSelectorFactory,
                                        IEmployeeJournalFactory employeeJournalFactory,
                                        ICounterpartyJournalFactory counterpartyJournalFactory,
                                        IDeliveryPointJournalFactory deliveryPointJournalFactory,
                                        ISubdivisionJournalFactory subdivisionJournalFactory,
                                        IGtkTabsOpener gtkDialogsOpener,
                                        IUndeliveredOrdersJournalOpener undeliveredOrdersJournalOpener,
                                        INomenclatureSelectorFactory nomenclatureSelector,
                                        IUndeliveredOrdersRepository undeliveredOrdersRepository,
                                        string phone = null) : this(uowBuilder, unitOfWorkFactory, employeeService, counterpartySelectorFactory, subdivisionRepository,
                                                                    commonServices, nomenclatureRepository, userRepository, filePickerService, orderSelectorFactory,
                                                                    employeeJournalFactory, counterpartyJournalFactory, deliveryPointJournalFactory, subdivisionJournalFactory, gtkDialogsOpener,
                                                                    undeliveredOrdersJournalOpener, nomenclatureSelector, undeliveredOrdersRepository, phone)
        {
            var currentOrder = UoW.GetById <Order>(order.Id);

            Entity.Order        = currentOrder;
            Entity.Counterparty = currentOrder.Client;
            Entity.Phone        = phone;
        }
Exemplo n.º 3
0
        protected override void ConfigureWithUow()
        {
            enumcomboDocumentType.ItemsEnum   = typeof(DocumentType);
            enumcomboDocumentType.HiddenItems = new[] { DocumentType.DeliveryDocument as object };

            yentryrefWarehouse.ItemsQuery = StoreDocumentHelper.GetRestrictedWarehouseQuery();

            if (ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("user_have_access_only_to_warehouse_and_complaints") &&
                !ServicesConfig.CommonServices.UserService.GetCurrentUser(UoW).IsAdmin)
            {
                yentryrefWarehouse.Sensitive = yentryrefWarehouse.CanEditReference = false;
            }

            if (CurrentUserSettings.Settings.DefaultWarehouse != null)
            {
                yentryrefWarehouse.Subject = UoW.GetById <Warehouse>(CurrentUserSettings.Settings.DefaultWarehouse.Id);
            }

            var filter = new EmployeeRepresentationFilterViewModel();

            filter.SetAndRefilterAtOnce(
                x => x.RestrictCategory = EmployeeCategory.driver,
                x => x.Status           = EmployeeStatus.IsWorking
                );
            yentryrefDriver.RepresentationModel = new EmployeesVM(filter);
            dateperiodDocs.StartDate            = DateTime.Today.AddDays(-7);
            dateperiodDocs.EndDate = DateTime.Today.AddDays(1);

            comboMovementStatus.ItemsEnum = typeof(MovementDocumentStatus);
        }
Exemplo n.º 4
0
 private void CreateActivateNodeAction()
 {
     PopupActionsList.Add(
         new JournalAction(
             "Активировать",
             selectedItems => canActivateDistrictsSet && canUpdate &&
             selectedItems.OfType <DistrictsSetJournalNode>().FirstOrDefault()?.Status == DistrictsSetStatus.Draft,
             selectedItems => true,
             selectedItems => {
         var selectedNodes = selectedItems.OfType <DistrictsSetJournalNode>();
         var selectedNode  = selectedNodes.FirstOrDefault();
         if (selectedNode == null)
         {
             return;
         }
         var activeDistrictsSet = UoW.Session.QueryOver <DistrictsSet>().Where(x => x.Status == DistrictsSetStatus.Active).Take(1).SingleOrDefault();
         if (activeDistrictsSet?.DateCreated > selectedNode.DateCreated)
         {
             commonServices.InteractiveService.ShowMessage(ImportanceLevel.Warning, "Нельзя активировать, так как дата создания выбранной версии меньше чем дата создания активной версии");
             return;
         }
         var selectedDistrictsSet = UoW.GetById <DistrictsSet>(selectedNode.Id);
         if (selectedDistrictsSet.Districts.All(x => x.CopyOf == null) &&
             !commonServices.InteractiveService.Question("Для выбранной версии невозможно перенести все приоритеты работы водителей\nПродолжить?"))
         {
             return;
         }
         TabParent.AddSlaveTab(this,
                               new DistrictsSetActivationViewModel(EntityUoWBuilder.ForOpen(selectedNode.Id), QS.DomainModel.UoW.UnitOfWorkFactory.GetDefaultFactory, commonServices)
                               );
     }
             )
         );
 }
        private IJournalAction CreateGiveFuelAction()
        {
            return(new JournalAction(
                       "Выдать топливо",
                       selectedItems => selectedItems.FirstOrDefault() is RouteListJournalNode node &&
                       _fuelIssuingStatuses.Contains(node.StatusEnum),
                       selectedItems => true,
                       selectedItems =>
            {
                if (!(selectedItems.FirstOrDefault() is RouteListJournalNode selectedNode))
                {
                    return;
                }

                var routeList = UoW.GetById <RouteList>(selectedNode.Id);
                TabParent.OpenTab(
                    DialogHelper.GenerateDialogHashName <RouteList>(selectedNode.Id),
                    () => new FuelDocumentViewModel(
                        routeList,
                        commonServices,
                        _subdivisionRepository,
                        _employeeRepository,
                        _fuelRepository,
                        NavigationManagerProvider.NavigationManager,
                        _trackRepository,
                        _categoryRepository,
                        _employeeJournalFactory,
                        _carJournalFactory
                        )
                    );
            }
                       ));
        }
Exemplo n.º 6
0
        private void NomenclatureSelectorOnEntitySelectedResult(object sender, JournalSelectedNodesEventArgs e)
        {
            var nomenclatureNode = e.SelectedNodes.FirstOrDefault();

            if (nomenclatureNode == null)
            {
                return;
            }

            var nomenclature = UoW.GetById <Nomenclature>(nomenclatureNode.Id);

            var node = new GoodsReceptionVMNode
            {
                Category       = nomenclature.Category,
                NomenclatureId = nomenclature.Id,
                Name           = nomenclature.Name
            };

            if (node.Category == NomenclatureCategory.equipment)
            {
                node.Direction = Domain.Orders.Direction.PickUp;
            }

            if (!GoodsReceptionList.Any(n => n.NomenclatureId == node.NomenclatureId))
            {
                GoodsReceptionList.Add(node);
            }
        }
        private void CreateActivateNodeAction()
        {
            PopupActionsList.Add(
                new JournalAction(
                    "Активировать",
                    selectedItems => canActivateDistrictsSet && canUpdate &&
                    selectedItems.OfType <FinancialDistrictsSetsJournalNode>().FirstOrDefault()?.Status == DistrictsSetStatus.Draft,
                    selectedItems => true,
                    selectedItems => {
                var selectedNodes = selectedItems.OfType <FinancialDistrictsSetsJournalNode>();
                var selectedNode  = selectedNodes.FirstOrDefault();

                if (selectedNode == null)
                {
                    return;
                }

                var activeFinancialDistrictsSet = UoW.Session.QueryOver <FinancialDistrictsSet>()
                                                  .Where(x => x.Status == DistrictsSetStatus.Active)
                                                  .Take(1)
                                                  .SingleOrDefault();

                if (activeFinancialDistrictsSet?.DateCreated > selectedNode.DateCreated)
                {
                    commonServices.InteractiveService.ShowMessage(ImportanceLevel.Warning, "Нельзя активировать, так как дата создания выбранной версии меньше чем дата создания активной версии");
                    return;
                }

                var selectedFinancialDistrictsSet = UoW.GetById <FinancialDistrictsSet>(selectedNode.Id);

                FinancialDistrictSetActivation(selectedFinancialDistrictsSet, activeFinancialDistrictsSet);
            }
                    )
                );
        }
        private void CreateCloseNodeAction()
        {
            PopupActionsList.Add(
                new JournalAction(
                    "Закрыть",
                    selectedItems => canUpdate &&
                    selectedItems.OfType <FinancialDistrictsSetsJournalNode>().FirstOrDefault()?.Status == DistrictsSetStatus.Draft,
                    selectedItems => true,
                    selectedItems => {
                var selectedNodes = selectedItems.OfType <FinancialDistrictsSetsJournalNode>();
                var selectedNode  = selectedNodes.FirstOrDefault();

                if (selectedNode != null)
                {
                    var districtsSet = UoW.GetById <FinancialDistrictsSet>(selectedNode.Id);

                    if (districtsSet != null)
                    {
                        districtsSet.Status        = DistrictsSetStatus.Closed;
                        districtsSet.DateClosed    = DateTime.Now;
                        districtsSet.DateActivated = null;
                        UoW.Save(districtsSet);
                        UoW.Commit();
                        Refresh();
                    }
                }
            }
                    )
                );
        }
        //FIXME отделить от GTK
        void CreateSelfDeliveryCashInvoices(int orderId)
        {
            var order = UoW.GetById <VodovozOrder>(orderId);

            if (order.SelfDeliveryIsFullyPaid(new CashRepository()))
            {
                MessageDialogHelper.RunInfoDialog("Заказ уже оплачен полностью");
                return;
            }

            if (order.OrderSum > 0 && !order.SelfDeliveryIsFullyIncomePaid())
            {
                MainClass.MainWin.TdiMain.OpenTab(
                    "selfDelivery_" + DialogHelper.GenerateDialogHashName <Income>(orderId),
                    () => new CashIncomeSelfDeliveryDlg(order, PermissionsSettings.PermissionService)
                    );
            }

            if (order.OrderSumReturn > 0 && !order.SelfDeliveryIsFullyExpenseReturned())
            {
                MainClass.MainWin.TdiMain.OpenTab(
                    "selfDelivery_" + DialogHelper.GenerateDialogHashName <Expense>(orderId),
                    () => new CashExpenseSelfDeliveryDlg(order, PermissionsSettings.PermissionService)
                    );
            }
        }
Exemplo n.º 10
0
 public StoreItemDlg(CarWindow glass) : this()
 {
     if (glass != null)
     {
         Entity.CarWindow = UoW.GetById <CarWindow>(glass.Id);
     }
 }
        protected override void ConfigureWithUow()
        {
            enumcomboDocumentType.ItemsEnum   = typeof(DocumentType);
            enumcomboDocumentType.HiddenItems = new[] { DocumentType.DeliveryDocument as object };

            evmeWarehouse.SetEntityAutocompleteSelectorFactory(new WarehouseSelectorFactory());

            if (ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("user_have_access_only_to_warehouse_and_complaints") &&
                !ServicesConfig.CommonServices.UserService.GetCurrentUser(UoW).IsAdmin)
            {
                evmeWarehouse.Sensitive = evmeWarehouse.CanEditReference = false;
            }

            if (CurrentUserSettings.Settings.DefaultWarehouse != null)
            {
                evmeWarehouse.Subject = UoW.GetById <Warehouse>(CurrentUserSettings.Settings.DefaultWarehouse.Id);
            }

            var filter = new EmployeeFilterViewModel();

            filter.SetAndRefilterAtOnce(
                x => x.RestrictCategory = EmployeeCategory.driver,
                x => x.Status           = EmployeeStatus.IsWorking
                );
            var driverFactory = new EmployeeJournalFactory(filter);

            evmeDriver.SetEntityAutocompleteSelectorFactory(driverFactory.CreateEmployeeAutocompleteSelectorFactory());
            dateperiodDocs.StartDate = DateTime.Today.AddDays(-7);
            dateperiodDocs.EndDate   = DateTime.Today.AddDays(1);

            comboMovementStatus.ItemsEnum = typeof(MovementDocumentStatus);
            evmeDriver.Changed           += (sender, args) => OnRefiltered();
            evmeWarehouse.Changed        += (sender, args) => OnRefiltered();
        }
Exemplo n.º 12
0
 private void CreateToDraftNodeAction()
 {
     PopupActionsList.Add(
         new JournalAction(
             "В черновик",
             selectedItems => canUpdate &&
             selectedItems.OfType <DistrictsSetJournalNode>().FirstOrDefault()?.Status == DistrictsSetStatus.Closed,
             selectedItems => true,
             selectedItems => {
         var selectedNodes = selectedItems.OfType <DistrictsSetJournalNode>();
         var selectedNode  = selectedNodes.FirstOrDefault();
         if (selectedNode != null)
         {
             var districtsSet = UoW.GetById <DistrictsSet>(selectedNode.Id);
             if (districtsSet != null)
             {
                 districtsSet.Status        = DistrictsSetStatus.Draft;
                 districtsSet.DateClosed    = null;
                 districtsSet.DateActivated = null;
                 UoW.Save(districtsSet);
                 UoW.Commit();
                 Refresh();
             }
         }
     }
             )
         );
 }
Exemplo n.º 13
0
        void FineDlgExist_EntitySaved(object sender, EntitySavedEventArgs e)
        {
            //Мы здесь не можем выполнить просто рефреш, так как если удалить сотрудника из штрафа, получаем эксепшен.
            int id = FineEditItem.Fine.Id;

            UoW.Session.Evict(FineEditItem.Fine);
            FineEditItem.Fine = UoW.GetById <Fine>(id);
        }
Exemplo n.º 14
0
 public void ConfigureForSalaryGiveout(int employeeId, decimal balance, bool canChangeEmployee, ExpenseType expenseType)
 {
     evmeEmployee.Subject      = UoW.GetById <Employee>(employeeId);
     evmeEmployee.Sensitive    = canChangeEmployee;
     Entity.TypeOperation      = expenseType;
     yspinMoney.ValueAsDecimal = balance;
     UpdateEmployeeBalanceVisibility();
 }
Exemplo n.º 15
0
        void DlgManualSet_ObjectSelected(object sender, ReferenceRepresentationSelectedEventArgs e)
        {
            var dlg        = sender as ReferenceRepresentation;
            var editingRow = dlg.Tag as ReadingXLSRow;

            editingRow.Fitting = UoW.GetById <Fitting>(e.ObjectId);
            editingRow.Status  = ReadingXLSRow.RowStatus.ManualSet;
        }
Exemplo n.º 16
0
        protected void OnButtonSelectTemplateClicked(object sender, EventArgs e)
        {
            var node     = representationtreeview1.GetSelectedObject <CommentsTemplatesVMNode>();
            var template = UoW.GetById <CommentsTemplates>(node.Id);

            Entity.Text           = template.CommentTemplate;
            Entity.CommentsGroups = template.CommentsTmpGroups;
        }
Exemplo n.º 17
0
        void Dlg_ObjectSelected1(object sender, ReferenceRepresentationSelectedEventArgs e)
        {
            var fittings = UoW.GetById <Fitting> (e.GetNodes <FittingVMNode> ().Select(x => x.Id).ToArray());

            foreach (var item in e.GetNodes <FittingVMNode>())
            {
                Entity.AddItem(fittings.First(x => x.Id == item.Id));
            }
        }
Exemplo n.º 18
0
 protected override void ConfigureWithUow()
 {
     speccomboStock.SetRenderTextFunc <Warehouse>(x => x.Name);
     speccomboStock.ItemsList = new WarehouseRepository().GetActiveWarehouse(UoW);
     if (CurrentUserSettings.Settings.DefaultWarehouse != null)
     {
         speccomboStock.SelectedItem = UoW.GetById <Warehouse>(CurrentUserSettings.Settings.DefaultWarehouse.Id);
     }
 }
Exemplo n.º 19
0
        private void SelectFromStock_OnSelectResult(object sender, JournalSelectedEventArgs e)
        {
            var selects = e.GetSelectedObjects <SizeJournalNode>();
            var analogs = UoW.GetById <Size>(selects.Select(x => x.Id));

            foreach (var analog in analogs)
            {
                Entity.ObservableSuitableSizes.Add(analog);
            }
        }
        void SelectDialog_OnSelectResult(object sender, QS.Project.Journal.JournalSelectedEventArgs e)
        {
            var items    = (IssuanceSheetItem[])((EmployeeJournalViewModel)sender).Tag;
            var employee = UoW.GetById <EmployeeCard>(e.SelectedObjects.First().GetId());

            foreach (var item in items)
            {
                item.Employee = employee;
            }
        }
Exemplo n.º 21
0
        void CheckOperation(IncomeType incomeType)
        {
            lblRouteList.Visible             = yEntryRouteList.Visible
                                             = incomeType == IncomeType.DriverReport;

            if (incomeType == IncomeType.DriverReport)
            {
                Entity.IncomeCategory = UoW.GetById <IncomeCategory>(1);
            }
        }
Exemplo n.º 22
0
        void Dlg_ItemPriceSelected(object sender, ReferenceRepresentationSelectedEventArgs e)
        {
            var dlg = sender as ReferenceRepresentation;
            var priceEditingItem = dlg.Tag as ProjectItem;
            var priceItem        = UoW.GetById <PriceItem>(e.ObjectId);

            priceEditingItem.FittingPrice      = priceItem.Cost;
            priceEditingItem.PriceCurrency     = priceItem.Currency;
            priceEditingItem.SelectedPriceItem = priceItem;
        }
 public EmployeeVacationViewModel(
     int employeeId,
     IEntityUoWBuilder uowBuilder,
     IUnitOfWorkFactory unitOfWorkFactory,
     INavigationManager navigation,
     BaseParameters baseParameters,
     IValidator validator = null) : this(uowBuilder, unitOfWorkFactory, navigation, baseParameters)
 {
     Entity.Employee = UoW.GetById <EmployeeCard>(employeeId);
 }
        void SetNomenclature_OnSelectResult(object sender, QS.Project.Journal.JournalSelectedEventArgs e)
        {
            var page         = NavigationManager.FindPage((DialogViewModelBase)sender);
            var items        = page.Tag as IssuanceSheetItem[];
            var nomenclature = UoW.GetById <Nomenclature>(e.SelectedObjects[0].GetId());

            foreach (var item in items)
            {
                item.Nomenclature = nomenclature;
            }
        }
Exemplo n.º 25
0
 void Analog_OnSelectResult(object sender, QS.Project.Journal.JournalSelectedEventArgs e)
 {
     foreach (var toolsNode in e.SelectedObjects)
     {
         var tools = UoW.GetById <ProtectionTools>(toolsNode.GetId());
         if (tools.Type == Entity?.Type)
         {
             Entity.AddAnalog(tools);
         }
     }
 }
Exemplo n.º 26
0
        void JournalViewModel_OnEntitySelectedResult(object sender, JournalSelectedNodesEventArgs e)
        {
            var selectedNode = e.SelectedNodes.FirstOrDefault();

            if (selectedNode != null)
            {
                Subject = UoW.GetById(SubjectType, selectedNode.Id);
            }

            ChangedByUser?.Invoke(sender, e);
        }
Exemplo n.º 27
0
        void AddEmployeeDlg_ObjectSelected(object sender, ReferenceRepresentationSelectedEventArgs e)
        {
            var employee = UoW.GetById <Employee>(e.ObjectId);

            if (Entity.Items.Any(x => x.Employee.Id == employee.Id))
            {
                MessageDialogWorks.RunErrorDialog("Сотрудник {0} уже присутствует в списке.", employee.ShortName);
                return;
            }
            Entity.AddItem(employee);
        }
        public CarLoadDocumentDlg(int routeListId, int?warehouseId)
        {
            this.Build();
            ConfigureNewDoc();

            if (warehouseId.HasValue)
            {
                Entity.Warehouse = UoW.GetById <Warehouse>(warehouseId.Value);
            }
            Entity.RouteList = UoW.GetById <RouteList>(routeListId);
            ConfigureDlg();
        }
Exemplo n.º 29
0
        void Dlg_ObjectSelected(object sender, JournalObjectSelectedEventArgs e)
        {
            var selectedIds = e.GetSelectedIds();

            if (!selectedIds.Any())
            {
                return;
            }
            var points = UoW.GetById <DeliveryPoint>(e.GetSelectedIds()).ToList();

            points.ForEach(Entity.AddDeliveryPoint);
        }
Exemplo n.º 30
0
        private void OnDeliveryPointJournalObjectSelected(object sender, JournalSelectedNodesEventArgs e)
        {
            var selectedIds = e.SelectedNodes;

            if (!selectedIds.Any())
            {
                return;
            }
            var points = UoW.GetById <DeliveryPoint>(e.SelectedNodes.Select(n => n.Id)).ToList();

            points.ForEach(Entity.AddDeliveryPoint);
        }