Esempio n. 1
0
        protected void OnBtnShowUndeliveryClicked(object sender, EventArgs e)
        {
            UndeliveriesView dlg = new UndeliveriesView();

            dlg.HideFilterAndControls();
            dlg.UndeliveredOrdersFilter.SetAndRefilterAtOnce(
                x => x.RestrictOldOrder          = Entity.UndeliveredOrder.OldOrder,
                x => x.RestrictOldOrderStartDate = Entity.UndeliveredOrder.OldOrder.DeliveryDate,
                x => x.RestrictOldOrderEndDate   = Entity.UndeliveredOrder.OldOrder.DeliveryDate,
                x => x.RestrictUndeliveryStatus  = Entity.UndeliveredOrder.UndeliveryStatus
                );
            TabParent.AddSlaveTab(this, dlg);
        }
Esempio n. 2
0
        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);
                UndeliveriesView dlg = new UndeliveriesView();
                dlg.HideFilterAndControls();
                dlg.UndeliveredOrdersFilter.SetAndRefilterAtOnce(
                    x => x.ResetFilter(),
                    x => x.RestrictOldOrder          = order,
                    x => x.RestrictOldOrderStartDate = order.DeliveryDate,
                    x => x.RestrictOldOrderEndDate   = order.DeliveryDate
                    );
                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
                    );
            }
                    )
                );
        }