какой то коммит

This commit is contained in:
gg12 darfren 2024-04-08 22:02:19 +04:00
parent 35f58ba3bc
commit e763e1179b
54 changed files with 4433 additions and 177 deletions

View File

@ -1,39 +0,0 @@
namespace SchoolSchedule
{
partial class Form1
{
/// <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()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace SchoolSchedule
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,141 @@
namespace SchoolSchedule
{
partial class GradeForm
{
/// <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()
{
textBox1 = new TextBox();
label1 = new Label();
comboBox1 = new ComboBox();
label2 = new Label();
label3 = new Label();
textBox2 = new TextBox();
button1 = new Button();
button2 = new Button();
SuspendLayout();
//
// textBox1
//
textBox1.Location = new Point(159, 35);
textBox1.Name = "textBox1";
textBox1.Size = new Size(100, 23);
textBox1.TabIndex = 0;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(12, 9);
label1.Name = "label1";
label1.Size = new Size(141, 15);
label1.TabIndex = 1;
label1.Text = "Классный руководитель";
//
// comboBox1
//
comboBox1.FormattingEnabled = true;
comboBox1.Location = new Point(159, 6);
comboBox1.Name = "comboBox1";
comboBox1.Size = new Size(233, 23);
comboBox1.TabIndex = 2;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(115, 43);
label2.Name = "label2";
label2.Size = new Size(38, 15);
label2.TabIndex = 3;
label2.Text = "Буква";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(115, 72);
label3.Name = "label3";
label3.Size = new Size(26, 15);
label3.TabIndex = 4;
label3.Text = "Год";
//
// textBox2
//
textBox2.Location = new Point(159, 64);
textBox2.Name = "textBox2";
textBox2.Size = new Size(100, 23);
textBox2.TabIndex = 5;
//
// button1
//
button1.Location = new Point(236, 93);
button1.Name = "button1";
button1.Size = new Size(75, 23);
button1.TabIndex = 6;
button1.Text = "Добавить";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click;
//
// button2
//
button2.Location = new Point(317, 93);
button2.Name = "button2";
button2.Size = new Size(75, 23);
button2.TabIndex = 7;
button2.Text = "Отмена";
button2.UseVisualStyleBackColor = true;
button2.Click += button2_Click;
//
// GradeForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(400, 128);
Controls.Add(button2);
Controls.Add(button1);
Controls.Add(textBox2);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(comboBox1);
Controls.Add(label1);
Controls.Add(textBox1);
Name = "GradeForm";
Text = "GradeForm";
Load += GradeForm_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBox1;
private Label label1;
private ComboBox comboBox1;
private Label label2;
private Label label3;
private TextBox textBox2;
private Button button1;
private Button button2;
}
}

View File

@ -0,0 +1,130 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.BusinessLogicsContracts;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.ViewModels;
using SchoolScheduleDataModels.Models;
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 SchoolSchedule
{
public partial class GradeForm : Form
{
private readonly ITeacherLogic _logicT;
private readonly IGradeLogic _logicG;
private int? _id;
public int Id { set { _id = value; } }
public GradeForm(ITeacherLogic logicT, IGradeLogic logicG)
{
InitializeComponent();
_logicT = logicT;
_logicG = logicG;
}
private void GradeForm_Load(object sender, EventArgs e)
{
try
{
var list = _logicT.ReadList(null);
if (list != null)
{
comboBox1.DisplayMember = "FullName";
comboBox1.ValueMember = "Id";
comboBox1.DataSource = list;
comboBox1.SelectedItem = null;
}
if (_id.HasValue)
{
var dbind = _logicG.ReadElement(new GradeSearchModel { Id = _id });
for (int i = 0; i < comboBox1.Items.Count; i++)
{
if (list[i].Id == dbind.TeacherId)
comboBox1.SelectedIndex = i;
}
textBox1.Text = dbind.Letter.ToString();
textBox2.Text = dbind.Year.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void button1_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text))
{
MessageBox.Show("Заполните поле Буква", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (textBox1.Text.Length > 1 || !(textBox1.Text[0] >= 'A' && textBox1.Text[0] <= 'Z'))
{
MessageBox.Show("Поле буква должно быть одной заглавной буквой латинского алфавита", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBox2.Text))
{
MessageBox.Show("Заполните поле Год", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBox1.SelectedValue == null)
{
MessageBox.Show("Выберите классного руководителя", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
int year = int.Parse(textBox2.Text);
if (!(year >= 1 && year <= 11))
{
throw new Exception("Ошибка при создании заказа. Год должен быть числом от 1 до 11");
}
GradeBindingModel model = new GradeBindingModel
{
Id = (_id.HasValue ? _id.Value : 0),
TeacherId = Convert.ToInt32(comboBox1.SelectedValue),
Letter = textBox1.Text[0],
Year = year,
};
var operationResult = (_id.HasValue ? _logicG.Update(model) : _logicG.Create(model));
if (!operationResult)
{
throw new Exception("Ошибка при создании заказа.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void button2_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -0,0 +1,112 @@
namespace SchoolSchedule
{
partial class GradesForm
{
/// <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()
{
dataGridView1 = new DataGridView();
AddButton = new Button();
ChangeButton = new Button();
DeleteButton = new Button();
RefreshButton = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Location = new Point(12, 12);
dataGridView1.Name = "dataGridView1";
dataGridView1.Size = new Size(352, 289);
dataGridView1.TabIndex = 0;
//
// AddButton
//
AddButton.Location = new Point(370, 12);
AddButton.Name = "AddButton";
AddButton.Size = new Size(148, 23);
AddButton.TabIndex = 1;
AddButton.Text = "Добавить";
AddButton.UseVisualStyleBackColor = true;
AddButton.Click += AddButton_Click;
//
// ChangeButton
//
ChangeButton.Location = new Point(370, 41);
ChangeButton.Name = "ChangeButton";
ChangeButton.Size = new Size(148, 23);
ChangeButton.TabIndex = 2;
ChangeButton.Text = "Изменить";
ChangeButton.UseVisualStyleBackColor = true;
ChangeButton.Click += ChangeButton_Click;
//
// DeleteButton
//
DeleteButton.Location = new Point(370, 70);
DeleteButton.Name = "DeleteButton";
DeleteButton.Size = new Size(148, 23);
DeleteButton.TabIndex = 3;
DeleteButton.Text = "Удалить";
DeleteButton.UseVisualStyleBackColor = true;
DeleteButton.Click += DeleteButton_Click;
//
// RefreshButton
//
RefreshButton.Location = new Point(370, 99);
RefreshButton.Name = "RefreshButton";
RefreshButton.Size = new Size(148, 23);
RefreshButton.TabIndex = 4;
RefreshButton.Text = "Обновить";
RefreshButton.UseVisualStyleBackColor = true;
RefreshButton.Click += RefreshButton_Click;
//
// GradesForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(557, 315);
Controls.Add(RefreshButton);
Controls.Add(DeleteButton);
Controls.Add(ChangeButton);
Controls.Add(AddButton);
Controls.Add(dataGridView1);
Name = "GradesForm";
Text = "GradesForm";
Load += GradesForm_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private Button AddButton;
private Button ChangeButton;
private Button DeleteButton;
private Button RefreshButton;
}
}

View File

@ -0,0 +1,121 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.BusinessLogicsContracts;
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 SchoolSchedule
{
public partial class GradesForm : Form
{
private readonly IGradeLogic _logic;
public GradesForm(IGradeLogic logic)
{
InitializeComponent();
_logic = logic;
}
private void GradesForm_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView1.DataSource = list;
dataGridView1.Columns["Id"].Visible = false;
dataGridView1.Columns["TeacherId"].Visible = false;
dataGridView1.Columns["Year"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns["Letter"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns["TeacherFullName"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void AddButton_Click(object sender, EventArgs e)
{
var service =
Program.ServiceProvider?.GetService(typeof(GradeForm));
if (service is GradeForm form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ChangeButton_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count == 1)
{
var service =
Program.ServiceProvider?.GetService(typeof(GradeForm));
if (service is GradeForm form)
{
form.Id =
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void DeleteButton_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id =
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_logic.Delete(new GradeBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void RefreshButton_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View 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>

View File

@ -0,0 +1,210 @@
namespace SchoolSchedule
{
partial class LessonCreateForm
{
/// <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()
{
dateTimePicker1 = new DateTimePicker();
timeCombo = new ComboBox();
teacherCombo = new ComboBox();
subjectCombo = new ComboBox();
homeworkBox = new TextBox();
gradeCombo = new ComboBox();
label1 = new Label();
label2 = new Label();
label3 = new Label();
label4 = new Label();
label5 = new Label();
label6 = new Label();
AddButton = new Button();
CancelButton = new Button();
SuspendLayout();
//
// dateTimePicker1
//
dateTimePicker1.Location = new Point(148, 12);
dateTimePicker1.Name = "dateTimePicker1";
dateTimePicker1.Size = new Size(200, 23);
dateTimePicker1.TabIndex = 0;
//
// timeCombo
//
timeCombo.FormattingEnabled = true;
timeCombo.Location = new Point(148, 41);
timeCombo.Name = "timeCombo";
timeCombo.Size = new Size(200, 23);
timeCombo.TabIndex = 1;
//
// teacherCombo
//
teacherCombo.FormattingEnabled = true;
teacherCombo.Location = new Point(148, 70);
teacherCombo.Name = "teacherCombo";
teacherCombo.Size = new Size(200, 23);
teacherCombo.TabIndex = 2;
//
// subjectCombo
//
subjectCombo.FormattingEnabled = true;
subjectCombo.Location = new Point(148, 99);
subjectCombo.Name = "subjectCombo";
subjectCombo.Size = new Size(200, 23);
subjectCombo.TabIndex = 3;
//
// homeworkBox
//
homeworkBox.Location = new Point(147, 157);
homeworkBox.Name = "homeworkBox";
homeworkBox.Size = new Size(200, 23);
homeworkBox.TabIndex = 4;
//
// gradeCombo
//
gradeCombo.FormattingEnabled = true;
gradeCombo.Location = new Point(148, 128);
gradeCombo.Name = "gradeCombo";
gradeCombo.Size = new Size(200, 23);
gradeCombo.TabIndex = 5;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(98, 18);
label1.Name = "label1";
label1.Size = new Size(32, 15);
label1.TabIndex = 6;
label1.Text = "Дата";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(98, 44);
label2.Name = "label2";
label2.Size = new Size(42, 15);
label2.TabIndex = 7;
label2.Text = "Время";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(88, 73);
label3.Name = "label3";
label3.Size = new Size(52, 15);
label3.TabIndex = 8;
label3.Text = "Учитель";
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(81, 102);
label4.Name = "label4";
label4.Size = new Size(55, 15);
label4.TabIndex = 9;
label4.Text = "Предмет";
//
// label5
//
label5.AutoSize = true;
label5.Location = new Point(98, 131);
label5.Name = "label5";
label5.Size = new Size(39, 15);
label5.TabIndex = 10;
label5.Text = "Класс";
//
// label6
//
label6.AutoSize = true;
label6.Location = new Point(27, 160);
label6.Name = "label6";
label6.Size = new Size(114, 15);
label6.TabIndex = 11;
label6.Text = "Доамашняя работа";
//
// AddButton
//
AddButton.Location = new Point(192, 186);
AddButton.Name = "AddButton";
AddButton.Size = new Size(75, 23);
AddButton.TabIndex = 12;
AddButton.Text = "Добавить";
AddButton.UseVisualStyleBackColor = true;
AddButton.Click += AddButton_Click;
//
// CancelButton
//
CancelButton.Location = new Point(273, 186);
CancelButton.Name = "CancelButton";
CancelButton.Size = new Size(75, 23);
CancelButton.TabIndex = 13;
CancelButton.Text = "Отмена";
CancelButton.UseVisualStyleBackColor = true;
CancelButton.Click += CancelButton_Click;
//
// LessonCreateForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(367, 230);
Controls.Add(CancelButton);
Controls.Add(AddButton);
Controls.Add(label6);
Controls.Add(label5);
Controls.Add(label4);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(gradeCombo);
Controls.Add(homeworkBox);
Controls.Add(subjectCombo);
Controls.Add(teacherCombo);
Controls.Add(timeCombo);
Controls.Add(dateTimePicker1);
Name = "LessonCreateForm";
Text = "LessonCreateForm";
Load += LessonCreateForm_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private DateTimePicker dateTimePicker1;
private ComboBox timeCombo;
private ComboBox teacherCombo;
private ComboBox subjectCombo;
private TextBox homeworkBox;
private ComboBox gradeCombo;
private Label label1;
private Label label2;
private Label label3;
private Label label4;
private Label label5;
private Label label6;
private Button AddButton;
private Button CancelButton;
}
}

View File

@ -0,0 +1,203 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.BusinessLogicsContracts;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleDataBaseImplement.Models;
using SchoolScheduleDataModels.Enums;
using SchoolScheduleDataModels.Models;
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;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace SchoolSchedule
{
public partial class LessonCreateForm : Form
{
private readonly ISubjectLogic _logicS;
private readonly IStudentLogic _logicSt;
private readonly IGradeLogic _logicG;
private readonly ITeacherLogic _logicT;
private readonly ISchedulePlaceLogic _logicD;
private readonly ILessonLogic _logicL;
private int? _id;
public int Id { set { _id = value; } }
public LessonCreateForm(ISubjectLogic logicS, IGradeLogic logicG, ITeacherLogic logicT, ISchedulePlaceLogic logicD, ILessonLogic logicL, IStudentLogic logicSt)
{
_logicS = logicS;
_logicG = logicG;
_logicT = logicT;
_logicD = logicD;
_logicL = logicL;
_logicSt = logicSt;
InitializeComponent();
}
private void LessonCreateForm_Load(object sender, EventArgs e)
{
try
{
var listG = _logicG.ReadList(null);
if (listG != null)
{
gradeCombo.DisplayMember = "FullName";
gradeCombo.ValueMember = "Id";
gradeCombo.DataSource = listG;
gradeCombo.SelectedItem = null;
}
var listT = _logicT.ReadList(null);
if (listT != null)
{
teacherCombo.DisplayMember = "FullName";
teacherCombo.ValueMember = "Id";
teacherCombo.DataSource = listT;
teacherCombo.SelectedItem = null;
}
var listS = _logicS.ReadList(null);
if (listT != null)
{
subjectCombo.DisplayMember = "SubjectName";
subjectCombo.ValueMember = "Id";
subjectCombo.DataSource = listS;
subjectCombo.SelectedItem = null;
}
var listD = _logicD.ReadList(null);
if (listT != null)
{
timeCombo.DisplayMember = "Time";
timeCombo.ValueMember = "Id";
timeCombo.DataSource = listD;
timeCombo.SelectedItem = null;
}
if (_id.HasValue)
{
if (_id.HasValue)
{
var dbind = _logicL.ReadElement(new LessonSearchModel { Id = _id });
for (int i = 0; i < gradeCombo.Items.Count; i++)
{
if (listG[i].Id == dbind.GradeId)
gradeCombo.SelectedIndex = i;
}
for (int i = 0; i < subjectCombo.Items.Count; i++)
{
if (listS[i].Id == dbind.SubjectId)
subjectCombo.SelectedIndex = i;
}
for (int i = 0; i < teacherCombo.Items.Count; i++)
{
if (listT[i].Id == dbind.GradeId)
teacherCombo.SelectedIndex = i;
}
for (int i = 0; i < timeCombo.Items.Count; i++)
{
if (listD[i].Id == dbind.SchedulePlaceId)
timeCombo.SelectedIndex = i;
}
homeworkBox.Text = dbind.Homework;
dateTimePicker1.Value = dbind.Date.ToDateTime(TimeOnly.Parse("00:00 AM"));
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void AddButton_Click(object sender, EventArgs e)
{
if (gradeCombo.SelectedValue == null)
{
MessageBox.Show("Выберите класс", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (subjectCombo.SelectedValue == null)
{
MessageBox.Show("Выберите предмет", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (timeCombo.SelectedValue == null)
{
MessageBox.Show("Выберите Время", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (teacherCombo.SelectedValue == null)
{
MessageBox.Show("Выберите учителя", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
LessonBindingModel model = new LessonBindingModel
{
Id = (_id.HasValue ? _id.Value : 0),
GradeId = Convert.ToInt32(gradeCombo.SelectedValue),
TeacherId = Convert.ToInt32(teacherCombo.SelectedValue),
SubjectId = Convert.ToInt32(subjectCombo.SelectedValue),
SchedulePlaceId = Convert.ToInt32(timeCombo.SelectedValue),
Homework = homeworkBox.Text,
Date = DateOnly.FromDateTime(dateTimePicker1.Value)
};
var operationResult = (_id.HasValue ? _logicL.Update(model) : _logicL.Create(model));
if (!operationResult)
{
throw new Exception("Ошибка при создании занятия.");
}
var list = _logicG.GetStudents(new GradeSearchModel { Id = model.GradeId });
var lst = _logicL.ReadList(null);
ILessonModel cur = null;
foreach (var lesson in lst)
{
if (lesson.SubjectId == model.SubjectId && lesson.GradeId == model.GradeId && lesson.TeacherId == model.TeacherId &&
lesson.SchedulePlaceId == model.SchedulePlaceId && lesson.Date == model.Date)
cur = lesson;
}
foreach (var student in list)
{
if (student.Attendance.ContainsKey(cur.Id))
continue;
student.Attendance[cur.Id] = (cur, StudentStatus.ПР, null);
_logicSt.Update(new StudentBindingModel
{
Id = student.Id,
FullName = student.FullName,
GradeId = student.GradeId,
Attendance = student.Attendance
}
);
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void CancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View 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>

View File

@ -0,0 +1,105 @@
namespace SchoolSchedule
{
partial class LessonForm
{
/// <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()
{
dataGridView1 = new DataGridView();
Name = new DataGridViewTextBoxColumn();
Status = new DataGridViewTextBoxColumn();
Mark = new DataGridViewTextBoxColumn();
ChangeButton = new Button();
CancelButton = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Columns.AddRange(new DataGridViewColumn[] { Name, Status, Mark });
dataGridView1.Location = new Point(12, 12);
dataGridView1.Name = "dataGridView1";
dataGridView1.Size = new Size(462, 401);
dataGridView1.TabIndex = 0;
//
// Name
//
Name.HeaderText = "ФИО";
Name.Name = "Name";
Name.Width = 200;
//
// Status
//
Status.HeaderText = "Статус";
Status.Name = "Status";
//
// Mark
//
Mark.HeaderText = "Оценка";
Mark.Name = "Mark";
//
// ChangeButton
//
ChangeButton.Location = new Point(318, 419);
ChangeButton.Name = "ChangeButton";
ChangeButton.Size = new Size(75, 30);
ChangeButton.TabIndex = 1;
ChangeButton.Text = "Изменить";
ChangeButton.UseVisualStyleBackColor = true;
//
// CancelButton
//
CancelButton.Location = new Point(399, 419);
CancelButton.Name = "CancelButton";
CancelButton.Size = new Size(75, 30);
CancelButton.TabIndex = 2;
CancelButton.Text = "Отмена";
CancelButton.UseVisualStyleBackColor = true;
//
// LessonForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(486, 455);
Controls.Add(CancelButton);
Controls.Add(ChangeButton);
Controls.Add(dataGridView1);
Text = "LessonForm";
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private DataGridViewTextBoxColumn Name;
private DataGridViewTextBoxColumn Status;
private DataGridViewTextBoxColumn Mark;
private Button ChangeButton;
private Button CancelButton;
}
}

View File

@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Diagnostics;
using SchoolScheduleContracts.BusinessLogicsContracts;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleDataModels.Models;
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 SchoolSchedule
{
public partial class LessonForm : Form
{
public ILessonModel Lesson { get; set; } = null;
IStudentLogic _logic;
public LessonForm(IStudentLogic logic)
{
_logic = logic;
InitializeComponent();
LoadData();
}
public void LoadData()
{
if (Lesson != null)
{
var students = _logic.ReadList(new StudentSearchModel { GradeId = Lesson.GradeId });
foreach (var student in students)
{
dataGridView1.Rows.Clear();
dataGridView1.Rows.Add(new object[] { student.FullName, student.Attendance[Lesson.Id].Item2, student.Attendance[Lesson.Id].Item3 });
}
}
}
}
}

View File

@ -0,0 +1,129 @@
<?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>
<metadata name="Name.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Status.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Mark.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,86 @@
namespace SchoolSchedule
{
partial class LessonsForm
{
/// <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()
{
dataGridView1 = new DataGridView();
OpenButton = new Button();
AddButton = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Location = new Point(12, 12);
dataGridView1.Name = "dataGridView1";
dataGridView1.Size = new Size(472, 426);
dataGridView1.TabIndex = 0;
//
// OpenButton
//
OpenButton.Location = new Point(12, 444);
OpenButton.Name = "OpenButton";
OpenButton.Size = new Size(472, 32);
OpenButton.TabIndex = 1;
OpenButton.Text = "Открыть журнал";
OpenButton.UseVisualStyleBackColor = true;
OpenButton.Click += OpenButton_Click;
//
// AddButton
//
AddButton.Location = new Point(13, 482);
AddButton.Name = "AddButton";
AddButton.Size = new Size(471, 32);
AddButton.TabIndex = 2;
AddButton.Text = "Добавить занятие";
AddButton.UseVisualStyleBackColor = true;
AddButton.Click += AddButton_Click;
//
// LessonsForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(495, 521);
Controls.Add(AddButton);
Controls.Add(OpenButton);
Controls.Add(dataGridView1);
Name = "LessonsForm";
Text = "LessonsForm";
Load += LessonsForm_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private Button OpenButton;
private Button AddButton;
}
}

View File

@ -0,0 +1,93 @@
using SchoolScheduleContracts.BusinessLogicsContracts;
using SchoolScheduleContracts.SearchModels;
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 SchoolSchedule
{
public partial class LessonsForm : Form
{
private readonly ILessonLogic _logic;
public LessonsForm(ILessonLogic logic)
{
_logic = logic;
InitializeComponent();
}
private void LessonsForm_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView1.DataSource = list;
dataGridView1.Columns["Id"].Visible = false;
dataGridView1.Columns["SchedulePlaceId"].Visible = false;
dataGridView1.Columns["TeacherId"].Visible = false;
dataGridView1.Columns["SubjectId"].Visible = false;
dataGridView1.Columns["GradeId"].Visible = false;
dataGridView1.Columns["Date"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns["SchedulePlaceTime"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns["TeacherFullName"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns["SubjectName"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns["GradeName"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void AddButton_Click(object sender, EventArgs e)
{
var service =
Program.ServiceProvider?.GetService(typeof(LessonCreateForm));
if (service is LessonCreateForm form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void OpenButton_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count == 1)
{
var service =
Program.ServiceProvider?.GetService(typeof(LessonForm));
if (service is LessonForm form)
{
form.Lesson =
_logic.ReadElement(new LessonSearchModel { Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value) });
form.LoadData();
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
}
}

View 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>

View File

@ -1,17 +1,53 @@
using Microsoft.Extensions.DependencyInjection;
using SchoolScheduleBusinessLogic;
using SchoolScheduleContracts.BusinessLogicsContracts;
using SchoolScheduleContracts.StoragesContracts;
using SchoolScheduleDataBaseImplement.Implements;
namespace SchoolSchedule
{
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 Form1());
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<LessonsForm>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddTransient<ISubjectStorage, SubjectStorage>();
services.AddTransient<ITeacherStorage, TeacherStorage>();
services.AddTransient<ILessonStorage, LessonStorage>();
services.AddTransient<IGradeStorage, GradeStorage>();
services.AddTransient<ISchedulePlaceStorage, SchedulePlaceStorage>();
services.AddTransient<IStudentStorage, StudentStorage>();
services.AddTransient<ISubjectLogic, SubjectLogic>();
services.AddTransient<ITeacherLogic, TeacherLogic>();
services.AddTransient<IStudentLogic, StudentLogic>();
services.AddTransient<ISchedulePlaceLogic, SchedulePlaceLogic>();
services.AddTransient<ILessonLogic, LessonLogic>();
services.AddTransient<IGradeLogic, GradeLogic>();
services.AddTransient<SubjectForm>();
services.AddTransient<SubjectsForm>();
services.AddTransient<TeacherForm>();
services.AddTransient<TeachersForm>();
services.AddTransient<GradeForm>();
services.AddTransient<GradesForm>();
services.AddTransient<StudentForm>();
services.AddTransient<StudentsForm>();
services.AddTransient<LessonCreateForm>();
services.AddTransient<LessonsForm>();
services.AddTransient<LessonForm>();
}
}
}

View File

@ -16,6 +16,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SchoolScheduleBusinessLogic\SchoolScheduleBusinessLogic.csproj" />
<ProjectReference Include="..\SchoolScheduleDataBaseImplement\SchoolScheduleDataBaseImplement.csproj" />
</ItemGroup>

View File

@ -0,0 +1,119 @@
namespace SchoolSchedule
{
partial class StudentForm
{
/// <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()
{
comboBox1 = new ComboBox();
textBox1 = new TextBox();
label1 = new Label();
label2 = new Label();
AddButton = new Button();
CancelButton = new Button();
SuspendLayout();
//
// comboBox1
//
comboBox1.FormattingEnabled = true;
comboBox1.Location = new Point(56, 12);
comboBox1.Name = "comboBox1";
comboBox1.Size = new Size(216, 23);
comboBox1.TabIndex = 0;
//
// textBox1
//
textBox1.Location = new Point(56, 41);
textBox1.Name = "textBox1";
textBox1.Size = new Size(216, 23);
textBox1.TabIndex = 1;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(12, 15);
label1.Name = "label1";
label1.Size = new Size(39, 15);
label1.TabIndex = 2;
label1.Text = "Класс";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(21, 44);
label2.Name = "label2";
label2.Size = new Size(30, 15);
label2.TabIndex = 3;
label2.Text = "Фио";
//
// AddButton
//
AddButton.Location = new Point(117, 70);
AddButton.Name = "AddButton";
AddButton.Size = new Size(75, 23);
AddButton.TabIndex = 4;
AddButton.Text = "Добавить";
AddButton.UseVisualStyleBackColor = true;
AddButton.Click += AddButton_Click;
//
// CancelButton
//
CancelButton.Location = new Point(199, 70);
CancelButton.Name = "CancelButton";
CancelButton.Size = new Size(73, 23);
CancelButton.TabIndex = 5;
CancelButton.Text = "Отмена";
CancelButton.UseVisualStyleBackColor = true;
CancelButton.Click += CancelButton_Click;
//
// StudentForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(280, 101);
Controls.Add(CancelButton);
Controls.Add(AddButton);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(textBox1);
Controls.Add(comboBox1);
Name = "StudentForm";
Text = "StudentForm";
Load += StudentForm_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private ComboBox comboBox1;
private TextBox textBox1;
private Label label1;
private Label label2;
private Button AddButton;
private Button CancelButton;
}
}

View File

@ -0,0 +1,106 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.BusinessLogicsContracts;
using SchoolScheduleContracts.SearchModels;
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;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace SchoolSchedule
{
public partial class StudentForm : Form
{
private readonly IStudentLogic _logicS;
private readonly IGradeLogic _logicG;
private int? _id;
public int Id { set { _id = value; } }
public StudentForm(IStudentLogic logicS, IGradeLogic logicG)
{
InitializeComponent();
_logicG = logicG;
_logicS = logicS;
}
private void StudentForm_Load(object sender, EventArgs e)
{
try
{
var list = _logicG.ReadList(null);
if (list != null)
{
comboBox1.DisplayMember = "FullName";
comboBox1.ValueMember = "Id";
comboBox1.DataSource = list;
comboBox1.SelectedItem = null;
}
if (_id.HasValue)
{
var dbind = _logicS.ReadElement(new StudentSearchModel { Id = _id });
for (int i = 0; i < comboBox1.Items.Count; i++)
{
if (list[i].Id == dbind.GradeId)
comboBox1.SelectedIndex = i;
}
textBox1.Text = dbind.FullName.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void AddButton_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text))
{
MessageBox.Show("Заполните поле Фио", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBox1.SelectedValue == null)
{
MessageBox.Show("Выберите класс", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
StudentBindingModel model = new StudentBindingModel
{
Id = (_id.HasValue ? _id.Value : 0),
FullName = textBox1.Text,
GradeId = Convert.ToInt32(comboBox1.SelectedValue),
};
var operationResult = (_id.HasValue ? _logicS.Update(model) : _logicS.Create(model));
if (!operationResult)
{
throw new Exception("Ошибка при создании ученика.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void CancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View 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>

View File

@ -0,0 +1,112 @@
namespace SchoolSchedule
{
partial class StudentsForm
{
/// <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()
{
dataGridView1 = new DataGridView();
AddButton = new Button();
ChangeButton = new Button();
DeleteButton = new Button();
RefreshButton = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Location = new Point(12, 12);
dataGridView1.Name = "dataGridView1";
dataGridView1.Size = new Size(442, 356);
dataGridView1.TabIndex = 0;
//
// AddButton
//
AddButton.Location = new Point(460, 12);
AddButton.Name = "AddButton";
AddButton.Size = new Size(122, 23);
AddButton.TabIndex = 1;
AddButton.Text = "Добавить";
AddButton.UseVisualStyleBackColor = true;
AddButton.Click += AddButton_Click;
//
// ChangeButton
//
ChangeButton.Location = new Point(460, 41);
ChangeButton.Name = "ChangeButton";
ChangeButton.Size = new Size(122, 23);
ChangeButton.TabIndex = 2;
ChangeButton.Text = "Изменить";
ChangeButton.UseVisualStyleBackColor = true;
ChangeButton.Click += ChangeButton_Click;
//
// DeleteButton
//
DeleteButton.Location = new Point(460, 70);
DeleteButton.Name = "DeleteButton";
DeleteButton.Size = new Size(122, 23);
DeleteButton.TabIndex = 3;
DeleteButton.Text = "Удалить";
DeleteButton.UseVisualStyleBackColor = true;
DeleteButton.Click += DeleteButton_Click;
//
// RefreshButton
//
RefreshButton.Location = new Point(460, 99);
RefreshButton.Name = "RefreshButton";
RefreshButton.Size = new Size(122, 23);
RefreshButton.TabIndex = 4;
RefreshButton.Text = "Обновить";
RefreshButton.UseVisualStyleBackColor = true;
RefreshButton.Click += RefreshButton_Click;
//
// StudentsForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(624, 380);
Controls.Add(RefreshButton);
Controls.Add(DeleteButton);
Controls.Add(ChangeButton);
Controls.Add(AddButton);
Controls.Add(dataGridView1);
Name = "StudentsForm";
Text = "StudentsForm";
Load += StudentsForm_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private Button AddButton;
private Button ChangeButton;
private Button DeleteButton;
private Button RefreshButton;
}
}

View File

@ -0,0 +1,118 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.BusinessLogicsContracts;
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 SchoolSchedule
{
public partial class StudentsForm : Form
{
private readonly IStudentLogic _logic;
public StudentsForm(IStudentLogic logic)
{
InitializeComponent();
_logic = logic;
}
private void StudentsForm_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView1.DataSource = list;
dataGridView1.Columns["Id"].Visible = false;
dataGridView1.Columns["Attendance"].Visible = false;
dataGridView1.Columns["GradeId"].Visible = false;
dataGridView1.Columns["GradeName"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns["FullName"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void AddButton_Click(object sender, EventArgs e)
{
var service =
Program.ServiceProvider?.GetService(typeof(StudentForm));
if (service is StudentForm form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ChangeButton_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count == 1)
{
var service =
Program.ServiceProvider?.GetService(typeof(StudentForm));
if (service is StudentForm form)
{
form.Id =
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void DeleteButton_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id =
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_logic.Delete(new StudentBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void RefreshButton_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View 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>

View File

@ -0,0 +1,98 @@
namespace SchoolSchedule
{
partial class SubjectForm
{
/// <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()
{
sqlCommandBuilder1 = new Microsoft.Data.SqlClient.SqlCommandBuilder();
textBox1 = new TextBox();
label1 = new Label();
AddButton = new Button();
CancelButton = new Button();
SuspendLayout();
//
// textBox1
//
textBox1.Location = new Point(77, 12);
textBox1.Name = "textBox1";
textBox1.Size = new Size(204, 23);
textBox1.TabIndex = 0;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(12, 15);
label1.Name = "label1";
label1.Size = new Size(59, 15);
label1.TabIndex = 1;
label1.Text = "Название";
//
// AddButton
//
AddButton.Location = new Point(125, 41);
AddButton.Name = "AddButton";
AddButton.Size = new Size(75, 23);
AddButton.TabIndex = 2;
AddButton.Text = "Добавить";
AddButton.UseVisualStyleBackColor = true;
AddButton.Click += AddButton_Click;
//
// CancelButton
//
CancelButton.Location = new Point(206, 41);
CancelButton.Name = "CancelButton";
CancelButton.Size = new Size(75, 23);
CancelButton.TabIndex = 3;
CancelButton.Text = "Отмена";
CancelButton.UseVisualStyleBackColor = true;
CancelButton.Click += CancelButton_Click;
//
// SubjectForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(287, 68);
Controls.Add(CancelButton);
Controls.Add(AddButton);
Controls.Add(label1);
Controls.Add(textBox1);
Name = "SubjectForm";
Text = "SubjectForm";
Load += SubjectForm_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Microsoft.Data.SqlClient.SqlCommandBuilder sqlCommandBuilder1;
private TextBox textBox1;
private Label label1;
private Button AddButton;
private Button CancelButton;
}
}

View File

@ -0,0 +1,93 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.BusinessLogicsContracts;
using SchoolScheduleContracts.SearchModels;
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 SchoolSchedule
{
public partial class SubjectForm : Form
{
private readonly ISubjectLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public SubjectForm(ISubjectLogic logic)
{
_logic = logic;
InitializeComponent();
}
private void SubjectForm_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _logic.ReadElement(new SubjectSearchModel
{
Id =
_id.Value
});
if (view != null)
{
textBox1.Text = view.SubjectName;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void AddButton_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text))
{
MessageBox.Show("Заполните название", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new SubjectBindingModel
{
Id = _id ?? 0,
SubjectName = textBox1.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)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void CancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,123 @@
<?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>
<metadata name="sqlCommandBuilder1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,112 @@
namespace SchoolSchedule
{
partial class SubjectsForm
{
/// <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()
{
dataGridView1 = new DataGridView();
AddButton = new Button();
DeleteButton = new Button();
ChangeButton = new Button();
RefreshButton = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Location = new Point(12, 12);
dataGridView1.Name = "dataGridView1";
dataGridView1.Size = new Size(369, 269);
dataGridView1.TabIndex = 0;
//
// AddButton
//
AddButton.Location = new Point(387, 12);
AddButton.Name = "AddButton";
AddButton.Size = new Size(75, 23);
AddButton.TabIndex = 1;
AddButton.Text = "Добавить";
AddButton.UseVisualStyleBackColor = true;
AddButton.Click += AddButton_Click;
//
// DeleteButton
//
DeleteButton.Location = new Point(387, 70);
DeleteButton.Name = "DeleteButton";
DeleteButton.Size = new Size(75, 23);
DeleteButton.TabIndex = 2;
DeleteButton.Text = "Удалить";
DeleteButton.UseVisualStyleBackColor = true;
DeleteButton.Click += DeleteButton_Click;
//
// ChangeButton
//
ChangeButton.Location = new Point(387, 41);
ChangeButton.Name = "ChangeButton";
ChangeButton.Size = new Size(75, 23);
ChangeButton.TabIndex = 3;
ChangeButton.Text = "Изменить";
ChangeButton.UseVisualStyleBackColor = true;
ChangeButton.Click += ChangeButton_Click;
//
// RefreshButton
//
RefreshButton.Location = new Point(387, 99);
RefreshButton.Name = "RefreshButton";
RefreshButton.Size = new Size(75, 23);
RefreshButton.TabIndex = 4;
RefreshButton.Text = "Обновить";
RefreshButton.UseVisualStyleBackColor = true;
RefreshButton.Click += RefreshButton_Click;
//
// SubjectsForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(501, 289);
Controls.Add(RefreshButton);
Controls.Add(ChangeButton);
Controls.Add(DeleteButton);
Controls.Add(AddButton);
Controls.Add(dataGridView1);
Name = "SubjectsForm";
Text = "SubjectsForm";
Load += SubjectsForm_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private Button AddButton;
private Button DeleteButton;
private Button ChangeButton;
private Button RefreshButton;
}
}

View File

@ -0,0 +1,118 @@
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.Logging;
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.BusinessLogicsContracts;
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 SchoolSchedule
{
public partial class SubjectsForm : Form
{
private readonly ISubjectLogic _logic;
public SubjectsForm(ISubjectLogic logic)
{
_logic = logic;
InitializeComponent();
}
private void SubjectsForm_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView1.DataSource = list;
dataGridView1.Columns["Id"].Visible = false;
dataGridView1.Columns["SubjectName"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void AddButton_Click(object sender, EventArgs e)
{
var service =
Program.ServiceProvider?.GetService(typeof(SubjectForm));
if (service is SubjectForm form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void DeleteButton_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id =
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_logic.Delete(new SubjectBindingModel
{
Id = id
}))
{
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ChangeButton_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count == 1)
{
var service =
Program.ServiceProvider?.GetService(typeof(SubjectForm));
if (service is SubjectForm form)
{
form.Id =
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void RefreshButton_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View 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>

View File

@ -0,0 +1,96 @@
namespace SchoolSchedule
{
partial class TeacherForm
{
/// <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()
{
textBox1 = new TextBox();
label1 = new Label();
AddButton = new Button();
CancelButton = new Button();
SuspendLayout();
//
// textBox1
//
textBox1.Location = new Point(48, 12);
textBox1.Name = "textBox1";
textBox1.Size = new Size(357, 23);
textBox1.TabIndex = 0;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(12, 15);
label1.Name = "label1";
label1.Size = new Size(30, 15);
label1.TabIndex = 1;
label1.Text = "Фио";
//
// AddButton
//
AddButton.Location = new Point(249, 41);
AddButton.Name = "AddButton";
AddButton.Size = new Size(75, 23);
AddButton.TabIndex = 2;
AddButton.Text = "Добавить";
AddButton.UseVisualStyleBackColor = true;
AddButton.Click += AddButton_Click;
//
// CancelButton
//
CancelButton.Location = new Point(330, 41);
CancelButton.Name = "CancelButton";
CancelButton.Size = new Size(75, 23);
CancelButton.TabIndex = 3;
CancelButton.Text = "Отмена";
CancelButton.UseVisualStyleBackColor = true;
CancelButton.Click += CancelButton_Click;
//
// TeacherForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(417, 68);
Controls.Add(CancelButton);
Controls.Add(AddButton);
Controls.Add(label1);
Controls.Add(textBox1);
Name = "TeacherForm";
Text = "TeacherForm";
Load += TeacherForm_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBox1;
private Label label1;
private Button AddButton;
private Button CancelButton;
}
}

View File

@ -0,0 +1,92 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.BusinessLogicsContracts;
using SchoolScheduleContracts.SearchModels;
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 SchoolSchedule
{
public partial class TeacherForm : Form
{
ITeacherLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public TeacherForm(ITeacherLogic logic)
{
_logic = logic;
InitializeComponent();
}
private void TeacherForm_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _logic.ReadElement(new TeacherSearchModel
{
Id =
_id.Value
});
if (view != null)
{
textBox1.Text = view.FullName;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void AddButton_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text))
{
MessageBox.Show("Заполните название", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new TeacherBindingModel
{
Id = _id ?? 0,
FullName = textBox1.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)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void CancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View 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>

View File

@ -0,0 +1,112 @@
namespace SchoolSchedule
{
partial class TeachersForm
{
/// <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()
{
dataGridView1 = new DataGridView();
AddButton = new Button();
ChangeButton = new Button();
DeleteButton = new Button();
RefreshButton = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Location = new Point(12, 12);
dataGridView1.Name = "dataGridView1";
dataGridView1.Size = new Size(359, 305);
dataGridView1.TabIndex = 0;
//
// AddButton
//
AddButton.Location = new Point(377, 12);
AddButton.Name = "AddButton";
AddButton.Size = new Size(112, 23);
AddButton.TabIndex = 1;
AddButton.Text = "Добавить";
AddButton.UseVisualStyleBackColor = true;
AddButton.Click += AddButton_Click;
//
// ChangeButton
//
ChangeButton.Location = new Point(377, 41);
ChangeButton.Name = "ChangeButton";
ChangeButton.Size = new Size(112, 23);
ChangeButton.TabIndex = 2;
ChangeButton.Text = "Изменить";
ChangeButton.UseVisualStyleBackColor = true;
ChangeButton.Click += ChangeButton_Click;
//
// DeleteButton
//
DeleteButton.Location = new Point(377, 70);
DeleteButton.Name = "DeleteButton";
DeleteButton.Size = new Size(112, 23);
DeleteButton.TabIndex = 3;
DeleteButton.Text = "Удалить";
DeleteButton.UseVisualStyleBackColor = true;
DeleteButton.Click += DeleteButton_Click;
//
// RefreshButton
//
RefreshButton.Location = new Point(377, 99);
RefreshButton.Name = "RefreshButton";
RefreshButton.Size = new Size(112, 23);
RefreshButton.TabIndex = 4;
RefreshButton.Text = "Обновить";
RefreshButton.UseVisualStyleBackColor = true;
RefreshButton.Click += RefreshButton_Click;
//
// TeachersForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(526, 323);
Controls.Add(RefreshButton);
Controls.Add(DeleteButton);
Controls.Add(ChangeButton);
Controls.Add(AddButton);
Controls.Add(dataGridView1);
Name = "TeachersForm";
Text = "TeachersForm";
Load += TeachersForm_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private Button AddButton;
private Button ChangeButton;
private Button DeleteButton;
private Button RefreshButton;
}
}

View File

@ -0,0 +1,118 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.BusinessLogicsContracts;
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 SchoolSchedule
{
public partial class TeachersForm : Form
{
private readonly ITeacherLogic _logic;
public TeachersForm(ITeacherLogic logic)
{
_logic = logic;
InitializeComponent();
}
private void TeachersForm_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView1.DataSource = list;
dataGridView1.Columns["Id"].Visible = false;
dataGridView1.Columns["FullName"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void AddButton_Click(object sender, EventArgs e)
{
var service =
Program.ServiceProvider?.GetService(typeof(TeacherForm));
if (service is TeacherForm form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ChangeButton_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count == 1)
{
var service =
Program.ServiceProvider?.GetService(typeof(TeacherForm));
if (service is TeacherForm form)
{
form.Id =
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void DeleteButton_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id =
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_logic.Delete(new TeacherBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void RefreshButton_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View 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>

View File

@ -18,5 +18,7 @@ namespace SchoolScheduleContracts.ViewModels
public int TeacherId { get; set; }
[DisplayName("Классный руководитель")]
public string TeacherFullName { get; set; }
[DisplayName("Название")]
public string FullName { get; set; }
}
}

View File

@ -0,0 +1,84 @@
using Microsoft.EntityFrameworkCore;
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.StoragesContracts;
using SchoolScheduleContracts.ViewModels;
using SchoolScheduleDataBaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataBaseImplement.Implements
{
public class GradeStorage : IGradeStorage
{
public List<GradeViewModel> GetFullList()
{
using var context = new SchoolScheduleDataBase();
return context.Grades.Include(x => x.Teacher)
.Select(x => x.GetViewModel)
.ToList();
}
public List<GradeViewModel> GetFilteredList(GradeSearchModel model)
{
using var context = new SchoolScheduleDataBase();
return context.Grades.Include(x => x.Teacher)
.Where(x => (!model.Id.HasValue || x.Id == model.Id) && (!model.Letter.HasValue || x.Letter == model.Letter)
&& (!model.Year.HasValue || x.Year == model.Year))
.Select(x => x.GetViewModel)
.ToList();
}
public GradeViewModel? GetElement(GradeSearchModel model)
{
if (!model.Id.HasValue && (!model.Letter.HasValue || !model.Year.HasValue))
{
return null;
}
using var context = new SchoolScheduleDataBase();
return context.Grades.Include(x => x.Teacher)
.FirstOrDefault(x =>
(model.Id.HasValue && x.Id == model.Id) || (model.Letter.HasValue && model.Year.HasValue && x.Year == model.Year && x.Letter == model.Letter))
?.GetViewModel;
}
public GradeViewModel? Insert(GradeBindingModel model)
{
using var context = new SchoolScheduleDataBase();
var newComponent = Grade.Create(context, model);
if (newComponent == null)
{
return null;
}
context.Grades.Add(newComponent);
context.SaveChanges();
return newComponent.GetViewModel;
}
public GradeViewModel? Update(GradeBindingModel model)
{
using var context = new SchoolScheduleDataBase();
var component = context.Grades.FirstOrDefault(x => x.Id ==
model.Id);
if (component == null)
{
return null;
}
component.Update(context, model);
context.SaveChanges();
return component.GetViewModel;
}
public GradeViewModel? Delete(GradeBindingModel model)
{
using var context = new SchoolScheduleDataBase();
var element = context.Grades.FirstOrDefault(rec => rec.Id ==
model.Id);
if (element != null)
{
context.Grades.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,83 @@
using Microsoft.EntityFrameworkCore;
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.StoragesContracts;
using SchoolScheduleContracts.ViewModels;
using SchoolScheduleDataBaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataBaseImplement.Implements
{
public class LessonStorage : ILessonStorage
{
public List<LessonViewModel> GetFullList()
{
using var context = new SchoolScheduleDataBase();
return context.Lessons.Include(x => x.Grade).Include(x => x.Subject).Include(x => x.SchedulePlace).Include(x => x.Teacher)
.Select(x => x.GetViewModel)
.ToList();
}
public List<LessonViewModel> GetFilteredList(LessonSearchModel model)
{
using var context = new SchoolScheduleDataBase();
return context.Lessons.Include(x => x.Grade)
.Where(x => (!model.Id.HasValue || x.Id == model.Id) && (!model.GradeId.HasValue || x.GradeId == model.GradeId)
&& (!model.TeacherId.HasValue || x.TeacherId == model.TeacherId) && (!model.SubjectId.HasValue || x.TeacherId == model.SubjectId)
&& (!model.Date.HasValue || x.Date == model.Date) && (!model.SchedulePlaceId.HasValue || x.SchedulePlaceId == model.SchedulePlaceId)
&& (!model.DateFrom.HasValue || x.Date >= model.DateFrom) && (!model.DateTo.HasValue || x.Date <= model.DateTo))
.Select(x => x.GetViewModel)
.ToList();
}
public LessonViewModel? GetElement(LessonSearchModel model)
{
using var context = new SchoolScheduleDataBase();
return context.Lessons.Include(x => x.Teacher)
.FirstOrDefault(x => (!model.Id.HasValue || x.Id == model.Id) && (!model.GradeId.HasValue || x.GradeId == model.GradeId)
&& (!model.TeacherId.HasValue || x.TeacherId == model.TeacherId) && (!model.SubjectId.HasValue || x.TeacherId == model.SubjectId)
&& (!model.Date.HasValue || x.Date == model.Date) && (!model.SchedulePlaceId.HasValue || x.SchedulePlaceId == model.SchedulePlaceId))
?.GetViewModel;
}
public LessonViewModel? Insert(LessonBindingModel model)
{
using var context = new SchoolScheduleDataBase();
var newComponent = Lesson.Create(context, model);
if (newComponent == null)
{
return null;
}
context.Lessons.Add(newComponent);
context.SaveChanges();
return newComponent.GetViewModel;
}
public LessonViewModel? Update(LessonBindingModel model)
{
using var context = new SchoolScheduleDataBase();
var component = context.Lessons.FirstOrDefault(x => x.Id ==
model.Id);
if (component == null)
{
return null;
}
component.Update(context, model);
context.SaveChanges();
return component.GetViewModel;
}
public LessonViewModel? Delete(LessonBindingModel model)
{
using var context = new SchoolScheduleDataBase();
var element = context.Lessons.FirstOrDefault(rec => rec.Id ==
model.Id);
if (element != null)
{
context.Lessons.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,86 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.StoragesContracts;
using SchoolScheduleContracts.ViewModels;
using SchoolScheduleDataBaseImplement.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataBaseImplement.Implements
{
public class SchedulePlaceStorage : ISchedulePlaceStorage
{
public List<SchedulePlaceViewModel> GetFullList()
{
using var context = new SchoolScheduleDataBase();
return context.SchedulePlaces
.Select(x => x.GetViewModel)
.ToList();
}
public List<SchedulePlaceViewModel> GetFilteredList(SchedulePlaceSearchModel model)
{
if (!model.Id.HasValue)
{
return new();
}
using var context = new SchoolScheduleDataBase();
return context.SchedulePlaces
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
public SchedulePlaceViewModel? GetElement(SchedulePlaceSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new SchoolScheduleDataBase();
return context.SchedulePlaces
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
}
public SchedulePlaceViewModel? Insert(SchedulePlaceBindingModel model)
{
var newComponent = SchedulePlace.Create(model);
if (newComponent == null)
{
return null;
}
using var context = new SchoolScheduleDataBase();
context.SchedulePlaces.Add(newComponent);
context.SaveChanges();
return newComponent.GetViewModel;
}
public SchedulePlaceViewModel? Update(SchedulePlaceBindingModel model)
{
using var context = new SchoolScheduleDataBase();
var component = context.SchedulePlaces.FirstOrDefault(x => x.Id ==
model.Id);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
public SchedulePlaceViewModel? Delete(SchedulePlaceBindingModel model)
{
using var context = new SchoolScheduleDataBase();
var element = context.SchedulePlaces.FirstOrDefault(rec => rec.Id ==
model.Id);
if (element != null)
{
context.SchedulePlaces.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,102 @@
using Microsoft.EntityFrameworkCore;
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.BusinessLogicsContracts;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.StoragesContracts;
using SchoolScheduleContracts.ViewModels;
using SchoolScheduleDataBaseImplement.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataBaseImplement.Implements
{
public class StudentStorage : IStudentStorage
{
public List<StudentViewModel> GetFullList()
{
using var context = new SchoolScheduleDataBase();
return context.Students.Include(x => x.Grade)
.Select(x => x.GetViewModel)
.ToList();
}
public List<StudentViewModel> GetFilteredList(StudentSearchModel model)
{
using var context = new SchoolScheduleDataBase();
return context.Students.Include(x => x.Grade)
.Where(x => (!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.FullName) || x.FullName == model.FullName)
&& (!model.GradeId.HasValue || x.GradeId == model.GradeId))
.Select(x => x.GetViewModel)
.ToList();
}
public StudentViewModel? GetElement(StudentSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new SchoolScheduleDataBase();
return context.Students.Include(x => x.Grade)
.FirstOrDefault(x =>
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public StudentViewModel? Insert(StudentBindingModel model)
{
using var context = new SchoolScheduleDataBase();
var newComponent = Student.Create(context, model);
if (newComponent == null)
{
return null;
}
context.Students.Add(newComponent);
context.SaveChanges();
return newComponent.GetViewModel;
}
public StudentViewModel? Update(StudentBindingModel model)
{
using var context = new SchoolScheduleDataBase();
using var transaction = context.Database.BeginTransaction();
try
{
var component = context.Students.FirstOrDefault(x => x.Id ==
model.Id);
if (component == null)
{
return null;
}
if (component == null)
{
return null;
}
component.Update(context, model);
context.SaveChanges();
component.UpdateAttendance(context, model);
transaction.Commit();
return component.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public StudentViewModel? Delete(StudentBindingModel model)
{
using var context = new SchoolScheduleDataBase();
var element = context.Students.FirstOrDefault(rec => rec.Id ==
model.Id);
if (element != null)
{
context.Students.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,91 @@
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.StoragesContracts;
using SchoolScheduleContracts.ViewModels;
using SchoolScheduleDataBaseImplement.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataBaseImplement.Implements
{
public class SubjectStorage : ISubjectStorage
{
public List<SubjectViewModel> GetFullList()
{
using var context = new SchoolScheduleDataBase();
return context.Subjects
.Select(x => x.GetViewModel)
.ToList();
}
public List<SubjectViewModel> GetFilteredList(SubjectSearchModel
model)
{
if (string.IsNullOrEmpty(model.SubjectName))
{
return new();
}
using var context = new SchoolScheduleDataBase();
return context.Subjects
.Where(x => x.SubjectName.Contains(model.SubjectName))
.Select(x => x.GetViewModel)
.ToList();
}
public SubjectViewModel? GetElement(SubjectSearchModel model)
{
if (string.IsNullOrEmpty(model.SubjectName) && !model.Id.HasValue)
{
return null;
}
using var context = new SchoolScheduleDataBase();
return context.Subjects
.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.SubjectName) && x.SubjectName ==
model.SubjectName) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public SubjectViewModel? Insert(SubjectBindingModel model)
{
using var context = new SchoolScheduleDataBase();
var newComponent = Subject.Create(context, model);
if (newComponent == null)
{
return null;
}
context.Subjects.Add(newComponent);
context.SaveChanges();
return newComponent.GetViewModel;
}
public SubjectViewModel? Update(SubjectBindingModel model)
{
using var context = new SchoolScheduleDataBase();
var component = context.Subjects.FirstOrDefault(x => x.Id ==
model.Id);
if (component == null)
{
return null;
}
component.Update(context, model);
context.SaveChanges();
return component.GetViewModel;
}
public SubjectViewModel? Delete(SubjectBindingModel model)
{
using var context = new SchoolScheduleDataBase();
var element = context.Subjects.FirstOrDefault(rec => rec.Id ==
model.Id);
if (element != null)
{
context.Subjects.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,82 @@
using Microsoft.EntityFrameworkCore;
using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.SearchModels;
using SchoolScheduleContracts.StoragesContracts;
using SchoolScheduleContracts.ViewModels;
using SchoolScheduleDataBaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataBaseImplement.Implements
{
public class TeacherStorage : ITeacherStorage
{
public List<TeacherViewModel> GetFullList()
{
using var context = new SchoolScheduleDataBase();
return context.Teachers.Include(x => x.Grade)
.Select(x => x.GetViewModel)
.ToList();
}
public List<TeacherViewModel> GetFilteredList(TeacherSearchModel model)
{
using var context = new SchoolScheduleDataBase();
return context.Teachers.Include(x => x.Grade)
.Where(x => (!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.FullName) || x.FullName == model.FullName))
.Select(x => x.GetViewModel)
.ToList();
}
public TeacherViewModel? GetElement(TeacherSearchModel model)
{
if (!model.Id.HasValue && string.IsNullOrEmpty(model.FullName))
{
return null;
}
using var context = new SchoolScheduleDataBase();
return context.Teachers.Include(x => x.Grade)
.FirstOrDefault(x => (!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.FullName) || x.FullName == model.FullName))
?.GetViewModel;
}
public TeacherViewModel? Insert(TeacherBindingModel model)
{
using var context = new SchoolScheduleDataBase();
var newComponent = Teacher.Create(context, model);
if (newComponent == null)
{
return null;
}
context.Teachers.Add(newComponent);
context.SaveChanges();
return newComponent.GetViewModel;
}
public TeacherViewModel? Update(TeacherBindingModel model)
{
using var context = new SchoolScheduleDataBase();
var component = context.Teachers.FirstOrDefault(x => x.Id ==
model.Id);
if (component == null)
{
return null;
}
component.Update(context, model);
context.SaveChanges();
return component.GetViewModel;
}
public TeacherViewModel? Delete(TeacherBindingModel model)
{
using var context = new SchoolScheduleDataBase();
var element = context.Teachers.FirstOrDefault(rec => rec.Id ==
model.Id);
if (element != null)
{
context.Teachers.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -12,7 +12,7 @@ using SchoolScheduleDataBaseImplement;
namespace SchoolScheduleDataBaseImplement.Migrations
{
[DbContext(typeof(SchoolScheduleDataBase))]
[Migration("20240408103656_InitialCreate")]
[Migration("20240408165811_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
@ -45,6 +45,8 @@ namespace SchoolScheduleDataBaseImplement.Migrations
b.HasKey("Id");
b.HasIndex("TeacherId");
b.ToTable("Grades");
});
@ -100,7 +102,6 @@ namespace SchoolScheduleDataBaseImplement.Migrations
.HasColumnType("int");
b.Property<int?>("Mark")
.IsRequired()
.HasColumnType("int");
b.Property<int>("Status")
@ -185,17 +186,22 @@ namespace SchoolScheduleDataBaseImplement.Migrations
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("TeacherId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TeacherId")
.IsUnique();
b.ToTable("Teachers");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Grade", b =>
{
b.HasOne("SchoolScheduleDataBaseImplement.Models.Teacher", "Teacher")
.WithMany("Grade")
.HasForeignKey("TeacherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Teacher");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Lesson", b =>
{
b.HasOne("SchoolScheduleDataBaseImplement.Models.Grade", "Grade")
@ -261,25 +267,11 @@ namespace SchoolScheduleDataBaseImplement.Migrations
b.Navigation("Grade");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Teacher", b =>
{
b.HasOne("SchoolScheduleDataBaseImplement.Models.Grade", "Grade")
.WithOne("Teacher")
.HasForeignKey("SchoolScheduleDataBaseImplement.Models.Teacher", "TeacherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Grade");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Grade", b =>
{
b.Navigation("Lessons");
b.Navigation("Students");
b.Navigation("Teacher")
.IsRequired();
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Lesson", b =>
@ -304,6 +296,8 @@ namespace SchoolScheduleDataBaseImplement.Migrations
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Teacher", b =>
{
b.Navigation("Grade");
b.Navigation("Lessons");
});
#pragma warning restore 612, 618

View File

@ -11,21 +11,6 @@ namespace SchoolScheduleDataBaseImplement.Migrations
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Grades",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Year = table.Column<int>(type: "int", nullable: false),
Letter = table.Column<string>(type: "nvarchar(1)", nullable: false),
TeacherId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Grades", x => x.Id);
});
migrationBuilder.CreateTable(
name: "SchedulePlaces",
columns: table => new
@ -52,44 +37,38 @@ namespace SchoolScheduleDataBaseImplement.Migrations
table.PrimaryKey("PK_Subjects", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Students",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FullName = table.Column<string>(type: "nvarchar(max)", nullable: false),
GradeId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Students", x => x.Id);
table.ForeignKey(
name: "FK_Students_Grades_GradeId",
column: x => x.GradeId,
principalTable: "Grades",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Teachers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FullName = table.Column<string>(type: "nvarchar(max)", nullable: false),
TeacherId = table.Column<int>(type: "int", nullable: false)
FullName = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Teachers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Grades",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Year = table.Column<int>(type: "int", nullable: false),
Letter = table.Column<string>(type: "nvarchar(1)", nullable: false),
TeacherId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Grades", x => x.Id);
table.ForeignKey(
name: "FK_Teachers_Grades_TeacherId",
name: "FK_Grades_Teachers_TeacherId",
column: x => x.TeacherId,
principalTable: "Grades",
principalTable: "Teachers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
@ -131,7 +110,27 @@ namespace SchoolScheduleDataBaseImplement.Migrations
column: x => x.TeacherId,
principalTable: "Teachers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Students",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FullName = table.Column<string>(type: "nvarchar(max)", nullable: false),
GradeId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Students", x => x.Id);
table.ForeignKey(
name: "FK_Students_Grades_GradeId",
column: x => x.GradeId,
principalTable: "Grades",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
@ -143,7 +142,7 @@ namespace SchoolScheduleDataBaseImplement.Migrations
StudentId = table.Column<int>(type: "int", nullable: false),
LessonId = table.Column<int>(type: "int", nullable: false),
Status = table.Column<int>(type: "int", nullable: false),
Mark = table.Column<int>(type: "int", nullable: false)
Mark = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
@ -162,6 +161,11 @@ namespace SchoolScheduleDataBaseImplement.Migrations
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_Grades_TeacherId",
table: "Grades",
column: "TeacherId");
migrationBuilder.CreateIndex(
name: "IX_Lessons_GradeId",
table: "Lessons",
@ -196,12 +200,6 @@ namespace SchoolScheduleDataBaseImplement.Migrations
name: "IX_Students_GradeId",
table: "Students",
column: "GradeId");
migrationBuilder.CreateIndex(
name: "IX_Teachers_TeacherId",
table: "Teachers",
column: "TeacherId",
unique: true);
}
/// <inheritdoc />
@ -223,10 +221,10 @@ namespace SchoolScheduleDataBaseImplement.Migrations
name: "Subjects");
migrationBuilder.DropTable(
name: "Teachers");
name: "Grades");
migrationBuilder.DropTable(
name: "Grades");
name: "Teachers");
}
}
}

View File

@ -42,6 +42,8 @@ namespace SchoolScheduleDataBaseImplement.Migrations
b.HasKey("Id");
b.HasIndex("TeacherId");
b.ToTable("Grades");
});
@ -97,7 +99,6 @@ namespace SchoolScheduleDataBaseImplement.Migrations
.HasColumnType("int");
b.Property<int?>("Mark")
.IsRequired()
.HasColumnType("int");
b.Property<int>("Status")
@ -182,17 +183,22 @@ namespace SchoolScheduleDataBaseImplement.Migrations
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("TeacherId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TeacherId")
.IsUnique();
b.ToTable("Teachers");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Grade", b =>
{
b.HasOne("SchoolScheduleDataBaseImplement.Models.Teacher", "Teacher")
.WithMany("Grade")
.HasForeignKey("TeacherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Teacher");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Lesson", b =>
{
b.HasOne("SchoolScheduleDataBaseImplement.Models.Grade", "Grade")
@ -258,25 +264,11 @@ namespace SchoolScheduleDataBaseImplement.Migrations
b.Navigation("Grade");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Teacher", b =>
{
b.HasOne("SchoolScheduleDataBaseImplement.Models.Grade", "Grade")
.WithOne("Teacher")
.HasForeignKey("SchoolScheduleDataBaseImplement.Models.Teacher", "TeacherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Grade");
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Grade", b =>
{
b.Navigation("Lessons");
b.Navigation("Students");
b.Navigation("Teacher")
.IsRequired();
});
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Lesson", b =>
@ -301,6 +293,8 @@ namespace SchoolScheduleDataBaseImplement.Migrations
modelBuilder.Entity("SchoolScheduleDataBaseImplement.Models.Teacher", b =>
{
b.Navigation("Grade");
b.Navigation("Lessons");
});
#pragma warning restore 612, 618

View File

@ -39,6 +39,7 @@ new();
Id = model.Id,
Year = model.Year,
TeacherId = model.TeacherId,
Teacher = context.Teachers.First(y => y.Id == model.TeacherId),
Letter = model.Letter
};
}
@ -59,7 +60,8 @@ new();
Year = Year,
Letter = Letter,
TeacherId = TeacherId,
TeacherFullName = Teacher.FullName
TeacherFullName = Teacher.FullName,
FullName = Year.ToString() + Letter.ToString(),
};
}

View File

@ -34,7 +34,7 @@ namespace SchoolScheduleDataBaseImplement.Models
public virtual Subject Subject { get; set; } = new();
public virtual Grade Grade { get; set; } = new();
public static Lesson Create(SchoolScheduleDataBase context, LessonViewModel model)
public static Lesson Create(SchoolScheduleDataBase context, LessonBindingModel model)
{
return new Lesson
{
@ -74,7 +74,10 @@ namespace SchoolScheduleDataBaseImplement.Models
Date = Date,
Homework = Homework,
SchedulePlaceId = SchedulePlaceId,
SchedulePlaceTime = SchedulePlace.Time,
GradeId = GradeId,
TeacherId = TeacherId,
SubjectId = SubjectId,
SchedulePlaceTime = SchedulePlace.Time,
TeacherFullName = Teacher.FullName,
SubjectName = Subject.SubjectName,
GradeName = Grade.Year.ToString() + Grade.Letter.ToString()

View File

@ -17,7 +17,6 @@ namespace SchoolScheduleDataBaseImplement.Models
public int LessonId { get; private set; }
[Required]
public StudentStatus Status { get; set; }
[Required]
public int? Mark { get; set; } = null;
public virtual Student Student { get; set; } = new();
public virtual Lesson Lesson { get; set; } = new();

View File

@ -19,7 +19,7 @@ namespace SchoolScheduleDataBaseImplement.Models
public TimeOnly Time { get; private set; }
[ForeignKey("SchedulePlaceId")]
public virtual List<Lesson> Lessons { get; set; } = new();
public static SchedulePlace Create(SchedulePlaceViewModel model)
public static SchedulePlace Create(SchedulePlaceBindingModel model)
{
return new SchedulePlace
{

View File

@ -67,6 +67,7 @@ namespace SchoolScheduleDataBaseImplement.Models
FullName = FullName,
GradeId = GradeId,
GradeName = Grade.Year.ToString() + Grade.Letter.ToString(),
Attendance = Attendance
};
public void UpdateAttendance(SchoolScheduleDataBase context, StudentBindingModel model)

View File

@ -34,7 +34,7 @@ namespace SchoolScheduleDataBaseImplement.Models
}
public void Update(SchoolScheduleDataBase context, SubjectBindingModel model)
{
SubjectName = SubjectName;
SubjectName = model.SubjectName;
}
public SubjectViewModel GetViewModel => new()
{

View File

@ -20,7 +20,7 @@ namespace SchoolScheduleDataBaseImplement.Models
[ForeignKey("TeacherId")]
public virtual List<Lesson> Lessons { get; set; } = new();
[ForeignKey("TeacherId")]
public virtual Grade Grade { get; set; }
public virtual List<Grade> Grade { get; set; } = new();
public static Teacher Create(SchoolScheduleDataBase context, TeacherBindingModel model)
{