private void CreateEditAction() { var editAction = new JournalAction("Открыть заказ", (selected) => { var selectedNodes = selected.OfType <DriverMessageJournalNode>(); return(selectedNodes.Count() == 1); }, (selected) => true, (selected) => { var selectedNodes = selected.OfType <DriverMessageJournalNode>(); if (selectedNodes.Count() != 1) { return; } var selectedNode = selectedNodes.First(); _gtkTabsOpener.OpenOrderDlg(this, selectedNode.OrderId); HideJournal(); } ); RowActivatedAction = editAction; NodeActionsList.Add(editAction); }
protected override void CreatePopupActions() { PopupActionsList.Add( new JournalAction( "Перейти в недовезённый заказ", selectedItems => true, selectedItems => true, selectedItems => { var selectedNodes = selectedItems.OfType <UndeliveredOrderJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode != null) { _gtkDlgOpener.OpenOrderDlg(this, selectedNode.OldOrderId); } } ) ); PopupActionsList.Add( new JournalAction( "Перейти в новый заказ", selectedItems => { var selectedNodes = selectedItems.OfType <UndeliveredOrderJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); return(selectedNode != null && selectedNode.NewOrderId > 0); }, selectedItems => true, selectedItems => { var selectedNodes = selectedItems.OfType <UndeliveredOrderJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode != null) { _gtkDlgOpener.OpenOrderDlg(this, selectedNode.NewOrderId); } } ) ); PopupActionsList.Add( new JournalAction( "Закрыть недовоз", selectedItems => { var selectedNodes = selectedItems.OfType <UndeliveredOrderJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); return(selectedNode != null && selectedNode.UndeliveryStatus != UndeliveryStatus.Closed && _canCloseUndeliveries); }, selectedItems => true, selectedItems => { var selectedNodes = selectedItems.OfType <UndeliveredOrderJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode == null) { return; } UndeliveredOrder undeliveredOrder = UoW.GetById <UndeliveredOrder>(selectedNode.Id); undeliveredOrder.Close(CurrentEmployee); UoW.Save(undeliveredOrder); UoW.Commit(); } ) ); PopupActionsList.Add( new JournalAction( "Создать штраф", selectedItems => true, selectedItems => true, selectedItems => { var selectedNodes = selectedItems.OfType <UndeliveredOrderJournalNode>(); var selectedNode = selectedNodes.FirstOrDefault(); if (selectedNode == null) { return; } FineViewModel fineViewModel = new FineViewModel( EntityUoWBuilder.ForCreate(), UnitOfWorkFactory, _undeliveryViewOpener, _employeeService, _driverEmployeeJournalFactory.CreateWorkingDriverEmployeeAutocompleteSelectorFactory(), _employeeSettings, _commonServices ); var undeliveredOrder = UoW.GetById <UndeliveredOrder>(selectedNode.Id); fineViewModel.UndeliveredOrder = undeliveredOrder; fineViewModel.RouteList = new RouteListItemRepository().GetRouteListItemForOrder(UoW, undeliveredOrder.OldOrder)?.RouteList; TabParent.AddSlaveTab(this, fineViewModel); } ) ); }
protected override void CreatePopupActions() { Complaint GetComplaint(object[] objs) { var selectedNodes = objs.Cast <ComplaintJournalNode>(); if (selectedNodes.Count() != 1) { return(null); } var complaint = UoW.GetById <Complaint>(selectedNodes.FirstOrDefault().Id); return(complaint); } Order GetOrder(object[] objs) { var complaint = GetComplaint(objs); return(GetComplaint(objs)?.Order); } RouteList GetRouteList(object[] objs) { var order = GetOrder(objs); if (order == null) { return(null); } var rl = _routeListItemRepository.GetRouteListItemForOrder(UoW, order)?.RouteList; return(rl); } bool HasOrder(object[] objs) => GetOrder(objs) != null; bool HasRouteList(object[] objs) => GetRouteList(objs) != null; PopupActionsList.Add( new JournalAction( "Открыть заказ", HasOrder, n => true, n => _gtkDlgOpener.OpenOrderDlg(this, GetOrder(n).Id) ) ); PopupActionsList.Add( new JournalAction( "Открыть маршрутный лист", HasRouteList, n => true, n => _gtkDlgOpener.OpenCreateRouteListDlg(this, GetRouteList(n).Id) ) ); PopupActionsList.Add( new JournalAction( "Создать штраф", n => EntityConfigs[typeof(Complaint)].PermissionResult.CanUpdate, n => EntityConfigs[typeof(Complaint)].PermissionResult.CanUpdate, n => { var currentComplaintId = n.OfType <ComplaintJournalNode>().FirstOrDefault()?.Id; ComplaintViewModel currentComplaintVM = null; if (currentComplaintId.HasValue) { currentComplaintVM = new ComplaintViewModel( EntityUoWBuilder.ForOpen(currentComplaintId.Value), _unitOfWorkFactory, _commonServices, _undeliveredOrdersJournalOpener, _employeeService, _counterpartySelectorFactory, _filePickerService, _subdivisionRepository, _nomenclatureRepository, _userRepository, _orderSelectorFactory, _employeeJournalFactory, _counterpartyJournalFactory, _deliveryPointJournalFactory, _subdivisionJournalFactory, _gtkDlgOpener, _undeliveredOrdersJournalOpener, _salesPlanJournalFactory, _nomenclatureSelector, _undeliveredOrdersRepository ); currentComplaintVM.AddFineCommand.Execute(this); } } ) ); PopupActionsList.Add( new JournalAction( "Закрыть рекламацию", n => n.OfType <ComplaintJournalNode>().FirstOrDefault()?.Status != ComplaintStatuses.Closed && canCloseComplaint, n => EntityConfigs[typeof(Complaint)].PermissionResult.CanUpdate && canCloseComplaint, n => { var currentComplaintId = n.OfType <ComplaintJournalNode>().FirstOrDefault()?.Id; ComplaintViewModel currentComplaintVM = null; if (currentComplaintId.HasValue) { currentComplaintVM = new ComplaintViewModel( EntityUoWBuilder.ForOpen(currentComplaintId.Value), _unitOfWorkFactory, _commonServices, _undeliveredOrdersJournalOpener, _employeeService, _counterpartySelectorFactory, _filePickerService, _subdivisionRepository, _nomenclatureRepository, _userRepository, _orderSelectorFactory, _employeeJournalFactory, _counterpartyJournalFactory, _deliveryPointJournalFactory, _subdivisionJournalFactory, _gtkDlgOpener, _undeliveredOrdersJournalOpener, _salesPlanJournalFactory, _nomenclatureSelector, _undeliveredOrdersRepository ); string msg = string.Empty; if (!currentComplaintVM.Entity.Close(ref msg)) { ShowWarningMessage(msg, "Не удалось закрыть"); } else { currentComplaintVM.Save(); } } } ) ); }