From 3cc2a7e154d306282adc2ff26436fcd1bcaf3ecf Mon Sep 17 00:00:00 2001 From: bocchanskyy Date: Mon, 11 Nov 2024 16:50:22 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B1=D1=8F=D1=82=D0=BA=D0=B8,=20?= =?UTF-8?q?=D1=83=20=D0=BC=D0=B5=D0=BD=D1=8F=20=D0=BE=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D1=8C=20=D1=81=D0=B8=D0=BB=D1=8C=D0=BD=D0=BE=20=D1=81=D0=B3?= =?UTF-8?q?=D0=BE=D1=80=D0=B5=D0=BB=D0=BE.=20=D0=9D=D0=BE=20=D1=8F=20?= =?UTF-8?q?=D1=8D=D1=82=D0=BE=20=D1=81=D0=B4=D0=B5=D0=BB=D1=8F=D0=BB=D1=8C?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormMain.Designer.cs | 8 +- VolkovLabs/InternetShopOrdersApp/FormMain.cs | 16 ++-- .../FormOrder.Designer.cs | 21 +++-- VolkovLabs/InternetShopOrdersApp/FormOrder.cs | 19 ++-- .../InternetShopOrdersApp.csproj | 1 + .../20241111112246_SecondMig.Designer.cs | 87 +++++++++++++++++++ .../Migrations/20241111112246_SecondMig.cs | 22 +++++ .../Models/Orders.cs | 1 + 8 files changed, 144 insertions(+), 31 deletions(-) create mode 100644 VolkovLabs/InternetShopOrdersDatabaseImplement/Migrations/20241111112246_SecondMig.Designer.cs create mode 100644 VolkovLabs/InternetShopOrdersDatabaseImplement/Migrations/20241111112246_SecondMig.cs diff --git a/VolkovLabs/InternetShopOrdersApp/FormMain.Designer.cs b/VolkovLabs/InternetShopOrdersApp/FormMain.Designer.cs index 3e71a3d..8fe68b9 100644 --- a/VolkovLabs/InternetShopOrdersApp/FormMain.Designer.cs +++ b/VolkovLabs/InternetShopOrdersApp/FormMain.Designer.cs @@ -98,7 +98,7 @@ // документToolStripMenuItem.Name = "документToolStripMenuItem"; документToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S; - документToolStripMenuItem.Size = new Size(358, 24); + документToolStripMenuItem.Size = new Size(326, 24); документToolStripMenuItem.Text = "Документ с простой таблицей"; документToolStripMenuItem.Click += документToolStripMenuItem_Click; // @@ -106,7 +106,7 @@ // документСТаблицейToolStripMenuItem.Name = "документСТаблицейToolStripMenuItem"; документСТаблицейToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T; - документСТаблицейToolStripMenuItem.Size = new Size(358, 24); + документСТаблицейToolStripMenuItem.Size = new Size(326, 24); документСТаблицейToolStripMenuItem.Text = "Отчет по всем заказам"; документСТаблицейToolStripMenuItem.Click += документСТаблицейToolStripMenuItem_Click; // @@ -114,8 +114,8 @@ // документСДиаграммойToolStripMenuItem.Name = "документСДиаграммойToolStripMenuItem"; документСДиаграммойToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C; - документСДиаграммойToolStripMenuItem.Size = new Size(358, 24); - документСДиаграммойToolStripMenuItem.Text = "Документ с линейной диаграммой"; + документСДиаграммойToolStripMenuItem.Size = new Size(326, 24); + документСДиаграммойToolStripMenuItem.Text = "Документ с гистограммой"; документСДиаграммойToolStripMenuItem.Click += документСДиаграммойToolStripMenuItem_Click; // // выбранныеТоварыToolStripMenuItem diff --git a/VolkovLabs/InternetShopOrdersApp/FormMain.cs b/VolkovLabs/InternetShopOrdersApp/FormMain.cs index f6d2643..7d3ddb3 100644 --- a/VolkovLabs/InternetShopOrdersApp/FormMain.cs +++ b/VolkovLabs/InternetShopOrdersApp/FormMain.cs @@ -146,7 +146,7 @@ namespace InternetShopOrdersApp (1, 0, "Личные данные", ""), (1, 1, "ФИО заказчика", "Fullname"), (2, 1, "Электронная почта", "Email"), - (3, 0, "Изображение заказа", "OrderImage"), + (3, 0, "Выбранный товар", "SelectedItemName"), }, Data = orders }); @@ -181,14 +181,17 @@ namespace InternetShopOrdersApp itemCounts[order.SelectedItemName]++; } - var chartData = new List + var sortedItemCounts = itemCounts.OrderBy(kvp => kvp.Key).ToList(); + + var chartData = sortedItemCounts.Select(kvp => new ChartData { - new ChartData { SeriesName = "Заказы по товарам", Data = itemCounts.ToDictionary(kvp => kvp.Key, kvp => (double)kvp.Value) } - }; + SeriesName = kvp.Key, // Название товара + Data = new Dictionary { { kvp.Key, kvp.Value } } + }).ToList(); string filePath = saveFileDialog.FileName; - histogramGenerator.CreateHistogramPdf(filePath, "Какие товары сколько раз заказывали", "Диаграмма заказов", OxyPlot.Legends.LegendPosition.BottomCenter, chartData); + histogramGenerator.CreateHistogramPdf(filePath, "", "Диаграмма заказов", OxyPlot.Legends.LegendPosition.BottomCenter, chartData); MessageBox.Show("PDF успешно сгенерирован!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); } @@ -197,8 +200,7 @@ namespace InternetShopOrdersApp MessageBox.Show($"Ошибка: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - } + } } - } } diff --git a/VolkovLabs/InternetShopOrdersApp/FormOrder.Designer.cs b/VolkovLabs/InternetShopOrdersApp/FormOrder.Designer.cs index e14877f..e193f85 100644 --- a/VolkovLabs/InternetShopOrdersApp/FormOrder.Designer.cs +++ b/VolkovLabs/InternetShopOrdersApp/FormOrder.Designer.cs @@ -37,7 +37,7 @@ buttonCancel = new Button(); buttonSave = new Button(); openFileDialog = new OpenFileDialog(); - controlInputRegexEmail = new ControlsLibraryNet60.Input.ControlInputRegexEmail(); + mailControl = new NevaevaLibrary.MailControl(); SuspendLayout(); // // labelFIO @@ -117,22 +117,21 @@ openFileDialog.FileName = "openFileDialog"; openFileDialog.Multiselect = true; // - // controlInputRegexEmail + // mailControl // - controlInputRegexEmail.Location = new Point(12, 253); - controlInputRegexEmail.Margin = new Padding(5, 6, 5, 6); - controlInputRegexEmail.Name = "controlInputRegexEmail"; - controlInputRegexEmail.Pattern = "^([\\w\\d\\.\\-]+)@([\\w\\-]+)((\\.(\\w){2,3})+)$"; - controlInputRegexEmail.Size = new Size(458, 33); - controlInputRegexEmail.TabIndex = 9; - controlInputRegexEmail.Value = ""; + mailControl.Email = null; + mailControl.Location = new Point(12, 250); + mailControl.Name = "mailControl"; + mailControl.Size = new Size(280, 37); + mailControl.TabIndex = 9; + mailControl.validateEmailRegex = null; // // FormOrder // AutoScaleDimensions = new SizeF(8F, 19F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(495, 450); - Controls.Add(controlInputRegexEmail); + Controls.Add(mailControl); Controls.Add(buttonSave); Controls.Add(buttonCancel); Controls.Add(buttonOrderPic); @@ -159,6 +158,6 @@ private Button buttonCancel; private Button buttonSave; private OpenFileDialog openFileDialog; - private ControlsLibraryNet60.Input.ControlInputRegexEmail controlInputRegexEmail; + private NevaevaLibrary.MailControl mailControl; } } \ No newline at end of file diff --git a/VolkovLabs/InternetShopOrdersApp/FormOrder.cs b/VolkovLabs/InternetShopOrdersApp/FormOrder.cs index b684f59..3fd532f 100644 --- a/VolkovLabs/InternetShopOrdersApp/FormOrder.cs +++ b/VolkovLabs/InternetShopOrdersApp/FormOrder.cs @@ -12,6 +12,8 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Text.RegularExpressions; +using System.Diagnostics; +using NevaevaLibrary; namespace InternetShopOrdersApp { @@ -22,7 +24,7 @@ namespace InternetShopOrdersApp private readonly ISelectedItemLogic _selectedItemLogic; private List _selectedItems; private string? orderImage = null; - public int Id { set { Id = value; } } + public int Id { set { _id = value; } } public FormOrder(IOrderLogic logic, ISelectedItemLogic selectedItemLogic) { @@ -36,6 +38,8 @@ namespace InternetShopOrdersApp { _selectedItems = _selectedItemLogic.ReadList(null); customSelectedCheckedListBox.PopulateList(_selectedItems.Select(x => x.Name).ToList()); + mailControl.validateEmailRegex = new System.Text.RegularExpressions.Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); + mailControl.setTooltipText("name@example.com"); if (_id.HasValue) { try @@ -45,7 +49,7 @@ namespace InternetShopOrdersApp { textBoxFIO.Text = view.Fullname; customSelectedCheckedListBox.SelectedElement = view.SelectedItemName; - controlInputRegexEmail.Value = view.Email; + mailControl.Email = view.Email; orderImage = view.OrderImage; } } @@ -70,13 +74,10 @@ namespace InternetShopOrdersApp { MessageBox.Show("Выберите фото заказа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } - if (controlInputRegexEmail.Value == null) + if (string.IsNullOrEmpty(mailControl.Email)) { - MessageBox.Show("Введите электронную почту", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - if (!Regex.IsMatch(controlInputRegexEmail.Value, controlInputRegexEmail.Pattern)) - { - MessageBox.Show("Некорректный формат ввода электронной почты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Не указана почта, либо она не соответствует шаблону.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; } try @@ -87,7 +88,7 @@ namespace InternetShopOrdersApp Fullname = textBoxFIO.Text, OrderImage = orderImage, SelectedItemId = _selectedItems.First(x => x.Name == customSelectedCheckedListBox.SelectedElement).Id, - Email = controlInputRegexEmail.Value, + Email = mailControl.Email, }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) diff --git a/VolkovLabs/InternetShopOrdersApp/InternetShopOrdersApp.csproj b/VolkovLabs/InternetShopOrdersApp/InternetShopOrdersApp.csproj index 06ddae6..5d77f9a 100644 --- a/VolkovLabs/InternetShopOrdersApp/InternetShopOrdersApp.csproj +++ b/VolkovLabs/InternetShopOrdersApp/InternetShopOrdersApp.csproj @@ -17,6 +17,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/VolkovLabs/InternetShopOrdersDatabaseImplement/Migrations/20241111112246_SecondMig.Designer.cs b/VolkovLabs/InternetShopOrdersDatabaseImplement/Migrations/20241111112246_SecondMig.Designer.cs new file mode 100644 index 0000000..67e52ea --- /dev/null +++ b/VolkovLabs/InternetShopOrdersDatabaseImplement/Migrations/20241111112246_SecondMig.Designer.cs @@ -0,0 +1,87 @@ +// +using InternetShopOrdersDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace InternetShopOrdersDatabaseImplement.Migrations +{ + [DbContext(typeof(OrdersDatabase))] + [Migration("20241111112246_SecondMig")] + partial class SecondMig + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("InternetShopOrdersDatabaseImplement.Models.Orders", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("Fullname") + .IsRequired() + .HasColumnType("text"); + + b.Property("OrderImage") + .IsRequired() + .HasColumnType("text"); + + b.Property("SelectedItemId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SelectedItemId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("InternetShopOrdersDatabaseImplement.Models.SelectedItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("SelectedItems"); + }); + + modelBuilder.Entity("InternetShopOrdersDatabaseImplement.Models.Orders", b => + { + b.HasOne("InternetShopOrdersDatabaseImplement.Models.SelectedItem", "SelectedItem") + .WithMany() + .HasForeignKey("SelectedItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SelectedItem"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/VolkovLabs/InternetShopOrdersDatabaseImplement/Migrations/20241111112246_SecondMig.cs b/VolkovLabs/InternetShopOrdersDatabaseImplement/Migrations/20241111112246_SecondMig.cs new file mode 100644 index 0000000..89ea868 --- /dev/null +++ b/VolkovLabs/InternetShopOrdersDatabaseImplement/Migrations/20241111112246_SecondMig.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace InternetShopOrdersDatabaseImplement.Migrations +{ + /// + public partial class SecondMig : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/VolkovLabs/InternetShopOrdersDatabaseImplement/Models/Orders.cs b/VolkovLabs/InternetShopOrdersDatabaseImplement/Models/Orders.cs index 4541011..34edf9f 100644 --- a/VolkovLabs/InternetShopOrdersDatabaseImplement/Models/Orders.cs +++ b/VolkovLabs/InternetShopOrdersDatabaseImplement/Models/Orders.cs @@ -52,6 +52,7 @@ namespace InternetShopOrdersDatabaseImplement.Models } Fullname = model.Fullname; SelectedItemId = model.SelectedItemId; + Email = model.Email; SelectedItem = context.SelectedItems.First(x => x.Id == model.SelectedItemId); OrderImage = model.OrderImage; }