#1.3
This commit is contained in:
parent
ee8e367a5c
commit
83a76cf83e
@ -11,16 +11,14 @@ public class Factory
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string FactoryName { get; private set; } = string.Empty;
|
||||
public string LastName { get; private set; } = string.Empty;
|
||||
public Manufacturer Manufacturer { get; private set; }
|
||||
public static Factory CreateEntity(int id, string factoryName, string last,
|
||||
public static Factory CreateEntity(int id, string factoryName,
|
||||
Manufacturer manufacturer)
|
||||
{
|
||||
return new Factory
|
||||
{
|
||||
Id = id,
|
||||
FactoryName = factoryName ?? string.Empty,
|
||||
LastName = last ?? string.Empty,
|
||||
Manufacturer = manufacturer
|
||||
};
|
||||
}
|
||||
|
39
ShoeStore/ShoeStore/Forms/Form1.Designer.cs
generated
39
ShoeStore/ShoeStore/Forms/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
||||
namespace ShoeStore.Forms
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <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.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
118
ShoeStore/ShoeStore/Forms/FormFactory.Designer.cs
generated
Normal file
118
ShoeStore/ShoeStore/Forms/FormFactory.Designer.cs
generated
Normal file
@ -0,0 +1,118 @@
|
||||
namespace ShoeStore.Forms
|
||||
{
|
||||
partial class FormFactory
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
comboBox1 = new ComboBox();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
textBox1 = new TextBox();
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// comboBox1
|
||||
//
|
||||
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBox1.FormattingEnabled = true;
|
||||
comboBox1.Location = new Point(74, 79);
|
||||
comboBox1.Name = "comboBox1";
|
||||
comboBox1.Size = new Size(182, 23);
|
||||
comboBox1.TabIndex = 0;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(22, 29);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(59, 15);
|
||||
label1.TabIndex = 1;
|
||||
label1.Text = "Название";
|
||||
label1.Click += label1_Click;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(22, 82);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(46, 15);
|
||||
label2.TabIndex = 2;
|
||||
label2.Text = "Страна";
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
textBox1.Location = new Point(87, 26);
|
||||
textBox1.Name = "textBox1";
|
||||
textBox1.Size = new Size(169, 23);
|
||||
textBox1.TabIndex = 3;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(22, 140);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(102, 23);
|
||||
button1.TabIndex = 4;
|
||||
button1.Text = "Сохранить";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(158, 140);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(98, 23);
|
||||
button2.TabIndex = 5;
|
||||
button2.Text = "Отмена";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormFactory
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(280, 199);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(textBox1);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(comboBox1);
|
||||
Name = "FormFactory";
|
||||
Text = "FormFactory";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox comboBox1;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private TextBox textBox1;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
}
|
||||
}
|
@ -10,11 +10,16 @@ using System.Windows.Forms;
|
||||
|
||||
namespace ShoeStore.Forms
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
public partial class FormFactory : Form
|
||||
{
|
||||
public Form1()
|
||||
public FormFactory()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void label1_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
138
ShoeStore/ShoeStore/Forms/FormStore.Designer.cs
generated
138
ShoeStore/ShoeStore/Forms/FormStore.Designer.cs
generated
@ -28,19 +28,153 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
textBoxStoreType = new TextBox();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
textBoxStoreName = new TextBox();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
numericUpDownEmployees = new NumericUpDown();
|
||||
label5 = new Label();
|
||||
numericUpDownVisitors = new NumericUpDown();
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownEmployees).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownVisitors).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// textBoxStoreType
|
||||
//
|
||||
textBoxStoreType.Location = new Point(161, 47);
|
||||
textBoxStoreType.Name = "textBoxStoreType";
|
||||
textBoxStoreType.Size = new Size(178, 23);
|
||||
textBoxStoreType.TabIndex = 0;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(39, 50);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(84, 15);
|
||||
label1.TabIndex = 1;
|
||||
label1.Text = "Тип магазина:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(39, 94);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(116, 15);
|
||||
label2.TabIndex = 2;
|
||||
label2.Text = "Название магазина:";
|
||||
//
|
||||
// textBoxStoreName
|
||||
//
|
||||
textBoxStoreName.Location = new Point(161, 91);
|
||||
textBoxStoreName.Name = "textBoxStoreName";
|
||||
textBoxStoreName.Size = new Size(178, 23);
|
||||
textBoxStoreName.TabIndex = 3;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(39, 137);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(0, 15);
|
||||
label3.TabIndex = 4;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(39, 152);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(148, 15);
|
||||
label4.TabIndex = 6;
|
||||
label4.Text = "Количество сотрудников:";
|
||||
//
|
||||
// numericUpDownEmployees
|
||||
//
|
||||
numericUpDownEmployees.Location = new Point(193, 150);
|
||||
numericUpDownEmployees.Maximum = new decimal(new int[] { 20, 0, 0, 0 });
|
||||
numericUpDownEmployees.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
numericUpDownEmployees.Name = "numericUpDownEmployees";
|
||||
numericUpDownEmployees.Size = new Size(60, 23);
|
||||
numericUpDownEmployees.TabIndex = 7;
|
||||
numericUpDownEmployees.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.Location = new Point(39, 191);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(147, 15);
|
||||
label5.TabIndex = 8;
|
||||
label5.Text = "Количество посетителей:";
|
||||
//
|
||||
// numericUpDownVisitors
|
||||
//
|
||||
numericUpDownVisitors.Location = new Point(193, 189);
|
||||
numericUpDownVisitors.Maximum = new decimal(new int[] { 30, 0, 0, 0 });
|
||||
numericUpDownVisitors.Name = "numericUpDownVisitors";
|
||||
numericUpDownVisitors.Size = new Size(60, 23);
|
||||
numericUpDownVisitors.TabIndex = 9;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(39, 234);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(125, 23);
|
||||
button1.TabIndex = 10;
|
||||
button1.Text = "Сохраить";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(214, 234);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(125, 23);
|
||||
button2.TabIndex = 11;
|
||||
button2.Text = "Отмена";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormStore
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
ClientSize = new Size(392, 304);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(numericUpDownVisitors);
|
||||
Controls.Add(label5);
|
||||
Controls.Add(numericUpDownEmployees);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(textBoxStoreName);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(textBoxStoreType);
|
||||
Name = "FormStore";
|
||||
Text = "FormStore";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Магазин";
|
||||
Load += FormStore_Load;
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownEmployees).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownVisitors).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TextBox textBoxStoreType;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private TextBox textBoxStoreName;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private NumericUpDown numericUpDownEmployees;
|
||||
private Label label5;
|
||||
private NumericUpDown numericUpDownVisitors;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using ShoeStore.Forms;
|
||||
using ShoeStore.Entities;
|
||||
using ShoeStore.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -9,79 +10,78 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShoeStore.Forms
|
||||
namespace ShoeStore.Forms;
|
||||
|
||||
public partial class FormStore : Form
|
||||
{
|
||||
public partial class FormStore : Form
|
||||
private readonly IStoreRepository _storeRepository;
|
||||
private int? _storeId;
|
||||
public int Id
|
||||
{
|
||||
private readonly IStoreRepository _storeRepository;
|
||||
private int? _storeId;
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var store =
|
||||
_storeRepository.ReadStoreById(value);
|
||||
if (store == null)
|
||||
{
|
||||
|
||||
|
||||
|
||||
throw new InvalidDataException(nameof(store));
|
||||
}
|
||||
textBoxAnimalSpecies.Text = store.AnimalSpecies;
|
||||
textBoxAnimalNickName.Text =
|
||||
store.AnimalNickName;
|
||||
numericUpDownAge.Value = store.Age;
|
||||
numericUpDownWeight.Value =
|
||||
(decimal)store.Weight;
|
||||
_storeId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public FormAnimal(IAnimalRepository storeRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_storeRepository = storeRepository ??
|
||||
throw new
|
||||
ArgumentNullException(nameof(storeRepository));
|
||||
}
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxAnimalSpecies.Text) || string.IsNullOrWhiteSpace(textBoxAnimalNickName.Text))
|
||||
var store = _storeRepository.ReadStoreById(value);
|
||||
if (store == null)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
throw new InvalidDataException(nameof(store));
|
||||
}
|
||||
if (_storeId.HasValue)
|
||||
{
|
||||
_storeRepository.UpdateAnimal(CreateAnimal(_storeId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_storeRepository.CreateAnimal(CreateAnimal(0));
|
||||
}
|
||||
Close();
|
||||
|
||||
textBoxStoreType.Text = store.StoreType;
|
||||
textBoxStoreName.Text = store.StoreName;
|
||||
numericUpDownEmployees.Value = store.Employees;
|
||||
numericUpDownVisitors.Value = (decimal)store.Visitors;
|
||||
_storeId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) =>
|
||||
Close();
|
||||
private Animal CreateAnimal(int id) => Animal.CreateEntity(id,
|
||||
textBoxAnimalSpecies.Text,
|
||||
textBoxAnimalNickName.Text,
|
||||
Convert.ToInt32(numericUpDownAge.Value),
|
||||
Convert.ToDouble(numericUpDownWeight.Value));
|
||||
}
|
||||
public FormStore(IStoreRepository storeRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_storeRepository = storeRepository ??
|
||||
throw new ArgumentNullException(nameof(storeRepository));
|
||||
}
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxStoreType.Text)
|
||||
||
|
||||
string.IsNullOrWhiteSpace(textBoxStoreName.Text))
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
if (_storeId.HasValue)
|
||||
{
|
||||
_storeRepository.UpdateStore(CreateStore(_storeId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_storeRepository.CreateStore(CreateStore(0));
|
||||
}
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
private Store CreateStore(int id) => Store.CreateEntity(id,
|
||||
textBoxStoreType.Text,
|
||||
textBoxStoreName.Text,
|
||||
Convert.ToInt32(numericUpDownEmployees.Value),
|
||||
Convert.ToDouble(numericUpDownVisitors.Value));
|
||||
|
||||
private void FormStore_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
123
ShoeStore/ShoeStore/Forms/FormStores.Designer.cs
generated
Normal file
123
ShoeStore/ShoeStore/Forms/FormStores.Designer.cs
generated
Normal file
@ -0,0 +1,123 @@
|
||||
namespace ShoeStore.Forms
|
||||
{
|
||||
partial class FormStores
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
panel1 = new Panel();
|
||||
button3 = new Button();
|
||||
button2 = new Button();
|
||||
button1 = new Button();
|
||||
dataGridViewData = new DataGridView();
|
||||
panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(button3);
|
||||
panel1.Controls.Add(button2);
|
||||
panel1.Controls.Add(button1);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(970, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(122, 450);
|
||||
panel1.TabIndex = 0;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.BackgroundImage = Properties.Resources.Gradelink_cross_1;
|
||||
button3.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
button3.Location = new Point(16, 193);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(85, 78);
|
||||
button3.TabIndex = 2;
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.BackgroundImage = Properties.Resources.Simpleicons_Business_pencil_striped_symbol_for_interface_edit_buttons_svg;
|
||||
button2.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
button2.Location = new Point(16, 110);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(85, 77);
|
||||
button2.TabIndex = 1;
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.BackgroundImage = Properties.Resources.Ambox_plus_svg;
|
||||
button1.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
button1.Location = new Point(16, 27);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(85, 77);
|
||||
button1.TabIndex = 0;
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// dataGridViewData
|
||||
//
|
||||
dataGridViewData.AllowUserToAddRows = false;
|
||||
dataGridViewData.AllowUserToResizeColumns = false;
|
||||
dataGridViewData.AllowUserToResizeRows = false;
|
||||
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewData.Dock = DockStyle.Fill;
|
||||
dataGridViewData.Location = new Point(0, 0);
|
||||
dataGridViewData.MultiSelect = false;
|
||||
dataGridViewData.Name = "dataGridViewData";
|
||||
dataGridViewData.ReadOnly = true;
|
||||
dataGridViewData.RowHeadersVisible = false;
|
||||
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewData.Size = new Size(970, 450);
|
||||
dataGridViewData.TabIndex = 1;
|
||||
dataGridViewData.CellContentClick += dataGridViewData_CellContentClick;
|
||||
//
|
||||
// FormStores
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1092, 450);
|
||||
Controls.Add(dataGridViewData);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormStores";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Магазины";
|
||||
Load += FormStores_Load;
|
||||
panel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel1;
|
||||
private Button button3;
|
||||
private Button button2;
|
||||
private Button button1;
|
||||
private DataGridView dataGridViewData;
|
||||
}
|
||||
}
|
118
ShoeStore/ShoeStore/Forms/FormStores.cs
Normal file
118
ShoeStore/ShoeStore/Forms/FormStores.cs
Normal file
@ -0,0 +1,118 @@
|
||||
using ShoeStore.Repositories;
|
||||
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 Unity;
|
||||
|
||||
namespace ShoeStore.Forms
|
||||
{
|
||||
public partial class FormStores : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IStoreRepository _storeRepository;
|
||||
public FormStores(IUnityContainer container, IStoreRepository
|
||||
storeRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
_storeRepository = storeRepository ??
|
||||
throw new
|
||||
ArgumentNullException(nameof(storeRepository));
|
||||
}
|
||||
private void FormStores_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormStore>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
var form = _container.Resolve<FormStore>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ButtonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить запись?", "Удаление",
|
||||
MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
_storeRepository.DeleteStore(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() => dataGridViewData.DataSource =
|
||||
_storeRepository.ReadStores();
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridViewData.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id =
|
||||
Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void dataGridViewData_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
120
ShoeStore/ShoeStore/Forms/FormStores.resx
Normal file
120
ShoeStore/ShoeStore/Forms/FormStores.resx
Normal 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>
|
50
ShoeStore/ShoeStore/Properties/Resources.Designer.cs
generated
50
ShoeStore/ShoeStore/Properties/Resources.Designer.cs
generated
@ -60,6 +60,36 @@ namespace ShoeStore.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap _862518 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("862518", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap _8625181 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("8625181", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Ambox_plus_svg {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Ambox_plus.svg", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
@ -69,5 +99,25 @@ namespace ShoeStore.Properties {
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Gradelink_cross_1 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Gradelink-cross-1", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Simpleicons_Business_pencil_striped_symbol_for_interface_edit_buttons_svg {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Simpleicons_Business_pencil-striped-symbol-for-interface-edit-buttons.svg", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,4 +121,19 @@
|
||||
<data name="fb3882d00f3138e7a504134cff73630f" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\fb3882d00f3138e7a504134cff73630f.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="862518" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\862518.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Gradelink-cross-1" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Gradelink-cross-1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Ambox_plus.svg" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Ambox_plus.svg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="8625181" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\8625181.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Simpleicons_Business_pencil-striped-symbol-for-interface-edit-buttons.svg" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Simpleicons_Business_pencil-striped-symbol-for-interface-edit-buttons.svg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
ShoeStore/ShoeStore/Resources/862518.png
Normal file
BIN
ShoeStore/ShoeStore/Resources/862518.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
BIN
ShoeStore/ShoeStore/Resources/8625181.png
Normal file
BIN
ShoeStore/ShoeStore/Resources/8625181.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
BIN
ShoeStore/ShoeStore/Resources/Ambox_plus.svg.png
Normal file
BIN
ShoeStore/ShoeStore/Resources/Ambox_plus.svg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 73 KiB |
BIN
ShoeStore/ShoeStore/Resources/Gradelink-cross-1.png
Normal file
BIN
ShoeStore/ShoeStore/Resources/Gradelink-cross-1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Loading…
Reference in New Issue
Block a user