Ребятки, у меня очень сильно сгорело. Но я это сделяль.
This commit is contained in:
parent
4c409b841d
commit
3cc2a7e154
@ -98,7 +98,7 @@
|
|||||||
//
|
//
|
||||||
документToolStripMenuItem.Name = "документToolStripMenuItem";
|
документToolStripMenuItem.Name = "документToolStripMenuItem";
|
||||||
документToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
документToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||||
документToolStripMenuItem.Size = new Size(358, 24);
|
документToolStripMenuItem.Size = new Size(326, 24);
|
||||||
документToolStripMenuItem.Text = "Документ с простой таблицей";
|
документToolStripMenuItem.Text = "Документ с простой таблицей";
|
||||||
документToolStripMenuItem.Click += документToolStripMenuItem_Click;
|
документToolStripMenuItem.Click += документToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
@ -106,7 +106,7 @@
|
|||||||
//
|
//
|
||||||
документСТаблицейToolStripMenuItem.Name = "документСТаблицейToolStripMenuItem";
|
документСТаблицейToolStripMenuItem.Name = "документСТаблицейToolStripMenuItem";
|
||||||
документСТаблицейToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
|
документСТаблицейToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
|
||||||
документСТаблицейToolStripMenuItem.Size = new Size(358, 24);
|
документСТаблицейToolStripMenuItem.Size = new Size(326, 24);
|
||||||
документСТаблицейToolStripMenuItem.Text = "Отчет по всем заказам";
|
документСТаблицейToolStripMenuItem.Text = "Отчет по всем заказам";
|
||||||
документСТаблицейToolStripMenuItem.Click += документСТаблицейToolStripMenuItem_Click;
|
документСТаблицейToolStripMenuItem.Click += документСТаблицейToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
@ -114,8 +114,8 @@
|
|||||||
//
|
//
|
||||||
документСДиаграммойToolStripMenuItem.Name = "документСДиаграммойToolStripMenuItem";
|
документСДиаграммойToolStripMenuItem.Name = "документСДиаграммойToolStripMenuItem";
|
||||||
документСДиаграммойToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
|
документСДиаграммойToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
|
||||||
документСДиаграммойToolStripMenuItem.Size = new Size(358, 24);
|
документСДиаграммойToolStripMenuItem.Size = new Size(326, 24);
|
||||||
документСДиаграммойToolStripMenuItem.Text = "Документ с линейной диаграммой";
|
документСДиаграммойToolStripMenuItem.Text = "Документ с гистограммой";
|
||||||
документСДиаграммойToolStripMenuItem.Click += документСДиаграммойToolStripMenuItem_Click;
|
документСДиаграммойToolStripMenuItem.Click += документСДиаграммойToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// выбранныеТоварыToolStripMenuItem
|
// выбранныеТоварыToolStripMenuItem
|
||||||
|
@ -146,7 +146,7 @@ namespace InternetShopOrdersApp
|
|||||||
(1, 0, "Личные данные", ""),
|
(1, 0, "Личные данные", ""),
|
||||||
(1, 1, "ФИО заказчика", "Fullname"),
|
(1, 1, "ФИО заказчика", "Fullname"),
|
||||||
(2, 1, "Электронная почта", "Email"),
|
(2, 1, "Электронная почта", "Email"),
|
||||||
(3, 0, "Изображение заказа", "OrderImage"),
|
(3, 0, "Выбранный товар", "SelectedItemName"),
|
||||||
},
|
},
|
||||||
Data = orders
|
Data = orders
|
||||||
});
|
});
|
||||||
@ -181,14 +181,17 @@ namespace InternetShopOrdersApp
|
|||||||
itemCounts[order.SelectedItemName]++;
|
itemCounts[order.SelectedItemName]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
var chartData = new List<ChartData>
|
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<string, double> { { kvp.Key, kvp.Value } }
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
string filePath = saveFileDialog.FileName;
|
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);
|
MessageBox.Show("PDF успешно сгенерирован!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
@ -197,8 +200,7 @@ namespace InternetShopOrdersApp
|
|||||||
MessageBox.Show($"Ошибка: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show($"Ошибка: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
openFileDialog = new OpenFileDialog();
|
openFileDialog = new OpenFileDialog();
|
||||||
controlInputRegexEmail = new ControlsLibraryNet60.Input.ControlInputRegexEmail();
|
mailControl = new NevaevaLibrary.MailControl();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// labelFIO
|
// labelFIO
|
||||||
@ -117,22 +117,21 @@
|
|||||||
openFileDialog.FileName = "openFileDialog";
|
openFileDialog.FileName = "openFileDialog";
|
||||||
openFileDialog.Multiselect = true;
|
openFileDialog.Multiselect = true;
|
||||||
//
|
//
|
||||||
// controlInputRegexEmail
|
// mailControl
|
||||||
//
|
//
|
||||||
controlInputRegexEmail.Location = new Point(12, 253);
|
mailControl.Email = null;
|
||||||
controlInputRegexEmail.Margin = new Padding(5, 6, 5, 6);
|
mailControl.Location = new Point(12, 250);
|
||||||
controlInputRegexEmail.Name = "controlInputRegexEmail";
|
mailControl.Name = "mailControl";
|
||||||
controlInputRegexEmail.Pattern = "^([\\w\\d\\.\\-]+)@([\\w\\-]+)((\\.(\\w){2,3})+)$";
|
mailControl.Size = new Size(280, 37);
|
||||||
controlInputRegexEmail.Size = new Size(458, 33);
|
mailControl.TabIndex = 9;
|
||||||
controlInputRegexEmail.TabIndex = 9;
|
mailControl.validateEmailRegex = null;
|
||||||
controlInputRegexEmail.Value = "";
|
|
||||||
//
|
//
|
||||||
// FormOrder
|
// FormOrder
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 19F);
|
AutoScaleDimensions = new SizeF(8F, 19F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(495, 450);
|
ClientSize = new Size(495, 450);
|
||||||
Controls.Add(controlInputRegexEmail);
|
Controls.Add(mailControl);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonOrderPic);
|
Controls.Add(buttonOrderPic);
|
||||||
@ -159,6 +158,6 @@
|
|||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private OpenFileDialog openFileDialog;
|
private OpenFileDialog openFileDialog;
|
||||||
private ControlsLibraryNet60.Input.ControlInputRegexEmail controlInputRegexEmail;
|
private NevaevaLibrary.MailControl mailControl;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,6 +12,8 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using NevaevaLibrary;
|
||||||
|
|
||||||
namespace InternetShopOrdersApp
|
namespace InternetShopOrdersApp
|
||||||
{
|
{
|
||||||
@ -22,7 +24,7 @@ namespace InternetShopOrdersApp
|
|||||||
private readonly ISelectedItemLogic _selectedItemLogic;
|
private readonly ISelectedItemLogic _selectedItemLogic;
|
||||||
private List<SelectedItemViewModel> _selectedItems;
|
private List<SelectedItemViewModel> _selectedItems;
|
||||||
private string? orderImage = null;
|
private string? orderImage = null;
|
||||||
public int Id { set { Id = value; } }
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
public FormOrder(IOrderLogic logic, ISelectedItemLogic selectedItemLogic)
|
public FormOrder(IOrderLogic logic, ISelectedItemLogic selectedItemLogic)
|
||||||
{
|
{
|
||||||
@ -36,6 +38,8 @@ namespace InternetShopOrdersApp
|
|||||||
{
|
{
|
||||||
_selectedItems = _selectedItemLogic.ReadList(null);
|
_selectedItems = _selectedItemLogic.ReadList(null);
|
||||||
customSelectedCheckedListBox.PopulateList(_selectedItems.Select(x => x.Name).ToList());
|
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)
|
if (_id.HasValue)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -45,7 +49,7 @@ namespace InternetShopOrdersApp
|
|||||||
{
|
{
|
||||||
textBoxFIO.Text = view.Fullname;
|
textBoxFIO.Text = view.Fullname;
|
||||||
customSelectedCheckedListBox.SelectedElement = view.SelectedItemName;
|
customSelectedCheckedListBox.SelectedElement = view.SelectedItemName;
|
||||||
controlInputRegexEmail.Value = view.Email;
|
mailControl.Email = view.Email;
|
||||||
orderImage = view.OrderImage;
|
orderImage = view.OrderImage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,13 +74,10 @@ namespace InternetShopOrdersApp
|
|||||||
{
|
{
|
||||||
MessageBox.Show("Выберите фото заказа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Выберите фото заказа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
if (controlInputRegexEmail.Value == null)
|
if (string.IsNullOrEmpty(mailControl.Email))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Введите электронную почту", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Не указана почта, либо она не соответствует шаблону.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
return;
|
||||||
if (!Regex.IsMatch(controlInputRegexEmail.Value, controlInputRegexEmail.Pattern))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Некорректный формат ввода электронной почты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -87,7 +88,7 @@ namespace InternetShopOrdersApp
|
|||||||
Fullname = textBoxFIO.Text,
|
Fullname = textBoxFIO.Text,
|
||||||
OrderImage = orderImage,
|
OrderImage = orderImage,
|
||||||
SelectedItemId = _selectedItems.First(x => x.Name == customSelectedCheckedListBox.SelectedElement).Id,
|
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);
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
|
||||||
|
<PackageReference Include="NevaevaLibrary" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
87
VolkovLabs/InternetShopOrdersDatabaseImplement/Migrations/20241111112246_SecondMig.Designer.cs
generated
Normal file
87
VolkovLabs/InternetShopOrdersDatabaseImplement/Migrations/20241111112246_SecondMig.Designer.cs
generated
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
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
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
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<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Fullname")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("OrderImage")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("SelectedItemId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("SelectedItemId");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternetShopOrdersDatabaseImplement.Models.SelectedItem", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace InternetShopOrdersDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class SecondMig : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -52,6 +52,7 @@ namespace InternetShopOrdersDatabaseImplement.Models
|
|||||||
}
|
}
|
||||||
Fullname = model.Fullname;
|
Fullname = model.Fullname;
|
||||||
SelectedItemId = model.SelectedItemId;
|
SelectedItemId = model.SelectedItemId;
|
||||||
|
Email = model.Email;
|
||||||
SelectedItem = context.SelectedItems.First(x => x.Id == model.SelectedItemId);
|
SelectedItem = context.SelectedItems.First(x => x.Id == model.SelectedItemId);
|
||||||
OrderImage = model.OrderImage;
|
OrderImage = model.OrderImage;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user