diff --git a/ProjectWorkshop/Forms/FormAssemblies.cs b/ProjectWorkshop/Forms/FormAssemblies.cs index 69d8f97..16e9b3e 100644 --- a/ProjectWorkshop/Forms/FormAssemblies.cs +++ b/ProjectWorkshop/Forms/FormAssemblies.cs @@ -27,6 +27,18 @@ namespace ProjectWorkshop.Forms 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 @@ -83,10 +95,7 @@ namespace ProjectWorkshop.Forms } - private void FormAssemblies_Load(object sender, EventArgs e) - { - - } + private void LoadList() => dataGridView.DataSource = _assemblyRepository.ReadAssemblies(); diff --git a/ProjectWorkshop/Forms/FormAssesmblerShift.Designer.cs b/ProjectWorkshop/Forms/FormAssesmblerShift.Designer.cs index ddab37d..35be2fb 100644 --- a/ProjectWorkshop/Forms/FormAssesmblerShift.Designer.cs +++ b/ProjectWorkshop/Forms/FormAssesmblerShift.Designer.cs @@ -30,15 +30,13 @@ { labelWorkHours = new Label(); numericUpDownWorkHours = new NumericUpDown(); - groupBox = new GroupBox(); - dataGridViewAssemblerShift = new DataGridView(); - ColumnAssembler = new DataGridViewComboBoxColumn(); - ColumnShift = new DataGridViewComboBoxColumn(); buttonSave = new Button(); buttonCancel = new Button(); + comboBoxAssembler = new ComboBox(); + comboBoxShift = new ComboBox(); + labelAssembler = new Label(); + labelShift = new Label(); ((System.ComponentModel.ISupportInitialize)numericUpDownWorkHours).BeginInit(); - groupBox.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridViewAssemblerShift).BeginInit(); SuspendLayout(); // // labelWorkHours @@ -52,52 +50,15 @@ // // numericUpDownWorkHours // - numericUpDownWorkHours.Location = new Point(198, 31); + numericUpDownWorkHours.Location = new Point(190, 31); numericUpDownWorkHours.Name = "numericUpDownWorkHours"; - numericUpDownWorkHours.Size = new Size(113, 23); + numericUpDownWorkHours.Size = new Size(121, 23); numericUpDownWorkHours.TabIndex = 1; // - // groupBox - // - groupBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; - groupBox.Controls.Add(dataGridViewAssemblerShift); - groupBox.Location = new Point(35, 78); - groupBox.Name = "groupBox"; - groupBox.Size = new Size(280, 328); - groupBox.TabIndex = 3; - groupBox.TabStop = false; - groupBox.Text = "groupBox1"; - // - // dataGridViewAssemblerShift - // - dataGridViewAssemblerShift.AllowUserToResizeColumns = false; - dataGridViewAssemblerShift.AllowUserToResizeRows = false; - dataGridViewAssemblerShift.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridViewAssemblerShift.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridViewAssemblerShift.Columns.AddRange(new DataGridViewColumn[] { ColumnAssembler, ColumnShift }); - dataGridViewAssemblerShift.Dock = DockStyle.Fill; - dataGridViewAssemblerShift.Location = new Point(3, 19); - dataGridViewAssemblerShift.Name = "dataGridViewAssemblerShift"; - dataGridViewAssemblerShift.RowHeadersVisible = false; - dataGridViewAssemblerShift.Size = new Size(274, 306); - dataGridViewAssemblerShift.TabIndex = 3; - // - // ColumnAssembler - // - ColumnAssembler.HeaderText = "Сборщик"; - ColumnAssembler.Name = "ColumnAssembler"; - // - // ColumnShift - // - ColumnShift.HeaderText = "Смена"; - ColumnShift.Name = "ColumnShift"; - ColumnShift.Resizable = DataGridViewTriState.True; - ColumnShift.SortMode = DataGridViewColumnSortMode.Automatic; - // // buttonSave // buttonSave.Anchor = AnchorStyles.Bottom; - buttonSave.Location = new Point(53, 431); + buttonSave.Location = new Point(53, 216); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(75, 23); buttonSave.TabIndex = 4; @@ -108,7 +69,7 @@ // buttonCancel // buttonCancel.Anchor = AnchorStyles.Bottom; - buttonCancel.Location = new Point(220, 431); + buttonCancel.Location = new Point(220, 216); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(75, 23); buttonCancel.TabIndex = 5; @@ -116,21 +77,56 @@ buttonCancel.UseVisualStyleBackColor = true; buttonCancel.Click += ButtonCancel_Click; // + // comboBoxAssembler + // + comboBoxAssembler.FormattingEnabled = true; + comboBoxAssembler.Location = new Point(190, 92); + comboBoxAssembler.Name = "comboBoxAssembler"; + comboBoxAssembler.Size = new Size(121, 23); + comboBoxAssembler.TabIndex = 6; + // + // comboBoxShift + // + comboBoxShift.FormattingEnabled = true; + comboBoxShift.Location = new Point(190, 157); + comboBoxShift.Name = "comboBoxShift"; + comboBoxShift.Size = new Size(121, 23); + comboBoxShift.TabIndex = 7; + // + // labelAssembler + // + labelAssembler.AutoSize = true; + labelAssembler.Location = new Point(53, 95); + labelAssembler.Name = "labelAssembler"; + labelAssembler.Size = new Size(63, 15); + labelAssembler.TabIndex = 8; + labelAssembler.Text = "Сборщик:"; + // + // labelShift + // + labelShift.AutoSize = true; + labelShift.Location = new Point(70, 165); + labelShift.Name = "labelShift"; + labelShift.Size = new Size(46, 15); + labelShift.TabIndex = 9; + labelShift.Text = "Смена:"; + // // FormAssesmblerShift // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(355, 466); + ClientSize = new Size(355, 251); + Controls.Add(labelShift); + Controls.Add(labelAssembler); + Controls.Add(comboBoxShift); + Controls.Add(comboBoxAssembler); Controls.Add(buttonCancel); Controls.Add(buttonSave); - Controls.Add(groupBox); Controls.Add(numericUpDownWorkHours); Controls.Add(labelWorkHours); Name = "FormAssesmblerShift"; - Text = "Смена сборщика"; + Text = "Выход на смену"; ((System.ComponentModel.ISupportInitialize)numericUpDownWorkHours).EndInit(); - groupBox.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridViewAssemblerShift).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -139,11 +135,11 @@ private Label labelWorkHours; private NumericUpDown numericUpDownWorkHours; - private GroupBox groupBox; - private DataGridView dataGridViewAssemblerShift; - private DataGridViewComboBoxColumn ColumnAssembler; - private DataGridViewComboBoxColumn ColumnShift; private Button buttonSave; private Button buttonCancel; + private ComboBox comboBoxAssembler; + private ComboBox comboBoxShift; + private Label labelAssembler; + private Label labelShift; } } \ No newline at end of file diff --git a/ProjectWorkshop/Forms/FormAssesmblerShift.cs b/ProjectWorkshop/Forms/FormAssesmblerShift.cs index 1143232..8c9c80e 100644 --- a/ProjectWorkshop/Forms/FormAssesmblerShift.cs +++ b/ProjectWorkshop/Forms/FormAssesmblerShift.cs @@ -25,25 +25,25 @@ namespace ProjectWorkshop.Forms numericUpDownWorkHours.Value = 1; - ColumnAssembler.DataSource = assemblerRepository.ReadAssemblers(); - ColumnAssembler.DisplayMember = "FullName"; - ColumnAssembler.ValueMember = "Id"; + comboBoxAssembler.DataSource = assemblerRepository.ReadAssemblers(); + comboBoxAssembler.DisplayMember = "FullName"; + comboBoxAssembler.ValueMember = "Id"; - ColumnShift.DataSource = shiftRepository.ReadShifts(); - ColumnShift.DisplayMember = "Id"; - ColumnShift.ValueMember = "Id"; + comboBoxShift.DataSource = shiftRepository.ReadShifts(); + comboBoxShift.DisplayMember = "Id"; + comboBoxShift.ValueMember = "Id"; } private void ButtonSave_Click(object sender, EventArgs e) { try { - if (numericUpDownWorkHours.Value < 1 || dataGridViewAssemblerShift.RowCount < 1) + if (numericUpDownWorkHours.Value < 1 || comboBoxAssembler.SelectedIndex < 0 || comboBoxShift.SelectedIndex < 0) { throw new Exception("Имеются незаполненные поля"); } _assemblerShiftRepository.CreateAssemblerShift(AssemblerShift.CreateOperation((int)numericUpDownWorkHours.Value, - Convert.ToInt32(ColumnAssembler.ValueMember), Convert.ToInt32(ColumnShift.ValueMember))); + (int)comboBoxAssembler.SelectedValue!, (int)comboBoxShift.SelectedValue!)); Close(); } diff --git a/ProjectWorkshop/Forms/FormAssesmblerShift.resx b/ProjectWorkshop/Forms/FormAssesmblerShift.resx index 607f5ab..af32865 100644 --- a/ProjectWorkshop/Forms/FormAssesmblerShift.resx +++ b/ProjectWorkshop/Forms/FormAssesmblerShift.resx @@ -1,7 +1,7 @@