Готовая лаб. работа 1

This commit is contained in:
Никита Потапов 2024-02-26 01:20:07 +04:00
parent 3e34afb54b
commit eeffc761e0
9 changed files with 20 additions and 14 deletions

View File

@ -73,7 +73,7 @@
buttonSaveComponent.Location = new Point(211, 80);
buttonSaveComponent.Name = "buttonSaveComponent";
buttonSaveComponent.Size = new Size(115, 29);
buttonSaveComponent.TabIndex = 4;
buttonSaveComponent.TabIndex = 1;
buttonSaveComponent.Text = "Сохранить";
buttonSaveComponent.UseVisualStyleBackColor = true;
buttonSaveComponent.Click += ButtonSaveComponent_Click;

View File

@ -12,8 +12,7 @@ namespace SecuritySystemView
private readonly IComponentLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public FormComponent(ILogger<FormComponent> logger, IComponentLogic
logic)
public FormComponent(ILogger<FormComponent> logger, IComponentLogic logic)
{
InitializeComponent();

View File

@ -96,7 +96,7 @@
buttonSave.Location = new Point(370, 118);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 6;
buttonSave.TabIndex = 1;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;

View File

@ -79,8 +79,10 @@
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 31);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(775, 296);
dataGridView.TabIndex = 1;
//
@ -134,7 +136,7 @@
buttonRefresh.Location = new Point(816, 290);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(216, 29);
buttonRefresh.TabIndex = 6;
buttonRefresh.TabIndex = 1;
buttonRefresh.Text = "Обновить список";
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += ButtonRefresh_Click;

View File

@ -143,6 +143,7 @@
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(627, 285);
dataGridView.TabIndex = 0;
//
@ -173,7 +174,7 @@
buttonSave.Location = new Point(537, 409);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(108, 29);
buttonSave.TabIndex = 5;
buttonSave.TabIndex = 1;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;

View File

@ -123,18 +123,16 @@ namespace SecuritySystemView
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
_logger.LogInformation("Удаление компонента: {ComponentName} - {Count}", dataGridView.SelectedRows[0].Cells[1].Value);
_logger.LogInformation("Удаление компонента: {ComponentName} - {Count}", dataGridView.SelectedRows[0].Cells[1].Value, dataGridView.SelectedRows[0].Cells[2].Value);
_secureComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}

View File

@ -75,7 +75,7 @@
buttonSave.Location = new Point(230, 84);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 4;
buttonSave.TabIndex = 1;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;

View File

@ -61,6 +61,12 @@ namespace SecuritySystemView
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (Count <= 0)
{
MessageBox.Show("Количество должно быть больше 0", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxComponents.SelectedValue == null)
{
MessageBox.Show("Выберите компонент", "Ошибка",

View File

@ -88,7 +88,7 @@
buttonAdd.Location = new Point(739, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 29);
buttonAdd.TabIndex = 5;
buttonAdd.TabIndex = 1;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAddSecure_Click;
@ -104,7 +104,7 @@
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
Name = "FormSecures";
Text = делия";
Text = зделия";
Load += FormSecures_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);