diff --git a/ProjectWorkshop/ProjectWorkshop/Entities/Assembler.cs b/ProjectWorkshop/ProjectWorkshop/Entities/Assembler.cs new file mode 100644 index 0000000..8a9b2f2 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Entities/Assembler.cs @@ -0,0 +1,26 @@ +using ProjectWorkshop.Entities.Enums; + +namespace ProjectWorkshop.Entities; + +public class Assembler +{ + public int ID { get; private set; } + + public string FullName { get; private set; } = string.Empty; + + public AssemblerRank AssemblerRank { get; private set; } + + public DateTime WorkExperience { get; private set; } + + public static Assembler CreateEntity(int id, string fullName, AssemblerRank assemblerRank, DateTime? dateTime = null) + { + return new Assembler + { + ID = id, + FullName = fullName, + AssemblerRank = assemblerRank, + WorkExperience = dateTime ?? DateTime.Now + }; + } + +} diff --git a/ProjectWorkshop/ProjectWorkshop/Entities/AssemblerShift.cs b/ProjectWorkshop/ProjectWorkshop/Entities/AssemblerShift.cs new file mode 100644 index 0000000..2f418a9 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Entities/AssemblerShift.cs @@ -0,0 +1,23 @@ +namespace ProjectWorkshop.Entities; + +public class AssemblerShift +{ + public int ID { get; private set; } + + public int WorkHours { get; private set; } + + public int AssemblerID_Assembler { get; private set; } + + public int ShiftID_Shift { get; private set; } + + public static AssemblerShift CreateOperation(int id, int workHours, int assemblerID, int shiftID_Shift) + { + return new AssemblerShift + { + ID = id, + WorkHours = workHours, + AssemblerID_Assembler = assemblerID, + ShiftID_Shift = shiftID_Shift + }; + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Entities/Assembly.cs b/ProjectWorkshop/ProjectWorkshop/Entities/Assembly.cs new file mode 100644 index 0000000..a843867 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Entities/Assembly.cs @@ -0,0 +1,26 @@ +using ProjectWorkshop.Entities.Enums; + +namespace ProjectWorkshop.Entities; + +public class Assembly +{ + public int ID { get; private set; } + + public int Count { get; private set; } + + public int AssemblerID_Assembler { get; private set; } + + public IEnumerable ProductAssembly { get; private set; } = []; + + public static Assembly CreateOperation(int id, int count, int assemblerID, IEnumerable productAssembly) + { + return new Assembly + { + ID = id, + Count = count, + AssemblerID_Assembler = assemblerID, + ProductAssembly = productAssembly + }; + } +} + diff --git a/ProjectWorkshop/ProjectWorkshop/Entities/Enums/AssemblerRank.cs b/ProjectWorkshop/ProjectWorkshop/Entities/Enums/AssemblerRank.cs new file mode 100644 index 0000000..9937895 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Entities/Enums/AssemblerRank.cs @@ -0,0 +1,12 @@ +namespace ProjectWorkshop.Entities.Enums; + +public enum AssemblerRank +{ + None = 0, + + Ordinary = 1, + + Senior = 2, + + Head = 3 +} diff --git a/ProjectWorkshop/ProjectWorkshop/Entities/Enums/ProductType.cs b/ProjectWorkshop/ProjectWorkshop/Entities/Enums/ProductType.cs new file mode 100644 index 0000000..249df9a --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Entities/Enums/ProductType.cs @@ -0,0 +1,13 @@ +namespace ProjectWorkshop.Entities.Enums; + +[Flags] +public enum ProductType +{ + None = 0, + + Electronics = 1, + + Furniture = 2, + + CarParts = 4 +} diff --git a/ProjectWorkshop/ProjectWorkshop/Entities/Product.cs b/ProjectWorkshop/ProjectWorkshop/Entities/Product.cs new file mode 100644 index 0000000..38e90ad --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Entities/Product.cs @@ -0,0 +1,29 @@ +using ProjectWorkshop.Entities.Enums; + +namespace ProjectWorkshop.Entities; + +public class Product +{ + public int ID { get; private set; } + + public string ProductName { get; private set; } = string.Empty; + + public double Price { get; private set; } + + public DateTime AssemblyDate { get; private set; } + + public ProductType ProductType { get; private set; } + + + public static Product CreateEntity(int id, string productName, double price, ProductType productType) + { + return new Product + { + ID = id, + ProductName = productName ?? string.Empty, + Price = price, + ProductType = productType, + AssemblyDate = DateTime.Now + }; + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Entities/ProductAssembly.cs b/ProjectWorkshop/ProjectWorkshop/Entities/ProductAssembly.cs new file mode 100644 index 0000000..340bf76 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Entities/ProductAssembly.cs @@ -0,0 +1,23 @@ +namespace ProjectWorkshop.Entities; + +public class ProductAssembly +{ + public int ID { get; private set; } + + public int ProductID_Product { get; private set; } + + public int AssemblyID_Assembly { get; private set; } + + public int Count { get; private set; } + + public static ProductAssembly CreateElement(int id, int productID, int assemblyID, int count) + { + return new ProductAssembly + { + ID = id, + ProductID_Product = productID, + AssemblyID_Assembly = assemblyID, + Count = count + }; + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Entities/Shift.cs b/ProjectWorkshop/ProjectWorkshop/Entities/Shift.cs new file mode 100644 index 0000000..c25e256 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Entities/Shift.cs @@ -0,0 +1,17 @@ +namespace ProjectWorkshop.Entities; + +public class Shift +{ + public int ID { get; private set; } + + public DateTime ShiftDate { get; private set; } + + public static Shift CreateEntity(int id, DateTime? dateTime = null) + { + return new Shift + { + ID = id, + ShiftDate = dateTime ?? DateTime.Now + }; + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Form1.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Form1.Designer.cs deleted file mode 100644 index 6cc9a46..0000000 --- a/ProjectWorkshop/ProjectWorkshop/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ProjectWorkshop -{ - partial class Form1 - { - /// - /// 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.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} diff --git a/ProjectWorkshop/ProjectWorkshop/Form1.cs b/ProjectWorkshop/ProjectWorkshop/Form1.cs deleted file mode 100644 index 456d6bc..0000000 --- a/ProjectWorkshop/ProjectWorkshop/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ProjectWorkshop -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/ProjectWorkshop/ProjectWorkshop/FormWorkshop.Designer.cs b/ProjectWorkshop/ProjectWorkshop/FormWorkshop.Designer.cs new file mode 100644 index 0000000..4782f7a --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/FormWorkshop.Designer.cs @@ -0,0 +1,138 @@ +namespace ProjectWorkshop +{ + partial class FormWorkshop + { + /// + /// 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() + { + menuStrip = new MenuStrip(); + справочникиToolStripMenuItem = new ToolStripMenuItem(); + AssemblersToolStripMenuItem = new ToolStripMenuItem(); + ShiftsToolStripMenuItem = new ToolStripMenuItem(); + ProductsToolStripMenuItem = new ToolStripMenuItem(); + операцииToolStripMenuItem = new ToolStripMenuItem(); + AssemblyToolStripMenuItem = new ToolStripMenuItem(); + AssemblerShiftToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + menuStrip.SuspendLayout(); + SuspendLayout(); + // + // menuStrip + // + menuStrip.ImageScalingSize = new Size(32, 32); + menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(1354, 42); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { AssemblersToolStripMenuItem, ShiftsToolStripMenuItem, ProductsToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(184, 38); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // AssemblersToolStripMenuItem + // + AssemblersToolStripMenuItem.Name = "AssemblersToolStripMenuItem"; + AssemblersToolStripMenuItem.Size = new Size(359, 44); + AssemblersToolStripMenuItem.Text = "Сборщики"; + AssemblersToolStripMenuItem.Click += AssemblersToolStripMenuItem_Click; + // + // ShiftsToolStripMenuItem + // + ShiftsToolStripMenuItem.Name = "ShiftsToolStripMenuItem"; + ShiftsToolStripMenuItem.Size = new Size(359, 44); + ShiftsToolStripMenuItem.Text = "Смены"; + ShiftsToolStripMenuItem.Click += ShiftsToolStripMenuItem_Click; + // + // ProductsToolStripMenuItem + // + ProductsToolStripMenuItem.Name = "ProductsToolStripMenuItem"; + ProductsToolStripMenuItem.Size = new Size(359, 44); + ProductsToolStripMenuItem.Text = "Изделия"; + ProductsToolStripMenuItem.Click += ProductsToolStripMenuItem_Click_1; + // + // операцииToolStripMenuItem + // + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { AssemblyToolStripMenuItem, AssemblerShiftToolStripMenuItem }); + операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; + операцииToolStripMenuItem.Size = new Size(147, 38); + операцииToolStripMenuItem.Text = "Операции"; + // + // AssemblyToolStripMenuItem + // + AssemblyToolStripMenuItem.Name = "AssemblyToolStripMenuItem"; + AssemblyToolStripMenuItem.Size = new Size(330, 44); + AssemblyToolStripMenuItem.Text = "Сборка"; + AssemblyToolStripMenuItem.Click += AssemblyToolStripMenuItem_Click; + // + // AssemblerShiftToolStripMenuItem + // + AssemblerShiftToolStripMenuItem.Name = "AssemblerShiftToolStripMenuItem"; + AssemblerShiftToolStripMenuItem.Size = new Size(330, 44); + AssemblerShiftToolStripMenuItem.Text = "Выйти на смену "; + AssemblerShiftToolStripMenuItem.Click += AssemblerShiftToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(116, 38); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // FormWorkshop + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.цех; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(1354, 785); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormWorkshop"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Цех"; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem операцииToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem AssemblyToolStripMenuItem; + private ToolStripMenuItem AssemblerShiftToolStripMenuItem; + private ToolStripMenuItem AssemblersToolStripMenuItem; + private ToolStripMenuItem ShiftsToolStripMenuItem; + private ToolStripMenuItem ProductsToolStripMenuItem; + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/FormWorkshop.cs b/ProjectWorkshop/ProjectWorkshop/FormWorkshop.cs new file mode 100644 index 0000000..f6a8c7c --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/FormWorkshop.cs @@ -0,0 +1,77 @@ +using ProjectWorkshop.Forms; +using Unity; + +namespace ProjectWorkshop +{ + public partial class FormWorkshop : Form + { + private readonly IUnityContainer _container; + + public FormWorkshop(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + } + + private void AssemblersToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ShiftsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ProductsToolStripMenuItem_Click_1(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void AssemblyToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void AssemblerShiftToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/FormWorkshop.resx b/ProjectWorkshop/ProjectWorkshop/FormWorkshop.resx new file mode 100644 index 0000000..31084d5 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/FormWorkshop.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 17, 17 + + \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembler.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembler.Designer.cs new file mode 100644 index 0000000..1ca4b1b --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembler.Designer.cs @@ -0,0 +1,140 @@ +namespace ProjectWorkshop.Forms +{ + partial class FormAssembler + { + /// + /// 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() + { + labelFullName = new Label(); + textBoxFullName = new TextBox(); + labelAssemblerRank = new Label(); + comboBoxAssemblerRank = new ComboBox(); + labelWorkExperience = new Label(); + dateTimePickerWorkExperience = new DateTimePicker(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelFullName + // + labelFullName.AutoSize = true; + labelFullName.Location = new Point(43, 52); + labelFullName.Name = "labelFullName"; + labelFullName.Size = new Size(194, 32); + labelFullName.TabIndex = 0; + labelFullName.Text = "ФИО Сборщика:"; + // + // textBoxFullName + // + textBoxFullName.Location = new Point(278, 52); + textBoxFullName.Name = "textBoxFullName"; + textBoxFullName.Size = new Size(324, 39); + textBoxFullName.TabIndex = 1; + // + // labelAssemblerRank + // + labelAssemblerRank.AutoSize = true; + labelAssemblerRank.Location = new Point(85, 198); + labelAssemblerRank.Name = "labelAssemblerRank"; + labelAssemblerRank.Size = new Size(94, 32); + labelAssemblerRank.TabIndex = 2; + labelAssemblerRank.Text = "Разряд:"; + // + // comboBoxAssemblerRank + // + comboBoxAssemblerRank.FormattingEnabled = true; + comboBoxAssemblerRank.Location = new Point(278, 198); + comboBoxAssemblerRank.Name = "comboBoxAssemblerRank"; + comboBoxAssemblerRank.Size = new Size(324, 40); + comboBoxAssemblerRank.TabIndex = 3; + // + // labelWorkExperience + // + labelWorkExperience.AutoSize = true; + labelWorkExperience.Location = new Point(59, 349); + labelWorkExperience.Name = "labelWorkExperience"; + labelWorkExperience.Size = new Size(162, 32); + labelWorkExperience.TabIndex = 4; + labelWorkExperience.Text = "Стаж работы:"; + // + // dateTimePickerWorkExperience + // + dateTimePickerWorkExperience.Location = new Point(278, 344); + dateTimePickerWorkExperience.Name = "dateTimePickerWorkExperience"; + dateTimePickerWorkExperience.Size = new Size(324, 39); + dateTimePickerWorkExperience.TabIndex = 5; + // + // buttonSave + // + buttonSave.Location = new Point(87, 505); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(150, 46); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(387, 505); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(150, 46); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormAssembler + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(636, 623); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(dateTimePickerWorkExperience); + Controls.Add(labelWorkExperience); + Controls.Add(comboBoxAssemblerRank); + Controls.Add(labelAssemblerRank); + Controls.Add(textBoxFullName); + Controls.Add(labelFullName); + Name = "FormAssembler"; + Text = "Сборщик"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelFullName; + private TextBox textBoxFullName; + private Label labelAssemblerRank; + private ComboBox comboBoxAssemblerRank; + private Label labelWorkExperience; + private DateTimePicker dateTimePickerWorkExperience; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembler.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembler.cs new file mode 100644 index 0000000..27a584c --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembler.cs @@ -0,0 +1,89 @@ +using ProjectWorkshop.Entities; +using ProjectWorkshop.Entities.Enums; +using ProjectWorkshop.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; + +namespace ProjectWorkshop.Forms +{ + public partial class FormAssembler : Form + { + private readonly IAssemblerRepository _assemblerRepository; + + private int? _assemblerID; + + public int Id + { + set + { + try + { + var assembler = _assemblerRepository.ReadAssemblerByID(value); + if (assembler == null) + { + throw new InvalidDataException(nameof(assembler)); + } + _assemblerID = assembler.ID; + textBoxFullName.Text = assembler.FullName; + comboBoxAssemblerRank.SelectedItem = assembler.AssemblerRank; + dateTimePickerWorkExperience.Value = assembler.WorkExperience; + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormAssembler(IAssemblerRepository assemblerRepository) + { + InitializeComponent(); + comboBoxAssemblerRank.DataSource = Enum.GetValues(typeof(AssemblerRank)); + _assemblerRepository = assemblerRepository ?? + throw new ArgumentNullException(nameof(assemblerRepository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrEmpty(textBoxFullName.Text)) + { + throw new Exception("Имеется незаполненное поле"); + } + + if (_assemblerID.HasValue) + { + _assemblerRepository.UpdateAssembler(CreateAssembler(_assemblerID.Value)); + } + else + { + _assemblerRepository.CreateAssembler(CreateAssembler(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + Close(); + } + + private Assembler CreateAssembler(int id) => Assembler.CreateEntity(id, + textBoxFullName.Text, (AssemblerRank)comboBoxAssemblerRank.SelectedItem!, dateTimePickerWorkExperience.Value); + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Form1.resx b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembler.resx similarity index 92% rename from ProjectWorkshop/ProjectWorkshop/Form1.resx rename to ProjectWorkshop/ProjectWorkshop/Forms/FormAssembler.resx index 1af7de1..8b2ff64 100644 --- a/ProjectWorkshop/ProjectWorkshop/Form1.resx +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembler.resx @@ -1,17 +1,17 @@  - diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShift.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShift.Designer.cs new file mode 100644 index 0000000..3c4842f --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShift.Designer.cs @@ -0,0 +1,143 @@ +namespace ProjectWorkshop.Forms +{ + partial class FormAssemblerShift + { + /// + /// 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() + { + labelWorkHours = new Label(); + numericUpDownWorkHours = new NumericUpDown(); + labelAssembler = new Label(); + labelShiftDate = new Label(); + comboBoxAssembler = new ComboBox(); + comboBoxShiftDate = new ComboBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWorkHours).BeginInit(); + SuspendLayout(); + // + // labelWorkHours + // + labelWorkHours.AutoSize = true; + labelWorkHours.Location = new Point(64, 76); + labelWorkHours.Name = "labelWorkHours"; + labelWorkHours.Size = new Size(216, 32); + labelWorkHours.TabIndex = 0; + labelWorkHours.Text = "Отработать часов:"; + // + // numericUpDownWorkHours + // + numericUpDownWorkHours.Location = new Point(370, 74); + numericUpDownWorkHours.Name = "numericUpDownWorkHours"; + numericUpDownWorkHours.Size = new Size(298, 39); + numericUpDownWorkHours.TabIndex = 1; + // + // labelAssembler + // + labelAssembler.AutoSize = true; + labelAssembler.Location = new Point(99, 193); + labelAssembler.Name = "labelAssembler"; + labelAssembler.Size = new Size(122, 32); + labelAssembler.TabIndex = 2; + labelAssembler.Text = "Сборщик:"; + // + // labelShiftDate + // + labelShiftDate.AutoSize = true; + labelShiftDate.Location = new Point(79, 308); + labelShiftDate.Name = "labelShiftDate"; + labelShiftDate.Size = new Size(157, 32); + labelShiftDate.TabIndex = 3; + labelShiftDate.Text = "Дата выхода:"; + // + // comboBoxAssembler + // + comboBoxAssembler.FormattingEnabled = true; + comboBoxAssembler.Location = new Point(370, 193); + comboBoxAssembler.Name = "comboBoxAssembler"; + comboBoxAssembler.Size = new Size(298, 40); + comboBoxAssembler.TabIndex = 4; + // + // comboBoxShiftDate + // + comboBoxShiftDate.FormattingEnabled = true; + comboBoxShiftDate.Location = new Point(370, 308); + comboBoxShiftDate.Name = "comboBoxShiftDate"; + comboBoxShiftDate.Size = new Size(298, 40); + comboBoxShiftDate.TabIndex = 5; + // + // buttonSave + // + buttonSave.Location = new Point(99, 477); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(150, 46); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(432, 477); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(150, 46); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormAssemblerShift + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(755, 621); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(comboBoxShiftDate); + Controls.Add(comboBoxAssembler); + Controls.Add(labelShiftDate); + Controls.Add(labelAssembler); + Controls.Add(numericUpDownWorkHours); + Controls.Add(labelWorkHours); + Name = "FormAssemblerShift"; + Text = "Выход на смену"; + ((System.ComponentModel.ISupportInitialize)numericUpDownWorkHours).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelWorkHours; + private NumericUpDown numericUpDownWorkHours; + private Label labelAssembler; + private Label labelShiftDate; + private ComboBox comboBoxAssembler; + private ComboBox comboBoxShiftDate; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShift.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShift.cs new file mode 100644 index 0000000..02c30d3 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShift.cs @@ -0,0 +1,66 @@ +using ProjectWorkshop.Entities; +using ProjectWorkshop.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; + +namespace ProjectWorkshop.Forms +{ + public partial class FormAssemblerShift : Form + { + private readonly IAssemblerShiftRepository _assemblerShiftRepository; + + public FormAssemblerShift(IAssemblerShiftRepository assemblerShiftRepository, IShiftRepository shiftRepository, + IAssemblerRepository assemblerRepository) + { + InitializeComponent(); + _assemblerShiftRepository = assemblerShiftRepository ?? + throw new ArgumentNullException(nameof(assemblerShiftRepository)); + + numericUpDownWorkHours.Value = 1; + + comboBoxAssembler.DataSource = assemblerRepository.ReadAssemblers(); + comboBoxAssembler.DisplayMember = "FullName"; + comboBoxAssembler.ValueMember = "ID"; + + comboBoxShiftDate.DataSource = shiftRepository.ReadShifts().ToList(); + comboBoxShiftDate.DisplayMember = "ShiftDate"; + comboBoxShiftDate.ValueMember = "ID"; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (numericUpDownWorkHours.Value < 1 || comboBoxAssembler.SelectedIndex < 0 || comboBoxShiftDate.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + var assemblerShift = AssemblerShift.CreateOperation(0, + (int)numericUpDownWorkHours.Value, + (int)comboBoxAssembler.SelectedValue!, + (int)comboBoxShiftDate.SelectedValue!); + + _assemblerShiftRepository.CreateAssemblerShift(assemblerShift); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + Close(); + } + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShift.resx b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShift.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShift.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.Designer.cs new file mode 100644 index 0000000..de46933 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.Designer.cs @@ -0,0 +1,98 @@ +namespace ProjectWorkshop.Forms +{ + partial class FormAssemblerShifts + { + /// + /// 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() + { + panel = new Panel(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(1081, 0); + panel.Name = "panel"; + panel.Size = new Size(265, 783); + panel.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.plus; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(65, 47); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(152, 145); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 82; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(1081, 783); + dataGridView.TabIndex = 1; + // + // FormAssemblerShifts + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1346, 783); + Controls.Add(dataGridView); + Controls.Add(panel); + Name = "FormAssemblerShifts"; + Text = "Выходы на смену"; + Load += FormAssemblerShifts_Load; + panel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.cs new file mode 100644 index 0000000..f8eb37c --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.cs @@ -0,0 +1,54 @@ +using ProjectWorkshop.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 ProjectWorkshop.Forms +{ + public partial class FormAssemblerShifts : Form + { + private readonly IUnityContainer _container; + + private readonly IAssemblerShiftRepository _assemblerShiftRepository; + public FormAssemblerShifts(IUnityContainer container, IAssemblerShiftRepository assemblerShiftRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _assemblerShiftRepository = assemblerShiftRepository ?? + throw new ArgumentNullException(nameof(assemblerShiftRepository)); + } + private void FormAssemblerShifts_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 LoadList() => dataGridView.DataSource = _assemblerShiftRepository.ReadAssemblerShifts(); + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.resx b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.Designer.cs new file mode 100644 index 0000000..103c281 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.Designer.cs @@ -0,0 +1,127 @@ +namespace ProjectWorkshop.Forms +{ + partial class FormAssemblers + { + /// + /// 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() + { + panel = new Panel(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(buttonDel); + panel.Controls.Add(buttonUpd); + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(1279, 0); + panel.Name = "panel"; + panel.Size = new Size(313, 850); + panel.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.minus; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(83, 479); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(150, 145); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.pencil; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(83, 255); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(150, 145); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.plus; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(83, 39); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(150, 145); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 82; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(1279, 850); + dataGridView.TabIndex = 1; + // + // FormAssemblers + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1592, 850); + Controls.Add(dataGridView); + Controls.Add(panel); + Name = "FormAssemblers"; + StartPosition = FormStartPosition.CenterParent; + Text = "Сборщики"; + Load += FormAssemblers_Load; + panel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.cs new file mode 100644 index 0000000..a4ad521 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.cs @@ -0,0 +1,115 @@ +using ProjectWorkshop.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 ProjectWorkshop.Forms +{ + public partial class FormAssemblers : Form + { + private readonly IUnityContainer _container; + + private readonly IAssemblerRepository _assemblerRepository; + + public FormAssemblers(IUnityContainer container, IAssemblerRepository assemblerRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _assemblerRepository = assemblerRepository ?? + throw new ArgumentNullException(nameof(assemblerRepository)); + } + + private void FormAssemblers_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 + { + _assemblerRepository.DeleteAssembler(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _assemblerRepository.ReadAssemblers(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value); + return true; + } + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.resx b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.Designer.cs new file mode 100644 index 0000000..a321a64 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.Designer.cs @@ -0,0 +1,112 @@ +namespace ProjectWorkshop.Forms +{ + partial class FormAssemblies + { + /// + /// 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() + { + panel = new Panel(); + buttonDel = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(buttonDel); + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(1062, 0); + panel.Name = "panel"; + panel.Size = new Size(279, 798); + panel.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.minus; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(67, 305); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(150, 151); + buttonDel.TabIndex = 1; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.plus; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(67, 40); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(150, 151); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 82; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(1062, 798); + dataGridView.TabIndex = 1; + // + // FormAssemblies + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1341, 798); + Controls.Add(dataGridView); + Controls.Add(panel); + Name = "FormAssemblies"; + Text = "Сборки"; + Load += FormAssemblies_Load; + panel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private Button buttonDel; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.cs new file mode 100644 index 0000000..ea78441 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.cs @@ -0,0 +1,93 @@ +using ProjectWorkshop.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 ProjectWorkshop.Forms +{ + public partial class FormAssemblies : Form + { + private readonly IUnityContainer _container; + + private readonly IAssemblyRepository _assemblyRepository; + public FormAssemblies(IUnityContainer container, IAssemblyRepository assemblyRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _assemblyRepository = assemblyRepository ?? + throw new ArgumentNullException(nameof(assemblyRepository)); + } + + private void FormAssemblies_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 + { + _assemblyRepository.DeleteAssembly(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _assemblyRepository.ReadAssemblies(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value); + return true; + } + + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.resx b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembly.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembly.Designer.cs new file mode 100644 index 0000000..f58fa09 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembly.Designer.cs @@ -0,0 +1,149 @@ +namespace ProjectWorkshop.Forms +{ + partial class FormAssembly + { + /// + /// 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() + { + labelAssembler = new Label(); + comboBoxAssembler = new ComboBox(); + groupBox = new GroupBox(); + dataGridViewAssemblies = new DataGridView(); + ColumnProductName = new DataGridViewComboBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); + buttonSave = new Button(); + buttonCancel = new Button(); + groupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewAssemblies).BeginInit(); + SuspendLayout(); + // + // labelAssembler + // + labelAssembler.AutoSize = true; + labelAssembler.Location = new Point(50, 71); + labelAssembler.Name = "labelAssembler"; + labelAssembler.Size = new Size(122, 32); + labelAssembler.TabIndex = 0; + labelAssembler.Text = "Сборщик:"; + // + // comboBoxAssembler + // + comboBoxAssembler.FormattingEnabled = true; + comboBoxAssembler.Location = new Point(242, 71); + comboBoxAssembler.Name = "comboBoxAssembler"; + comboBoxAssembler.Size = new Size(386, 40); + comboBoxAssembler.TabIndex = 1; + // + // groupBox + // + groupBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBox.Controls.Add(dataGridViewAssemblies); + groupBox.Location = new Point(50, 160); + groupBox.Name = "groupBox"; + groupBox.Size = new Size(618, 591); + groupBox.TabIndex = 2; + groupBox.TabStop = false; + // + // dataGridViewAssemblies + // + dataGridViewAssemblies.AllowUserToResizeColumns = false; + dataGridViewAssemblies.AllowUserToResizeRows = false; + dataGridViewAssemblies.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewAssemblies.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewAssemblies.Columns.AddRange(new DataGridViewColumn[] { ColumnProductName, ColumnCount }); + dataGridViewAssemblies.Location = new Point(3, 35); + dataGridViewAssemblies.MultiSelect = false; + dataGridViewAssemblies.Name = "dataGridViewAssemblies"; + dataGridViewAssemblies.RowHeadersVisible = false; + dataGridViewAssemblies.RowHeadersWidth = 82; + dataGridViewAssemblies.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewAssemblies.Size = new Size(612, 553); + dataGridViewAssemblies.TabIndex = 0; + // + // ColumnProductName + // + ColumnProductName.HeaderText = "Название изделия"; + ColumnProductName.MinimumWidth = 10; + ColumnProductName.Name = "ColumnProductName"; + // + // ColumnCount + // + ColumnCount.HeaderText = "Количество"; + ColumnCount.MinimumWidth = 10; + ColumnCount.Name = "ColumnCount"; + // + // buttonSave + // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonSave.Location = new Point(82, 786); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(150, 46); + buttonSave.TabIndex = 3; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(464, 786); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(150, 46); + buttonCancel.TabIndex = 4; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormAssembly + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(715, 861); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(groupBox); + Controls.Add(comboBoxAssembler); + Controls.Add(labelAssembler); + Name = "FormAssembly"; + Text = "Сборка"; + groupBox.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewAssemblies).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelAssembler; + private ComboBox comboBoxAssembler; + private GroupBox groupBox; + private DataGridView dataGridViewAssemblies; + private DataGridViewComboBoxColumn ColumnProductName; + private DataGridViewTextBoxColumn ColumnCount; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembly.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembly.cs new file mode 100644 index 0000000..954eab9 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembly.cs @@ -0,0 +1,96 @@ +using ProjectWorkshop.Entities; +using ProjectWorkshop.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; + +namespace ProjectWorkshop.Forms +{ + public partial class FormAssembly : Form + { + private readonly IAssemblyRepository _assemblyRepository; + public FormAssembly(IAssemblyRepository assemblyRepository, IAssemblerRepository assemblerRepository, IProductRepository productRepository) + { + InitializeComponent(); + _assemblyRepository = assemblyRepository ?? throw new ArgumentNullException(nameof(assemblyRepository)); + + comboBoxAssembler.DataSource = assemblerRepository.ReadAssemblers(); + comboBoxAssembler.DisplayMember = "FullName"; + comboBoxAssembler.ValueMember = "ID"; + + var products = productRepository.ReadProducts() + .Select(p => new { p.ProductName, p.ID }) + .ToList(); + + ColumnProductName.DataSource = products; + ColumnProductName.DisplayMember = "ProductName"; + ColumnProductName.ValueMember = "ID"; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (dataGridViewAssemblies.RowCount < 1 || comboBoxAssembler.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + var productAssemblies = CreateListProductAssemblyFromDataGrid(); + + if (!productAssemblies.Any()) + { + throw new Exception("Добавьте хотя бы один продукт для сборки."); + } + + var totalCount = productAssemblies.Sum(pa => pa.Count); + + _assemblyRepository.CreateAssembly(Assembly.CreateOperation( + id: 0, + count: totalCount, + assemblerID: (int)comboBoxAssembler.SelectedValue!, + productAssembly: productAssemblies + )); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + Close(); + } + + private List CreateListProductAssemblyFromDataGrid() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridViewAssemblies.Rows) + { + if (row.Cells["ColumnProductName"].Value == null || row.Cells["ColumnCount"].Value == null) + { + continue; + } + + list.Add(ProductAssembly.CreateElement( + id: 0, + productID: Convert.ToInt32(row.Cells["ColumnProductName"].Value), + assemblyID: 0, + count: Convert.ToInt32(row.Cells["ColumnCount"].Value) + )); + + } + + return list; + } + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembly.resx b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembly.resx new file mode 100644 index 0000000..4c1a834 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssembly.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectWorkshop/ProjectWorkshop/Forms/FormProduct.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormProduct.Designer.cs new file mode 100644 index 0000000..22b0cde --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormProduct.Designer.cs @@ -0,0 +1,143 @@ +namespace ProjectWorkshop.Forms +{ + partial class FormProduct + { + /// + /// 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() + { + labelProductName = new Label(); + labelProductType = new Label(); + labelPrice = new Label(); + textBoxProductName = new TextBox(); + numericUpDownPrice = new NumericUpDown(); + checkedListBoxProductType = new CheckedListBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit(); + SuspendLayout(); + // + // labelProductName + // + labelProductName.AutoSize = true; + labelProductName.Location = new Point(52, 73); + labelProductName.Name = "labelProductName"; + labelProductName.Size = new Size(222, 32); + labelProductName.TabIndex = 0; + labelProductName.Text = "Название изделия:"; + // + // labelProductType + // + labelProductType.AutoSize = true; + labelProductType.Location = new Point(77, 431); + labelProductType.Name = "labelProductType"; + labelProductType.Size = new Size(157, 32); + labelProductType.TabIndex = 1; + labelProductType.Text = "Тип изделия:"; + // + // labelPrice + // + labelPrice.AutoSize = true; + labelPrice.Location = new Point(86, 226); + labelPrice.Name = "labelPrice"; + labelPrice.Size = new Size(136, 32); + labelPrice.TabIndex = 2; + labelPrice.Text = "Стоимость:"; + // + // textBoxProductName + // + textBoxProductName.Location = new Point(318, 73); + textBoxProductName.Name = "textBoxProductName"; + textBoxProductName.Size = new Size(332, 39); + textBoxProductName.TabIndex = 3; + // + // numericUpDownPrice + // + numericUpDownPrice.Location = new Point(318, 224); + numericUpDownPrice.Maximum = new decimal(new int[] { 1000000000, 0, 0, 0 }); + numericUpDownPrice.Name = "numericUpDownPrice"; + numericUpDownPrice.Size = new Size(332, 39); + numericUpDownPrice.TabIndex = 4; + // + // checkedListBoxProductType + // + checkedListBoxProductType.FormattingEnabled = true; + checkedListBoxProductType.Location = new Point(318, 361); + checkedListBoxProductType.Name = "checkedListBoxProductType"; + checkedListBoxProductType.Size = new Size(332, 184); + checkedListBoxProductType.TabIndex = 5; + // + // buttonSave + // + buttonSave.Location = new Point(110, 640); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(150, 46); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(426, 640); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(150, 46); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormProduct + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(729, 765); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(checkedListBoxProductType); + Controls.Add(numericUpDownPrice); + Controls.Add(textBoxProductName); + Controls.Add(labelPrice); + Controls.Add(labelProductType); + Controls.Add(labelProductName); + Name = "FormProduct"; + Text = "Изделие"; + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelProductName; + private Label labelProductType; + private Label labelPrice; + private TextBox textBoxProductName; + private NumericUpDown numericUpDownPrice; + private CheckedListBox checkedListBoxProductType; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormProduct.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormProduct.cs new file mode 100644 index 0000000..671ef0f --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormProduct.cs @@ -0,0 +1,123 @@ +using ProjectWorkshop.Entities; +using ProjectWorkshop.Entities.Enums; +using ProjectWorkshop.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; + +namespace ProjectWorkshop.Forms +{ + public partial class FormProduct : Form + { + private readonly IProductRepository _productRepository; + + private int? _productID; + + public int Id + { + set + { + try + { + var product = _productRepository.ReadProductByID(value); + if (product == null) + { + throw new InvalidDataException(nameof(product)); + } + + foreach (ProductType elem in Enum.GetValues(typeof(ProductType))) + { + if ((elem & product.ProductType) != 0) + { + checkedListBoxProductType.SetItemChecked(checkedListBoxProductType.Items.IndexOf(elem), true); + } + } + + textBoxProductName.Text = product.ProductName; + numericUpDownPrice.Value = (int)product.Price; + + _productID = value; + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormProduct(IProductRepository productRepository, IAssemblerRepository assemblerRepository) + { + InitializeComponent(); + _productRepository = productRepository ?? + throw new ArgumentNullException(nameof(productRepository)); + + + foreach (var elem in Enum.GetValues(typeof(ProductType))) + { + checkedListBoxProductType.Items.Add(elem); + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxProductName.Text) || checkedListBoxProductType.CheckedItems.Count == 0) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_productID.HasValue) + { + _productRepository.UpdateProduct(CreateProduct(_productID.Value)); + } + else + { + _productRepository.CreateProduct(CreateProduct(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + Close(); + } + + private Product CreateProduct(int id) + { + + ProductType productType = ProductType.None; + + foreach (var elem in checkedListBoxProductType.CheckedItems) + { + productType |= (ProductType)elem; + } + + if (string.IsNullOrEmpty(textBoxProductName.Text)) + { + throw new Exception("Название продукта не может быть пустым"); + } + + + return Product.CreateEntity( + id, + textBoxProductName.Text, + Convert.ToDouble(numericUpDownPrice.Value), + productType + ); + } + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormProduct.resx b/ProjectWorkshop/ProjectWorkshop/Forms/FormProduct.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormProduct.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.Designer.cs new file mode 100644 index 0000000..c41838c --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.Designer.cs @@ -0,0 +1,126 @@ +namespace ProjectWorkshop.Forms +{ + partial class FormProducts + { + /// + /// 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() + { + panel = new Panel(); + buttonUpd = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + buttonDel = new Button(); + panel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(buttonDel); + panel.Controls.Add(buttonUpd); + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(903, 0); + panel.Name = "panel"; + panel.Size = new Size(257, 757); + panel.TabIndex = 0; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.pencil; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(53, 288); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(150, 151); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.plus; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(55, 50); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(150, 151); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 82; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(903, 757); + dataGridView.TabIndex = 1; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.pencil; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(53, 535); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(150, 151); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // FormProducts + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1160, 757); + Controls.Add(dataGridView); + Controls.Add(panel); + Name = "FormProducts"; + Text = "Изделия"; + Load += FormProducts_Load; + panel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridView; + private Button buttonDel; + } +} \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.cs new file mode 100644 index 0000000..14aea98 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.cs @@ -0,0 +1,111 @@ +using ProjectWorkshop.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 ProjectWorkshop.Forms +{ + public partial class FormProducts : Form + { + private readonly IUnityContainer _container; + + private readonly IProductRepository _productRepository; + public FormProducts(IUnityContainer container, IProductRepository productRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _productRepository = productRepository ?? + throw new ArgumentNullException(nameof(productRepository)); + } + + private void FormProducts_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 + { + _productRepository.DeleteProduct(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _productRepository.ReadProducts(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value); + return true; + } + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.resx b/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectWorkshop/ProjectWorkshop/Forms/FormShift.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormShift.Designer.cs new file mode 100644 index 0000000..10a3623 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormShift.Designer.cs @@ -0,0 +1,95 @@ +namespace ProjectWorkshop.Forms +{ + partial class FormShift + { + /// + /// 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() + { + labelShiftDate = new Label(); + dateTimePickerShiftDate = new DateTimePicker(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelShiftDate + // + labelShiftDate.AutoSize = true; + labelShiftDate.Location = new Point(57, 166); + labelShiftDate.Name = "labelShiftDate"; + labelShiftDate.Size = new Size(264, 32); + labelShiftDate.TabIndex = 0; + labelShiftDate.Text = "Дата выхода на смену:"; + // + // dateTimePickerShiftDate + // + dateTimePickerShiftDate.Location = new Point(358, 166); + dateTimePickerShiftDate.Name = "dateTimePickerShiftDate"; + dateTimePickerShiftDate.Size = new Size(400, 39); + dateTimePickerShiftDate.TabIndex = 1; + // + // buttonSave + // + buttonSave.Location = new Point(114, 317); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(150, 46); + buttonSave.TabIndex = 2; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(484, 317); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(150, 46); + buttonCancel.TabIndex = 3; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormShift + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(dateTimePickerShiftDate); + Controls.Add(labelShiftDate); + Name = "FormShift"; + Text = "Смена"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelShiftDate; + private DateTimePicker dateTimePickerShiftDate; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormShift.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormShift.cs new file mode 100644 index 0000000..9f88269 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormShift.cs @@ -0,0 +1,78 @@ +using ProjectWorkshop.Entities; +using ProjectWorkshop.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; + +namespace ProjectWorkshop.Forms +{ + public partial class FormShift : Form + { + private readonly IShiftRepository _shiftRepository; + + private int? _shiftID; + + public int Id + { + set + { + try + { + var shift = _shiftRepository.ReadShiftByID(value); + if (shift == null) + { + throw new InvalidOperationException(nameof(shift)); + } + _shiftID = shift.ID; + dateTimePickerShiftDate.Value = shift.ShiftDate; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormShift(IShiftRepository shiftRepository) + { + InitializeComponent(); + _shiftRepository = shiftRepository ?? + throw new ArgumentNullException(nameof(shiftRepository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (_shiftID.HasValue) + { + _shiftRepository.UpdateShift(CreateShift(_shiftID.Value)); + } + else + { + _shiftRepository.CreateShift(CreateShift(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + Close(); + } + + private Shift CreateShift(int id) => Shift.CreateEntity(id, dateTimePickerShiftDate.Value); + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormShift.resx b/ProjectWorkshop/ProjectWorkshop/Forms/FormShift.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormShift.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.Designer.cs new file mode 100644 index 0000000..527039e --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.Designer.cs @@ -0,0 +1,95 @@ +namespace ProjectWorkshop.Forms +{ + partial class FormShifts + { + /// + /// 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() + { + panel = new Panel(); + buttonAdd = new Button(); + dataGridViewShifts = new DataGridView(); + panel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewShifts).BeginInit(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(962, 0); + panel.Name = "panel"; + panel.Size = new Size(326, 768); + panel.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.plus; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(93, 59); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(150, 151); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewShifts + // + dataGridViewShifts.AllowUserToResizeColumns = false; + dataGridViewShifts.AllowUserToResizeRows = false; + dataGridViewShifts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewShifts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewShifts.Dock = DockStyle.Fill; + dataGridViewShifts.Location = new Point(0, 0); + dataGridViewShifts.MultiSelect = false; + dataGridViewShifts.Name = "dataGridViewShifts"; + dataGridViewShifts.ReadOnly = true; + dataGridViewShifts.RowHeadersVisible = false; + dataGridViewShifts.RowHeadersWidth = 82; + dataGridViewShifts.Size = new Size(962, 768); + dataGridViewShifts.TabIndex = 1; + // + // FormShifts + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1288, 768); + Controls.Add(dataGridViewShifts); + Controls.Add(panel); + Name = "FormShifts"; + Text = "Смены"; + Load += FormShifts_Load; + panel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewShifts).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private Button buttonAdd; + private DataGridView dataGridViewShifts; + } +} \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.cs new file mode 100644 index 0000000..4e46211 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.cs @@ -0,0 +1,54 @@ +using ProjectWorkshop.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 ProjectWorkshop.Forms +{ + public partial class FormShifts : Form + { + private readonly IUnityContainer _container; + + private readonly IShiftRepository _shiftRepository; + public FormShifts(IUnityContainer container, IShiftRepository shiftRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _shiftRepository = shiftRepository ?? throw new ArgumentNullException(nameof(shiftRepository)); + } + + private void FormShifts_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 LoadList() => dataGridViewShifts.DataSource = _shiftRepository.ReadShifts(); + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.resx b/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectWorkshop/ProjectWorkshop/Program.cs b/ProjectWorkshop/ProjectWorkshop/Program.cs index d478315..b9b1494 100644 --- a/ProjectWorkshop/ProjectWorkshop/Program.cs +++ b/ProjectWorkshop/ProjectWorkshop/Program.cs @@ -1,3 +1,7 @@ +using ProjectWorkshop.Repositories.Implementations; +using ProjectWorkshop.Repositories; +using Unity; + namespace ProjectWorkshop { internal static class Program @@ -11,7 +15,21 @@ namespace ProjectWorkshop // To customize application configuration such as set high DPI settings 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(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + + return container; } } } \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/ProjectWorkshop.csproj b/ProjectWorkshop/ProjectWorkshop/ProjectWorkshop.csproj index 663fdb8..dd71423 100644 --- a/ProjectWorkshop/ProjectWorkshop/ProjectWorkshop.csproj +++ b/ProjectWorkshop/ProjectWorkshop/ProjectWorkshop.csproj @@ -8,4 +8,27 @@ enable + + + + + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Properties/Resources.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Properties/Resources.Designer.cs new file mode 100644 index 0000000..be135b7 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectWorkshop.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("ProjectWorkshop.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 minus { + get { + object obj = ResourceManager.GetObject("minus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap pencil { + get { + object obj = ResourceManager.GetObject("pencil", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap plus { + get { + object obj = ResourceManager.GetObject("plus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap цех { + get { + object obj = ResourceManager.GetObject("цех", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Properties/Resources.resx b/ProjectWorkshop/ProjectWorkshop/Properties/Resources.resx new file mode 100644 index 0000000..b28c4f7 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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\minus.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\цех.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\plus.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\pencil.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Repositories/IAssemblerRepository.cs b/ProjectWorkshop/ProjectWorkshop/Repositories/IAssemblerRepository.cs new file mode 100644 index 0000000..6b113fb --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Repositories/IAssemblerRepository.cs @@ -0,0 +1,16 @@ +using ProjectWorkshop.Entities; + +namespace ProjectWorkshop.Repositories; + +public interface IAssemblerRepository +{ + IEnumerable ReadAssemblers(); + + Assembler ReadAssemblerByID(int id); + + void CreateAssembler(Assembler assembler); + + void UpdateAssembler(Assembler assembler); + + void DeleteAssembler(int id); +} diff --git a/ProjectWorkshop/ProjectWorkshop/Repositories/IAssemblerShiftRepository.cs b/ProjectWorkshop/ProjectWorkshop/Repositories/IAssemblerShiftRepository.cs new file mode 100644 index 0000000..d923e13 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Repositories/IAssemblerShiftRepository.cs @@ -0,0 +1,9 @@ +using ProjectWorkshop.Entities; +namespace ProjectWorkshop.Repositories; + +public interface IAssemblerShiftRepository +{ + IEnumerable ReadAssemblerShifts(int? workHours = null, int? assemblerID = null, int? shiftID = null); + + void CreateAssemblerShift(AssemblerShift assemblerShift); +} diff --git a/ProjectWorkshop/ProjectWorkshop/Repositories/IAssemblyRepository.cs b/ProjectWorkshop/ProjectWorkshop/Repositories/IAssemblyRepository.cs new file mode 100644 index 0000000..fb61dce --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Repositories/IAssemblyRepository.cs @@ -0,0 +1,12 @@ +using ProjectWorkshop.Entities; +namespace ProjectWorkshop.Repositories; + +public interface IAssemblyRepository +{ + IEnumerable ReadAssemblies(int? productID = null, int? assemblyID = null, int? count = null); + + void CreateAssembly(Assembly assembly); + + void DeleteAssembly(int id); + +} diff --git a/ProjectWorkshop/ProjectWorkshop/Repositories/IProductAssemblyRepository.cs b/ProjectWorkshop/ProjectWorkshop/Repositories/IProductAssemblyRepository.cs new file mode 100644 index 0000000..295580c --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Repositories/IProductAssemblyRepository.cs @@ -0,0 +1,15 @@ +using ProjectWorkshop.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectWorkshop.Repositories; + +public interface IProductAssemblyRepository +{ + void CreateProductAssembly(ProductAssembly productAssembly); + + void DeleteProductAssembly(int id); +} diff --git a/ProjectWorkshop/ProjectWorkshop/Repositories/IProductRepository.cs b/ProjectWorkshop/ProjectWorkshop/Repositories/IProductRepository.cs new file mode 100644 index 0000000..d69b496 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Repositories/IProductRepository.cs @@ -0,0 +1,15 @@ +using ProjectWorkshop.Entities; +namespace ProjectWorkshop.Repositories; + +public interface IProductRepository +{ + IEnumerable ReadProducts(); + + Product ReadProductByID(int id); + + void CreateProduct(Product product); + + void UpdateProduct(Product product); + + void DeleteProduct(int id); +} diff --git a/ProjectWorkshop/ProjectWorkshop/Repositories/IShiftRepository.cs b/ProjectWorkshop/ProjectWorkshop/Repositories/IShiftRepository.cs new file mode 100644 index 0000000..775eaf1 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Repositories/IShiftRepository.cs @@ -0,0 +1,15 @@ +using ProjectWorkshop.Entities; +namespace ProjectWorkshop.Repositories; + +public interface IShiftRepository +{ + IEnumerable ReadShifts(); + + Shift ReadShiftByID(int id); + + void CreateShift(Shift shift); + + void UpdateShift(Shift shift); + + void DeleteShift(int id); +} diff --git a/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/AssemblerRepository.cs b/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/AssemblerRepository.cs new file mode 100644 index 0000000..b1cd3d1 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/AssemblerRepository.cs @@ -0,0 +1,33 @@ +using ProjectWorkshop.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectWorkshop.Repositories.Implementations; + +public class AssemblerRepository : IAssemblerRepository +{ + public void CreateAssembler(Assembler assembler) + { + } + + public void DeleteAssembler(int id) + { + } + + public Assembler ReadAssemblerByID(int id) + { + return Assembler.CreateEntity(0, string.Empty, Entities.Enums.AssemblerRank.None, DateTime.Now); + } + + public IEnumerable ReadAssemblers() + { + return []; + } + + public void UpdateAssembler(Assembler assembler) + { + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/AssemblerShiftRepository.cs b/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/AssemblerShiftRepository.cs new file mode 100644 index 0000000..70d25ea --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/AssemblerShiftRepository.cs @@ -0,0 +1,20 @@ +using ProjectWorkshop.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectWorkshop.Repositories.Implementations; + +public class AssemblerShiftRepository : IAssemblerShiftRepository +{ + public void CreateAssemblerShift(AssemblerShift assemblerShift) + { + } + + public IEnumerable ReadAssemblerShifts(int? workHours = null, int? assemblerID = null, int? shiftID = null) + { + return []; + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/AssemblyRepository.cs b/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/AssemblyRepository.cs new file mode 100644 index 0000000..02bc872 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/AssemblyRepository.cs @@ -0,0 +1,24 @@ +using ProjectWorkshop.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectWorkshop.Repositories.Implementations; + +public class AssemblyRepository : IAssemblyRepository +{ + public void CreateAssembly(Assembly assembly) + { + } + + public void DeleteAssembly(int id) + { + } + + public IEnumerable ReadAssemblies(int? productID = null, int? assemblyID = null, int? count = null) + { + return []; + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/ProductAssemblyRepository.cs b/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/ProductAssemblyRepository.cs new file mode 100644 index 0000000..6042cf2 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/ProductAssemblyRepository.cs @@ -0,0 +1,19 @@ +using ProjectWorkshop.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectWorkshop.Repositories.Implementations; + +internal class ProductAssemblyRepository : IProductAssemblyRepository +{ + public void CreateProductAssembly(ProductAssembly productAssembly) + { + } + + public void DeleteProductAssembly(int id) + { + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/ProductRepository.cs b/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/ProductRepository.cs new file mode 100644 index 0000000..fdeb4ee --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/ProductRepository.cs @@ -0,0 +1,34 @@ +using ProjectWorkshop.Entities; +using ProjectWorkshop.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectWorkshop.Repositories.Implementations; + +public class ProductRepository : IProductRepository +{ + public void CreateProduct(Product product) + { + } + + public void DeleteProduct(int id) + { + } + + public Product ReadProductByID(int id) + { + return Product.CreateEntity(0, string.Empty, 0, ProductType.None); + } + + public IEnumerable ReadProducts() + { + return []; + } + + public void UpdateProduct(Product product) + { + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/ShiftRepository.cs b/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/ShiftRepository.cs new file mode 100644 index 0000000..d0fe5c0 --- /dev/null +++ b/ProjectWorkshop/ProjectWorkshop/Repositories/Implementations/ShiftRepository.cs @@ -0,0 +1,33 @@ +using ProjectWorkshop.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectWorkshop.Repositories.Implementations; + +internal class ShiftRepository : IShiftRepository +{ + public void CreateShift(Shift shift) + { + } + + public void DeleteShift(int id) + { + } + + public Shift ReadShiftByID(int id) + { + return Shift.CreateEntity(0, DateTime.Now); + } + + public IEnumerable ReadShifts() + { + return []; + } + + public void UpdateShift(Shift shift) + { + } +} diff --git a/ProjectWorkshop/ProjectWorkshop/Resources/minus.jpg b/ProjectWorkshop/ProjectWorkshop/Resources/minus.jpg new file mode 100644 index 0000000..54d42a0 Binary files /dev/null and b/ProjectWorkshop/ProjectWorkshop/Resources/minus.jpg differ diff --git a/ProjectWorkshop/ProjectWorkshop/Resources/minus1.jpg b/ProjectWorkshop/ProjectWorkshop/Resources/minus1.jpg new file mode 100644 index 0000000..54d42a0 Binary files /dev/null and b/ProjectWorkshop/ProjectWorkshop/Resources/minus1.jpg differ diff --git a/ProjectWorkshop/ProjectWorkshop/Resources/pencil.jpg b/ProjectWorkshop/ProjectWorkshop/Resources/pencil.jpg new file mode 100644 index 0000000..734f22d Binary files /dev/null and b/ProjectWorkshop/ProjectWorkshop/Resources/pencil.jpg differ diff --git a/ProjectWorkshop/ProjectWorkshop/Resources/pencil1.jpg b/ProjectWorkshop/ProjectWorkshop/Resources/pencil1.jpg new file mode 100644 index 0000000..734f22d Binary files /dev/null and b/ProjectWorkshop/ProjectWorkshop/Resources/pencil1.jpg differ diff --git a/ProjectWorkshop/ProjectWorkshop/Resources/plus.jpg b/ProjectWorkshop/ProjectWorkshop/Resources/plus.jpg new file mode 100644 index 0000000..0af22be Binary files /dev/null and b/ProjectWorkshop/ProjectWorkshop/Resources/plus.jpg differ diff --git a/ProjectWorkshop/ProjectWorkshop/Resources/plus1.jpg b/ProjectWorkshop/ProjectWorkshop/Resources/plus1.jpg new file mode 100644 index 0000000..0af22be Binary files /dev/null and b/ProjectWorkshop/ProjectWorkshop/Resources/plus1.jpg differ diff --git a/ProjectWorkshop/ProjectWorkshop/Resources/plus2.jpg b/ProjectWorkshop/ProjectWorkshop/Resources/plus2.jpg new file mode 100644 index 0000000..0af22be Binary files /dev/null and b/ProjectWorkshop/ProjectWorkshop/Resources/plus2.jpg differ diff --git a/ProjectWorkshop/ProjectWorkshop/Resources/цех.jpg b/ProjectWorkshop/ProjectWorkshop/Resources/цех.jpg new file mode 100644 index 0000000..784b635 Binary files /dev/null and b/ProjectWorkshop/ProjectWorkshop/Resources/цех.jpg differ