PIbd-21_Kudrinsky_O.S._LabWork_1 #1
@ -30,9 +30,9 @@
|
||||
{
|
||||
panel = new Panel();
|
||||
buttonAdd = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
dataGridViewAssemblerShifts = new DataGridView();
|
||||
panel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewAssemblerShifts).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel
|
||||
@ -55,37 +55,37 @@
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// dataGridView
|
||||
// dataGridViewAssemblerShifts
|
||||
//
|
||||
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;
|
||||
dataGridViewAssemblerShifts.AllowUserToAddRows = false;
|
||||
dataGridViewAssemblerShifts.AllowUserToDeleteRows = false;
|
||||
dataGridViewAssemblerShifts.AllowUserToResizeColumns = false;
|
||||
dataGridViewAssemblerShifts.AllowUserToResizeRows = false;
|
||||
dataGridViewAssemblerShifts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewAssemblerShifts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewAssemblerShifts.Dock = DockStyle.Fill;
|
||||
dataGridViewAssemblerShifts.Location = new Point(0, 0);
|
||||
dataGridViewAssemblerShifts.MultiSelect = false;
|
||||
dataGridViewAssemblerShifts.Name = "dataGridViewAssemblerShifts";
|
||||
dataGridViewAssemblerShifts.ReadOnly = true;
|
||||
dataGridViewAssemblerShifts.RowHeadersVisible = false;
|
||||
dataGridViewAssemblerShifts.RowHeadersWidth = 82;
|
||||
dataGridViewAssemblerShifts.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewAssemblerShifts.Size = new Size(1081, 783);
|
||||
dataGridViewAssemblerShifts.TabIndex = 1;
|
||||
//
|
||||
// FormAssemblerShifts
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1346, 783);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(dataGridViewAssemblerShifts);
|
||||
Controls.Add(panel);
|
||||
Name = "FormAssemblerShifts";
|
||||
Text = "Выходы на смену";
|
||||
Load += FormAssemblerShifts_Load;
|
||||
panel.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewAssemblerShifts).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
@ -93,6 +93,6 @@
|
||||
|
||||
private Panel panel;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridView;
|
||||
private DataGridView dataGridViewAssemblerShifts;
|
||||
}
|
||||
}
|
@ -49,6 +49,6 @@ namespace ProjectWorkshop.Forms
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() => dataGridView.DataSource = _assemblerShiftRepository.ReadAssemblerShifts();
|
||||
private void LoadList() => dataGridViewAssemblerShifts.DataSource = _assemblerShiftRepository.ReadAssemblerShifts();
|
||||
}
|
||||
}
|
||||
|
@ -32,9 +32,9 @@
|
||||
buttonDel = new Button();
|
||||
buttonUpd = new Button();
|
||||
buttonAdd = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
dataGridViewAssemblers = new DataGridView();
|
||||
panel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewAssemblers).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel
|
||||
@ -81,38 +81,38 @@
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// dataGridView
|
||||
// dataGridViewAssemblers
|
||||
//
|
||||
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;
|
||||
dataGridViewAssemblers.AllowUserToAddRows = false;
|
||||
dataGridViewAssemblers.AllowUserToDeleteRows = false;
|
||||
dataGridViewAssemblers.AllowUserToResizeColumns = false;
|
||||
dataGridViewAssemblers.AllowUserToResizeRows = false;
|
||||
dataGridViewAssemblers.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewAssemblers.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewAssemblers.Dock = DockStyle.Fill;
|
||||
dataGridViewAssemblers.Location = new Point(0, 0);
|
||||
dataGridViewAssemblers.MultiSelect = false;
|
||||
dataGridViewAssemblers.Name = "dataGridViewAssemblers";
|
||||
dataGridViewAssemblers.ReadOnly = true;
|
||||
dataGridViewAssemblers.RowHeadersVisible = false;
|
||||
dataGridViewAssemblers.RowHeadersWidth = 82;
|
||||
dataGridViewAssemblers.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewAssemblers.Size = new Size(1279, 850);
|
||||
dataGridViewAssemblers.TabIndex = 1;
|
||||
//
|
||||
// FormAssemblers
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1592, 850);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(dataGridViewAssemblers);
|
||||
Controls.Add(panel);
|
||||
Name = "FormAssemblers";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Сборщики";
|
||||
Load += FormAssemblers_Load;
|
||||
panel.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewAssemblers).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
@ -122,6 +122,6 @@
|
||||
private Button buttonDel;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridView;
|
||||
private DataGridView dataGridViewAssemblers;
|
||||
}
|
||||
}
|
@ -96,19 +96,19 @@ namespace ProjectWorkshop.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridView.DataSource = _assemblerRepository.ReadAssemblers();
|
||||
private void LoadList() => dataGridViewAssemblers.DataSource = _assemblerRepository.ReadAssemblers();
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridView.SelectedRows.Count < 1)
|
||||
if (dataGridViewAssemblers.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
|
||||
id = Convert.ToInt32(dataGridViewAssemblers.SelectedRows[0].Cells["ID"].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -31,9 +31,9 @@
|
||||
panel = new Panel();
|
||||
buttonDel = new Button();
|
||||
buttonAdd = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
dataGridViewAssemblies = new DataGridView();
|
||||
panel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewAssemblies).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel
|
||||
@ -68,37 +68,37 @@
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// dataGridView
|
||||
// dataGridViewAssemblies
|
||||
//
|
||||
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;
|
||||
dataGridViewAssemblies.AllowUserToAddRows = false;
|
||||
dataGridViewAssemblies.AllowUserToDeleteRows = false;
|
||||
dataGridViewAssemblies.AllowUserToResizeColumns = false;
|
||||
dataGridViewAssemblies.AllowUserToResizeRows = false;
|
||||
dataGridViewAssemblies.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewAssemblies.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewAssemblies.Dock = DockStyle.Fill;
|
||||
dataGridViewAssemblies.Location = new Point(0, 0);
|
||||
dataGridViewAssemblies.MultiSelect = false;
|
||||
dataGridViewAssemblies.Name = "dataGridViewAssemblies";
|
||||
dataGridViewAssemblies.ReadOnly = true;
|
||||
dataGridViewAssemblies.RowHeadersVisible = false;
|
||||
dataGridViewAssemblies.RowHeadersWidth = 82;
|
||||
dataGridViewAssemblies.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewAssemblies.Size = new Size(1062, 798);
|
||||
dataGridViewAssemblies.TabIndex = 1;
|
||||
//
|
||||
// FormAssemblies
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1341, 798);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(dataGridViewAssemblies);
|
||||
Controls.Add(panel);
|
||||
Name = "FormAssemblies";
|
||||
Text = "Сборки";
|
||||
Load += FormAssemblies_Load;
|
||||
panel.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewAssemblies).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
@ -107,6 +107,6 @@
|
||||
private Panel panel;
|
||||
private Button buttonDel;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridView;
|
||||
private DataGridView dataGridViewAssemblies;
|
||||
}
|
||||
}
|
@ -74,18 +74,18 @@ namespace ProjectWorkshop.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridView.DataSource = _assemblyRepository.ReadAssemblies();
|
||||
private void LoadList() => dataGridViewAssemblies.DataSource = _assemblyRepository.ReadAssemblies();
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridView.SelectedRows.Count < 1)
|
||||
if (dataGridViewAssemblies.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
|
||||
id = Convert.ToInt32(dataGridViewAssemblies.SelectedRows[0].Cells["ID"].Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -29,12 +29,12 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
panel = new Panel();
|
||||
buttonDel = new Button();
|
||||
buttonUpd = new Button();
|
||||
buttonAdd = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
buttonDel = new Button();
|
||||
dataGridViewProducts = new DataGridView();
|
||||
panel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewProducts).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel
|
||||
@ -48,6 +48,17 @@
|
||||
panel.Size = new Size(257, 757);
|
||||
panel.TabIndex = 0;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.BackgroundImage = Properties.Resources.minus;
|
||||
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;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.BackgroundImage = Properties.Resources.pencil;
|
||||
@ -70,48 +81,37 @@
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// dataGridView
|
||||
// dataGridViewProducts
|
||||
//
|
||||
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;
|
||||
dataGridViewProducts.AllowUserToAddRows = false;
|
||||
dataGridViewProducts.AllowUserToDeleteRows = false;
|
||||
dataGridViewProducts.AllowUserToResizeColumns = false;
|
||||
dataGridViewProducts.AllowUserToResizeRows = false;
|
||||
dataGridViewProducts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewProducts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewProducts.Dock = DockStyle.Fill;
|
||||
dataGridViewProducts.Location = new Point(0, 0);
|
||||
dataGridViewProducts.MultiSelect = false;
|
||||
dataGridViewProducts.Name = "dataGridViewProducts";
|
||||
dataGridViewProducts.ReadOnly = true;
|
||||
dataGridViewProducts.RowHeadersVisible = false;
|
||||
dataGridViewProducts.RowHeadersWidth = 82;
|
||||
dataGridViewProducts.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewProducts.Size = new Size(903, 757);
|
||||
dataGridViewProducts.TabIndex = 1;
|
||||
//
|
||||
// FormProducts
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1160, 757);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(dataGridViewProducts);
|
||||
Controls.Add(panel);
|
||||
Name = "FormProducts";
|
||||
Text = "Изделия";
|
||||
Load += FormProducts_Load;
|
||||
panel.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewProducts).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@
|
||||
private Panel panel;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridView;
|
||||
private DataGridView dataGridViewProducts;
|
||||
private Button buttonDel;
|
||||
}
|
||||
}
|
@ -93,18 +93,18 @@ namespace ProjectWorkshop.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridView.DataSource = _productRepository.ReadProducts();
|
||||
private void LoadList() => dataGridViewProducts.DataSource = _productRepository.ReadProducts();
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridView.SelectedRows.Count < 1)
|
||||
if (dataGridViewProducts.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id =
|
||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
|
||||
Convert.ToInt32(dataGridViewProducts.SelectedRows[0].Cells["ID"].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,8 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
panel = new Panel();
|
||||
buttonDel = new Button();
|
||||
buttonUpd = new Button();
|
||||
buttonAdd = new Button();
|
||||
dataGridViewShifts = new DataGridView();
|
||||
panel.SuspendLayout();
|
||||
@ -37,6 +39,8 @@
|
||||
//
|
||||
// panel
|
||||
//
|
||||
panel.Controls.Add(buttonDel);
|
||||
panel.Controls.Add(buttonUpd);
|
||||
panel.Controls.Add(buttonAdd);
|
||||
panel.Dock = DockStyle.Right;
|
||||
panel.Location = new Point(962, 0);
|
||||
@ -44,6 +48,28 @@
|
||||
panel.Size = new Size(326, 768);
|
||||
panel.TabIndex = 0;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.BackgroundImage = Properties.Resources.minus;
|
||||
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDel.Location = new Point(93, 551);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(150, 151);
|
||||
buttonDel.TabIndex = 2;
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += ButtonDel_Click;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.BackgroundImage = Properties.Resources.pencil;
|
||||
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUpd.Location = new Point(93, 295);
|
||||
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;
|
||||
@ -68,6 +94,7 @@
|
||||
dataGridViewShifts.ReadOnly = true;
|
||||
dataGridViewShifts.RowHeadersVisible = false;
|
||||
dataGridViewShifts.RowHeadersWidth = 82;
|
||||
dataGridViewShifts.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewShifts.Size = new Size(962, 768);
|
||||
dataGridViewShifts.TabIndex = 1;
|
||||
//
|
||||
@ -91,5 +118,7 @@
|
||||
private Panel panel;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridViewShifts;
|
||||
private Button buttonDel;
|
||||
private Button buttonUpd;
|
||||
}
|
||||
}
|
@ -49,6 +49,61 @@ namespace ProjectWorkshop.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findID))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<FormShift>();
|
||||
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
|
||||
{
|
||||
_shiftRepository.DeleteShift(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridViewShifts.DataSource = _shiftRepository.ReadShifts();
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridViewShifts.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id =
|
||||
Convert.ToInt32(dataGridViewShifts.SelectedRows[0].Cells["ID"].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user