diff --git a/OpticStore/OpticStore/Entities/Component.cs b/OpticStore/OpticStore/Entities/Component.cs new file mode 100644 index 0000000..be5bfe3 --- /dev/null +++ b/OpticStore/OpticStore/Entities/Component.cs @@ -0,0 +1,25 @@ +using OpticStore.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpticStore.Entities +{ + public class Component + { + public int Id { get; private set; } + public string ComponentName { get; private set; } = string.Empty; + public ComponentCategory ComponentCategory { get; private set; } + public static Component CreateEntity(int id, string componentName, ComponentCategory componentCategory) + { + return new Component + { + Id = id, + ComponentName = componentName ?? string.Empty, + ComponentCategory = componentCategory + }; + } + } +} diff --git a/OpticStore/OpticStore/Entities/Enums/ComponentCategory.cs b/OpticStore/OpticStore/Entities/Enums/ComponentCategory.cs new file mode 100644 index 0000000..392b6a0 --- /dev/null +++ b/OpticStore/OpticStore/Entities/Enums/ComponentCategory.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpticStore.Entities.Enums +{ + public enum ComponentCategory + { + none = 0, + lenses = 1, + Case = 2, + frames = 3 + } +} diff --git a/OpticStore/OpticStore/Entities/Enums/OrderStatus.cs b/OpticStore/OpticStore/Entities/Enums/OrderStatus.cs new file mode 100644 index 0000000..a618f40 --- /dev/null +++ b/OpticStore/OpticStore/Entities/Enums/OrderStatus.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpticStore.Entities.Enums +{ + public enum OrderStatus + { + none = 0, + completed = 1, + inProgress = 2, + } + +} diff --git a/OpticStore/OpticStore/Entities/Order.cs b/OpticStore/OpticStore/Entities/Order.cs new file mode 100644 index 0000000..9be2a21 --- /dev/null +++ b/OpticStore/OpticStore/Entities/Order.cs @@ -0,0 +1,31 @@ +using Microsoft.VisualBasic.FileIO; +using OpticStore.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpticStore.Entities +{ + public class Order + { + public int Id { get; private set; } + public int StoreId { get; private set; } + public DateTime OrderDate { get; private set; } + public OrderStatus OrderStatus { get; private set; } + public IEnumerable OrderComponent {get;private set;} = new List(); + public static Order CreateOperation(int id,int storeId,OrderStatus orderStatus, IEnumerable orderComponent) + { + return new Order + { + Id = id, + StoreId = storeId, + OrderDate = DateTime.Now, + OrderStatus = orderStatus, + OrderComponent = orderComponent + }; + } + } + +} diff --git a/OpticStore/OpticStore/Entities/OrderComponent.cs b/OpticStore/OpticStore/Entities/OrderComponent.cs new file mode 100644 index 0000000..e875e7a --- /dev/null +++ b/OpticStore/OpticStore/Entities/OrderComponent.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpticStore.Entities +{ + public class OrderComponent + { + public int Id { get; private set; } + public int ComponentId { get; private set; } + public int Count { get; private set; } + public static OrderComponent CreateElement(int id, int componentId,int count) + { + return new OrderComponent + { + Id = id, + ComponentId = componentId, + Count = count + }; + } + } + +} diff --git a/OpticStore/OpticStore/Entities/Shipment.cs b/OpticStore/OpticStore/Entities/Shipment.cs new file mode 100644 index 0000000..554788c --- /dev/null +++ b/OpticStore/OpticStore/Entities/Shipment.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpticStore.Entities +{ + public class Shipment + { + public int Id { get; private set; } + public int StoreId { get; private set; } + public DateTime ShipmentDate { get; private set; } + public int Amount { get; private set; } + public IEnumerable ShipmentComponent { get; private set; } = new List(); + public static Shipment CreateOperation(int id,int storeId, int amount, IEnumerable shipmentComponent) + { + return new Shipment + { + Id = id, + StoreId = storeId, + ShipmentDate=DateTime.Now, + Amount = amount, + ShipmentComponent = shipmentComponent + }; + } + } +} diff --git a/OpticStore/OpticStore/Entities/ShipmentComponent.cs b/OpticStore/OpticStore/Entities/ShipmentComponent.cs new file mode 100644 index 0000000..98915e9 --- /dev/null +++ b/OpticStore/OpticStore/Entities/ShipmentComponent.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpticStore.Entities +{ + public class ShipmentComponent + { + public int Id { get; private set; } + public int ComponentId { get; private set; } + public int Count { get; private set; } + public static ShipmentComponent CreateElement(int id, int componentId,int count) + { + return new ShipmentComponent + { + Id = id, + ComponentId = componentId, + Count = count + }; + } + } + +} diff --git a/OpticStore/OpticStore/Entities/Store.cs b/OpticStore/OpticStore/Entities/Store.cs new file mode 100644 index 0000000..db11a0f --- /dev/null +++ b/OpticStore/OpticStore/Entities/Store.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpticStore.Entities +{ + public class Store + { + public int Id { get; private set; } + public string storeName { get; private set; } = string.Empty; + public string storeAdress { get; private set; } = string.Empty; + public string phoneNumber { get; private set; } = string.Empty; + public static Store CreateEntity(int id, string name, string + adress, string phone) + { + return new Store + { + Id = id, + storeName = name ?? string.Empty, + storeAdress = adress ?? string.Empty, + phoneNumber = phone ?? string.Empty + }; + } + } +} diff --git a/OpticStore/OpticStore/Form1.Designer.cs b/OpticStore/OpticStore/Form1.Designer.cs index 7de316f..a4cd6a6 100644 --- a/OpticStore/OpticStore/Form1.Designer.cs +++ b/OpticStore/OpticStore/Form1.Designer.cs @@ -1,6 +1,6 @@ namespace OpticStore { - partial class Form1 + partial class FormOptic { /// /// Required designer variable. @@ -28,12 +28,112 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.CatalogsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.StoresToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.OperationsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.OrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ShipmentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.отчётыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.menuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.CatalogsToolStripMenuItem, + this.OperationsToolStripMenuItem, + 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 = 0; + this.menuStrip1.Text = "menuStrip1"; + // + // CatalogsToolStripMenuItem + // + this.CatalogsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.StoresToolStripMenuItem, + this.ComponentsToolStripMenuItem}); + this.CatalogsToolStripMenuItem.Name = "CatalogsToolStripMenuItem"; + this.CatalogsToolStripMenuItem.Size = new System.Drawing.Size(94, 20); + this.CatalogsToolStripMenuItem.Text = "Справочники"; + this.CatalogsToolStripMenuItem.Click += new System.EventHandler(this.CatalogsToolStripMenuItem_Click); + // + // StoresToolStripMenuItem + // + this.StoresToolStripMenuItem.Name = "StoresToolStripMenuItem"; + this.StoresToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.StoresToolStripMenuItem.Text = "Магазины Оптики"; + this.StoresToolStripMenuItem.Click += new System.EventHandler(this.StoresToolStripMenuItem_Click); + // + // ComponentsToolStripMenuItem + // + this.ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem"; + this.ComponentsToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.ComponentsToolStripMenuItem.Text = "Компоненты"; + this.ComponentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click); + // + // OperationsToolStripMenuItem + // + this.OperationsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.OrdersToolStripMenuItem, + this.ShipmentsToolStripMenuItem}); + this.OperationsToolStripMenuItem.Name = "OperationsToolStripMenuItem"; + this.OperationsToolStripMenuItem.Size = new System.Drawing.Size(75, 20); + this.OperationsToolStripMenuItem.Text = "Операции"; + this.OperationsToolStripMenuItem.Click += new System.EventHandler(this.OperationsToolStripMenuItem_Click); + // + // OrdersToolStripMenuItem + // + this.OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem"; + this.OrdersToolStripMenuItem.Size = new System.Drawing.Size(126, 22); + this.OrdersToolStripMenuItem.Text = "Заказы"; + this.OrdersToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click); + // + // ShipmentsToolStripMenuItem + // + this.ShipmentsToolStripMenuItem.Name = "ShipmentsToolStripMenuItem"; + this.ShipmentsToolStripMenuItem.Size = new System.Drawing.Size(126, 22); + this.ShipmentsToolStripMenuItem.Text = "Поставки"; + this.ShipmentsToolStripMenuItem.Click += new System.EventHandler(this.ShipmentsToolStripMenuItem_Click); + // + // отчёты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); + // + // FormOptic + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackgroundImage = global::OpticStore.Properties.Resources.rainbow; + this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; + this.Controls.Add(this.menuStrip1); + this.MainMenuStrip = this.menuStrip1; + this.Name = "FormOptic"; + this.Text = "Оптика"; + this.Load += new System.EventHandler(this.FormOptic_Load); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + } #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem CatalogsToolStripMenuItem; + private ToolStripMenuItem StoresToolStripMenuItem; + private ToolStripMenuItem ComponentsToolStripMenuItem; + private ToolStripMenuItem OperationsToolStripMenuItem; + private ToolStripMenuItem OrdersToolStripMenuItem; + private ToolStripMenuItem ShipmentsToolStripMenuItem; + private ToolStripMenuItem отчётыToolStripMenuItem; } } \ No newline at end of file diff --git a/OpticStore/OpticStore/Form1.cs b/OpticStore/OpticStore/Form1.cs index 886a762..5912fec 100644 --- a/OpticStore/OpticStore/Form1.cs +++ b/OpticStore/OpticStore/Form1.cs @@ -1,10 +1,108 @@ +using OpticStore.Forms; +using Unity; + namespace OpticStore { - public partial class Form1 : Form + public partial class FormOptic : Form { - public Form1() + private readonly IUnityContainer _container; + + public FormOptic(IUnityContainer container) { InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + } + private void StoresToolStripMenuItem_Click(object sender, + EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ComponentsToolStripMenuItem_Click(object sender, EventArgs + e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ShipmentsToolStripMenuItem_Click(object sender, + EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void FormOptic_Load(object sender, EventArgs e) + { + + } + + private void ToolStripMenuItem_Click(object sender, EventArgs e) + { + + } + + private void button1_Click(object sender, EventArgs e) + { + + } + + private void ComponentsToolStripMenuItem_Click_1(object sender, EventArgs e) + { + + } + + private void OrdersToolStripMenuItem_Click_1(object sender, EventArgs e) + { + + } + + private void ShipmentsToolStripMenuItem_Click_1(object sender, EventArgs e) + { + + } + + private void OperationsToolStripMenuItem_Click(object sender, EventArgs e) + { + + } + + private void CatalogsToolStripMenuItem_Click(object sender, EventArgs e) + { + } } } \ No newline at end of file diff --git a/OpticStore/OpticStore/Form1.resx b/OpticStore/OpticStore/Form1.resx index 1af7de1..938108a 100644 --- a/OpticStore/OpticStore/Form1.resx +++ b/OpticStore/OpticStore/Form1.resx @@ -1,64 +1,4 @@ - - - + @@ -117,4 +57,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/OpticStore/OpticStore/Forms/FormComponent.Designer.cs b/OpticStore/OpticStore/Forms/FormComponent.Designer.cs new file mode 100644 index 0000000..ac22302 --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormComponent.Designer.cs @@ -0,0 +1,125 @@ +namespace OpticStore.Forms +{ + partial class FormComponent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.textBoxComponentName = new System.Windows.Forms.TextBox(); + this.comboBoxCategory = new System.Windows.Forms.ComboBox(); + this.ButtonSave = new System.Windows.Forms.Button(); + this.ButtonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(37, 46); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(129, 15); + this.label1.TabIndex = 0; + this.label1.Text = "Название компонента"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(37, 110); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(63, 15); + this.label2.TabIndex = 1; + this.label2.Text = "Категория"; + this.label2.Click += new System.EventHandler(this.label2_Click); + // + // textBoxComponentName + // + this.textBoxComponentName.Location = new System.Drawing.Point(210, 46); + this.textBoxComponentName.Name = "textBoxComponentName"; + this.textBoxComponentName.Size = new System.Drawing.Size(215, 23); + this.textBoxComponentName.TabIndex = 2; + this.textBoxComponentName.TextChanged += new System.EventHandler(this.textBoxComponentName_TextChanged); + // + // comboBoxCategory + // + this.comboBoxCategory.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxCategory.FormattingEnabled = true; + this.comboBoxCategory.Location = new System.Drawing.Point(210, 107); + this.comboBoxCategory.Name = "comboBoxCategory"; + this.comboBoxCategory.Size = new System.Drawing.Size(215, 23); + this.comboBoxCategory.TabIndex = 3; + this.comboBoxCategory.SelectedIndexChanged += new System.EventHandler(this.comboBoxCategory_SelectedIndexChanged); + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(37, 182); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(75, 23); + this.ButtonSave.TabIndex = 4; + this.ButtonSave.Text = "Сохранить"; + this.ButtonSave.UseVisualStyleBackColor = true; + this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // ButtonCancel + // + this.ButtonCancel.Location = new System.Drawing.Point(350, 182); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(75, 23); + this.ButtonCancel.TabIndex = 5; + this.ButtonCancel.Text = "Отменить"; + this.ButtonCancel.UseVisualStyleBackColor = true; + this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // FormComponent + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(478, 260); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.ButtonSave); + this.Controls.Add(this.comboBoxCategory); + this.Controls.Add(this.textBoxComponentName); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "FormComponent"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Компонент"; + this.Load += new System.EventHandler(this.FormComponent_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label label1; + private Label label2; + private TextBox textBoxComponentName; + private ComboBox comboBoxCategory; + private Button ButtonSave; + private Button ButtonCancel; + } +} \ No newline at end of file diff --git a/OpticStore/OpticStore/Forms/FormComponent.cs b/OpticStore/OpticStore/Forms/FormComponent.cs new file mode 100644 index 0000000..43a94b0 --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormComponent.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using OpticStore.Repositories; +using OpticStore.Entities.Enums; +using OpticStore.Entities; + +namespace OpticStore.Forms +{ + public partial class FormComponent : Form + { + private readonly IComponentRepository _componentRepository; + private int? _componentId; + public int Id + { + set + { + try + { + var component = + _componentRepository.ReadComponentById(value); + if (component == null) + { + throw new + InvalidDataException(nameof(component)); + } + textBoxComponentName.Text = component.ComponentName; + comboBoxCategory.SelectedItem = + component.ComponentCategory; + _componentId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при полученииданных", MessageBoxButtons.OK, MessageBoxIcon.Error); + + return; + } + } + } + public FormComponent(IComponentRepository componentRepository) + { + InitializeComponent(); + _componentRepository = componentRepository ?? + throw new + ArgumentNullException(nameof(componentRepository)); + comboBoxCategory.DataSource = + Enum.GetValues(typeof(ComponentCategory)); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxComponentName.Text) + || + comboBoxCategory.SelectedIndex < 1) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_componentId.HasValue) + { + _componentRepository.UpdateComponent(CreateComponent(_componentId.Value)); + } + else + { + _componentRepository.CreateComponent(CreateComponent(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) =>Close(); + private Component CreateComponent(int id) => + Component.CreateEntity(id, textBoxComponentName.Text, + (ComponentCategory)comboBoxCategory.SelectedItem!); + + + private void label2_Click(object sender, EventArgs e) + { + + } + + private void FormComponent_Load(object sender, EventArgs e) + { + + } + + private void button1_Click(object sender, EventArgs e) + { + + } + + private void ButtonCancel_Click_1(object sender, EventArgs e) + { + + } + + private void comboBoxCategory_SelectedIndexChanged(object sender, EventArgs e) + { + + } + + private void textBoxComponentName_TextChanged(object sender, EventArgs e) + { + + } + } +} diff --git a/OpticStore/OpticStore/Forms/FormComponent.resx b/OpticStore/OpticStore/Forms/FormComponent.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormComponent.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/OpticStore/OpticStore/Forms/FormComponents.Designer.cs b/OpticStore/OpticStore/Forms/FormComponents.Designer.cs new file mode 100644 index 0000000..749470a --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormComponents.Designer.cs @@ -0,0 +1,126 @@ +namespace OpticStore.Forms +{ + partial class FormComponents + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panel1 = new System.Windows.Forms.Panel(); + this.ButtonDel = new System.Windows.Forms.Button(); + this.ButtonUpd = new System.Windows.Forms.Button(); + this.ButtonAdd = new System.Windows.Forms.Button(); + this.dataGridViewData = new System.Windows.Forms.DataGridView(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).BeginInit(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Controls.Add(this.ButtonDel); + this.panel1.Controls.Add(this.ButtonUpd); + this.panel1.Controls.Add(this.ButtonAdd); + this.panel1.Dock = System.Windows.Forms.DockStyle.Right; + this.panel1.Location = new System.Drawing.Point(711, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(200, 507); + this.panel1.TabIndex = 0; + // + // ButtonDel + // + this.ButtonDel.BackgroundImage = global::OpticStore.Properties.Resources.f24a597c2792f7337cd6b93538de629b; + this.ButtonDel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.ButtonDel.Location = new System.Drawing.Point(29, 341); + this.ButtonDel.Name = "ButtonDel"; + this.ButtonDel.Size = new System.Drawing.Size(143, 97); + this.ButtonDel.TabIndex = 2; + this.ButtonDel.UseVisualStyleBackColor = true; + this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // ButtonUpd + // + this.ButtonUpd.BackgroundImage = global::OpticStore.Properties.Resources.Antu_qtdesigner_svg; + this.ButtonUpd.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.ButtonUpd.Location = new System.Drawing.Point(29, 173); + this.ButtonUpd.Name = "ButtonUpd"; + this.ButtonUpd.Size = new System.Drawing.Size(143, 97); + this.ButtonUpd.TabIndex = 1; + this.ButtonUpd.UseVisualStyleBackColor = true; + this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // ButtonAdd + // + this.ButtonAdd.BackgroundImage = global::OpticStore.Properties.Resources.Fairytale_button_add_svg__1_; + this.ButtonAdd.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.ButtonAdd.Location = new System.Drawing.Point(27, 12); + this.ButtonAdd.Name = "ButtonAdd"; + this.ButtonAdd.Size = new System.Drawing.Size(143, 97); + this.ButtonAdd.TabIndex = 0; + this.ButtonAdd.UseVisualStyleBackColor = true; + this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridViewData + // + this.dataGridViewData.AllowUserToAddRows = false; + this.dataGridViewData.AllowUserToDeleteRows = false; + this.dataGridViewData.AllowUserToResizeColumns = false; + this.dataGridViewData.AllowUserToResizeRows = false; + this.dataGridViewData.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridViewData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridViewData.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridViewData.Location = new System.Drawing.Point(0, 0); + this.dataGridViewData.MultiSelect = false; + this.dataGridViewData.Name = "dataGridViewData"; + this.dataGridViewData.ReadOnly = true; + this.dataGridViewData.RowHeadersVisible = false; + this.dataGridViewData.RowTemplate.Height = 25; + this.dataGridViewData.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridViewData.Size = new System.Drawing.Size(711, 507); + this.dataGridViewData.TabIndex = 1; + // + // FormComponents + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(911, 507); + this.Controls.Add(this.dataGridViewData); + this.Controls.Add(this.panel1); + this.Name = "FormComponents"; + this.Text = "Компоненты"; + this.panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panel1; + private Button ButtonDel; + private Button ButtonUpd; + private Button ButtonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/OpticStore/OpticStore/Forms/FormComponents.cs b/OpticStore/OpticStore/Forms/FormComponents.cs new file mode 100644 index 0000000..f408319 --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormComponents.cs @@ -0,0 +1,126 @@ +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; +using OpticStore.Repositories; + +namespace OpticStore.Forms +{ + public partial class FormComponents : Form + { + private readonly IUnityContainer _container; + private readonly IComponentRepository _componentRepository; + public FormComponents(IUnityContainer container, IComponentRepository + componentRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _componentRepository = componentRepository ?? + throw new + ArgumentNullException(nameof(componentRepository)); + } + private void FormComponents_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().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(); + 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 + { + _componentRepository.DeleteComponent(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridViewData.DataSource = + _componentRepository.ReadComponents(); + 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 button1_Click(object sender, EventArgs e) + { + + } + + private void button2_Click(object sender, EventArgs e) + { + + } + + private void button3_Click(object sender, EventArgs e) + { + + } + } +} diff --git a/OpticStore/OpticStore/Forms/FormComponents.resx b/OpticStore/OpticStore/Forms/FormComponents.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormComponents.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/OpticStore/OpticStore/Forms/FormOrder.Designer.cs b/OpticStore/OpticStore/Forms/FormOrder.Designer.cs new file mode 100644 index 0000000..174d7a1 --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormOrder.Designer.cs @@ -0,0 +1,199 @@ +namespace OpticStore.Forms +{ + partial class FormOrder + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.comboBoxStatus = new System.Windows.Forms.ComboBox(); + this.dateTimePickerOrderDate = new System.Windows.Forms.DateTimePicker(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.dataGridViewComponents = new System.Windows.Forms.DataGridView(); + this.ButtonSave = new System.Windows.Forms.Button(); + this.ButtonCancel = new System.Windows.Forms.Button(); + this.comboBoxStore = new System.Windows.Forms.ComboBox(); + this.ColumnCategory = new System.Windows.Forms.DataGridViewComboBoxColumn(); + this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewComponents)).BeginInit(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(86, 44); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(54, 15); + this.label1.TabIndex = 0; + this.label1.Text = "Магазин"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(86, 98); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(69, 15); + this.label2.TabIndex = 1; + this.label2.Text = "Дата заказа"; + this.label2.Click += new System.EventHandler(this.label2_Click); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(86, 152); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(80, 15); + this.label3.TabIndex = 2; + this.label3.Text = "Статус заказа"; + // + // comboBoxStatus + // + this.comboBoxStatus.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxStatus.FormattingEnabled = true; + this.comboBoxStatus.Location = new System.Drawing.Point(182, 149); + this.comboBoxStatus.Name = "comboBoxStatus"; + this.comboBoxStatus.Size = new System.Drawing.Size(200, 23); + this.comboBoxStatus.TabIndex = 4; + this.comboBoxStatus.SelectedIndexChanged += new System.EventHandler(this.comboBoxStatus_SelectedIndexChanged); + // + // dateTimePickerOrderDate + // + this.dateTimePickerOrderDate.Enabled = false; + this.dateTimePickerOrderDate.Location = new System.Drawing.Point(182, 98); + this.dateTimePickerOrderDate.Name = "dateTimePickerOrderDate"; + this.dateTimePickerOrderDate.Size = new System.Drawing.Size(200, 23); + this.dateTimePickerOrderDate.TabIndex = 5; + this.dateTimePickerOrderDate.ValueChanged += new System.EventHandler(this.dateTimePickerDateReceipt_ValueChanged); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.dataGridViewComponents); + this.groupBox1.Location = new System.Drawing.Point(118, 202); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(247, 185); + this.groupBox1.TabIndex = 6; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Компоненты"; + // + // dataGridViewComponents + // + this.dataGridViewComponents.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridViewComponents.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ColumnCategory, + this.ColumnCount}); + this.dataGridViewComponents.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridViewComponents.Location = new System.Drawing.Point(3, 19); + this.dataGridViewComponents.Name = "dataGridViewComponents"; + this.dataGridViewComponents.RowTemplate.Height = 25; + this.dataGridViewComponents.Size = new System.Drawing.Size(241, 163); + this.dataGridViewComponents.TabIndex = 0; + this.dataGridViewComponents.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick); + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(91, 426); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(75, 23); + this.ButtonSave.TabIndex = 7; + this.ButtonSave.Text = "Сохранить"; + this.ButtonSave.UseVisualStyleBackColor = true; + this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // ButtonCancel + // + this.ButtonCancel.Location = new System.Drawing.Point(304, 426); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(75, 23); + this.ButtonCancel.TabIndex = 8; + this.ButtonCancel.Text = "Отменить"; + this.ButtonCancel.UseVisualStyleBackColor = true; + this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // comboBoxStore + // + this.comboBoxStore.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxStore.FormattingEnabled = true; + this.comboBoxStore.Location = new System.Drawing.Point(182, 44); + this.comboBoxStore.Name = "comboBoxStore"; + this.comboBoxStore.Size = new System.Drawing.Size(197, 23); + this.comboBoxStore.TabIndex = 9; + this.comboBoxStore.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // + // ColumnCategory + // + this.ColumnCategory.HeaderText = "Категория"; + this.ColumnCategory.Name = "ColumnCategory"; + // + // ColumnCount + // + this.ColumnCount.HeaderText = "Количество"; + this.ColumnCount.Name = "ColumnCount"; + this.ColumnCount.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.ColumnCount.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + // + // FormOrder + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(479, 461); + this.Controls.Add(this.comboBoxStore); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.ButtonSave); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.dateTimePickerOrderDate); + this.Controls.Add(this.comboBoxStatus); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "FormOrder"; + this.Text = "Заказ"; + this.Load += new System.EventHandler(this.FormOrder_Load_1); + this.groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewComponents)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private ComboBox comboBoxStatus; + private DateTimePicker dateTimePickerOrderDate; + private GroupBox groupBox1; + private DataGridView dataGridViewComponents; + private Button ButtonSave; + private Button ButtonCancel; + private ComboBox comboBoxStore; + private DataGridViewComboBoxColumn ColumnCategory; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/OpticStore/OpticStore/Forms/FormOrder.cs b/OpticStore/OpticStore/Forms/FormOrder.cs new file mode 100644 index 0000000..124207f --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormOrder.cs @@ -0,0 +1,116 @@ +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 OpticStore.Repositories; +using OpticStore.Entities; +using OpticStore.Repositories.Implementations; +using OpticStore.Entities.Enums; + +namespace OpticStore.Forms +{ + public partial class FormOrder : Form + { + private readonly IOrderRepository _orderRepository; + public FormOrder(IOrderRepository + orderRepository, + IStoreRepository storeRepository, + IComponentRepository componentRepository) + { + InitializeComponent(); + _orderRepository = orderRepository ?? + throw new + ArgumentNullException(nameof(orderRepository)); + comboBoxStore.DataSource = storeRepository.ReadStores(); + comboBoxStore.DisplayMember = "storeName"; + comboBoxStore.ValueMember = "Id"; + comboBoxStatus.DataSource = orderRepository.ReadOrder(); + comboBoxStatus.DisplayMember = "OrderStatus"; + comboBoxStatus.ValueMember = "Id"; + + ColumnCategory.DataSource = componentRepository.ReadComponents(); + ColumnCategory.DisplayMember = "ComponentName"; + ColumnCategory.ValueMember = "Id"; + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (dataGridViewComponents.RowCount < 1 || + comboBoxStore.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненныеполя"); + } + _orderRepository.CreateOrder(Order.CreateOperation(0, + (int)comboBoxStore.SelectedValue!, (OrderStatus)comboBoxStatus.SelectedValue!, + CreateListOrderComponentFromDataGrid())); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => + Close(); + private List + CreateListOrderComponentFromDataGrid() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridViewComponents.Rows) + { + if (row.Cells["ColumnCategory"].Value == null || + row.Cells["ColumnComponent"].Value == null) + { + continue; + } + list.Add(OrderComponent.CreateElement(0, + Convert.ToInt32(row.Cells["ColumnComponent"].Value), Convert.ToInt32(row.Cells["ColumnCount"].Value))); + } + return list; + } + + + + private void label2_Click(object sender, EventArgs e) + { + + } + + private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + + } + + private void FormOrder_Load(object sender, EventArgs e) + { + + } + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + + } + + private void dateTimePickerDateReceipt_ValueChanged(object sender, EventArgs e) + { + + } + + private void comboBoxStatus_SelectedIndexChanged(object sender, EventArgs e) + { + + } + + private void FormOrder_Load_1(object sender, EventArgs e) + { + + } + } +} diff --git a/OpticStore/OpticStore/Forms/FormOrder.resx b/OpticStore/OpticStore/Forms/FormOrder.resx new file mode 100644 index 0000000..46201d6 --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormOrder.resx @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + \ No newline at end of file diff --git a/OpticStore/OpticStore/Forms/FormOrders.Designer.cs b/OpticStore/OpticStore/Forms/FormOrders.Designer.cs new file mode 100644 index 0000000..0b92e92 --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormOrders.Designer.cs @@ -0,0 +1,107 @@ +namespace OpticStore.Forms +{ + partial class FormOrders + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panel1 = new System.Windows.Forms.Panel(); + this.ButtonAdd = new System.Windows.Forms.Button(); + this.ButtonDel = new System.Windows.Forms.Button(); + this.dataGridViewData = new System.Windows.Forms.DataGridView(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).BeginInit(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Controls.Add(this.ButtonAdd); + this.panel1.Controls.Add(this.ButtonDel); + this.panel1.Dock = System.Windows.Forms.DockStyle.Right; + this.panel1.Location = new System.Drawing.Point(600, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(200, 450); + this.panel1.TabIndex = 0; + // + // ButtonAdd + // + this.ButtonAdd.BackgroundImage = global::OpticStore.Properties.Resources.Fairytale_button_add_svg__1_; + this.ButtonAdd.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.ButtonAdd.Location = new System.Drawing.Point(40, 74); + this.ButtonAdd.Name = "ButtonAdd"; + this.ButtonAdd.Size = new System.Drawing.Size(148, 78); + this.ButtonAdd.TabIndex = 4; + this.ButtonAdd.UseVisualStyleBackColor = true; + this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // ButtonDel + // + this.ButtonDel.BackgroundImage = global::OpticStore.Properties.Resources.f24a597c2792f7337cd6b93538de629b; + this.ButtonDel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.ButtonDel.Location = new System.Drawing.Point(40, 267); + this.ButtonDel.Name = "ButtonDel"; + this.ButtonDel.Size = new System.Drawing.Size(148, 78); + this.ButtonDel.TabIndex = 3; + this.ButtonDel.UseVisualStyleBackColor = true; + this.ButtonDel.Click += new System.EventHandler(this.button2_Click); + // + // dataGridViewData + // + this.dataGridViewData.AllowUserToAddRows = false; + this.dataGridViewData.AllowUserToDeleteRows = false; + this.dataGridViewData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridViewData.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridViewData.Location = new System.Drawing.Point(0, 0); + this.dataGridViewData.Name = "dataGridViewData"; + this.dataGridViewData.ReadOnly = true; + this.dataGridViewData.RowTemplate.Height = 25; + this.dataGridViewData.Size = new System.Drawing.Size(600, 450); + this.dataGridViewData.TabIndex = 1; + this.dataGridViewData.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridViewData_CellContentClick); + // + // FormOrders + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.dataGridViewData); + this.Controls.Add(this.panel1); + this.Name = "FormOrders"; + this.Text = "Заказы"; + this.panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panel1; + private Button ButtonAdd; + private Button ButtonDel; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/OpticStore/OpticStore/Forms/FormOrders.cs b/OpticStore/OpticStore/Forms/FormOrders.cs new file mode 100644 index 0000000..2fff238 --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormOrders.cs @@ -0,0 +1,115 @@ +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; +using OpticStore.Repositories; + +namespace OpticStore.Forms +{ + public partial class FormOrders : Form + { + private readonly IUnityContainer _container; + private readonly IOrderRepository + _orderRepository; + public FormOrders(IUnityContainer container, + IOrderRepository orderRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _orderRepository = orderRepository ?? + throw new + ArgumentNullException(nameof(orderRepository)); + } + private void FormOrders_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().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 + { + _orderRepository.DeleteOrder(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridViewData.DataSource = + _orderRepository.ReadOrder(); + 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 button2_Click(object sender, EventArgs e) + { + + } + + + private void FormOrders_Load_1(object sender, EventArgs e) + { + + } + + private void dataGridViewData_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + + } + + private void button1_Click(object sender, EventArgs e) + { + + } + } +} diff --git a/OpticStore/OpticStore/Forms/FormOrders.resx b/OpticStore/OpticStore/Forms/FormOrders.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormOrders.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/OpticStore/OpticStore/Forms/FormShipment.Designer.cs b/OpticStore/OpticStore/Forms/FormShipment.Designer.cs new file mode 100644 index 0000000..e097f72 --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormShipment.Designer.cs @@ -0,0 +1,196 @@ +namespace OpticStore.Forms +{ + partial class FormShipment + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.dataGridViewComponents = new System.Windows.Forms.DataGridView(); + this.ColumnCategory = new System.Windows.Forms.DataGridViewComboBoxColumn(); + this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ButtonSave = new System.Windows.Forms.Button(); + this.ButtonCancel = new System.Windows.Forms.Button(); + this.comboBoxStore = new System.Windows.Forms.ComboBox(); + this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker(); + this.numericUpDownCount = new System.Windows.Forms.NumericUpDown(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewComponents)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).BeginInit(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(121, 25); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(54, 15); + this.label1.TabIndex = 0; + this.label1.Text = "Магазин"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(121, 77); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(85, 15); + this.label2.TabIndex = 1; + this.label2.Text = "Дата поставки"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(107, 127); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(95, 15); + this.label3.TabIndex = 2; + this.label3.Text = "Число поставок"; + this.label3.Click += new System.EventHandler(this.label3_Click); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.dataGridViewComponents); + this.groupBox1.Location = new System.Drawing.Point(161, 171); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(246, 173); + this.groupBox1.TabIndex = 3; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Компоненты"; + // + // dataGridViewComponents + // + this.dataGridViewComponents.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridViewComponents.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ColumnCategory, + this.ColumnCount}); + this.dataGridViewComponents.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridViewComponents.Location = new System.Drawing.Point(3, 19); + this.dataGridViewComponents.Name = "dataGridViewComponents"; + this.dataGridViewComponents.RowTemplate.Height = 25; + this.dataGridViewComponents.Size = new System.Drawing.Size(240, 151); + this.dataGridViewComponents.TabIndex = 0; + this.dataGridViewComponents.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridViewComponents_CellContentClick); + // + // ColumnCategory + // + this.ColumnCategory.HeaderText = "Категория"; + this.ColumnCategory.Name = "ColumnCategory"; + // + // ColumnCount + // + this.ColumnCount.HeaderText = "Количество"; + this.ColumnCount.Name = "ColumnCount"; + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(121, 383); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(75, 23); + this.ButtonSave.TabIndex = 0; + this.ButtonSave.Text = "Сохранить"; + this.ButtonSave.UseVisualStyleBackColor = true; + this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // ButtonCancel + // + this.ButtonCancel.Location = new System.Drawing.Point(358, 383); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(75, 23); + this.ButtonCancel.TabIndex = 4; + this.ButtonCancel.Text = "Отменить"; + this.ButtonCancel.UseVisualStyleBackColor = true; + this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // comboBoxStore + // + this.comboBoxStore.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxStore.FormattingEnabled = true; + this.comboBoxStore.Location = new System.Drawing.Point(233, 25); + this.comboBoxStore.Name = "comboBoxStore"; + this.comboBoxStore.Size = new System.Drawing.Size(200, 23); + this.comboBoxStore.TabIndex = 5; + // + // dateTimePicker1 + // + this.dateTimePicker1.Enabled = false; + this.dateTimePicker1.Location = new System.Drawing.Point(233, 77); + this.dateTimePicker1.Name = "dateTimePicker1"; + this.dateTimePicker1.Size = new System.Drawing.Size(200, 23); + this.dateTimePicker1.TabIndex = 6; + this.dateTimePicker1.ValueChanged += new System.EventHandler(this.dateTimePicker1_ValueChanged); + // + // numericUpDownCount + // + this.numericUpDownCount.Location = new System.Drawing.Point(233, 125); + this.numericUpDownCount.Name = "numericUpDownCount"; + this.numericUpDownCount.Size = new System.Drawing.Size(200, 23); + this.numericUpDownCount.TabIndex = 8; + this.numericUpDownCount.ValueChanged += new System.EventHandler(this.numericUpDownCount_ValueChanged); + // + // FormShipment + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(605, 432); + this.Controls.Add(this.numericUpDownCount); + this.Controls.Add(this.dateTimePicker1); + this.Controls.Add(this.comboBoxStore); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.ButtonSave); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "FormShipment"; + this.Text = "Поставка"; + this.Load += new System.EventHandler(this.FormShipment_Load); + this.groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewComponents)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private GroupBox groupBox1; + private Button ButtonSave; + private Button ButtonCancel; + private ComboBox comboBoxStore; + private DateTimePicker dateTimePicker1; + private DataGridView dataGridViewComponents; + private NumericUpDown numericUpDownCount; + private DataGridViewComboBoxColumn ColumnCategory; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/OpticStore/OpticStore/Forms/FormShipment.cs b/OpticStore/OpticStore/Forms/FormShipment.cs new file mode 100644 index 0000000..dffedf1 --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormShipment.cs @@ -0,0 +1,116 @@ +using OpticStore.Entities.Enums; +using OpticStore.Entities; +using OpticStore.Repositories; +using OpticStore.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Windows.Forms.VisualStyles; + +namespace OpticStore.Forms +{ + public partial class FormShipment : Form + { + private readonly IShipmentRepository _shipmentRepository; + public FormShipment(IShipmentRepository + shipmentRepository, + IStoreRepository storeRepository, + IComponentRepository componentRepository) + { + InitializeComponent(); + _shipmentRepository = shipmentRepository ?? + throw new + ArgumentNullException(nameof(shipmentRepository)); + comboBoxStore.DataSource = storeRepository.ReadStores(); + comboBoxStore.DisplayMember = "storeName"; + comboBoxStore.ValueMember = "Id"; + ColumnCategory.DataSource = componentRepository.ReadComponents(); + ColumnCategory.DisplayMember = "ComponentName"; + ColumnCategory.ValueMember = "Id"; + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (dataGridViewComponents.RowCount < 1 || + comboBoxStore.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненныеполя"); + } + _shipmentRepository.CreateShipment(Shipment.CreateOperation(0, + (int)comboBoxStore.SelectedValue!, Convert.ToInt32(numericUpDownCount.Value), + CreateListOrderComponentFromDataGrid())); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => + Close(); + private List + CreateListOrderComponentFromDataGrid() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridViewComponents.Rows) + { + if (row.Cells["ColumnCategory"].Value == null || + row.Cells["ColumnCount"].Value == null) + { + continue; + } + list.Add(ShipmentComponent.CreateElement(0, Convert.ToInt32(row.Cells["ColumnCategory"].Value), + Convert.ToInt32(row.Cells["ColumnCount"].Value))); + } + return list; + } + + private void FormShipment_Load(object sender, EventArgs e) + { + + } + + private void dateTimePicker1_ValueChanged(object sender, EventArgs e) + { + + } + + private void textBox1_TextChanged(object sender, EventArgs e) + { + + } + + private void numericUpDownCount_ValueChanged(object sender, EventArgs e) + { + + } + + private void ButtonSave_Click_1(object sender, EventArgs e) + { + + } + + private void ButtonCancel_Click_1(object sender, EventArgs e) + { + + } + + private void dataGridViewComponents_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + + } + + private void label3_Click(object sender, EventArgs e) + { + + } + } +} diff --git a/OpticStore/OpticStore/Forms/FormShipment.resx b/OpticStore/OpticStore/Forms/FormShipment.resx new file mode 100644 index 0000000..741a0c3 --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormShipment.resx @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/OpticStore/OpticStore/Forms/FormShipments.Designer.cs b/OpticStore/OpticStore/Forms/FormShipments.Designer.cs new file mode 100644 index 0000000..78612c9 --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormShipments.Designer.cs @@ -0,0 +1,106 @@ +namespace OpticStore.Forms +{ + partial class FormShipments + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panel1 = new System.Windows.Forms.Panel(); + this.ButtonDel = new System.Windows.Forms.Button(); + this.ButtonAdd = new System.Windows.Forms.Button(); + this.dataGridViewData = new System.Windows.Forms.DataGridView(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).BeginInit(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Controls.Add(this.ButtonDel); + this.panel1.Controls.Add(this.ButtonAdd); + this.panel1.Dock = System.Windows.Forms.DockStyle.Right; + this.panel1.Location = new System.Drawing.Point(600, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(200, 450); + this.panel1.TabIndex = 0; + // + // ButtonDel + // + this.ButtonDel.BackgroundImage = global::OpticStore.Properties.Resources.f24a597c2792f7337cd6b93538de629b; + this.ButtonDel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.ButtonDel.Location = new System.Drawing.Point(33, 256); + this.ButtonDel.Name = "ButtonDel"; + this.ButtonDel.Size = new System.Drawing.Size(155, 157); + this.ButtonDel.TabIndex = 4; + this.ButtonDel.UseVisualStyleBackColor = true; + this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // ButtonAdd + // + this.ButtonAdd.BackgroundImage = global::OpticStore.Properties.Resources.Fairytale_button_add_svg__1_; + this.ButtonAdd.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.ButtonAdd.Location = new System.Drawing.Point(33, 47); + this.ButtonAdd.Name = "ButtonAdd"; + this.ButtonAdd.Size = new System.Drawing.Size(155, 157); + this.ButtonAdd.TabIndex = 3; + this.ButtonAdd.UseVisualStyleBackColor = true; + this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridViewData + // + this.dataGridViewData.AllowUserToAddRows = false; + this.dataGridViewData.AllowUserToDeleteRows = false; + this.dataGridViewData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridViewData.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridViewData.Location = new System.Drawing.Point(0, 0); + this.dataGridViewData.Name = "dataGridViewData"; + this.dataGridViewData.ReadOnly = true; + this.dataGridViewData.RowTemplate.Height = 25; + this.dataGridViewData.Size = new System.Drawing.Size(600, 450); + this.dataGridViewData.TabIndex = 1; + // + // FormShipments + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.dataGridViewData); + this.Controls.Add(this.panel1); + this.Name = "FormShipments"; + this.Text = "Поставки"; + this.panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panel1; + private Button ButtonDel; + private Button ButtonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/OpticStore/OpticStore/Forms/FormShipments.cs b/OpticStore/OpticStore/Forms/FormShipments.cs new file mode 100644 index 0000000..3984b7c --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormShipments.cs @@ -0,0 +1,113 @@ +using OpticStore.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 OpticStore.Forms +{ + public partial class FormShipments : Form + { + private readonly IUnityContainer _container; + private readonly IShipmentRepository + _shipmentRepository; + public FormShipments(IUnityContainer container, + IShipmentRepository shipmentRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _shipmentRepository = shipmentRepository ?? + throw new + ArgumentNullException(nameof(shipmentRepository)); + } + private void FormShipments_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().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 + { + _shipmentRepository.DeleteShipment(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridViewData.DataSource = + _shipmentRepository.ReadShipment(); + 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 flowLayoutPanel1_Paint(object sender, PaintEventArgs e) + { + + } + + private void button1_Click(object sender, EventArgs e) + { + + } + + private void ButtonAdd_Click_1(object sender, EventArgs e) + { + + } + + private void ButtonDel_Click_1(object sender, EventArgs e) + { + + } + } +} diff --git a/OpticStore/OpticStore/Forms/FormShipments.resx b/OpticStore/OpticStore/Forms/FormShipments.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormShipments.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/OpticStore/OpticStore/Forms/FormStore.Designer.cs b/OpticStore/OpticStore/Forms/FormStore.Designer.cs new file mode 100644 index 0000000..1a9bc0d --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormStore.Designer.cs @@ -0,0 +1,147 @@ +namespace OpticStore.Forms +{ + partial class FormStore + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.textStoreName = new System.Windows.Forms.TextBox(); + this.textStoreAdress = new System.Windows.Forms.TextBox(); + this.textPhoneNumber = new System.Windows.Forms.TextBox(); + this.ButtonSave = new System.Windows.Forms.Button(); + this.ButtonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(43, 53); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(113, 15); + this.label1.TabIndex = 0; + this.label1.Text = "Название магазина"; + this.label1.Click += new System.EventHandler(this.label1_Click); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(43, 122); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(100, 15); + this.label2.TabIndex = 1; + this.label2.Text = "Адресс магазина"; + this.label2.Click += new System.EventHandler(this.label2_Click); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(43, 193); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(109, 15); + this.label3.TabIndex = 2; + this.label3.Text = "Телефон магазина"; + this.label3.Click += new System.EventHandler(this.label3_Click); + // + // textStoreName + // + this.textStoreName.Location = new System.Drawing.Point(157, 53); + this.textStoreName.Name = "textStoreName"; + this.textStoreName.Size = new System.Drawing.Size(253, 23); + this.textStoreName.TabIndex = 3; + this.textStoreName.TextChanged += new System.EventHandler(this.textStoreName_TextChanged); + // + // textStoreAdress + // + this.textStoreAdress.Location = new System.Drawing.Point(157, 122); + this.textStoreAdress.Name = "textStoreAdress"; + this.textStoreAdress.Size = new System.Drawing.Size(253, 23); + this.textStoreAdress.TabIndex = 4; + // + // textPhoneNumber + // + this.textPhoneNumber.Location = new System.Drawing.Point(158, 190); + this.textPhoneNumber.Name = "textPhoneNumber"; + this.textPhoneNumber.Size = new System.Drawing.Size(252, 23); + this.textPhoneNumber.TabIndex = 5; + this.textPhoneNumber.TextChanged += new System.EventHandler(this.textPhoneNumber_TextChanged); + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(43, 267); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(75, 23); + this.ButtonSave.TabIndex = 6; + this.ButtonSave.Text = "Сохранить"; + this.ButtonSave.UseVisualStyleBackColor = true; + this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // ButtonCancel + // + this.ButtonCancel.Location = new System.Drawing.Point(335, 267); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(75, 23); + this.ButtonCancel.TabIndex = 7; + this.ButtonCancel.Text = "Отмена"; + this.ButtonCancel.UseVisualStyleBackColor = true; + this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // FormStore + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(467, 323); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.ButtonSave); + this.Controls.Add(this.textPhoneNumber); + this.Controls.Add(this.textStoreAdress); + this.Controls.Add(this.textStoreName); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "FormStore"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Магазин"; + this.Load += new System.EventHandler(this.FormStore_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private TextBox textStoreName; + private TextBox textStoreAdress; + private TextBox textPhoneNumber; + private Button ButtonSave; + private Button ButtonCancel; + } +} \ No newline at end of file diff --git a/OpticStore/OpticStore/Forms/FormStore.cs b/OpticStore/OpticStore/Forms/FormStore.cs new file mode 100644 index 0000000..49e5300 --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormStore.cs @@ -0,0 +1,118 @@ +using OpticStore.Repositories; +using OpticStore.Entities; +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 OpticStore.Forms +{ + public partial class FormStore : Form + { + 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)); + } + textStoreName.Text = store.storeName; + textStoreAdress.Text = store.storeAdress; + textPhoneNumber.Text = store.phoneNumber; + _storeId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при полученииданных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormStore(IStoreRepository animalRepository) + { + InitializeComponent(); + _storeRepository = animalRepository ?? + throw new + ArgumentNullException(nameof(animalRepository)); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textPhoneNumber.Text) + || + string.IsNullOrWhiteSpace(textStoreAdress.Text) + || + string.IsNullOrWhiteSpace(textStoreName.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, textStoreName.Text, textStoreAdress.Text, textPhoneNumber.Text); + + private void label1_Click(object sender, EventArgs e) + { + + } + + private void label3_Click(object sender, EventArgs e) + { + + } + + + private void FormStore_Load(object sender, EventArgs e) + { + + } + + private void label2_Click(object sender, EventArgs e) + { + + } + + private void textStoreName_TextChanged(object sender, EventArgs e) + { + + } + + private void FormStore_Load_1(object sender, EventArgs e) + { + + } + + private void textPhoneNumber_TextChanged(object sender, EventArgs e) + { + + } + } +} diff --git a/OpticStore/OpticStore/Forms/FormStore.resx b/OpticStore/OpticStore/Forms/FormStore.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormStore.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/OpticStore/OpticStore/Forms/FormStores.Designer.cs b/OpticStore/OpticStore/Forms/FormStores.Designer.cs new file mode 100644 index 0000000..c954400 --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormStores.Designer.cs @@ -0,0 +1,132 @@ +namespace OpticStore.Forms +{ + partial class FormStores + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panel1 = new System.Windows.Forms.Panel(); + this.ButtonDel = new System.Windows.Forms.Button(); + this.ButtonUpd = new System.Windows.Forms.Button(); + this.ButtonAdd = new System.Windows.Forms.Button(); + this.dataGridViewData = new System.Windows.Forms.DataGridView(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).BeginInit(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Controls.Add(this.ButtonDel); + this.panel1.Controls.Add(this.ButtonUpd); + this.panel1.Controls.Add(this.ButtonAdd); + this.panel1.Dock = System.Windows.Forms.DockStyle.Right; + this.panel1.Location = new System.Drawing.Point(600, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(200, 450); + this.panel1.TabIndex = 0; + this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint); + // + // ButtonDel + // + this.ButtonDel.BackColor = System.Drawing.SystemColors.ButtonHighlight; + this.ButtonDel.BackgroundImage = global::OpticStore.Properties.Resources.f24a597c2792f7337cd6b93538de629b; + this.ButtonDel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.ButtonDel.Location = new System.Drawing.Point(50, 325); + this.ButtonDel.Name = "ButtonDel"; + this.ButtonDel.Size = new System.Drawing.Size(101, 78); + this.ButtonDel.TabIndex = 2; + this.ButtonDel.UseVisualStyleBackColor = false; + this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // ButtonUpd + // + this.ButtonUpd.BackColor = System.Drawing.SystemColors.ButtonHighlight; + this.ButtonUpd.BackgroundImage = global::OpticStore.Properties.Resources.Antu_qtdesigner_svg; + this.ButtonUpd.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.ButtonUpd.Location = new System.Drawing.Point(50, 182); + this.ButtonUpd.Name = "ButtonUpd"; + this.ButtonUpd.Size = new System.Drawing.Size(101, 78); + this.ButtonUpd.TabIndex = 1; + this.ButtonUpd.UseVisualStyleBackColor = false; + this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // ButtonAdd + // + this.ButtonAdd.BackColor = System.Drawing.SystemColors.ButtonHighlight; + this.ButtonAdd.BackgroundImage = global::OpticStore.Properties.Resources.Fairytale_button_add_svg__1_; + this.ButtonAdd.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.ButtonAdd.Location = new System.Drawing.Point(52, 49); + this.ButtonAdd.Name = "ButtonAdd"; + this.ButtonAdd.Size = new System.Drawing.Size(101, 78); + this.ButtonAdd.TabIndex = 0; + this.ButtonAdd.UseVisualStyleBackColor = false; + this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // dataGridViewData + // + this.dataGridViewData.AllowUserToAddRows = false; + this.dataGridViewData.AllowUserToDeleteRows = false; + this.dataGridViewData.AllowUserToResizeColumns = false; + this.dataGridViewData.AllowUserToResizeRows = false; + this.dataGridViewData.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridViewData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridViewData.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridViewData.Location = new System.Drawing.Point(0, 0); + this.dataGridViewData.MultiSelect = false; + this.dataGridViewData.Name = "dataGridViewData"; + this.dataGridViewData.ReadOnly = true; + this.dataGridViewData.RowHeadersVisible = false; + this.dataGridViewData.RowTemplate.Height = 25; + this.dataGridViewData.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridViewData.Size = new System.Drawing.Size(600, 450); + this.dataGridViewData.TabIndex = 1; + this.dataGridViewData.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick); + // + // FormStores + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.dataGridViewData); + this.Controls.Add(this.panel1); + this.Name = "FormStores"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Магазины"; + this.panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewData)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panel1; + private Button ButtonDel; + private Button ButtonUpd; + private Button ButtonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/OpticStore/OpticStore/Forms/FormStores.cs b/OpticStore/OpticStore/Forms/FormStores.cs new file mode 100644 index 0000000..f369d9e --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormStores.cs @@ -0,0 +1,123 @@ +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 OpticStore.Forms.FormStores; +using Unity; +using OpticStore.Repositories; + +namespace OpticStore.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().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(); + 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 dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + + } + + private void panel1_Paint(object sender, PaintEventArgs e) + { + + } + } +} diff --git a/OpticStore/OpticStore/Forms/FormStores.resx b/OpticStore/OpticStore/Forms/FormStores.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/OpticStore/OpticStore/Forms/FormStores.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/OpticStore/OpticStore/OpticStore.csproj b/OpticStore/OpticStore/OpticStore.csproj index b57c89e..32bb4ef 100644 --- a/OpticStore/OpticStore/OpticStore.csproj +++ b/OpticStore/OpticStore/OpticStore.csproj @@ -8,4 +8,23 @@ enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/OpticStore/OpticStore/Program.cs b/OpticStore/OpticStore/Program.cs index b581a3e..c134c9d 100644 --- a/OpticStore/OpticStore/Program.cs +++ b/OpticStore/OpticStore/Program.cs @@ -1,17 +1,38 @@ +using System.Drawing; +using Unity; +using OpticStore.Repositories; +using OpticStore.Repositories.Implementations; +using Unity.Lifetime; + + namespace OpticStore { internal static class Program { /// - /// The main entry point for the application. + /// The main entry point for the application. /// [STAThread] static void Main() { - // To customize application configuration such as set high DPI settings or default font, + // To customize application configuration such as set high DPIsettings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(CreateContainer().Resolve()); + } + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new + TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + return container; } } + } \ No newline at end of file diff --git a/OpticStore/OpticStore/Properties/Resources.Designer.cs b/OpticStore/OpticStore/Properties/Resources.Designer.cs new file mode 100644 index 0000000..33dbc2e --- /dev/null +++ b/OpticStore/OpticStore/Properties/Resources.Designer.cs @@ -0,0 +1,113 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace OpticStore.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.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() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OpticStore.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Antu_qtdesigner_svg { + get { + object obj = ResourceManager.GetObject("Antu_qtdesigner.svg", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap f24a597c2792f7337cd6b93538de629b { + get { + object obj = ResourceManager.GetObject("f24a597c2792f7337cd6b93538de629b", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Fairytale_button_add_svg__1_ { + get { + object obj = ResourceManager.GetObject("Fairytale_button_add.svg (1)", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap gratis_png_iconos_de_la_computadora_boton_de_cancelar { + get { + object obj = ResourceManager.GetObject("gratis-png-iconos-de-la-computadora-boton-de-cancelar", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap rainbow { + get { + object obj = ResourceManager.GetObject("rainbow", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/OpticStore/OpticStore/Properties/Resources.resx b/OpticStore/OpticStore/Properties/Resources.resx new file mode 100644 index 0000000..1746e63 --- /dev/null +++ b/OpticStore/OpticStore/Properties/Resources.resx @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\gratis-png-iconos-de-la-computadora-boton-de-cancelar.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Fairytale_button_add.svg (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\f24a597c2792f7337cd6b93538de629b.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Antu_qtdesigner.svg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\rainbow.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/OpticStore/OpticStore/Repositories/IComponentRepository.cs b/OpticStore/OpticStore/Repositories/IComponentRepository.cs new file mode 100644 index 0000000..7482dc8 --- /dev/null +++ b/OpticStore/OpticStore/Repositories/IComponentRepository.cs @@ -0,0 +1,18 @@ +using OpticStore.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpticStore.Repositories +{ + public interface IComponentRepository + { + IEnumerable ReadComponents(); + Component ReadComponentById(int id); + void CreateComponent(Component component); + void UpdateComponent(Component component); + void DeleteComponent(int id); + } +} diff --git a/OpticStore/OpticStore/Repositories/IOrderRepository.cs b/OpticStore/OpticStore/Repositories/IOrderRepository.cs new file mode 100644 index 0000000..240fe32 --- /dev/null +++ b/OpticStore/OpticStore/Repositories/IOrderRepository.cs @@ -0,0 +1,17 @@ +using OpticStore.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpticStore.Repositories +{ + public interface IOrderRepository + { + IEnumerable ReadOrder(DateTime? dateForm = null, DateTime? dateTo = null, + int? componentId = null, int? storeId = null); + void CreateOrder(Order order); + void DeleteOrder(int id); + } +} diff --git a/OpticStore/OpticStore/Repositories/IShipmentRepository.cs b/OpticStore/OpticStore/Repositories/IShipmentRepository.cs new file mode 100644 index 0000000..6490b50 --- /dev/null +++ b/OpticStore/OpticStore/Repositories/IShipmentRepository.cs @@ -0,0 +1,18 @@ +using OpticStore.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpticStore.Repositories +{ + public interface IShipmentRepository + { + IEnumerable ReadShipment(DateTime? dateForm=null, DateTime? dateTo = null, + int? componentId = null, int? storeId = null, int? count = null); + void CreateShipment(Shipment shipment); + void DeleteShipment(int id); + + } +} diff --git a/OpticStore/OpticStore/Repositories/IStoreRepository.cs b/OpticStore/OpticStore/Repositories/IStoreRepository.cs new file mode 100644 index 0000000..fa31bde --- /dev/null +++ b/OpticStore/OpticStore/Repositories/IStoreRepository.cs @@ -0,0 +1,18 @@ +using OpticStore.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpticStore.Repositories +{ + public interface IStoreRepository + { + IEnumerable ReadStores(); + Store ReadStoreById(int id); + void CreateStore(Store store); + void UpdateStore(Store store); + void DeleteStore(int id); + } +} diff --git a/OpticStore/OpticStore/Repositories/Implementations/ComponentRepository.cs b/OpticStore/OpticStore/Repositories/Implementations/ComponentRepository.cs new file mode 100644 index 0000000..e8737b0 --- /dev/null +++ b/OpticStore/OpticStore/Repositories/Implementations/ComponentRepository.cs @@ -0,0 +1,32 @@ +using OpticStore.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using OpticStore.Entities.Enums; + +namespace OpticStore.Repositories.Implementations +{ + internal class ComponentRepository:IComponentRepository + { + private List components = new List(); + public void CreateComponent(Component component) + { + } + public void DeleteComponent(int id) + { + } + public Component ReadComponentById(int id) + { + return Component.CreateEntity(0, string.Empty, ComponentCategory.none); + } + public IEnumerable ReadComponents() + { + return components; + } + public void UpdateComponent(Component component) + { + } + } +} diff --git a/OpticStore/OpticStore/Repositories/Implementations/OrderRepository.cs b/OpticStore/OpticStore/Repositories/Implementations/OrderRepository.cs new file mode 100644 index 0000000..c82308e --- /dev/null +++ b/OpticStore/OpticStore/Repositories/Implementations/OrderRepository.cs @@ -0,0 +1,25 @@ +using OpticStore.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpticStore.Repositories.Implementations +{ + internal class OrderRepository:IOrderRepository + { + private List orders = new List(); + public void CreateOrder(Order order) + { + } + public void DeleteOrder(int id) + { + } + public IEnumerable ReadOrder(DateTime? dateForm = null, DateTime? dateTo = null, + int? componentId = null, int? storeId = null) + { + return orders; + } + } +} diff --git a/OpticStore/OpticStore/Repositories/Implementations/ShipmentRepository.cs b/OpticStore/OpticStore/Repositories/Implementations/ShipmentRepository.cs new file mode 100644 index 0000000..4f9e673 --- /dev/null +++ b/OpticStore/OpticStore/Repositories/Implementations/ShipmentRepository.cs @@ -0,0 +1,25 @@ +using OpticStore.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpticStore.Repositories.Implementations +{ + internal class ShipmentRepository:IShipmentRepository + { + private List shipments = new List(); + public void CreateShipment(Shipment shipment) + { + } + public void DeleteShipment(int id) + { + } + public IEnumerable ReadShipment(DateTime? dateForm = null, DateTime? dateTo = null, + int? componentId = null, int? storeId = null, int? count = null) + { + return shipments; + } + } +} diff --git a/OpticStore/OpticStore/Repositories/Implementations/StoreRepository.cs b/OpticStore/OpticStore/Repositories/Implementations/StoreRepository.cs new file mode 100644 index 0000000..6487636 --- /dev/null +++ b/OpticStore/OpticStore/Repositories/Implementations/StoreRepository.cs @@ -0,0 +1,32 @@ +using OpticStore.Entities; +using OpticStore.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpticStore.Repositories.Implementations +{ + internal class StoreRepository:IStoreRepository + { + private List stores = new List(); + public void CreateStore(Store store) + { + } + public void DeleteStore(int id) + { + } + public Store ReadStoreById(int id) + { + return Store.CreateEntity(0, string.Empty, string.Empty, string.Empty); + } + public IEnumerable ReadStores() + { + return stores; + } + public void UpdateStore(Store store) + { + } + } +} diff --git a/OpticStore/OpticStore/Resources/Antu_qtdesigner.svg.png b/OpticStore/OpticStore/Resources/Antu_qtdesigner.svg.png new file mode 100644 index 0000000..7d0dfd9 Binary files /dev/null and b/OpticStore/OpticStore/Resources/Antu_qtdesigner.svg.png differ diff --git a/OpticStore/OpticStore/Resources/Fairytale_button_add.svg (1).png b/OpticStore/OpticStore/Resources/Fairytale_button_add.svg (1).png new file mode 100644 index 0000000..e4d9850 Binary files /dev/null and b/OpticStore/OpticStore/Resources/Fairytale_button_add.svg (1).png differ diff --git a/OpticStore/OpticStore/Resources/f24a597c2792f7337cd6b93538de629b.jpg b/OpticStore/OpticStore/Resources/f24a597c2792f7337cd6b93538de629b.jpg new file mode 100644 index 0000000..a167cdc Binary files /dev/null and b/OpticStore/OpticStore/Resources/f24a597c2792f7337cd6b93538de629b.jpg differ diff --git a/OpticStore/OpticStore/Resources/gratis-png-iconos-de-la-computadora-boton-de-cancelar.png b/OpticStore/OpticStore/Resources/gratis-png-iconos-de-la-computadora-boton-de-cancelar.png new file mode 100644 index 0000000..cd03696 Binary files /dev/null and b/OpticStore/OpticStore/Resources/gratis-png-iconos-de-la-computadora-boton-de-cancelar.png differ diff --git a/OpticStore/OpticStore/Resources/rainbow.jpg b/OpticStore/OpticStore/Resources/rainbow.jpg new file mode 100644 index 0000000..5a121f6 Binary files /dev/null and b/OpticStore/OpticStore/Resources/rainbow.jpg differ