diff --git a/ProjectWarehouse/ProjectWarehouse/Entities/Components.cs b/ProjectWarehouse/ProjectWarehouse/Entities/Components.cs index 719c8c7..515d71c 100644 --- a/ProjectWarehouse/ProjectWarehouse/Entities/Components.cs +++ b/ProjectWarehouse/ProjectWarehouse/Entities/Components.cs @@ -12,9 +12,9 @@ public class Components public double Count { get; private set; } - public Type_Components TypeComponents { get; private set; } + public Type_Components TypeComponentsId { get; private set; } - public static Components CreateEntity(int id, string name, decimal price, double count, Type_Components typeComponents) + public static Components CreateEntity(int id, string name, decimal price, double count, Type_Components typeComponentsId) { return new Components { @@ -22,7 +22,7 @@ public class Components Name = name, Price = price, Count = count, - TypeComponents = typeComponents + TypeComponentsId = typeComponentsId }; } } diff --git a/ProjectWarehouse/ProjectWarehouse/Entities/Components_Production.cs b/ProjectWarehouse/ProjectWarehouse/Entities/Components_Production.cs index 4c2d194..8c7bd1d 100644 --- a/ProjectWarehouse/ProjectWarehouse/Entities/Components_Production.cs +++ b/ProjectWarehouse/ProjectWarehouse/Entities/Components_Production.cs @@ -4,7 +4,7 @@ public class Components_Production { public int Id { get; set; } - public int ComponentsID { get; private set; } + public int ComponentsId { get; private set; } public int Count { get; private set; } @@ -13,7 +13,7 @@ public class Components_Production return new Components_Production { Id = id, - ComponentsID = componentsID, + ComponentsId = componentsID, Count = count }; } diff --git a/ProjectWarehouse/ProjectWarehouse/Entities/Employee.cs b/ProjectWarehouse/ProjectWarehouse/Entities/Employee.cs index 7ae4259..cf86b31 100644 --- a/ProjectWarehouse/ProjectWarehouse/Entities/Employee.cs +++ b/ProjectWarehouse/ProjectWarehouse/Entities/Employee.cs @@ -10,7 +10,7 @@ public class Employee public string LastName { get; private set; } = string.Empty; - public EmployeePost EmployeePost { get; private set; } + public EmployeePost EmployeePostId { get; private set; } public static Employee CreateEntity(int id, string first, string last, EmployeePost employeePost) @@ -20,7 +20,7 @@ public class Employee Id = id, FirstName = first ?? string.Empty, LastName = last ?? string.Empty, - EmployeePost = employeePost + EmployeePostId = employeePost }; } } \ No newline at end of file diff --git a/ProjectWarehouse/ProjectWarehouse/Entities/Enums/Type_Components.cs b/ProjectWarehouse/ProjectWarehouse/Entities/Enums/Type_Components.cs index 7ebba29..876a538 100644 --- a/ProjectWarehouse/ProjectWarehouse/Entities/Enums/Type_Components.cs +++ b/ProjectWarehouse/ProjectWarehouse/Entities/Enums/Type_Components.cs @@ -2,25 +2,25 @@ public enum Type_Components { - Electronic = 0, + Electronic = 1, - Mechanical = 1, + Mechanical = 2, - Fasteners = 2, + Fasteners = 3, - Plastic = 3, + Plastic = 4, - Power_supply_and_cables = 4, + Power_supply_and_cables = 5, - Hydraulic_and_pneumatic = 5, + Hydraulic_and_pneumatic = 6, - Optical = 6, + Optical = 7, - Metals = 7, + Metals = 8, - Wood = 8, + Wood = 9, - Glass = 9, + Glass = 10, - Chemistry = 10 + Chemistry = 11 } \ No newline at end of file diff --git a/ProjectWarehouse/ProjectWarehouse/Entities/Inventory.cs b/ProjectWarehouse/ProjectWarehouse/Entities/Inventory.cs index b31ec12..9d3e519 100644 --- a/ProjectWarehouse/ProjectWarehouse/Entities/Inventory.cs +++ b/ProjectWarehouse/ProjectWarehouse/Entities/Inventory.cs @@ -8,7 +8,7 @@ public class Inventory public bool IsDefect { get; private set; } - public int ComponentsID { get; private set; } + public int ComponentsId { get; private set; } public static Inventory CreateEntity(int id, double quantity, bool isDefect, int ComponentsID) { @@ -17,7 +17,7 @@ public class Inventory Id = id, Quantity = quantity, IsDefect = isDefect, - ComponentsID = ComponentsID + ComponentsId = ComponentsID }; } } diff --git a/ProjectWarehouse/ProjectWarehouse/Forms/FormEmployee.cs b/ProjectWarehouse/ProjectWarehouse/Forms/FormEmployee.cs index e87fae9..8a4d95b 100644 --- a/ProjectWarehouse/ProjectWarehouse/Forms/FormEmployee.cs +++ b/ProjectWarehouse/ProjectWarehouse/Forms/FormEmployee.cs @@ -28,13 +28,12 @@ namespace ProjectWarehouse.Forms textBoxLastName.Text = employee.LastName; foreach (EmployeePost elem in Enum.GetValues(typeof(EmployeePost))) { - if ((elem & employee.EmployeePost) != 0) + if ((elem & employee.EmployeePostId) != 0) { checkedListBoxPost.SetItemChecked(checkedListBoxPost.Items.IndexOf(elem), true); } } - _employeeId = value; } catch (Exception ex) diff --git a/ProjectWarehouse/ProjectWarehouse/Forms/FormInventory.Designer.cs b/ProjectWarehouse/ProjectWarehouse/Forms/FormInventory.Designer.cs index a668457..d7669da 100644 --- a/ProjectWarehouse/ProjectWarehouse/Forms/FormInventory.Designer.cs +++ b/ProjectWarehouse/ProjectWarehouse/Forms/FormInventory.Designer.cs @@ -128,7 +128,6 @@ #endregion private Label labelComponent; - private Label label2; private Label labelCount; private ComboBox comboBoxComponent; private CheckBox checkBoxIsDefect; diff --git a/ProjectWarehouse/ProjectWarehouse/Forms/FormInventory.cs b/ProjectWarehouse/ProjectWarehouse/Forms/FormInventory.cs index 76f17ac..4ae4b16 100644 --- a/ProjectWarehouse/ProjectWarehouse/Forms/FormInventory.cs +++ b/ProjectWarehouse/ProjectWarehouse/Forms/FormInventory.cs @@ -24,7 +24,7 @@ namespace ProjectWarehouse.Forms throw new InvalidDataException(nameof(inventory)); } - comboBoxComponent.SelectedValue = inventory.ComponentsID; + comboBoxComponent.SelectedValue = inventory.ComponentsId; numericUpDownCount.Value = (decimal)inventory.Quantity; checkBoxIsDefect.Checked = inventory.IsDefect; diff --git a/ProjectWarehouse/ProjectWarehouse/Forms/FormProduction.Designer.cs b/ProjectWarehouse/ProjectWarehouse/Forms/FormProduction.Designer.cs index a42a9a5..3de2f06 100644 --- a/ProjectWarehouse/ProjectWarehouse/Forms/FormProduction.Designer.cs +++ b/ProjectWarehouse/ProjectWarehouse/Forms/FormProduction.Designer.cs @@ -38,7 +38,7 @@ comboBoxEmployee = new ComboBox(); groupBoxComponents = new GroupBox(); dataGridViewComponents = new DataGridView(); - ColumnComponent = new DataGridViewComboBoxColumn(); + ColumnComponents = new DataGridViewComboBoxColumn(); ColumnCount = new DataGridViewTextBoxColumn(); groupBoxComponents.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridViewComponents).BeginInit(); @@ -47,40 +47,43 @@ // labelName // labelName.AutoSize = true; - labelName.Location = new Point(38, 14); + labelName.Location = new Point(43, 19); labelName.Name = "labelName"; - labelName.Size = new Size(122, 15); + labelName.Size = new Size(157, 20); labelName.TabIndex = 0; labelName.Text = "Название продукции"; // // labelDescription // labelDescription.AutoSize = true; - labelDescription.Location = new Point(36, 58); + labelDescription.Location = new Point(41, 77); labelDescription.Name = "labelDescription"; - labelDescription.Size = new Size(125, 15); + labelDescription.Size = new Size(159, 20); labelDescription.TabIndex = 1; labelDescription.Text = "Описание продукции"; // // textBoxName // - textBoxName.Location = new Point(191, 14); + textBoxName.Location = new Point(218, 19); + textBoxName.Margin = new Padding(3, 4, 3, 4); textBoxName.Name = "textBoxName"; - textBoxName.Size = new Size(165, 23); + textBoxName.Size = new Size(188, 27); textBoxName.TabIndex = 2; // // textBoxDescription // - textBoxDescription.Location = new Point(191, 56); + textBoxDescription.Location = new Point(218, 75); + textBoxDescription.Margin = new Padding(3, 4, 3, 4); textBoxDescription.Name = "textBoxDescription"; - textBoxDescription.Size = new Size(165, 23); + textBoxDescription.Size = new Size(188, 27); textBoxDescription.TabIndex = 3; // // buttonSave // - buttonSave.Location = new Point(63, 380); + buttonSave.Location = new Point(72, 507); + buttonSave.Margin = new Padding(3, 4, 3, 4); buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(94, 23); + buttonSave.Size = new Size(107, 31); buttonSave.TabIndex = 4; buttonSave.Text = "Сохранить"; buttonSave.UseVisualStyleBackColor = true; @@ -88,9 +91,10 @@ // // buttonCancel // - buttonCancel.Location = new Point(260, 380); + buttonCancel.Location = new Point(297, 507); + buttonCancel.Margin = new Padding(3, 4, 3, 4); buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(75, 23); + buttonCancel.Size = new Size(86, 31); buttonCancel.TabIndex = 5; buttonCancel.Text = "Отмена"; buttonCancel.UseVisualStyleBackColor = true; @@ -99,9 +103,9 @@ // labelEmployee // labelEmployee.AutoSize = true; - labelEmployee.Location = new Point(63, 102); + labelEmployee.Location = new Point(72, 136); labelEmployee.Name = "labelEmployee"; - labelEmployee.Size = new Size(59, 15); + labelEmployee.Size = new Size(74, 20); labelEmployee.TabIndex = 8; labelEmployee.Text = "Работник"; // @@ -109,21 +113,18 @@ // comboBoxEmployee.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxEmployee.FormattingEnabled = true; - comboBoxEmployee.Location = new Point(192, 102); - comboBoxEmployee.Margin = new Padding(3, 2, 3, 2); + comboBoxEmployee.Location = new Point(219, 136); comboBoxEmployee.Name = "comboBoxEmployee"; - comboBoxEmployee.Size = new Size(164, 23); + comboBoxEmployee.Size = new Size(187, 28); comboBoxEmployee.TabIndex = 7; // // groupBoxComponents // groupBoxComponents.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; groupBoxComponents.Controls.Add(dataGridViewComponents); - groupBoxComponents.Location = new Point(23, 144); - groupBoxComponents.Margin = new Padding(3, 2, 3, 2); + groupBoxComponents.Location = new Point(26, 192); groupBoxComponents.Name = "groupBoxComponents"; - groupBoxComponents.Padding = new Padding(3, 2, 3, 2); - groupBoxComponents.Size = new Size(349, 220); + groupBoxComponents.Size = new Size(399, 293); groupBoxComponents.TabIndex = 6; groupBoxComponents.TabStop = false; groupBoxComponents.Text = "Комплектующие"; @@ -134,23 +135,22 @@ dataGridViewComponents.AllowUserToResizeRows = false; dataGridViewComponents.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridViewComponents.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridViewComponents.Columns.AddRange(new DataGridViewColumn[] { ColumnComponent, ColumnCount }); + dataGridViewComponents.Columns.AddRange(new DataGridViewColumn[] { ColumnComponents, ColumnCount }); dataGridViewComponents.Dock = DockStyle.Fill; - dataGridViewComponents.Location = new Point(3, 18); - dataGridViewComponents.Margin = new Padding(3, 2, 3, 2); + dataGridViewComponents.Location = new Point(3, 23); dataGridViewComponents.MultiSelect = false; dataGridViewComponents.Name = "dataGridViewComponents"; dataGridViewComponents.RowHeadersVisible = false; dataGridViewComponents.RowHeadersWidth = 51; dataGridViewComponents.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridViewComponents.Size = new Size(343, 200); + dataGridViewComponents.Size = new Size(393, 267); dataGridViewComponents.TabIndex = 0; // - // ColumnComponent + // ColumnComponents // - ColumnComponent.HeaderText = "Компонент"; - ColumnComponent.MinimumWidth = 6; - ColumnComponent.Name = "ColumnComponent"; + ColumnComponents.HeaderText = "Компонент"; + ColumnComponents.MinimumWidth = 6; + ColumnComponents.Name = "ColumnComponents"; // // ColumnCount // @@ -160,9 +160,9 @@ // // FormProduction // - AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(398, 415); + ClientSize = new Size(455, 553); Controls.Add(labelEmployee); Controls.Add(comboBoxEmployee); Controls.Add(groupBoxComponents); @@ -172,6 +172,7 @@ Controls.Add(textBoxName); Controls.Add(labelDescription); Controls.Add(labelName); + Margin = new Padding(3, 4, 3, 4); Name = "FormProduction"; StartPosition = FormStartPosition.CenterParent; Text = "Продукция"; @@ -193,7 +194,7 @@ private ComboBox comboBoxEmployee; private GroupBox groupBoxComponents; private DataGridView dataGridViewComponents; - private DataGridViewComboBoxColumn ColumnComponent; + private DataGridViewComboBoxColumn ColumnComponents; private DataGridViewTextBoxColumn ColumnCount; } } \ No newline at end of file diff --git a/ProjectWarehouse/ProjectWarehouse/Forms/FormProduction.cs b/ProjectWarehouse/ProjectWarehouse/Forms/FormProduction.cs index f17da82..28b9d40 100644 --- a/ProjectWarehouse/ProjectWarehouse/Forms/FormProduction.cs +++ b/ProjectWarehouse/ProjectWarehouse/Forms/FormProduction.cs @@ -9,30 +9,6 @@ namespace ProjectWarehouse.Forms private int? _productionId; - public int Id - { - set - { - try - { - var production = _productionRepository.ReadProductionByID(value); - if (production == null) - { - throw new InvalidDataException(nameof(production)); - } - - textBoxName.Text = production.Name; - textBoxDescription.Text = production.Description; - _productionId = value; - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - } - } - public FormProduction(IProductionRepository productionRepository, IEmployeeRepository employeeRepository, IComponentsRepository componentsRepository) { InitializeComponent(); @@ -43,29 +19,22 @@ namespace ProjectWarehouse.Forms comboBoxEmployee.DisplayMember = "FirstName"; comboBoxEmployee.ValueMember = "Id"; - ColumnComponent.DataSource = componentsRepository.ReadComponents(); - ColumnComponent.DisplayMember = "Name"; - ColumnComponent.ValueMember = "Id"; + ColumnComponents.DataSource = componentsRepository.ReadComponents(); + ColumnComponents.DisplayMember = "Name"; + ColumnComponents.ValueMember = "Id"; } private void ButtonSave_Click(object sender, EventArgs e) { try { - if (string.IsNullOrWhiteSpace(textBoxName.Text) || string.IsNullOrWhiteSpace(textBoxDescription.Text) || dataGridViewComponents.RowCount < 1 || comboBoxEmployee.SelectedIndex < 0) + if (string.IsNullOrWhiteSpace(textBoxName.Text) || dataGridViewComponents.RowCount < 1 || comboBoxEmployee.SelectedIndex < 0) { throw new Exception("Имеются незаполненные поля"); } - - if (_productionId.HasValue) - { - _productionRepository.UpdateProduction(CreateProduction(_productionId.Value)); - } - else - { - _productionRepository.CreateProduction(CreateProduction(0)); - } - + + _productionRepository.CreateProduction(Production.CreateEntity(0, textBoxName.Text, textBoxDescription.Text, (int)comboBoxEmployee.SelectedValue!, CreateListComponents_ProductionsFromDataGrid())); + Close(); } catch (Exception ex) @@ -92,8 +61,5 @@ namespace ProjectWarehouse.Forms } return list; } - - - private Production CreateProduction(int id) => Production.CreateEntity(id, textBoxName.Text, textBoxDescription.Text, (int)comboBoxEmployee.SelectedItem!, CreateListComponents_ProductionsFromDataGrid()); } } diff --git a/ProjectWarehouse/ProjectWarehouse/Forms/FormProduction.resx b/ProjectWarehouse/ProjectWarehouse/Forms/FormProduction.resx index 4793a9a..70a1261 100644 --- a/ProjectWarehouse/ProjectWarehouse/Forms/FormProduction.resx +++ b/ProjectWarehouse/ProjectWarehouse/Forms/FormProduction.resx @@ -1,7 +1,7 @@