добавление части форм
This commit is contained in:
parent
aba05229f9
commit
c267472976
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
97
SUBD/SUBD/FormCreateDiscipline.Designer.cs
generated
Normal file
97
SUBD/SUBD/FormCreateDiscipline.Designer.cs
generated
Normal file
@ -0,0 +1,97 @@
|
||||
namespace SUBD
|
||||
{
|
||||
partial class FormCreateDiscipline
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
85
SUBD/SUBD/FormCreateDiscipline.cs
Normal file
85
SUBD/SUBD/FormCreateDiscipline.cs
Normal file
@ -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<FormCreateDiscipline> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
SUBD/SUBD/FormCreateDiscipline.resx
Normal file
60
SUBD/SUBD/FormCreateDiscipline.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
124
SUBD/SUBD/FormCreateGroup.Designer.cs
generated
Normal file
124
SUBD/SUBD/FormCreateGroup.Designer.cs
generated
Normal file
@ -0,0 +1,124 @@
|
||||
namespace SUBD
|
||||
{
|
||||
partial class FormCreateGroup
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
95
SUBD/SUBD/FormCreateGroup.cs
Normal file
95
SUBD/SUBD/FormCreateGroup.cs
Normal file
@ -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<FormCreateGroup> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
SUBD/SUBD/FormCreateGroup.resx
Normal file
60
SUBD/SUBD/FormCreateGroup.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
121
SUBD/SUBD/FormCreateStudent.Designer.cs
generated
Normal file
121
SUBD/SUBD/FormCreateStudent.Designer.cs
generated
Normal file
@ -0,0 +1,121 @@
|
||||
namespace SUBD
|
||||
{
|
||||
partial class FormCreateStudent
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
106
SUBD/SUBD/FormCreateStudent.cs
Normal file
106
SUBD/SUBD/FormCreateStudent.cs
Normal file
@ -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<FormCreateStudent> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
SUBD/SUBD/FormCreateStudent.resx
Normal file
60
SUBD/SUBD/FormCreateStudent.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
119
SUBD/SUBD/FormCreateTeacher.Designer.cs
generated
Normal file
119
SUBD/SUBD/FormCreateTeacher.Designer.cs
generated
Normal file
@ -0,0 +1,119 @@
|
||||
namespace SUBD
|
||||
{
|
||||
partial class FormCreateTeacher
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
87
SUBD/SUBD/FormCreateTeacher.cs
Normal file
87
SUBD/SUBD/FormCreateTeacher.cs
Normal file
@ -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<FormCreateTeacher> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
SUBD/SUBD/FormCreateTeacher.resx
Normal file
60
SUBD/SUBD/FormCreateTeacher.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
192
SUBD/SUBD/FormDiscipline.Designer.cs
generated
Normal file
192
SUBD/SUBD/FormDiscipline.Designer.cs
generated
Normal file
@ -0,0 +1,192 @@
|
||||
namespace SUBD
|
||||
{
|
||||
partial class FormDiscipline
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
150
SUBD/SUBD/FormDiscipline.cs
Normal file
150
SUBD/SUBD/FormDiscipline.cs
Normal file
@ -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<FormDiscipline> 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();
|
||||
}
|
||||
}
|
||||
}
|
120
SUBD/SUBD/FormDiscipline.resx
Normal file
120
SUBD/SUBD/FormDiscipline.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
192
SUBD/SUBD/FormGroup.Designer.cs
generated
Normal file
192
SUBD/SUBD/FormGroup.Designer.cs
generated
Normal file
@ -0,0 +1,192 @@
|
||||
namespace SUBD
|
||||
{
|
||||
partial class FormGroup
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
154
SUBD/SUBD/FormGroup.cs
Normal file
154
SUBD/SUBD/FormGroup.cs
Normal file
@ -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<FormGroup> 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();
|
||||
}
|
||||
}
|
||||
}
|
120
SUBD/SUBD/FormGroup.resx
Normal file
120
SUBD/SUBD/FormGroup.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
189
SUBD/SUBD/FormStudent.Designer.cs
generated
Normal file
189
SUBD/SUBD/FormStudent.Designer.cs
generated
Normal file
@ -0,0 +1,189 @@
|
||||
namespace SUBD
|
||||
{
|
||||
partial class FormStudent
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
166
SUBD/SUBD/FormStudent.cs
Normal file
166
SUBD/SUBD/FormStudent.cs
Normal file
@ -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<FormStudent> 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();
|
||||
}
|
||||
}
|
||||
}
|
60
SUBD/SUBD/FormStudent.resx
Normal file
60
SUBD/SUBD/FormStudent.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
189
SUBD/SUBD/FormTeacher.Designer.cs
generated
Normal file
189
SUBD/SUBD/FormTeacher.Designer.cs
generated
Normal file
@ -0,0 +1,189 @@
|
||||
namespace SUBD
|
||||
{
|
||||
partial class FormTeacher
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
154
SUBD/SUBD/FormTeacher.cs
Normal file
154
SUBD/SUBD/FormTeacher.cs
Normal file
@ -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<FormTeacher> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
SUBD/SUBD/FormTeacher.resx
Normal file
60
SUBD/SUBD/FormTeacher.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -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;
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[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<FormStudent>());
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddLogging(option =>
|
||||
{
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddNLog("nlog.config");
|
||||
});
|
||||
services.AddTransient<IResultOfControlStorage, ResultOfControlStorage>();
|
||||
services.AddTransient<IStatementStorage, StatementStorage>();
|
||||
services.AddTransient<ITeacherStorage, TeacherStorage>();
|
||||
services.AddTransient<IStudentStorage, StudentStorage>();
|
||||
services.AddTransient<IDisciplineStorage, DisciplineStorage>();
|
||||
services.AddTransient<IGroupStorage, GroupStorage>();
|
||||
services.AddTransient<IResultOfControlLogic, ResultOfControlLogic>();
|
||||
services.AddTransient<IStatementLogic, StatementLogic>();
|
||||
services.AddTransient<ITeacherLogic, TeacherLogic>();
|
||||
services.AddTransient<IStudentLogic, StudentLogic>();
|
||||
services.AddTransient<IDisciplineLogic, DisciplineLogic>();
|
||||
services.AddTransient<IGroupLogic, GroupLogic>();
|
||||
services.AddTransient<FormDiscipline>();
|
||||
services.AddTransient<FormTeacher>();
|
||||
services.AddTransient<FormGroup>();
|
||||
services.AddTransient<FormStudent>();
|
||||
services.AddTransient<FormCreateDiscipline>();
|
||||
services.AddTransient<FormCreateTeacher>();
|
||||
services.AddTransient<FormCreateGroup>();
|
||||
services.AddTransient<FormCreateStudent>();
|
||||
}
|
||||
}
|
||||
}
|
@ -13,9 +13,13 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.3" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ElectronicJournalBusinessLogic\ElectronicJournalBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\ElectronicJournalDatabaseImplement\ElectronicJournalDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user