This commit is contained in:
Student 2025-11-26 16:13:12 +04:00
commit e19947dea6
65 changed files with 5668 additions and 0 deletions

View File

@ -0,0 +1 @@
{"RootPath":"C:\\Users\\Student\\Downloads\\Модуль\\АвтоМастер\\NeshinaPolina07-11\\NeshinaPolina07-11","ProjectFileName":"NeshinaPolina07-11.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"AddOrder.cs"},{"SourceFile":"AddOrder.Designer.cs"},{"SourceFile":"AddProduct.cs"},{"SourceFile":"AddProduct.Designer.cs"},{"SourceFile":"DB.cs"},{"SourceFile":"EditProduct.cs"},{"SourceFile":"EditProduct.Designer.cs"},{"SourceFile":"Form1.cs"},{"SourceFile":"Form1.Designer.cs"},{"SourceFile":"Program.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"Regist.cs"},{"SourceFile":"Regist.Designer.cs"},{"SourceFile":"_1Menu.cs"},{"SourceFile":"_1Menu.Designer.cs"},{"SourceFile":"_2Menu.cs"},{"SourceFile":"_2Menu.Designer.cs"},{"SourceFile":"_3Menu.cs"},{"SourceFile":"_3Menu.Designer.cs"},{"SourceFile":"Properties\\Resources.Designer.cs"},{"SourceFile":"Properties\\Settings.Designer.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"}],"References":[{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Users\\Student\\Desktop\\MySql.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Deployment.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Drawing.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Net.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Windows.Forms.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\Users\\Student\\Downloads\\Модуль\\АвтоМастер\\NeshinaPolina07-11\\NeshinaPolina07-11\\bin\\Debug\\NeshinaPolina07-11.exe","OutputItemRelativePath":"NeshinaPolina07-11.exe"},{"OutputItemFullPath":"C:\\Users\\Student\\Downloads\\Модуль\\АвтоМастер\\NeshinaPolina07-11\\NeshinaPolina07-11\\bin\\Debug\\NeshinaPolina07-11.pdb","OutputItemRelativePath":"NeshinaPolina07-11.pdb"}],"CopyToOutputEntries":[]}

98
4Menu.Designer.cs generated Normal file
View File

@ -0,0 +1,98 @@
namespace NeshinaPolina07_11
{
partial class _4Menu
{
/// <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.dgvProducts = new System.Windows.Forms.DataGridView();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).BeginInit();
this.SuspendLayout();
//
// dgvProducts
//
this.dgvProducts.AllowUserToAddRows = false;
this.dgvProducts.AllowUserToDeleteRows = false;
this.dgvProducts.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
this.dgvProducts.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.dgvProducts.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight;
this.dgvProducts.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvProducts.Location = new System.Drawing.Point(19, 51);
this.dgvProducts.Name = "dgvProducts";
this.dgvProducts.ReadOnly = true;
this.dgvProducts.Size = new System.Drawing.Size(606, 317);
this.dgvProducts.TabIndex = 2;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(113, 39);
this.label1.TabIndex = 3;
this.label1.Text = "Гость";
//
// button1
//
this.button1.Location = new System.Drawing.Point(19, 415);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 4;
this.button1.Text = "Назад";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// _4Menu
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.MediumSpringGreen;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Controls.Add(this.dgvProducts);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "_4Menu";
this.Text = "_4Menu";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this._4Menu_FormClosing);
this.Load += new System.EventHandler(this._4Menu_Load);
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.DataGridView dgvProducts;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
}
}

81
4Menu.cs Normal file
View File

@ -0,0 +1,81 @@
using MySql.Data.MySqlClient;
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 NeshinaPolina07_11
{
public partial class _4Menu : Form
{
public _4Menu()
{
InitializeComponent();
this.Text = "Гость";
}
private void button1_Click(object sender, EventArgs e)
{
MainForm form = new MainForm();
form.Show();
this.Hide();
}
private void _4Menu_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Hide();
MainForm form1 = new MainForm();
form1.Show();
}
private void _4Menu_Load(object sender, EventArgs e)
{
try
{
var db = DB.GetInstance();
var connection = db.GetConnection();
string query = @"
SELECT
p.product_id,
p.product_article,
p.product_name,
p.unit,
p.price,
p.discount,
p.quantity_in_stock,
p.description,
p.photo,
c.category_name AS category,
m.manufacturer_name AS manufacturer,
s.supplier_name AS supplier
FROM products p
LEFT JOIN categories c ON p.category_id = c.category_id
LEFT JOIN manufacturers m ON p.manufacturer_id = m.manufacturer_id
LEFT JOIN suppliers s ON p.supplier_id = s.supplier_id;";
using (MySqlCommand cmd = new MySqlCommand(query, connection))
using (MySqlDataAdapter adapter = new MySqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
adapter.Fill(dt);
dgvProducts.DataSource = dt;
}
dgvProducts.AutoResizeColumns();
}
catch (Exception ex)
{
MessageBox.Show("Ошибка загрузки данных: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

120
4Menu.resx Normal file
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>

218
AddOrder.Designer.cs generated Normal file
View File

@ -0,0 +1,218 @@
namespace NeshinaPolina07_11
{
partial class AddOrder
{
/// <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.btnSave = new System.Windows.Forms.Button();
this.txtReceiveCode = new System.Windows.Forms.TextBox();
this.cmbPickupPoint = new System.Windows.Forms.ComboBox();
this.cmbUser = new System.Windows.Forms.ComboBox();
this.cmbStatus = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.dtpOrderDate = new System.Windows.Forms.DateTimePicker();
this.dtpDeliveryDate = new System.Windows.Forms.DateTimePicker();
this.SuspendLayout();
//
// btnSave
//
this.btnSave.Location = new System.Drawing.Point(95, 333);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(196, 23);
this.btnSave.TabIndex = 0;
this.btnSave.Text = "Добавить";
this.btnSave.UseVisualStyleBackColor = true;
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// txtReceiveCode
//
this.txtReceiveCode.Location = new System.Drawing.Point(154, 160);
this.txtReceiveCode.Name = "txtReceiveCode";
this.txtReceiveCode.Size = new System.Drawing.Size(201, 20);
this.txtReceiveCode.TabIndex = 6;
//
// cmbPickupPoint
//
this.cmbPickupPoint.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbPickupPoint.FormattingEnabled = true;
this.cmbPickupPoint.Location = new System.Drawing.Point(154, 204);
this.cmbPickupPoint.Name = "cmbPickupPoint";
this.cmbPickupPoint.Size = new System.Drawing.Size(200, 21);
this.cmbPickupPoint.TabIndex = 7;
//
// cmbUser
//
this.cmbUser.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbUser.FormattingEnabled = true;
this.cmbUser.Location = new System.Drawing.Point(154, 238);
this.cmbUser.Name = "cmbUser";
this.cmbUser.Size = new System.Drawing.Size(201, 21);
this.cmbUser.TabIndex = 8;
//
// cmbStatus
//
this.cmbStatus.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbStatus.FormattingEnabled = true;
this.cmbStatus.Location = new System.Drawing.Point(154, 265);
this.cmbStatus.Name = "cmbStatus";
this.cmbStatus.Size = new System.Drawing.Size(200, 21);
this.cmbStatus.TabIndex = 9;
this.cmbStatus.SelectedIndexChanged += new System.EventHandler(this.cmbStatus_SelectedIndexChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.label1.Location = new System.Drawing.Point(45, 25);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(310, 42);
this.label1.TabIndex = 10;
this.label1.Text = "Добавить заказ";
this.label1.Click += new System.EventHandler(this.label1_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 106);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 13);
this.label2.TabIndex = 11;
this.label2.Text = "Дата заказа";
this.label2.Click += new System.EventHandler(this.label2_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 133);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(83, 13);
this.label3.TabIndex = 12;
this.label3.Text = "Дата доставки";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 207);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(83, 13);
this.label4.TabIndex = 13;
this.label4.Text = "Пункст выдачи";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(12, 163);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(26, 13);
this.label5.TabIndex = 14;
this.label5.Text = "Код";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(12, 241);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(43, 13);
this.label8.TabIndex = 18;
this.label8.Text = "Клиент";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(12, 268);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(80, 13);
this.label9.TabIndex = 19;
this.label9.Text = "Статус заказа";
//
// dtpOrderDate
//
this.dtpOrderDate.Location = new System.Drawing.Point(154, 98);
this.dtpOrderDate.Name = "dtpOrderDate";
this.dtpOrderDate.Size = new System.Drawing.Size(200, 20);
this.dtpOrderDate.TabIndex = 21;
//
// dtpDeliveryDate
//
this.dtpDeliveryDate.Location = new System.Drawing.Point(154, 133);
this.dtpDeliveryDate.Name = "dtpDeliveryDate";
this.dtpDeliveryDate.Size = new System.Drawing.Size(200, 20);
this.dtpDeliveryDate.TabIndex = 22;
//
// AddOrder
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.MediumSpringGreen;
this.ClientSize = new System.Drawing.Size(381, 401);
this.Controls.Add(this.dtpDeliveryDate);
this.Controls.Add(this.dtpOrderDate);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.cmbStatus);
this.Controls.Add(this.cmbUser);
this.Controls.Add(this.cmbPickupPoint);
this.Controls.Add(this.txtReceiveCode);
this.Controls.Add(this.btnSave);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "AddOrder";
this.Text = "AddOrder";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.TextBox txtReceiveCode;
private System.Windows.Forms.ComboBox cmbPickupPoint;
private System.Windows.Forms.ComboBox cmbUser;
private System.Windows.Forms.ComboBox cmbStatus;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.DateTimePicker dtpOrderDate;
private System.Windows.Forms.DateTimePicker dtpDeliveryDate;
}
}

142
AddOrder.cs Normal file
View File

@ -0,0 +1,142 @@
using MySql.Data.MySqlClient;
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 NeshinaPolina07_11
{
public partial class AddOrder : Form
{
private readonly MySqlConnection _connection;
public AddOrder()
{
InitializeComponent();
_connection = DB.GetInstance().GetConnection();
LoadPickupPoints();
LoadUsers();
LoadStatuses();
dtpOrderDate.Value = DateTime.Now;
dtpDeliveryDate.Value = DateTime.Now.AddDays(3);
}
private void LoadPickupPoints()
{
LoadComboBox("pickup_points", "point_id", "address", cmbPickupPoint);
}
private void LoadUsers()
{
LoadComboBox("users", "user_id", "full_name", cmbUser);
}
private void LoadStatuses()
{
LoadComboBox("order_statuses", "status_id", "status_name", cmbStatus);
}
private void LoadComboBox(string table, string idCol, string nameCol, ComboBox combo)
{
string query = $"SELECT {idCol}, {nameCol} FROM {table} ORDER BY {nameCol}";
using (var cmd = new MySqlCommand(query, _connection))
using (var adapter = new MySqlDataAdapter(cmd))
{
var dt = new DataTable();
adapter.Fill(dt);
combo.DataSource = dt;
combo.DisplayMember = nameCol;
combo.ValueMember = idCol;
combo.SelectedIndex = -1;
}
}
private void label1_Click(object sender, EventArgs e)
{
}
private void btnSave_Click(object sender, EventArgs e)
{
if (cmbPickupPoint.SelectedValue == null)
{
MessageBox.Show("Выберите пункт выдачи.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (cmbUser.SelectedValue == null)
{
MessageBox.Show("Выберите пользователя.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (cmbStatus.SelectedValue == null)
{
MessageBox.Show("Выберите статус заказа.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrWhiteSpace(txtReceiveCode.Text))
{
MessageBox.Show("Введите код получения.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!string.IsNullOrWhiteSpace(txtReceiveCode.Text))
{
if (!int.TryParse(txtReceiveCode.Text, out int quantity) || quantity < 0)
{
MessageBox.Show("Введите код получения цифрами", "Некорректный код", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtReceiveCode.Focus();
return;
}
}
try
{
string getMaxIdQuery = "SELECT MAX(order_id) FROM orders";
using (var cmd = new MySqlCommand(getMaxIdQuery, _connection))
{
object result = cmd.ExecuteScalar();
int nextOrderId = result == DBNull.Value ? 1 : Convert.ToInt32(result) + 1;
string query = @"
INSERT INTO orders (order_id, order_date, delivery_date, pickup_point_id, user_id, receive_code, status_id)
VALUES (@order_id, @order_date, @delivery_date, @pickup_point_id, @user_id, @receive_code, @status_id)";
using (var insertCmd = new MySqlCommand(query, _connection))
{
insertCmd.Parameters.AddWithValue("@order_id", nextOrderId);
insertCmd.Parameters.AddWithValue("@order_date", dtpOrderDate.Value);
insertCmd.Parameters.AddWithValue("@delivery_date", dtpDeliveryDate.Value);
insertCmd.Parameters.AddWithValue("@pickup_point_id", cmbPickupPoint.SelectedValue);
insertCmd.Parameters.AddWithValue("@user_id", cmbUser.SelectedValue);
insertCmd.Parameters.AddWithValue("@receive_code", txtReceiveCode.Text.Trim());
insertCmd.Parameters.AddWithValue("@status_id", cmbStatus.SelectedValue);
insertCmd.ExecuteNonQuery();
}
}
MessageBox.Show("Заказ успешно добавлен.", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show($"Ошибка при добавлении заказа: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void label2_Click(object sender, EventArgs e)
{
}
private void cmbStatus_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}

120
AddOrder.resx Normal file
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>

283
AddProduct.Designer.cs generated Normal file
View File

@ -0,0 +1,283 @@
namespace NeshinaPolina07_11
{
partial class AddProduct
{
/// <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.label1 = new System.Windows.Forms.Label();
this.txtArticle = new System.Windows.Forms.TextBox();
this.txtName = new System.Windows.Forms.TextBox();
this.txtPrice = new System.Windows.Forms.TextBox();
this.txtDiscount = new System.Windows.Forms.TextBox();
this.txtQuantity = new System.Windows.Forms.TextBox();
this.cmbCategory = new System.Windows.Forms.ComboBox();
this.cmbManufacturer = new System.Windows.Forms.ComboBox();
this.cmbSupplier = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.txtDescription = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.label1.Location = new System.Drawing.Point(91, 9);
this.label1.Name = "label1";
this.label1.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label1.Size = new System.Drawing.Size(228, 39);
this.label1.TabIndex = 0;
this.label1.Text = "Добавление";
//
// txtArticle
//
this.txtArticle.Location = new System.Drawing.Point(45, 85);
this.txtArticle.Name = "txtArticle";
this.txtArticle.Size = new System.Drawing.Size(274, 20);
this.txtArticle.TabIndex = 1;
//
// txtName
//
this.txtName.Location = new System.Drawing.Point(45, 130);
this.txtName.Name = "txtName";
this.txtName.Size = new System.Drawing.Size(274, 20);
this.txtName.TabIndex = 2;
//
// txtPrice
//
this.txtPrice.Location = new System.Drawing.Point(45, 173);
this.txtPrice.Name = "txtPrice";
this.txtPrice.Size = new System.Drawing.Size(274, 20);
this.txtPrice.TabIndex = 4;
//
// txtDiscount
//
this.txtDiscount.Location = new System.Drawing.Point(45, 222);
this.txtDiscount.Name = "txtDiscount";
this.txtDiscount.Size = new System.Drawing.Size(274, 20);
this.txtDiscount.TabIndex = 5;
this.txtDiscount.TextChanged += new System.EventHandler(this.textBox5_TextChanged);
//
// txtQuantity
//
this.txtQuantity.Location = new System.Drawing.Point(45, 265);
this.txtQuantity.Name = "txtQuantity";
this.txtQuantity.Size = new System.Drawing.Size(274, 20);
this.txtQuantity.TabIndex = 6;
//
// cmbCategory
//
this.cmbCategory.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbCategory.FormattingEnabled = true;
this.cmbCategory.Location = new System.Drawing.Point(45, 356);
this.cmbCategory.Name = "cmbCategory";
this.cmbCategory.Size = new System.Drawing.Size(274, 21);
this.cmbCategory.TabIndex = 7;
//
// cmbManufacturer
//
this.cmbManufacturer.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbManufacturer.FormattingEnabled = true;
this.cmbManufacturer.Location = new System.Drawing.Point(45, 400);
this.cmbManufacturer.Name = "cmbManufacturer";
this.cmbManufacturer.Size = new System.Drawing.Size(274, 21);
this.cmbManufacturer.TabIndex = 8;
//
// cmbSupplier
//
this.cmbSupplier.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbSupplier.FormattingEnabled = true;
this.cmbSupplier.Location = new System.Drawing.Point(45, 444);
this.cmbSupplier.Name = "cmbSupplier";
this.cmbSupplier.Size = new System.Drawing.Size(274, 21);
this.cmbSupplier.TabIndex = 9;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(42, 69);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(48, 13);
this.label2.TabIndex = 10;
this.label2.Text = "Артикул";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(42, 114);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(38, 13);
this.label3.TabIndex = 11;
this.label3.Text = "Товар";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(42, 157);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(33, 13);
this.label4.TabIndex = 12;
this.label4.Text = "Цена";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(42, 206);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(44, 13);
this.label5.TabIndex = 13;
this.label5.Text = "Скидка";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(42, 249);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(120, 13);
this.label6.TabIndex = 14;
this.label6.Text = "Количество на складе";
//
// txtDescription
//
this.txtDescription.Location = new System.Drawing.Point(45, 313);
this.txtDescription.Name = "txtDescription";
this.txtDescription.Size = new System.Drawing.Size(274, 20);
this.txtDescription.TabIndex = 15;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(42, 297);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(57, 13);
this.label7.TabIndex = 16;
this.label7.Text = "Описание";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(42, 340);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(60, 13);
this.label8.TabIndex = 17;
this.label8.Text = "Категория";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(42, 384);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(86, 13);
this.label9.TabIndex = 18;
this.label9.Text = "Производитель";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(42, 428);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(65, 13);
this.label10.TabIndex = 19;
this.label10.Text = "Поставщик";
//
// button1
//
this.button1.Location = new System.Drawing.Point(87, 506);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(166, 47);
this.button1.TabIndex = 20;
this.button1.Text = "Добавить";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// AddProduct
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.MediumSpringGreen;
this.ClientSize = new System.Drawing.Size(381, 627);
this.Controls.Add(this.button1);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.txtDescription);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.cmbSupplier);
this.Controls.Add(this.cmbManufacturer);
this.Controls.Add(this.cmbCategory);
this.Controls.Add(this.txtQuantity);
this.Controls.Add(this.txtDiscount);
this.Controls.Add(this.txtPrice);
this.Controls.Add(this.txtName);
this.Controls.Add(this.txtArticle);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "AddProduct";
this.Text = "AddProduct";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtArticle;
private System.Windows.Forms.TextBox txtName;
private System.Windows.Forms.TextBox txtPrice;
private System.Windows.Forms.TextBox txtDiscount;
private System.Windows.Forms.TextBox txtQuantity;
private System.Windows.Forms.ComboBox cmbCategory;
private System.Windows.Forms.ComboBox cmbManufacturer;
private System.Windows.Forms.ComboBox cmbSupplier;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txtDescription;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Button button1;
}
}

247
AddProduct.cs Normal file
View File

@ -0,0 +1,247 @@
using MySql.Data.MySqlClient;
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 static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;
namespace NeshinaPolina07_11
{
public partial class AddProduct : Form
{
private _1Menu parentForm;
public AddProduct(_1Menu parent)
{
InitializeComponent();
parentForm = parent;
LoadCategories();
LoadManufacturers();
LoadSuppliers();
}
private void LoadCategories()
{
cmbCategory.Items.Clear();
try
{
var db = DB.GetInstance();
var connection = db.GetConnection();
string query = "SELECT category_id, category_name FROM categories ORDER BY category_name";
using (MySqlCommand cmd = new MySqlCommand(query, connection))
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
cmbCategory.Items.Add(new CategoryItem
{
Id = Convert.ToInt32(reader["category_id"]),
Name = reader["category_name"].ToString()
});
}
}
}
catch (Exception ex)
{
MessageBox.Show("Ошибка загрузки категорий: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
cmbCategory.DisplayMember = "Name";
cmbCategory.ValueMember = "Id";
if (cmbCategory.Items.Count > 0) cmbCategory.SelectedIndex = 0;
}
private void LoadManufacturers()
{
cmbManufacturer.Items.Clear();
try
{
var db = DB.GetInstance();
var connection = db.GetConnection();
string query = "SELECT manufacturer_id, manufacturer_name FROM manufacturers ORDER BY manufacturer_name";
using (MySqlCommand cmd = new MySqlCommand(query, connection))
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
cmbManufacturer.Items.Add(new ManufacturerItem
{
Id = Convert.ToInt32(reader["manufacturer_id"]),
Name = reader["manufacturer_name"].ToString()
});
}
}
}
catch (Exception ex)
{
MessageBox.Show("Ошибка загрузки производителей: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
cmbManufacturer.DisplayMember = "Name";
cmbManufacturer.ValueMember = "Id";
if (cmbManufacturer.Items.Count > 0) cmbManufacturer.SelectedIndex = 0;
}
private void LoadSuppliers()
{
cmbSupplier.Items.Clear();
try
{
var db = DB.GetInstance();
var connection = db.GetConnection();
string query = "SELECT supplier_id, supplier_name FROM suppliers ORDER BY supplier_name";
using (MySqlCommand cmd = new MySqlCommand(query, connection))
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
cmbSupplier.Items.Add(new SupplierItem
{
Id = Convert.ToInt32(reader["supplier_id"]),
Name = reader["supplier_name"].ToString()
});
}
}
}
catch (Exception ex)
{
MessageBox.Show("Ошибка загрузки поставщиков: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
cmbSupplier.DisplayMember = "Name";
cmbSupplier.ValueMember = "Id";
if (cmbSupplier.Items.Count > 0) cmbSupplier.SelectedIndex = 0;
}
private class CategoryItem
{
public int Id { get; set; }
public string Name { get; set; }
public override string ToString() => Name;
}
private class ManufacturerItem
{
public int Id { get; set; }
public string Name { get; set; }
public override string ToString() => Name;
}
private class SupplierItem
{
public int Id { get; set; }
public string Name { get; set; }
public override string ToString() => Name;
}
private int? GetCategoryId() => cmbCategory.SelectedItem is CategoryItem c ? c.Id : (int?)null;
private int? GetManufacturerId() => cmbManufacturer.SelectedItem is ManufacturerItem m ? m.Id : (int?)null;
private int? GetSupplierId() => cmbSupplier.SelectedItem is SupplierItem s ? s.Id : (int?)null;
private void textBox5_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(txtArticle.Text) || string.IsNullOrWhiteSpace(txtName.Text))
{
MessageBox.Show("Артикул и название товара обязательны для заполнения.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (!string.IsNullOrWhiteSpace(txtPrice.Text))
{
if (!decimal.TryParse(txtPrice.Text.Replace(',', '.'), out decimal price) || price < 0)
{
MessageBox.Show("Цена должна быть положительным числом (например: 199.99).", "Некорректная цена", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtPrice.Focus();
return;
}
}
if (!string.IsNullOrWhiteSpace(txtDiscount.Text))
{
if (!int.TryParse(txtDiscount.Text, out int discount) || discount < 0 || discount > 100)
{
MessageBox.Show("Скидка должна быть целым числом от 0 до 100%.", "Некорректная скидка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtDiscount.Focus();
return;
}
}
if (!string.IsNullOrWhiteSpace(txtQuantity.Text))
{
if (!int.TryParse(txtQuantity.Text, out int quantity) || quantity < 0)
{
MessageBox.Show("Количество должно быть целым неотрицательным числом (0 или больше).", "Некорректное количество", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtQuantity.Focus();
return;
}
}
try
{
var db = DB.GetInstance();
var connection = db.GetConnection();
string query = @"
INSERT INTO products (
product_article, product_name, unit, price, discount, quantity_in_stock, description,
category_id, manufacturer_id, supplier_id
) VALUES (
@article, @name, 'шт.', @price, @discount, @quantity, @description,
@categoryId, @manufacturerId, @supplierId
)";
using (MySqlCommand cmd = new MySqlCommand(query, connection))
{
cmd.Parameters.AddWithValue("@article", txtArticle.Text.Trim());
cmd.Parameters.AddWithValue("@name", txtName.Text.Trim());
if (decimal.TryParse(txtPrice.Text.Replace(',', '.'), out decimal parsedPrice))
cmd.Parameters.AddWithValue("@price", parsedPrice);
else
cmd.Parameters.AddWithValue("@price", DBNull.Value);
if (int.TryParse(txtDiscount.Text, out int parsedDiscount))
cmd.Parameters.AddWithValue("@discount", parsedDiscount);
else
cmd.Parameters.AddWithValue("@discount", DBNull.Value);
if (int.TryParse(txtQuantity.Text, out int parsedQuantity))
cmd.Parameters.AddWithValue("@quantity", parsedQuantity);
else
cmd.Parameters.AddWithValue("@quantity", DBNull.Value);
cmd.Parameters.AddWithValue("@description", string.IsNullOrWhiteSpace(txtDescription.Text)
? (object)DBNull.Value
: txtDescription.Text.Trim());
cmd.Parameters.AddWithValue("@categoryId", GetCategoryId() ?? (object)DBNull.Value);
cmd.Parameters.AddWithValue("@manufacturerId", GetManufacturerId() ?? (object)DBNull.Value);
cmd.Parameters.AddWithValue("@supplierId", GetSupplierId() ?? (object)DBNull.Value);
if (cmd.ExecuteNonQuery() > 0)
{
MessageBox.Show("Товар успешно добавлен!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
parentForm.RefreshData();
this.Close();
}
else
{
MessageBox.Show("Не удалось добавить товар.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
catch (Exception ex)
{
MessageBox.Show("Ошибка при добавлении товара: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

120
AddProduct.resx Normal file
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>

6
App.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

35
DB.cs Normal file
View File

@ -0,0 +1,35 @@
using MySql.Data.MySqlClient;
using System.Data;
namespace NeshinaPolina07_11
{
internal class DB
{
private static DB instance;
private MySqlConnection connection;
private readonly string connectionString =
"server=192.168.201.207;port=3306;username=ISP41_Neshina;password=ISP41_Neshina;database=ISP41_Neshina_Dem;SslMode=none; Charset=utf8mb4";
private DB()
{
connection = new MySqlConnection(connectionString);
OpenConnection();
}
public static DB GetInstance()
{
if (instance == null)
instance = new DB();
return instance;
}
public void OpenConnection()
{
if (connection.State == ConnectionState.Closed)
connection.Open();
}
public MySqlConnection GetConnection() => connection;
}
}

217
EditOrder.Designer.cs generated Normal file
View File

@ -0,0 +1,217 @@
namespace NeshinaPolina07_11
{
partial class EditOrder
{
/// <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.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.dtpOrderDate = new System.Windows.Forms.DateTimePicker();
this.dtpDeliveryDate = new System.Windows.Forms.DateTimePicker();
this.txtReceiveCode = new System.Windows.Forms.TextBox();
this.cmbPickupPoint = new System.Windows.Forms.ComboBox();
this.cmbUser = new System.Windows.Forms.ComboBox();
this.cmbStatus = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(28, 88);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 13);
this.label2.TabIndex = 12;
this.label2.Text = "Дата заказа";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(28, 131);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(83, 13);
this.label3.TabIndex = 13;
this.label3.Text = "Дата доставки";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(28, 177);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(26, 13);
this.label5.TabIndex = 15;
this.label5.Text = "Код";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(28, 218);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(83, 13);
this.label4.TabIndex = 16;
this.label4.Text = "Пункст выдачи";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(28, 260);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(43, 13);
this.label8.TabIndex = 19;
this.label8.Text = "Клиент";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(28, 295);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(80, 13);
this.label9.TabIndex = 20;
this.label9.Text = "Статус заказа";
//
// dtpOrderDate
//
this.dtpOrderDate.Location = new System.Drawing.Point(143, 88);
this.dtpOrderDate.Name = "dtpOrderDate";
this.dtpOrderDate.Size = new System.Drawing.Size(200, 20);
this.dtpOrderDate.TabIndex = 22;
//
// dtpDeliveryDate
//
this.dtpDeliveryDate.Location = new System.Drawing.Point(143, 131);
this.dtpDeliveryDate.Name = "dtpDeliveryDate";
this.dtpDeliveryDate.Size = new System.Drawing.Size(200, 20);
this.dtpDeliveryDate.TabIndex = 23;
//
// txtReceiveCode
//
this.txtReceiveCode.Location = new System.Drawing.Point(142, 170);
this.txtReceiveCode.Name = "txtReceiveCode";
this.txtReceiveCode.Size = new System.Drawing.Size(201, 20);
this.txtReceiveCode.TabIndex = 24;
//
// cmbPickupPoint
//
this.cmbPickupPoint.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbPickupPoint.FormattingEnabled = true;
this.cmbPickupPoint.Location = new System.Drawing.Point(142, 210);
this.cmbPickupPoint.Name = "cmbPickupPoint";
this.cmbPickupPoint.Size = new System.Drawing.Size(200, 21);
this.cmbPickupPoint.TabIndex = 25;
//
// cmbUser
//
this.cmbUser.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbUser.FormattingEnabled = true;
this.cmbUser.Location = new System.Drawing.Point(142, 252);
this.cmbUser.Name = "cmbUser";
this.cmbUser.Size = new System.Drawing.Size(201, 21);
this.cmbUser.TabIndex = 26;
//
// cmbStatus
//
this.cmbStatus.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbStatus.FormattingEnabled = true;
this.cmbStatus.Location = new System.Drawing.Point(143, 292);
this.cmbStatus.Name = "cmbStatus";
this.cmbStatus.Size = new System.Drawing.Size(200, 21);
this.cmbStatus.TabIndex = 27;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.label1.Location = new System.Drawing.Point(59, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(296, 42);
this.label1.TabIndex = 28;
this.label1.Text = "Редактировать";
this.label1.Click += new System.EventHandler(this.label1_Click);
//
// button1
//
this.button1.Location = new System.Drawing.Point(97, 336);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(204, 23);
this.button1.TabIndex = 29;
this.button1.Text = "Редактировать";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// EditOrder
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.MediumSpringGreen;
this.ClientSize = new System.Drawing.Size(403, 384);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Controls.Add(this.cmbStatus);
this.Controls.Add(this.cmbUser);
this.Controls.Add(this.cmbPickupPoint);
this.Controls.Add(this.txtReceiveCode);
this.Controls.Add(this.dtpDeliveryDate);
this.Controls.Add(this.dtpOrderDate);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.label4);
this.Controls.Add(this.label5);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "EditOrder";
this.Text = "EditOrder";
this.Load += new System.EventHandler(this.EditOrder_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.DateTimePicker dtpOrderDate;
private System.Windows.Forms.DateTimePicker dtpDeliveryDate;
private System.Windows.Forms.TextBox txtReceiveCode;
private System.Windows.Forms.ComboBox cmbPickupPoint;
private System.Windows.Forms.ComboBox cmbUser;
private System.Windows.Forms.ComboBox cmbStatus;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
}
}

161
EditOrder.cs Normal file
View File

@ -0,0 +1,161 @@
using MySql.Data.MySqlClient;
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 NeshinaPolina07_11
{
public partial class EditOrder : Form
{
private readonly int _orderId;
private readonly MySqlConnection _connection;
public EditOrder(int orderId)
{
InitializeComponent();
_orderId = orderId;
_connection = DB.GetInstance().GetConnection();
LoadComboBoxes();
LoadOrderData();
}
private void LoadComboBoxes()
{
LoadComboBox("pickup_points", "point_id", "address", cmbPickupPoint);
LoadComboBox("users", "user_id", "full_name", cmbUser);
LoadComboBox("order_statuses", "status_id", "status_name", cmbStatus);
}
private void LoadComboBox(string table, string idCol, string nameCol, ComboBox combo)
{
string query = $"SELECT {idCol}, {nameCol} FROM {table} ORDER BY {nameCol}";
using (var cmd = new MySqlCommand(query, _connection))
using (var adapter = new MySqlDataAdapter(cmd))
{
var dt = new DataTable();
adapter.Fill(dt);
combo.DataSource = dt;
combo.DisplayMember = nameCol;
combo.ValueMember = idCol;
combo.SelectedIndex = -1;
}
}
private void LoadOrderData()
{
string query = @"
SELECT
order_date, delivery_date, pickup_point_id, user_id, receive_code, status_id
FROM orders
WHERE order_id = @id";
using (var cmd = new MySqlCommand(query, _connection))
{
cmd.Parameters.AddWithValue("@id", _orderId);
using (var reader = cmd.ExecuteReader())
{
if (reader.Read())
{
dtpOrderDate.Value = Convert.ToDateTime(reader["order_date"]);
dtpDeliveryDate.Value = Convert.ToDateTime(reader["delivery_date"]);
txtReceiveCode.Text = reader["receive_code"].ToString();
SetComboBoxValue(cmbPickupPoint, reader["pickup_point_id"]);
SetComboBoxValue(cmbUser, reader["user_id"]);
SetComboBoxValue(cmbStatus, reader["status_id"]);
}
else
{
MessageBox.Show("Заказ не найден.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
DialogResult = DialogResult.Cancel;
Close();
}
}
}
}
private void SetComboBoxValue(ComboBox combo, object value)
{
if (value != DBNull.Value && combo.DataSource != null)
{
foreach (DataRowView row in combo.Items)
{
if (row[combo.ValueMember].Equals(value))
{
combo.SelectedItem = row;
return;
}
}
}
}
private void EditOrder_Load(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (cmbPickupPoint.SelectedValue == null)
{
MessageBox.Show("Выберите пункт выдачи.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (cmbUser.SelectedValue == null)
{
MessageBox.Show("Выберите пользователя.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (cmbStatus.SelectedValue == null)
{
MessageBox.Show("Выберите статус заказа.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrWhiteSpace(txtReceiveCode.Text))
{
MessageBox.Show("Введите код получения.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string query = @"
UPDATE orders
SET
order_date = @order_date,
delivery_date = @delivery_date,
pickup_point_id = @pickup_point_id,
user_id = @user_id,
receive_code = @receive_code,
status_id = @status_id
WHERE order_id = @id";
using (var cmd = new MySqlCommand(query, _connection))
{
cmd.Parameters.AddWithValue("@order_date", dtpOrderDate.Value);
cmd.Parameters.AddWithValue("@delivery_date", dtpDeliveryDate.Value);
cmd.Parameters.AddWithValue("@pickup_point_id", cmbPickupPoint.SelectedValue);
cmd.Parameters.AddWithValue("@user_id", cmbUser.SelectedValue);
cmd.Parameters.AddWithValue("@receive_code", txtReceiveCode.Text.Trim());
cmd.Parameters.AddWithValue("@status_id", cmbStatus.SelectedValue);
cmd.Parameters.AddWithValue("@id", _orderId);
cmd.ExecuteNonQuery();
}
MessageBox.Show("Заказ успешно обновлён.", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
}
}

120
EditOrder.resx Normal file
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>

285
EditProduct.Designer.cs generated Normal file
View File

@ -0,0 +1,285 @@
namespace NeshinaPolina07_11
{
partial class EditProduct
{
/// <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.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.textBox5 = new System.Windows.Forms.TextBox();
this.textBox6 = new System.Windows.Forms.TextBox();
this.cmbCategory = new System.Windows.Forms.ComboBox();
this.cmbManufacturer = new System.Windows.Forms.ComboBox();
this.cmbSupplier = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(149, 79);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(219, 20);
this.textBox1.TabIndex = 0;
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(149, 106);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(219, 20);
this.textBox2.TabIndex = 1;
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(149, 133);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(219, 20);
this.textBox3.TabIndex = 2;
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(149, 160);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(219, 20);
this.textBox4.TabIndex = 3;
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(149, 187);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(219, 20);
this.textBox5.TabIndex = 4;
//
// textBox6
//
this.textBox6.Location = new System.Drawing.Point(149, 214);
this.textBox6.Name = "textBox6";
this.textBox6.Size = new System.Drawing.Size(219, 20);
this.textBox6.TabIndex = 5;
//
// cmbCategory
//
this.cmbCategory.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbCategory.FormattingEnabled = true;
this.cmbCategory.Location = new System.Drawing.Point(149, 241);
this.cmbCategory.Name = "cmbCategory";
this.cmbCategory.Size = new System.Drawing.Size(219, 21);
this.cmbCategory.TabIndex = 6;
//
// cmbManufacturer
//
this.cmbManufacturer.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbManufacturer.FormattingEnabled = true;
this.cmbManufacturer.Location = new System.Drawing.Point(149, 269);
this.cmbManufacturer.Name = "cmbManufacturer";
this.cmbManufacturer.Size = new System.Drawing.Size(219, 21);
this.cmbManufacturer.TabIndex = 7;
this.cmbManufacturer.SelectedIndexChanged += new System.EventHandler(this.cmbManufacturer_SelectedIndexChanged);
//
// cmbSupplier
//
this.cmbSupplier.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbSupplier.FormattingEnabled = true;
this.cmbSupplier.Location = new System.Drawing.Point(149, 297);
this.cmbSupplier.Name = "cmbSupplier";
this.cmbSupplier.Size = new System.Drawing.Size(219, 21);
this.cmbSupplier.TabIndex = 8;
this.cmbSupplier.SelectedIndexChanged += new System.EventHandler(this.cmbSupplier_SelectedIndexChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(23, 82);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(48, 13);
this.label1.TabIndex = 9;
this.label1.Text = "Артикул";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(23, 109);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(38, 13);
this.label2.TabIndex = 10;
this.label2.Text = "Товар";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(23, 136);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(33, 13);
this.label3.TabIndex = 11;
this.label3.Text = "Цена";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(23, 163);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(44, 13);
this.label4.TabIndex = 12;
this.label4.Text = "Скидка";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(23, 190);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(120, 13);
this.label5.TabIndex = 13;
this.label5.Text = "Количество на складе";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(23, 217);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(57, 13);
this.label6.TabIndex = 14;
this.label6.Text = "Описание";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(23, 244);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(60, 13);
this.label7.TabIndex = 15;
this.label7.Text = "Категория";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(23, 272);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(86, 13);
this.label8.TabIndex = 16;
this.label8.Text = "Производитель";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(26, 297);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(65, 13);
this.label9.TabIndex = 17;
this.label9.Text = "Поставщик";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.label10.Location = new System.Drawing.Point(51, 9);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(300, 39);
this.label10.TabIndex = 18;
this.label10.Text = "Редактирование";
//
// button1
//
this.button1.Location = new System.Drawing.Point(108, 330);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(178, 42);
this.button1.TabIndex = 19;
this.button1.Text = "Изменить";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// EditProduct
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.MediumSpringGreen;
this.ClientSize = new System.Drawing.Size(403, 384);
this.Controls.Add(this.button1);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.cmbSupplier);
this.Controls.Add(this.cmbManufacturer);
this.Controls.Add(this.cmbCategory);
this.Controls.Add(this.textBox6);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "EditProduct";
this.Text = "EditProduct";
this.Load += new System.EventHandler(this.EditProduct_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.TextBox textBox5;
private System.Windows.Forms.TextBox textBox6;
private System.Windows.Forms.ComboBox cmbCategory;
private System.Windows.Forms.ComboBox cmbManufacturer;
private System.Windows.Forms.ComboBox cmbSupplier;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Button button1;
}
}

184
EditProduct.cs Normal file
View File

@ -0,0 +1,184 @@
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace NeshinaPolina07_11
{
public partial class EditProduct : Form
{
private readonly int _productId;
private readonly MySqlConnection _connection;
public EditProduct(int productId)
{
InitializeComponent();
_productId = productId;
_connection = DB.GetInstance().GetConnection();
LoadComboBoxes();
LoadProductData();
}
private void LoadComboBoxes()
{
LoadComboBox("categories", "category_id", "category_name", cmbCategory);
LoadComboBox("manufacturers", "manufacturer_id", "manufacturer_name", cmbManufacturer);
LoadComboBox("suppliers", "supplier_id", "supplier_name", cmbSupplier);
}
private void LoadComboBox(string table, string idColumn, string nameColumn, System.Windows.Forms.ComboBox combo)
{
string query = $"SELECT {idColumn}, {nameColumn} FROM {table} ORDER BY {nameColumn}";
using (var cmd = new MySqlCommand(query, _connection))
using (var adapter = new MySqlDataAdapter(cmd))
{
var dt = new DataTable();
adapter.Fill(dt);
combo.DataSource = dt;
combo.DisplayMember = nameColumn;
combo.ValueMember = idColumn;
combo.SelectedIndex = -1;
}
}
private void LoadProductData()
{
string query = @"
SELECT
product_article, product_name, price, discount,
quantity_in_stock, description,
category_id, manufacturer_id, supplier_id
FROM products
WHERE product_id = @id";
using (var cmd = new MySqlCommand(query, _connection))
{
cmd.Parameters.AddWithValue("@id", _productId);
using (var reader = cmd.ExecuteReader())
{
if (reader.Read())
{
textBox1.Text = reader["product_article"].ToString();
textBox2.Text = reader["product_name"].ToString();
textBox3.Text = reader["price"].ToString();
textBox4.Text = reader["discount"].ToString();
textBox5.Text = reader["quantity_in_stock"].ToString();
textBox6.Text = reader["description"].ToString();
SetComboBoxValue(cmbCategory, reader["category_id"]);
SetComboBoxValue(cmbManufacturer, reader["manufacturer_id"]);
SetComboBoxValue(cmbSupplier, reader["supplier_id"]);
}
else
{
MessageBox.Show("Продукт не найден.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
DialogResult = DialogResult.Cancel;
Close();
}
}
}
}
private void SetComboBoxValue(System.Windows.Forms.ComboBox combo, object value)
{
if (value != DBNull.Value && combo.DataSource != null)
{
foreach (DataRowView row in combo.Items)
{
if (row[combo.ValueMember].Equals(value))
{
combo.SelectedItem = row;
return;
}
}
}
}
private void EditProduct_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (!decimal.TryParse(textBox3.Text, out decimal price) || price < 0)
{
MessageBox.Show("Цена должна быть числом >= 0.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!int.TryParse(textBox4.Text, out int discount) || discount < 0 || discount > 100)
{
MessageBox.Show("Скидка должна быть от 0 до 100%.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!int.TryParse(textBox5.Text, out int quantity) || quantity < 0)
{
MessageBox.Show("Количество должно быть целым числом >= 0.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string query = @"
UPDATE products
SET
product_article = @article,
product_name = @name,
unit = 'шт.', -- напрямую в запросе!
price = @price,
discount = @discount,
quantity_in_stock = @quantity,
description = @description,
category_id = @category_id,
manufacturer_id = @manufacturer_id,
supplier_id = @supplier_id
WHERE product_id = @id";
using (var cmd = new MySqlCommand(query, _connection))
{
cmd.Parameters.AddWithValue("@article", textBox1.Text);
cmd.Parameters.AddWithValue("@name", textBox2.Text);
cmd.Parameters.AddWithValue("@price", price);
cmd.Parameters.AddWithValue("@discount", discount);
cmd.Parameters.AddWithValue("@quantity", quantity);
cmd.Parameters.AddWithValue("@description", textBox6.Text);
cmd.Parameters.AddWithValue("@category_id", cmbCategory.SelectedValue ?? DBNull.Value);
cmd.Parameters.AddWithValue("@manufacturer_id", cmbManufacturer.SelectedValue ?? DBNull.Value);
cmd.Parameters.AddWithValue("@supplier_id", cmbSupplier.SelectedValue ?? DBNull.Value);
cmd.Parameters.AddWithValue("@id", _productId);
cmd.ExecuteNonQuery();
}
MessageBox.Show("Данные успешно обновлены.", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
private void cmbManufacturer_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void cmbSupplier_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}

120
EditProduct.resx Normal file
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>

141
Form1.Designer.cs generated Normal file
View File

@ -0,0 +1,141 @@
namespace NeshinaPolina07_11
{
partial class MainForm
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором форм Windows
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.BackColor = System.Drawing.Color.Chartreuse;
this.checkBox1.Checked = true;
this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox1.Location = new System.Drawing.Point(135, 225);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(114, 17);
this.checkBox1.TabIndex = 0;
this.checkBox1.Text = "Показать пароль";
this.checkBox1.UseVisualStyleBackColor = false;
this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
//
// button1
//
this.button1.BackColor = System.Drawing.Color.MediumSpringGreen;
this.button1.Location = new System.Drawing.Point(135, 196);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(130, 23);
this.button1.TabIndex = 1;
this.button1.Text = "Авторизоваться";
this.button1.UseVisualStyleBackColor = false;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(135, 107);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(130, 20);
this.textBox1.TabIndex = 2;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(135, 153);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(130, 20);
this.textBox2.TabIndex = 3;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(132, 91);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(38, 13);
this.label1.TabIndex = 4;
this.label1.Text = "Логин";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(132, 137);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(45, 13);
this.label2.TabIndex = 5;
this.label2.Text = "Пароль";
//
// label3
//
this.label3.AutoSize = true;
this.label3.BackColor = System.Drawing.Color.Chartreuse;
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.label3.Location = new System.Drawing.Point(90, 52);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(240, 39);
this.label3.TabIndex = 6;
this.label3.Text = "Авторизация";
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(401, 319);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.checkBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "MainForm";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
}
}

79
Form1.cs Normal file
View File

@ -0,0 +1,79 @@
using System;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace NeshinaPolina07_11
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
checkBox1.Checked = false;
this.Text = "Авторизация";
}
private void button1_Click(object sender, EventArgs e)
{
string login = textBox1.Text.Trim();
string password = textBox2.Text;
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{
MessageBox.Show("Введите логин и пароль!");
return;
}
var db = DB.GetInstance();
var connection = db.GetConnection();
string query = "SELECT role_id FROM users WHERE Login = @login AND password_hash = @password";
using (var command = new MySqlCommand(query, connection))
{
command.Parameters.AddWithValue("@login", login);
command.Parameters.AddWithValue("@password", password);
object result = command.ExecuteScalar();
if (result != null && int.TryParse(result.ToString(), out int roleId))
{
switch (roleId)
{
case 1:
new _1Menu().Show();
break;
case 2:
new _2Menu().Show();
break;
case 3:
new _3Menu().Show();
break;
case 4:
new _4Menu().Show();
break;
default:
MessageBox.Show("Неизвестная роль пользователя.");
return;
}
this.Hide();
}
else
{
MessageBox.Show("Неверный логин или пароль! Попробуйте ещё раз.");
}
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
textBox2.UseSystemPasswordChar = !checkBox1.Checked;
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}

120
Form1.resx Normal file
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>

169
NeshinaPolina07-11.csproj Normal file
View File

@ -0,0 +1,169 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A9C79E82-A542-4C77-A66F-8F08DF52FE2E}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>NeshinaPolina07_11</RootNamespace>
<AssemblyName>NeshinaPolina07-11</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MySql.Data, Version=8.0.16.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Desktop\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="4Menu.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="4Menu.Designer.cs">
<DependentUpon>4Menu.cs</DependentUpon>
</Compile>
<Compile Include="AddOrder.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="AddOrder.Designer.cs">
<DependentUpon>AddOrder.cs</DependentUpon>
</Compile>
<Compile Include="AddProduct.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="AddProduct.Designer.cs">
<DependentUpon>AddProduct.cs</DependentUpon>
</Compile>
<Compile Include="DB.cs" />
<Compile Include="EditOrder.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="EditOrder.Designer.cs">
<DependentUpon>EditOrder.cs</DependentUpon>
</Compile>
<Compile Include="EditProduct.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="EditProduct.Designer.cs">
<DependentUpon>EditProduct.cs</DependentUpon>
</Compile>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Regist.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Regist.Designer.cs">
<DependentUpon>Regist.cs</DependentUpon>
</Compile>
<Compile Include="_1Menu.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="_1Menu.Designer.cs">
<DependentUpon>_1Menu.cs</DependentUpon>
</Compile>
<Compile Include="_2Menu.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="_2Menu.Designer.cs">
<DependentUpon>_2Menu.cs</DependentUpon>
</Compile>
<Compile Include="_3Menu.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="_3Menu.Designer.cs">
<DependentUpon>_3Menu.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="4Menu.resx">
<DependentUpon>4Menu.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="AddOrder.resx">
<DependentUpon>AddOrder.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="AddProduct.resx">
<DependentUpon>AddProduct.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="EditOrder.resx">
<DependentUpon>EditOrder.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="EditProduct.resx">
<DependentUpon>EditProduct.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="Regist.resx">
<DependentUpon>Regist.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="_1Menu.resx">
<DependentUpon>_1Menu.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="_2Menu.resx">
<DependentUpon>_2Menu.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="_3Menu.resx">
<DependentUpon>_3Menu.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

22
Program.cs Normal file
View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace NeshinaPolina07_11
{
internal static class Program
{
/// <summary>
/// Главная точка входа для приложения.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанных со сборкой.
[assembly: AssemblyTitle("NeshinaPolina07-11")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NeshinaPolina07-11")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// COM, следует установить атрибут ComVisible в TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("a9c79e82-a542-4c77-a66f-8f08df52fe2e")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

71
Properties/Resources.Designer.cs generated Normal file
View File

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программным средством.
// Версия среды выполнения: 4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
// код создан повторно.
// </auto-generated>
//------------------------------------------------------------------------------
namespace NeshinaPolina07_11.Properties
{
/// <summary>
/// Класс ресурсов со строгим типом для поиска локализованных строк и пр.
/// </summary>
// Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder
// класс с помощью таких средств, как ResGen или Visual Studio.
// Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen
// с параметром /str или заново постройте свой VS-проект.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Возврат кэшированного экземпляра ResourceManager, используемого этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NeshinaPolina07_11.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Переопределяет свойство CurrentUICulture текущего потока для всех
/// подстановки ресурсов с помощью этого класса ресурсов со строгим типом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

117
Properties/Resources.resx Normal file
View File

@ -0,0 +1,117 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

30
Properties/Settings.Designer.cs generated Normal file
View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace NeshinaPolina07_11.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

99
Regist.Designer.cs generated Normal file
View File

@ -0,0 +1,99 @@
namespace NeshinaPolina07_11
{
partial class Regist
{
/// <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.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.textBox5 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(142, 149);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 0;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(142, 194);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 1;
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(142, 245);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(100, 20);
this.textBox3.TabIndex = 2;
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(142, 289);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(100, 20);
this.textBox4.TabIndex = 3;
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(142, 333);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(100, 20);
this.textBox5.TabIndex = 4;
//
// Regist
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Name = "Regist";
this.Text = "Regist";
this.Load += new System.EventHandler(this.Regist_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.TextBox textBox5;
}
}

25
Regist.cs Normal file
View File

@ -0,0 +1,25 @@
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 NeshinaPolina07_11
{
public partial class Regist : Form
{
public Regist()
{
InitializeComponent();
}
private void Regist_Load(object sender, EventArgs e)
{
}
}
}

120
Regist.resx Normal file
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>

270
_1Menu.Designer.cs generated Normal file
View File

@ -0,0 +1,270 @@
namespace NeshinaPolina07_11
{
partial class _1Menu
{
/// <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.dgvProducts = new System.Windows.Forms.DataGridView();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.txtSearch = new System.Windows.Forms.TextBox();
this.cmbSort = new System.Windows.Forms.ComboBox();
this.cmbSupplier = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.lblSort = new System.Windows.Forms.Label();
this.lblSupplier = new System.Windows.Forms.Label();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.button6 = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.товарыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.заказыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).BeginInit();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// dgvProducts
//
this.dgvProducts.AllowUserToAddRows = false;
this.dgvProducts.AllowUserToDeleteRows = false;
this.dgvProducts.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
this.dgvProducts.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.dgvProducts.BackgroundColor = System.Drawing.SystemColors.ButtonFace;
this.dgvProducts.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvProducts.Location = new System.Drawing.Point(4, 119);
this.dgvProducts.Name = "dgvProducts";
this.dgvProducts.ReadOnly = true;
this.dgvProducts.Size = new System.Drawing.Size(556, 290);
this.dgvProducts.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.label1.Location = new System.Drawing.Point(-2, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(144, 31);
this.label1.TabIndex = 1;
this.label1.Text = "Директор";
//
// button1
//
this.button1.Location = new System.Drawing.Point(13, 415);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 2;
this.button1.Text = "Назад";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// txtSearch
//
this.txtSearch.Location = new System.Drawing.Point(4, 93);
this.txtSearch.Name = "txtSearch";
this.txtSearch.Size = new System.Drawing.Size(569, 20);
this.txtSearch.TabIndex = 3;
this.txtSearch.TextChanged += new System.EventHandler(this.txtSearch_TextChanged);
//
// cmbSort
//
this.cmbSort.FormattingEnabled = true;
this.cmbSort.Location = new System.Drawing.Point(582, 135);
this.cmbSort.Name = "cmbSort";
this.cmbSort.Size = new System.Drawing.Size(194, 21);
this.cmbSort.TabIndex = 4;
this.cmbSort.SelectedIndexChanged += new System.EventHandler(this.cmbSort_SelectedIndexChanged_1);
//
// cmbSupplier
//
this.cmbSupplier.FormattingEnabled = true;
this.cmbSupplier.Location = new System.Drawing.Point(582, 177);
this.cmbSupplier.Name = "cmbSupplier";
this.cmbSupplier.Size = new System.Drawing.Size(194, 21);
this.cmbSupplier.TabIndex = 5;
this.cmbSupplier.SelectedIndexChanged += new System.EventHandler(this.cmbSupplier_SelectedIndexChanged);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(1, 77);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(39, 13);
this.label2.TabIndex = 6;
this.label2.Text = "Поиск";
//
// lblSort
//
this.lblSort.AutoSize = true;
this.lblSort.Location = new System.Drawing.Point(579, 119);
this.lblSort.Name = "lblSort";
this.lblSort.Size = new System.Drawing.Size(67, 13);
this.lblSort.TabIndex = 7;
this.lblSort.Text = "Сортировка";
//
// lblSupplier
//
this.lblSupplier.AutoSize = true;
this.lblSupplier.Location = new System.Drawing.Point(579, 161);
this.lblSupplier.Name = "lblSupplier";
this.lblSupplier.Size = new System.Drawing.Size(71, 13);
this.lblSupplier.TabIndex = 8;
this.lblSupplier.Text = "Фильтрация";
//
// button4
//
this.button4.Location = new System.Drawing.Point(582, 254);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(194, 23);
this.button4.TabIndex = 11;
this.button4.Text = "Добавить";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button5
//
this.button5.Location = new System.Drawing.Point(582, 299);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(194, 23);
this.button5.TabIndex = 12;
this.button5.Text = "Редактировать";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.ForeColor = System.Drawing.SystemColors.AppWorkspace;
this.label3.Location = new System.Drawing.Point(579, 325);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(94, 13);
this.label3.TabIndex = 13;
this.label3.Text = "Выделите строку";
//
// button6
//
this.button6.Location = new System.Drawing.Point(582, 352);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(194, 23);
this.button6.TabIndex = 14;
this.button6.Text = "Удалить";
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.ForeColor = System.Drawing.SystemColors.AppWorkspace;
this.label4.Location = new System.Drawing.Point(579, 378);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(94, 13);
this.label4.TabIndex = 15;
this.label4.Text = "Выделите строку";
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.товарыToolStripMenuItem,
this.заказыToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(800, 24);
this.menuStrip1.TabIndex = 16;
this.menuStrip1.Text = "menuStrip1";
//
// товарыToolStripMenuItem
//
this.товарыToolStripMenuItem.Name = оварыToolStripMenuItem";
this.товарыToolStripMenuItem.Size = new System.Drawing.Size(60, 20);
this.товарыToolStripMenuItem.Text = "Товары";
this.товарыToolStripMenuItem.Click += new System.EventHandler(this.товарыToolStripMenuItem_Click);
//
// заказыToolStripMenuItem
//
this.заказыToolStripMenuItem.Name = аказыToolStripMenuItem";
this.заказыToolStripMenuItem.Size = new System.Drawing.Size(58, 20);
this.заказыToolStripMenuItem.Text = "Заказы";
this.заказыToolStripMenuItem.Click += new System.EventHandler(this.заказыToolStripMenuItem_Click);
//
// _1Menu
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.MediumSpringGreen;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.label4);
this.Controls.Add(this.button6);
this.Controls.Add(this.label3);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.lblSupplier);
this.Controls.Add(this.lblSort);
this.Controls.Add(this.label2);
this.Controls.Add(this.cmbSupplier);
this.Controls.Add(this.cmbSort);
this.Controls.Add(this.txtSearch);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Controls.Add(this.dgvProducts);
this.Controls.Add(this.menuStrip1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MainMenuStrip = this.menuStrip1;
this.MaximizeBox = false;
this.Name = "_1Menu";
this.Text = "_1Menu";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this._1Menu_FormClosing);
this.Load += new System.EventHandler(this._1Menu_Load);
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).EndInit();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.DataGridView dgvProducts;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox txtSearch;
private System.Windows.Forms.ComboBox cmbSort;
private System.Windows.Forms.ComboBox cmbSupplier;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label lblSort;
private System.Windows.Forms.Label lblSupplier;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem товарыToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem заказыToolStripMenuItem;
}
}

609
_1Menu.cs Normal file
View File

@ -0,0 +1,609 @@
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace NeshinaPolina07_11
{
public partial class _1Menu : Form
{
private const string MODE_PRODUCTS = "PRODUCTS";
private const string MODE_ORDERS = "ORDERS";
private string currentMode = MODE_PRODUCTS;
public _1Menu()
{
InitializeComponent();
InitializeSortComboBox();
LoadSuppliers();
this.Text = "Администратор";
}
private void InitializeSortComboBox()
{
cmbSort.Items.Clear();
cmbSort.Items.Add("Без сортировки");
cmbSort.Items.Add("По возрастанию (остаток)");
cmbSort.Items.Add("По убыванию (остаток)");
cmbSort.SelectedIndex = 0;
}
private void LoadSuppliers()
{
cmbSupplier.Items.Clear();
cmbSupplier.Items.Add(new SupplierItem { Name = "Все поставщики", Id = -1 });
try
{
var db = DB.GetInstance();
var connection = db.GetConnection();
string query = "SELECT supplier_id, supplier_name FROM suppliers ORDER BY supplier_name";
using (MySqlCommand cmd = new MySqlCommand(query, connection))
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
int id = Convert.ToInt32(reader["supplier_id"]);
string name = reader["supplier_name"].ToString();
cmbSupplier.Items.Add(new SupplierItem { Id = id, Name = name });
}
}
}
catch (Exception ex)
{
MessageBox.Show("Ошибка загрузки поставщиков: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
cmbSupplier.DisplayMember = "Name";
cmbSupplier.ValueMember = "Id";
cmbSupplier.SelectedIndex = 0;
}
private class SupplierItem
{
public int Id { get; set; }
public string Name { get; set; }
public override string ToString() => Name;
}
private void _1Menu_Load(object sender, EventArgs e)
{
LoadData();
}
private void SwitchMode(string mode)
{
currentMode = mode;
if (mode == MODE_PRODUCTS)
{
lblSort.Visible = true;
cmbSort.Visible = true;
lblSupplier.Visible = true;
cmbSupplier.Visible = true;
LoadProductsData(txtSearch.Text, cmbSort.SelectedItem?.ToString() ?? "Без сортировки", GetSelectedSupplierId());
}
else if (mode == MODE_ORDERS)
{
lblSort.Visible = false;
cmbSort.Visible = false;
lblSupplier.Visible = false;
cmbSupplier.Visible = false;
LoadOrdersData(txtSearch.Text);
}
}
private void LoadProductsData(string searchQuery = "", string sortOption = "Без сортировки", int? supplierId = null)
{
try
{
var db = DB.GetInstance();
var connection = db.GetConnection();
string query = @"
SELECT
p.product_id,
p.product_article,
p.product_name,
p.unit,
p.price,
p.discount,
p.quantity_in_stock,
p.description,
p.photo,
c.category_name AS category,
m.manufacturer_name AS manufacturer,
s.supplier_name AS supplier
FROM products p
LEFT JOIN categories c ON p.category_id = c.category_id
LEFT JOIN manufacturers m ON p.manufacturer_id = m.manufacturer_id
LEFT JOIN suppliers s ON p.supplier_id = s.supplier_id";
var conditions = new List<string>();
var parameters = new List<MySqlParameter>();
if (!string.IsNullOrWhiteSpace(searchQuery))
{
string searchPattern = "%" + searchQuery.Trim().ToLower() + "%";
conditions.Add(@"
LOWER(COALESCE(p.product_article, '')) LIKE @search OR
LOWER(COALESCE(p.product_name, '')) LIKE @search OR
LOWER(COALESCE(p.unit, '')) LIKE @search OR
LOWER(COALESCE(CAST(p.price AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(CAST(p.discount AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(CAST(p.quantity_in_stock AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(p.description, '')) LIKE @search OR
LOWER(COALESCE(p.photo, '')) LIKE @search OR
LOWER(COALESCE(c.category_name, '')) LIKE @search OR
LOWER(COALESCE(m.manufacturer_name, '')) LIKE @search OR
LOWER(COALESCE(s.supplier_name, '')) LIKE @search
");
parameters.Add(new MySqlParameter("@search", searchPattern));
}
if (supplierId.HasValue && supplierId.Value != -1)
{
conditions.Add("p.supplier_id = @supplierId");
parameters.Add(new MySqlParameter("@supplierId", supplierId.Value));
}
if (conditions.Count > 0)
{
query += " WHERE " + string.Join(" AND ", conditions);
}
switch (sortOption)
{
case "По возрастанию (остаток)":
query += " ORDER BY p.quantity_in_stock ASC";
break;
case "По убыванию (остаток)":
query += " ORDER BY p.quantity_in_stock DESC";
break;
}
using (MySqlCommand cmd = new MySqlCommand(query, connection))
{
cmd.Parameters.AddRange(parameters.ToArray());
using (MySqlDataAdapter adapter = new MySqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
adapter.Fill(dt);
dgvProducts.DataSource = dt;
}
}
dgvProducts.AutoResizeColumns();
}
catch (Exception ex)
{
MessageBox.Show("Ошибка загрузки данных о товарах: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadOrdersData(string searchQuery = "")
{
try
{
var db = DB.GetInstance();
var connection = db.GetConnection();
string query = @"
SELECT
o.order_id,
o.order_date,
o.delivery_date,
pp.address AS pickup_point, -- Вместо pickup_point_id
u.full_name AS user_name, -- Вместо user_id
o.receive_code,
os.status_name AS status -- Вместо status_id
FROM orders o
LEFT JOIN pickup_points pp ON o.pickup_point_id = pp.point_id
LEFT JOIN users u ON o.user_id = u.user_id
LEFT JOIN order_statuses os ON o.status_id = os.status_id";
var conditions = new List<string>();
var parameters = new List<MySqlParameter>();
if (!string.IsNullOrWhiteSpace(searchQuery))
{
string searchPattern = "%" + searchQuery.Trim().ToLower() + "%";
conditions.Add(@"
LOWER(COALESCE(CAST(o.order_id AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(CAST(o.order_date AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(CAST(o.delivery_date AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(pp.address, '')) LIKE @search OR -- Поиск по названию пункта выдачи
LOWER(COALESCE(u.full_name, '')) LIKE @search OR -- Поиск по имени пользователя
LOWER(COALESCE(o.receive_code, '')) LIKE @search OR
LOWER(COALESCE(os.status_name, '')) LIKE @search -- Поиск по названию статуса
");
parameters.Add(new MySqlParameter("@search", searchPattern));
}
if (conditions.Count > 0)
{
query += " WHERE " + string.Join(" AND ", conditions);
}
using (MySqlCommand cmd = new MySqlCommand(query, connection))
{
cmd.Parameters.AddRange(parameters.ToArray());
using (MySqlDataAdapter adapter = new MySqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
adapter.Fill(dt);
dgvProducts.DataSource = dt;
}
}
dgvProducts.AutoResizeColumns();
}
catch (Exception ex)
{
MessageBox.Show("Ошибка загрузки данных о заказах: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void PerformSearch()
{
if (currentMode == MODE_PRODUCTS)
{
LoadProductsData(txtSearch.Text, cmbSort.SelectedItem?.ToString() ?? "Без сортировки", GetSelectedSupplierId());
}
else if (currentMode == MODE_ORDERS)
{
LoadOrdersData(txtSearch.Text);
}
}
private void LoadData(string searchQuery = "", string sortOption = "Без сортировки", int? supplierId = null)
{
try
{
var db = DB.GetInstance();
var connection = db.GetConnection();
string query = @"
SELECT
p.product_id,
p.product_article,
p.product_name,
p.unit,
p.price,
p.discount,
p.quantity_in_stock,
p.description,
p.photo,
c.category_name AS category,
m.manufacturer_name AS manufacturer,
s.supplier_name AS supplier
FROM products p
LEFT JOIN categories c ON p.category_id = c.category_id
LEFT JOIN manufacturers m ON p.manufacturer_id = m.manufacturer_id
LEFT JOIN suppliers s ON p.supplier_id = s.supplier_id";
var conditions = new List<string>();
var parameters = new List<MySqlParameter>();
if (!string.IsNullOrWhiteSpace(searchQuery))
{
string searchPattern = "%" + searchQuery.Trim().ToLower() + "%";
conditions.Add(@"
LOWER(COALESCE(p.product_article, '')) LIKE @search OR
LOWER(COALESCE(p.product_name, '')) LIKE @search OR
LOWER(COALESCE(p.unit, '')) LIKE @search OR
LOWER(COALESCE(CAST(p.price AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(CAST(p.discount AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(CAST(p.quantity_in_stock AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(p.description, '')) LIKE @search OR
LOWER(COALESCE(p.photo, '')) LIKE @search OR
LOWER(COALESCE(c.category_name, '')) LIKE @search OR
LOWER(COALESCE(m.manufacturer_name, '')) LIKE @search OR
LOWER(COALESCE(s.supplier_name, '')) LIKE @search
");
parameters.Add(new MySqlParameter("@search", searchPattern));
}
if (supplierId.HasValue && supplierId.Value != -1)
{
conditions.Add("p.supplier_id = @supplierId");
parameters.Add(new MySqlParameter("@supplierId", supplierId.Value));
}
if (conditions.Count > 0)
{
query += " WHERE " + string.Join(" AND ", conditions);
}
switch (sortOption)
{
case "По возрастанию (остаток)":
query += " ORDER BY p.quantity_in_stock ASC";
break;
case "По убыванию (остаток)":
query += " ORDER BY p.quantity_in_stock DESC";
break;
}
using (MySqlCommand cmd = new MySqlCommand(query, connection))
{
cmd.Parameters.AddRange(parameters.ToArray());
using (MySqlDataAdapter adapter = new MySqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
adapter.Fill(dt);
dgvProducts.DataSource = dt;
}
}
dgvProducts.AutoResizeColumns();
}
catch (Exception ex)
{
MessageBox.Show("Ошибка загрузки данных: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button1_Click(object sender, EventArgs e)
{
MainForm form1 = new MainForm();
form1.Show();
this.Hide();
}
private void txtSearch_TextChanged(object sender, EventArgs e)
{
PerformSearch();
}
private void cmbSort_SelectedIndexChanged_1(object sender, EventArgs e)
{
if (currentMode == MODE_PRODUCTS)
{
LoadProductsData(txtSearch.Text, cmbSort.SelectedItem?.ToString() ?? "Без сортировки", GetSelectedSupplierId());
}
}
private void cmbSupplier_SelectedIndexChanged(object sender, EventArgs e)
{
if (currentMode == MODE_PRODUCTS)
{
int? supplierId = GetSelectedSupplierId();
string sort = cmbSort.SelectedItem?.ToString() ?? "Без сортировки";
LoadProductsData(txtSearch.Text, sort, supplierId);
}
}
private int? GetSelectedSupplierId()
{
if (cmbSupplier.SelectedItem is SupplierItem item)
{
return item.Id == -1 ? (int?)null : item.Id;
}
return null;
}
private void button2_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
}
//ДОБАВЛЕНИЕ
private void button4_Click(object sender, EventArgs e)
{
if (currentMode == MODE_PRODUCTS)
{
var addForm = new AddProduct(this);
addForm.ShowDialog();
}
else if (currentMode == MODE_ORDERS)
{
var addOrderForm = new AddOrder();
if (addOrderForm.ShowDialog() == DialogResult.OK)
{
LoadOrdersData(txtSearch.Text);
}
}
else
{
MessageBox.Show("Неизвестный режим.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
public void RefreshData()
{
if (currentMode == MODE_PRODUCTS)
{
PerformSearch();
}
else if (currentMode == MODE_ORDERS)
{
LoadOrdersData(txtSearch.Text);
}
}
//РЕДАКТИРОВАНИЕ
private void button5_Click(object sender, EventArgs e)
{
if (dgvProducts.SelectedRows.Count == 0)
{
MessageBox.Show("Пожалуйста, выберите запись для редактирования.", "Информация",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
var selectedRow = dgvProducts.SelectedRows[0];
if (currentMode == MODE_PRODUCTS)
{
if (selectedRow.Cells["product_id"].Value == null ||
!int.TryParse(selectedRow.Cells["product_id"].Value.ToString(), out int productId))
{
MessageBox.Show("Невозможно определить ID товара.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
using (var editForm = new EditProduct(productId))
{
if (editForm.ShowDialog() == DialogResult.OK)
{
LoadProductsData(txtSearch.Text, cmbSort.SelectedItem?.ToString() ?? "Без сортировки", GetSelectedSupplierId());
}
}
}
else if (currentMode == MODE_ORDERS)
{
if (selectedRow.Cells["order_id"].Value == null ||
!int.TryParse(selectedRow.Cells["order_id"].Value.ToString(), out int orderId))
{
MessageBox.Show("Невозможно определить ID заказа.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
using (var editForm = new EditOrder(orderId))
{
if (editForm.ShowDialog() == DialogResult.OK)
{
LoadOrdersData(txtSearch.Text);
}
}
}
}
private void button6_Click(object sender, EventArgs e)
{
if (dgvProducts.SelectedRows.Count == 0)
{
MessageBox.Show("Пожалуйста, выберите запись для удаления.", "Информация",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
var selectedRow = dgvProducts.SelectedRows[0];
if (currentMode == MODE_PRODUCTS)
{
if (selectedRow.Cells["product_id"].Value == null ||
!int.TryParse(selectedRow.Cells["product_id"].Value.ToString(), out int productId))
{
MessageBox.Show("Невозможно определить ID товара.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string productName = selectedRow.Cells["product_name"].Value?.ToString() ?? "неизвестный";
var result = MessageBox.Show(
$"Вы действительно хотите удалить товар \"{productName}\"?",
"Подтверждение удаления",
MessageBoxButtons.YesNo,
MessageBoxIcon.Warning);
if (result == DialogResult.Yes)
{
DeleteProduct(productId);
}
}
else if (currentMode == MODE_ORDERS)
{
if (selectedRow.Cells["order_id"].Value == null ||
!int.TryParse(selectedRow.Cells["order_id"].Value.ToString(), out int orderId))
{
MessageBox.Show("Невозможно определить ID заказа.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string orderInfo = $"заказ №{orderId}";
var result = MessageBox.Show(
$"Вы действительно хотите удалить {orderInfo}?",
"Подтверждение удаления",
MessageBoxButtons.YesNo,
MessageBoxIcon.Warning);
if (result == DialogResult.Yes)
{
DeleteOrder(orderId);
}
}
}
private void DeleteProduct(int productId)
{
try
{
var db = DB.GetInstance();
var connection = db.GetConnection();
using (var cmd = new MySqlCommand("DELETE FROM products WHERE product_id = @id", connection))
{
cmd.Parameters.AddWithValue("@id", productId);
int rows = cmd.ExecuteNonQuery();
if (rows > 0)
{
MessageBox.Show("Товар успешно удалён.", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
LoadProductsData(txtSearch.Text, cmbSort.SelectedItem?.ToString() ?? "Без сортировки", GetSelectedSupplierId());
}
else
{
MessageBox.Show("Товар не найден.", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
catch (Exception ex)
{
MessageBox.Show($"Ошибка при удалении товара: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void DeleteOrder(int orderId)
{
try
{
var db = DB.GetInstance();
var connection = db.GetConnection();
using (var cmd = new MySqlCommand("DELETE FROM orders WHERE order_id = @id", connection))
{
cmd.Parameters.AddWithValue("@id", orderId);
int rows = cmd.ExecuteNonQuery();
if (rows > 0)
{
MessageBox.Show("Заказ успешно удалён.", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
LoadOrdersData(txtSearch.Text);
}
else
{
MessageBox.Show("Заказ не найден.", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
catch (Exception ex)
{
MessageBox.Show($"Ошибка при удалении заказа: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void _1Menu_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Hide();
MainForm form1 = new MainForm();
form1.Show();
}
private void товарыToolStripMenuItem_Click(object sender, EventArgs e)
{
SwitchMode(MODE_PRODUCTS);
}
private void заказыToolStripMenuItem_Click(object sender, EventArgs e)
{
SwitchMode(MODE_ORDERS);
}
}
}

123
_1Menu.resx Normal file
View 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="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

193
_2Menu.Designer.cs generated Normal file
View File

@ -0,0 +1,193 @@
namespace NeshinaPolina07_11
{
partial class _2Menu
{
/// <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.label1 = new System.Windows.Forms.Label();
this.dgvProducts = new System.Windows.Forms.DataGridView();
this.txtSearch = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.cmbSort = new System.Windows.Forms.ComboBox();
this.cmbSupplier = new System.Windows.Forms.ComboBox();
this.lblSort = new System.Windows.Forms.Label();
this.lblSupplier = new System.Windows.Forms.Label();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.товарыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.заказыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).BeginInit();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.label1.Location = new System.Drawing.Point(12, 51);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(194, 39);
this.label1.TabIndex = 0;
this.label1.Text = "Менеджер";
//
// dgvProducts
//
this.dgvProducts.AllowUserToAddRows = false;
this.dgvProducts.AllowUserToDeleteRows = false;
this.dgvProducts.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
this.dgvProducts.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.dgvProducts.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight;
this.dgvProducts.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvProducts.Location = new System.Drawing.Point(19, 119);
this.dgvProducts.Name = "dgvProducts";
this.dgvProducts.ReadOnly = true;
this.dgvProducts.Size = new System.Drawing.Size(600, 290);
this.dgvProducts.TabIndex = 1;
this.dgvProducts.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
//
// txtSearch
//
this.txtSearch.Location = new System.Drawing.Point(19, 93);
this.txtSearch.Name = "txtSearch";
this.txtSearch.Size = new System.Drawing.Size(600, 20);
this.txtSearch.TabIndex = 2;
this.txtSearch.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// button2
//
this.button2.Location = new System.Drawing.Point(19, 415);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 4;
this.button2.Text = "Назад";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// cmbSort
//
this.cmbSort.FormattingEnabled = true;
this.cmbSort.Location = new System.Drawing.Point(625, 139);
this.cmbSort.Name = "cmbSort";
this.cmbSort.Size = new System.Drawing.Size(162, 21);
this.cmbSort.TabIndex = 6;
this.cmbSort.SelectedIndexChanged += new System.EventHandler(this.cmbSort_SelectedIndexChanged);
//
// cmbSupplier
//
this.cmbSupplier.FormattingEnabled = true;
this.cmbSupplier.Location = new System.Drawing.Point(625, 185);
this.cmbSupplier.Name = "cmbSupplier";
this.cmbSupplier.Size = new System.Drawing.Size(162, 21);
this.cmbSupplier.TabIndex = 7;
this.cmbSupplier.SelectedIndexChanged += new System.EventHandler(this.cmbSupplier_SelectedIndexChanged);
//
// lblSort
//
this.lblSort.AutoSize = true;
this.lblSort.Location = new System.Drawing.Point(625, 120);
this.lblSort.Name = "lblSort";
this.lblSort.Size = new System.Drawing.Size(67, 13);
this.lblSort.TabIndex = 8;
this.lblSort.Text = "Сортировка";
//
// lblSupplier
//
this.lblSupplier.AutoSize = true;
this.lblSupplier.Location = new System.Drawing.Point(625, 167);
this.lblSupplier.Name = "lblSupplier";
this.lblSupplier.Size = new System.Drawing.Size(71, 13);
this.lblSupplier.TabIndex = 9;
this.lblSupplier.Text = "Фильтрация";
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.товарыToolStripMenuItem,
this.заказыToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(800, 24);
this.menuStrip1.TabIndex = 17;
this.menuStrip1.Text = "menuStrip1";
//
// товарыToolStripMenuItem
//
this.товарыToolStripMenuItem.Name = оварыToolStripMenuItem";
this.товарыToolStripMenuItem.Size = new System.Drawing.Size(60, 20);
this.товарыToolStripMenuItem.Text = "Товары";
this.товарыToolStripMenuItem.Click += new System.EventHandler(this.товарыToolStripMenuItem_Click);
//
// заказыToolStripMenuItem
//
this.заказыToolStripMenuItem.Name = аказыToolStripMenuItem";
this.заказыToolStripMenuItem.Size = new System.Drawing.Size(58, 20);
this.заказыToolStripMenuItem.Text = "Заказы";
this.заказыToolStripMenuItem.Click += new System.EventHandler(this.заказыToolStripMenuItem_Click);
//
// _2Menu
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.MediumSpringGreen;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.menuStrip1);
this.Controls.Add(this.lblSupplier);
this.Controls.Add(this.lblSort);
this.Controls.Add(this.cmbSupplier);
this.Controls.Add(this.cmbSort);
this.Controls.Add(this.button2);
this.Controls.Add(this.txtSearch);
this.Controls.Add(this.dgvProducts);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "_2Menu";
this.Text = "_2Menu";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this._2Menu_FormClosing);
this.Load += new System.EventHandler(this._2Menu_Load);
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).EndInit();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.DataGridView dgvProducts;
private System.Windows.Forms.TextBox txtSearch;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.ComboBox cmbSort;
private System.Windows.Forms.ComboBox cmbSupplier;
private System.Windows.Forms.Label lblSort;
private System.Windows.Forms.Label lblSupplier;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem товарыToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem заказыToolStripMenuItem;
}
}

420
_2Menu.cs Normal file
View File

@ -0,0 +1,420 @@
using MySql.Data.MySqlClient;
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 NeshinaPolina07_11
{
public partial class _2Menu : Form
{
private const string MODE_PRODUCTS = "PRODUCTS";
private const string MODE_ORDERS = "ORDERS";
private string currentMode = MODE_PRODUCTS;
public _2Menu()
{
InitializeComponent();
InitializeSortComboBox();
LoadSuppliers();
this.Text = "Менеджер";
}
private void InitializeSortComboBox()
{
cmbSort.Items.Clear();
cmbSort.Items.Add("Без сортировки");
cmbSort.Items.Add("По возрастанию (остаток)");
cmbSort.Items.Add("По убыванию (остаток)");
cmbSort.SelectedIndex = 0;
}
private void LoadSuppliers()
{
cmbSupplier.Items.Clear();
cmbSupplier.Items.Add(new SupplierItem { Name = "Все поставщики", Id = -1 });
try
{
var db = DB.GetInstance();
var connection = db.GetConnection();
string query = "SELECT supplier_id, supplier_name FROM suppliers ORDER BY supplier_name";
using (MySqlCommand cmd = new MySqlCommand(query, connection))
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
int id = Convert.ToInt32(reader["supplier_id"]);
string name = reader["supplier_name"].ToString();
cmbSupplier.Items.Add(new SupplierItem { Id = id, Name = name });
}
}
}
catch (Exception ex)
{
MessageBox.Show("Ошибка загрузки поставщиков: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
cmbSupplier.DisplayMember = "Name";
cmbSupplier.ValueMember = "Id";
cmbSupplier.SelectedIndex = 0;
}
private class SupplierItem
{
public int Id { get; set; }
public string Name { get; set; }
public override string ToString() => Name;
}
private void SwitchMode(string mode)
{
currentMode = mode;
if (mode == MODE_PRODUCTS)
{
lblSort.Visible = true;
cmbSort.Visible = true;
lblSupplier.Visible = true;
cmbSupplier.Visible = true;
LoadProductsData(txtSearch.Text, cmbSort.SelectedItem?.ToString() ?? "Без сортировки", GetSelectedSupplierId());
}
else if (mode == MODE_ORDERS)
{
lblSort.Visible = false;
cmbSort.Visible = false;
lblSupplier.Visible = false;
cmbSupplier.Visible = false;
LoadOrdersData(txtSearch.Text);
}
}
private void LoadProductsData(string searchQuery = "", string sortOption = "Без сортировки", int? supplierId = null)
{
try
{
var db = DB.GetInstance();
var connection = db.GetConnection();
string query = @"
SELECT
p.product_id,
p.product_article,
p.product_name,
p.unit,
p.price,
p.discount,
p.quantity_in_stock,
p.description,
p.photo,
c.category_name AS category,
m.manufacturer_name AS manufacturer,
s.supplier_name AS supplier
FROM products p
LEFT JOIN categories c ON p.category_id = c.category_id
LEFT JOIN manufacturers m ON p.manufacturer_id = m.manufacturer_id
LEFT JOIN suppliers s ON p.supplier_id = s.supplier_id";
var conditions = new List<string>();
var parameters = new List<MySqlParameter>();
if (!string.IsNullOrWhiteSpace(searchQuery))
{
string searchPattern = "%" + searchQuery.Trim().ToLower() + "%";
conditions.Add(@"
LOWER(COALESCE(p.product_article, '')) LIKE @search OR
LOWER(COALESCE(p.product_name, '')) LIKE @search OR
LOWER(COALESCE(p.unit, '')) LIKE @search OR
LOWER(COALESCE(CAST(p.price AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(CAST(p.discount AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(CAST(p.quantity_in_stock AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(p.description, '')) LIKE @search OR
LOWER(COALESCE(p.photo, '')) LIKE @search OR
LOWER(COALESCE(c.category_name, '')) LIKE @search OR
LOWER(COALESCE(m.manufacturer_name, '')) LIKE @search OR
LOWER(COALESCE(s.supplier_name, '')) LIKE @search
");
parameters.Add(new MySqlParameter("@search", searchPattern));
}
if (supplierId.HasValue && supplierId.Value != -1)
{
conditions.Add("p.supplier_id = @supplierId");
parameters.Add(new MySqlParameter("@supplierId", supplierId.Value));
}
if (conditions.Count > 0)
{
query += " WHERE " + string.Join(" AND ", conditions);
}
switch (sortOption)
{
case "По возрастанию (остаток)":
query += " ORDER BY p.quantity_in_stock ASC";
break;
case "По убыванию (остаток)":
query += " ORDER BY p.quantity_in_stock DESC";
break;
}
using (MySqlCommand cmd = new MySqlCommand(query, connection))
{
cmd.Parameters.AddRange(parameters.ToArray());
using (MySqlDataAdapter adapter = new MySqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
adapter.Fill(dt);
dgvProducts.DataSource = dt;
}
}
dgvProducts.AutoResizeColumns();
}
catch (Exception ex)
{
MessageBox.Show("Ошибка загрузки данных о товарах: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadOrdersData(string searchQuery = "")
{
try
{
var db = DB.GetInstance();
var connection = db.GetConnection();
string query = @"
SELECT
o.order_id,
o.order_date,
o.delivery_date,
pp.address AS pickup_point, -- Вместо pickup_point_id
u.full_name AS user_name, -- Вместо user_id
o.receive_code,
os.status_name AS status -- Вместо status_id
FROM orders o
LEFT JOIN pickup_points pp ON o.pickup_point_id = pp.point_id
LEFT JOIN users u ON o.user_id = u.user_id
LEFT JOIN order_statuses os ON o.status_id = os.status_id";
var conditions = new List<string>();
var parameters = new List<MySqlParameter>();
if (!string.IsNullOrWhiteSpace(searchQuery))
{
string searchPattern = "%" + searchQuery.Trim().ToLower() + "%";
conditions.Add(@"
LOWER(COALESCE(CAST(o.order_id AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(CAST(o.order_date AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(CAST(o.delivery_date AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(pp.address, '')) LIKE @search OR -- Поиск по названию пункта выдачи
LOWER(COALESCE(u.full_name, '')) LIKE @search OR -- Поиск по имени пользователя
LOWER(COALESCE(o.receive_code, '')) LIKE @search OR
LOWER(COALESCE(os.status_name, '')) LIKE @search -- Поиск по названию статуса
");
parameters.Add(new MySqlParameter("@search", searchPattern));
}
if (conditions.Count > 0)
{
query += " WHERE " + string.Join(" AND ", conditions);
}
using (MySqlCommand cmd = new MySqlCommand(query, connection))
{
cmd.Parameters.AddRange(parameters.ToArray());
using (MySqlDataAdapter adapter = new MySqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
adapter.Fill(dt);
dgvProducts.DataSource = dt;
}
}
dgvProducts.AutoResizeColumns();
}
catch (Exception ex)
{
MessageBox.Show("Ошибка загрузки данных о заказах: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void PerformSearch()
{
if (currentMode == MODE_PRODUCTS)
{
LoadProductsData(txtSearch.Text, cmbSort.SelectedItem?.ToString() ?? "Без сортировки", GetSelectedSupplierId());
}
else if (currentMode == MODE_ORDERS)
{
LoadOrdersData(txtSearch.Text);
}
}
private void LoadData(string searchQuery = "", string sortOption = "Без сортировки", int? supplierId = null)
{
try
{
var db = DB.GetInstance();
var connection = db.GetConnection();
string query = @"
SELECT
p.product_id,
p.product_article,
p.product_name,
p.unit,
p.price,
p.discount,
p.quantity_in_stock,
p.description,
p.photo,
c.category_name AS category,
m.manufacturer_name AS manufacturer,
s.supplier_name AS supplier
FROM products p
LEFT JOIN categories c ON p.category_id = c.category_id
LEFT JOIN manufacturers m ON p.manufacturer_id = m.manufacturer_id
LEFT JOIN suppliers s ON p.supplier_id = s.supplier_id";
var conditions = new List<string>();
var parameters = new List<MySqlParameter>();
if (!string.IsNullOrWhiteSpace(searchQuery))
{
string searchPattern = "%" + searchQuery.Trim().ToLower() + "%";
conditions.Add(@"
LOWER(COALESCE(p.product_article, '')) LIKE @search OR
LOWER(COALESCE(p.product_name, '')) LIKE @search OR
LOWER(COALESCE(p.unit, '')) LIKE @search OR
LOWER(COALESCE(CAST(p.price AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(CAST(p.discount AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(CAST(p.quantity_in_stock AS CHAR), '')) LIKE @search OR
LOWER(COALESCE(p.description, '')) LIKE @search OR
LOWER(COALESCE(p.photo, '')) LIKE @search OR
LOWER(COALESCE(c.category_name, '')) LIKE @search OR
LOWER(COALESCE(m.manufacturer_name, '')) LIKE @search OR
LOWER(COALESCE(s.supplier_name, '')) LIKE @search
");
parameters.Add(new MySqlParameter("@search", searchPattern));
}
if (supplierId.HasValue && supplierId.Value != -1)
{
conditions.Add("p.supplier_id = @supplierId");
parameters.Add(new MySqlParameter("@supplierId", supplierId.Value));
}
if (conditions.Count > 0)
{
query += " WHERE " + string.Join(" AND ", conditions);
}
switch (sortOption)
{
case "По возрастанию (остаток)":
query += " ORDER BY p.quantity_in_stock ASC";
break;
case "По убыванию (остаток)":
query += " ORDER BY p.quantity_in_stock DESC";
break;
}
using (MySqlCommand cmd = new MySqlCommand(query, connection))
{
cmd.Parameters.AddRange(parameters.ToArray());
using (MySqlDataAdapter adapter = new MySqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
adapter.Fill(dt);
dgvProducts.DataSource = dt;
}
}
dgvProducts.AutoResizeColumns();
}
catch (Exception ex)
{
MessageBox.Show("Ошибка загрузки данных: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void _2Menu_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
MainForm form = new MainForm();
form.Show();
this.Hide();
}
private void button3_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
PerformSearch();
}
private void cmbSort_SelectedIndexChanged(object sender, EventArgs e)
{
if (currentMode == MODE_PRODUCTS)
{
LoadProductsData(txtSearch.Text, cmbSort.SelectedItem?.ToString() ?? "Без сортировки", GetSelectedSupplierId());
}
}
private void cmbSupplier_SelectedIndexChanged(object sender, EventArgs e)
{
if (currentMode == MODE_PRODUCTS)
{
int? supplierId = GetSelectedSupplierId();
string sort = cmbSort.SelectedItem?.ToString() ?? "Без сортировки";
LoadProductsData(txtSearch.Text, sort, supplierId);
}
}
private int? GetSelectedSupplierId()
{
if (cmbSupplier.SelectedItem is SupplierItem item)
{
return item.Id == -1 ? (int?)null : item.Id;
}
return null;
}
private void _2Menu_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Hide();
MainForm form1 = new MainForm();
form1.Show();
}
private void товарыToolStripMenuItem_Click(object sender, EventArgs e)
{
SwitchMode(MODE_ORDERS);
}
private void заказыToolStripMenuItem_Click(object sender, EventArgs e)
{
SwitchMode(MODE_PRODUCTS);
}
}
}

123
_2Menu.resx Normal file
View 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="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

99
_3Menu.Designer.cs generated Normal file
View File

@ -0,0 +1,99 @@
namespace NeshinaPolina07_11
{
partial class _3Menu
{
/// <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.label1 = new System.Windows.Forms.Label();
this.dgvProducts = new System.Windows.Forms.DataGridView();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.label1.Location = new System.Drawing.Point(13, 13);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(140, 39);
this.label1.TabIndex = 0;
this.label1.Text = "Клиент";
//
// dgvProducts
//
this.dgvProducts.AllowUserToAddRows = false;
this.dgvProducts.AllowUserToDeleteRows = false;
this.dgvProducts.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
this.dgvProducts.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
this.dgvProducts.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight;
this.dgvProducts.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvProducts.Location = new System.Drawing.Point(20, 82);
this.dgvProducts.Name = "dgvProducts";
this.dgvProducts.ReadOnly = true;
this.dgvProducts.Size = new System.Drawing.Size(553, 266);
this.dgvProducts.TabIndex = 1;
this.dgvProducts.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
//
// button1
//
this.button1.Location = new System.Drawing.Point(20, 415);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 2;
this.button1.Text = "Назад";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// _3Menu
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.MediumSpringGreen;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.button1);
this.Controls.Add(this.dgvProducts);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "_3Menu";
this.Text = "_3Menu";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this._3Menu_FormClosing);
this.Load += new System.EventHandler(this._3Menu_Load);
((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.DataGridView dgvProducts;
private System.Windows.Forms.Button button1;
}
}

85
_3Menu.cs Normal file
View File

@ -0,0 +1,85 @@
using MySql.Data.MySqlClient;
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 NeshinaPolina07_11
{
public partial class _3Menu : Form
{
public _3Menu()
{
InitializeComponent();
this.Text = "Пользователь";
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void _3Menu_Load(object sender, EventArgs e)
{
try
{
var db = DB.GetInstance();
var connection = db.GetConnection();
string query = @"
SELECT
p.product_id,
p.product_article,
p.product_name,
p.unit,
p.price,
p.discount,
p.quantity_in_stock,
p.description,
p.photo,
c.category_name AS category,
m.manufacturer_name AS manufacturer,
s.supplier_name AS supplier
FROM products p
LEFT JOIN categories c ON p.category_id = c.category_id
LEFT JOIN manufacturers m ON p.manufacturer_id = m.manufacturer_id
LEFT JOIN suppliers s ON p.supplier_id = s.supplier_id;";
using (MySqlCommand cmd = new MySqlCommand(query, connection))
using (MySqlDataAdapter adapter = new MySqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
adapter.Fill(dt);
dgvProducts.DataSource = dt;
}
dgvProducts.AutoResizeColumns();
}
catch (Exception ex)
{
MessageBox.Show("Ошибка загрузки данных: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button1_Click(object sender, EventArgs e)
{
MainForm form = new MainForm();
form.Show();
this.Hide();
}
private void _3Menu_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Hide();
MainForm form1 = new MainForm();
form1.Show();
}
}
}

120
_3Menu.resx Normal file
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>

BIN
bin/Debug/MySql.Data.dll Normal file

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

Binary file not shown.

View File

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]

Binary file not shown.

View File

@ -0,0 +1 @@
f85dbe7d7753b928204b8bee061e4d9ef1cbc2b218614edb54404b32f250e8d6

View File

@ -0,0 +1,21 @@
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07-11.csproj.AssemblyReference.cache
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07_11.Properties.Resources.resources
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07-11.csproj.GenerateResource.cache
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07-11.csproj.CoreCompileInputs.cache
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\bin\Debug\NeshinaPolina07-11.exe.config
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\bin\Debug\NeshinaPolina07-11.exe
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\bin\Debug\NeshinaPolina07-11.pdb
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\bin\Debug\MySql.Data.dll
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07-11.csproj.CopyComplete
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07-11.exe
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07-11.pdb
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07_11.Regist.resources
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07_11._1Menu.resources
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07_11._2Menu.resources
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07_11._3Menu.resources
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07_11.AddProduct.resources
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07_11.EditProduct.resources
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07_11.AddOrder.resources
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07_11.EditOrder.resources
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07_11._4Menu.resources
C:\Users\Student\Downloads\Модуль\АвтоМастер\NeshinaPolina07-11\NeshinaPolina07-11\obj\Debug\NeshinaPolina07_11.MainForm.resources

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.