//отрытие журнала недовоза на конкретном недовозе из диалога штрафов public void OpenFromFine(ITdiTab tab, Order oldOrder, DateTime?deliveryDate, UndeliveryStatus undeliveryStatus) { var undeliveredOrdersFilter = new UndeliveredOrdersFilterViewModel( ServicesConfig.CommonServices, new OrderSelectorFactory(), new EmployeeJournalFactory(), new CounterpartyJournalFactory(), new DeliveryPointJournalFactory(), new SubdivisionJournalFactory()) { RestrictOldOrder = oldOrder, RestrictOldOrderStartDate = deliveryDate, RestrictOldOrderEndDate = deliveryDate, RestrictUndeliveryStatus = undeliveryStatus }; var dlg = new UndeliveredOrdersJournalViewModel( undeliveredOrdersFilter, UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices, new GtkTabsOpener(), new EmployeeJournalFactory(), VodovozGtkServicesConfig.EmployeeService, new UndeliveredOrdersJournalOpener(), new OrderSelectorFactory(), new UndeliveredOrdersRepository()); tab.TabParent.AddSlaveTab(tab, dlg); }
protected void OnBtnShowUndeliveryClicked(object sender, EventArgs e) { var undeliveredOrdersFilter = new UndeliveredOrdersFilterViewModel( ServicesConfig.CommonServices, new OrderSelectorFactory(), new EmployeeJournalFactory(), new CounterpartyJournalFactory(), new DeliveryPointJournalFactory(), new SubdivisionJournalFactory()) { HidenByDefault = true, RestrictOldOrder = Entity.UndeliveredOrder.OldOrder, RestrictOldOrderStartDate = Entity.UndeliveredOrder.OldOrder.DeliveryDate, RestrictOldOrderEndDate = Entity.UndeliveredOrder.OldOrder.DeliveryDate, RestrictUndeliveryStatus = Entity.UndeliveredOrder.UndeliveryStatus }; var dlg = new UndeliveredOrdersJournalViewModel( undeliveredOrdersFilter, UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices, new GtkTabsOpener(), new EmployeeJournalFactory(), VodovozGtkServicesConfig.EmployeeService, new UndeliveredOrdersJournalOpener(), new OrderSelectorFactory(), new UndeliveredOrdersRepository() ); TabParent.AddSlaveTab(this, dlg); }
public ITdiTab OpenUndeliveriesWithCommentsPrintDlg(ITdiTab tab, UndeliveredOrdersFilterViewModel filter) { return(tab.TabParent.OpenTab( nameof(UndeliveriesWithCommentsPrintDlg), () => new UndeliveriesWithCommentsPrintDlg(filter) )); }
private void DrawRefreshed(UndeliveredOrdersFilterViewModel undeliveredOrdersFilter) { lblCaption.Markup = "<u><b>Сводка по недовозам\nСписок виновных:</b></u>"; yTreeView.ItemsDataSource = guilties; lblTotalUdeliveredBottles.Markup = $"Воды 19л: <b>{guilties.Sum(g => (decimal) g[3]):N0}</b> бут."; lblTotalUndeliveredOrders.Markup = $"Заказов: <b>{guilties.Sum(o => (int) o[1])}</b> шт."; }
public IList <object[]> GetGuilties(UndeliveredOrdersFilterViewModel filter) { OrderItem orderItemAlias = null; Nomenclature nomenclatureAlias = null; UndeliveredOrder undeliveredOrderAlias = null; Domain.Orders.Order oldOrderAlias = null; Domain.Orders.Order newOrderAlias = null; Employee oldOrderAuthorAlias = null; Counterparty counterpartyAlias = null; DeliveryPoint undeliveredOrderDeliveryPointAlias = null; Subdivision subdivisionAlias = null; GuiltyInUndelivery guiltyInUndeliveryAlias = null; Employee authorAlias = null; var subquery19LWatterQty = QueryOver.Of <OrderItem>(() => orderItemAlias) .Where(() => orderItemAlias.Order.Id == oldOrderAlias.Id) .Left.JoinQueryOver(i => i.Nomenclature, () => nomenclatureAlias) .Where(n => n.Category == NomenclatureCategory.water && n.TareVolume == TareVolume.Vol19L) .Select(Projections.Sum(() => orderItemAlias.Count)); var query = _uow.Session.QueryOver <UndeliveredOrder>(() => undeliveredOrderAlias) .Left.JoinAlias(u => u.OldOrder, () => oldOrderAlias) .Left.JoinAlias(u => u.NewOrder, () => newOrderAlias) .Left.JoinAlias(() => oldOrderAlias.Client, () => counterpartyAlias) .Left.JoinAlias(() => oldOrderAlias.Author, () => oldOrderAuthorAlias) .Left.JoinAlias(() => oldOrderAlias.DeliveryPoint, () => undeliveredOrderDeliveryPointAlias) .Left.JoinAlias(() => undeliveredOrderAlias.GuiltyInUndelivery, () => guiltyInUndeliveryAlias) .Left.JoinAlias(() => guiltyInUndeliveryAlias.GuiltyDepartment, () => subdivisionAlias) .Left.JoinAlias(u => u.Author, () => authorAlias); if (filter?.RestrictDriver != null) { var oldOrderIds = _undeliveredOrdersRepository.GetListOfUndeliveryIdsForDriver(_uow, filter.RestrictDriver); query.Where(() => oldOrderAlias.Id.IsIn(oldOrderIds.ToArray())); } if (filter?.RestrictOldOrder != null) { query.Where(() => oldOrderAlias.Id == filter.RestrictOldOrder.Id); } if (filter?.RestrictClient != null) { query.Where(() => counterpartyAlias.Id == filter.RestrictClient.Id); } if (filter?.RestrictAddress != null) { query.Where(() => undeliveredOrderDeliveryPointAlias.Id == filter.RestrictAddress.Id); } if (filter?.RestrictOldOrderAuthor != null) { query.Where(() => oldOrderAuthorAlias.Id == filter.RestrictOldOrderAuthor.Id); } if (filter?.RestrictOldOrderStartDate != null) { query.Where(() => oldOrderAlias.DeliveryDate >= filter.RestrictOldOrderStartDate); } if (filter?.RestrictOldOrderEndDate != null) { query.Where(() => oldOrderAlias.DeliveryDate <= filter.RestrictOldOrderEndDate.Value.AddDays(1).AddTicks(-1)); } if (filter?.RestrictNewOrderStartDate != null) { query.Where(() => newOrderAlias.DeliveryDate >= filter.RestrictNewOrderStartDate); } if (filter?.RestrictNewOrderEndDate != null) { query.Where(() => newOrderAlias.DeliveryDate <= filter.RestrictNewOrderEndDate.Value.AddDays(1).AddTicks(-1)); } if (filter?.RestrictGuiltySide != null) { query.Where(() => guiltyInUndeliveryAlias.GuiltySide == filter.RestrictGuiltySide); } if (filter != null && filter.RestrictIsProblematicCases) { query.Where(() => !guiltyInUndeliveryAlias.GuiltySide.IsIn(filter.ExcludingGuiltiesForProblematicCases)); } if (filter?.RestrictGuiltyDepartment != null) { query.Where(() => subdivisionAlias.Id == filter.RestrictGuiltyDepartment.Id); } if (filter?.RestrictInProcessAtDepartment != null) { query.Where(u => u.InProcessAtDepartment.Id == filter.RestrictInProcessAtDepartment.Id); } if (filter?.NewInvoiceCreated != null) { if (filter.NewInvoiceCreated.Value) { query.Where(u => u.NewOrder != null); } else { query.Where(u => u.NewOrder == null); } } if (filter?.RestrictUndeliveryStatus != null) { query.Where(u => u.UndeliveryStatus == filter.RestrictUndeliveryStatus); } if (filter?.RestrictUndeliveryAuthor != null) { query.Where(u => u.Author == filter.RestrictUndeliveryAuthor); } if (filter?.RestrictAuthorSubdivision != null) { query.Where(() => authorAlias.Subdivision.Id == filter.RestrictAuthorSubdivision.Id); } int position = 0; var result = query.SelectList(list => list .SelectGroup(u => u.Id) .Select(Projections.SqlFunction( new SQLFunctionTemplate( NHibernateUtil.String, "GROUP_CONCAT(" + "CASE ?1 " + $"WHEN '{nameof(GuiltyTypes.Department)}' THEN IFNULL(CONCAT('Отд: ', ?2), 'Отдел ВВ') " + $"WHEN '{nameof(GuiltyTypes.Client)}' THEN 'Клиент' " + $"WHEN '{nameof(GuiltyTypes.Driver)}' THEN 'Водитель' " + $"WHEN '{nameof(GuiltyTypes.ServiceMan)}' THEN 'Мастер СЦ' " + $"WHEN '{nameof(GuiltyTypes.ForceMajor)}' THEN 'Форс-мажор' " + $"WHEN '{nameof(GuiltyTypes.None)}' THEN 'Нет (не недовоз)' " + "ELSE ?1 " + "END ORDER BY ?1 ASC SEPARATOR '\n')" ), NHibernateUtil.String, Projections.Property(() => guiltyInUndeliveryAlias.GuiltySide), Projections.Property(() => subdivisionAlias.ShortName))) .SelectSubQuery(subquery19LWatterQty)) .List <object[]>() .GroupBy(x => x[1]) .Select(r => new[] { r.Key, r.Count(), position++, r.Sum(x => x[2] == null ? 0 : (decimal)x[2]) }) .ToList(); return(result); }
protected override void CreatePopupActions() { bool IsOrder(object[] objs) { var selectedNodes = objs.Cast <RetailOrderJournalNode>(); if (selectedNodes.Count() != 1) { return(false); } return(selectedNodes.FirstOrDefault().EntityType == typeof(VodovozOrder)); } PopupActionsList.Add( new JournalAction( "Перейти в маршрутный лист", selectedItems => selectedItems.Any( x => AccessRouteListKeeping((x as RetailOrderJournalNode).Id)) && IsOrder(selectedItems), selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <RetailOrderJournalNode>(); var addresses = UoW.Session.QueryOver <RouteListItem>() .Where(x => x.Order.Id.IsIn(selectedNodes.Select(n => n.Id).ToArray())).List(); var routes = addresses.GroupBy(x => x.RouteList.Id); var tdiMain = MainClass.MainWin.TdiMain; foreach (var route in routes) { tdiMain.OpenTab( DialogHelper.GenerateDialogHashName <RouteList>(route.Key), () => new RouteListKeepingDlg(route.Key, route.Select(x => x.Order.Id).ToArray()) ); } } ) ); PopupActionsList.Add( new JournalAction( "Перейти в недовоз", (selectedItems) => selectedItems.Any( o => _undeliveredOrdersRepository.GetListOfUndeliveriesForOrder( UoW, (o as RetailOrderJournalNode).Id).Any()) && IsOrder(selectedItems), selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <RetailOrderJournalNode>(); var order = UoW.GetById <VodovozOrder>(selectedNodes.FirstOrDefault().Id); var undeliveredOrdersFilter = new UndeliveredOrdersFilterViewModel( _commonServices, _orderSelectorFactory, _employeeJournalFactory, _counterpartyJournalFactory, _deliveryPointJournalFactory, _subdivisionJournalFactory) { HidenByDefault = true, RestrictOldOrder = order, RestrictOldOrderStartDate = order.DeliveryDate, RestrictOldOrderEndDate = order.DeliveryDate }; var dlg = new UndeliveredOrdersJournalViewModel( undeliveredOrdersFilter, UnitOfWorkFactory, _commonServices, _gtkDialogsOpener, _employeeJournalFactory, _employeeService, _undeliveredOrdersJournalOpener, _orderSelectorFactory, _undeliveredOrdersRepository ); MainClass.MainWin.TdiMain.AddTab(dlg); } ) ); PopupActionsList.Add( new JournalAction( "Открыть диалог закрытия", (selectedItems) => selectedItems.Any( x => AccessToRouteListClosing((x as RetailOrderJournalNode).Id)) && IsOrder(selectedItems), selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <RetailOrderJournalNode>(); var routeListIds = selectedNodes.Select(x => x.Id).ToArray(); var addresses = UoW.Session.QueryOver <RouteListItem>() .Where(x => x.Order.Id.IsIn(routeListIds)).List(); var routes = addresses.GroupBy(x => x.RouteList.Id); var tdiMain = MainClass.MainWin.TdiMain; foreach (var rl in routes) { tdiMain.OpenTab( DialogHelper.GenerateDialogHashName <RouteList>(rl.Key), () => new RouteListClosingDlg(rl.Key) ); } } ) ); PopupActionsList.Add( new JournalAction( "Открыть на Yandex картах(координаты)", IsOrder, selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <RetailOrderJournalNode>(); foreach (var sel in selectedNodes) { var order = UoW.GetById <VodovozOrder>(sel.Id); if (order.DeliveryPoint == null || order.DeliveryPoint.Latitude == null || order.DeliveryPoint.Longitude == null) { continue; } System.Diagnostics.Process.Start( string.Format( CultureInfo.InvariantCulture, "https://maps.yandex.ru/?ll={0},{1}&z=17", order.DeliveryPoint.Longitude, order.DeliveryPoint.Latitude ) ); } } ) ); PopupActionsList.Add( new JournalAction( "Открыть на Yandex картах(адрес)", IsOrder, selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <RetailOrderJournalNode>(); foreach (var sel in selectedNodes) { var order = UoW.GetById <VodovozOrder>(sel.Id); if (order.DeliveryPoint == null) { continue; } System.Diagnostics.Process.Start( string.Format(CultureInfo.InvariantCulture, "https://maps.yandex.ru/?text={0} {1} {2}", order.DeliveryPoint.City, order.DeliveryPoint.Street, order.DeliveryPoint.Building ) ); } } ) ); PopupActionsList.Add( new JournalAction( "Открыть на карте OSM", IsOrder, selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <RetailOrderJournalNode>(); foreach (var sel in selectedNodes) { var order = UoW.GetById <VodovozOrder>(sel.Id); if (order.DeliveryPoint == null || order.DeliveryPoint.Latitude == null || order.DeliveryPoint.Longitude == null) { continue; } System.Diagnostics.Process.Start(string.Format(CultureInfo.InvariantCulture, "http://www.openstreetmap.org/#map=17/{1}/{0}", order.DeliveryPoint.Longitude, order.DeliveryPoint.Latitude)); } } ) ); PopupActionsList.Add( new JournalAction( "Повторить заказ", IsOrder, selectedItems => true, (selectedItems) => { var selectedNodes = selectedItems.Cast <RetailOrderJournalNode>(); var order = UoW.GetById <VodovozOrder>(selectedNodes.FirstOrDefault().Id); var dlg = new OrderDlg(); dlg.CopyLesserOrderFrom(order.Id); var tdiMain = MainClass.MainWin.TdiMain; tdiMain.OpenTab( DialogHelper.GenerateDialogHashName <Domain.Orders.Order>(65656), () => dlg ); } ) ); }
public UndeliveriesWithCommentsPrintDlg(UndeliveredOrdersFilterViewModel filter) { this.Build(); if (filter.RestrictOldOrder != null) { oldOrderId = filter.RestrictOldOrder.Id; } if (filter.RestrictDriver != null) { driverId = filter.RestrictDriver.Id; } if (filter.RestrictClient != null) { clientId = filter.RestrictClient.Id; } if (filter.RestrictAddress != null) { addressId = filter.RestrictAddress.Id; } if (filter.RestrictOldOrderAuthor != null) { oldOrderAuthorId = filter.RestrictOldOrderAuthor.Id; } if (filter.RestrictOldOrderStartDate.HasValue) { oldOrderStartDate = filter.RestrictOldOrderStartDate.Value.ToString("s"); } if (filter.RestrictOldOrderEndDate.HasValue) { oldOrderEndDate = filter.RestrictOldOrderEndDate.Value.ToString("s"); } if (filter.RestrictNewOrderStartDate.HasValue) { newOrderStartDate = filter.RestrictNewOrderStartDate.Value.ToString("s"); } if (filter.RestrictNewOrderEndDate.HasValue) { newOrderEndDate = filter.RestrictNewOrderEndDate.Value.ToString("s"); } if (filter.RestrictGuiltySide.HasValue) { guiltySides = new[] { filter.RestrictGuiltySide.Value.ToString() } } ; if (filter.RestrictGuiltyDepartment != null) { guiltyDepartmentId = filter.RestrictGuiltyDepartment.Id; } if (filter.NewInvoiceCreated.HasValue) { newInvoiceCreated = filter.NewInvoiceCreated.Value ? "true" : "false"; } if (filter.RestrictUndeliveryStatus.HasValue) { undeliveryStatus = filter.RestrictUndeliveryStatus.ToString(); } if (filter.RestrictUndeliveryAuthor != null) { undeliveryAuthorId = filter.RestrictUndeliveryAuthor.Id; } if (filter.RestrictIsProblematicCases) { guiltySides = Enum.GetValues(typeof(GuiltyTypes)) .Cast <GuiltyTypes>() .Where(t => !filter.ExcludingGuiltiesForProblematicCases.Contains(t)) .Select(g => g.ToString()) .ToArray() ; } TabName = "Печать недовозов и комментариев"; Configure(); } void Configure() { PreviewDocument(); } void PreviewDocument() { var reportInfo = GetReportInfo(); reportViewer.LoadReport(reportInfo.GetReportUri(), reportInfo.GetParametersString(), reportInfo.ConnectionString, true); }