protected void OpenTab(string hashName, Func <ITdiTab> newTabFunc) { ITdiTab tab = TabParent.FindTab(hashName); if (tab == null) { TabParent.AddTab(newTabFunc(), this); } else { TabParent.SwitchOnTab(tab); } }
void YentryreferenceRLTo_Changed(object sender, EventArgs e) { if (yentryreferenceRLTo.Subject == null) { ytreeviewRLTo.ItemsDataSource = null; return; } RouteList routeListTo = yentryreferenceRLTo.Subject as RouteList; RouteList routeListFrom = yentryreferenceRLFrom.Subject as RouteList; if (DomainHelper.EqualDomainObjects(routeListFrom, routeListTo)) { yentryreferenceRLTo.Subject = null; MessageDialogHelper.RunErrorDialog("Вы дурачёк?", "Вы не можете передавать адреса в тот же МЛ, из которого забираете."); return; } if (TabParent != null) { var tab = TabParent.FindTab(DialogHelper.GenerateDialogHashName <RouteList>(routeListTo.Id)); if (!(tab is RouteListClosingDlg)) { if (tab != null) { MessageDialogHelper.RunErrorDialog("Маршрутный лист уже открыт в другой вкладке"); yentryreferenceRLTo.Subject = null; return; } } } CheckSensitivities(); routeListTo.UoW = UoW; IList <RouteListItemNode> items = new List <RouteListItemNode>(); foreach (var item in routeListTo.Addresses) { items.Add(new RouteListItemNode { RouteListItem = item }); } ytreeviewRLTo.ItemsDataSource = items; FillObservableDriverBalance(ObservableDriverBalanceTo, routeListTo); }
private IJournalAction CreateReturnToEnRouteAction() { return(new JournalAction( "Вернуть в путь", selectedItems => selectedItems.FirstOrDefault() is RouteListJournalNode node && _canReturnToEnRoute.Contains(node.StatusEnum), selectedItems => true, selectedItems => { var routeListIds = selectedItems.Cast <RouteListJournalNode>().Select(x => x.Id).ToArray(); bool isSlaveTabActive = false; using (var uowLocal = UnitOfWorkFactory.CreateWithoutRoot()) { var routeLists = uowLocal.Session.QueryOver <RouteList>() .Where(x => x.Id.IsIn(routeListIds)) .List(); foreach (var routeList in routeLists.Where(arg => arg.Status == RouteListStatus.Delivered)) { if (TabParent.FindTab(DialogHelper.GenerateDialogHashName <RouteList>(routeList.Id)) != null) { commonServices.InteractiveService.ShowMessage( ImportanceLevel.Info, "Требуется закрыть подчиненную вкладку"); isSlaveTabActive = true; continue; } routeList.ChangeStatusAndCreateTask(RouteListStatus.EnRoute, _callTaskWorker); uowLocal.Save(routeList); } if (isSlaveTabActive) { return; } uowLocal.Commit(); } } )); }
private void SendRouteListsInLoading(IList <RouteListJournalNode> selectedNodes) { var routeListIds = selectedNodes.Select(x => x.Id).ToArray(); using (var uowLocal = UnitOfWorkFactory.CreateWithoutRoot()) { var routeLists = uowLocal.Session.QueryOver <RouteList>() .Where(x => x.Id.IsIn(routeListIds)) .List(); bool needShowMessage = false; var messageStockList = new List <LackStockNode>(); foreach (var routeList in routeLists) { int warehouseId = 0; if (routeList.ClosingSubdivision.Id == _routeListParametersProvider.CashSubdivisionSofiiskayaId) { warehouseId = _routeListParametersProvider.WarehouseSofiiskayaId; } if (routeList.ClosingSubdivision.Id == _routeListParametersProvider.CashSubdivisionParnasId) { warehouseId = _routeListParametersProvider.WarehouseParnasId; } if (warehouseId > 0) { var onlineOrders = routeList.Addresses .SelectMany(adressItem => adressItem.Order.OrderItems) .Where(orderItem => orderItem.Nomenclature.OnlineStore != null) .ToList(); var warehouseStocks = _warehouseRepository .GetWarehouseNomenclatureStock(UoW, warehouseId, onlineOrders.Select(o => o.Nomenclature.Id).Distinct()) .ToList(); var lackWarehouseStocks = onlineOrders .Join(warehouseStocks, o => o.Nomenclature.Id, w => w.NomenclatureId, (o, w) => new LackStockNode { OrderId = o.Order.Id, NomenclatureName = o.Nomenclature.Name, Count = o.Count, Stock = w.Stock, Measure = o.Nomenclature.Unit.Name }) .Where(w => w.Stock < w.Count); messageStockList.AddRange(lackWarehouseStocks); var notExistInWarehouseNomenclatures = onlineOrders .Where(o => warehouseStocks.All(w => w.NomenclatureId != o.Nomenclature.Id)) .Select(o => new LackStockNode { OrderId = o.Order.Id, NomenclatureName = o.Nomenclature.Name, Count = o.Count, Measure = o.Nomenclature.Unit.Name }); messageStockList.AddRange(notExistInWarehouseNomenclatures); } } var stockMessage = new StringBuilder(); if (messageStockList.Count > 0) { needShowMessage = true; stockMessage.Append("В наличии нет следующих товаров:"); messageStockList.ForEach(messageItem => { stockMessage.Append(Environment.NewLine); stockMessage.Append( $"Заказ {messageItem.OrderId}: {messageItem.NomenclatureName} - {messageItem.Count} {messageItem.Measure}"); }); stockMessage.Append($"{Environment.NewLine}Всё равно отправить МЛ на погрузку?"); } if (needShowMessage && !commonServices.InteractiveService.Question(stockMessage.ToString())) { return; } bool isSlaveTabActive = false; foreach (var routeList in routeLists.Where(arg => arg.Status == RouteListStatus.Confirmed)) { if (TabParent.FindTab(DialogHelper.GenerateDialogHashName <RouteList>(routeList.Id)) != null) { commonServices.InteractiveService.ShowMessage(ImportanceLevel.Info, "Требуется закрыть подчиненную вкладку"); isSlaveTabActive = true; continue; } foreach (var address in routeList.Addresses) { if (address.Order.OrderStatus < OrderStatus.OnLoading) { address.Order.ChangeStatusAndCreateTasks(OrderStatus.OnLoading, _callTaskWorker); } } routeList.ChangeStatusAndCreateTask(RouteListStatus.InLoading, _callTaskWorker); uowLocal.Save(routeList); } if (isSlaveTabActive) { return; } uowLocal.Commit(); } }
protected void InitPopupActions() { var callTaskWorker = new CallTaskWorker( CallTaskSingletonFactory.GetInstance(), callTaskRepository, new OrderRepository(), new EmployeeRepository(), baseParametersProvider, commonServices.UserService, SingletonErrorReporter.Instance); PopupActionsList.Add(new JournalAction( "Закрытие МЛ", (selectedItems) => selectedItems.Any(x => closingDlgStatuses.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => selectedItems.Any(x => closingDlgStatuses.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => { var selectedNode = selectedItems.FirstOrDefault() as RouteListJournalNode; if (selectedNode != null && closingDlgStatuses.Contains(selectedNode.StatusEnum)) { TabParent.OpenTab( DialogHelper.GenerateDialogHashName <RouteList>(selectedNode.Id), () => new RouteListClosingDlg(selectedNode.Id) ); } } )); PopupActionsList.Add(new JournalAction( "Создание талона погрузки", (selectedItems) => selectedItems.Any(x => createCarLoadDocument.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => selectedItems.Any(x => createCarLoadDocument.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => { var selectedNode = selectedItems.FirstOrDefault() as RouteListJournalNode; if (selectedNode != null) { TabParent.OpenTab(() => new CarLoadDocumentDlg(selectedNode.Id, null)); } } )); PopupActionsList.Add(new JournalAction( "Создание талона разгрузки", (selectedItems) => selectedItems.Any(x => createCarUnloadDocument.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => selectedItems.Any(x => createCarUnloadDocument.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => { var selectedNode = selectedItems.FirstOrDefault() as RouteListJournalNode; if (selectedNode != null) { TabParent.OpenTab(() => new CarUnloadDocumentDlg(selectedNode.Id, null)); } } )); PopupActionsList.Add(new JournalAction( "Выдать топливо", (selectedItems) => selectedItems.Any(x => fuelIssuingStatuses.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => selectedItems.Any(x => fuelIssuingStatuses.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => { var selectedNode = selectedItems.FirstOrDefault() as RouteListJournalNode; if (selectedNode != null) { var RouteList = UoW.GetById <RouteList>(selectedNode.Id); TabParent.OpenTab( DialogHelper.GenerateDialogHashName <RouteList>(selectedNode.Id), () => new FuelDocumentViewModel( RouteList, commonServices, subdivisionRepository, new EmployeeRepository(), fuelRepository, NavigationManagerProvider.NavigationManager, new TrackRepository(), new CategoryRepository(new ParametersProvider()) ) ); } } )); PopupActionsList.Add(new JournalAction( "Вернуть в статус Сдается", (selectedItems) => selectedItems.Any(x => canReturnToOnClosing.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => selectedItems.Any(x => canReturnToOnClosing.Contains((x as RouteListJournalNode).StatusEnum)), (selectedItems) => { var selectedNode = selectedItems.FirstOrDefault() as RouteListJournalNode; bool isSlaveTabActive = false; if (selectedNode != null) { using (var uowLocal = UnitOfWorkFactory.CreateWithoutRoot()) { var routeList = uowLocal.Session.QueryOver <RouteList>() .Where(x => x.Id == selectedNode.Id) .List().FirstOrDefault(); if (canReturnToOnClosing.Contains(routeList.Status)) { if (TabParent.FindTab(DialogHelper.GenerateDialogHashName <RouteList>(routeList.Id)) != null) { MessageDialogHelper.RunInfoDialog("Требуется закрыть подчиненную вкладку"); isSlaveTabActive = true; return; } routeList.ChangeStatusAndCreateTask(RouteListStatus.OnClosing, callTaskWorker); uowLocal.Save(routeList); if (isSlaveTabActive) { return; } } uowLocal.Commit(); } } } )); }
public ITdiTab FindTab(string hashName, string masterHashName = null) { return(TabParent.FindTab(hashName, masterHashName)); }