Compare commits
18 Commits
main
...
Lab4_Volko
Author | SHA1 | Date | |
---|---|---|---|
944eb853aa | |||
cc2fa54e35 | |||
83136c5c25 | |||
3cc2a7e154 | |||
4c409b841d | |||
fb17f2b58d | |||
7b0038a08f | |||
242c5e4b58 | |||
36513dcb02 | |||
0bf36059e1 | |||
3ba5fd8046 | |||
4865ee8da9 | |||
160b7dc88a | |||
66702ee864 | |||
cca38e76c1 | |||
5f19fb8329 | |||
c44986349c | |||
52a0e50af6 |
@ -1,4 +1,2 @@
|
||||
# KOP_PIbd-33_Volkov_N.A._Tikhonenkov_A.E.
|
||||
# KOP_PIbd-33_Volkov_N.A.-Var21
|
||||
|
||||
Волков Н.А. - Вариант 20
|
||||
Тихоненков А.Е. - Вариант 21
|
7
VolkovLabs/InternetShopDataModels/IId.cs
Normal file
7
VolkovLabs/InternetShopDataModels/IId.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace InternetShopOrdersDataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
16
VolkovLabs/InternetShopDataModels/Models/IOrderModel.cs
Normal file
16
VolkovLabs/InternetShopDataModels/Models/IOrderModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersDataModels.Models
|
||||
{
|
||||
public interface IOrderModel : IId
|
||||
{
|
||||
string Fullname { get; }
|
||||
public string OrderImage { get; }
|
||||
public int SelectedItemId { get; }
|
||||
string Email { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersDataModels.Models
|
||||
{
|
||||
public interface ISelectedItemModel : IId
|
||||
{
|
||||
string Name { get; }
|
||||
}
|
||||
}
|
173
VolkovLabs/InternetShopOrdersApp/FormMain.Designer.cs
generated
Normal file
173
VolkovLabs/InternetShopOrdersApp/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,173 @@
|
||||
namespace InternetShopOrdersApp
|
||||
{
|
||||
partial class FormMain
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
menuStrip = new MenuStrip();
|
||||
заказыToolStripMenuItem = new ToolStripMenuItem();
|
||||
создатьToolStripMenuItem = new ToolStripMenuItem();
|
||||
редактироватьToolStripMenuItem = new ToolStripMenuItem();
|
||||
удалитьToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчётыToolStripMenuItem = new ToolStripMenuItem();
|
||||
документToolStripMenuItem = new ToolStripMenuItem();
|
||||
документСТаблицейToolStripMenuItem = new ToolStripMenuItem();
|
||||
документСДиаграммойToolStripMenuItem = new ToolStripMenuItem();
|
||||
выбранныеТоварыToolStripMenuItem = new ToolStripMenuItem();
|
||||
controlDataTable = new ControlsLibraryNet60.Data.ControlDataTableTable();
|
||||
excelImagesComponent = new WinFormsLibraryVolkov.NonVisualComponents.ExcelImagesComponent(components);
|
||||
componentHistogramToPdf = new FormLibrary.ComponentHistogramToPdf(components);
|
||||
componentDocumentWithTableHeaderRowWord = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableHeaderRowWord(components);
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(18, 18);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { заказыToolStripMenuItem, отчётыToolStripMenuItem, выбранныеТоварыToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(800, 27);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "menuStrip";
|
||||
//
|
||||
// заказыToolStripMenuItem
|
||||
//
|
||||
заказыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { создатьToolStripMenuItem, редактироватьToolStripMenuItem, удалитьToolStripMenuItem });
|
||||
заказыToolStripMenuItem.Name = "заказыToolStripMenuItem";
|
||||
заказыToolStripMenuItem.Size = new Size(68, 23);
|
||||
заказыToolStripMenuItem.Text = "Заказы";
|
||||
//
|
||||
// создатьToolStripMenuItem
|
||||
//
|
||||
создатьToolStripMenuItem.Name = "создатьToolStripMenuItem";
|
||||
создатьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A;
|
||||
создатьToolStripMenuItem.Size = new Size(231, 24);
|
||||
создатьToolStripMenuItem.Text = "Создать";
|
||||
создатьToolStripMenuItem.Click += создатьToolStripMenuItem_Click;
|
||||
//
|
||||
// редактироватьToolStripMenuItem
|
||||
//
|
||||
редактироватьToolStripMenuItem.Name = "редактироватьToolStripMenuItem";
|
||||
редактироватьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.U;
|
||||
редактироватьToolStripMenuItem.Size = new Size(231, 24);
|
||||
редактироватьToolStripMenuItem.Text = "Редактировать";
|
||||
редактироватьToolStripMenuItem.Click += редактироватьToolStripMenuItem_Click;
|
||||
//
|
||||
// удалитьToolStripMenuItem
|
||||
//
|
||||
удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
|
||||
удалитьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D;
|
||||
удалитьToolStripMenuItem.Size = new Size(231, 24);
|
||||
удалитьToolStripMenuItem.Text = "Удалить";
|
||||
удалитьToolStripMenuItem.Click += удалитьToolStripMenuItem_Click;
|
||||
//
|
||||
// отчётыToolStripMenuItem
|
||||
//
|
||||
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { документToolStripMenuItem, документСТаблицейToolStripMenuItem, документСДиаграммойToolStripMenuItem });
|
||||
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
||||
отчётыToolStripMenuItem.Size = new Size(71, 23);
|
||||
отчётыToolStripMenuItem.Text = "Отчёты";
|
||||
//
|
||||
// документToolStripMenuItem
|
||||
//
|
||||
документToolStripMenuItem.Name = "документToolStripMenuItem";
|
||||
документToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
||||
документToolStripMenuItem.Size = new Size(326, 24);
|
||||
документToolStripMenuItem.Text = "Документ с простой таблицей";
|
||||
документToolStripMenuItem.Click += документToolStripMenuItem_Click;
|
||||
//
|
||||
// документСТаблицейToolStripMenuItem
|
||||
//
|
||||
документСТаблицейToolStripMenuItem.Name = "документСТаблицейToolStripMenuItem";
|
||||
документСТаблицейToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
|
||||
документСТаблицейToolStripMenuItem.Size = new Size(326, 24);
|
||||
документСТаблицейToolStripMenuItem.Text = "Отчет по всем заказам";
|
||||
документСТаблицейToolStripMenuItem.Click += документСТаблицейToolStripMenuItem_Click;
|
||||
//
|
||||
// документСДиаграммойToolStripMenuItem
|
||||
//
|
||||
документСДиаграммойToolStripMenuItem.Name = "документСДиаграммойToolStripMenuItem";
|
||||
документСДиаграммойToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.C;
|
||||
документСДиаграммойToolStripMenuItem.Size = new Size(326, 24);
|
||||
документСДиаграммойToolStripMenuItem.Text = "Документ с гистограммой";
|
||||
документСДиаграммойToolStripMenuItem.Click += документСДиаграммойToolStripMenuItem_Click;
|
||||
//
|
||||
// выбранныеТоварыToolStripMenuItem
|
||||
//
|
||||
выбранныеТоварыToolStripMenuItem.Name = "выбранныеТоварыToolStripMenuItem";
|
||||
выбранныеТоварыToolStripMenuItem.Size = new Size(147, 23);
|
||||
выбранныеТоварыToolStripMenuItem.Text = "Выбранные товары";
|
||||
выбранныеТоварыToolStripMenuItem.Click += выбранныеТоварыToolStripMenuItem_Click;
|
||||
//
|
||||
// controlDataTable
|
||||
//
|
||||
controlDataTable.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
controlDataTable.AutoSize = true;
|
||||
controlDataTable.Location = new Point(0, 31);
|
||||
controlDataTable.Margin = new Padding(4, 4, 4, 4);
|
||||
controlDataTable.Name = "controlDataTable";
|
||||
controlDataTable.SelectedRowIndex = -1;
|
||||
controlDataTable.Size = new Size(800, 420);
|
||||
controlDataTable.TabIndex = 1;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 19F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(controlDataTable);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Name = "FormMain";
|
||||
Text = "Заказы";
|
||||
Load += FormMain_Load;
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem заказыToolStripMenuItem;
|
||||
private ToolStripMenuItem создатьToolStripMenuItem;
|
||||
private ToolStripMenuItem редактироватьToolStripMenuItem;
|
||||
private ToolStripMenuItem удалитьToolStripMenuItem;
|
||||
private ToolStripMenuItem отчётыToolStripMenuItem;
|
||||
private ToolStripMenuItem документToolStripMenuItem;
|
||||
private ToolStripMenuItem документСТаблицейToolStripMenuItem;
|
||||
private ToolStripMenuItem выбранныеТоварыToolStripMenuItem;
|
||||
private ToolStripMenuItem документСДиаграммойToolStripMenuItem;
|
||||
private ControlsLibraryNet60.Data.ControlDataTableTable controlDataTable;
|
||||
private WinFormsLibraryVolkov.NonVisualComponents.ExcelImagesComponent excelImagesComponent;
|
||||
private FormLibrary.ComponentHistogramToPdf componentHistogramToPdf;
|
||||
private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableHeaderRowWord componentDocumentWithTableHeaderRowWord;
|
||||
}
|
||||
}
|
206
VolkovLabs/InternetShopOrdersApp/FormMain.cs
Normal file
206
VolkovLabs/InternetShopOrdersApp/FormMain.cs
Normal file
@ -0,0 +1,206 @@
|
||||
using InternetShopOrdersBusinessLogic.BusinessLogics;
|
||||
using InternetShopOrdersContracts.BusinessLogicContracts;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using ControlsLibraryNet60.Models;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using WinFormsLibraryVolkov.NonVisualComponents;
|
||||
using ComponentsLibraryNet60.Core;
|
||||
using ComponentsLibraryNet60.DocumentWithTable;
|
||||
using ComponentsLibraryNet60.Models;
|
||||
using OxyPlot.Legends;
|
||||
using FormLibrary.HelperClasses;
|
||||
using FormLibrary;
|
||||
using System.Diagnostics;
|
||||
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace InternetShopOrdersApp
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private IOrderLogic _logic;
|
||||
|
||||
public FormMain(IOrderLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
controlDataTable.LoadColumns(new List<DataTableColumnConfig>
|
||||
{
|
||||
new DataTableColumnConfig { ColumnHeader = "", PropertyName = "Id", Visible = false, Width = 10 },
|
||||
new DataTableColumnConfig { ColumnHeader = "ФИО заказчика", PropertyName = "Fullname", Visible = true, Width = 200 },
|
||||
new DataTableColumnConfig { ColumnHeader = "Выбранный товар", PropertyName = "SelectedItemName", Visible = true, Width = 200 },
|
||||
new DataTableColumnConfig { ColumnHeader = "Электронная почта", PropertyName = "Email", Visible = true, Width = 200 },
|
||||
});
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
controlDataTable.Clear();
|
||||
var orders = _logic.ReadList(null);
|
||||
if (orders != null)
|
||||
{
|
||||
controlDataTable.AddTable(orders);
|
||||
}
|
||||
}
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void создатьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormOrder));
|
||||
if (service is FormOrder form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormOrder));
|
||||
if (service is FormOrder form)
|
||||
{
|
||||
form.Id = controlDataTable.GetSelectedObject<OrderViewModel>().Id;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
if (_logic.Delete(new OrderBindingModel { Id = controlDataTable.GetSelectedObject<OrderViewModel>().Id }))
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void документToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
|
||||
{
|
||||
saveFileDialog.Filter = "Excel Workbook (*.xlsx)|*.xlsx";
|
||||
saveFileDialog.Title = "Сохранить Excel файл";
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
List<string> orderImages = new List<string>();
|
||||
foreach (var order in _logic.ReadList(null))
|
||||
{
|
||||
orderImages.Add(order.OrderImage);
|
||||
}
|
||||
string path = saveFileDialog.FileName;
|
||||
excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Фотокарточки заказов", orderImages.ToArray()));
|
||||
}
|
||||
MessageBox.Show("Excel успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
private void выбранныеТоварыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSelectedItems));
|
||||
if (service is FormSelectedItems form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void документСТаблицейToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
|
||||
{
|
||||
saveFileDialog.Filter = "Word Document (*.docx)|*.docx";
|
||||
saveFileDialog.Title = "Сохранить Word файл";
|
||||
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var orders = _logic.ReadList(null);
|
||||
componentDocumentWithTableHeaderRowWord.CreateDoc(new ComponentDocumentWithTableHeaderDataConfig<OrderViewModel>
|
||||
{
|
||||
FilePath = saveFileDialog.FileName,
|
||||
Header = "Заказы",
|
||||
UseUnion = true,
|
||||
ColumnsRowsWidth = new List<(int, int)> { (5, 0), (10, 0), (10, 0), (10, 0) },
|
||||
ColumnUnion = new List<(int StartIndex, int Count)> { (1, 2) },
|
||||
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
|
||||
{
|
||||
(0, 0, "Id", "Id"),
|
||||
(1, 0, "Личные данные", ""),
|
||||
(1, 1, "ФИО заказчика", "Fullname"),
|
||||
(2, 1, "Электронная почта", "Email"),
|
||||
(3, 0, "Выбранный товар", "SelectedItemName"),
|
||||
},
|
||||
Data = orders
|
||||
});
|
||||
|
||||
MessageBox.Show("Word файл был успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void документСДиаграммойToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
|
||||
{
|
||||
saveFileDialog.Filter = "PDF Document (*.pdf)|*.pdf";
|
||||
saveFileDialog.Title = "Сохранить PDF файл";
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
var histogramGenerator = new ComponentHistogramToPdf();
|
||||
|
||||
var orders = _logic.ReadList(null);
|
||||
|
||||
var itemCounts = new Dictionary<string, int>();
|
||||
foreach (var order in orders)
|
||||
{
|
||||
if (!itemCounts.ContainsKey(order.SelectedItemName))
|
||||
{
|
||||
itemCounts[order.SelectedItemName] = 0;
|
||||
}
|
||||
itemCounts[order.SelectedItemName]++;
|
||||
}
|
||||
|
||||
var sortedItemCounts = itemCounts.OrderBy(kvp => kvp.Key).ToList();
|
||||
|
||||
var chartData = sortedItemCounts.Select(kvp => new ChartData
|
||||
{
|
||||
SeriesName = kvp.Key, // Название товара
|
||||
Data = new Dictionary<string, double> { { kvp.Key, kvp.Value } }
|
||||
}).ToList();
|
||||
|
||||
string filePath = saveFileDialog.FileName;
|
||||
|
||||
histogramGenerator.CreateHistogramPdf(filePath, "", "Диаграмма заказов", OxyPlot.Legends.LegendPosition.BottomCenter, chartData);
|
||||
|
||||
MessageBox.Show("PDF успешно сгенерирован!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Ошибка: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
135
VolkovLabs/InternetShopOrdersApp/FormMain.resx
Normal file
135
VolkovLabs/InternetShopOrdersApp/FormMain.resx
Normal file
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="excelImagesComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>138, 17</value>
|
||||
</metadata>
|
||||
<metadata name="componentHistogramToPdf.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>734, 22</value>
|
||||
</metadata>
|
||||
<metadata name="componentDocumentWithTableHeaderRowWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>328, 20</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>177</value>
|
||||
</metadata>
|
||||
</root>
|
163
VolkovLabs/InternetShopOrdersApp/FormOrder.Designer.cs
generated
Normal file
163
VolkovLabs/InternetShopOrdersApp/FormOrder.Designer.cs
generated
Normal file
@ -0,0 +1,163 @@
|
||||
namespace InternetShopOrdersApp
|
||||
{
|
||||
partial class FormOrder
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelFIO = new Label();
|
||||
textBoxFIO = new TextBox();
|
||||
labelMail = new Label();
|
||||
labelSelectedItem = new Label();
|
||||
customSelectedCheckedListBox = new WinFormsLibraryVolkov.CustomSelectedCheckedListBox();
|
||||
buttonOrderPic = new Button();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
openFileDialog = new OpenFileDialog();
|
||||
mailControl = new NevaevaLibrary.MailControl();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelFIO
|
||||
//
|
||||
labelFIO.AutoSize = true;
|
||||
labelFIO.Location = new Point(12, 9);
|
||||
labelFIO.Name = "labelFIO";
|
||||
labelFIO.Size = new Size(107, 19);
|
||||
labelFIO.TabIndex = 0;
|
||||
labelFIO.Text = "ФИО заказчика";
|
||||
//
|
||||
// textBoxFIO
|
||||
//
|
||||
textBoxFIO.Location = new Point(12, 31);
|
||||
textBoxFIO.Name = "textBoxFIO";
|
||||
textBoxFIO.Size = new Size(471, 26);
|
||||
textBoxFIO.TabIndex = 1;
|
||||
//
|
||||
// labelMail
|
||||
//
|
||||
labelMail.AutoSize = true;
|
||||
labelMail.Location = new Point(12, 228);
|
||||
labelMail.Name = "labelMail";
|
||||
labelMail.Size = new Size(132, 19);
|
||||
labelMail.TabIndex = 2;
|
||||
labelMail.Text = "Электронная почта";
|
||||
//
|
||||
// labelSelectedItem
|
||||
//
|
||||
labelSelectedItem.AutoSize = true;
|
||||
labelSelectedItem.Location = new Point(12, 79);
|
||||
labelSelectedItem.Name = "labelSelectedItem";
|
||||
labelSelectedItem.Size = new Size(124, 19);
|
||||
labelSelectedItem.TabIndex = 4;
|
||||
labelSelectedItem.Text = "Выбранный товар";
|
||||
//
|
||||
// customSelectedCheckedListBox
|
||||
//
|
||||
customSelectedCheckedListBox.Location = new Point(12, 102);
|
||||
customSelectedCheckedListBox.Margin = new Padding(3, 4, 3, 4);
|
||||
customSelectedCheckedListBox.Name = "customSelectedCheckedListBox";
|
||||
customSelectedCheckedListBox.SelectedElement = "";
|
||||
customSelectedCheckedListBox.Size = new Size(196, 122);
|
||||
customSelectedCheckedListBox.TabIndex = 5;
|
||||
//
|
||||
// buttonOrderPic
|
||||
//
|
||||
buttonOrderPic.Location = new Point(12, 331);
|
||||
buttonOrderPic.Name = "buttonOrderPic";
|
||||
buttonOrderPic.Size = new Size(471, 26);
|
||||
buttonOrderPic.TabIndex = 6;
|
||||
buttonOrderPic.Text = "Выбрать фото заказа";
|
||||
buttonOrderPic.UseVisualStyleBackColor = true;
|
||||
buttonOrderPic.Click += buttonOrderPic_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(388, 412);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(95, 26);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отменить";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(12, 412);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(107, 26);
|
||||
buttonSave.TabIndex = 8;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
openFileDialog.FileName = "openFileDialog";
|
||||
openFileDialog.Multiselect = true;
|
||||
//
|
||||
// mailControl
|
||||
//
|
||||
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(mailControl);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonOrderPic);
|
||||
Controls.Add(customSelectedCheckedListBox);
|
||||
Controls.Add(labelSelectedItem);
|
||||
Controls.Add(labelMail);
|
||||
Controls.Add(textBoxFIO);
|
||||
Controls.Add(labelFIO);
|
||||
Name = "FormOrder";
|
||||
Text = "Заказ";
|
||||
Load += FormOrder_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelFIO;
|
||||
private TextBox textBoxFIO;
|
||||
private Label labelMail;
|
||||
private Label labelSelectedItem;
|
||||
private WinFormsLibraryVolkov.CustomSelectedCheckedListBox customSelectedCheckedListBox;
|
||||
private Button buttonOrderPic;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private NevaevaLibrary.MailControl mailControl;
|
||||
}
|
||||
}
|
116
VolkovLabs/InternetShopOrdersApp/FormOrder.cs
Normal file
116
VolkovLabs/InternetShopOrdersApp/FormOrder.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.BusinessLogicContracts;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Diagnostics;
|
||||
using NevaevaLibrary;
|
||||
|
||||
namespace InternetShopOrdersApp
|
||||
{
|
||||
public partial class FormOrder : Form
|
||||
{
|
||||
private int? _id;
|
||||
private readonly IOrderLogic _logic;
|
||||
private readonly ISelectedItemLogic _selectedItemLogic;
|
||||
private List<SelectedItemViewModel> _selectedItems;
|
||||
private string? orderImage = null;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormOrder(IOrderLogic logic, ISelectedItemLogic selectedItemLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
_selectedItemLogic = selectedItemLogic;
|
||||
_selectedItems = new List<SelectedItemViewModel>();
|
||||
}
|
||||
|
||||
private void FormOrder_Load(object sender, EventArgs e)
|
||||
{
|
||||
_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
|
||||
{
|
||||
var view = _logic.ReadElement(new OrderSearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxFIO.Text = view.Fullname;
|
||||
customSelectedCheckedListBox.SelectedElement = view.SelectedItemName;
|
||||
mailControl.Email = view.Email;
|
||||
orderImage = view.OrderImage;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxFIO.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните ФИО заказчика", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
if (customSelectedCheckedListBox.SelectedElement == null)
|
||||
{
|
||||
MessageBox.Show("Укажите выбранные товары", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
if (orderImage == null)
|
||||
{
|
||||
MessageBox.Show("Выберите фото заказа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
if (string.IsNullOrEmpty(mailControl.Email))
|
||||
{
|
||||
MessageBox.Show("Не указана почта, либо она не соответствует шаблону.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var model = new OrderBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
Fullname = textBoxFIO.Text,
|
||||
OrderImage = orderImage,
|
||||
SelectedItemId = _selectedItems.First(x => x.Name == customSelectedCheckedListBox.SelectedElement).Id,
|
||||
Email = mailControl.Email,
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Возникла ошибка при сохранении. Дополнительная информация в логах");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Успешное сохранение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonOrderPic_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() != DialogResult.Cancel)
|
||||
{
|
||||
orderImage = openFileDialog.FileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
123
VolkovLabs/InternetShopOrdersApp/FormOrder.resx
Normal file
123
VolkovLabs/InternetShopOrdersApp/FormOrder.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
84
VolkovLabs/InternetShopOrdersApp/FormSelectedItems.Designer.cs
generated
Normal file
84
VolkovLabs/InternetShopOrdersApp/FormSelectedItems.Designer.cs
generated
Normal file
@ -0,0 +1,84 @@
|
||||
namespace InternetShopOrdersApp
|
||||
{
|
||||
partial class FormSelectedItems
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
NameCol = new DataGridViewTextBoxColumn();
|
||||
Id = new DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { NameCol, Id });
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 47;
|
||||
dataGridView.Size = new Size(800, 356);
|
||||
dataGridView.TabIndex = 0;
|
||||
dataGridView.CellValueChanged += dataGridView_CellValueChanged;
|
||||
dataGridView.UserDeletingRow += dataGridView_UserDeletingRow;
|
||||
dataGridView.KeyUp += dataGridView_KeyUp;
|
||||
//
|
||||
// NameCol
|
||||
//
|
||||
NameCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
NameCol.HeaderText = "Название товара";
|
||||
NameCol.MinimumWidth = 6;
|
||||
NameCol.Name = "NameCol";
|
||||
//
|
||||
// Id
|
||||
//
|
||||
Id.HeaderText = "Id";
|
||||
Id.MinimumWidth = 6;
|
||||
Id.Name = "Id";
|
||||
Id.Visible = false;
|
||||
Id.Width = 125;
|
||||
//
|
||||
// FormSelectedItems
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 19F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 356);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormSelectedItems";
|
||||
Text = "Выбранные товары";
|
||||
Load += FormSelectedItems_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn NameCol;
|
||||
private DataGridViewTextBoxColumn Id;
|
||||
}
|
||||
}
|
104
VolkovLabs/InternetShopOrdersApp/FormSelectedItems.cs
Normal file
104
VolkovLabs/InternetShopOrdersApp/FormSelectedItems.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.BusinessLogicContracts;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace InternetShopOrdersApp
|
||||
{
|
||||
public partial class FormSelectedItems : Form
|
||||
{
|
||||
private readonly ISelectedItemLogic _logic;
|
||||
private bool loading = false;
|
||||
|
||||
public FormSelectedItems(ISelectedItemLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
loading = true;
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
foreach (var selectedItem in list)
|
||||
{
|
||||
int rowIndex = dataGridView.Rows.Add();
|
||||
dataGridView.Rows[rowIndex].Cells[0].Value = selectedItem.Name;
|
||||
dataGridView.Rows[rowIndex].Cells[1].Value = selectedItem.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void FormSelectedItems_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (loading || e.RowIndex < 0 || e.ColumnIndex != 0) return;
|
||||
if (dataGridView.Rows[e.RowIndex].Cells[1].Value != null && !string.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[1].Value.ToString()))
|
||||
{
|
||||
var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
if (name is null) return;
|
||||
_logic.Update(new SelectedItemBindingModel { Id = Convert.ToInt32(dataGridView.Rows[e.RowIndex].Cells[1].Value), Name = name.ToString() });
|
||||
}
|
||||
else
|
||||
{
|
||||
var name = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
if (name is null) return;
|
||||
_logic.Create(new SelectedItemBindingModel { Id = 0, Name = name.ToString() });
|
||||
int newInterestId = _logic.ReadList(null).ToList().Last().Id;
|
||||
dataGridView.Rows[e.RowIndex].Cells[1].Value = newInterestId;
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Insert:
|
||||
dataGridView.Rows.Add();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteRows(DataGridViewSelectedRowCollection rows)
|
||||
{
|
||||
for (int i = 0; i < rows.Count; i++)
|
||||
{
|
||||
DataGridViewRow row = rows[i];
|
||||
if (!_logic.Delete(new SelectedItemBindingModel { Id = Convert.ToInt32(row.Cells[1].Value) })) continue;
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
|
||||
{
|
||||
e.Cancel = true;
|
||||
if (dataGridView.SelectedRows == null) return;
|
||||
if (MessageBox.Show("Удалить записи?", "Подтвердите действие", MessageBoxButtons.YesNo) == DialogResult.No) return;
|
||||
deleteRows(dataGridView.SelectedRows);
|
||||
}
|
||||
}
|
||||
}
|
126
VolkovLabs/InternetShopOrdersApp/FormSelectedItems.resx
Normal file
126
VolkovLabs/InternetShopOrdersApp/FormSelectedItems.resx
Normal file
@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="NameCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -0,0 +1,31 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<OutputType>WinExe</OutputType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
|
||||
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
|
||||
<PackageReference Include="FormLibrary" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
|
||||
<PackageReference Include="NevaevaLibrary" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\InternetShopOrdersBusinessLogic\InternetShopOrdersBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\InternetShopOrdersContracts\InternetShopOrdersContracts.csproj" />
|
||||
<ProjectReference Include="..\InternetShopOrdersDatabaseImplement\InternetShopOrdersDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
|
||||
<ProjectReference Include="..\WinFormsLibraryVolkov\WinFormsLibraryVolkov.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
186
VolkovLabs/InternetShopOrdersApp/PluginsConvention.cs
Normal file
186
VolkovLabs/InternetShopOrdersApp/PluginsConvention.cs
Normal file
@ -0,0 +1,186 @@
|
||||
using ComponentsLibraryNet60.Core;
|
||||
using ComponentsLibraryNet60.DocumentWithTable;
|
||||
using ComponentsLibraryNet60.Models;
|
||||
using ControlsLibraryNet60.Data;
|
||||
using ControlsLibraryNet60.Models;
|
||||
using FormLibrary;
|
||||
using FormLibrary.HelperClasses;
|
||||
using InternetShopOrdersBusinessLogic.BusinessLogics;
|
||||
using InternetShopOrdersContracts.BusinessLogicContracts;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using InternetShopOrdersDatabaseImplement.Implements;
|
||||
using NevaevaLibrary.LogicalComponents;
|
||||
using PluginsConventionLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WinFormsLibraryVolkov.NonVisualComponents;
|
||||
|
||||
namespace InternetShopOrdersApp
|
||||
{
|
||||
public class PluginsConvention : IPluginsConvention
|
||||
{
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly ISelectedItemLogic _selecteditemLogic;
|
||||
private readonly ControlDataTableTable _controlDataTableTable;
|
||||
private readonly ExcelImagesComponent _excelImagesComponent;
|
||||
private readonly ComponentDocumentWithTableHeaderRowWord _wordTableComponent;
|
||||
private readonly ComponentHistogramToPdf _componentHistogramToPdf;
|
||||
|
||||
public string PluginName { get; set; } = "MyLabworkPlugin";
|
||||
|
||||
public UserControl GetControl
|
||||
{
|
||||
get { return _controlDataTableTable; }
|
||||
}
|
||||
|
||||
public PluginsConvention()
|
||||
{
|
||||
_orderLogic = new OrderLogic(new OrderStorage());
|
||||
_selecteditemLogic = new SelectedItemLogic(new SelectedItemStorage());
|
||||
_controlDataTableTable = new();
|
||||
_excelImagesComponent = new();
|
||||
_wordTableComponent = new();
|
||||
_componentHistogramToPdf = new();
|
||||
}
|
||||
|
||||
public PluginsConventionElement GetElement
|
||||
{
|
||||
get
|
||||
{
|
||||
int Id = _controlDataTableTable.GetSelectedObject<OrderViewModel>()!.Id;
|
||||
byte[] bytes = new byte[16];
|
||||
BitConverter.GetBytes(Id).CopyTo(bytes, 0);
|
||||
Guid guid = new Guid(bytes);
|
||||
return new PluginsConventionElement() { Id = guid };
|
||||
}
|
||||
}
|
||||
|
||||
public Form GetForm(PluginsConventionElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return new FormOrder(_orderLogic, _selecteditemLogic);
|
||||
}
|
||||
else
|
||||
{
|
||||
FormOrder form = new FormOrder(_orderLogic, _selecteditemLogic);
|
||||
form.Id = element.Id.GetHashCode();
|
||||
return form;
|
||||
}
|
||||
}
|
||||
|
||||
public Form GetThesaurus()
|
||||
{
|
||||
return new FormSelectedItems(_selecteditemLogic);
|
||||
}
|
||||
|
||||
public bool DeleteElement(PluginsConventionElement element)
|
||||
{
|
||||
_orderLogic.Delete(new InternetShopOrdersContracts.BindingModels.OrderBindingModel { Id = element.GetHashCode() });
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ReloadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var orders = _orderLogic.ReadList(null);
|
||||
if (_orderLogic != null)
|
||||
{
|
||||
_controlDataTableTable.Clear();
|
||||
|
||||
_controlDataTableTable.LoadColumns(new List<DataTableColumnConfig>
|
||||
{
|
||||
new DataTableColumnConfig { ColumnHeader = "", PropertyName = "Id", Visible = false, Width = 10 },
|
||||
new DataTableColumnConfig { ColumnHeader = "ФИО заказчика", PropertyName = "Fullname", Visible = true, Width = 200 },
|
||||
new DataTableColumnConfig { ColumnHeader = "Выбранный товар", PropertyName = "SelectedItemName", Visible = true, Width = 200 },
|
||||
new DataTableColumnConfig { ColumnHeader = "Электронная почта", PropertyName = "Email", Visible = true, Width = 200 },
|
||||
});
|
||||
_controlDataTableTable.AddTable(orders);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
List<string> orderImages = new List<string>();
|
||||
foreach (var order in _orderLogic.ReadList(null))
|
||||
{
|
||||
orderImages.Add(order.OrderImage);
|
||||
}
|
||||
string path = saveDocument.FileName;
|
||||
if (_excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Фотокарточки товаров", orderImages.ToArray())))
|
||||
{
|
||||
MessageBox.Show("Документ с фотографиями заказов создан");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
string path = saveDocument.FileName;
|
||||
|
||||
var orders = _orderLogic.ReadList(null);
|
||||
ComponentDocumentWithTableHeaderRowWord table = new ComponentDocumentWithTableHeaderRowWord();
|
||||
table.CreateDoc(new ComponentDocumentWithTableHeaderDataConfig<OrderViewModel>
|
||||
{
|
||||
FilePath = path,
|
||||
Header = "Заказы",
|
||||
UseUnion = true,
|
||||
ColumnsRowsWidth = new List<(int, int)> { (5, 0), (10, 0), (10, 0), (10, 0) },
|
||||
ColumnUnion = new List<(int StartIndex, int Count)> { (1, 2) },
|
||||
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
|
||||
{
|
||||
(0, 0, "Id", "Id"),
|
||||
(1, 0, "Личные данные", ""),
|
||||
(1, 1, "ФИО заказчика", "Fullname"),
|
||||
(2, 1, "Электронная почта", "Email"),
|
||||
(3, 0, "Выбранный товар", "SelectedItemName"),
|
||||
},
|
||||
Data = orders
|
||||
});
|
||||
MessageBox.Show("Word файл был успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
|
||||
{
|
||||
string filePath = saveDocument.FileName;
|
||||
ComponentHistogramToPdf histogramGenerator = new ComponentHistogramToPdf();
|
||||
|
||||
var orders = _orderLogic.ReadList(null);
|
||||
|
||||
var itemCounts = new Dictionary<string, int>();
|
||||
foreach (var order in orders)
|
||||
{
|
||||
if (!itemCounts.ContainsKey(order.SelectedItemName))
|
||||
{
|
||||
itemCounts[order.SelectedItemName] = 0;
|
||||
}
|
||||
itemCounts[order.SelectedItemName]++;
|
||||
}
|
||||
|
||||
var sortedItemCounts = itemCounts.OrderBy(kvp => kvp.Key).ToList();
|
||||
|
||||
var chartData = sortedItemCounts.Select(kvp => new ChartData
|
||||
{
|
||||
SeriesName = kvp.Key, // Название товара
|
||||
Data = new Dictionary<string, double> { { kvp.Key, kvp.Value } }
|
||||
}).ToList();
|
||||
|
||||
|
||||
histogramGenerator.CreateHistogramPdf(filePath, "", "Диаграмма заказов", OxyPlot.Legends.LegendPosition.BottomCenter, chartData);
|
||||
MessageBox.Show("Pdf файл был успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
41
VolkovLabs/InternetShopOrdersApp/Program.cs
Normal file
41
VolkovLabs/InternetShopOrdersApp/Program.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using InternetShopOrdersBusinessLogic.BusinessLogics;
|
||||
using InternetShopOrdersContracts.BusinessLogicContracts;
|
||||
using InternetShopOrdersContracts.StorageContracts;
|
||||
using InternetShopOrdersDatabaseImplement.Implements;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
|
||||
namespace InternetShopOrdersApp
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
}
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddTransient<ISelectedItemStorage, SelectedItemStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<ISelectedItemLogic, SelectedItemLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormOrder>();
|
||||
services.AddTransient<FormSelectedItems>();
|
||||
}
|
||||
}
|
||||
}
|
184
VolkovLabs/InternetShopOrdersAppPlugins/FormMain.Designer.cs
generated
Normal file
184
VolkovLabs/InternetShopOrdersAppPlugins/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,184 @@
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace InternetShopOrdersAppPlugins
|
||||
{
|
||||
partial class FormMain
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.ControlsStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ActionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ThesaurusToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.AddElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.UpdElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.DelElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.DocsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SimpleDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.TableDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ChartDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.panelControl = new System.Windows.Forms.Panel();
|
||||
this.menuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.ControlsStripMenuItem,
|
||||
this.ActionsToolStripMenuItem,
|
||||
this.DocsToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Padding = new System.Windows.Forms.Padding(7, 3, 0, 3);
|
||||
this.menuStrip.Size = new System.Drawing.Size(914, 30);
|
||||
this.menuStrip.TabIndex = 0;
|
||||
this.menuStrip.Text = "Меню";
|
||||
//
|
||||
// ControlsStripMenuItem
|
||||
//
|
||||
this.ControlsStripMenuItem.Name = "ControlsStripMenuItem";
|
||||
this.ControlsStripMenuItem.Size = new System.Drawing.Size(113, 24);
|
||||
this.ControlsStripMenuItem.Text = "Компоненты";
|
||||
//
|
||||
// ActionsToolStripMenuItem
|
||||
//
|
||||
this.ActionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.ThesaurusToolStripMenuItem,
|
||||
this.AddElementToolStripMenuItem,
|
||||
this.UpdElementToolStripMenuItem,
|
||||
this.DelElementToolStripMenuItem});
|
||||
this.ActionsToolStripMenuItem.Name = "ActionsToolStripMenuItem";
|
||||
this.ActionsToolStripMenuItem.Size = new System.Drawing.Size(88, 24);
|
||||
this.ActionsToolStripMenuItem.Text = "Действия";
|
||||
//
|
||||
// ThesaurusToolStripMenuItem
|
||||
//
|
||||
this.ThesaurusToolStripMenuItem.Name = "ThesaurusToolStripMenuItem";
|
||||
this.ThesaurusToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I)));
|
||||
this.ThesaurusToolStripMenuItem.Size = new System.Drawing.Size(223, 26);
|
||||
this.ThesaurusToolStripMenuItem.Text = "Справочник";
|
||||
//
|
||||
// AddElementToolStripMenuItem
|
||||
//
|
||||
this.AddElementToolStripMenuItem.Name = "AddElementToolStripMenuItem";
|
||||
this.AddElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
|
||||
this.AddElementToolStripMenuItem.Size = new System.Drawing.Size(223, 26);
|
||||
this.AddElementToolStripMenuItem.Text = "Добавить";
|
||||
//
|
||||
// UpdElementToolStripMenuItem
|
||||
//
|
||||
this.UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem";
|
||||
this.UpdElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U)));
|
||||
this.UpdElementToolStripMenuItem.Size = new System.Drawing.Size(223, 26);
|
||||
this.UpdElementToolStripMenuItem.Text = "Изменить";
|
||||
//
|
||||
// DelElementToolStripMenuItem
|
||||
//
|
||||
this.DelElementToolStripMenuItem.Name = "DelElementToolStripMenuItem";
|
||||
this.DelElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D)));
|
||||
this.DelElementToolStripMenuItem.Size = new System.Drawing.Size(223, 26);
|
||||
this.DelElementToolStripMenuItem.Text = "Удалить";
|
||||
//
|
||||
// DocsToolStripMenuItem
|
||||
//
|
||||
this.DocsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.SimpleDocToolStripMenuItem,
|
||||
this.TableDocToolStripMenuItem,
|
||||
this.ChartDocToolStripMenuItem});
|
||||
this.DocsToolStripMenuItem.Name = "DocsToolStripMenuItem";
|
||||
this.DocsToolStripMenuItem.Size = new System.Drawing.Size(101, 24);
|
||||
this.DocsToolStripMenuItem.Text = "Документы";
|
||||
//
|
||||
// SimpleDocToolStripMenuItem
|
||||
//
|
||||
this.SimpleDocToolStripMenuItem.Name = "SimpleDocToolStripMenuItem";
|
||||
this.SimpleDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||
this.SimpleDocToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
|
||||
this.SimpleDocToolStripMenuItem.Text = "Простой документ";
|
||||
//
|
||||
// TableDocToolStripMenuItem
|
||||
//
|
||||
this.TableDocToolStripMenuItem.Name = "TableDocToolStripMenuItem";
|
||||
this.TableDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T)));
|
||||
this.TableDocToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
|
||||
this.TableDocToolStripMenuItem.Text = "Документ с таблицой";
|
||||
//
|
||||
// ChartDocToolStripMenuItem
|
||||
//
|
||||
this.ChartDocToolStripMenuItem.Name = "ChartDocToolStripMenuItem";
|
||||
this.ChartDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
|
||||
this.ChartDocToolStripMenuItem.Size = new System.Drawing.Size(313, 26);
|
||||
this.ChartDocToolStripMenuItem.Text = "Документ с диаграммой";
|
||||
//
|
||||
// panelControl
|
||||
//
|
||||
this.panelControl.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panelControl.Location = new System.Drawing.Point(0, 30);
|
||||
this.panelControl.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.panelControl.Name = "panelControl";
|
||||
this.panelControl.Size = new System.Drawing.Size(914, 570);
|
||||
this.panelControl.TabIndex = 1;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(914, 600);
|
||||
this.Controls.Add(this.panelControl);
|
||||
this.Controls.Add(this.menuStrip);
|
||||
this.MainMenuStrip = this.menuStrip;
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormMain";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Главная форма";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
this.menuStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.MenuStrip menuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem ControlsStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem DocsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem SimpleDocToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem TableDocToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ChartDocToolStripMenuItem;
|
||||
private System.Windows.Forms.Panel panelControl;
|
||||
private System.Windows.Forms.ToolStripMenuItem ActionsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ThesaurusToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem AddElementToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem UpdElementToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem DelElementToolStripMenuItem;
|
||||
}
|
||||
}
|
241
VolkovLabs/InternetShopOrdersAppPlugins/FormMain.cs
Normal file
241
VolkovLabs/InternetShopOrdersAppPlugins/FormMain.cs
Normal file
@ -0,0 +1,241 @@
|
||||
using PluginsConventionLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace InternetShopOrdersAppPlugins
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly Dictionary<string, IPluginsConvention> _plugins;
|
||||
private string _selectedPlugin;
|
||||
|
||||
public FormMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
_plugins = new();
|
||||
LoadPlugins();
|
||||
_selectedPlugin = string.Empty;
|
||||
}
|
||||
|
||||
private void LoadPlugins()
|
||||
{
|
||||
List<IPluginsConvention> pluginsList = GetPlugins();
|
||||
|
||||
foreach (var plugin in pluginsList)
|
||||
{
|
||||
_plugins[plugin.PluginName] = plugin;
|
||||
CreateMenuItem(plugin.PluginName);
|
||||
}
|
||||
}
|
||||
|
||||
private List<IPluginsConvention> GetPlugins()
|
||||
{
|
||||
string currentDir = Environment.CurrentDirectory;
|
||||
string pluginsDir = Directory.GetParent(currentDir).Parent.Parent.Parent.FullName + "\\Plugins";
|
||||
string[] dllFiles = Directory.GetFiles(
|
||||
pluginsDir,
|
||||
"*.dll",
|
||||
SearchOption.AllDirectories
|
||||
);
|
||||
List<IPluginsConvention> plugins = new();
|
||||
foreach (string dllFile in dllFiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
Assembly assembly = Assembly.LoadFrom(dllFile);
|
||||
Type[] types = assembly.GetTypes();
|
||||
foreach (Type type in types)
|
||||
{
|
||||
if (typeof(IPluginsConvention).IsAssignableFrom(type) && !type.IsInterface)
|
||||
{
|
||||
if (Activator.CreateInstance(type) is IPluginsConvention plugin)
|
||||
{
|
||||
plugins.Add(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(
|
||||
ex.Message
|
||||
);
|
||||
}
|
||||
}
|
||||
return plugins;
|
||||
}
|
||||
|
||||
private void CreateMenuItem(string pluginName)
|
||||
{
|
||||
ToolStripMenuItem menuItem = new(pluginName);
|
||||
menuItem.Click += (object? sender, EventArgs e) =>
|
||||
{
|
||||
UserControl userControl = _plugins[pluginName].GetControl;
|
||||
if (userControl != null)
|
||||
{
|
||||
panelControl.Controls.Clear();
|
||||
userControl.Dock = DockStyle.Fill;
|
||||
_plugins[pluginName].ReloadData();
|
||||
_selectedPlugin = pluginName;
|
||||
panelControl.Controls.Add(userControl);
|
||||
}
|
||||
};
|
||||
ControlsStripMenuItem.DropDownItems.Add(menuItem);
|
||||
}
|
||||
|
||||
private void FormMain_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_selectedPlugin) ||
|
||||
!_plugins.ContainsKey(_selectedPlugin))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!e.Control)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.I:
|
||||
ShowThesaurus();
|
||||
break;
|
||||
case Keys.A:
|
||||
AddNewElement();
|
||||
break;
|
||||
case Keys.U:
|
||||
UpdateElement();
|
||||
break;
|
||||
case Keys.D:
|
||||
DeleteElement();
|
||||
break;
|
||||
case Keys.S:
|
||||
CreateSimpleDoc();
|
||||
break;
|
||||
case Keys.T:
|
||||
CreateTableDoc();
|
||||
break;
|
||||
case Keys.C:
|
||||
CreateChartDoc();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowThesaurus()
|
||||
{
|
||||
_plugins[_selectedPlugin].GetThesaurus()?.Show();
|
||||
}
|
||||
|
||||
private void AddNewElement()
|
||||
{
|
||||
var form = _plugins[_selectedPlugin].GetForm(null);
|
||||
if (form != null && form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].ReloadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateElement()
|
||||
{
|
||||
var element = _plugins[_selectedPlugin].GetElement;
|
||||
if (element == null)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Не выбран элемент для обновления",
|
||||
"Ошибка",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error
|
||||
);
|
||||
return;
|
||||
}
|
||||
var form = _plugins[_selectedPlugin].GetForm(element);
|
||||
if (form != null && form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].ReloadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteElement()
|
||||
{
|
||||
if (MessageBox.Show(
|
||||
"Удалить выбранный элемент?",
|
||||
"Удаление",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var element = _plugins[_selectedPlugin].GetElement;
|
||||
if (element == null)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Не выбран элемент для удаления",
|
||||
"Ошибка",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (_plugins[_selectedPlugin].DeleteElement(element))
|
||||
{
|
||||
_plugins[_selectedPlugin].ReloadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateSimpleDoc()
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "Excel Files|*.xlsx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||
|
||||
}
|
||||
}
|
||||
private void CreateTableDoc()
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "Word Files|*.docx"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||
|
||||
}
|
||||
}
|
||||
private void CreateChartDoc()
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new()
|
||||
{
|
||||
Filter = "PDF Files|*.pdf"
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_plugins[_selectedPlugin].CreateChartDocument(new PluginsConventionSaveDocument() { FileName = saveFileDialog.FileName });
|
||||
}
|
||||
}
|
||||
|
||||
private void ThesaurusToolStripMenuItem_Click(object sender, EventArgs e) => ShowThesaurus();
|
||||
private void AddElementToolStripMenuItem_Click(object sender, EventArgs e) => AddNewElement();
|
||||
private void UpdElementToolStripMenuItem_Click(object sender, EventArgs e) => UpdateElement();
|
||||
private void DelElementToolStripMenuItem_Click(object sender, EventArgs e) => DeleteElement();
|
||||
private void SimpleDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateSimpleDoc();
|
||||
private void TableDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateTableDoc();
|
||||
private void ChartDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateChartDoc();
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
63
VolkovLabs/InternetShopOrdersAppPlugins/FormMain.resx
Normal file
63
VolkovLabs/InternetShopOrdersAppPlugins/FormMain.resx
Normal file
@ -0,0 +1,63 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
|
||||
<PackageReference Include="System.Text.Encodings.Web" Version="8.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PluginsConventionLibrary\PluginsConventionLibrary.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
17
VolkovLabs/InternetShopOrdersAppPlugins/Program.cs
Normal file
17
VolkovLabs/InternetShopOrdersAppPlugins/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace InternetShopOrdersAppPlugins
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormMain());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.BusinessLogicContracts;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using InternetShopOrdersContracts.StorageContracts;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
|
||||
namespace InternetShopOrdersBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class OrderLogic : IOrderLogic
|
||||
{
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
|
||||
public OrderLogic(IOrderStorage orderStorage)
|
||||
{
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public OrderViewModel? ReadElement(OrderSearchModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
var element = _orderStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_orderStorage.Insert(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_orderStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Fullname))
|
||||
{
|
||||
throw new ArgumentNullException("Нет ФИО заказчика", nameof(model.Fullname));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
throw new ArgumentNullException("Нет электронной почты заказчика", nameof(model.Email));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.BusinessLogicContracts;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using InternetShopOrdersContracts.StorageContracts;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
|
||||
namespace InternetShopOrdersBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class SelectedItemLogic : ISelectedItemLogic
|
||||
{
|
||||
private readonly ISelectedItemStorage _selectedItemStorage;
|
||||
|
||||
public SelectedItemLogic(ISelectedItemStorage selectedItemStorage)
|
||||
{
|
||||
_selectedItemStorage = selectedItemStorage;
|
||||
}
|
||||
|
||||
public List<SelectedItemViewModel>? ReadList(SelectedItemSearchModel? model)
|
||||
{
|
||||
var list = model == null ? _selectedItemStorage.GetFullList() : _selectedItemStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public SelectedItemViewModel? ReadElement(SelectedItemSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
var element = _selectedItemStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(SelectedItemBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_selectedItemStorage.Insert(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(SelectedItemBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_selectedItemStorage.Update(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(SelectedItemBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_selectedItemStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(SelectedItemBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия выбранного товара", nameof(model.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\InternetShopOrdersContracts\InternetShopOrdersContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,13 @@
|
||||
using InternetShopOrdersDataModels.Models;
|
||||
|
||||
namespace InternetShopOrdersContracts.BindingModels
|
||||
{
|
||||
public class OrderBindingModel : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Fullname { get; set; } = string.Empty;
|
||||
public string OrderImage { get; set; }
|
||||
public int SelectedItemId { get; set; }
|
||||
public string Email { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using InternetShopOrdersDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.BindingModels
|
||||
{
|
||||
public class SelectedItemBindingModel : ISelectedItemModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = String.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IOrderLogic
|
||||
{
|
||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||
bool Create(OrderBindingModel model);
|
||||
bool Update(OrderBindingModel model);
|
||||
bool Delete(OrderBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface ISelectedItemLogic
|
||||
{
|
||||
List<SelectedItemViewModel>? ReadList(SelectedItemSearchModel? model);
|
||||
SelectedItemViewModel? ReadElement(SelectedItemSearchModel model);
|
||||
bool Create(SelectedItemBindingModel model);
|
||||
bool Update(SelectedItemBindingModel model);
|
||||
bool Delete(SelectedItemBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\InternetShopDataModels\InternetShopDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.SearchModels
|
||||
{
|
||||
public class OrderSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.SearchModels
|
||||
{
|
||||
public class SelectedItemSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.StorageContracts
|
||||
{
|
||||
public interface IOrderStorage
|
||||
{
|
||||
List<OrderViewModel> GetFullList();
|
||||
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
||||
OrderViewModel? GetElement(OrderSearchModel model);
|
||||
OrderViewModel? Insert(OrderBindingModel model);
|
||||
OrderViewModel? Update(OrderBindingModel model);
|
||||
OrderViewModel? Delete(OrderBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.StorageContracts
|
||||
{
|
||||
public interface ISelectedItemStorage
|
||||
{
|
||||
List<SelectedItemViewModel> GetFullList();
|
||||
List<SelectedItemViewModel> GetFilteredList(SelectedItemSearchModel model);
|
||||
SelectedItemViewModel? GetElement(SelectedItemSearchModel model);
|
||||
SelectedItemViewModel? Insert(SelectedItemBindingModel model);
|
||||
SelectedItemViewModel? Update(SelectedItemBindingModel model);
|
||||
SelectedItemViewModel? Delete(SelectedItemBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using InternetShopOrdersDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.ViewModels
|
||||
{
|
||||
public class OrderViewModel : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("ФИО заказчика")]
|
||||
public string Fullname { get; set; } = string.Empty;
|
||||
|
||||
public string OrderImage { get; set; } = string.Empty;
|
||||
|
||||
public int SelectedItemId { get; set; }
|
||||
public string SelectedItemName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Электронная почта")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using InternetShopOrdersDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersContracts.ViewModels
|
||||
{
|
||||
public class SelectedItemViewModel : ISelectedItemModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using InternetShopOrdersContracts.StorageContracts;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using InternetShopOrdersDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Security.Principal;
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new OrdersDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.SelectedItem)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new OrdersDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.SelectedItem)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new OrdersDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.SelectedItem)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
using var context = new OrdersDatabase();
|
||||
var newOrder = Orders.Create(context, model);
|
||||
if (newOrder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
return newOrder.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
using var context = new OrdersDatabase();
|
||||
var Order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (Order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Order.Update(model, context);
|
||||
context.SaveChanges();
|
||||
return Order.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new OrdersDatabase();
|
||||
var element = context.Orders
|
||||
.Include(x => x.SelectedItem)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Orders.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.SearchModels;
|
||||
using InternetShopOrdersContracts.StorageContracts;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using InternetShopOrdersDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement.Implements
|
||||
{
|
||||
public class SelectedItemStorage : ISelectedItemStorage
|
||||
{
|
||||
public List<SelectedItemViewModel> GetFullList()
|
||||
{
|
||||
using var context = new OrdersDatabase();
|
||||
return context.SelectedItems
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<SelectedItemViewModel> GetFilteredList(SelectedItemSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new OrdersDatabase();
|
||||
return context.SelectedItems
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public SelectedItemViewModel? GetElement(SelectedItemSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new OrdersDatabase();
|
||||
return context.SelectedItems
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public SelectedItemViewModel? Insert(SelectedItemBindingModel model)
|
||||
{
|
||||
var newSelectedItem = SelectedItem.Create(model);
|
||||
if (newSelectedItem == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new OrdersDatabase();
|
||||
context.SelectedItems.Add(newSelectedItem);
|
||||
context.SaveChanges();
|
||||
return newSelectedItem.GetViewModel;
|
||||
}
|
||||
public SelectedItemViewModel? Update(SelectedItemBindingModel model)
|
||||
{
|
||||
using var context = new OrdersDatabase();
|
||||
var component = context.SelectedItems.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
public SelectedItemViewModel? Delete(SelectedItemBindingModel model)
|
||||
{
|
||||
using var context = new OrdersDatabase();
|
||||
var element = context.SelectedItems.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.SelectedItems.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\InternetShopOrdersContracts\InternetShopOrdersContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
87
VolkovLabs/InternetShopOrdersDatabaseImplement/Migrations/20241016152345_InitialMig.Designer.cs
generated
Normal file
87
VolkovLabs/InternetShopOrdersDatabaseImplement/Migrations/20241016152345_InitialMig.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("20241016152345_InitialMig")]
|
||||
partial class InitialMig
|
||||
{
|
||||
/// <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,65 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialMig : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SelectedItems",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SelectedItems", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Fullname = table.Column<string>(type: "text", nullable: false),
|
||||
Email = table.Column<string>(type: "text", nullable: false),
|
||||
SelectedItemId = table.Column<int>(type: "integer", nullable: false),
|
||||
OrderImage = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_SelectedItems_SelectedItemId",
|
||||
column: x => x.SelectedItemId,
|
||||
principalTable: "SelectedItems",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_SelectedItemId",
|
||||
table: "Orders",
|
||||
column: "SelectedItemId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SelectedItems");
|
||||
}
|
||||
}
|
||||
}
|
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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
// <auto-generated />
|
||||
using InternetShopOrdersDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(OrdersDatabase))]
|
||||
partial class OrdersDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(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,70 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using InternetShopOrdersDataModels.Models;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement.Models
|
||||
{
|
||||
public class Orders : IOrderModel
|
||||
{
|
||||
[Required]
|
||||
public string Fullname { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; private set; }
|
||||
|
||||
public int SelectedItemId { get; set; }
|
||||
|
||||
public virtual SelectedItem SelectedItem { get; set; } = new();
|
||||
|
||||
[Required]
|
||||
public string OrderImage { get; set; } = string.Empty;
|
||||
|
||||
public static Orders? Create(OrdersDatabase context, OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Orders()
|
||||
{
|
||||
Id = model.Id,
|
||||
Fullname = model.Fullname,
|
||||
Email = model.Email,
|
||||
SelectedItemId = model.SelectedItemId,
|
||||
SelectedItem = context.SelectedItems.First(x => x.Id == model.SelectedItemId),
|
||||
OrderImage = model.OrderImage,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel? model, OrdersDatabase context)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Fullname = model.Fullname;
|
||||
SelectedItemId = model.SelectedItemId;
|
||||
Email = model.Email;
|
||||
SelectedItem = context.SelectedItems.First(x => x.Id == model.SelectedItemId);
|
||||
OrderImage = model.OrderImage;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Fullname = Fullname,
|
||||
Email = Email,
|
||||
SelectedItemId = SelectedItemId,
|
||||
SelectedItemName = SelectedItem.Name,
|
||||
OrderImage = OrderImage,
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
using InternetShopOrdersContracts.BindingModels;
|
||||
using InternetShopOrdersContracts.ViewModels;
|
||||
using InternetShopOrdersDataModels.Models;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement.Models
|
||||
{
|
||||
public class SelectedItem : ISelectedItemModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
|
||||
public static SelectedItem? Create(SelectedItemBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new SelectedItem()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
};
|
||||
}
|
||||
public static SelectedItem? Create(SelectedItemViewModel? model)
|
||||
{
|
||||
return new SelectedItem()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
};
|
||||
}
|
||||
public void Update(SelectedItemBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Name = model.Name;
|
||||
}
|
||||
public SelectedItemViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using InternetShopOrdersDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InternetShopOrdersDatabaseImplement
|
||||
{
|
||||
public class OrdersDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
=> optionsBuilder.UseNpgsql("Host=localhost;Database=InternetShopOrdersDB;Username=postgres;Password=postgres");
|
||||
|
||||
public virtual DbSet<Orders> Orders { set; get; }
|
||||
public virtual DbSet<SelectedItem> SelectedItems { set; get; }
|
||||
}
|
||||
}
|
BIN
VolkovLabs/NuGetPackages.7z
Normal file
BIN
VolkovLabs/NuGetPackages.7z
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/ComponentsLibraryNet60.dll
Normal file
BIN
VolkovLabs/Plugins/ComponentsLibraryNet60.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/ControlsLibraryNet60.dll
Normal file
BIN
VolkovLabs/Plugins/ControlsLibraryNet60.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/DocumentFormat.OpenXml.dll
Normal file
BIN
VolkovLabs/Plugins/DocumentFormat.OpenXml.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/FormLibrary.dll
Normal file
BIN
VolkovLabs/Plugins/FormLibrary.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Humanizer.dll
Normal file
BIN
VolkovLabs/Plugins/Humanizer.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/InternetShopDataModels.dll
Normal file
BIN
VolkovLabs/Plugins/InternetShopDataModels.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/InternetShopOrdersApp.dll
Normal file
BIN
VolkovLabs/Plugins/InternetShopOrdersApp.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/InternetShopOrdersAppPlugins.dll
Normal file
BIN
VolkovLabs/Plugins/InternetShopOrdersAppPlugins.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/InternetShopOrdersBusinessLogic.dll
Normal file
BIN
VolkovLabs/Plugins/InternetShopOrdersBusinessLogic.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/InternetShopOrdersContracts.dll
Normal file
BIN
VolkovLabs/Plugins/InternetShopOrdersContracts.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/InternetShopOrdersDataModels.dll
Normal file
BIN
VolkovLabs/Plugins/InternetShopOrdersDataModels.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/InternetShopOrdersDatabaseImplement.dll
Normal file
BIN
VolkovLabs/Plugins/InternetShopOrdersDatabaseImplement.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Interop.Microsoft.Office.Core.dll
Normal file
BIN
VolkovLabs/Plugins/Interop.Microsoft.Office.Core.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Interop.Microsoft.Office.Interop.Excel.dll
Normal file
BIN
VolkovLabs/Plugins/Interop.Microsoft.Office.Interop.Excel.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.Bcl.AsyncInterfaces.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.Bcl.AsyncInterfaces.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.CodeAnalysis.CSharp.Workspaces.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.CodeAnalysis.CSharp.Workspaces.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.CodeAnalysis.CSharp.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.CodeAnalysis.CSharp.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.CodeAnalysis.CSharp.resources.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.CodeAnalysis.CSharp.resources.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.CodeAnalysis.Workspaces.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.CodeAnalysis.Workspaces.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.CodeAnalysis.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.CodeAnalysis.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.CodeAnalysis.resources.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.CodeAnalysis.resources.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.EntityFrameworkCore.Design.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.EntityFrameworkCore.Design.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.EntityFrameworkCore.Relational.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.EntityFrameworkCore.Relational.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.EntityFrameworkCore.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.EntityFrameworkCore.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.Extensions.Caching.Abstractions.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.Extensions.Caching.Abstractions.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.Extensions.Caching.Memory.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.Extensions.Caching.Memory.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.Extensions.DependencyInjection.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.Extensions.DependencyInjection.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.Extensions.DependencyModel.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.Extensions.DependencyModel.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.Extensions.Logging.Abstractions.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.Extensions.Logging.Abstractions.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.Extensions.Logging.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.Extensions.Logging.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.Extensions.Options.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.Extensions.Options.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Microsoft.Extensions.Primitives.dll
Normal file
BIN
VolkovLabs/Plugins/Microsoft.Extensions.Primitives.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/MigraDoc.DocumentObjectModel.dll
Normal file
BIN
VolkovLabs/Plugins/MigraDoc.DocumentObjectModel.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/MigraDoc.DocumentObjectModel.resources.dll
Normal file
BIN
VolkovLabs/Plugins/MigraDoc.DocumentObjectModel.resources.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/MigraDoc.Rendering.dll
Normal file
BIN
VolkovLabs/Plugins/MigraDoc.Rendering.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/MigraDoc.Rendering.resources.dll
Normal file
BIN
VolkovLabs/Plugins/MigraDoc.Rendering.resources.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Mono.TextTemplating.dll
Normal file
BIN
VolkovLabs/Plugins/Mono.TextTemplating.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/NevaevaLibrary.dll
Normal file
BIN
VolkovLabs/Plugins/NevaevaLibrary.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Npgsql.EntityFrameworkCore.PostgreSQL.dll
Normal file
BIN
VolkovLabs/Plugins/Npgsql.EntityFrameworkCore.PostgreSQL.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/Npgsql.dll
Normal file
BIN
VolkovLabs/Plugins/Npgsql.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/OxyPlot.WindowsForms.dll
Normal file
BIN
VolkovLabs/Plugins/OxyPlot.WindowsForms.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/OxyPlot.Wpf.Shared.dll
Normal file
BIN
VolkovLabs/Plugins/OxyPlot.Wpf.Shared.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/OxyPlot.Wpf.dll
Normal file
BIN
VolkovLabs/Plugins/OxyPlot.Wpf.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/OxyPlot.dll
Normal file
BIN
VolkovLabs/Plugins/OxyPlot.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/PdfSharp.Charting.dll
Normal file
BIN
VolkovLabs/Plugins/PdfSharp.Charting.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/PdfSharp.Charting.resources.dll
Normal file
BIN
VolkovLabs/Plugins/PdfSharp.Charting.resources.dll
Normal file
Binary file not shown.
BIN
VolkovLabs/Plugins/PdfSharp.dll
Normal file
BIN
VolkovLabs/Plugins/PdfSharp.dll
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user