Ejemplo n.º 1
0
        public ShowOffers(List <OfferView> offers)
        {
            MinimumSize = new Size(640, 480);
            KeyPreview  = true;
            Text        = "Предложения";
            var offersTable = new VirtualTable(new TemplateManager <OfferView>(
                                                   () => {
                var row = Row.Headers();

                var header = new Header("Поставщик").Sortable("Supplier");
                header.InlineStyle.Set(StyleElementType.Width, WidthHolder.OffersWidths[0]);
                row.Append(header);

                header = new Header("Наименование").Sortable("ProductSynonym");
                header.InlineStyle.Set(StyleElementType.Width, WidthHolder.OffersWidths[2]);
                row.Append(header);

                header = new Header("Производитель").Sortable("ProducerSynonym");
                header.InlineStyle.Set(StyleElementType.Width, WidthHolder.OffersWidths[3]);
                row.Append(header);
                return(row);
            },
                                                   offer => Row.Cells(offer.Supplier,
                                                                      offer.ProductSynonym,
                                                                      offer.ProducerSynonym)));

            offersTable.CellSpacing = 1;
            offersTable.RegisterBehavior(
                new ToolTipBehavior(),
                new ColumnResizeBehavior(),
                new SortInList());
            offersTable.TemplateManager.Source = offers;
            offersTable.Behavior <ColumnResizeBehavior>().ColumnResized += column => WidthHolder.Update(offersTable, column, WidthHolder.OffersWidths);
            offersTable.TemplateManager.ResetColumns();
            Controls.Add(offersTable.Host);
            this.InputMap().KeyDown(Keys.Escape, Close);
        }
        public ShowSynonymReport(IList <SynonymReportItem> items)
        {
            Text   = "Отчет о сопоставлениях";
            report = new VirtualTable(new TemplateManager <SynonymReportItem>(
                                          () => {
                var row = new Row();

                var widths = WidthHolder.ReportWidths;

                var header = new Header("Пользователь").Sortable("User");
                header.InlineStyle.Set(StyleElementType.Width, widths[0]);
                row.Append(header);

                header = new Header("Прайс").Sortable("Price");
                header.InlineStyle.Set(StyleElementType.Width, widths[1]);
                row.Append(header);

                header = new Header("Регион").Sortable("Region");
                header.InlineStyle.Set(StyleElementType.Width, widths[2]);
                row.Append(header);

                header = new Header("Синоним").Sortable("Synonym");
                header.InlineStyle.Set(StyleElementType.Width, widths[3]);
                row.Append(header);

                header = new Header("Производитель").Sortable("Producer");
                header.InlineStyle.Set(StyleElementType.Width, widths[4]);
                row.Append(header);

                header = new Header("Продукты").Sortable("Products");
                header.InlineStyle.Set(StyleElementType.Width, widths[4]);
                row.Append(header);

                return(row);
            },
                                          i => {
                var row = Row.Cells(i.User, i.Price, i.Region, i.Synonym, i.Producer, i.Products);
                if (i.IsSuspicious == 1)
                {
                    row.AddClass("Suspicious");
                }
                return(row);
            }));
            report.CellSpacing = 1;
            report.RegisterBehavior(new ToolTipBehavior(),
                                    new ColumnResizeBehavior(),
                                    new SortInList(),
                                    new RowSelectionBehavior());
            report.TemplateManager.Source = items.ToList();
            report.Behavior <ColumnResizeBehavior>().ColumnResized += column => WidthHolder.Update(report, column, WidthHolder.ReportWidths);
            report.TemplateManager.ResetColumns();
            report.Host
            .InputMap()
            .KeyDown(Keys.Space, Suspicios)
            .KeyDown(Keys.Delete, Delete)
            .KeyDown(Keys.F11, Reload);

            Controls.Add(report.Host);

            var toolBar = new ToolStrip();

            Controls.Add(toolBar);

            var begin = DateTime.Now.AddDays(-1).Date;
            var end   = DateTime.Now.Date;

            var beginPeriodCalendar = new DateTimePicker {
                Value = begin,
                Width = 130,
            };

            var endPeriodCalendar = new DateTimePicker {
                Value = end,
                Width = 130,
            };

            toolBar
            .Label("C")
            .Host(beginPeriodCalendar)
            .Label("По")
            .Host(endPeriodCalendar)
            .Button("Показать", () => Action(s => {
                lastBeginDate = beginPeriodCalendar.Value;
                lastEndDate   = endPeriodCalendar.Value;
                report.TemplateManager.Source = s.ShowSynonymReport(beginPeriodCalendar.Value, endPeriodCalendar.Value).ToList();
            }))
            .Separator()
            .Button("Suspicious", "Подозрительный (Пробел)", Suspicios)
            .Button("Удалить (Delete)", Delete)
            .Button("Обновить (F11)", Reload);

            MinimumSize = new Size(640, 480);
            KeyPreview  = true;
            this.InputMap().KeyDown(Keys.Escape, Close);
            report.Behavior <IRowSelectionBehavior>().SelectedRowChanged += (oldIndex, newIndex) => {
                var item = report.Translate <SynonymReportItem>(report.ViewPort.GetRow(newIndex));
                if (item.IsSuspicious == 0)
                {
                    toolBar.Items["Suspicious"].Text = "Подозрительный (Пробел)";
                }
                else
                {
                    toolBar.Items["Suspicious"].Text = "Не подозрительный (Пробел)";
                }
            };
        }
        public ShowProductsAndProducers(ProducerDto producer, List <ProducerDto> producers, List <ProductAndProducer> productAndProducers)
        {
            this.producer            = producer;
            this.productAndProducers = productAndProducers;
            this.producers           = producers;

            MinimumSize = new Size(640, 480);
            Size        = new Size(640, 480);
            Text        = "Продукты";
            KeyPreview  = true;
            KeyDown    += (sender, args) => {
                if (args.KeyCode == Keys.Escape)
                {
                    Close();
                }
            };

            productsAndProducers = new VirtualTable(new TemplateManager <ProductAndProducer>(
                                                        () => {
                var row = Row.Headers(new Header().AddClass("CheckBoxColumn"));

                var header = new Header("Продукт").Sortable("Product");
                header.InlineStyle.Set(StyleElementType.Width, WidthHolder.ProductsAndProducersWidths[0]);
                row.Append(header);

                header = new Header("Производитель").Sortable("Producer");
                header.InlineStyle.Set(StyleElementType.Width, WidthHolder.ProductsAndProducersWidths[1]);
                row.Append(header);

                header = new Header("Количество предложений").Sortable("OffersCount");
                header.InlineStyle.Set(StyleElementType.Width, WidthHolder.ProductsAndProducersWidths[2]);
                row.Append(header);

                header = new Header("Количество заказов").Sortable("OrdersCount");
                header.InlineStyle.Set(StyleElementType.Width, WidthHolder.ProductsAndProducersWidths[3]);
                row.Append(header);
                return(row);
            },
                                                        offer => {
                var row = Row.Cells(offer.Product,
                                    offer.Producer,
                                    offer.OffersCount,
                                    offer.OrdersCount);
                if (offer.ExistsInRls == 0)
                {
                    row.AddClass("NotExistsInRls");
                }
                if (offer.ProducerId != producer.Id)
                {
                    row.Prepend(new CheckBoxInput(offer.Selected));
                }
                else
                {
                    row.Prepend(new Cell());
                }
                return(row);
            }));
            productsAndProducers.CellSpacing = 1;
            productsAndProducers.RegisterBehavior(
                new ToolTipBehavior(),
                new SortInList(),
                new RowSelectionBehavior(),
                new ColumnResizeBehavior(),
                new InputSupport(input => {
                var row = (Row)input.Parent.Parent;
                var productAndProducer = productsAndProducers.Translate <ProductAndProducer>(row);
                ((IList <ProductAndProducer>)productsAndProducers.TemplateManager.Source)
                .Where(p => p.ProducerId == productAndProducer.ProducerId)
                .Each(p => p.Selected = ((CheckBoxInput)input).Checked);
                productsAndProducers.RebuildViewPort();
            }));
            productsAndProducers.TemplateManager.Source = productAndProducers;
            productsAndProducers.Behavior <ColumnResizeBehavior>().ColumnResized += column => WidthHolder.Update(productsAndProducers, column, WidthHolder.ProductsAndProducersWidths);
            productsAndProducers.Host.InputMap()
            .KeyDown(Keys.F3, Join)
            .KeyDown(Keys.F4, ShowOffersForProducerId)
            .KeyDown(Keys.F5, ShowOffersForCatalogId);

            var toolStrip = new ToolStrip();

            toolStrip
            .Button(String.Format("Объединить c {0} (F3)", producer.Name), Join)
            .Button("Предложения для производителя (F4)", ShowOffersForProducerId)
            .Button("Предложения для продукта (F5)", ShowOffersForCatalogId);

            productsAndProducers.TemplateManager.ResetColumns();
            Controls.Add(productsAndProducers.Host);
            Controls.Add(toolStrip);
        }
Ejemplo n.º 4
0
        public ShowAssortmentForProducer(uint producerId, Pager <AssortmentDto> assortments)
        {
            Text        = "Ассортимент";
            MinimumSize = new Size(640, 480);

            var tools = new ToolStrip()
                        .Button("Удалить (Delete)", Delete);

            var navigationToolStrip = new ToolStrip()
                                      .Button("Prev", "Предыдущая страница")
                                      .Label("PageLabel", "")
                                      .Button("Next", "Следующая страница");

            assortmentTable = new VirtualTable(new TemplateManager <AssortmentDto>(
                                                   () => Row.Headers(new Header("Проверен").AddClass("CheckBoxColumn1"), "Продукт", "Производитель"),
                                                   a => {
                var row = Row.Cells(new CheckBoxInput(a.Checked).Attr("Name", "Checked"), a.Product, a.Producer);
                if (a.Id == Settings.Default.BookmarkAssortimentId)
                {
                    ((IDomElementWithChildren)row.Children.ElementAt(1)).Prepend(new TextBlock {
                        Class = "BookmarkGlyph"
                    });
                }
                return(row);
            }));
            assortmentTable.CellSpacing = 1;
            assortmentTable.RegisterBehavior(
                new RowSelectionBehavior(),
                new ToolTipBehavior(),
                new ColumnResizeBehavior(),
                new InputController());
            assortmentTable.Behavior <ColumnResizeBehavior>().ColumnResized += column => WidthHolder.Update(assortmentTable, column, WidthHolder.AssortimentWidths);
            assortmentTable.TemplateManager.ResetColumns();
            assortmentTable.Host
            .InputMap()
            .KeyDown(Keys.Delete, Delete);

            assortmentTable.Host.InputMap()
            .KeyDown(Keys.Escape, Close);

            Controls.Add(assortmentTable.Host);
            Controls.Add(navigationToolStrip);
            Controls.Add(tools);

            navigationToolStrip.ActAsPaginator(
                assortments,
                page => {
                Pager <AssortmentDto> pager = null;
                Action(s => { pager = s.ShowAssortmentForProducer(producerId, page); });
                assortmentTable.TemplateManager.Source = pager.Content.ToList();
                return(pager);
            });

            assortmentTable.TemplateManager.Source = assortments.Content.ToList();

            Shown += (s, a) => assortmentTable.Host.Focus();
        }
        public ShowSuspiciousSynonyms(IList <SynonymReportItem> items)
        {
            Text        = "Подозрительные сопоставления";
            MinimumSize = new Size(640, 480);
            var widths = WidthHolder.SyspiciosSynonyms;
            var tools  = new ToolStrip()
                         .Button("Удалить (Delete)", Delete)
                         .Button("Не подозрительный (Пробел)", NotSuspicious)
                         .Button("Отправить уведомление поставщику", SendNotificationToSupplier)
                         .Button("Обновить (F11)", Reload);

            report = new VirtualTable(new TemplateManager <SynonymReportItem>(
                                          () => {
                var row = new Row();

                var header = new Header("Пользователь").Sortable("User");
                header.InlineStyle.Set(StyleElementType.Width, widths[0]);
                row.Append(header);

                header = new Header("Прайс").Sortable("Price");
                header.InlineStyle.Set(StyleElementType.Width, widths[1]);
                row.Append(header);

                header = new Header("Регион").Sortable("Region");
                header.InlineStyle.Set(StyleElementType.Width, widths[2]);
                row.Append(header);

                header = new Header("Синоним").Sortable("Synonym");
                header.InlineStyle.Set(StyleElementType.Width, widths[3]);
                row.Append(header);

                header = new Header("Производитель").Sortable("Producer");
                header.InlineStyle.Set(StyleElementType.Width, widths[4]);
                row.Append(header);

                header = new Header("Продукты").Sortable("Products");
                header.InlineStyle.Set(StyleElementType.Width, widths[4]);
                row.Append(header);

                return(row);
            },
                                          i => Row.Cells(i.User, i.Price, i.Region, i.Synonym, i.Producer, i.Products)));
            report.CellSpacing = 1;
            report.RegisterBehavior(new ToolTipBehavior(),
                                    new ColumnResizeBehavior(),
                                    new RowSelectionBehavior(),
                                    new SortInList());
            report.Host
            .InputMap()
            .KeyDown(Keys.Delete, NotSuspicious)
            .KeyDown(Keys.Space, Delete)
            .KeyDown(Keys.F11, Reload);

            report.TemplateManager.Source = items.ToList();
            report.Behavior <ColumnResizeBehavior>().ColumnResized += column => WidthHolder.Update(report, column, widths);
            report.TemplateManager.ResetColumns();

            Controls.Add(report.Host);
            Controls.Add(tools);
            KeyPreview = true;
            this.InputMap().KeyDown(Keys.Escape, Close);

            Shown += (s, a) => report.Host.Focus();
        }
Ejemplo n.º 6
0
        public ShowAssortment(Pager <AssortmentDto> assortments)
        {
            Text        = "Ассортимент";
            MinimumSize = new Size(640, 480);

            tools = new ToolStrip()
                    .Edit("SearchText")
                    .Button("Поиск", Search)
                    .Separator()
                    .Button("Удалить (Delete)", Delete)
                    .Separator()
                    .Button("Удалить синоним", DeleteProducerSynonym)
                    .Button("Обновить (F11)", Reload);

            navigationToolStrip = new ToolStrip()
                                  .Button("К закаладке", MoveToBookmark)
                                  .Button("Установить закладку", SetBookmark)
                                  .Separator()
                                  .Button("Prev", "Предыдущая страница")
                                  .Label("PageLabel", "")
                                  .Button("Next", "Следующая страница");

            assortmentTable = new VirtualTable(new TemplateManager <AssortmentDto>(
                                                   () => Row.Headers("Продукт", "Производитель"),
                                                   a => {
                var row = Row.Cells(new Cell(new TextBlock(a.Product)), new Cell(new TextBlock(a.Producer)));
                if (a.Id == Settings.Default.BookmarkAssortimentId)
                {
                    ((IDomElementWithChildren)row.Children.ElementAt(1)).Prepend(new TextBlock {
                        Class = "BookmarkGlyph"
                    });
                }
                return(row);
            }));
            assortmentTable.CellSpacing = 1;
            assortmentTable.RegisterBehavior(
                new RowSelectionBehavior(),
                new ToolTipBehavior(),
                new ColumnResizeBehavior(),
                new InputController());
            assortmentTable.Behavior <ColumnResizeBehavior>().ColumnResized += column => WidthHolder.Update(assortmentTable, column, WidthHolder.AssortimentWidths);
            assortmentTable.TemplateManager.ResetColumns();
            assortmentTable.Host
            .InputMap()
            .KeyDown(Keys.Delete, Delete)
            .KeyDown(Keys.F11, Reload);

            UpdateAssortment(assortments);

            var searchText = ((ToolStripTextBox)tools.Items["SearchText"]);

            searchText.KeyDown += (sender, args) => {
                if (args.KeyCode == Keys.Enter)
                {
                    Search();
                }
            };

            assortmentTable.Host.InputMap()
            .KeyDown(Keys.Enter, Search)
            .KeyDown(Keys.Escape, () => {
                searchText.Text = "";
                if (!String.IsNullOrEmpty(_searchText))
                {
                    _searchText = "";
                    var pager   = Request(s => s.GetAssortmentPage(0));
                    UpdateAssortment(pager);
                    navigationToolStrip.UpdatePaginator(pager);
                }
            })
            .KeyPress((o, a) => {
                if (!Char.IsLetterOrDigit(a.KeyChar))
                {
                    return;
                }
                searchText.Text += a.KeyChar;
            });

            var behavior = assortmentTable.Behavior <IRowSelectionBehavior>();

            behavior.SelectedRowChanged += (oldRow, newRow) => SelectedAssortmentChanged(behavior.Selected <AssortmentDto>());

            synonymsTable = new VirtualTable(new TemplateManager <ProducerSynonymDto>(
                                                 () => {
                var row    = Row.Headers();
                var header = new Header("Синоним").Sortable("Name");
                header.InlineStyle.Set(StyleElementType.Width, WidthHolder.ProducerWidths[0]);
                row.Append(header);

                header = new Header("Поставщик").Sortable("Supplier");
                header.InlineStyle.Set(StyleElementType.Width, WidthHolder.ProducerWidths[1]);
                row.Append(header);

                header = new Header("Регион").Sortable("Region");
                header.InlineStyle.Set(StyleElementType.Width, WidthHolder.ProducerWidths[2]);
                row.Append(header);

                return(row);
            },
                                                 synonym => {
                var row = Row.Cells(synonym.Name,
                                    synonym.Supplier,
                                    synonym.Region);
                if (synonym.HaveOffers)
                {
                    row.AddClass("WithoutOffers");
                }
                return(row);
            }));
            synonymsTable.CellSpacing = 1;
            synonymsTable.RegisterBehavior(new ToolTipBehavior(),
                                           new SortInList(),
                                           new ColumnResizeBehavior(),
                                           new RowSelectionBehavior());

            synonymsTable.Host.InputMap();
            synonymsTable.Behavior <ColumnResizeBehavior>().ColumnResized += column => WidthHolder.Update(synonymsTable, column, WidthHolder.ProducerWidths);

            equivalentTable = new VirtualTable(new TemplateManager <ProducerEquivalentDto>(
                                                   () => Row.Headers("Эквивалент"), e => Row.Cells(e.Name)));

            var producersToSynonymsSplit = new SplitContainer {
                Dock        = DockStyle.Fill,
                Orientation = Orientation.Horizontal
            };
            var producersToEquivalentsSplit = new SplitContainer {
                Dock = DockStyle.Fill,
            };

            producersToEquivalentsSplit.Panel1.Controls.Add(assortmentTable.Host);
            producersToEquivalentsSplit.Panel2.Controls.Add(equivalentTable.Host);

            producersToSynonymsSplit.Panel1.Controls.Add(producersToEquivalentsSplit);
            producersToSynonymsSplit.Panel2.Controls.Add(synonymsTable.Host);

            Controls.Add(producersToSynonymsSplit);
            Controls.Add(navigationToolStrip);
            Controls.Add(tools);

            producersToSynonymsSplit.SplitterDistance    = (int)(0.5 * Height);
            producersToEquivalentsSplit.SplitterDistance = (int)(0.7 * producersToEquivalentsSplit.Width);

            assortmentTable.Host.Tag = PaginatorExtention.TableName;

            navigationToolStrip.ActAsPaginator(assortments, LoadPage);

            MoveToBookmark();
            Shown += (s, a) => assortmentTable.Host.Focus();

            var selected = assortmentTable.Selected <AssortmentDto>();

            SelectedAssortmentChanged(selected);
        }