Compare commits

...

46 Commits
main ... lab4

Author SHA1 Message Date
3bde9f70c7 лаба готова
ура!!!!!!! я рада!!!!!!
2024-12-15 02:41:35 +04:00
035f88c956 не работает пока что... библиотеки (файлы) он видите ли не видит не удается ему найти... 2024-12-04 16:15:12 +04:00
2cdcc41989 начала или продолжила 4 лабу
нужно нормально взять и доделать тудушки
2024-12-04 01:07:09 +04:00
674ef91a3e перекинула плагины в папку 2024-12-01 02:33:19 +04:00
cd24c38f4a создала основные классы для работы с приложением (плагином) 2024-11-30 22:09:21 +04:00
1ba0759d3c провсто добавила новый проект для 4 лабы случайно в третью 2024-11-30 20:39:18 +04:00
6c77b73f44 о еще пофиксила критическое и сдала 2024-11-20 16:55:12 +04:00
3ea68ad50d все сделала, только сдать осталось 2024-11-20 16:45:43 +04:00
394ecca149 работает форма добавления и редактирования полностью, пофиксила компонент выбора из списка 2024-11-20 13:39:30 +04:00
9c3a569942 работает справочник, все отлично
нужно связать теперь главную и справочник, поработать с горячими главишами и документами
2024-11-20 13:13:24 +04:00
64c1a27950 ну и вызов справочника добавила, все, спать 2024-11-20 01:36:20 +04:00
716c8682de без клавиш все работает вроде по созданию/редактированию/удалению основной сущности 2024-11-20 01:29:06 +04:00
9e1d524c2e работает проверка на изменение перед закрытием 2024-11-20 00:37:05 +04:00
061773baca работает вывод полей для редактирования 2024-11-20 00:06:32 +04:00
e507aa62a2 выводится тривью на главной форме 2024-11-19 22:29:34 +04:00
e5dd7184ed вроде все классы готовы, теперь нужно доработать формы и приступить к документам... 2024-11-19 02:15:38 +04:00
f1422b3632 нужно еще сторедж классы сделать и формы начать пилить по-адекватному 2024-11-19 01:40:09 +04:00
12844f798e поправила одно поле в моделях и сделала модели для базы данных 2024-11-19 01:20:24 +04:00
be9a809eae слой бизнес логики закончен 2024-11-19 00:49:49 +04:00
b111ab8039 так, я закончила слой контрактов. далее ждет жЕпа 2024-11-18 01:55:14 +04:00
c3b0de078d начала слой контрактов, добавила модели (интерфейсы моделей) 2024-11-18 01:41:24 +04:00
0dd9d6702c начинаю делать форму для справочника 2024-11-18 01:20:57 +04:00
9e102f153d форму создания/редактирования налепила вроде 2024-11-18 00:00:54 +04:00
f396b005b8 ну... я форму главную накидала немного 2024-11-17 15:30:59 +04:00
d29d0674ca вторая лаба сдана, а коммит в третьей 2024-11-06 17:14:14 +04:00
53121f5150 новый проект добавила, попыталась подключить пакет Кирилла, не вышло не фортануло. но и не сильно то надо, спасть вообще пора... 2024-11-05 23:02:31 +04:00
da0b0b3c97 чет подправила, у меня там очень много закомментированного кода было... 2024-11-05 18:50:01 +04:00
dd9e86a211 все работает НАКОНЕЦ ТО Я ЕГО РОТ НАОБОРОТ да и поздно уже... на паре ему не работалось...( 2024-10-23 22:51:01 +04:00
78cadc292f что-то работает во втором компоненте, но это все ТАКОЕ Г.... 2024-10-23 17:55:00 +04:00
db33928447 работает третий компонент, а второй не работает 2024-10-22 12:40:57 +04:00
e2e42acf98 так.. ну я начала что-то делать и устала. 6 часов делала второй компонент, гпт всякую фигню советует, опять переделывать... нужно настроить объединение ячеек в таблице и вообще вывод информации 2024-10-20 17:52:02 +04:00
c357d9e21b продолжаю делать 2 лабу... 2024-10-07 14:38:45 +04:00
4ef34fb579 изменения делаю во второй лабе, но я доделала и у меня приняли 1 лабу, 3 компонент 2024-10-07 14:15:47 +04:00
8a74c38488 начала делать второй компонент 2024-10-06 23:30:51 +04:00
877dcc8eed убрала излишние комментарии :/ для первого компонента 2024-10-06 22:26:24 +04:00
719ba80758 готов первый компонент 2024-10-06 22:24:58 +04:00
d79cf20111 рабочий третий компонент без символов начала и конца и спроверкой на нуллбл 2024-09-28 13:59:17 +04:00
d270df92c0 какие-то танцы с бубном по третьему компоненту и считыванию подстроки 2024-09-23 14:04:59 +04:00
da7b64ec6f чет проверила в лабе, подправила (в третьем компоненте...)
вроде работает
2024-09-23 01:06:36 +04:00
bbc5701cbc работает третий компонент :_) 2024-09-21 17:36:24 +04:00
0bd7fd69e3 второй компонент работает 2024-09-14 22:23:11 +04:00
89ceade732 в процессе разработки второго компонента 2024-09-06 22:21:18 +04:00
be6e8d0466 начинаю делать компонент ввода 2024-09-06 11:44:11 +04:00
33f373fde7 добавила тестовое приложение и протестировала компонент выбора из списка 2024-09-06 11:43:48 +04:00
8084f4f79a добавила компонент выбора из списка 2024-09-06 11:43:25 +04:00
34989eaa4a создание проекта 2024-09-06 10:02:55 +04:00
147 changed files with 5470 additions and 0 deletions

View File

@ -0,0 +1,29 @@
<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="Components" Version="1.0.1" />
<PackageReference Include="FixedWinFormsLibrary1" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Plugins\Plugins.csproj" />
<ProjectReference Include="..\ShopBusinessLogic\ShopBusinessLogic.csproj" />
<ProjectReference Include="..\ShopDataBaseImplements\ShopDataBaseImplements.csproj" />
<ProjectReference Include="..\UserComponentsOption19\UserComponentsOption19.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,184 @@
namespace AppShopInternetOption19
{
partial class FormEdit_Add
{
/// <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()
{
textComponentOrderSum = new WinFormsLibrary1.TextComponent();
textBoxFIO = new TextBox();
labelFIO = new Label();
labelGoodDescription = new Label();
textBoxGoodDescription = new TextBox();
labelOrderSum = new Label();
labelOrderStatus = new Label();
selectComponentOrderStatus = new UserComponentsOption19.SelectComponent();
buttonClose = new Button();
buttonSave = new Button();
SuspendLayout();
//
// textComponentOrderSum
//
textComponentOrderSum.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
textComponentOrderSum.Location = new Point(213, -35);
textComponentOrderSum.Margin = new Padding(3, 4, 3, 4);
textComponentOrderSum.Name = "textComponentOrderSum";
textComponentOrderSum.Size = new Size(351, 199);
textComponentOrderSum.TabIndex = 0;
textComponentOrderSum.TextValue = 0;
//
// textBoxFIO
//
textBoxFIO.Location = new Point(60, 9);
textBoxFIO.Name = "textBoxFIO";
textBoxFIO.Size = new Size(346, 27);
textBoxFIO.TabIndex = 1;
textBoxFIO.TextChanged += valueChanged;
//
// labelFIO
//
labelFIO.AutoSize = true;
labelFIO.Location = new Point(12, 9);
labelFIO.Name = "labelFIO";
labelFIO.Size = new Size(42, 20);
labelFIO.TabIndex = 4;
labelFIO.Text = "ФИО";
//
// labelGoodDescription
//
labelGoodDescription.Anchor = AnchorStyles.Top | AnchorStyles.Right;
labelGoodDescription.AutoSize = true;
labelGoodDescription.Location = new Point(430, 16);
labelGoodDescription.Name = "labelGoodDescription";
labelGoodDescription.Size = new Size(131, 20);
labelGoodDescription.TabIndex = 7;
labelGoodDescription.Text = "Описание товара";
//
// textBoxGoodDescription
//
textBoxGoodDescription.Anchor = AnchorStyles.Top | AnchorStyles.Right;
textBoxGoodDescription.Location = new Point(582, 9);
textBoxGoodDescription.Name = "textBoxGoodDescription";
textBoxGoodDescription.Size = new Size(378, 27);
textBoxGoodDescription.TabIndex = 8;
textBoxGoodDescription.TextChanged += valueChanged;
//
// labelOrderSum
//
labelOrderSum.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
labelOrderSum.AutoSize = true;
labelOrderSum.Location = new Point(248, 59);
labelOrderSum.Name = "labelOrderSum";
labelOrderSum.Size = new Size(104, 20);
labelOrderSum.TabIndex = 9;
labelOrderSum.Text = "Сумма заказа";
//
// labelOrderStatus
//
labelOrderStatus.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
labelOrderStatus.AutoSize = true;
labelOrderStatus.Location = new Point(12, 59);
labelOrderStatus.Name = "labelOrderStatus";
labelOrderStatus.Size = new Size(101, 20);
labelOrderStatus.TabIndex = 10;
labelOrderStatus.Text = "Статус заказа";
//
// selectComponentOrderStatus
//
selectComponentOrderStatus.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
selectComponentOrderStatus.Location = new Point(12, 91);
selectComponentOrderStatus.Name = "selectComponentOrderStatus";
selectComponentOrderStatus.SelectedValue = "";
selectComponentOrderStatus.Size = new Size(189, 36);
selectComponentOrderStatus.TabIndex = 11;
selectComponentOrderStatus.SelectComponentChanged += valueChanged;
//
// buttonClose
//
buttonClose.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonClose.BackColor = Color.IndianRed;
buttonClose.ForeColor = SystemColors.ButtonHighlight;
buttonClose.Location = new Point(582, 80);
buttonClose.Name = "buttonClose";
buttonClose.Size = new Size(138, 47);
buttonClose.TabIndex = 12;
buttonClose.Text = "Закрыть";
buttonClose.UseVisualStyleBackColor = false;
buttonClose.Click += buttonClose_Click;
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonSave.BackColor = Color.LightGreen;
buttonSave.ForeColor = Color.DarkGreen;
buttonSave.Location = new Point(822, 80);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(138, 47);
buttonSave.TabIndex = 13;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = false;
buttonSave.Click += buttonSave_Click;
//
// FormEdit_Add
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1032, 166);
Controls.Add(buttonSave);
Controls.Add(buttonClose);
Controls.Add(selectComponentOrderStatus);
Controls.Add(labelOrderStatus);
Controls.Add(labelOrderSum);
Controls.Add(textBoxGoodDescription);
Controls.Add(labelGoodDescription);
Controls.Add(labelFIO);
Controls.Add(textBoxFIO);
Controls.Add(textComponentOrderSum);
Name = "FormEdit_Add";
Text = "Редактировать/добавить сущность";
Load += FormEdit_Add_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private WinFormsLibrary1.TextComponent textComponentOrderSum;
private TextBox textBoxFIO;
private TextBox textBoxLastName;
private TextBox textBoxPatronymic;
private Label labelFIO;
private Label labelLastName;
private Label labelPatronymic;
private Label labelGoodDescription;
private TextBox textBoxGoodDescription;
private Label labelOrderSum;
private Label labelOrderStatus;
private UserComponentsOption19.SelectComponent selectComponentOrderStatus;
private Button buttonClose;
private Button buttonSave;
}
}

View File

@ -0,0 +1,124 @@
using ShopContracts.BindingModels;
using ShopContracts.BusinessLogicContracts;
using ShopContracts.SearchModels;
namespace AppShopInternetOption19
{
public partial class FormEdit_Add : Form
{
private readonly IOrderLogic _orderLogic;
private readonly IOrderStatusLogic _orderStatusLogic;
private int? _id;
public int Id { set { _id = value; } }
private bool isChanged = false;
public FormEdit_Add(IOrderLogic orderLogic, IOrderStatusLogic orderStatusLogic)
{
_orderLogic = orderLogic;
_orderStatusLogic = orderStatusLogic;
InitializeComponent();
selectComponentOrderStatus.FillList(_orderStatusLogic.ReadList(null), "Name");
textBoxFIO.TextChanged += valueChanged;
textBoxGoodDescription.TextChanged += valueChanged;
textComponentOrderSum.TextChanged += valueChanged;
selectComponentOrderStatus.SelectComponentChanged += valueChanged;
}
private void FormEdit_Add_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
if (_id != null)
{
var element = _orderLogic.ReadElement(new OrderSearchModel { Id = _id.Value });
if (element != null)
{
textBoxFIO.Text = element.FIO;
textBoxGoodDescription.Text = element.OrderDescription;
selectComponentOrderStatus.SelectedValue = element.OrderStatus;
if (int.TryParse(element.OrderSumm?.ToString(), out int result))
{
textComponentOrderSum.TextValue = result;
}
else
{
textComponentOrderSum.TextValue = null;
}
}
}
isChanged = false;
}
catch (Exception)
{
throw;
}
}
private void valueChanged(object sender, EventArgs e)
{
isChanged = true;
}
private void buttonClose_Click(object sender, EventArgs e)
{
if (isChanged == true)
{
var result = MessageBox.Show(
"Есть несохраненные изменения. Вы уверены, что хотите закрыть?",
"Подтверждение",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question
);
if (result == DialogResult.Yes)
{
Close();
}
else if (result == DialogResult.No)
{
MessageBox.Show("Окей, тогда делайте дальше)", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
Close();
}
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
var element = new OrderBindingModel
{
Id = _id ?? 0,
FIO = textBoxFIO.Text,
OrderDescription = textBoxGoodDescription.Text,
OrderStatus = selectComponentOrderStatus.SelectedValue.ToString(),
OrderSumm = textComponentOrderSum.TextValue.ToString() ?? "Оплачено скидками",
};
var operatingResult = _id.HasValue ? _orderLogic.Update(element) : _orderLogic.Create(element);
if (!operatingResult)
{
throw new Exception("Ошибка при создании сущности");
}
MessageBox.Show("Создание сущности прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}

View File

@ -0,0 +1,120 @@
<?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>
</root>

View File

@ -0,0 +1,95 @@
using ShopDataBaseImplements.Models;
namespace AppShopInternetOption19.Forms
{
partial class FormGuide
{
/// <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()
{
dataGridViewGuide = new DataGridView();
OrderStatus = new DataGridViewTextBoxColumn();
ID = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)dataGridViewGuide).BeginInit();
SuspendLayout();
//
// dataGridViewGuide
//
dataGridViewGuide.AllowUserToAddRows = false;
dataGridViewGuide.AllowUserToDeleteRows = false;
dataGridViewGuide.AllowUserToResizeColumns = false;
dataGridViewGuide.AllowUserToResizeRows = false;
dataGridViewGuide.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridViewGuide.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewGuide.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewGuide.Columns.AddRange(new DataGridViewColumn[] { OrderStatus, ID });
dataGridViewGuide.EditMode = DataGridViewEditMode.EditOnF2;
dataGridViewGuide.Location = new Point(12, 11);
dataGridViewGuide.MultiSelect = false;
dataGridViewGuide.Name = "dataGridViewGuide";
dataGridViewGuide.RowHeadersVisible = false;
dataGridViewGuide.RowHeadersWidth = 51;
dataGridViewGuide.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewGuide.Size = new Size(282, 411);
dataGridViewGuide.TabIndex = 0;
dataGridViewGuide.CellEndEdit += dataGridViewGuide_CellEndEdit;
dataGridViewGuide.CellValidating += dataGridViewGuide_CellValidating;
dataGridViewGuide.KeyDown += dataGridViewGuide_KeyDown;
//
// ID
//
ID.HeaderText = "Id";
ID.MinimumWidth = 6;
ID.Name = "Id";
ID.Visible = false;
//
// OrderStatus
//
OrderStatus.HeaderText = "Статус заказа";
OrderStatus.MinimumWidth = 6;
OrderStatus.Name = "OrderStatus";
//
// FormGuide
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(306, 435);
Controls.Add(dataGridViewGuide);
Name = "FormGuide";
Text = "Справочник";
((System.ComponentModel.ISupportInitialize)dataGridViewGuide).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewGuide;
private DataGridViewTextBoxColumn OrderStatus;
private DataGridViewTextBoxColumn ID;
}
}

View File

@ -0,0 +1,140 @@
using ShopBusinessLogic;
using ShopContracts.BindingModels;
using ShopContracts.BusinessLogicContracts;
using ShopContracts.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;
namespace AppShopInternetOption19.Forms
{
public partial class FormGuide : Form
{
private readonly IOrderStatusLogic _orderStatusLogic;
public FormGuide(IOrderStatusLogic orderStatusLogic)
{
_orderStatusLogic = orderStatusLogic;
InitializeComponent();
LoadData();
}
private void LoadData()
{
try
{
var orderStatuses = _orderStatusLogic.ReadList(null);
if (orderStatuses != null)
{
dataGridViewGuide.Rows.Clear();
foreach (var status in orderStatuses)
{
dataGridViewGuide.Rows.Add(status.Name, status.Id);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void dataGridViewGuide_KeyDown(object sender, KeyEventArgs e)
{
try
{
if (e.KeyCode == Keys.Insert)
{
dataGridViewGuide.Rows.Add();
dataGridViewGuide.CurrentCell = dataGridViewGuide.Rows[dataGridViewGuide.Rows.Count - 1].Cells["OrderStatus"]; // Ставим фокус на новую строку
e.Handled = true;
}
if (e.KeyCode == Keys.Delete)
{
if (dataGridViewGuide.SelectedRows.Count == 1)
{
DataGridViewRow currentRow = dataGridViewGuide.SelectedRows[0];
if (currentRow.Cells["Id"].Value != null || Convert.ToInt32(currentRow.Cells["Id"].Value) != 0)
{
var result = MessageBox.Show(
"Уверены???? удалю ведь щас",
"Подтверждение",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question
);
if (result == DialogResult.Yes)
{
_orderStatusLogic.Delete(new OrderStatusBindingModel { Id = Convert.ToInt32(currentRow.Cells["Id"].Value) });
MessageBox.Show("Ну все, успешно удалено");
LoadData();
}
else
{
MessageBox.Show("Ну не удаляй значит :/", "хммм", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
MessageBox.Show("ну тут нечего удалять", "алё", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void dataGridViewGuide_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
string? userInput = e.FormattedValue.ToString();
if (string.IsNullOrWhiteSpace(userInput))
{
MessageBox.Show("Ну ты не торопись давай, пустую запись сохранять низя Э", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
e.Cancel = true;
}
}
private void dataGridViewGuide_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
try
{
DataGridViewRow currentRow = dataGridViewGuide.Rows[e.RowIndex];
if (currentRow.Cells["Id"].Value == null || Convert.ToInt32(currentRow.Cells["Id"].Value) == 0)
{
_orderStatusLogic.Create(new OrderStatusBindingModel
{
Name = currentRow.Cells["OrderStatus"].Value.ToString()!,
});
}
else
{
_orderStatusLogic.Update(new OrderStatusBindingModel
{
Id = Convert.ToInt32(currentRow.Cells["Id"].Value),
Name = currentRow.Cells["OrderStatus"].Value.ToString(),
});
}
MessageBox.Show("Ура, успешно сохранена новая запись");
}
catch (Exception ex)
{
MessageBox.Show("Э ты ЧО на" + ex.Message);
}
}
}
}

View 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="OrderStatus.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>

View File

@ -0,0 +1,151 @@
namespace AppShopInternetOption19
{
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();
userControlTreeView = new Components.UserControlTreeView();
menuStrip1 = new MenuStrip();
добавитьToolStripMenuItem = new ToolStripMenuItem();
редактироватьToolStripMenuItem = new ToolStripMenuItem();
удалитьToolStripMenuItem = new ToolStripMenuItem();
созданиеПростогоДокументаToolStripMenuItem = new ToolStripMenuItem();
сОзданиеДоктаСТаблицейToolStripMenuItem = new ToolStripMenuItem();
созданиеДоктаСДиаграммойToolStripMenuItem = new ToolStripMenuItem();
справочникToolStripMenuItem = new ToolStripMenuItem();
createWord = new UserComponentsOption19.BigTextWordNoVisibleComponent(components);
createExcelPieDiagram = new Components.ComponentExcelWithPieDiagram(components);
createPdfTable = new WinFormsLibrary1.PDFTable(components);
menuStrip1.SuspendLayout();
SuspendLayout();
//
// userControlTreeView
//
userControlTreeView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
userControlTreeView.BackColor = SystemColors.ActiveCaption;
userControlTreeView.Location = new Point(1, 35);
userControlTreeView.Margin = new Padding(3, 4, 3, 4);
userControlTreeView.Name = "userControlTreeView";
userControlTreeView.SelectedIndex = -1;
userControlTreeView.Size = new Size(1278, 428);
userControlTreeView.TabIndex = 0;
userControlTreeView.Load += FormMain_Load;
//
// menuStrip1
//
menuStrip1.ImageScalingSize = new Size(20, 20);
menuStrip1.Items.AddRange(new ToolStripItem[] { добавитьToolStripMenuItem, редактироватьToolStripMenuItem, удалитьToolStripMenuItem, созданиеПростогоДокументаToolStripMenuItem, сОзданиеДоктаСТаблицейToolStripMenuItem, созданиеДоктаСДиаграммойToolStripMenuItem, справочникToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(1291, 28);
menuStrip1.TabIndex = 1;
menuStrip1.Text = "menuStrip1";
//
// добавитьToolStripMenuItem
//
добавитьToolStripMenuItem.Name = обавитьToolStripMenuItem";
добавитьToolStripMenuItem.Size = new Size(90, 24);
добавитьToolStripMenuItem.Text = "Добавить";
добавитьToolStripMenuItem.Click += добавитьToolStripMenuItem_Click;
//
// редактироватьToolStripMenuItem
//
редактироватьToolStripMenuItem.Name = "редактироватьToolStripMenuItem";
редактироватьToolStripMenuItem.Size = new Size(125, 24);
редактироватьToolStripMenuItem.Text = "Редактировать";
редактироватьToolStripMenuItem.Click += редактироватьToolStripMenuItem_Click;
//
// удалитьToolStripMenuItem
//
удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
удалитьToolStripMenuItem.Size = new Size(79, 24);
удалитьToolStripMenuItem.Text = "Удалить";
удалитьToolStripMenuItem.Click += удалитьToolStripMenuItem_Click;
//
// созданиеПростогоДокументаToolStripMenuItem
//
созданиеПростогоДокументаToolStripMenuItem.Name = "созданиеПростогоДокументаToolStripMenuItem";
созданиеПростогоДокументаToolStripMenuItem.Size = new Size(235, 24);
созданиеПростогоДокументаToolStripMenuItem.Text = "Создание простого документа";
созданиеПростогоДокументаToolStripMenuItem.Click += созданиеПростогоДокументаToolStripMenuItem_Click;
//
// сОзданиеДоктаСТаблицейToolStripMenuItem
//
сОзданиеДоктаСТаблицейToolStripMenuItem.Name = "сОзданиеДоктаСТаблицейToolStripMenuItem";
сОзданиеДоктаСТаблицейToolStripMenuItem.Size = new Size(219, 24);
сОзданиеДоктаСТаблицейToolStripMenuItem.Text = "Создание док-та с таблицей";
сОзданиеДоктаСТаблицейToolStripMenuItem.Click += сОзданиеДоктаСТаблицейToolStripMenuItem_Click;
//
// созданиеДоктаСДиаграммойToolStripMenuItem
//
созданиеДоктаСДиаграммойToolStripMenuItem.Name = "созданиеДоктаСДиаграммойToolStripMenuItem";
созданиеДоктаСДиаграммойToolStripMenuItem.Size = new Size(241, 24);
созданиеДоктаСДиаграммойToolStripMenuItem.Text = "Создание док-та с диаграммой";
созданиеДоктаСДиаграммойToolStripMenuItem.Click += созданиеДоктаСДиаграммойToolStripMenuItem_Click;
//
// справочникToolStripMenuItem
//
справочникToolStripMenuItem.Name = "справочникToolStripMenuItem";
справочникToolStripMenuItem.Size = new Size(108, 24);
справочникToolStripMenuItem.Text = "Справочник";
справочникToolStripMenuItem.Click += справочникToolStripMenuItem_Click;
//
// FormMain
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1291, 465);
Controls.Add(userControlTreeView);
Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1;
Name = "FormMain";
Text = "Главная форма";
Load += FormMain_Load;
KeyDown += FormMain_KeyDown;
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Components.UserControlTreeView userControlTreeView;
private MenuStrip menuStrip1;
private ToolStripMenuItem добавитьToolStripMenuItem;
private ToolStripMenuItem редактироватьToolStripMenuItem;
private ToolStripMenuItem удалитьToolStripMenuItem;
private ToolStripMenuItem созданиеПростогоДокументаToolStripMenuItem;
private ToolStripMenuItem сОзданиеДоктаСТаблицейToolStripMenuItem;
private ToolStripMenuItem созданиеДоктаСДиаграммойToolStripMenuItem;
private ToolStripMenuItem справочникToolStripMenuItem;
private UserComponentsOption19.BigTextWordNoVisibleComponent createWord;
private Components.ComponentExcelWithPieDiagram createExcelPieDiagram;
private WinFormsLibrary1.PDFTable createPdfTable;
}
}

View File

@ -0,0 +1,394 @@
using AppShopInternetOption19.Forms;
using Components;
using ShopContracts.BindingModels;
using ShopContracts.BusinessLogicContracts;
using ShopContracts.SearchModels;
using ShopDataBaseImplements.Models;
using System.Windows.Forms;
using UserComponentsOption19;
using WinFormsLibrary1;
using WinFormsLibrary1.HelperClasses;
namespace AppShopInternetOption19
{
public partial class FormMain : Form
{
private readonly IOrderLogic _orderLogic;
private readonly IOrderStatusLogic _orderStatusLogic;
public FormMain(IOrderLogic orderLogic, IOrderStatusLogic orderStatusLogic)
{
InitializeComponent();
_orderLogic = orderLogic;
_orderStatusLogic = orderStatusLogic;
this.KeyPreview = true;
LoadData();
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void äîáàâèòüToolStripMenuItem_Click(object sender, EventArgs e)
{
Add();
}
private void LoadData()
{
try
{
var orders = _orderLogic.ReadList(null);
if (orders == null)
{
return;
}
foreach (var order in orders)
{
if (order.OrderSumm == null || order.OrderSumm == string.Empty)
{
order.OrderSumm = "îïëà÷åíî ñêèäêàìè";
}
}
List<(string PropertyName, bool AlwaysCreateBranch)> hierarchy =
[
("OrderStatus", false),
("OrderSumm", false),
("Id", false),
("FIO", false),
];
userControlTreeView.SetHierarchy(hierarchy);
userControlTreeView.SetTreeObjects(orders);
}
catch (Exception ex)
{
MessageBox.Show($"{ex.Message}");
}
}
private void ðåäàêòèðîâàòüToolStripMenuItem_Click(object sender, EventArgs e)
{
Update();
}
private void óäàëèòüToolStripMenuItem_Click(object sender, EventArgs e)
{
Delete();
}
private void ñïðàâî÷íèêToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormGuide));
if (!(service is FormGuide form))
{
return;
}
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
private void Add()
{
var service = Program.ServiceProvider?.GetService(typeof(FormEdit_Add));
if (!(service is FormEdit_Add form))
{
return;
}
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
private void Update()
{
var service = Program.ServiceProvider?.GetService(typeof(FormEdit_Add));
if (!(service is FormEdit_Add form))
{
return;
}
var selectedOrder = userControlTreeView.GetObjectSelectedNode<OrderBindingModel>();
form.Id = Convert.ToInt32(selectedOrder.Id);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
private void Delete()
{
try
{
var selectedOrder = userControlTreeView.GetObjectSelectedNode<OrderBindingModel>();
if (selectedOrder != null)
{
var result = MessageBox.Show(
"Óâåðåíû???? óäàëþ âåäü ùàñ",
"Ïîäòâåðæäåíèå",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question
);
if (result == DialogResult.Yes)
{
_orderLogic.Delete(new OrderBindingModel { Id = selectedOrder.Id });
MessageBox.Show("Íó âñå, óñïåøíî óäàëåíî");
LoadData();
}
else if (result == DialogResult.No)
{
MessageBox.Show("Îêåé, òîãäà äåëàéòå äàëüøå)", "Èíôîðìàöèÿ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
LoadData();
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void CreateWord()
{
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
{
saveFileDialog.Filter = "Word Documents (*.docx)|*.docx";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
string filePath = saveFileDialog.FileName;
string title = "çàêàçû, êîòîðûå îïëà÷åíû ïîëíîñòüþ çà ñ÷åò ñêèäîê :D";
string[] data;
try
{
var orders = _orderLogic.ReadList(null);
if (orders != null)
{
// Ôèëüòðóåì çàêàçû, ãäå ñóììà çàêàçà ðàâíà null èëè ïóñòîé ñòðîêå
var freeOrders = orders
.Where(x => string.IsNullOrEmpty(x.OrderSumm))
.Select(x => $"ID: {x.Id}, ÔÈÎ: {x.FIO}, Ñòàòóñ çàêàçà: {x.OrderStatus}, Îïèñàíèå çàêàçà: {x.OrderDescription}")
.ToList();
if (freeOrders.Count == 0)
{
MessageBox.Show("Íåò çàêàçîâ, îïëà÷åííûõ ñêèäêàìè.");
return;
}
// Ïðåîáðàçóåì ñïèñîê â ìàññèâ ñòðîê äëÿ ïåðåäà÷è â ìåòîä
data = freeOrders.ToArray();
// Ñîçäàåì äîêóìåíò Word
createWord.CreateAndSaveDocument(filePath, title, data);
MessageBox.Show("Óñïåøíî :D ïðîâåðÿé íàëè÷èå ôàéëà...");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
private void CreateExcel()
{
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
{
saveFileDialog.Filter = "Excel Files (*.xlsx)|*.xlsx";
saveFileDialog.Title = "Ñîõðàíèòü äèàãðàììó â Excel";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
string filePath = saveFileDialog.FileName;
try
{
var orders = _orderLogic.ReadList(null);
if (orders == null || !orders.Any())
{
MessageBox.Show("Íåò äàííûõ äëÿ ñîçäàíèÿ äèàãðàììû.");
return;
}
var groupedData = orders
.Where(o => o.OrderSumm != null && o.OrderSumm != "" && o.OrderSumm != string.Empty)
.GroupBy(o => o.OrderStatus)
.Select(g => new ComponentExcelWithPieDiagram.ChartData
{
SeriesName = g.Key,
SeriesValue = g.Count()
})
.ToList();
if (!groupedData.Any())
{
MessageBox.Show("Íåò îïëà÷åííûõ çàêàçîâ.");
return;
}
string title = "Îïëà÷åííûå çàêàçû ïî ñòàòóñàì";
string diagramTitle = "Ðàñïðåäåëåíèå îïëà÷åííûõ çàêàçîâ";
createExcelPieDiagram.CreateExcelWithPieChart(
filePath,
title,
diagramTitle,
ComponentExcelWithPieDiagram.LegendPosition.Left,
groupedData
);
MessageBox.Show("Ôàéë óñïåøíî ñîçäàí.", "Èíôîðìàöèÿ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show($"Îøèáêà ïðè ñîçäàíèè ôàéëà: {ex.Message}", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void CreatePdf()
{
using (SaveFileDialog fileDialog = new SaveFileDialog())
{
fileDialog.Filter = "PDF Files (*.pdf)|*.pdf";
fileDialog.Title = "Ñîõðàíèòü äèàãðàììó â PDF";
if (fileDialog.ShowDialog() == DialogResult.OK)
{
string filePath = fileDialog.FileName;
string fileTitle = "Èíôîðìàöèÿ î çàêàçàõ";
try
{
var orders = _orderLogic.ReadList(null);
if (orders == null || !orders.Any())
{
MessageBox.Show("Íåò äàííûõ");
return;
}
List<string[,]> tables = new List<string[,]>();
string[,] tableData = new string[orders.Count + 1, 5];
// Øàïêà òàáëèöû
tableData[0, 0] = "Èäåíòèôèêàòîð";
tableData[0, 1] = "ÔÈÎ";
tableData[0, 2] = "Ñòàòóñ çàêàçà";
tableData[0, 3] = "Ñóììà çàêàçîâ";
tableData[0, 4] = "Îïèñàíèå";
for (int i = 0; i < orders.Count; i++)
{
var order = orders[i];
tableData[i + 1, 0] = order.Id.ToString();
tableData[i + 1, 1] = order.FIO;
tableData[i + 1, 2] = order.OrderStatus;
tableData[i + 1, 3] = string.IsNullOrWhiteSpace(order.OrderSumm)
? "Îïëà÷åí ñêèäêàìè"
: order.OrderSumm;
tableData[i + 1, 4] = order.OrderDescription;
}
tables.Add(tableData);
PdfDocumentData pdfData = new PdfDocumentData(filePath, fileTitle, tables);
createPdfTable.GeneratePdf(pdfData);
MessageBox.Show("Ôàéë óñïåøíî ñîçäàí.", "Èíôîðìàöèÿ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show($"Îøèáêà ïðè ñîçäàíèè ôàéëà: {ex.Message}", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
//private class PdfDocumentData
//{
// public string FileName { get; set; }
// public string DocumentTitle { get; set; }
// public List<string[,]> Tables { get; set; }
// public PdfDocumentData(string fileName, string documentTitle, List<string[,]> tables)
// {
// FileName = fileName ?? throw new ArgumentNullException("fileName");
// DocumentTitle = documentTitle ?? throw new ArgumentNullException("documentTitle");
// Tables = tables ?? throw new ArgumentNullException("tables");
// }
//}
private void FormMain_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control)
{
switch (e.KeyCode)
{
case Keys.A:
Add();
e.SuppressKeyPress = true;
break;
case Keys.U:
Update();
e.SuppressKeyPress = true;
break;
case Keys.D:
Delete();
e.SuppressKeyPress = true;
break;
case Keys.S:
CreateWord();
e.SuppressKeyPress = true;
break;
case Keys.C:
CreateExcel();
e.SuppressKeyPress = true;
break;
case Keys.T:
CreatePdf();
e.SuppressKeyPress = true;
break;
}
}
}
private void ñîçäàíèåÏðîñòîãîÄîêóìåíòàToolStripMenuItem_Click(object sender, EventArgs e)
{
CreateWord();
}
private void ñÎçäàíèåÄîêòàÑÒàáëèöåéToolStripMenuItem_Click(object sender, EventArgs e)
{
CreatePdf();
}
private void ñîçäàíèåÄîêòàÑÄèàãðàììîéToolStripMenuItem_Click(object sender, EventArgs e)
{
CreateExcel();
}
}
}

View File

@ -0,0 +1,132 @@
<?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="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="createWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>153, 17</value>
</metadata>
<metadata name="createExcelPieDiagram.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>444, 17</value>
</metadata>
<metadata name="createPdfTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>727, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,272 @@
using AppShopInternetOption19.Forms;
using Components;
using DocumentFormat.OpenXml.Drawing.Charts;
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
using DocumentFormat.OpenXml.Spreadsheet;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
using Plugins;
using ShopBusinessLogic;
using ShopContracts.BindingModels;
using ShopContracts.BusinessLogicContracts;
using ShopContracts.SearchModels;
using ShopContracts.ViewModels;
using ShopDataBaseImplements.Implements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UserComponentsOption19;
using WinFormsLibrary1;
using WinFormsLibrary1.HelperClasses;
namespace AppShopInternetOption19
{
public class PluginsConvention : IPluginsConvention
{
private readonly IOrderLogic _orderLogic;
private readonly IOrderStatusLogic _orderStatusLogic;
private readonly UserControlTreeView _userControlTreeView;
private readonly PDFTable _pdfTable;
private readonly BigTextWordNoVisibleComponent _wordDocument;
private readonly ComponentExcelWithPieDiagram _excelDiagram;
public string PluginName => "Orders";
public PluginsConvention()
{
_orderLogic = new OrderLogic(new OrderStorage());
_orderStatusLogic = new OrderStatusLogic(new OrderStatusStorage());
_pdfTable = new PDFTable();
_wordDocument = new BigTextWordNoVisibleComponent();
_excelDiagram = new ComponentExcelWithPieDiagram();
_userControlTreeView = new UserControlTreeView();
}
public UserControl GetControl
{
get { ReloadData(); return _userControlTreeView; }
}
public PluginsConventionElement GetElement
{
get
{
int Id = _userControlTreeView.GetObjectSelectedNode<OrderBindingModel>().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 FormMain(_orderLogic, _orderStatusLogic);
}
else
{
//int id = element.Id.GetHashCode();
byte[] bytes = element.Id.ToByteArray();
int Id = BitConverter.ToInt32(bytes, 0);
var form = new FormEdit_Add(_orderLogic, _orderStatusLogic);
form.Id = Id;
return form;
}
}
public void ReloadData()
{
try
{
var orders = _orderLogic.ReadList(null);
if (orders == null)
{
return;
}
foreach (var order in orders)
{
if (order.OrderSumm == null || order.OrderSumm == string.Empty)
{
order.OrderSumm = "оплачено скидками";
}
}
List<(string PropertyName, bool AlwaysCreateBranch)> hierarchy =
[
("OrderStatus", false),
("OrderSumm", false),
("Id", false),
("FIO", false),
];
_userControlTreeView.SetHierarchy(hierarchy);
_userControlTreeView.SetTreeObjects(orders);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public Form GetGuide()
{
return new FormGuide(_orderStatusLogic);
}
public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
{
string filePath = saveDocument.FileName;
try
{
var orders = _orderLogic.ReadList(null);
if (orders == null || !orders.Any())
{
MessageBox.Show("Нет данных для создания диаграммы.");
return false;
}
var groupedData = orders
.Where(o => o.OrderSumm != null && o.OrderSumm != "" && o.OrderSumm != string.Empty)
.GroupBy(o => o.OrderStatus)
.Select(g => new ComponentExcelWithPieDiagram.ChartData
{
SeriesName = g.Key,
SeriesValue = g.Count()
})
.ToList();
if (!groupedData.Any())
{
MessageBox.Show("Нет оплаченных заказов.");
return false;
}
string title = "Оплаченные заказы по статусам";
string diagramTitle = "Распределение оплаченных заказов";
_excelDiagram.CreateExcelWithPieChart(
filePath,
title,
diagramTitle,
ComponentExcelWithPieDiagram.LegendPosition.Left,
groupedData
);
return true;
}
catch (Exception ex)
{
MessageBox.Show(
$"Ошибка при создании файла: {ex.Message}",
"Ошибка",
MessageBoxButtons.OK,
MessageBoxIcon.Error
);
return false;
}
}
public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument)
{
string[] data;
string filePath = saveDocument.FileName;
string title = "Заказики";
try
{
var orders = _orderLogic.ReadList(null);
if (orders != null)
{
var freeOrders = orders
.Where(x => string.IsNullOrEmpty(x.OrderSumm))
.Select(x => $"ID: {x.Id}, ФИО: {x.FIO}, Статус заказа: {x.OrderStatus}, Описание заказа: {x.OrderDescription}")
.ToList();
if (freeOrders.Count == 0)
{
MessageBox.Show("Нет заказов, оплаченных скидками.");
return false;
}
data = freeOrders.ToArray();
_wordDocument.CreateAndSaveDocument(filePath, title, data);
return true;
}
else return false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return false;
}
}
public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
{
string filePath = saveDocument.FileName;
string fileTitle = "Информация о заказах";
try
{
var orders = _orderLogic.ReadList(null);
if (orders == null || !orders.Any())
{
MessageBox.Show("Нет данных");
return false;
}
List<string[,]> tables = new List<string[,]>();
string[,] tableData = new string[orders.Count + 1, 5];
// Шапка таблицы
tableData[0, 0] = "Идентификатор";
tableData[0, 1] = "ФИО";
tableData[0, 2] = "Статус заказа";
tableData[0, 3] = "Сумма заказов";
tableData[0, 4] = "Описание";
for (int i = 0; i < orders.Count; i++)
{
var order = orders[i];
tableData[i + 1, 0] = order.Id.ToString();
tableData[i + 1, 1] = order.FIO;
tableData[i + 1, 2] = order.OrderStatus;
tableData[i + 1, 3] = string.IsNullOrWhiteSpace(order.OrderSumm)
? "Оплачен скидками"
: order.OrderSumm;
tableData[i + 1, 4] = order.OrderDescription;
}
tables.Add(tableData);
PdfDocumentData pdfData = new PdfDocumentData(filePath, fileTitle, tables);
_pdfTable.GeneratePdf(pdfData);
return true;
}
catch (Exception ex)
{
MessageBox.Show($"Ошибка при создании файла: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
public bool DeleteElement(PluginsConventionElement element)
{
_orderLogic.Delete(new OrderBindingModel() { Id = element.Id.GetHashCode()});
return true;
}
}
}

View File

@ -0,0 +1,52 @@
using AppShopInternetOption19.Forms;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using ShopBusinessLogic;
using ShopContracts.BusinessLogicContracts;
using ShopContracts.StorageContracts;
using ShopDataBaseImplements.Implements;
namespace AppShopInternetOption19
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
/// <summary>
/// </summary>
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.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
//option.AddNLog("nlog.config");
});
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IOrderStatusStorage, OrderStatusStorage>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IOrderStatusLogic, OrderStatusLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormEdit_Add>();
services.AddTransient<FormGuide>();
}
}
}

View File

@ -0,0 +1,183 @@
namespace FormPlugins
{
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.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.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.menuStrip.SuspendLayout();
this.SuspendLayout();
//
// menuStrip
//
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.Size = new System.Drawing.Size(800, 24);
this.menuStrip.TabIndex = 0;
this.menuStrip.Text = "Меню";
//
// ControlsStripMenuItem
//
this.ControlsStripMenuItem.Name = "ControlsStripMenuItem";
this.ControlsStripMenuItem.Size = new System.Drawing.Size(94, 20);
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(70, 20);
this.ActionsToolStripMenuItem.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(82, 20);
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(233, 22);
this.SimpleDocToolStripMenuItem.Text = "Простой документ";
this.SimpleDocToolStripMenuItem.Click += new System.EventHandler(this.SimpleDocToolStripMenuItem_Click);
//
// 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(233, 22);
this.TableDocToolStripMenuItem.Text = "Документ с таблицой";
this.TableDocToolStripMenuItem.Click += new System.EventHandler(this.TableDocToolStripMenuItem_Click);
//
// 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(233, 22);
this.ChartDocToolStripMenuItem.Text = "Диаграмма";
this.ChartDocToolStripMenuItem.Click += new System.EventHandler(this.ChartDocToolStripMenuItem_Click);
//
// panelControl
//
this.panelControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelControl.Location = new System.Drawing.Point(0, 24);
this.panelControl.Name = "panelControl";
this.panelControl.Size = new System.Drawing.Size(800, 426);
this.panelControl.TabIndex = 1;
//
// 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(180, 22);
this.ThesaurusToolStripMenuItem.Text = "Справочник";
this.ThesaurusToolStripMenuItem.Click += new System.EventHandler(this.ThesaurusToolStripMenuItem_Click);
//
// 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(180, 22);
this.AddElementToolStripMenuItem.Text = "Добавить";
this.AddElementToolStripMenuItem.Click += new System.EventHandler(this.AddElementToolStripMenuItem_Click);
//
// 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(180, 22);
this.UpdElementToolStripMenuItem.Text = "Изменить";
this.UpdElementToolStripMenuItem.Click += new System.EventHandler(this.UpdElementToolStripMenuItem_Click);
//
// 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(180, 22);
this.DelElementToolStripMenuItem.Text = "Удалить";
this.DelElementToolStripMenuItem.Click += new System.EventHandler(this.DelElementToolStripMenuItem_Click);
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.panelControl);
this.Controls.Add(this.menuStrip);
this.MainMenuStrip = this.menuStrip;
this.Name = "FormMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Главная форма";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormMain_KeyDown);
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;
}
}

View File

@ -0,0 +1,220 @@
using Plugins;
using System.Reflection;
namespace FormPlugins
{
public partial class FormMain : Form
{
private readonly Dictionary<string, IPluginsConvention> _plugins;
private string _selectedPlugin;
public FormMain()
{
InitializeComponent();
_plugins = LoadPlugins();
_selectedPlugin = string.Empty;
}
private Dictionary<string, IPluginsConvention> LoadPlugins()
{
var plugins = new Dictionary<string, IPluginsConvention>();
string pluginsPath = Directory.GetParent(Directory.GetCurrentDirectory())!.Parent!.Parent!.FullName + "\\plugins";
string[] dlls = Directory.GetFiles(pluginsPath, "*.dll", SearchOption.AllDirectories);
foreach (string dll in dlls)
{
try
{
Assembly assembly = Assembly.LoadFrom(dll);
var types = assembly.GetTypes().Where(t => !t.IsInterface && !t.IsAbstract
&& typeof(IPluginsConvention).IsAssignableFrom(t));
foreach (var type in types)
{
var plugin = (IPluginsConvention)Activator.CreateInstance(type)!;
plugins.Add(plugin.PluginName, plugin);
CreateToolStripMenuItem(plugin.PluginName);
}
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
}
}
return plugins;
}
private void CreateToolStripMenuItem(string pluginName)
{
var menuItem = new ToolStripMenuItem(pluginName);
menuItem.Click += (object? sender, EventArgs e) =>
{
_selectedPlugin = pluginName;
IPluginsConvention plugin = _plugins[pluginName];
UserControl userControl = plugin.GetControl;
if (userControl != null)
{
panelControl.Controls.Clear();
plugin.ReloadData();
userControl.Dock = DockStyle.Fill;
panelControl.Controls.Add(userControl);
}
};
ControlsStripMenuItem.DropDown.Items.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:
ShowGuide();
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 ShowGuide()
{
if (string.IsNullOrEmpty(_selectedPlugin) || !_plugins.ContainsKey(_selectedPlugin))
{
MessageBox.Show("Плагин не выбран или не найден.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_plugins[_selectedPlugin].GetGuide()?.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()
{
// TODO узнать где сохранять
using (var dialog = new SaveFileDialog { Filter = "docx|*.docx" })
{
if (dialog.ShowDialog() == DialogResult.OK)
{
string fileName = dialog.FileName.ToString();
if (_plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument() { FileName = fileName }))
{
MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Ошибка при создании документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void CreateTableDoc()
{
// TODO узнать где сохранять
using (var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" })
{
if (dialog.ShowDialog() == DialogResult.OK)
{
string fileName = dialog.FileName.ToString();
if (_plugins[_selectedPlugin].CreateChartDocument(new PluginsConventionSaveDocument() { FileName = fileName }))
{
MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Ошибка при создании документа",
"Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void CreateChartDoc()
{
// TODO узнать где сохранять
using (var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" })
{
if (dialog.ShowDialog() == DialogResult.OK)
{
string fileName = dialog.FileName.ToString();
if (_plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument() { FileName = fileName }))
{
MessageBox.Show("Документ сохранен", "Создание документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Ошибка при создании документа",
"Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ThesaurusToolStripMenuItem_Click(object sender, EventArgs e) => ShowGuide();
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();
}
}

View File

@ -0,0 +1,120 @@
<?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>
</root>

View File

@ -0,0 +1,40 @@
<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="Microsoft.Bcl.AsyncInterfaces" Version="9.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AppShopInternetOption19\AppShopInternetOption19.csproj" />
<ProjectReference Include="..\Plugins\Plugins.csproj" />
<ProjectReference Include="..\ShopBusinessLogic\ShopBusinessLogic.csproj" />
<ProjectReference Include="..\ShopContracts\ShopContracts.csproj" />
<ProjectReference Include="..\ShopDataBaseImplements\ShopDataBaseImplements.csproj" />
<ProjectReference Include="..\ShopDataModels\ShopDataModels.csproj" />
<ProjectReference Include="..\TestAppForCheckComponentsWorking\TestAppForCheckComponentsWorking.csproj" />
<ProjectReference Include="..\UserComponentsOption19\UserComponentsOption19.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,17 @@
namespace FormPlugins
{
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());
}
}
}

View File

@ -0,0 +1,16 @@
namespace Plugins
{
public interface IPluginsConvention
{
string PluginName { get; }
UserControl GetControl { get; }
PluginsConventionElement GetElement { get; }
Form GetForm(PluginsConventionElement element);
Form GetGuide();
bool DeleteElement(PluginsConventionElement element);
void ReloadData();
bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument);
bool CreateTableDocument(PluginsConventionSaveDocument saveDocument);
bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);
}
}

View File

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,7 @@
namespace Plugins
{
public class PluginsConventionElement
{
public Guid Id { get; set; }
}
}

View File

@ -0,0 +1,7 @@
namespace Plugins
{
public class PluginsConventionSaveDocument
{
public string FileName { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,95 @@
using ShopContracts.BindingModels;
using ShopContracts.BusinessLogicContracts;
using ShopContracts.SearchModels;
using ShopContracts.StorageContracts;
using ShopContracts.ViewModels;
using System;
namespace ShopBusinessLogic
{
public class OrderLogic : IOrderLogic
{
IOrderStorage _orderStorage;
public OrderLogic(IOrderStorage orderStorage)
{
_orderStorage = orderStorage;
}
public bool Create(OrderBindingModel model)
{
CheckModel(model, false);
if (_orderStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Delete(OrderBindingModel model)
{
CheckModel(model, false);
if (_orderStorage.Delete(model) == null)
{
return false;
}
return true;
}
public OrderViewModel? ReadElement(OrderSearchModel model)
{
if (model == null)
{
return null;
}
var element = _orderStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
{
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public bool Update(OrderBindingModel model)
{
CheckModel(model, false);
if (_orderStorage.Update(model) == null) { return false; }
return true;
}
private void CheckModel(OrderBindingModel model, bool param = true)
{
if (model == null)
{
throw new ArgumentNullException($"Объект \"{model}\" нулл");
}
if (!param)
{
return;
}
if (model.FIO == null || string.IsNullOrEmpty(model.FIO))
{
throw new ArgumentNullException("Что-то с именем клиента - его нет почему-то");
}
if (model.OrderStatus == null || string.IsNullOrEmpty(model.OrderStatus))
{
throw new ArgumentNullException("что-то со статусом заказа - его нет почему-то");
}
if(model.OrderSumm == null)
{
model.OrderSumm = "оплачено скидками";
}
}
}
}

View File

@ -0,0 +1,85 @@
using ShopContracts.BindingModels;
using ShopContracts.BusinessLogicContracts;
using ShopContracts.SearchModels;
using ShopContracts.StorageContracts;
using ShopContracts.ViewModels;
namespace ShopBusinessLogic
{
public class OrderStatusLogic : IOrderStatusLogic
{
IOrderStatusStorage _orderStorage;
public OrderStatusLogic(IOrderStatusStorage orderStorage)
{
_orderStorage = orderStorage;
}
public bool Create(OrderStatusBindingModel model)
{
CheckModel(model, false);
if (_orderStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Delete(OrderStatusBindingModel model)
{
CheckModel(model, false);
if (_orderStorage.Delete(model) == null)
{
return false;
}
return true;
}
public OrderStatusViewModel? ReadElement(OrderStatusSearchModel model)
{
if (model == null)
{
return null;
}
var element = _orderStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public List<OrderStatusViewModel>? ReadList(OrderStatusSearchModel? model)
{
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
if (list == null)
{
return null;
}
return list;
}
public bool Update(OrderStatusBindingModel model)
{
CheckModel(model, false);
if (_orderStorage.Update(model) == null) { return false; }
return true;
}
private void CheckModel(OrderStatusBindingModel model, bool param = true)
{
if (model == null)
{
throw new ArgumentNullException($"Объект \"{model}\" нулл");
}
if (!param)
{
return;
}
if (model.Name == null || string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Что-то с именем клиента - его нет почему-то");
}
}
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ShopContracts\ShopContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,13 @@
using ShopDataModels.Models;
namespace ShopContracts.BindingModels
{
public class OrderBindingModel : IOrderModel
{
public int Id { get; set; }
public string FIO { get; set; } = string.Empty;
public string OrderDescription { get; set; } = string.Empty;
public string OrderStatus { get; set; } = string.Empty;
public string? OrderSumm { get; set; } = null;
}
}

View File

@ -0,0 +1,10 @@
using ShopDataModels.Models;
namespace ShopContracts.BindingModels
{
public class OrderStatusBindingModel : IOrderStatusModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,15 @@
using ShopContracts.BindingModels;
using ShopContracts.SearchModels;
using ShopContracts.ViewModels;
namespace ShopContracts.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);
}
}

Some files were not shown because too many files have changed in this diff Show More