Ещё одна правка

This commit is contained in:
artur-kalimullin 2024-11-15 12:52:00 +04:00
parent 464378bb9a
commit 3f98e2cf2a
11 changed files with 38 additions and 9 deletions

View File

@ -8,6 +8,7 @@ namespace ProjectSchedule.Forms
private readonly IUnityContainer _container; private readonly IUnityContainer _container;
private readonly IAudienceRepository _audienceRepository; private readonly IAudienceRepository _audienceRepository;
public FormAudiences(IUnityContainer container, IAudienceRepository audienceRepository) public FormAudiences(IUnityContainer container, IAudienceRepository audienceRepository)
{ {
InitializeComponent(); InitializeComponent();
@ -16,6 +17,7 @@ namespace ProjectSchedule.Forms
_audienceRepository = audienceRepository ?? _audienceRepository = audienceRepository ??
throw new ArgumentNullException(nameof(audienceRepository)); throw new ArgumentNullException(nameof(audienceRepository));
} }
private void FormAudiences_Load(object sender, EventArgs e) private void FormAudiences_Load(object sender, EventArgs e)
{ {
try try
@ -27,6 +29,7 @@ namespace ProjectSchedule.Forms
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonAdd_Click(object sender, EventArgs e) private void ButtonAdd_Click(object sender, EventArgs e)
{ {
try try
@ -39,6 +42,7 @@ namespace ProjectSchedule.Forms
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonUpd_Click(object sender, EventArgs e) private void ButtonUpd_Click(object sender, EventArgs e)
{ {
if (!TryGetIdentifierFromSelectedRow(out var findId)) if (!TryGetIdentifierFromSelectedRow(out var findId))
@ -58,6 +62,7 @@ namespace ProjectSchedule.Forms
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonDel_Click(object sender, EventArgs e) private void ButtonDel_Click(object sender, EventArgs e)
{ {
if (!TryGetIdentifierFromSelectedRow(out var findId)) if (!TryGetIdentifierFromSelectedRow(out var findId))
@ -82,6 +87,7 @@ namespace ProjectSchedule.Forms
} }
private void LoadList() => dataGridViewData.DataSource = _audienceRepository.ReadAudiences(); private void LoadList() => dataGridViewData.DataSource = _audienceRepository.ReadAudiences();
private bool TryGetIdentifierFromSelectedRow(out int id) private bool TryGetIdentifierFromSelectedRow(out int id)
{ {
id = 0; id = 0;

View File

@ -180,17 +180,21 @@
// //
numericUpDownNumberPair.Location = new Point(245, 302); numericUpDownNumberPair.Location = new Point(245, 302);
numericUpDownNumberPair.Maximum = new decimal(new int[] { 8, 0, 0, 0 }); numericUpDownNumberPair.Maximum = new decimal(new int[] { 8, 0, 0, 0 });
numericUpDownNumberPair.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
numericUpDownNumberPair.Name = "numericUpDownNumberPair"; numericUpDownNumberPair.Name = "numericUpDownNumberPair";
numericUpDownNumberPair.Size = new Size(210, 27); numericUpDownNumberPair.Size = new Size(210, 27);
numericUpDownNumberPair.TabIndex = 15; numericUpDownNumberPair.TabIndex = 15;
numericUpDownNumberPair.Value = new decimal(new int[] { 1, 0, 0, 0 });
// //
// numericUpDownNumberDay // numericUpDownNumberDay
// //
numericUpDownNumberDay.Location = new Point(245, 257); numericUpDownNumberDay.Location = new Point(245, 257);
numericUpDownNumberDay.Maximum = new decimal(new int[] { 7, 0, 0, 0 }); numericUpDownNumberDay.Maximum = new decimal(new int[] { 7, 0, 0, 0 });
numericUpDownNumberDay.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
numericUpDownNumberDay.Name = "numericUpDownNumberDay"; numericUpDownNumberDay.Name = "numericUpDownNumberDay";
numericUpDownNumberDay.Size = new Size(210, 27); numericUpDownNumberDay.Size = new Size(210, 27);
numericUpDownNumberDay.TabIndex = 16; numericUpDownNumberDay.TabIndex = 16;
numericUpDownNumberDay.Value = new decimal(new int[] { 1, 0, 0, 0 });
// //
// buttonSave // buttonSave
// //

View File

@ -11,7 +11,6 @@ namespace ProjectSchedule.Forms
IDisciplineRepository disciplineRepository, IGroupStudentsRepository groupStudentsRepository) IDisciplineRepository disciplineRepository, IGroupStudentsRepository groupStudentsRepository)
{ {
InitializeComponent(); InitializeComponent();
_curriculumSupplementRepository = curriculumSupplementRepository ?? _curriculumSupplementRepository = curriculumSupplementRepository ??
throw new ArgumentNullException(nameof(curriculumSupplementRepository)); throw new ArgumentNullException(nameof(curriculumSupplementRepository));

View File

@ -67,15 +67,12 @@ namespace ProjectSchedule.Forms
} }
} }
private void LoadList() private void LoadList() =>
{
dataGridViewData.DataSource = _curriculumSupplementRepository.ReadCurriculumSupplements(); dataGridViewData.DataSource = _curriculumSupplementRepository.ReadCurriculumSupplements();
}
private bool TryGetIdentifierFromSelectedRow(out int id) private bool TryGetIdentifierFromSelectedRow(out int id)
{ {
id = 0; id = 0;
if (dataGridViewData.SelectedRows.Count < 1) if (dataGridViewData.SelectedRows.Count < 1)
{ {
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

View File

@ -20,6 +20,7 @@ public partial class FormDiscipline : Form
{ {
throw new InvalidDataException(nameof(discipline)); throw new InvalidDataException(nameof(discipline));
} }
textBoxNameDiscipline.Text = discipline.NameDiscipline; textBoxNameDiscipline.Text = discipline.NameDiscipline;
_disciplineId = value; _disciplineId = value;
} }
@ -46,6 +47,7 @@ public partial class FormDiscipline : Form
{ {
throw new Exception("Поле 'Название дисциплины' должно быть заполнено."); throw new Exception("Поле 'Название дисциплины' должно быть заполнено.");
} }
if (_disciplineId.HasValue) if (_disciplineId.HasValue)
{ {
_disciplineRepository.UpdateDiscipline(CreateDiscipline(_disciplineId.Value)); _disciplineRepository.UpdateDiscipline(CreateDiscipline(_disciplineId.Value));

View File

@ -8,6 +8,7 @@ namespace ProjectSchedule.Forms
private readonly IUnityContainer _container; private readonly IUnityContainer _container;
private readonly IDisciplineRepository _disciplineRepository; private readonly IDisciplineRepository _disciplineRepository;
public FormDisciplines(IUnityContainer container, IDisciplineRepository disciplineRepository) public FormDisciplines(IUnityContainer container, IDisciplineRepository disciplineRepository)
{ {
InitializeComponent(); InitializeComponent();
@ -16,6 +17,7 @@ namespace ProjectSchedule.Forms
_disciplineRepository = disciplineRepository ?? _disciplineRepository = disciplineRepository ??
throw new ArgumentNullException(nameof(disciplineRepository)); throw new ArgumentNullException(nameof(disciplineRepository));
} }
private void FormDisciplines_Load(object sender, EventArgs e) private void FormDisciplines_Load(object sender, EventArgs e)
{ {
try try
@ -27,6 +29,7 @@ namespace ProjectSchedule.Forms
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonAdd_Click(object sender, EventArgs e) private void ButtonAdd_Click(object sender, EventArgs e)
{ {
try try
@ -39,6 +42,7 @@ namespace ProjectSchedule.Forms
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonUpd_Click(object sender, EventArgs e) private void ButtonUpd_Click(object sender, EventArgs e)
{ {
if (!TryGetIdentifierFromSelectedRow(out var findId)) if (!TryGetIdentifierFromSelectedRow(out var findId))
@ -58,6 +62,7 @@ namespace ProjectSchedule.Forms
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonDel_Click(object sender, EventArgs e) private void ButtonDel_Click(object sender, EventArgs e)
{ {
if (!TryGetIdentifierFromSelectedRow(out var findId)) if (!TryGetIdentifierFromSelectedRow(out var findId))
@ -82,6 +87,7 @@ namespace ProjectSchedule.Forms
} }
private void LoadList() => dataGridViewData.DataSource = _disciplineRepository.ReadDisciplines(); private void LoadList() => dataGridViewData.DataSource = _disciplineRepository.ReadDisciplines();
private bool TryGetIdentifierFromSelectedRow(out int id) private bool TryGetIdentifierFromSelectedRow(out int id)
{ {
id = 0; id = 0;

View File

@ -20,6 +20,7 @@ public partial class FormEducator : Form
{ {
throw new InvalidDataException(nameof(educator)); throw new InvalidDataException(nameof(educator));
} }
textBoxSurname.Text = educator.Surname; textBoxSurname.Text = educator.Surname;
textBoxName.Text = educator.Name; textBoxName.Text = educator.Name;
textBoxPatronymic.Text = educator.Patronymic; textBoxPatronymic.Text = educator.Patronymic;
@ -49,6 +50,7 @@ public partial class FormEducator : Form
{ {
throw new Exception("Имеются незаполненные поля"); throw new Exception("Имеются незаполненные поля");
} }
if (_educatorId.HasValue) if (_educatorId.HasValue)
{ {
_educatorRepository.UpdateEducator(CreateEducator(_educatorId.Value)); _educatorRepository.UpdateEducator(CreateEducator(_educatorId.Value));

View File

@ -8,6 +8,7 @@ namespace ProjectSchedule.Forms
private readonly IUnityContainer _container; private readonly IUnityContainer _container;
private readonly IEducatorRepository _educatorRepository; private readonly IEducatorRepository _educatorRepository;
public FormEducators(IUnityContainer container, IEducatorRepository educatorRepository) public FormEducators(IUnityContainer container, IEducatorRepository educatorRepository)
{ {
InitializeComponent(); InitializeComponent();
@ -16,6 +17,7 @@ namespace ProjectSchedule.Forms
_educatorRepository = educatorRepository ?? _educatorRepository = educatorRepository ??
throw new ArgumentNullException(nameof(educatorRepository)); throw new ArgumentNullException(nameof(educatorRepository));
} }
private void FormEducators_Load(object sender, EventArgs e) private void FormEducators_Load(object sender, EventArgs e)
{ {
try try
@ -27,6 +29,7 @@ namespace ProjectSchedule.Forms
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonAdd_Click(object sender, EventArgs e) private void ButtonAdd_Click(object sender, EventArgs e)
{ {
try try
@ -39,6 +42,7 @@ namespace ProjectSchedule.Forms
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonUpd_Click(object sender, EventArgs e) private void ButtonUpd_Click(object sender, EventArgs e)
{ {
if (!TryGetIdentifierFromSelectedRow(out var findId)) if (!TryGetIdentifierFromSelectedRow(out var findId))
@ -58,6 +62,7 @@ namespace ProjectSchedule.Forms
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonDel_Click(object sender, EventArgs e) private void ButtonDel_Click(object sender, EventArgs e)
{ {
if (!TryGetIdentifierFromSelectedRow(out var findId)) if (!TryGetIdentifierFromSelectedRow(out var findId))
@ -82,6 +87,7 @@ namespace ProjectSchedule.Forms
} }
private void LoadList() => dataGridViewData.DataSource = _educatorRepository.ReadEducators(); private void LoadList() => dataGridViewData.DataSource = _educatorRepository.ReadEducators();
private bool TryGetIdentifierFromSelectedRow(out int id) private bool TryGetIdentifierFromSelectedRow(out int id)
{ {
id = 0; id = 0;

View File

@ -70,9 +70,11 @@
// //
numericUpDownQuantityStudents.Location = new Point(213, 121); numericUpDownQuantityStudents.Location = new Point(213, 121);
numericUpDownQuantityStudents.Maximum = new decimal(new int[] { 66, 0, 0, 0 }); numericUpDownQuantityStudents.Maximum = new decimal(new int[] { 66, 0, 0, 0 });
numericUpDownQuantityStudents.Minimum = new decimal(new int[] { 2, 0, 0, 0 });
numericUpDownQuantityStudents.Name = "numericUpDownQuantityStudents"; numericUpDownQuantityStudents.Name = "numericUpDownQuantityStudents";
numericUpDownQuantityStudents.Size = new Size(176, 27); numericUpDownQuantityStudents.Size = new Size(176, 27);
numericUpDownQuantityStudents.TabIndex = 3; numericUpDownQuantityStudents.TabIndex = 3;
numericUpDownQuantityStudents.Value = new decimal(new int[] { 2, 0, 0, 0 });
// //
// textBoxAbbreviationGroup // textBoxAbbreviationGroup
// //

View File

@ -20,6 +20,7 @@ public partial class FormGroupStudents : Form
{ {
throw new InvalidDataException(nameof(groupStudents)); throw new InvalidDataException(nameof(groupStudents));
} }
textBoxAbbreviationGroup.Text = groupStudents.AbbreviationGroup; textBoxAbbreviationGroup.Text = groupStudents.AbbreviationGroup;
textBoxGroupNumber.Text = groupStudents.GroupNumber; textBoxGroupNumber.Text = groupStudents.GroupNumber;
numericUpDownQuantityStudents.Value = groupStudents.QuantityStudents; numericUpDownQuantityStudents.Value = groupStudents.QuantityStudents;
@ -68,8 +69,6 @@ public partial class FormGroupStudents : Form
private void ButtonCancel_Click(object sender, EventArgs e) => Close(); private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private GroupStudents CreateGroupOfStudents(int id) private GroupStudents CreateGroupOfStudents(int id) =>
{ GroupStudents.CreateEntity(id, textBoxAbbreviationGroup.Text, textBoxGroupNumber.Text, Convert.ToInt32(numericUpDownQuantityStudents.Value));
return GroupStudents.CreateEntity(id, textBoxAbbreviationGroup.Text, textBoxGroupNumber.Text, Convert.ToInt32(numericUpDownQuantityStudents.Value));
}
} }

View File

@ -8,6 +8,7 @@ namespace ProjectSchedule.Forms
private readonly IUnityContainer _container; private readonly IUnityContainer _container;
private readonly IGroupStudentsRepository _groupStudentsRepository; private readonly IGroupStudentsRepository _groupStudentsRepository;
public FormGroupsStudents(IUnityContainer container, IGroupStudentsRepository groupStudentsRepository) public FormGroupsStudents(IUnityContainer container, IGroupStudentsRepository groupStudentsRepository)
{ {
InitializeComponent(); InitializeComponent();
@ -16,6 +17,7 @@ namespace ProjectSchedule.Forms
_groupStudentsRepository = groupStudentsRepository ?? _groupStudentsRepository = groupStudentsRepository ??
throw new ArgumentNullException(nameof(groupStudentsRepository)); throw new ArgumentNullException(nameof(groupStudentsRepository));
} }
private void FormGroupsStudents_Load(object sender, EventArgs e) private void FormGroupsStudents_Load(object sender, EventArgs e)
{ {
try try
@ -27,6 +29,7 @@ namespace ProjectSchedule.Forms
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonAdd_Click(object sender, EventArgs e) private void ButtonAdd_Click(object sender, EventArgs e)
{ {
try try
@ -39,6 +42,7 @@ namespace ProjectSchedule.Forms
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonUpd_Click(object sender, EventArgs e) private void ButtonUpd_Click(object sender, EventArgs e)
{ {
if (!TryGetIdentifierFromSelectedRow(out var findId)) if (!TryGetIdentifierFromSelectedRow(out var findId))
@ -58,6 +62,7 @@ namespace ProjectSchedule.Forms
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonDel_Click(object sender, EventArgs e) private void ButtonDel_Click(object sender, EventArgs e)
{ {
if (!TryGetIdentifierFromSelectedRow(out var findId)) if (!TryGetIdentifierFromSelectedRow(out var findId))
@ -82,6 +87,7 @@ namespace ProjectSchedule.Forms
} }
private void LoadList() => dataGridViewData.DataSource = _groupStudentsRepository.ReadGroupsStudents(); private void LoadList() => dataGridViewData.DataSource = _groupStudentsRepository.ReadGroupsStudents();
private bool TryGetIdentifierFromSelectedRow(out int id) private bool TryGetIdentifierFromSelectedRow(out int id)
{ {
id = 0; id = 0;