готовая лаба 1

This commit is contained in:
Алексей Крюков 2024-02-27 21:55:35 +04:00
parent 7a8a3451f3
commit e8047232f6
8 changed files with 407 additions and 74 deletions

View File

@ -1,4 +1,4 @@
namespace PrintedBarView
namespace TypographyView
{
partial class FormMakeShipment
{
@ -30,7 +30,7 @@
{
labelShop = new Label();
labelPrinted = new Label();
label1 = new Label();
labelCount = new Label();
comboBoxShop = new ComboBox();
comboBoxPrinted = new ComboBox();
textBoxCount = new TextBox();
@ -41,58 +41,58 @@
// labelShop
//
labelShop.AutoSize = true;
labelShop.Location = new Point(12, 9);
labelShop.Location = new Point(12, 22);
labelShop.Name = "labelShop";
labelShop.Size = new Size(72, 20);
labelShop.Size = new Size(76, 20);
labelShop.TabIndex = 0;
labelShop.Text = "Магазин:";
labelShop.Text = "Магазин :";
//
// labelPrinted
//
labelPrinted.AutoSize = true;
labelPrinted.Location = new Point(12, 45);
labelPrinted.Location = new Point(12, 57);
labelPrinted.Name = "labelPrinted";
labelPrinted.Size = new Size(65, 20);
labelPrinted.Size = new Size(75, 20);
labelPrinted.TabIndex = 1;
labelPrinted.Text = "Закуски:";
labelPrinted.Text = "Изделие :";
//
// label1
// labelCount
//
label1.AutoSize = true;
label1.Location = new Point(12, 84);
label1.Name = "label1";
label1.Size = new Size(93, 20);
label1.TabIndex = 2;
label1.Text = "Количество:";
labelCount.AutoSize = true;
labelCount.Location = new Point(12, 96);
labelCount.Name = "labelCount";
labelCount.Size = new Size(97, 20);
labelCount.TabIndex = 2;
labelCount.Text = "Количество :";
//
// comboBoxShop
//
comboBoxShop.FormattingEnabled = true;
comboBoxShop.Location = new Point(111, 6);
comboBoxShop.Location = new Point(116, 19);
comboBoxShop.Name = "comboBoxShop";
comboBoxShop.Size = new Size(252, 28);
comboBoxShop.Size = new Size(247, 28);
comboBoxShop.TabIndex = 3;
//
// comboBoxPrinted
//
comboBoxPrinted.FormattingEnabled = true;
comboBoxPrinted.Location = new Point(111, 45);
comboBoxPrinted.Location = new Point(116, 54);
comboBoxPrinted.Name = "comboBoxPrinted";
comboBoxPrinted.Size = new Size(252, 28);
comboBoxPrinted.Size = new Size(247, 28);
comboBoxPrinted.TabIndex = 4;
//
// textBoxCount
//
textBoxCount.Location = new Point(111, 84);
textBoxCount.Location = new Point(116, 93);
textBoxCount.Name = "textBoxCount";
textBoxCount.Size = new Size(252, 27);
textBoxCount.Size = new Size(247, 27);
textBoxCount.TabIndex = 5;
//
// buttonSave
//
buttonSave.Location = new Point(111, 133);
buttonSave.Location = new Point(116, 126);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(104, 37);
buttonSave.Size = new Size(102, 43);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
@ -100,28 +100,28 @@
//
// buttonCancel
//
buttonCancel.Location = new Point(221, 133);
buttonCancel.Location = new Point(261, 126);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(110, 37);
buttonCancel.Size = new Size(102, 43);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FromMakeShipment
// FormMakeShipment
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(386, 182);
ClientSize = new Size(431, 206);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxCount);
Controls.Add(comboBoxPrinted);
Controls.Add(comboBoxShop);
Controls.Add(label1);
Controls.Add(labelCount);
Controls.Add(labelPrinted);
Controls.Add(labelShop);
Name = "FromMakeShipment";
Name = "FormMakeShipment";
Text = "Пополнение магазина";
Load += FormMakeShipment_Load;
ResumeLayout(false);
@ -132,7 +132,7 @@
private Label labelShop;
private Label labelPrinted;
private Label label1;
private Label labelCount;
private ComboBox comboBoxShop;
private ComboBox comboBoxPrinted;
private TextBox textBoxCount;

View File

@ -10,6 +10,8 @@ using System.Windows.Forms;
using TypographyContracts.BusinessLogicsContracts;
using TypographyContracts.SearchModels;
using Microsoft.Extensions.Logging;
using TypographyContracts.BusinessLogicsContracts;
using TypographyContracts.SearchModels;
namespace TypographyView
{
@ -120,4 +122,4 @@ namespace TypographyView
Close();
}
}
}
}

View File

@ -28,12 +28,172 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "FormShop";
labelName = new Label();
labelAddress = new Label();
labelOpeningDate = new Label();
textBoxName = new TextBox();
textBoxAddress = new TextBox();
dateTimePicker = new DateTimePicker();
groupBoxPrinted = new GroupBox();
dataGridView = new DataGridView();
buttonSave = new Button();
buttonCancel = new Button();
Columnid = new DataGridViewTextBoxColumn();
ColumnPrinted = new DataGridViewTextBoxColumn();
ColumnCount = new DataGridViewTextBoxColumn();
groupBoxPrinted.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(12, 23);
labelName.Name = "labelName";
labelName.Size = new Size(84, 20);
labelName.TabIndex = 0;
labelName.Text = "Название :";
//
// labelAddress
//
labelAddress.AutoSize = true;
labelAddress.Location = new Point(12, 59);
labelAddress.Name = "labelAddress";
labelAddress.Size = new Size(58, 20);
labelAddress.TabIndex = 1;
labelAddress.Text = "Адрес :";
//
// labelOpeningDate
//
labelOpeningDate.AutoSize = true;
labelOpeningDate.Location = new Point(12, 96);
labelOpeningDate.Name = "labelOpeningDate";
labelOpeningDate.Size = new Size(117, 20);
labelOpeningDate.TabIndex = 2;
labelOpeningDate.Text = "Дата открытия :";
//
// textBoxName
//
textBoxName.Location = new Point(135, 20);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(250, 27);
textBoxName.TabIndex = 3;
//
// textBoxAddress
//
textBoxAddress.Location = new Point(135, 56);
textBoxAddress.Name = "textBoxAddress";
textBoxAddress.Size = new Size(250, 27);
textBoxAddress.TabIndex = 4;
//
// dateTimePicker
//
dateTimePicker.Location = new Point(135, 96);
dateTimePicker.Name = "dateTimePicker";
dateTimePicker.Size = new Size(250, 27);
dateTimePicker.TabIndex = 6;
//
// groupBoxPrinted
//
groupBoxPrinted.Controls.Add(dataGridView);
groupBoxPrinted.Location = new Point(12, 129);
groupBoxPrinted.Name = "groupBoxPrinted";
groupBoxPrinted.Size = new Size(598, 292);
groupBoxPrinted.TabIndex = 7;
groupBoxPrinted.TabStop = false;
groupBoxPrinted.Text = "Изделия";
//
// dataGridView
//
dataGridView.BackgroundColor = SystemColors.ControlLightLight;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { Columnid, ColumnPrinted, ColumnCount });
dataGridView.Location = new Point(0, 26);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
dataGridView.Size = new Size(592, 260);
dataGridView.TabIndex = 0;
//
// buttonSave
//
buttonSave.Location = new Point(330, 431);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(95, 34);
buttonSave.TabIndex = 8;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(449, 431);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(95, 34);
buttonCancel.TabIndex = 9;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// Columnid
//
Columnid.HeaderText = "Id";
Columnid.MinimumWidth = 6;
Columnid.Name = "Columnid";
Columnid.Visible = false;
Columnid.Width = 125;
//
// ColumnPrinted
//
ColumnPrinted.HeaderText = "Название изделия";
ColumnPrinted.MinimumWidth = 6;
ColumnPrinted.Name = "ColumnPrinted";
ColumnPrinted.Width = 410;
//
// ColumnCount
//
ColumnCount.HeaderText = "Количество";
ColumnCount.MinimumWidth = 6;
ColumnCount.Name = "ColumnCount";
ColumnCount.Width = 125;
//
// FormShop
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(618, 477);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(groupBoxPrinted);
Controls.Add(dateTimePicker);
Controls.Add(textBoxAddress);
Controls.Add(textBoxName);
Controls.Add(labelOpeningDate);
Controls.Add(labelAddress);
Controls.Add(labelName);
Name = "FormShop";
Text = "Магазин";
Load += FormShop_Load;
groupBoxPrinted.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelName;
private Label labelAddress;
private Label labelOpeningDate;
private TextBox textBoxName;
private TextBox textBoxAddress;
private DateTimePicker dateTimePicker;
private GroupBox groupBoxPrinted;
private DataGridView dataGridView;
private Button buttonSave;
private Button buttonCancel;
private DataGridViewTextBoxColumn Columnid;
private DataGridViewTextBoxColumn ColumnPrinted;
private DataGridViewTextBoxColumn ColumnCount;
}
}

View File

@ -1,12 +1,8 @@
using Microsoft.Extensions.Logging;
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 TypographyContracts.BindingModels;
using TypographyContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using TypographyContracts.SearchModels;
using TypographyDataModels.Models;
using System.Windows.Forms;
using TypographyContracts.BindingModels;
using TypographyContracts.BusinessLogicsContracts;
@ -128,5 +124,4 @@ namespace TypographyView
Close();
}
}
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
@ -117,4 +117,13 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="Columnid.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnPrinted.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -28,18 +28,89 @@
/// </summary>
private void InitializeComponent()
{
dataGridView = new DataGridView();
buttonAdd = new Button();
buttonEdit = new Button();
buttonUpd = new Button();
buttonDel = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.BackgroundColor = SystemColors.ControlLightLight;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(1, 1);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
dataGridView.Size = new Size(503, 447);
dataGridView.TabIndex = 0;
//
// buttonAdd
//
buttonAdd.Location = new Point(543, 28);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(141, 45);
buttonAdd.TabIndex = 1;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// buttonEdit
//
buttonEdit.Location = new Point(543, 91);
buttonEdit.Name = "buttonEdit";
buttonEdit.Size = new Size(141, 45);
buttonEdit.TabIndex = 2;
buttonEdit.Text = "Изменить";
buttonEdit.UseVisualStyleBackColor = true;
buttonEdit.Click += ButtonEdit_Click;
//
// buttonUpd
//
buttonUpd.Location = new Point(543, 216);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(141, 45);
buttonUpd.TabIndex = 3;
buttonUpd.Text = "Обновить";
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
//
// buttonDel
//
buttonDel.Location = new Point(543, 156);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(141, 45);
buttonDel.TabIndex = 4;
buttonDel.Text = "Удалить";
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// FormShops
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
ClientSize = new Size(697, 450);
Controls.Add(buttonDel);
Controls.Add(buttonUpd);
Controls.Add(buttonEdit);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
Name = "FormShops";
Text = "Магазины";
Load += FormShops_Load;
Click += FormShops_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonAdd;
private Button buttonEdit;
private Button buttonUpd;
private Button buttonDel;
}
}

View File

@ -7,14 +7,107 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TypographyContracts.BindingModels;
using TypographyContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using TypographyView;
namespace TypographyView
{
public partial class FormShops : Form
{
public FormShops()
private readonly ILogger _logger;
private readonly IShopLogic _logic;
public FormShops(ILogger<FormShops> logger, IShopLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormShops_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["ShopPrinteds"].Visible = false;
}
_logger.LogInformation("Shops loading");
}
catch (Exception ex)
{
_logger.LogError(ex, "Shops loading error");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
if (service is FormShop form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonEdit_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
if (service is FormShop form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Deletion of shop");
try
{
if (!_logic.Delete(new ShopBindingModel { Id = id }))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Shop deletion error");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
LoadData();
}
}
}
}

View File

@ -52,6 +52,9 @@ namespace TypographyView
services.AddTransient<FormPrintedComponent>();
services.AddTransient<FormPrinteds>();
services.AddTransient<FormMakeShipment>();
services.AddTransient<FormShop>();
services.AddTransient<FormShops>();
}
}
}