diff --git a/SUBD/ElectronicJournalContracts/SearchModels/TeacherSearchModel.cs b/SUBD/ElectronicJournalContracts/SearchModels/TeacherSearchModel.cs
index 05c0081..ba65f43 100644
--- a/SUBD/ElectronicJournalContracts/SearchModels/TeacherSearchModel.cs
+++ b/SUBD/ElectronicJournalContracts/SearchModels/TeacherSearchModel.cs
@@ -4,6 +4,6 @@
{
public int? Id { get; set; }
public string? Name { get; set; }
- public string? Academic_title { get; set; }
+ public string? AcademicTitle { get; set; }
}
}
diff --git a/SUBD/ElectronicJournalDatabaseImplement/Implements/TeacherStorage.cs b/SUBD/ElectronicJournalDatabaseImplement/Implements/TeacherStorage.cs
index 2a83a38..ecbffff 100644
--- a/SUBD/ElectronicJournalDatabaseImplement/Implements/TeacherStorage.cs
+++ b/SUBD/ElectronicJournalDatabaseImplement/Implements/TeacherStorage.cs
@@ -3,6 +3,7 @@ using ElectronicJournalContracts.SearchModels;
using ElectronicJournalContracts.StorageContracts;
using ElectronicJournalContracts.ViewModels;
using ElectronicJournalDatabaseImplement.Models;
+using System.Xml.Linq;
namespace ElectronicJournalDatabaseImplement.Implements
{
@@ -30,7 +31,7 @@ namespace ElectronicJournalDatabaseImplement.Implements
ElectronicJournalContext context = new ElectronicJournalContext();
return context.Teachers
.FirstOrDefault(x =>
- (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name && x.AcademicTitle == model.Academic_title) ||
+ (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name && x.AcademicTitle == model.AcademicTitle) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
@@ -40,7 +41,7 @@ namespace ElectronicJournalDatabaseImplement.Implements
ElectronicJournalContext context = new ElectronicJournalContext();
return context.Teachers
.OrderBy(x => x.Name)
- .Where(x => x.Name.Contains(model.Name))
+ .Where(x => x.Name.Contains(model.Name) || x.AcademicTitle.Contains(model.AcademicTitle))
.Select(x => x.GetViewModel)
.ToList();
}
diff --git a/SUBD/SUBD/FormCreateDiscipline.Designer.cs b/SUBD/SUBD/FormCreateDiscipline.Designer.cs
new file mode 100644
index 0000000..bc3c234
--- /dev/null
+++ b/SUBD/SUBD/FormCreateDiscipline.Designer.cs
@@ -0,0 +1,97 @@
+namespace SUBD
+{
+ partial class FormCreateDiscipline
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ label1 = new Label();
+ ButtonSave = new Button();
+ ButtonCancel = new Button();
+ textBoxName = new TextBox();
+ SuspendLayout();
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(5, 19);
+ label1.Name = "label1";
+ label1.Size = new Size(77, 20);
+ label1.TabIndex = 0;
+ label1.Text = "Название";
+ //
+ // ButtonSave
+ //
+ ButtonSave.Location = new Point(5, 49);
+ ButtonSave.Name = "ButtonSave";
+ ButtonSave.Size = new Size(94, 29);
+ ButtonSave.TabIndex = 3;
+ ButtonSave.Text = "Сохранить";
+ ButtonSave.UseVisualStyleBackColor = true;
+ ButtonSave.Click += ButtonSave_Click;
+ //
+ // ButtonCancel
+ //
+ ButtonCancel.Location = new Point(105, 49);
+ ButtonCancel.Name = "ButtonCancel";
+ ButtonCancel.Size = new Size(94, 29);
+ ButtonCancel.TabIndex = 4;
+ ButtonCancel.Text = "Отмена";
+ ButtonCancel.UseVisualStyleBackColor = true;
+ ButtonCancel.Click += ButtonCancel_Click;
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(88, 16);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(289, 27);
+ textBoxName.TabIndex = 7;
+ //
+ // FormCreateDiscipline
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(396, 90);
+ Controls.Add(textBoxName);
+ Controls.Add(ButtonCancel);
+ Controls.Add(ButtonSave);
+ Controls.Add(label1);
+ FormBorderStyle = FormBorderStyle.FixedToolWindow;
+ Name = "FormCreateDiscipline";
+ Text = "Создание дисциплины";
+ Load += FormCreateDiscipline_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label label1;
+ private Button ButtonSave;
+ private Button ButtonCancel;
+ private TextBox textBoxName;
+ }
+}
\ No newline at end of file
diff --git a/SUBD/SUBD/FormCreateDiscipline.cs b/SUBD/SUBD/FormCreateDiscipline.cs
new file mode 100644
index 0000000..c74a6b3
--- /dev/null
+++ b/SUBD/SUBD/FormCreateDiscipline.cs
@@ -0,0 +1,85 @@
+using ElectronicJournalContracts.BindingModels;
+using ElectronicJournalContracts.BusinessLogicContracts;
+using ElectronicJournalContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+
+namespace SUBD
+{
+ public partial class FormCreateDiscipline : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IDisciplineLogic _logic;
+ private int? _id;
+ public int Id { set { _id = value; } }
+ public FormCreateDiscipline(ILogger logger, IDisciplineLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxName.Text))
+ {
+ MessageBox.Show("Заполните имя", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение дисциплины");
+ try
+ {
+ var model = new DisciplineBindingModel
+ {
+ Id = _id ?? 0,
+ Title = textBoxName.Text
+ };
+ var operationResult = _id.HasValue ? _logic.Update(model) :
+ _logic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения дисциплины");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+
+ private void FormCreateDiscipline_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ try
+ {
+ _logger.LogInformation("Получение дисциплины");
+ var view = _logic.ReadElement(new DisciplineSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.Title;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения дисциплины");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+}
diff --git a/SUBD/SUBD/FormCreateDiscipline.resx b/SUBD/SUBD/FormCreateDiscipline.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SUBD/SUBD/FormCreateDiscipline.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD/SUBD/FormCreateGroup.Designer.cs b/SUBD/SUBD/FormCreateGroup.Designer.cs
new file mode 100644
index 0000000..cd9327d
--- /dev/null
+++ b/SUBD/SUBD/FormCreateGroup.Designer.cs
@@ -0,0 +1,124 @@
+namespace SUBD
+{
+ partial class FormCreateGroup
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ button1 = new Button();
+ button2 = new Button();
+ textBoxName = new TextBox();
+ numericUpDownCourse = new NumericUpDown();
+ label1 = new Label();
+ label2 = new Label();
+ ((System.ComponentModel.ISupportInitialize)numericUpDownCourse).BeginInit();
+ SuspendLayout();
+ //
+ // button1
+ //
+ button1.Location = new Point(12, 72);
+ button1.Name = "button1";
+ button1.Size = new Size(97, 29);
+ button1.TabIndex = 0;
+ button1.Text = "Сохранить";
+ button1.UseVisualStyleBackColor = true;
+ button1.Click += ButtonSave_Click;
+ //
+ // button2
+ //
+ button2.Location = new Point(115, 72);
+ button2.Name = "button2";
+ button2.Size = new Size(82, 29);
+ button2.TabIndex = 1;
+ button2.Text = "Отмена";
+ button2.UseVisualStyleBackColor = true;
+ button2.Click += ButtonCancel_Click;
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(109, 6);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(284, 27);
+ textBoxName.TabIndex = 2;
+ //
+ // numericUpDownCourse
+ //
+ numericUpDownCourse.Location = new Point(109, 39);
+ numericUpDownCourse.Maximum = new decimal(new int[] { 6, 0, 0, 0 });
+ numericUpDownCourse.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
+ numericUpDownCourse.Name = "numericUpDownCourse";
+ numericUpDownCourse.Size = new Size(284, 27);
+ numericUpDownCourse.TabIndex = 4;
+ numericUpDownCourse.Value = new decimal(new int[] { 1, 0, 0, 0 });
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(12, 12);
+ label1.Name = "label1";
+ label1.Size = new Size(77, 20);
+ label1.TabIndex = 5;
+ label1.Text = "Название";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(12, 46);
+ label2.Name = "label2";
+ label2.Size = new Size(41, 20);
+ label2.TabIndex = 6;
+ label2.Text = "Курс";
+ //
+ // FormCreateGroup
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(403, 113);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Controls.Add(numericUpDownCourse);
+ Controls.Add(textBoxName);
+ Controls.Add(button2);
+ Controls.Add(button1);
+ FormBorderStyle = FormBorderStyle.FixedToolWindow;
+ Name = "FormCreateGroup";
+ Text = "Создание группы";
+ Load += FormCreateGroup_Load;
+ ((System.ComponentModel.ISupportInitialize)numericUpDownCourse).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button button1;
+ private Button button2;
+ private TextBox textBoxName;
+ private NumericUpDown numericUpDownCourse;
+ private Label label1;
+ private Label label2;
+ }
+}
\ No newline at end of file
diff --git a/SUBD/SUBD/FormCreateGroup.cs b/SUBD/SUBD/FormCreateGroup.cs
new file mode 100644
index 0000000..9c8ab0c
--- /dev/null
+++ b/SUBD/SUBD/FormCreateGroup.cs
@@ -0,0 +1,95 @@
+using ElectronicJournalContracts.BindingModels;
+using ElectronicJournalContracts.BusinessLogicContracts;
+using ElectronicJournalContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace SUBD
+{
+ public partial class FormCreateGroup : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IGroupLogic _logic;
+ private int? _id;
+ public int Id { set { _id = value; } }
+ public FormCreateGroup(ILogger logger, IGroupLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxName.Text))
+ {
+ MessageBox.Show("Заполните название", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение группы");
+ try
+ {
+ var model = new GroupBindingModel
+ {
+ Id = _id ?? 0,
+ Title = textBoxName.Text,
+ Course = (int)numericUpDownCourse.Value
+ };
+ var operationResult = _id.HasValue ? _logic.Update(model) :
+ _logic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения группы");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ private void FormCreateGroup_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ try
+ {
+ _logger.LogInformation("Получение группы");
+ var view = _logic.ReadElement(new GroupSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.Title;
+ numericUpDownCourse.Value = view.Course;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения группы");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+}
diff --git a/SUBD/SUBD/FormCreateGroup.resx b/SUBD/SUBD/FormCreateGroup.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SUBD/SUBD/FormCreateGroup.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD/SUBD/FormCreateStudent.Designer.cs b/SUBD/SUBD/FormCreateStudent.Designer.cs
new file mode 100644
index 0000000..0cb75a4
--- /dev/null
+++ b/SUBD/SUBD/FormCreateStudent.Designer.cs
@@ -0,0 +1,121 @@
+namespace SUBD
+{
+ partial class FormCreateStudent
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ comboBoxGroup = new ComboBox();
+ textBoxName = new TextBox();
+ ButtonSave = new Button();
+ ButtonCancel = new Button();
+ label1 = new Label();
+ label2 = new Label();
+ SuspendLayout();
+ //
+ // comboBoxGroup
+ //
+ comboBoxGroup.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxGroup.FormattingEnabled = true;
+ comboBoxGroup.Location = new Point(119, 54);
+ comboBoxGroup.Name = "comboBoxGroup";
+ comboBoxGroup.Size = new Size(250, 28);
+ comboBoxGroup.TabIndex = 1;
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(119, 12);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(250, 27);
+ textBoxName.TabIndex = 3;
+ //
+ // ButtonSave
+ //
+ ButtonSave.Location = new Point(32, 97);
+ ButtonSave.Name = "ButtonSave";
+ ButtonSave.Size = new Size(94, 29);
+ ButtonSave.TabIndex = 6;
+ ButtonSave.Text = "Сохранить";
+ ButtonSave.UseVisualStyleBackColor = true;
+ ButtonSave.Click += ButtonSave_Click;
+ //
+ // ButtonCancel
+ //
+ ButtonCancel.Location = new Point(132, 97);
+ ButtonCancel.Name = "ButtonCancel";
+ ButtonCancel.Size = new Size(94, 29);
+ ButtonCancel.TabIndex = 7;
+ ButtonCancel.Text = "Отмена";
+ ButtonCancel.UseVisualStyleBackColor = true;
+ ButtonCancel.Click += ButtonCancel_Click;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(32, 10);
+ label1.Name = "label1";
+ label1.Size = new Size(77, 20);
+ label1.TabIndex = 8;
+ label1.Text = "Название";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(32, 57);
+ label2.Name = "label2";
+ label2.Size = new Size(58, 20);
+ label2.TabIndex = 10;
+ label2.Text = "Группа";
+ //
+ // FormCreateStudent
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(379, 137);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Controls.Add(ButtonCancel);
+ Controls.Add(ButtonSave);
+ Controls.Add(textBoxName);
+ Controls.Add(comboBoxGroup);
+ FormBorderStyle = FormBorderStyle.FixedToolWindow;
+ Name = "FormCreateStudent";
+ Text = "Создание студента";
+ Load += FormCreateStudent_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private ComboBox comboBoxGroup;
+ private TextBox textBoxName;
+ private Button ButtonSave;
+ private Button ButtonCancel;
+ private Label label1;
+ private Label label2;
+ }
+}
\ No newline at end of file
diff --git a/SUBD/SUBD/FormCreateStudent.cs b/SUBD/SUBD/FormCreateStudent.cs
new file mode 100644
index 0000000..4a26c39
--- /dev/null
+++ b/SUBD/SUBD/FormCreateStudent.cs
@@ -0,0 +1,106 @@
+using ElectronicJournalContracts.BindingModels;
+using ElectronicJournalContracts.BusinessLogicContracts;
+using ElectronicJournalContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+
+namespace SUBD
+{
+ public partial class FormCreateStudent : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IGroupLogic _Glogic;
+ private readonly IStudentLogic _Slogic;
+ private int? _id;
+ public int Id { set { _id = value; } }
+ public FormCreateStudent(ILogger logger, IGroupLogic glogic, IStudentLogic slogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _Glogic = glogic;
+ _Slogic = slogic;
+ }
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxName.Text))
+ {
+ MessageBox.Show("Заполните ФИО", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение студента");
+ try
+ {
+ var model = new StudentBindingModel
+ {
+ Id = _id ?? 0,
+ Name = textBoxName.Text,
+ GroupId = (int)comboBoxGroup.SelectedValue
+ };
+ var operationResult = _id.HasValue ? _Slogic.Update(model) :
+ _Slogic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения студента");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+
+ private void FormCreateStudent_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ _logger.LogInformation("Загрузка группы");
+ var listG = _Glogic.ReadList(null).ToList();
+ if (listG != null)
+ {
+ comboBoxGroup.DisplayMember = "Title";
+ comboBoxGroup.ValueMember = "Id";
+ comboBoxGroup.DataSource = listG;
+ comboBoxGroup.SelectedItem = null;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения получения списков. Доп информация в логах");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ if (_id.HasValue)
+ {
+ try
+ {
+ var view = _Slogic.ReadElement(new StudentSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.Name;
+ comboBoxGroup.SelectedValue = view.GroupId;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения получения студента. Доп информация в логах");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+}
diff --git a/SUBD/SUBD/FormCreateStudent.resx b/SUBD/SUBD/FormCreateStudent.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SUBD/SUBD/FormCreateStudent.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD/SUBD/FormCreateTeacher.Designer.cs b/SUBD/SUBD/FormCreateTeacher.Designer.cs
new file mode 100644
index 0000000..2f5c704
--- /dev/null
+++ b/SUBD/SUBD/FormCreateTeacher.Designer.cs
@@ -0,0 +1,119 @@
+namespace SUBD
+{
+ partial class FormCreateTeacher
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ ButtonSave = new Button();
+ ButtonCancel = new Button();
+ textBoxName = new TextBox();
+ textBoxAcad = new TextBox();
+ label1 = new Label();
+ label2 = new Label();
+ SuspendLayout();
+ //
+ // ButtonSave
+ //
+ ButtonSave.Location = new Point(12, 90);
+ ButtonSave.Name = "ButtonSave";
+ ButtonSave.Size = new Size(94, 29);
+ ButtonSave.TabIndex = 0;
+ ButtonSave.Text = "Сохранить";
+ ButtonSave.UseVisualStyleBackColor = true;
+ ButtonSave.Click += ButtonSave_Click;
+ //
+ // ButtonCancel
+ //
+ ButtonCancel.Location = new Point(112, 90);
+ ButtonCancel.Name = "ButtonCancel";
+ ButtonCancel.Size = new Size(94, 29);
+ ButtonCancel.TabIndex = 1;
+ ButtonCancel.Text = "Отмена";
+ ButtonCancel.UseVisualStyleBackColor = true;
+ ButtonCancel.Click += ButtonCancel_Click;
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(137, 18);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(218, 27);
+ textBoxName.TabIndex = 2;
+ //
+ // textBoxAcad
+ //
+ textBoxAcad.Location = new Point(137, 53);
+ textBoxAcad.Name = "textBoxAcad";
+ textBoxAcad.Size = new Size(218, 27);
+ textBoxAcad.TabIndex = 4;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(12, 21);
+ label1.Name = "label1";
+ label1.Size = new Size(39, 20);
+ label1.TabIndex = 6;
+ label1.Text = "Имя";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(12, 56);
+ label2.Name = "label2";
+ label2.Size = new Size(119, 20);
+ label2.TabIndex = 8;
+ label2.Text = "Ученое звание";
+ //
+ // FormCreateTeacher
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(364, 131);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Controls.Add(textBoxAcad);
+ Controls.Add(textBoxName);
+ Controls.Add(ButtonCancel);
+ Controls.Add(ButtonSave);
+ FormBorderStyle = FormBorderStyle.FixedToolWindow;
+ Name = "FormCreateTeacher";
+ Text = "Создание преподавателя";
+ Load += FormCreateTeacher_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Button ButtonSave;
+ private Button ButtonCancel;
+ private TextBox textBoxName;
+ private TextBox textBoxAcad;
+ private Label label1;
+ private Label label2;
+ }
+}
\ No newline at end of file
diff --git a/SUBD/SUBD/FormCreateTeacher.cs b/SUBD/SUBD/FormCreateTeacher.cs
new file mode 100644
index 0000000..52edde3
--- /dev/null
+++ b/SUBD/SUBD/FormCreateTeacher.cs
@@ -0,0 +1,87 @@
+using ElectronicJournalContracts.BindingModels;
+using ElectronicJournalContracts.BusinessLogicContracts;
+using ElectronicJournalContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+
+namespace SUBD
+{
+ public partial class FormCreateTeacher : Form
+ {
+ private readonly ILogger _logger;
+ private readonly ITeacherLogic _logic;
+ private int? _id;
+ public int Id { set { _id = value; } }
+ public FormCreateTeacher(ILogger logger, ITeacherLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+ private void ButtonSave_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxName.Text))
+ {
+ MessageBox.Show("Заполните ФИО", "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение учителя");
+ try
+ {
+ var model = new TeacherBindingModel
+ {
+ Id = _id ?? 0,
+ Name = textBoxName.Text,
+ AcademicTitle = textBoxAcad.Text,
+ };
+ var operationResult = _id.HasValue ? _logic.Update(model) :
+ _logic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения учителя");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+
+ private void FormCreateTeacher_Load(object sender, EventArgs e)
+ {
+ if (_id.HasValue)
+ {
+ try
+ {
+ _logger.LogInformation("Получение учителя");
+ var view = _logic.ReadElement(new TeacherSearchModel
+ {
+ Id = _id.Value
+ });
+ if (view != null)
+ {
+ textBoxName.Text = view.Name;
+ textBoxAcad.Text = view.AcademicTitle;
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка получения учителя");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+}
diff --git a/SUBD/SUBD/FormCreateTeacher.resx b/SUBD/SUBD/FormCreateTeacher.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SUBD/SUBD/FormCreateTeacher.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD/SUBD/FormDiscipline.Designer.cs b/SUBD/SUBD/FormDiscipline.Designer.cs
new file mode 100644
index 0000000..8ae39a4
--- /dev/null
+++ b/SUBD/SUBD/FormDiscipline.Designer.cs
@@ -0,0 +1,192 @@
+namespace SUBD
+{
+ partial class FormDiscipline
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView = new DataGridView();
+ ButtonAdd = new Button();
+ ButtonUpd = new Button();
+ ButtonDel = new Button();
+ buttonRef = new Button();
+ textBoxFilter = new TextBox();
+ comboBoxFilter = new ComboBox();
+ ButtonDrop = new Button();
+ ButtonFilter = new Button();
+ labelCount = new Label();
+ labelTime = new Label();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 12);
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(719, 426);
+ dataGridView.TabIndex = 0;
+ //
+ // ButtonAdd
+ //
+ ButtonAdd.Location = new Point(737, 12);
+ ButtonAdd.Name = "ButtonAdd";
+ ButtonAdd.Size = new Size(163, 29);
+ ButtonAdd.TabIndex = 1;
+ ButtonAdd.Text = "Добавить";
+ ButtonAdd.UseVisualStyleBackColor = true;
+ ButtonAdd.Click += ButtonAdd_Click;
+ //
+ // ButtonUpd
+ //
+ ButtonUpd.Location = new Point(737, 47);
+ ButtonUpd.Name = "ButtonUpd";
+ ButtonUpd.Size = new Size(163, 29);
+ ButtonUpd.TabIndex = 2;
+ ButtonUpd.Text = "Изменить";
+ ButtonUpd.UseVisualStyleBackColor = true;
+ ButtonUpd.Click += ButtonUpd_Click;
+ //
+ // ButtonDel
+ //
+ ButtonDel.Location = new Point(737, 82);
+ ButtonDel.Name = "ButtonDel";
+ ButtonDel.Size = new Size(163, 29);
+ ButtonDel.TabIndex = 3;
+ ButtonDel.Text = "Удалить";
+ ButtonDel.UseVisualStyleBackColor = true;
+ ButtonDel.Click += ButtonDelete_Click;
+ //
+ // buttonRef
+ //
+ buttonRef.Location = new Point(737, 117);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(163, 32);
+ buttonRef.TabIndex = 4;
+ buttonRef.Text = "Обновить";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += ButtonRef_Click;
+ //
+ // textBoxFilter
+ //
+ textBoxFilter.Location = new Point(737, 277);
+ textBoxFilter.Name = "textBoxFilter";
+ textBoxFilter.Size = new Size(163, 27);
+ textBoxFilter.TabIndex = 15;
+ //
+ // comboBoxFilter
+ //
+ comboBoxFilter.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxFilter.FormattingEnabled = true;
+ comboBoxFilter.Items.AddRange(new object[] { "Название" });
+ comboBoxFilter.Location = new Point(737, 243);
+ comboBoxFilter.Name = "comboBoxFilter";
+ comboBoxFilter.Size = new Size(163, 28);
+ comboBoxFilter.TabIndex = 14;
+ //
+ // ButtonDrop
+ //
+ ButtonDrop.Location = new Point(737, 345);
+ ButtonDrop.Name = "ButtonDrop";
+ ButtonDrop.Size = new Size(163, 29);
+ ButtonDrop.TabIndex = 13;
+ ButtonDrop.Text = "Сбросить";
+ ButtonDrop.UseVisualStyleBackColor = true;
+ ButtonDrop.Click += ButtonDrop_Click;
+ //
+ // ButtonFilter
+ //
+ ButtonFilter.Location = new Point(737, 310);
+ ButtonFilter.Name = "ButtonFilter";
+ ButtonFilter.Size = new Size(163, 29);
+ ButtonFilter.TabIndex = 12;
+ ButtonFilter.Text = "Наложить фильтр";
+ ButtonFilter.UseVisualStyleBackColor = true;
+ ButtonFilter.Click += ButtonFilter_Click;
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(737, 190);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(48, 20);
+ labelCount.TabIndex = 16;
+ labelCount.Text = "Count";
+ //
+ // labelTime
+ //
+ labelTime.AutoSize = true;
+ labelTime.Location = new Point(737, 220);
+ labelTime.Name = "labelTime";
+ labelTime.Size = new Size(42, 20);
+ labelTime.TabIndex = 17;
+ labelTime.Text = "Time";
+ //
+ // FormDiscipline
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(912, 450);
+ Controls.Add(labelTime);
+ Controls.Add(labelCount);
+ Controls.Add(textBoxFilter);
+ Controls.Add(comboBoxFilter);
+ Controls.Add(ButtonDrop);
+ Controls.Add(ButtonFilter);
+ Controls.Add(buttonRef);
+ Controls.Add(ButtonDel);
+ Controls.Add(ButtonUpd);
+ Controls.Add(ButtonAdd);
+ Controls.Add(dataGridView);
+ FormBorderStyle = FormBorderStyle.FixedToolWindow;
+ Name = "FormDiscipline";
+ Text = "Дисциплина";
+ Load += FormDiscipline_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button ButtonAdd;
+ private Button ButtonUpd;
+ private Button ButtonDel;
+ private Button buttonRef;
+ private TextBox textBoxFilter;
+ private ComboBox comboBoxFilter;
+ private Button ButtonDrop;
+ private Button ButtonFilter;
+ private Label labelCount;
+ private Label labelTime;
+ }
+}
\ No newline at end of file
diff --git a/SUBD/SUBD/FormDiscipline.cs b/SUBD/SUBD/FormDiscipline.cs
new file mode 100644
index 0000000..bb98114
--- /dev/null
+++ b/SUBD/SUBD/FormDiscipline.cs
@@ -0,0 +1,150 @@
+using ElectronicJournalBusinessLogic.BusinessLogic;
+using ElectronicJournalContracts.BindingModels;
+using ElectronicJournalContracts.BusinessLogicContracts;
+using ElectronicJournalContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+using System.Diagnostics;
+
+namespace SUBD
+{
+ public partial class FormDiscipline : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IDisciplineLogic _disciplineLogic;
+ public FormDiscipline(ILogger logger, IDisciplineLogic disciplineLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _disciplineLogic = disciplineLogic;
+ }
+ private void LoadData()
+ {
+ try
+ {
+ Stopwatch stopwatch = new Stopwatch();
+ stopwatch.Start();
+ var list = _disciplineLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ }
+ _logger.LogInformation("Загрузка дисциплин");
+ stopwatch.Stop();
+ TimeSpan ts = stopwatch.Elapsed;
+ string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
+ ts.Hours, ts.Minutes, ts.Seconds,
+ ts.Milliseconds / 10);
+ labelTime.Text = ("RunTime " + elapsedTime);
+ labelCount.Text = "Count: " + list.Count();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки дисциплин");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service =
+ Program.ServiceProvider?.GetService(typeof(FormCreateDiscipline));
+ if (service is FormCreateDiscipline form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void ButtonUpd_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service =
+ Program.ServiceProvider?.GetService(typeof(FormCreateDiscipline));
+ if (service is FormCreateDiscipline form)
+ {
+ form.Id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void ButtonDelete_Click(object sender, EventArgs e)
+ {
+ if (MessageBox.Show("Удалить дисциплину?", "Вопрос",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ _logger.LogInformation("Дисциплина удалена");
+ try
+ {
+ if (!_disciplineLogic.Delete(new DisciplineBindingModel
+ {
+ Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value),
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления дисциплины");
+ MessageBox.Show(ex.Message, "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void ButtonFilter_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ DisciplineSearchModel model = new DisciplineSearchModel();
+ model.Id = 9999;
+ switch (comboBoxFilter.SelectedItem)
+ {
+ case "Название":
+ model.Title = textBoxFilter.Text;
+ break;
+ default:
+ LoadData();
+ break;
+ }
+ var list = _disciplineLogic.ReadList(model);
+ if (list != null)
+ {
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ }
+ _logger.LogInformation("Загрузка дисциплин");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки дисциплин");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonDrop_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void FormDiscipline_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/SUBD/SUBD/FormDiscipline.resx b/SUBD/SUBD/FormDiscipline.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/SUBD/SUBD/FormDiscipline.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD/SUBD/FormGroup.Designer.cs b/SUBD/SUBD/FormGroup.Designer.cs
new file mode 100644
index 0000000..c6a64d4
--- /dev/null
+++ b/SUBD/SUBD/FormGroup.Designer.cs
@@ -0,0 +1,192 @@
+namespace SUBD
+{
+ partial class FormGroup
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView = new DataGridView();
+ ButtonAdd = new Button();
+ ButtonUpd = new Button();
+ ButtonDel = new Button();
+ ButtonRef = new Button();
+ textBoxFilter = new TextBox();
+ comboBoxFilter = new ComboBox();
+ ButtonDrop = new Button();
+ ButtonFilter = new Button();
+ labelCount = new Label();
+ labelTime = new Label();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.AllowUserToAddRows = false;
+ dataGridView.AllowUserToDeleteRows = false;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 12);
+ dataGridView.Name = "dataGridView";
+ dataGridView.ReadOnly = true;
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(684, 426);
+ dataGridView.TabIndex = 0;
+ //
+ // ButtonAdd
+ //
+ ButtonAdd.Location = new Point(702, 12);
+ ButtonAdd.Name = "ButtonAdd";
+ ButtonAdd.Size = new Size(146, 29);
+ ButtonAdd.TabIndex = 1;
+ ButtonAdd.Text = "Добавить";
+ ButtonAdd.UseVisualStyleBackColor = true;
+ ButtonAdd.Click += ButtonAdd_Click;
+ //
+ // ButtonUpd
+ //
+ ButtonUpd.Location = new Point(702, 47);
+ ButtonUpd.Name = "ButtonUpd";
+ ButtonUpd.Size = new Size(146, 29);
+ ButtonUpd.TabIndex = 2;
+ ButtonUpd.Text = "Изменить";
+ ButtonUpd.UseVisualStyleBackColor = true;
+ ButtonUpd.Click += ButtonUpd_Click;
+ //
+ // ButtonDel
+ //
+ ButtonDel.Location = new Point(702, 82);
+ ButtonDel.Name = "ButtonDel";
+ ButtonDel.Size = new Size(146, 29);
+ ButtonDel.TabIndex = 3;
+ ButtonDel.Text = "Удалить";
+ ButtonDel.UseVisualStyleBackColor = true;
+ ButtonDel.Click += ButtonDelete_Click;
+ //
+ // ButtonRef
+ //
+ ButtonRef.Location = new Point(702, 117);
+ ButtonRef.Name = "ButtonRef";
+ ButtonRef.Size = new Size(146, 29);
+ ButtonRef.TabIndex = 4;
+ ButtonRef.Text = "Обновить";
+ ButtonRef.UseVisualStyleBackColor = true;
+ ButtonRef.Click += ButtonRef_Click;
+ //
+ // textBoxFilter
+ //
+ textBoxFilter.Location = new Point(702, 269);
+ textBoxFilter.Name = "textBoxFilter";
+ textBoxFilter.Size = new Size(146, 27);
+ textBoxFilter.TabIndex = 21;
+ //
+ // comboBoxFilter
+ //
+ comboBoxFilter.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxFilter.FormattingEnabled = true;
+ comboBoxFilter.Items.AddRange(new object[] { "Название", "Курс" });
+ comboBoxFilter.Location = new Point(702, 235);
+ comboBoxFilter.Name = "comboBoxFilter";
+ comboBoxFilter.Size = new Size(146, 28);
+ comboBoxFilter.TabIndex = 20;
+ //
+ // ButtonDrop
+ //
+ ButtonDrop.Location = new Point(702, 337);
+ ButtonDrop.Name = "ButtonDrop";
+ ButtonDrop.Size = new Size(146, 29);
+ ButtonDrop.TabIndex = 19;
+ ButtonDrop.Text = "Сбросить";
+ ButtonDrop.UseVisualStyleBackColor = true;
+ ButtonDrop.Click += ButtonDrop_Click;
+ //
+ // ButtonFilter
+ //
+ ButtonFilter.Location = new Point(702, 302);
+ ButtonFilter.Name = "ButtonFilter";
+ ButtonFilter.Size = new Size(146, 29);
+ ButtonFilter.TabIndex = 18;
+ ButtonFilter.Text = "Наложить фильтр";
+ ButtonFilter.UseVisualStyleBackColor = true;
+ ButtonFilter.Click += ButtonFilter_Click;
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(702, 180);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(51, 20);
+ labelCount.TabIndex = 22;
+ labelCount.Text = "Count:";
+ //
+ // labelTime
+ //
+ labelTime.AutoSize = true;
+ labelTime.Location = new Point(702, 212);
+ labelTime.Name = "labelTime";
+ labelTime.Size = new Size(42, 20);
+ labelTime.TabIndex = 23;
+ labelTime.Text = "Time";
+ //
+ // FormGroup
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(851, 450);
+ Controls.Add(labelTime);
+ Controls.Add(labelCount);
+ Controls.Add(textBoxFilter);
+ Controls.Add(comboBoxFilter);
+ Controls.Add(ButtonDrop);
+ Controls.Add(ButtonFilter);
+ Controls.Add(ButtonRef);
+ Controls.Add(ButtonDel);
+ Controls.Add(ButtonUpd);
+ Controls.Add(ButtonAdd);
+ Controls.Add(dataGridView);
+ FormBorderStyle = FormBorderStyle.FixedToolWindow;
+ Name = "FormGroup";
+ Text = "Группа";
+ Load += FormGroup_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button ButtonAdd;
+ private Button ButtonUpd;
+ private Button ButtonDel;
+ private Button ButtonRef;
+ private TextBox textBoxFilter;
+ private ComboBox comboBoxFilter;
+ private Button ButtonDrop;
+ private Button ButtonFilter;
+ private Label labelCount;
+ private Label labelTime;
+ }
+}
\ No newline at end of file
diff --git a/SUBD/SUBD/FormGroup.cs b/SUBD/SUBD/FormGroup.cs
new file mode 100644
index 0000000..8ac0e1c
--- /dev/null
+++ b/SUBD/SUBD/FormGroup.cs
@@ -0,0 +1,154 @@
+using ElectronicJournalBusinessLogic.BusinessLogic;
+using ElectronicJournalContracts.BindingModels;
+using ElectronicJournalContracts.BusinessLogicContracts;
+using ElectronicJournalContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+using System.Diagnostics;
+using System.Windows.Forms;
+
+namespace SUBD
+{
+ public partial class FormGroup : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IGroupLogic _groupLogic;
+ public FormGroup(ILogger logger, IGroupLogic groupLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _groupLogic = groupLogic;
+ }
+ private void LoadData()
+ {
+ try
+ {
+ Stopwatch stopwatch = new Stopwatch();
+ stopwatch.Start();
+ var list = _groupLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ }
+ _logger.LogInformation("Загрузка группы");
+ stopwatch.Stop();
+ TimeSpan ts = stopwatch.Elapsed;
+ string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
+ ts.Hours, ts.Minutes, ts.Seconds,
+ ts.Milliseconds / 10);
+ labelTime.Text = ("RunTime " + elapsedTime);
+ labelCount.Text = "Count: " + list.Count();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки группы");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service =
+ Program.ServiceProvider?.GetService(typeof(FormCreateGroup));
+ if (service is FormCreateGroup form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void ButtonUpd_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service =
+ Program.ServiceProvider?.GetService(typeof(FormCreateGroup));
+ if (service is FormCreateGroup form)
+ {
+ form.Id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void ButtonDelete_Click(object sender, EventArgs e)
+ {
+ if (MessageBox.Show("Удалить группу?", "Вопрос",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ _logger.LogInformation("Группа удалена");
+ try
+ {
+ if (!_groupLogic.Delete(new GroupBindingModel
+ {
+ Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value),
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления группы");
+ MessageBox.Show(ex.Message, "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void ButtonFilter_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ GroupSearchModel model = new GroupSearchModel();
+ model.Id = 9999;
+ switch (comboBoxFilter.SelectedItem)
+ {
+ case "Название":
+ model.Title = textBoxFilter.Text;
+ break;
+ case "Курс":
+ model.Course = Convert.ToInt32(textBoxFilter.Text);
+ break;
+ default:
+ LoadData();
+ break;
+ }
+ var list = _groupLogic.ReadList(model);
+ if (list != null)
+ {
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ }
+ _logger.LogInformation("Загрузка группы");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки групп");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonDrop_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void FormGroup_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/SUBD/SUBD/FormGroup.resx b/SUBD/SUBD/FormGroup.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/SUBD/SUBD/FormGroup.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD/SUBD/FormStudent.Designer.cs b/SUBD/SUBD/FormStudent.Designer.cs
new file mode 100644
index 0000000..442d969
--- /dev/null
+++ b/SUBD/SUBD/FormStudent.Designer.cs
@@ -0,0 +1,189 @@
+namespace SUBD
+{
+ partial class FormStudent
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView = new DataGridView();
+ ButtonAdd = new Button();
+ ButtonUpd = new Button();
+ ButtonDel = new Button();
+ ButtonRef = new Button();
+ ButtonFilter = new Button();
+ ButtonDrop = new Button();
+ comboBoxFilter = new ComboBox();
+ textBoxFilter = new TextBox();
+ labelTime = new Label();
+ labelCount = new Label();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 12);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(623, 418);
+ dataGridView.TabIndex = 1;
+ //
+ // ButtonAdd
+ //
+ ButtonAdd.Location = new Point(654, 12);
+ ButtonAdd.Name = "ButtonAdd";
+ ButtonAdd.Size = new Size(147, 29);
+ ButtonAdd.TabIndex = 2;
+ ButtonAdd.Text = "Добавить";
+ ButtonAdd.UseVisualStyleBackColor = true;
+ ButtonAdd.Click += ButtonAdd_Click;
+ //
+ // ButtonUpd
+ //
+ ButtonUpd.Location = new Point(654, 47);
+ ButtonUpd.Name = "ButtonUpd";
+ ButtonUpd.Size = new Size(147, 29);
+ ButtonUpd.TabIndex = 3;
+ ButtonUpd.Text = "Изменить";
+ ButtonUpd.UseVisualStyleBackColor = true;
+ ButtonUpd.Click += ButtonUpd_Click;
+ //
+ // ButtonDel
+ //
+ ButtonDel.Location = new Point(654, 82);
+ ButtonDel.Name = "ButtonDel";
+ ButtonDel.Size = new Size(147, 29);
+ ButtonDel.TabIndex = 4;
+ ButtonDel.Text = "Удалить";
+ ButtonDel.UseVisualStyleBackColor = true;
+ ButtonDel.Click += ButtonDel_Click;
+ //
+ // ButtonRef
+ //
+ ButtonRef.Location = new Point(654, 117);
+ ButtonRef.Name = "ButtonRef";
+ ButtonRef.Size = new Size(147, 29);
+ ButtonRef.TabIndex = 5;
+ ButtonRef.Text = "Обновить";
+ ButtonRef.UseVisualStyleBackColor = true;
+ ButtonRef.Click += ButtonRef_Click;
+ //
+ // ButtonFilter
+ //
+ ButtonFilter.Location = new Point(653, 316);
+ ButtonFilter.Name = "ButtonFilter";
+ ButtonFilter.Size = new Size(147, 29);
+ ButtonFilter.TabIndex = 6;
+ ButtonFilter.Text = "Наложить фильтр";
+ ButtonFilter.UseVisualStyleBackColor = true;
+ ButtonFilter.Click += ButtonFilter_Click;
+ //
+ // ButtonDrop
+ //
+ ButtonDrop.Location = new Point(653, 351);
+ ButtonDrop.Name = "ButtonDrop";
+ ButtonDrop.Size = new Size(147, 29);
+ ButtonDrop.TabIndex = 7;
+ ButtonDrop.Text = "Сбросить";
+ ButtonDrop.UseVisualStyleBackColor = true;
+ ButtonDrop.Click += ButtonDrop_Click;
+ //
+ // comboBoxFilter
+ //
+ comboBoxFilter.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxFilter.FormattingEnabled = true;
+ comboBoxFilter.Items.AddRange(new object[] { "Имя", "Группа" });
+ comboBoxFilter.Location = new Point(653, 240);
+ comboBoxFilter.Name = "comboBoxFilter";
+ comboBoxFilter.Size = new Size(147, 28);
+ comboBoxFilter.TabIndex = 8;
+ //
+ // textBoxFilter
+ //
+ textBoxFilter.Location = new Point(653, 274);
+ textBoxFilter.Name = "textBoxFilter";
+ textBoxFilter.Size = new Size(147, 27);
+ textBoxFilter.TabIndex = 9;
+ //
+ // labelTime
+ //
+ labelTime.AutoSize = true;
+ labelTime.Location = new Point(653, 208);
+ labelTime.Name = "labelTime";
+ labelTime.Size = new Size(42, 20);
+ labelTime.TabIndex = 12;
+ labelTime.Text = "Time";
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(653, 188);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(51, 20);
+ labelCount.TabIndex = 13;
+ labelCount.Text = "Count:";
+ //
+ // FormStudent
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(812, 449);
+ Controls.Add(labelCount);
+ Controls.Add(labelTime);
+ Controls.Add(textBoxFilter);
+ Controls.Add(comboBoxFilter);
+ Controls.Add(ButtonDrop);
+ Controls.Add(ButtonFilter);
+ Controls.Add(ButtonRef);
+ Controls.Add(ButtonDel);
+ Controls.Add(ButtonUpd);
+ Controls.Add(ButtonAdd);
+ Controls.Add(dataGridView);
+ FormBorderStyle = FormBorderStyle.FixedToolWindow;
+ Name = "FormStudent";
+ Text = "Студент";
+ Load += FormStudent_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button ButtonAdd;
+ private Button ButtonUpd;
+ private Button ButtonDel;
+ private Button ButtonRef;
+ private Button ButtonFilter;
+ private Button ButtonDrop;
+ private ComboBox comboBoxFilter;
+ private TextBox textBoxFilter;
+ private Label labelTime;
+ private Label labelCount;
+ }
+}
\ No newline at end of file
diff --git a/SUBD/SUBD/FormStudent.cs b/SUBD/SUBD/FormStudent.cs
new file mode 100644
index 0000000..ccde1ff
--- /dev/null
+++ b/SUBD/SUBD/FormStudent.cs
@@ -0,0 +1,166 @@
+using ElectronicJournalContracts.BindingModels;
+using ElectronicJournalContracts.BusinessLogicContracts;
+using ElectronicJournalContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Diagnostics;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace SUBD
+{
+ public partial class FormStudent : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IStudentLogic _studentLogic;
+ public FormStudent(ILogger logger, IStudentLogic studentLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _studentLogic = studentLogic;
+ }
+ private void LoadData()
+ {
+ try
+ {
+ Stopwatch stopwatch = new Stopwatch();
+ stopwatch.Start();
+ var list = _studentLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ dataGridView.Columns["GroupId"].Visible = false;
+ }
+ _logger.LogInformation("Загрузка студента");
+ stopwatch.Stop();
+ TimeSpan ts = stopwatch.Elapsed;
+ string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
+ ts.Hours, ts.Minutes, ts.Seconds,
+ ts.Milliseconds / 10);
+ labelTime.Text = ("RunTime " + elapsedTime);
+ labelCount.Text = "Count: " + list.Count();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки студента");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service =
+ Program.ServiceProvider?.GetService(typeof(FormCreateStudent));
+ if (service is FormCreateStudent form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void ButtonUpd_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service =
+ Program.ServiceProvider?.GetService(typeof(FormCreateStudent));
+ if (service is FormCreateStudent form)
+ {
+ form.Id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (MessageBox.Show("Удалить студента?", "Вопрос",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ _logger.LogInformation("Студент удален");
+ try
+ {
+ if (!_studentLogic.Delete(new StudentBindingModel
+ {
+ Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value),
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления студент");
+ MessageBox.Show(ex.Message, "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void ButtonFilter_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ StudentSearchModel model = new StudentSearchModel();
+ model.Id = 9999;
+ switch (comboBoxFilter.SelectedItem)
+ {
+ case "Имя":
+ model.Name = textBoxFilter.Text;
+ break;
+ case "Группа":
+ model.GroupName = textBoxFilter.Text;
+ break;
+ default:
+ LoadData();
+ break;
+ }
+ var list = _studentLogic.ReadList(model);
+ if (list != null)
+ {
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ dataGridView.Columns["GroupId"].Visible = false;
+ }
+ _logger.LogInformation("Загрузка студента");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки студентов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonDrop_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void FormStudent_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/SUBD/SUBD/FormStudent.resx b/SUBD/SUBD/FormStudent.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SUBD/SUBD/FormStudent.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD/SUBD/FormTeacher.Designer.cs b/SUBD/SUBD/FormTeacher.Designer.cs
new file mode 100644
index 0000000..138a64b
--- /dev/null
+++ b/SUBD/SUBD/FormTeacher.Designer.cs
@@ -0,0 +1,189 @@
+namespace SUBD
+{
+ partial class FormTeacher
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView = new DataGridView();
+ ButtonAdd = new Button();
+ ButtonUpd = new Button();
+ ButtonDelete = new Button();
+ ButtonRef = new Button();
+ textBoxFilter = new TextBox();
+ comboBoxFilter = new ComboBox();
+ ButtonDrop = new Button();
+ ButtonFilter = new Button();
+ labelCount = new Label();
+ labelTime = new Label();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 9);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowHeadersWidth = 51;
+ dataGridView.RowTemplate.Height = 29;
+ dataGridView.Size = new Size(719, 426);
+ dataGridView.TabIndex = 0;
+ //
+ // ButtonAdd
+ //
+ ButtonAdd.Location = new Point(737, 12);
+ ButtonAdd.Name = "ButtonAdd";
+ ButtonAdd.Size = new Size(146, 29);
+ ButtonAdd.TabIndex = 1;
+ ButtonAdd.Text = "Добавить";
+ ButtonAdd.UseVisualStyleBackColor = true;
+ ButtonAdd.Click += ButtonAdd_Click;
+ //
+ // ButtonUpd
+ //
+ ButtonUpd.Location = new Point(737, 47);
+ ButtonUpd.Name = "ButtonUpd";
+ ButtonUpd.Size = new Size(146, 29);
+ ButtonUpd.TabIndex = 2;
+ ButtonUpd.Text = "Изменить";
+ ButtonUpd.UseVisualStyleBackColor = true;
+ ButtonUpd.Click += ButtonUpd_Click;
+ //
+ // ButtonDelete
+ //
+ ButtonDelete.Location = new Point(737, 82);
+ ButtonDelete.Name = "ButtonDelete";
+ ButtonDelete.Size = new Size(146, 29);
+ ButtonDelete.TabIndex = 3;
+ ButtonDelete.Text = "Удалить";
+ ButtonDelete.UseVisualStyleBackColor = true;
+ ButtonDelete.Click += ButtonDelete_Click;
+ //
+ // ButtonRef
+ //
+ ButtonRef.Location = new Point(737, 117);
+ ButtonRef.Name = "ButtonRef";
+ ButtonRef.Size = new Size(146, 29);
+ ButtonRef.TabIndex = 4;
+ ButtonRef.Text = "Обновить";
+ ButtonRef.UseVisualStyleBackColor = true;
+ ButtonRef.Click += ButtonRef_Click;
+ //
+ // textBoxFilter
+ //
+ textBoxFilter.Location = new Point(737, 275);
+ textBoxFilter.Name = "textBoxFilter";
+ textBoxFilter.Size = new Size(146, 27);
+ textBoxFilter.TabIndex = 15;
+ //
+ // comboBoxFilter
+ //
+ comboBoxFilter.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxFilter.FormattingEnabled = true;
+ comboBoxFilter.Items.AddRange(new object[] { "Имя", "Ученое звание" });
+ comboBoxFilter.Location = new Point(737, 241);
+ comboBoxFilter.Name = "comboBoxFilter";
+ comboBoxFilter.Size = new Size(146, 28);
+ comboBoxFilter.TabIndex = 14;
+ //
+ // ButtonDrop
+ //
+ ButtonDrop.Location = new Point(737, 343);
+ ButtonDrop.Name = "ButtonDrop";
+ ButtonDrop.Size = new Size(146, 29);
+ ButtonDrop.TabIndex = 13;
+ ButtonDrop.Text = "Сбросить";
+ ButtonDrop.UseVisualStyleBackColor = true;
+ ButtonDrop.Click += ButtonDrop_Click;
+ //
+ // ButtonFilter
+ //
+ ButtonFilter.Location = new Point(737, 308);
+ ButtonFilter.Name = "ButtonFilter";
+ ButtonFilter.Size = new Size(146, 29);
+ ButtonFilter.TabIndex = 12;
+ ButtonFilter.Text = "Наложить фильтр";
+ ButtonFilter.UseVisualStyleBackColor = true;
+ ButtonFilter.Click += ButtonFilter_Click;
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(737, 177);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(48, 20);
+ labelCount.TabIndex = 16;
+ labelCount.Text = "Count";
+ //
+ // labelTime
+ //
+ labelTime.AutoSize = true;
+ labelTime.Location = new Point(737, 208);
+ labelTime.Name = "labelTime";
+ labelTime.Size = new Size(42, 20);
+ labelTime.TabIndex = 17;
+ labelTime.Text = "Time";
+ //
+ // FormTeacher
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(907, 450);
+ Controls.Add(labelTime);
+ Controls.Add(labelCount);
+ Controls.Add(textBoxFilter);
+ Controls.Add(comboBoxFilter);
+ Controls.Add(ButtonDrop);
+ Controls.Add(ButtonFilter);
+ Controls.Add(ButtonRef);
+ Controls.Add(ButtonDelete);
+ Controls.Add(ButtonUpd);
+ Controls.Add(ButtonAdd);
+ Controls.Add(dataGridView);
+ FormBorderStyle = FormBorderStyle.FixedToolWindow;
+ Name = "FormTeacher";
+ Text = "Преподаватель";
+ Load += FormTeacher_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button ButtonAdd;
+ private Button ButtonUpd;
+ private Button ButtonDelete;
+ private Button ButtonRef;
+ private TextBox textBoxFilter;
+ private ComboBox comboBoxFilter;
+ private Button ButtonDrop;
+ private Button ButtonFilter;
+ private Label labelCount;
+ private Label labelTime;
+ }
+}
\ No newline at end of file
diff --git a/SUBD/SUBD/FormTeacher.cs b/SUBD/SUBD/FormTeacher.cs
new file mode 100644
index 0000000..2da3d8d
--- /dev/null
+++ b/SUBD/SUBD/FormTeacher.cs
@@ -0,0 +1,154 @@
+using ElectronicJournalBusinessLogic.BusinessLogic;
+using ElectronicJournalContracts.BindingModels;
+using ElectronicJournalContracts.BusinessLogicContracts;
+using ElectronicJournalContracts.SearchModels;
+using Microsoft.Extensions.Logging;
+using System.Diagnostics;
+
+namespace SUBD
+{
+ public partial class FormTeacher : Form
+ {
+ private readonly ILogger _logger;
+ private readonly ITeacherLogic _teacherLogic;
+ public FormTeacher(ILogger logger, ITeacherLogic teacherLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _teacherLogic = teacherLogic;
+ }
+ private void LoadData()
+ {
+ try
+ {
+ Stopwatch stopwatch = new Stopwatch();
+ stopwatch.Start();
+ var list = _teacherLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ }
+ _logger.LogInformation("Загрузка преподавателей");
+ stopwatch.Stop();
+ TimeSpan ts = stopwatch.Elapsed;
+ string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
+ ts.Hours, ts.Minutes, ts.Seconds,
+ ts.Milliseconds / 10);
+ labelTime.Text = ("RunTime " + elapsedTime);
+ labelCount.Text = "Count: " + list.Count();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки преподавателей");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ var service =
+ Program.ServiceProvider?.GetService(typeof(FormCreateTeacher));
+ if (service is FormCreateTeacher form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void FormTeacher_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void ButtonUpd_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service =
+ Program.ServiceProvider?.GetService(typeof(FormCreateTeacher));
+ if (service is FormCreateTeacher form)
+ {
+ form.Id =
+ Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+ private void ButtonFilter_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ TeacherSearchModel model = new TeacherSearchModel();
+ model.Id = 9999;
+ switch (comboBoxFilter.SelectedItem)
+ {
+ case "Имя":
+ model.Name = textBoxFilter.Text;
+ break;
+ case "Ученое звание":
+ model.AcademicTitle = textBoxFilter.Text;
+ break;
+ default:
+ LoadData();
+ break;
+ }
+ var list = _teacherLogic.ReadList(model);
+ if (list != null)
+ {
+ dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
+ dataGridView.DataSource = list;
+ dataGridView.Columns["Id"].Visible = false;
+ }
+ _logger.LogInformation("Загрузка учителей");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки заказов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
+ MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonDrop_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void ButtonDelete_Click(object sender, EventArgs e)
+ {
+ if (MessageBox.Show("Удалить преподавателя?", "Вопрос",
+ MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ _logger.LogInformation("Преподаватель удален");
+ try
+ {
+ if (!_teacherLogic.Delete(new TeacherBindingModel
+ {
+ Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value),
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления преподавателя");
+ MessageBox.Show(ex.Message, "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+}
diff --git a/SUBD/SUBD/FormTeacher.resx b/SUBD/SUBD/FormTeacher.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SUBD/SUBD/FormTeacher.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD/SUBD/Program.cs b/SUBD/SUBD/Program.cs
index 6bba20c..6c13402 100644
--- a/SUBD/SUBD/Program.cs
+++ b/SUBD/SUBD/Program.cs
@@ -1,17 +1,56 @@
+using ElectronicJournalBusinessLogic.BusinessLogic;
+using ElectronicJournalContracts.BusinessLogicContracts;
+using ElectronicJournalContracts.StorageContracts;
+using ElectronicJournalDatabaseImplement.Implements;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+
namespace SUBD
{
internal static class Program
{
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
- // To customize application configuration such as set high DPI settings or default font,
- // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new FormElectronicJournal());
+ var services = new ServiceCollection();
+ ConfigureServices(services);
+ _serviceProvider = services.BuildServiceProvider();
+ Application.Run(_serviceProvider.GetRequiredService());
+ }
+ private static void ConfigureServices(ServiceCollection services)
+ {
+ services.AddLogging(option =>
+ {
+ option.SetMinimumLevel(LogLevel.Information);
+ option.AddNLog("nlog.config");
+ });
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
}
}
}
\ No newline at end of file
diff --git a/SUBD/SUBD/SUBD.csproj b/SUBD/SUBD/SUBD.csproj
index 1751b9d..035a35e 100644
--- a/SUBD/SUBD/SUBD.csproj
+++ b/SUBD/SUBD/SUBD.csproj
@@ -13,9 +13,13 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+