Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
e03b4f94d3 | |||
77fa33ef78 | |||
ad006f8af0 | |||
4695c8d1c8 | |||
242c61b655 | |||
c015aab079 | |||
bfe732607e |
@ -8,4 +8,41 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Npgsql" Version="9.0.2" />
|
||||
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
<PackageReference Include="Unity" Version="5.11.10" />
|
||||
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Entities.Enums
|
||||
{ [Flags]
|
||||
public enum Groupp
|
||||
{
|
||||
None = 0,
|
||||
First = 1,
|
||||
Second = 2,
|
||||
Third = 4,
|
||||
Fourth = 8
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Entities.Enums
|
||||
{ public enum TypeS
|
||||
{
|
||||
None = 0,
|
||||
One = 1,
|
||||
Two = 2,
|
||||
Three = 3,
|
||||
Four = 4,
|
||||
Five = 5
|
||||
}
|
||||
}
|
33
Academic_Performance/Academic_Performance/Entities/Mark.cs
Normal file
33
Academic_Performance/Academic_Performance/Entities/Mark.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using Academic_Performance.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Entities
|
||||
{
|
||||
public class Mark
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int StudentId { get; private set; }
|
||||
/// public int TeachersId { get; private set; }
|
||||
/// <summary>
|
||||
///public int SubjectId { get; private set; }
|
||||
/// </summary>
|
||||
public string Value { get; private set; } = string.Empty;
|
||||
public static Mark CreateElement(int id,
|
||||
int studentId,///int teacherId, int subjectId,
|
||||
string value)
|
||||
{
|
||||
return new Mark
|
||||
{
|
||||
Id = id,
|
||||
StudentId = studentId,
|
||||
/// TeachersId = teacherId,
|
||||
/// SubjectId = subjectId,
|
||||
Value = value
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
29
Academic_Performance/Academic_Performance/Entities/Order.cs
Normal file
29
Academic_Performance/Academic_Performance/Entities/Order.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using Academic_Performance.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Entities
|
||||
{
|
||||
public class Order
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int StudentId { get; private set; }
|
||||
public string Information { get; private set; } = string.Empty;
|
||||
public TypeS? TypeS { get; private set; }
|
||||
public DateTime Date { get; private set; }
|
||||
public static Order CreateEntity(int id, int studentId, string information,TypeS types)
|
||||
{
|
||||
return new Order
|
||||
{
|
||||
Id = id,
|
||||
StudentId = studentId,
|
||||
Information = information,
|
||||
TypeS = types,
|
||||
Date = DateTime.Now
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
using Academic_Performance.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Entities
|
||||
{
|
||||
public class Statement
|
||||
{ public int Id { get; private set; }
|
||||
public int SubjectId { get; private set; }
|
||||
public int TeacherId{ get; private set; }
|
||||
|
||||
public DateTime Date { get; private set; }
|
||||
public IEnumerable<Mark> Mark{ get; private set; } = [];
|
||||
public static Statement CreateOperation(int id, int subjectId, int teacherId, IEnumerable<Mark> mark)
|
||||
{
|
||||
return new Statement
|
||||
{
|
||||
Id = id,
|
||||
SubjectId = subjectId,
|
||||
TeacherId = teacherId,
|
||||
Date = DateTime.Now,
|
||||
Mark = mark
|
||||
};
|
||||
}
|
||||
|
||||
public static Statement CreateOperation(TempMarks tempmarks, IEnumerable<Mark> mark)
|
||||
{
|
||||
return new Statement
|
||||
{
|
||||
Id = tempmarks.Id,
|
||||
SubjectId = tempmarks.SubjectId,
|
||||
TeacherId = tempmarks.TeacherId,
|
||||
Date = tempmarks.Date,
|
||||
Mark = mark
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using Academic_Performance.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Entities
|
||||
{
|
||||
public class Student
|
||||
{
|
||||
public int Id{ get; private set; }
|
||||
public Groupp Groupp { get; private set; }
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
public string Flow { get; private set; } = string.Empty;
|
||||
public static Student CreateEntity(int id, string name,string flow, Groupp groupp)
|
||||
{
|
||||
return new Student
|
||||
{
|
||||
Id = id,
|
||||
Name = name,
|
||||
Flow=flow,
|
||||
Groupp =groupp,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using Microsoft.VisualBasic.Devices;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Entities;
|
||||
public class Subject
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
public static Subject CreateEntity(int id, string name)
|
||||
{
|
||||
return new Subject
|
||||
{
|
||||
Id = id,
|
||||
Name = name
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Entities;
|
||||
|
||||
public class Teacher
|
||||
{ public int Id { get; private set; }
|
||||
public string Name{ get; private set; } = string.Empty;
|
||||
public static Teacher CreateEntity(int id, string name)
|
||||
{
|
||||
return new Teacher
|
||||
{
|
||||
Id = id,
|
||||
Name = name,
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Entities;
|
||||
|
||||
public class TempMarks
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int StudentId { get; private set; }
|
||||
public int TeacherId { get; private set; }
|
||||
public int SubjectId { get; private set; }
|
||||
public DateTime Date { get; private set; }
|
||||
public string Value { get; private set; } = string.Empty;
|
||||
}
|
@ -28,12 +28,134 @@
|
||||
/// </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";
|
||||
menuStrip = new MenuStrip();
|
||||
cToolStripMenuItem = new ToolStripMenuItem();
|
||||
studentToolStripMenuItem = new ToolStripMenuItem();
|
||||
TeacherToolStripMenuItem = new ToolStripMenuItem();
|
||||
SubToolStripMenuItem = new ToolStripMenuItem();
|
||||
операцииToolStripMenuItem = new ToolStripMenuItem();
|
||||
добавлениеToolStripMenuItem = new ToolStripMenuItem();
|
||||
ведомостьToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
таблицаСОценкамиToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(24, 24);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { cToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Padding = new Padding(5, 1, 0, 1);
|
||||
menuStrip.Size = new Size(623, 26);
|
||||
menuStrip.TabIndex = 0;
|
||||
menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// cToolStripMenuItem
|
||||
//
|
||||
cToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { studentToolStripMenuItem, TeacherToolStripMenuItem, SubToolStripMenuItem });
|
||||
cToolStripMenuItem.Name = "cToolStripMenuItem";
|
||||
cToolStripMenuItem.Size = new Size(117, 24);
|
||||
cToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// studentToolStripMenuItem
|
||||
//
|
||||
studentToolStripMenuItem.Name = "studentToolStripMenuItem";
|
||||
studentToolStripMenuItem.Size = new Size(201, 26);
|
||||
studentToolStripMenuItem.Text = "Студенты";
|
||||
studentToolStripMenuItem.Click += studentToolStripMenuItem_Click;
|
||||
//
|
||||
// TeacherToolStripMenuItem
|
||||
//
|
||||
TeacherToolStripMenuItem.Name = "TeacherToolStripMenuItem";
|
||||
TeacherToolStripMenuItem.Size = new Size(201, 26);
|
||||
TeacherToolStripMenuItem.Text = "Преподаватели";
|
||||
TeacherToolStripMenuItem.Click += TeacherToolStripMenuItem_Click;
|
||||
//
|
||||
// SubToolStripMenuItem
|
||||
//
|
||||
SubToolStripMenuItem.Name = "SubToolStripMenuItem";
|
||||
SubToolStripMenuItem.Size = new Size(201, 26);
|
||||
SubToolStripMenuItem.Text = "Предметы";
|
||||
SubToolStripMenuItem.Click += SubToolStripMenuItem_Click;
|
||||
//
|
||||
// операцииToolStripMenuItem
|
||||
//
|
||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { добавлениеToolStripMenuItem, ведомостьToolStripMenuItem });
|
||||
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
||||
операцииToolStripMenuItem.Size = new Size(95, 24);
|
||||
операцииToolStripMenuItem.Text = "Операции";
|
||||
//
|
||||
// добавлениеToolStripMenuItem
|
||||
//
|
||||
добавлениеToolStripMenuItem.Name = "добавлениеToolStripMenuItem";
|
||||
добавлениеToolStripMenuItem.Size = new Size(167, 26);
|
||||
добавлениеToolStripMenuItem.Text = "Ведомость";
|
||||
добавлениеToolStripMenuItem.Click += добавлениеToolStripMenuItem_Click;
|
||||
//
|
||||
// ведомостьToolStripMenuItem
|
||||
//
|
||||
ведомостьToolStripMenuItem.Name = "ведомостьToolStripMenuItem";
|
||||
ведомостьToolStripMenuItem.Size = new Size(167, 26);
|
||||
ведомостьToolStripMenuItem.Text = "Приказ";
|
||||
ведомостьToolStripMenuItem.Click += ведомостьToolStripMenuItem_Click;
|
||||
//
|
||||
// отчетыToolStripMenuItem
|
||||
//
|
||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, таблицаСОценкамиToolStripMenuItem });
|
||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||
//
|
||||
// DirectoryReportToolStripMenuItem
|
||||
//
|
||||
DirectoryReportToolStripMenuItem.Name = "DirectoryReportToolStripMenuItem";
|
||||
DirectoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
|
||||
DirectoryReportToolStripMenuItem.Size = new Size(354, 26);
|
||||
DirectoryReportToolStripMenuItem.Text = "Документ со справочниками ";
|
||||
DirectoryReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
|
||||
//
|
||||
// таблицаСОценкамиToolStripMenuItem
|
||||
//
|
||||
таблицаСОценкамиToolStripMenuItem.Name = "таблицаСОценкамиToolStripMenuItem";
|
||||
таблицаСОценкамиToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
|
||||
таблицаСОценкамиToolStripMenuItem.Size = new Size(354, 26);
|
||||
таблицаСОценкамиToolStripMenuItem.Text = "Таблица с оценками";
|
||||
таблицаСОценкамиToolStripMenuItem.Click += таблицаСОценкамиToolStripMenuItem_Click;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
BackgroundImage = Properties.Resources.unnamed;
|
||||
BackgroundImageLayout = ImageLayout.Stretch;
|
||||
ClientSize = new Size(623, 360);
|
||||
Controls.Add(menuStrip);
|
||||
MainMenuStrip = menuStrip;
|
||||
Margin = new Padding(2, 3, 2, 3);
|
||||
Name = "Form1";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Form1";
|
||||
menuStrip.ResumeLayout(false);
|
||||
menuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem cToolStripMenuItem;
|
||||
private ToolStripMenuItem studentToolStripMenuItem;
|
||||
private ToolStripMenuItem TeacherToolStripMenuItem;
|
||||
private ToolStripMenuItem SubToolStripMenuItem;
|
||||
private ToolStripMenuItem операцииToolStripMenuItem;
|
||||
private ToolStripMenuItem добавлениеToolStripMenuItem;
|
||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||
private ToolStripMenuItem ведомостьToolStripMenuItem;
|
||||
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
|
||||
private ToolStripMenuItem таблицаСОценкамиToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,113 @@
|
||||
using Academic_Performance.Forms;
|
||||
using Unity;
|
||||
|
||||
namespace Academic_Performance
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
private readonly IUnityContainer _container;
|
||||
public Form1(IUnityContainer container)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
private void studentToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormStudents>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void TeacherToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormTeachers>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void SubToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormSubjects>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void îöåíêèToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormMarks>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void äîáàâëåíèåToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormMarks>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void âåäîìîñòüToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormOrders>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void DirectoryReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormDirectoryReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void òàáëèöàÑÎöåíêàìèToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<ReportMarks>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,4 +117,7 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
99
Academic_Performance/Academic_Performance/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
99
Academic_Performance/Academic_Performance/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
@ -0,0 +1,99 @@
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
partial class FormDirectoryReport
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
checkBoxStudent = new CheckBox();
|
||||
checkBoxTeacher = new CheckBox();
|
||||
checkBoxSubject = new CheckBox();
|
||||
buttonCreate = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// checkBoxStudent
|
||||
//
|
||||
checkBoxStudent.AutoSize = true;
|
||||
checkBoxStudent.Location = new Point(28, 40);
|
||||
checkBoxStudent.Name = "checkBoxStudent";
|
||||
checkBoxStudent.Size = new Size(95, 24);
|
||||
checkBoxStudent.TabIndex = 0;
|
||||
checkBoxStudent.Text = "Cтуденты";
|
||||
checkBoxStudent.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxTeacher
|
||||
//
|
||||
checkBoxTeacher.AutoSize = true;
|
||||
checkBoxTeacher.Location = new Point(28, 106);
|
||||
checkBoxTeacher.Name = "checkBoxTeacher";
|
||||
checkBoxTeacher.Size = new Size(140, 24);
|
||||
checkBoxTeacher.TabIndex = 1;
|
||||
checkBoxTeacher.Text = "Преподаватели";
|
||||
checkBoxTeacher.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxSubject
|
||||
//
|
||||
checkBoxSubject.AutoSize = true;
|
||||
checkBoxSubject.Location = new Point(28, 157);
|
||||
checkBoxSubject.Name = "checkBoxSubject";
|
||||
checkBoxSubject.Size = new Size(103, 24);
|
||||
checkBoxSubject.TabIndex = 2;
|
||||
checkBoxSubject.Text = "Предметы";
|
||||
checkBoxSubject.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(429, 106);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(149, 29);
|
||||
buttonCreate.TabIndex = 3;
|
||||
buttonCreate.Text = "Сформировать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += buttonCreate_Click;
|
||||
//
|
||||
// FormDirectoryReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(608, 215);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(checkBoxSubject);
|
||||
Controls.Add(checkBoxTeacher);
|
||||
Controls.Add(checkBoxStudent);
|
||||
Name = "FormDirectoryReport";
|
||||
Text = "FormDirectoryReport";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CheckBox checkBoxStudent;
|
||||
private CheckBox checkBoxTeacher;
|
||||
private CheckBox checkBoxSubject;
|
||||
private Button buttonCreate;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
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 Academic_Performance.Reports;
|
||||
using Unity;
|
||||
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
public partial class FormDirectoryReport : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
public FormDirectoryReport(IUnityContainer container)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (!checkBoxTeacher.Checked && !checkBoxStudent.Checked && !checkBoxSubject.Checked)
|
||||
{
|
||||
throw new Exception("Не выбран ни один справочник для выгрузки");
|
||||
}
|
||||
var sfd = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Docx Files | *.docx"
|
||||
};
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
throw new Exception("Не выбран файла для отчета");
|
||||
}
|
||||
if (_container.Resolve<DocReport>().CreateDoc(sfd.FileName, checkBoxTeacher.Checked,
|
||||
checkBoxStudent.Checked, checkBoxSubject.Checked))
|
||||
{
|
||||
MessageBox.Show("Документ сформирован", "Формирование документа",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
||||
"Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при создании отчета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
239
Academic_Performance/Academic_Performance/Forms/FormMark.Designer.cs
generated
Normal file
239
Academic_Performance/Academic_Performance/Forms/FormMark.Designer.cs
generated
Normal file
@ -0,0 +1,239 @@
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
partial class FormMark
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
comboBoxTeacher = new ComboBox();
|
||||
comboBoxValue = new ComboBox();
|
||||
buttonSave = new Button();
|
||||
buttonEx = new Button();
|
||||
label2 = new Label();
|
||||
label4 = new Label();
|
||||
groupBox = new GroupBox();
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
dataGridView1 = new DataGridView();
|
||||
ColStudent = new DataGridViewComboBoxColumn();
|
||||
ColValue = new DataGridViewTextBoxColumn();
|
||||
label1 = new Label();
|
||||
comboBoxSubject = new ComboBox();
|
||||
groupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// comboBoxTeacher
|
||||
//
|
||||
comboBoxTeacher.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxTeacher.FormattingEnabled = true;
|
||||
comboBoxTeacher.Location = new Point(236, 12);
|
||||
comboBoxTeacher.Margin = new Padding(2, 3, 2, 3);
|
||||
comboBoxTeacher.Name = "comboBoxTeacher";
|
||||
comboBoxTeacher.Size = new Size(286, 28);
|
||||
comboBoxTeacher.TabIndex = 1;
|
||||
//
|
||||
// comboBoxValue
|
||||
//
|
||||
comboBoxValue.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxValue.FormattingEnabled = true;
|
||||
comboBoxValue.Location = new Point(205, 200);
|
||||
comboBoxValue.Margin = new Padding(2, 3, 2, 3);
|
||||
comboBoxValue.Name = "comboBoxValue";
|
||||
comboBoxValue.Size = new Size(286, 28);
|
||||
comboBoxValue.TabIndex = 3;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(69, 301);
|
||||
buttonSave.Margin = new Padding(2, 3, 2, 3);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(89, 27);
|
||||
buttonSave.TabIndex = 4;
|
||||
buttonSave.Text = "button1";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonEx
|
||||
//
|
||||
buttonEx.Location = new Point(373, 301);
|
||||
buttonEx.Margin = new Padding(2, 3, 2, 3);
|
||||
buttonEx.Name = "buttonEx";
|
||||
buttonEx.Size = new Size(89, 27);
|
||||
buttonEx.TabIndex = 5;
|
||||
buttonEx.Text = "button2";
|
||||
buttonEx.UseVisualStyleBackColor = true;
|
||||
buttonEx.Click += buttonEx_Click;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(50, 15);
|
||||
label2.Margin = new Padding(2, 0, 2, 0);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(154, 20);
|
||||
label2.TabIndex = 7;
|
||||
label2.Text = "ФИО Преподавателя";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(39, 207);
|
||||
label4.Margin = new Padding(2, 0, 2, 0);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(61, 20);
|
||||
label4.TabIndex = 9;
|
||||
label4.Text = "Оценка";
|
||||
//
|
||||
// groupBox
|
||||
//
|
||||
groupBox.Controls.Add(button1);
|
||||
groupBox.Controls.Add(button2);
|
||||
groupBox.Controls.Add(dataGridView1);
|
||||
groupBox.Dock = DockStyle.Bottom;
|
||||
groupBox.Location = new Point(0, 181);
|
||||
groupBox.Margin = new Padding(3, 4, 3, 4);
|
||||
groupBox.Name = "groupBox";
|
||||
groupBox.Padding = new Padding(3, 4, 3, 4);
|
||||
groupBox.Size = new Size(640, 423);
|
||||
groupBox.TabIndex = 33;
|
||||
groupBox.TabStop = false;
|
||||
groupBox.Text = "Ведомость";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(406, 315);
|
||||
button1.Margin = new Padding(2, 3, 2, 3);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(174, 55);
|
||||
button1.TabIndex = 2;
|
||||
button1.Text = "Отмена";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(73, 320);
|
||||
button2.Margin = new Padding(2, 3, 2, 3);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(131, 49);
|
||||
button2.TabIndex = 1;
|
||||
button2.Text = "Сохранение";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += button2_Click;
|
||||
//
|
||||
// dataGridView1
|
||||
//
|
||||
dataGridView1.AllowUserToResizeColumns = false;
|
||||
dataGridView1.AllowUserToResizeRows = false;
|
||||
dataGridView1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView1.Columns.AddRange(new DataGridViewColumn[] { ColStudent, ColValue });
|
||||
dataGridView1.Location = new Point(26, 41);
|
||||
dataGridView1.Margin = new Padding(3, 4, 3, 4);
|
||||
dataGridView1.MultiSelect = false;
|
||||
dataGridView1.Name = "dataGridView1";
|
||||
dataGridView1.RowHeadersVisible = false;
|
||||
dataGridView1.RowHeadersWidth = 62;
|
||||
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView1.Size = new Size(600, 207);
|
||||
dataGridView1.TabIndex = 0;
|
||||
dataGridView1.CellContentClick += dataGridView1_CellContentClick;
|
||||
//
|
||||
// ColStudent
|
||||
//
|
||||
ColStudent.HeaderText = "Студент";
|
||||
ColStudent.MinimumWidth = 8;
|
||||
ColStudent.Name = "ColStudent";
|
||||
//
|
||||
// ColValue
|
||||
//
|
||||
ColValue.HeaderText = "Оценка";
|
||||
ColValue.MinimumWidth = 8;
|
||||
ColValue.Name = "ColValue";
|
||||
ColValue.Resizable = DataGridViewTriState.True;
|
||||
ColValue.SortMode = DataGridViewColumnSortMode.NotSortable;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(113, 96);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(70, 20);
|
||||
label1.TabIndex = 35;
|
||||
label1.Text = "Предмет";
|
||||
//
|
||||
// comboBoxSubject
|
||||
//
|
||||
comboBoxSubject.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxSubject.FormattingEnabled = true;
|
||||
comboBoxSubject.Location = new Point(236, 88);
|
||||
comboBoxSubject.Margin = new Padding(2, 3, 2, 3);
|
||||
comboBoxSubject.Name = "comboBoxSubject";
|
||||
comboBoxSubject.Size = new Size(286, 28);
|
||||
comboBoxSubject.TabIndex = 36;
|
||||
//
|
||||
// FormMark
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(640, 604);
|
||||
Controls.Add(comboBoxSubject);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(groupBox);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(buttonEx);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(comboBoxValue);
|
||||
Controls.Add(comboBoxTeacher);
|
||||
Margin = new Padding(2, 3, 2, 3);
|
||||
Name = "FormMark";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "FormMark";
|
||||
groupBox.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private ComboBox comboBoxTeacher;
|
||||
private ComboBox comboBoxValue;
|
||||
private Button buttonSave;
|
||||
private Button buttonEx;
|
||||
private Label label2;
|
||||
private Label label4;
|
||||
private GroupBox groupBox;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
private DataGridView dataGridView1;
|
||||
private Label label1;
|
||||
private ComboBox comboBoxSubject;
|
||||
private DataGridViewComboBoxColumn ColStudent;
|
||||
private DataGridViewTextBoxColumn ColValue;
|
||||
}
|
||||
}
|
105
Academic_Performance/Academic_Performance/Forms/FormMark.cs
Normal file
105
Academic_Performance/Academic_Performance/Forms/FormMark.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using Academic_Performance.Entities;
|
||||
using Academic_Performance.Entities.Enums;
|
||||
using Academic_Performance.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Contracts;
|
||||
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 Academic_Performance.Forms
|
||||
{
|
||||
public partial class FormMark : Form
|
||||
{
|
||||
private readonly IStatementRepository _statementRepository;
|
||||
public FormMark(IStatementRepository statementRepository, ITeacherRepository teacherRepository, ISubjectRepository subjectRepository, IStudentRepository studentRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_statementRepository = statementRepository ??
|
||||
throw new ArgumentNullException(nameof(statementRepository));
|
||||
ColStudent.DataSource = studentRepository.ReadStudent();
|
||||
ColStudent.DisplayMember = "Name";
|
||||
ColStudent.ValueMember = "Id";
|
||||
comboBoxSubject.DataSource = subjectRepository.ReadSubject();
|
||||
comboBoxSubject.DisplayMember = "Name";
|
||||
comboBoxSubject.ValueMember = "Id";
|
||||
comboBoxTeacher.DataSource = teacherRepository.ReadTeachers();
|
||||
comboBoxTeacher.DisplayMember = "Name";
|
||||
comboBoxTeacher.ValueMember = "Id";
|
||||
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dataGridView1.RowCount < 1 || comboBoxTeacher.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
_statementRepository.CreateStatement(Statement.CreateOperation(0, (int)comboBoxSubject.SelectedValue!, (int)comboBoxTeacher.SelectedValue!, CreateListMark()));
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка сохранения", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonEx_Click(object sender, EventArgs e)
|
||||
|
||||
=> Close();
|
||||
private List<Mark> CreateListMark()
|
||||
{
|
||||
var list = new List<Mark>();
|
||||
foreach (DataGridViewRow row in dataGridView1.Rows)
|
||||
{
|
||||
if (
|
||||
row.Cells["ColStudent"].Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
list.Add(Mark.CreateElement(0, Convert.ToInt32(row.Cells["ColStudent"].Value),
|
||||
///(int)comboBoxSubject.SelectedValue!,(int)comboBoxTeacher.SelectedValue!,
|
||||
row.Cells["ColValue"].Value.ToString()
|
||||
));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dataGridView1.RowCount < 1 ||
|
||||
comboBoxTeacher.SelectedIndex < 0 || comboBoxSubject.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
_statementRepository.CreateStatement(Statement.CreateOperation(0, (int)comboBoxSubject.SelectedValue!,
|
||||
(int)comboBoxTeacher.SelectedValue!,
|
||||
CreateListMark()));
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
126
Academic_Performance/Academic_Performance/Forms/FormMark.resx
Normal file
126
Academic_Performance/Academic_Performance/Forms/FormMark.resx
Normal file
@ -0,0 +1,126 @@
|
||||
<?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="ColStudent.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColValue.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
118
Academic_Performance/Academic_Performance/Forms/FormMarks.Designer.cs
generated
Normal file
118
Academic_Performance/Academic_Performance/Forms/FormMarks.Designer.cs
generated
Normal file
@ -0,0 +1,118 @@
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
partial class FormMarks
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
panel1 = new Panel();
|
||||
buttonDel = new Button();
|
||||
buttonSave = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(buttonDel);
|
||||
panel1.Controls.Add(buttonSave);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(473, 0);
|
||||
panel1.Margin = new Padding(2, 3, 2, 3);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(167, 360);
|
||||
panel1.TabIndex = 2;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.BackgroundImage = Properties.Resources.Del;
|
||||
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDel.Location = new Point(41, 259);
|
||||
buttonDel.Margin = new Padding(2, 3, 2, 3);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(89, 79);
|
||||
buttonDel.TabIndex = 2;
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.BackgroundImage = Properties.Resources.Add;
|
||||
buttonSave.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonSave.Location = new Point(41, 23);
|
||||
buttonSave.Margin = new Padding(2, 3, 2, 3);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(89, 75);
|
||||
buttonSave.TabIndex = 0;
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.AllowUserToResizeColumns = false;
|
||||
dataGridView.AllowUserToResizeRows = false;
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Fill;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Margin = new Padding(2, 3, 2, 3);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.RowHeadersWidth = 62;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(473, 360);
|
||||
dataGridView.TabIndex = 3;
|
||||
//
|
||||
// FormMarks
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(640, 360);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(panel1);
|
||||
Margin = new Padding(2, 3, 2, 3);
|
||||
Name = "FormMarks";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "FormMarks";
|
||||
Load += FormMarks_Load;
|
||||
panel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel1;
|
||||
private Button buttonDel;
|
||||
private Button buttonSave;
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
90
Academic_Performance/Academic_Performance/Forms/FormMarks.cs
Normal file
90
Academic_Performance/Academic_Performance/Forms/FormMarks.cs
Normal file
@ -0,0 +1,90 @@
|
||||
using Academic_Performance.Repositories;
|
||||
using Academic_Performance.Repositories.Implementations;
|
||||
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 System.Xml.Linq;
|
||||
using Unity;
|
||||
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
public partial class FormMarks : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
private readonly IStatementRepository _statementRepository;
|
||||
public FormMarks(IUnityContainer container, IStatementRepository statementRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
_statementRepository = statementRepository ??
|
||||
throw new ArgumentNullException(nameof(statementRepository));
|
||||
}
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormMark>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
_statementRepository.DeleteStatement(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
private void FormMarks_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() =>
|
||||
dataGridView.DataSource = _statementRepository.ReadStatement();
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridView.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
120
Academic_Performance/Academic_Performance/Forms/FormMarks.resx
Normal file
120
Academic_Performance/Academic_Performance/Forms/FormMarks.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
153
Academic_Performance/Academic_Performance/Forms/FormOrder.Designer.cs
generated
Normal file
153
Academic_Performance/Academic_Performance/Forms/FormOrder.Designer.cs
generated
Normal file
@ -0,0 +1,153 @@
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
partial class FormOrder
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
buttonSave = new Button();
|
||||
buttonEx = new Button();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
comboBoxType = new ComboBox();
|
||||
textBoxInf = new TextBox();
|
||||
comboBoxIdStudent = new ComboBox();
|
||||
label4 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(130, 259);
|
||||
buttonSave.Margin = new Padding(2);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(127, 27);
|
||||
buttonSave.TabIndex = 1;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonEx
|
||||
//
|
||||
buttonEx.Location = new Point(367, 259);
|
||||
buttonEx.Margin = new Padding(2);
|
||||
buttonEx.Name = "buttonEx";
|
||||
buttonEx.Size = new Size(115, 27);
|
||||
buttonEx.TabIndex = 2;
|
||||
buttonEx.Text = "Отмена";
|
||||
buttonEx.UseVisualStyleBackColor = true;
|
||||
buttonEx.Click += buttonEx_Click;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(83, 19);
|
||||
label2.Margin = new Padding(2, 0, 2, 0);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(35, 20);
|
||||
label2.TabIndex = 4;
|
||||
label2.Text = "Тип";
|
||||
label2.Click += label2_Click;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(35, 94);
|
||||
label3.Margin = new Padding(2, 0, 2, 0);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(102, 20);
|
||||
label3.TabIndex = 5;
|
||||
label3.Text = "Информация";
|
||||
//
|
||||
// comboBoxType
|
||||
//
|
||||
comboBoxType.FormattingEnabled = true;
|
||||
comboBoxType.Location = new Point(157, 11);
|
||||
comboBoxType.Margin = new Padding(2);
|
||||
comboBoxType.Name = "comboBoxType";
|
||||
comboBoxType.Size = new Size(414, 28);
|
||||
comboBoxType.TabIndex = 7;
|
||||
//
|
||||
// textBoxInf
|
||||
//
|
||||
textBoxInf.Location = new Point(157, 87);
|
||||
textBoxInf.Margin = new Padding(2);
|
||||
textBoxInf.Name = "textBoxInf";
|
||||
textBoxInf.Size = new Size(421, 27);
|
||||
textBoxInf.TabIndex = 8;
|
||||
//
|
||||
// comboBoxIdStudent
|
||||
//
|
||||
comboBoxIdStudent.FormattingEnabled = true;
|
||||
comboBoxIdStudent.Location = new Point(157, 164);
|
||||
comboBoxIdStudent.Margin = new Padding(2);
|
||||
comboBoxIdStudent.Name = "comboBoxIdStudent";
|
||||
comboBoxIdStudent.Size = new Size(421, 28);
|
||||
comboBoxIdStudent.TabIndex = 9;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(35, 172);
|
||||
label4.Margin = new Padding(2, 0, 2, 0);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(107, 20);
|
||||
label4.TabIndex = 10;
|
||||
label4.Text = "ФИО Студента";
|
||||
//
|
||||
// FormOrder
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(640, 308);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(comboBoxIdStudent);
|
||||
Controls.Add(textBoxInf);
|
||||
Controls.Add(comboBoxType);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(buttonEx);
|
||||
Controls.Add(buttonSave);
|
||||
Margin = new Padding(2);
|
||||
Name = "FormOrder";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "FormOrder";
|
||||
Load += FormOrder_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonSave;
|
||||
private Button buttonEx;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private ComboBox comboBoxType;
|
||||
private TextBox textBoxInf;
|
||||
private ComboBox comboBoxIdStudent;
|
||||
private Label label4;
|
||||
}
|
||||
}
|
107
Academic_Performance/Academic_Performance/Forms/FormOrder.cs
Normal file
107
Academic_Performance/Academic_Performance/Forms/FormOrder.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using Academic_Performance.Entities;
|
||||
using Academic_Performance.Entities.Enums;
|
||||
using Academic_Performance.Repositories;
|
||||
using Academic_Performance.Repositories.Implementations;
|
||||
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 Academic_Performance.Forms
|
||||
{
|
||||
public partial class FormOrder : Form
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
|
||||
private int? _orderId;
|
||||
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var order = _orderRepository.GetOrderById(value);
|
||||
if (order == null)
|
||||
{
|
||||
throw new InvalidDataException(nameof(order));
|
||||
}
|
||||
textBoxInf.Text = order.Information;
|
||||
_orderId = value;
|
||||
comboBoxType.SelectedItem =
|
||||
order.TypeS;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public FormOrder(IOrderRepository orderRepository, IStudentRepository studentRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_orderRepository = orderRepository ??
|
||||
throw new
|
||||
ArgumentNullException(nameof(orderRepository));
|
||||
comboBoxType.DataSource =
|
||||
Enum.GetValues(typeof(TypeS));
|
||||
comboBoxIdStudent.DataSource = studentRepository.ReadStudent();
|
||||
comboBoxIdStudent.DisplayMember = "Name";
|
||||
comboBoxIdStudent.ValueMember = "Id";
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxInf.Text))
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
||||
if (_orderId.HasValue)
|
||||
{
|
||||
_orderRepository.UpdateOrder(CreateOrder(_orderId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_orderRepository.AddOrder(CreateOrder(0));
|
||||
}
|
||||
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonEx_Click(object sender, EventArgs e) => Close();
|
||||
private Order CreateOrder(int id) => Order.CreateEntity(id, (int)comboBoxIdStudent.SelectedValue!, textBoxInf.Text,
|
||||
(TypeS)comboBoxType.SelectedItem!);
|
||||
|
||||
private void FormOrder_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void label2_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
120
Academic_Performance/Academic_Performance/Forms/FormOrder.resx
Normal file
120
Academic_Performance/Academic_Performance/Forms/FormOrder.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
133
Academic_Performance/Academic_Performance/Forms/FormOrders.Designer.cs
generated
Normal file
133
Academic_Performance/Academic_Performance/Forms/FormOrders.Designer.cs
generated
Normal file
@ -0,0 +1,133 @@
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
partial class FormOrders
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
panel1 = new Panel();
|
||||
buttonDel = new Button();
|
||||
buttonUpd = new Button();
|
||||
buttonSave = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(buttonDel);
|
||||
panel1.Controls.Add(buttonUpd);
|
||||
panel1.Controls.Add(buttonSave);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(473, 0);
|
||||
panel1.Margin = new Padding(2);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(167, 360);
|
||||
panel1.TabIndex = 1;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.BackgroundImage = Properties.Resources.Del;
|
||||
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDel.Location = new Point(42, 259);
|
||||
buttonDel.Margin = new Padding(2);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(90, 78);
|
||||
buttonDel.TabIndex = 2;
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.BackgroundImage = Properties.Resources.Upd;
|
||||
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUpd.Location = new Point(42, 138);
|
||||
buttonUpd.Margin = new Padding(2);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(90, 77);
|
||||
buttonUpd.TabIndex = 1;
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.BackgroundImage = Properties.Resources.Add;
|
||||
buttonSave.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonSave.Location = new Point(42, 22);
|
||||
buttonSave.Margin = new Padding(2);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(90, 74);
|
||||
buttonSave.TabIndex = 0;
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.AllowUserToResizeColumns = false;
|
||||
dataGridView.AllowUserToResizeRows = false;
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Fill;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Margin = new Padding(2);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.RowHeadersWidth = 62;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(473, 360);
|
||||
dataGridView.TabIndex = 2;
|
||||
//
|
||||
// FormOrders
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(640, 360);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(panel1);
|
||||
Margin = new Padding(2);
|
||||
Name = "FormOrders";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "FormOrders";
|
||||
Load += FormOrders_Load;
|
||||
panel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel1;
|
||||
private Button buttonDel;
|
||||
private Button buttonUpd;
|
||||
private Button buttonSave;
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
110
Academic_Performance/Academic_Performance/Forms/FormOrders.cs
Normal file
110
Academic_Performance/Academic_Performance/Forms/FormOrders.cs
Normal file
@ -0,0 +1,110 @@
|
||||
using Academic_Performance.Repositories;
|
||||
using Academic_Performance.Repositories.Implementations;
|
||||
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 Unity;
|
||||
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
public partial class FormOrders : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
public FormOrders(IUnityContainer container, IOrderRepository orderRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
_orderRepository = orderRepository ??
|
||||
throw new ArgumentNullException(nameof(orderRepository));
|
||||
}
|
||||
private void FormOrders_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormOrder>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<FormOrder>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить запись?", "Удаление",
|
||||
MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
_orderRepository.DeleteOrder(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() => dataGridView.DataSource = _orderRepository.ReadOrder();
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridView.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id =
|
||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
120
Academic_Performance/Academic_Performance/Forms/FormOrders.resx
Normal file
120
Academic_Performance/Academic_Performance/Forms/FormOrders.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
148
Academic_Performance/Academic_Performance/Forms/FormStudent.Designer.cs
generated
Normal file
148
Academic_Performance/Academic_Performance/Forms/FormStudent.Designer.cs
generated
Normal file
@ -0,0 +1,148 @@
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
partial class FormStudent
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
label = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
textBoxName = new TextBox();
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
checkedListBoxGroup = new CheckedListBox();
|
||||
textBoxFlow = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label
|
||||
//
|
||||
label.AutoSize = true;
|
||||
label.Location = new Point(31, 25);
|
||||
label.Margin = new Padding(2, 0, 2, 0);
|
||||
label.Name = "label";
|
||||
label.Size = new Size(105, 20);
|
||||
label.TabIndex = 0;
|
||||
label.Text = "ФИО студента";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(37, 101);
|
||||
label2.Margin = new Padding(2, 0, 2, 0);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(58, 20);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Группа";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(44, 183);
|
||||
label3.Margin = new Padding(2, 0, 2, 0);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(51, 20);
|
||||
label3.TabIndex = 2;
|
||||
label3.Text = "Поток";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(137, 21);
|
||||
textBoxName.Margin = new Padding(2, 3, 2, 3);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(309, 27);
|
||||
textBoxName.TabIndex = 3;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(31, 253);
|
||||
button1.Margin = new Padding(2, 3, 2, 3);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(89, 27);
|
||||
button1.TabIndex = 6;
|
||||
button1.Text = "Сохранить";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += button1_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(357, 253);
|
||||
button2.Margin = new Padding(2, 3, 2, 3);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(89, 27);
|
||||
button2.TabIndex = 7;
|
||||
button2.Text = "Отмена";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkedListBoxGroup
|
||||
//
|
||||
checkedListBoxGroup.FormattingEnabled = true;
|
||||
checkedListBoxGroup.Location = new Point(137, 69);
|
||||
checkedListBoxGroup.Name = "checkedListBoxGroup";
|
||||
checkedListBoxGroup.Size = new Size(309, 92);
|
||||
checkedListBoxGroup.TabIndex = 10;
|
||||
//
|
||||
// textBoxFlow
|
||||
//
|
||||
textBoxFlow.Location = new Point(137, 180);
|
||||
textBoxFlow.Margin = new Padding(2, 3, 2, 3);
|
||||
textBoxFlow.Name = "textBoxFlow";
|
||||
textBoxFlow.Size = new Size(309, 27);
|
||||
textBoxFlow.TabIndex = 11;
|
||||
//
|
||||
// FormStudent
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(481, 311);
|
||||
Controls.Add(textBoxFlow);
|
||||
Controls.Add(checkedListBoxGroup);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label);
|
||||
Margin = new Padding(2, 3, 2, 3);
|
||||
Name = "FormStudent";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Студент";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private TextBox textBoxName;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
private CheckedListBox checkedListBoxGroup;
|
||||
private TextBox textBoxFlow;
|
||||
}
|
||||
}
|
107
Academic_Performance/Academic_Performance/Forms/FormStudent.cs
Normal file
107
Academic_Performance/Academic_Performance/Forms/FormStudent.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using Academic_Performance.Repositories;
|
||||
using Academic_Performance.Entities;
|
||||
using Academic_Performance.Repositories.Implementations;
|
||||
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 Academic_Performance.Entities.Enums;
|
||||
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
public partial class FormStudent : Form
|
||||
{
|
||||
private readonly IStudentRepository _studentRepository;
|
||||
private int? _studentId;
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var student = _studentRepository.GetStudentById(value);
|
||||
if (student == null)
|
||||
{
|
||||
throw new InvalidDataException(nameof(student));
|
||||
}
|
||||
|
||||
foreach (Groupp elem in Enum.GetValues(typeof(Groupp)))
|
||||
{
|
||||
if ((elem & student.Groupp) != 0)
|
||||
{
|
||||
checkedListBoxGroup.SetItemChecked(checkedListBoxGroup.Items.IndexOf(elem), true);
|
||||
}
|
||||
}
|
||||
textBoxName.Text = student.Name;
|
||||
textBoxFlow.Text = student.Flow;
|
||||
|
||||
_studentId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public FormStudent(IStudentRepository studentRepository)
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
_studentRepository = studentRepository ??
|
||||
throw new ArgumentNullException(nameof(studentRepository));
|
||||
|
||||
foreach (var elem in Enum.GetValues(typeof(Groupp)))
|
||||
{
|
||||
checkedListBoxGroup.Items.Add(elem);
|
||||
}
|
||||
|
||||
}
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxName.Text) || string.IsNullOrWhiteSpace(textBoxFlow.Text))
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
||||
if (_studentId.HasValue)
|
||||
{
|
||||
_studentRepository.UpdateStudent(CreateStudent(_studentId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_studentRepository.AddStudent(CreateStudent(0));
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
private Student CreateStudent(int id)
|
||||
{
|
||||
|
||||
Groupp groupp = Groupp.None;
|
||||
foreach (var elem in checkedListBoxGroup.CheckedItems)
|
||||
{
|
||||
groupp |= (Groupp)elem;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Student.CreateEntity(id, textBoxName.Text, textBoxFlow.Text, groupp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
120
Academic_Performance/Academic_Performance/Forms/FormStudent.resx
Normal file
120
Academic_Performance/Academic_Performance/Forms/FormStudent.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
133
Academic_Performance/Academic_Performance/Forms/FormStudents.Designer.cs
generated
Normal file
133
Academic_Performance/Academic_Performance/Forms/FormStudents.Designer.cs
generated
Normal file
@ -0,0 +1,133 @@
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
partial class FormStudents
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
panel1 = new Panel();
|
||||
button3 = new Button();
|
||||
button2 = new Button();
|
||||
button1 = new Button();
|
||||
dataGridView1 = new DataGridView();
|
||||
panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(button3);
|
||||
panel1.Controls.Add(button2);
|
||||
panel1.Controls.Add(button1);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(473, 0);
|
||||
panel1.Margin = new Padding(2);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(167, 360);
|
||||
panel1.TabIndex = 0;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.BackgroundImage = Properties.Resources.Del;
|
||||
button3.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
button3.Location = new Point(42, 259);
|
||||
button3.Margin = new Padding(2);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(90, 78);
|
||||
button3.TabIndex = 2;
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += button3_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.BackgroundImage = Properties.Resources.Upd;
|
||||
button2.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
button2.Location = new Point(42, 138);
|
||||
button2.Margin = new Padding(2);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(90, 77);
|
||||
button2.TabIndex = 1;
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += button2_Click;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.BackgroundImage = Properties.Resources.Add;
|
||||
button1.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
button1.Location = new Point(42, 22);
|
||||
button1.Margin = new Padding(2);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(90, 74);
|
||||
button1.TabIndex = 0;
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += button1_Click;
|
||||
//
|
||||
// dataGridView1
|
||||
//
|
||||
dataGridView1.AllowUserToAddRows = false;
|
||||
dataGridView1.AllowUserToDeleteRows = false;
|
||||
dataGridView1.AllowUserToResizeColumns = false;
|
||||
dataGridView1.AllowUserToResizeRows = false;
|
||||
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView1.Dock = DockStyle.Fill;
|
||||
dataGridView1.Location = new Point(0, 0);
|
||||
dataGridView1.Margin = new Padding(2);
|
||||
dataGridView1.MultiSelect = false;
|
||||
dataGridView1.Name = "dataGridView1";
|
||||
dataGridView1.ReadOnly = true;
|
||||
dataGridView1.RowHeadersVisible = false;
|
||||
dataGridView1.RowHeadersWidth = 62;
|
||||
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView1.Size = new Size(473, 360);
|
||||
dataGridView1.TabIndex = 1;
|
||||
//
|
||||
// FormStudents
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(640, 360);
|
||||
Controls.Add(dataGridView1);
|
||||
Controls.Add(panel1);
|
||||
Margin = new Padding(2);
|
||||
Name = "FormStudents";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "FormStudents";
|
||||
Load += StudentsList_Load;
|
||||
panel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel1;
|
||||
private Button button3;
|
||||
private Button button2;
|
||||
private Button button1;
|
||||
private DataGridView dataGridView1;
|
||||
}
|
||||
}
|
106
Academic_Performance/Academic_Performance/Forms/FormStudents.cs
Normal file
106
Academic_Performance/Academic_Performance/Forms/FormStudents.cs
Normal file
@ -0,0 +1,106 @@
|
||||
using Academic_Performance.Repositories;
|
||||
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 Unity;
|
||||
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
public partial class FormStudents : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IStudentRepository _studentRepository;
|
||||
|
||||
public FormStudents(IUnityContainer container, IStudentRepository studentRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
_studentRepository = studentRepository ?? throw new ArgumentNullException(nameof(studentRepository));
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormStudent>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() => dataGridView1.DataSource = _studentRepository.ReadStudent();
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<FormStudent>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridView1.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["ID"].Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
_studentRepository.DeleteStudent(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void StudentsList_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
101
Academic_Performance/Academic_Performance/Forms/FormSubject.Designer.cs
generated
Normal file
101
Academic_Performance/Academic_Performance/Forms/FormSubject.Designer.cs
generated
Normal file
@ -0,0 +1,101 @@
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
partial class FormSubject
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
buttonSave = new Button();
|
||||
buttonEx = new Button();
|
||||
label1 = new Label();
|
||||
textBoxName = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(254, 180);
|
||||
buttonSave.Margin = new Padding(2, 3, 2, 3);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(89, 27);
|
||||
buttonSave.TabIndex = 1;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonEx
|
||||
//
|
||||
buttonEx.Location = new Point(396, 180);
|
||||
buttonEx.Margin = new Padding(2, 3, 2, 3);
|
||||
buttonEx.Name = "buttonEx";
|
||||
buttonEx.Size = new Size(89, 27);
|
||||
buttonEx.TabIndex = 2;
|
||||
buttonEx.Text = "Отмена";
|
||||
buttonEx.UseVisualStyleBackColor = true;
|
||||
buttonEx.Click += buttonEx_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(69, 104);
|
||||
label1.Margin = new Padding(2, 0, 2, 0);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(148, 20);
|
||||
label1.TabIndex = 3;
|
||||
label1.Text = "Название предмета";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(254, 104);
|
||||
textBoxName.Margin = new Padding(2, 3, 2, 3);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(231, 27);
|
||||
textBoxName.TabIndex = 4;
|
||||
//
|
||||
// FormSubject
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(640, 255);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonEx);
|
||||
Controls.Add(buttonSave);
|
||||
Margin = new Padding(2, 3, 2, 3);
|
||||
Name = "FormSubject";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "FormSubject";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonSave;
|
||||
private Button buttonEx;
|
||||
private Label label1;
|
||||
private TextBox textBoxName;
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
using Academic_Performance.Entities;
|
||||
using Academic_Performance.Repositories;
|
||||
using Academic_Performance.Repositories.Implementations;
|
||||
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 Academic_Performance.Forms
|
||||
{
|
||||
public partial class FormSubject : Form
|
||||
{
|
||||
private readonly ISubjectRepository _subjectRepository;
|
||||
private int? _subjectId;
|
||||
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var student = _subjectRepository.GetSubjectById(value);
|
||||
if (student == null)
|
||||
{
|
||||
throw new InvalidDataException(nameof(student));
|
||||
}
|
||||
textBoxName.Text = student.Name;
|
||||
_subjectId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FormSubject(ISubjectRepository subjectRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_subjectRepository = subjectRepository ??
|
||||
throw new ArgumentNullException(nameof(subjectRepository));
|
||||
|
||||
}
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxName.Text))
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
||||
if (_subjectId.HasValue)
|
||||
{
|
||||
_subjectRepository.UpdateSubject(CreateSubject(_subjectId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_subjectRepository.AddSubject(CreateSubject(0));
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
private Subject CreateSubject(int id) => Subject.CreateEntity(
|
||||
id,
|
||||
textBoxName.Text
|
||||
);
|
||||
private void buttonEx_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
}
|
||||
}
|
120
Academic_Performance/Academic_Performance/Forms/FormSubject.resx
Normal file
120
Academic_Performance/Academic_Performance/Forms/FormSubject.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
133
Academic_Performance/Academic_Performance/Forms/FormSubjects.Designer.cs
generated
Normal file
133
Academic_Performance/Academic_Performance/Forms/FormSubjects.Designer.cs
generated
Normal file
@ -0,0 +1,133 @@
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
partial class FormSubjects
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
panel1 = new Panel();
|
||||
button3 = new Button();
|
||||
button2 = new Button();
|
||||
button1 = new Button();
|
||||
dataGridView1 = new DataGridView();
|
||||
panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(button3);
|
||||
panel1.Controls.Add(button2);
|
||||
panel1.Controls.Add(button1);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(473, 0);
|
||||
panel1.Margin = new Padding(2);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(167, 360);
|
||||
panel1.TabIndex = 1;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.BackgroundImage = Properties.Resources.Del;
|
||||
button3.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
button3.Location = new Point(42, 259);
|
||||
button3.Margin = new Padding(2);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(90, 78);
|
||||
button3.TabIndex = 2;
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += button3_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.BackgroundImage = Properties.Resources.Upd;
|
||||
button2.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
button2.Location = new Point(42, 138);
|
||||
button2.Margin = new Padding(2);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(90, 77);
|
||||
button2.TabIndex = 1;
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += button2_Click;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.BackgroundImage = Properties.Resources.Add;
|
||||
button1.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
button1.Location = new Point(42, 22);
|
||||
button1.Margin = new Padding(2);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(90, 74);
|
||||
button1.TabIndex = 0;
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += button1_Click;
|
||||
//
|
||||
// dataGridView1
|
||||
//
|
||||
dataGridView1.AllowUserToAddRows = false;
|
||||
dataGridView1.AllowUserToDeleteRows = false;
|
||||
dataGridView1.AllowUserToResizeColumns = false;
|
||||
dataGridView1.AllowUserToResizeRows = false;
|
||||
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView1.Dock = DockStyle.Fill;
|
||||
dataGridView1.Location = new Point(0, 0);
|
||||
dataGridView1.Margin = new Padding(2);
|
||||
dataGridView1.MultiSelect = false;
|
||||
dataGridView1.Name = "dataGridView1";
|
||||
dataGridView1.ReadOnly = true;
|
||||
dataGridView1.RowHeadersVisible = false;
|
||||
dataGridView1.RowHeadersWidth = 62;
|
||||
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView1.Size = new Size(473, 360);
|
||||
dataGridView1.TabIndex = 2;
|
||||
//
|
||||
// FormSubjects
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(640, 360);
|
||||
Controls.Add(dataGridView1);
|
||||
Controls.Add(panel1);
|
||||
Margin = new Padding(2);
|
||||
Name = "FormSubjects";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "FormSubjects";
|
||||
Load += FormSubject_Load;
|
||||
panel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel1;
|
||||
private Button button3;
|
||||
private Button button2;
|
||||
private Button button1;
|
||||
private DataGridView dataGridView1;
|
||||
}
|
||||
}
|
126
Academic_Performance/Academic_Performance/Forms/FormSubjects.cs
Normal file
126
Academic_Performance/Academic_Performance/Forms/FormSubjects.cs
Normal file
@ -0,0 +1,126 @@
|
||||
using Academic_Performance.Repositories;
|
||||
using Academic_Performance.Repositories.Implementations;
|
||||
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 System.Xml.Linq;
|
||||
using Unity;
|
||||
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
public partial class FormSubjects : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly ISubjectRepository _subjectRepository;
|
||||
public FormSubjects(IUnityContainer container, ISubjectRepository subjectRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
_subjectRepository = subjectRepository ?? throw new ArgumentNullException(nameof(subjectRepository));
|
||||
}
|
||||
private void FormSubject_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormSubject>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<FormSubject>();
|
||||
form.Id= findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить запись?", "Удаление",
|
||||
MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
_subjectRepository.DeleteSubject(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void SubjectList_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridView1.DataSource = _subjectRepository.ReadSubject();
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridView1.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id =
|
||||
Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -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>
|
101
Academic_Performance/Academic_Performance/Forms/FormTeacher.Designer.cs
generated
Normal file
101
Academic_Performance/Academic_Performance/Forms/FormTeacher.Designer.cs
generated
Normal file
@ -0,0 +1,101 @@
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
partial class FormTeacher
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
buttonSave = new Button();
|
||||
buttonEx = new Button();
|
||||
label1 = new Label();
|
||||
textBoxName = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(85, 133);
|
||||
buttonSave.Margin = new Padding(2, 2, 2, 2);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(90, 27);
|
||||
buttonSave.TabIndex = 0;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonEx
|
||||
//
|
||||
buttonEx.Location = new Point(278, 133);
|
||||
buttonEx.Margin = new Padding(2, 2, 2, 2);
|
||||
buttonEx.Name = "buttonEx";
|
||||
buttonEx.Size = new Size(90, 27);
|
||||
buttonEx.TabIndex = 1;
|
||||
buttonEx.Text = "Отмена";
|
||||
buttonEx.UseVisualStyleBackColor = true;
|
||||
buttonEx.Click += buttonEx_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(3, 73);
|
||||
label1.Margin = new Padding(2, 0, 2, 0);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(154, 20);
|
||||
label1.TabIndex = 2;
|
||||
label1.Text = "ФИО Преподавателя";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(174, 70);
|
||||
textBoxName.Margin = new Padding(2, 2, 2, 2);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(194, 27);
|
||||
textBoxName.TabIndex = 3;
|
||||
//
|
||||
// FormTeacher
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(457, 206);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonEx);
|
||||
Controls.Add(buttonSave);
|
||||
Margin = new Padding(2, 2, 2, 2);
|
||||
Name = "FormTeacher";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "FormTeacher";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonSave;
|
||||
private Button buttonEx;
|
||||
private Label label1;
|
||||
private TextBox textBoxName;
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
using Academic_Performance.Repositories;
|
||||
using Academic_Performance.Entities;
|
||||
using Academic_Performance.Repositories.Implementations;
|
||||
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 Academic_Performance.Forms
|
||||
{
|
||||
public partial class FormTeacher : Form
|
||||
{
|
||||
|
||||
private readonly ITeacherRepository _teacherRepository;
|
||||
|
||||
private int? _teacherId;
|
||||
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var teacher = _teacherRepository.GetTeacherById(value);
|
||||
if (teacher == null)
|
||||
{
|
||||
throw new InvalidOperationException(nameof(teacher));
|
||||
}
|
||||
|
||||
textBoxName.Text = teacher.Name;
|
||||
_teacherId = value;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
public FormTeacher(ITeacherRepository teacherRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_teacherRepository = teacherRepository ??
|
||||
throw new ArgumentNullException(nameof(teacherRepository));
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxName.Text))
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
||||
if (_teacherId.HasValue)
|
||||
{
|
||||
_teacherRepository.UpdateTeacher(CreateTeacher(_teacherId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_teacherRepository.CreateTeacher(CreateTeacher(0));
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private Teacher CreateTeacher(int id) =>
|
||||
Teacher.CreateEntity(id, textBoxName.Text);
|
||||
|
||||
private void buttonEx_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
}
|
||||
}
|
120
Academic_Performance/Academic_Performance/Forms/FormTeacher.resx
Normal file
120
Academic_Performance/Academic_Performance/Forms/FormTeacher.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
132
Academic_Performance/Academic_Performance/Forms/FormTeachers.Designer.cs
generated
Normal file
132
Academic_Performance/Academic_Performance/Forms/FormTeachers.Designer.cs
generated
Normal file
@ -0,0 +1,132 @@
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
partial class FormTeachers
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
panel1 = new Panel();
|
||||
button3 = new Button();
|
||||
button2 = new Button();
|
||||
button1 = new Button();
|
||||
dataGridView1 = new DataGridView();
|
||||
panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(button3);
|
||||
panel1.Controls.Add(button2);
|
||||
panel1.Controls.Add(button1);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(473, 0);
|
||||
panel1.Margin = new Padding(2);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(167, 360);
|
||||
panel1.TabIndex = 1;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.BackgroundImage = Properties.Resources.Del;
|
||||
button3.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
button3.Location = new Point(42, 259);
|
||||
button3.Margin = new Padding(2);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(90, 78);
|
||||
button3.TabIndex = 2;
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += button3_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.BackgroundImage = Properties.Resources.Upd;
|
||||
button2.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
button2.Location = new Point(42, 138);
|
||||
button2.Margin = new Padding(2);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(90, 77);
|
||||
button2.TabIndex = 1;
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += button2_Click;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.BackgroundImage = Properties.Resources.Add;
|
||||
button1.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
button1.Location = new Point(42, 22);
|
||||
button1.Margin = new Padding(2);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(90, 74);
|
||||
button1.TabIndex = 0;
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += button1_Click;
|
||||
//
|
||||
// dataGridView1
|
||||
//
|
||||
dataGridView1.AllowUserToAddRows = false;
|
||||
dataGridView1.AllowUserToDeleteRows = false;
|
||||
dataGridView1.AllowUserToResizeColumns = false;
|
||||
dataGridView1.AllowUserToResizeRows = false;
|
||||
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView1.Dock = DockStyle.Fill;
|
||||
dataGridView1.Location = new Point(0, 0);
|
||||
dataGridView1.Margin = new Padding(2);
|
||||
dataGridView1.MultiSelect = false;
|
||||
dataGridView1.Name = "dataGridView1";
|
||||
dataGridView1.ReadOnly = true;
|
||||
dataGridView1.RowHeadersWidth = 62;
|
||||
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView1.Size = new Size(473, 360);
|
||||
dataGridView1.TabIndex = 2;
|
||||
//
|
||||
// FormTeachers
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(640, 360);
|
||||
Controls.Add(dataGridView1);
|
||||
Controls.Add(panel1);
|
||||
Margin = new Padding(2);
|
||||
Name = "FormTeachers";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "FormTeachers";
|
||||
Load += FormTeachers_Load;
|
||||
panel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel1;
|
||||
private Button button3;
|
||||
private Button button2;
|
||||
private Button button1;
|
||||
private DataGridView dataGridView1;
|
||||
}
|
||||
}
|
113
Academic_Performance/Academic_Performance/Forms/FormTeachers.cs
Normal file
113
Academic_Performance/Academic_Performance/Forms/FormTeachers.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using Academic_Performance.Repositories;
|
||||
using Academic_Performance.Repositories.Implementations;
|
||||
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 System.Xml.Linq;
|
||||
using Unity;
|
||||
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
public partial class FormTeachers : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
private readonly ITeacherRepository _teacherRepository;
|
||||
public FormTeachers(IUnityContainer container, ITeacherRepository teacherRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
_teacherRepository = teacherRepository ??
|
||||
throw new ArgumentNullException(nameof(teacherRepository));
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormTeacher>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void FormTeachers_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() => dataGridView1.DataSource = _teacherRepository.ReadTeachers();
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<FormTeacher>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_teacherRepository.DeleteTeacher(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridView1.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -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>
|
164
Academic_Performance/Academic_Performance/Forms/ReportMarks.Designer.cs
generated
Normal file
164
Academic_Performance/Academic_Performance/Forms/ReportMarks.Designer.cs
generated
Normal file
@ -0,0 +1,164 @@
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
partial class ReportMarks
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dateTimePickerStart = new DateTimePicker();
|
||||
dateTimePickerEnd = new DateTimePicker();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
comboBoxStudent = new ComboBox();
|
||||
textBoxFile = new TextBox();
|
||||
buttonFile = new Button();
|
||||
buttonSave = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dateTimePickerStart
|
||||
//
|
||||
dateTimePickerStart.Location = new Point(160, 225);
|
||||
dateTimePickerStart.Name = "dateTimePickerStart";
|
||||
dateTimePickerStart.Size = new Size(250, 27);
|
||||
dateTimePickerStart.TabIndex = 0;
|
||||
//
|
||||
// dateTimePickerEnd
|
||||
//
|
||||
dateTimePickerEnd.Location = new Point(160, 308);
|
||||
dateTimePickerEnd.Name = "dateTimePickerEnd";
|
||||
dateTimePickerEnd.Size = new Size(250, 27);
|
||||
dateTimePickerEnd.TabIndex = 1;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(28, 225);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(94, 20);
|
||||
label1.TabIndex = 2;
|
||||
label1.Text = "Дата начала";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(28, 308);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(87, 20);
|
||||
label2.TabIndex = 3;
|
||||
label2.Text = "Дата конца";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(28, 65);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(112, 20);
|
||||
label3.TabIndex = 4;
|
||||
label3.Text = "Путь до файла:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(28, 148);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(107, 20);
|
||||
label4.TabIndex = 5;
|
||||
label4.Text = "ФИО Студента";
|
||||
//
|
||||
// comboBoxStudent
|
||||
//
|
||||
comboBoxStudent.FormattingEnabled = true;
|
||||
comboBoxStudent.Location = new Point(160, 148);
|
||||
comboBoxStudent.Name = "comboBoxStudent";
|
||||
comboBoxStudent.Size = new Size(250, 28);
|
||||
comboBoxStudent.TabIndex = 6;
|
||||
//
|
||||
// textBoxFile
|
||||
//
|
||||
textBoxFile.Location = new Point(164, 65);
|
||||
textBoxFile.Name = "textBoxFile";
|
||||
textBoxFile.ReadOnly = true;
|
||||
textBoxFile.Size = new Size(246, 27);
|
||||
textBoxFile.TabIndex = 7;
|
||||
//
|
||||
// buttonFile
|
||||
//
|
||||
buttonFile.Location = new Point(427, 65);
|
||||
buttonFile.Name = "buttonFile";
|
||||
buttonFile.Size = new Size(39, 29);
|
||||
buttonFile.TabIndex = 8;
|
||||
buttonFile.Text = "...";
|
||||
buttonFile.UseVisualStyleBackColor = true;
|
||||
buttonFile.Click += buttonFile_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(164, 386);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(164, 29);
|
||||
buttonSave.TabIndex = 9;
|
||||
buttonSave.Text = "Сформировать";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// ReportMarks
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(525, 450);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(buttonFile);
|
||||
Controls.Add(textBoxFile);
|
||||
Controls.Add(comboBoxStudent);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(dateTimePickerEnd);
|
||||
Controls.Add(dateTimePickerStart);
|
||||
Name = "ReportMarks";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "ReportMarks";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DateTimePicker dateTimePickerStart;
|
||||
private DateTimePicker dateTimePickerEnd;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private ComboBox comboBoxStudent;
|
||||
private TextBox textBoxFile;
|
||||
private Button buttonFile;
|
||||
private Button buttonSave;
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
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 Academic_Performance.Reports;
|
||||
using Academic_Performance.Repositories;
|
||||
using Unity;
|
||||
|
||||
namespace Academic_Performance.Forms
|
||||
{
|
||||
public partial class ReportMarks : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
public ReportMarks(IUnityContainer container, IStudentRepository studentRepository)
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
comboBoxStudent.DataSource = studentRepository.ReadStudent();
|
||||
comboBoxStudent.DisplayMember = "Name";
|
||||
comboBoxStudent.ValueMember = "Id";
|
||||
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxFile.Text))
|
||||
{
|
||||
throw new Exception("Отсутствует имя файла для отчета");
|
||||
}
|
||||
if (comboBoxStudent.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Не выбран студент");
|
||||
}
|
||||
|
||||
if (dateTimePickerEnd.Value <=
|
||||
dateTimePickerStart.Value)
|
||||
{
|
||||
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||
}
|
||||
if
|
||||
(_container.Resolve<TableReport>().CreateTable(textBoxFile.Text,
|
||||
(int)comboBoxStudent.SelectedValue!,
|
||||
dateTimePickerStart.Value, dateTimePickerEnd.Value))
|
||||
{
|
||||
MessageBox.Show("Документ сформирован",
|
||||
"Формирование документа",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
||||
"Формирование документа",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при создании очета",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonFile_Click(object sender, EventArgs e)
|
||||
{
|
||||
var sfd = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Excel Files | *.xlsx"
|
||||
};
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
textBoxFile.Text = sfd.FileName;
|
||||
}
|
||||
}
|
||||
}
|
120
Academic_Performance/Academic_Performance/Forms/ReportMarks.resx
Normal file
120
Academic_Performance/Academic_Performance/Forms/ReportMarks.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -1,3 +1,12 @@
|
||||
using Unity.Lifetime;
|
||||
using Unity;
|
||||
using Academic_Performance.Repositories;
|
||||
using Academic_Performance.Repositories.Implementations;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
using Unity.Microsoft.Logging;
|
||||
|
||||
namespace Academic_Performance
|
||||
{
|
||||
internal static class Program
|
||||
@ -11,7 +20,44 @@ namespace Academic_Performance
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(CreateContainer().Resolve<Form1>());
|
||||
}
|
||||
private static IUnityContainer CreateContainer()
|
||||
{
|
||||
var container = new UnityContainer();
|
||||
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
||||
|
||||
|
||||
|
||||
container.RegisterType<ISubjectRepository,SubjectRepository>(new TransientLifetimeManager());
|
||||
container.RegisterType<ITeacherRepository, TeacherRepository>(new
|
||||
TransientLifetimeManager());
|
||||
container.RegisterType<IStudentRepository,
|
||||
StudentRepository>(new TransientLifetimeManager());
|
||||
container.RegisterType<IOrderRepository,
|
||||
OrderRepository>(new TransientLifetimeManager());
|
||||
container.RegisterType<IStatementRepository,
|
||||
StatementRepository>(new TransientLifetimeManager());
|
||||
container.RegisterType<IConnectionString,
|
||||
ConnectionString>(new TransientLifetimeManager());
|
||||
return container;
|
||||
|
||||
}
|
||||
|
||||
private static LoggerFactory CreateLoggerFactory()
|
||||
{
|
||||
var loggerFactory = new LoggerFactory();
|
||||
loggerFactory.AddSerilog(new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build())
|
||||
.CreateLogger());
|
||||
return loggerFactory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
103
Academic_Performance/Academic_Performance/Properties/Resources.Designer.cs
generated
Normal file
103
Academic_Performance/Academic_Performance/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Academic_Performance.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||
/// </summary>
|
||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||
// с помощью такого средства, как ResGen или Visual Studio.
|
||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||
// с параметром /str или перестройте свой проект VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Academic_Performance.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Add {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Add", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Del {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Del", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap unnamed {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("unnamed", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Upd {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Upd", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
<?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>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="Del" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Del.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="unnamed" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\unnamed.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Add" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Upd" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Upd.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Academic_Performance.Repositories;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Academic_Performance.Reports;
|
||||
|
||||
public class DocReport
|
||||
{
|
||||
private readonly IStudentRepository _studentRepository;
|
||||
private readonly ISubjectRepository _subjectRepository;
|
||||
private readonly ITeacherRepository _teacherRepository;
|
||||
|
||||
private readonly ILogger<DocReport> _logger;
|
||||
|
||||
public DocReport(IStudentRepository studentRepository, ISubjectRepository subjectRepository,
|
||||
ITeacherRepository teacherRepository,ILogger<DocReport> logger)
|
||||
{
|
||||
_studentRepository = studentRepository ?? throw new ArgumentNullException(nameof(studentRepository));
|
||||
_subjectRepository = subjectRepository ?? throw new ArgumentNullException(nameof(subjectRepository));
|
||||
_teacherRepository = teacherRepository ?? throw new ArgumentNullException(nameof(teacherRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateDoc(string filePath, bool includeTeachers, bool includeSubjects, bool includeStudents)
|
||||
{
|
||||
try
|
||||
{
|
||||
var builder = new WordBuilder(filePath).AddHeader("Документ со справочниками");
|
||||
if (includeStudents)
|
||||
{
|
||||
builder.AddParagraph("Студенты").AddTable([3500, 3500,3500], GetGetStudentById());
|
||||
}
|
||||
if (includeTeachers)
|
||||
{
|
||||
builder.AddParagraph("Преподаватели").AddTable([3500], GetTeacherById());
|
||||
}
|
||||
if (includeSubjects)
|
||||
{
|
||||
builder.AddParagraph("Предменты").AddTable([1200], GetSubjectById());
|
||||
}
|
||||
builder.Build();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string[]> GetGetStudentById()
|
||||
{
|
||||
return [
|
||||
["ФИО Студента", "Поток", "Группа"],
|
||||
.. _studentRepository
|
||||
.ReadStudent()
|
||||
.Select(x => new string[] { x.Name, x.Flow, x.Groupp.ToString() }),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private List<string[]> GetTeacherById()
|
||||
{
|
||||
return [
|
||||
["ФИO Преподавателя"],
|
||||
.. _teacherRepository
|
||||
.ReadTeachers()
|
||||
.Select(x => new string[] { x.Name}),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private List<string[]> GetSubjectById()
|
||||
{
|
||||
return [
|
||||
["Название"],
|
||||
.._subjectRepository
|
||||
.ReadSubject()
|
||||
.Select(x => new string[] { x.Name }),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,335 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using DocumentFormat.OpenXml;
|
||||
|
||||
namespace Academic_Performance.Reports;
|
||||
|
||||
|
||||
public class ExcelBuilder
|
||||
{
|
||||
private readonly string _filePath;
|
||||
|
||||
private readonly SheetData _sheetData;
|
||||
|
||||
private readonly MergeCells _mergeCells;
|
||||
|
||||
private readonly Columns _columns;
|
||||
|
||||
private uint _rowIndex = 0;
|
||||
|
||||
public ExcelBuilder(string filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filePath))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
}
|
||||
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
|
||||
_filePath = filePath;
|
||||
_sheetData = new SheetData();
|
||||
_mergeCells = new MergeCells();
|
||||
_columns = new Columns();
|
||||
_rowIndex = 1;
|
||||
}
|
||||
|
||||
public ExcelBuilder AddHeader(string header, int startIndex, int cnt)
|
||||
{
|
||||
CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithoutBorder);
|
||||
for (int i = startIndex + 1; i < startIndex + cnt; ++i)
|
||||
{
|
||||
CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder);
|
||||
}
|
||||
|
||||
_mergeCells.Append(new MergeCell()
|
||||
{
|
||||
Reference = new StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + cnt - 1)}{_rowIndex}")
|
||||
}); _rowIndex++;
|
||||
|
||||
return this;
|
||||
}
|
||||
public ExcelBuilder AddParagraph(string text, int columnIndex)
|
||||
{
|
||||
CreateCell(columnIndex, _rowIndex++, text, StyleIndex.SimpleTextWithoutBorder);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExcelBuilder AddTable(int[] columnsWidths, List<string[]> data)
|
||||
{
|
||||
if (columnsWidths == null || columnsWidths.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(columnsWidths));
|
||||
}
|
||||
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
|
||||
if (data.Any(x => x.Length != columnsWidths.Length))
|
||||
{
|
||||
throw new InvalidOperationException("widths.Length != data.Length");
|
||||
}
|
||||
|
||||
uint counter = 1;
|
||||
int coef = 2;
|
||||
_columns.Append(columnsWidths.Select(x => new Column
|
||||
{
|
||||
Min = counter,
|
||||
Max = counter++,
|
||||
Width = x * coef,
|
||||
CustomWidth = true
|
||||
}));
|
||||
|
||||
for (var j = 0; j < data.First().Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data.First()[j], StyleIndex.BoldTextWithBorder);
|
||||
}
|
||||
|
||||
_rowIndex++;
|
||||
for (var i = 1; i < data.Count - 1; ++i)
|
||||
{
|
||||
for (var j = 0; j < data[i].Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data[i][j], StyleIndex.SimpleTextWithBorder);
|
||||
}
|
||||
|
||||
_rowIndex++;
|
||||
}
|
||||
|
||||
for (var j = 0; j < data.Last().Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.BoldTextWithBorder);
|
||||
}
|
||||
|
||||
_rowIndex++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Build()
|
||||
{
|
||||
using var spreadsheetDocument = SpreadsheetDocument.Create(_filePath, SpreadsheetDocumentType.Workbook);
|
||||
var workbookpart = spreadsheetDocument.AddWorkbookPart();
|
||||
GenerateStyle(workbookpart);
|
||||
workbookpart.Workbook = new Workbook();
|
||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||
worksheetPart.Worksheet = new Worksheet();
|
||||
if (_columns.HasChildren)
|
||||
{
|
||||
worksheetPart.Worksheet.Append(_columns);
|
||||
}
|
||||
|
||||
worksheetPart.Worksheet.Append(_sheetData);
|
||||
|
||||
var sheets = spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
|
||||
|
||||
var sheet = new Sheet()
|
||||
{
|
||||
Id = spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||
SheetId = 1,
|
||||
Name = "Лист 1"
|
||||
};
|
||||
|
||||
sheets.Append(sheet);
|
||||
if (_mergeCells.HasChildren)
|
||||
{
|
||||
worksheetPart.Worksheet.InsertAfter(_mergeCells, worksheetPart.Worksheet.Elements<SheetData>().First());
|
||||
}
|
||||
}
|
||||
|
||||
private static void GenerateStyle(WorkbookPart workbookPart)
|
||||
{
|
||||
var workbookStylesPart = workbookPart.AddNewPart<WorkbookStylesPart>();
|
||||
workbookStylesPart.Stylesheet = new Stylesheet();
|
||||
|
||||
var fonts = new Fonts()
|
||||
{
|
||||
Count = 2,
|
||||
KnownFonts = BooleanValue.FromBoolean(true)
|
||||
};
|
||||
|
||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||
{
|
||||
FontSize = new FontSize() { Val = 11 },
|
||||
FontName = new FontName() { Val = "Calibri" },
|
||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||
FontScheme = new FontScheme() { Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor) }
|
||||
});
|
||||
|
||||
// Жирный шрифт.
|
||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||
{
|
||||
FontSize = new FontSize() { Val = 11 },
|
||||
FontName = new FontName() { Val = "Calibri" },
|
||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||
FontScheme = new FontScheme()
|
||||
{
|
||||
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||
},
|
||||
Bold = new Bold() { Val = true }
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(fonts);
|
||||
|
||||
// Default Fill.
|
||||
var fills = new Fills() { Count = 1 };
|
||||
fills.Append(new Fill
|
||||
{
|
||||
PatternFill = new PatternFill() { PatternType = new EnumValue<PatternValues>(PatternValues.None) }
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(fills);
|
||||
|
||||
// Default Border.
|
||||
var borders = new Borders() { Count = 2 };
|
||||
borders.Append(new Border
|
||||
{
|
||||
LeftBorder = new LeftBorder(),
|
||||
RightBorder = new RightBorder(),
|
||||
TopBorder = new TopBorder(),
|
||||
BottomBorder = new BottomBorder(),
|
||||
DiagonalBorder = new DiagonalBorder()
|
||||
});
|
||||
|
||||
// Настройка с границами.
|
||||
borders.Append(new Border
|
||||
{
|
||||
LeftBorder = new LeftBorder() { Style = BorderStyleValues.Thin },
|
||||
RightBorder = new RightBorder() { Style = BorderStyleValues.Thin },
|
||||
TopBorder = new TopBorder() { Style = BorderStyleValues.Thin },
|
||||
BottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin },
|
||||
DiagonalBorder = new DiagonalBorder()
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(borders);
|
||||
|
||||
// Default cell format and a date cell format.
|
||||
var cellFormats = new CellFormats() { Count = 4 };
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 0,
|
||||
BorderId = 0,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Left,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
|
||||
// Форматы.
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 0,
|
||||
BorderId = 1,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Right,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 1,
|
||||
BorderId = 0,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Center,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 1,
|
||||
BorderId = 1,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Center,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(cellFormats);
|
||||
}
|
||||
private enum StyleIndex
|
||||
{
|
||||
SimpleTextWithoutBorder = 0,
|
||||
SimpleTextWithBorder = 1,
|
||||
BoldTextWithoutBorder = 2,
|
||||
BoldTextWithBorder = 3,
|
||||
}
|
||||
|
||||
private void CreateCell(int columnIndex, uint rowIndex, string text, StyleIndex styleIndex)
|
||||
{
|
||||
var columnName = GetExcelColumnName(columnIndex);
|
||||
var cellReference = columnName + rowIndex;
|
||||
var row = _sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex! == rowIndex);
|
||||
|
||||
if (row == null)
|
||||
{
|
||||
row = new Row() { RowIndex = rowIndex };
|
||||
_sheetData.Append(row);
|
||||
}
|
||||
|
||||
var newCell = row.Elements<Cell>()
|
||||
.FirstOrDefault(c => c.CellReference != null && c.CellReference.Value == columnName + rowIndex);
|
||||
if (newCell == null)
|
||||
{
|
||||
Cell? refCell = null;
|
||||
foreach (Cell cell in row.Elements<Cell>())
|
||||
{
|
||||
if (cell.CellReference?.Value != null && cell.CellReference.Value.Length == cellReference.Length)
|
||||
{
|
||||
if (string.Compare(cell.CellReference.Value, cellReference, true) > 0)
|
||||
{
|
||||
refCell = cell;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newCell = new Cell() { CellReference = cellReference };
|
||||
row.InsertBefore(newCell, refCell);
|
||||
}
|
||||
|
||||
newCell.CellValue = new CellValue(text);
|
||||
newCell.DataType = CellValues.String;
|
||||
newCell.StyleIndex = (uint)styleIndex;
|
||||
}
|
||||
|
||||
private static string GetExcelColumnName(int columnNumber)
|
||||
{
|
||||
columnNumber += 1;
|
||||
int dividend = columnNumber;
|
||||
string columnName = string.Empty;
|
||||
int modulo;
|
||||
|
||||
while (dividend > 0)
|
||||
{
|
||||
modulo = (dividend - 1) % 26;
|
||||
columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
|
||||
dividend = (dividend - modulo) / 26;
|
||||
}
|
||||
|
||||
return columnName;
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Academic_Performance.Entities;
|
||||
using Academic_Performance.Repositories;
|
||||
using Academic_Performance.Repositories.Implementations;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Academic_Performance.Reports;
|
||||
|
||||
public class TableReport
|
||||
{
|
||||
private readonly IStatementRepository _statementRepository;
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly ISubjectRepository _subjectRepository;
|
||||
private readonly ITeacherRepository _teacherRepository;
|
||||
private readonly ILogger<TableReport> _logger;
|
||||
internal static readonly string[] item = ["Преподаватель", "Дата", "Предмет", "Оценка"];
|
||||
|
||||
public TableReport(IStatementRepository statementRepository,IOrderRepository orderRepository,
|
||||
ISubjectRepository subjectRepository,ILogger<TableReport> logger, ITeacherRepository teacherRepository)
|
||||
{
|
||||
_teacherRepository = teacherRepository ?? throw new ArgumentNullException(nameof(teacherRepository));
|
||||
_statementRepository = statementRepository ?? throw new ArgumentNullException(nameof(statementRepository));
|
||||
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
_subjectRepository = subjectRepository ?? throw new ArgumentNullException(nameof(subjectRepository));
|
||||
}
|
||||
|
||||
public bool CreateTable(string filePath, int studentId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
new ExcelBuilder(filePath)
|
||||
.AddHeader("Сводка по успеваемости ", 0,4)
|
||||
.AddParagraph("за период", 0)
|
||||
.AddTable([15,15,15,15], GetData(studentId,startDate, endDate))
|
||||
.Build();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string[]> GetData(int studentId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var subjects = _subjectRepository
|
||||
.ReadSubject()
|
||||
.ToDictionary(s => s.Id, s => s.Name);
|
||||
var teacher = _teacherRepository
|
||||
.ReadTeachers()
|
||||
.ToDictionary(p => p.Id, p => $"{p.Name}");
|
||||
// Получаем оценки за диапазон дат для указанного студента
|
||||
var markss= _statementRepository
|
||||
.ReadStatement()
|
||||
.Where(g => g.Date >= startDate && g.Date <= endDate
|
||||
&& g.Mark.Any(sg => sg.StudentId == studentId))
|
||||
.Select(g => new
|
||||
{Date = g.Date, Subject = subjects.TryGetValue(g.SubjectId, out var subject) ? subject : "Неизвестный предмет",
|
||||
|
||||
Value = long.TryParse(g.Mark.First(sg => sg.StudentId == studentId).Value, out var gradeValue) ? gradeValue : 0,
|
||||
Teacher = teacher.TryGetValue(g.TeacherId, out var prof) ? prof : "Неизвестный преподаватель"
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
||||
var averageGrade = markss.Any() ? markss.Average(g => g.Value) : 0;
|
||||
// Формируем заголовки и строки для таблицы
|
||||
return new List<string[]> { item }
|
||||
.Union(markss.Select(g => new string[]
|
||||
{
|
||||
g.Date.ToString("dd.MM.yyyy"),
|
||||
g.Subject,
|
||||
g.Value.ToString(),
|
||||
g.Teacher
|
||||
}))
|
||||
.Union(new[]
|
||||
{
|
||||
new string[]
|
||||
{
|
||||
"Средний балл", averageGrade.ToString("0.00"), ""
|
||||
}
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
namespace Academic_Performance.Reports;
|
||||
|
||||
public class WordBuilder
|
||||
{
|
||||
private readonly string _filePath;
|
||||
private readonly Document _document;
|
||||
private readonly Body _body;
|
||||
|
||||
public WordBuilder(string filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filePath))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
}
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
_filePath = filePath;
|
||||
_document = new Document();
|
||||
_body = _document.AppendChild(new Body());
|
||||
}
|
||||
|
||||
public WordBuilder AddHeader(string header)
|
||||
{
|
||||
var paragraph = _body.AppendChild(new Paragraph());
|
||||
var run = paragraph.AppendChild(new Run());
|
||||
// TODO прописать настройки под жирный текст
|
||||
run.PrependChild(new RunProperties());
|
||||
run.RunProperties.AddChild(new Bold());
|
||||
run.AppendChild(new Text(header));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public WordBuilder AddParagraph(string text)
|
||||
{
|
||||
var paragraph = _body.AppendChild(new Paragraph());
|
||||
var run = paragraph.AppendChild(new Run());
|
||||
run.AppendChild(new Text(text));
|
||||
return this;
|
||||
}
|
||||
|
||||
public WordBuilder AddTable(int[] widths, List<string[]> data)
|
||||
{
|
||||
if (widths == null || widths.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(widths));
|
||||
}
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
if (data.Any(x => x.Length != widths.Length))
|
||||
{
|
||||
throw new InvalidOperationException("widths.Length != data.Length");
|
||||
}
|
||||
var table = new Table();
|
||||
table.AppendChild(new TableProperties(
|
||||
new TableBorders(
|
||||
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 })));
|
||||
|
||||
// Заголовок
|
||||
var tr = new TableRow();
|
||||
for (var j = 0; j < widths.Length; ++j)
|
||||
{
|
||||
tr.Append(new TableCell(new TableCellProperties(new TableCellWidth() { Width = widths[j].ToString() }),
|
||||
new Paragraph(new Run(new RunProperties(new Bold()), new Text(data.First()[j])))));
|
||||
}
|
||||
table.Append(tr);
|
||||
// Данные
|
||||
table.Append(data.Skip(1).Select(x => new TableRow(x.Select(y => new TableCell(new Paragraph(new Run(new Text(y))))))));
|
||||
_body.Append(table);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Build()
|
||||
{
|
||||
using var wordDocument = WordprocessingDocument.Create(_filePath,
|
||||
WordprocessingDocumentType.Document);
|
||||
var mainPart = wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = _document;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Npgsql;
|
||||
|
||||
namespace Academic_Performance.Repositories;
|
||||
|
||||
public interface IConnectionString
|
||||
{
|
||||
public string ConnectionString { get; }
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using Academic_Performance.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Repositories
|
||||
{
|
||||
public interface IOrderRepository
|
||||
{ IEnumerable<Order> ReadOrder(DateTime? dateForm = null, DateTime? dateTo = null);
|
||||
Order GetOrderById(int id);
|
||||
void AddOrder(Order order);
|
||||
void UpdateOrder(Order order);
|
||||
void DeleteOrder(int id);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using Academic_Performance.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Repositories
|
||||
{
|
||||
public interface IStatementRepository
|
||||
{
|
||||
IEnumerable<Statement> ReadStatement(DateTime? dateFrom = null, DateTime? dateTo = null);
|
||||
void CreateStatement(Statement statement);
|
||||
void DeleteStatement(int id);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using Academic_Performance.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Repositories
|
||||
{
|
||||
public interface IStudentRepository
|
||||
{
|
||||
IEnumerable<Student> ReadStudent();
|
||||
Student GetStudentById(int id);
|
||||
void AddStudent(Student student);
|
||||
void UpdateStudent(Student student);
|
||||
void DeleteStudent(int id);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using Academic_Performance.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Repositories
|
||||
{
|
||||
public interface ISubjectRepository
|
||||
{
|
||||
IEnumerable<Subject> ReadSubject();
|
||||
Subject GetSubjectById(int id);
|
||||
void AddSubject(Subject subject);
|
||||
void UpdateSubject(Subject subject);
|
||||
void DeleteSubject(int id);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using Academic_Performance.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Repositories
|
||||
{
|
||||
public interface ITeacherRepository
|
||||
{
|
||||
IEnumerable<Teacher> ReadTeachers();
|
||||
Teacher GetTeacherById(int id);
|
||||
void CreateTeacher(Teacher teacher);
|
||||
void UpdateTeacher(Teacher teacher);
|
||||
void DeleteTeacher(int id);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualBasic.ApplicationServices;
|
||||
|
||||
namespace Academic_Performance.Repositories.Implementations;
|
||||
|
||||
public class ConnectionString : IConnectionString
|
||||
{
|
||||
string IConnectionString.ConnectionString => "Server=127.0.0.1,5432;Database=postgres;Uid=A;Pwd=A;";
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
using Academic_Performance.Entities;
|
||||
using Academic_Performance.Entities.Enums;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Repositories.Implementations
|
||||
{
|
||||
public class OrderRepository : IOrderRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<OrderRepository> _logger;
|
||||
public OrderRepository(IConnectionString connectionString, ILogger<OrderRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void AddOrder(Order order)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(order));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"INSERT INTO Orderrr(TypeS,Date,StudentId,Information)
|
||||
VALUES (@TypeS,@Date,@StudentId,@Information)";
|
||||
connection.Execute(queryInsert, order);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void DeleteOrder(int id)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"DELETE FROM Orderrr WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public IEnumerable<Order> GetAllOrders()
|
||||
{
|
||||
return new List<Order>();
|
||||
}
|
||||
public Order GetOrderById(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM Orderrr WHERE Id=@id";
|
||||
var order = connection.QueryFirst<Order>(querySelect, new
|
||||
{
|
||||
id
|
||||
});
|
||||
_logger.LogDebug("Найденный объект: {json}",
|
||||
JsonConvert.SerializeObject(order));
|
||||
return order;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void UpdateOrder(Order order)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}",
|
||||
JsonConvert.SerializeObject(order));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"UPDATE Orderrr SET
|
||||
Information=@Information,
|
||||
TypeS=@TypeS,
|
||||
Date=@Date,
|
||||
StudentId=@StudentId
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryUpdate, order);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
IEnumerable<Order> IOrderRepository.ReadOrder(DateTime? dateForm = null, DateTime? dateTo = null)
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Orderrr";
|
||||
var order = connection.Query<Order>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(order));
|
||||
return order;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
using Academic_Performance.Entities;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Repositories.Implementations
|
||||
{
|
||||
public class StatementRepository : IStatementRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<StudentRepository> _logger;
|
||||
public StatementRepository(IConnectionString connectionString, ILogger<StudentRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateStatement(Statement statement)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(statement));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
connection.Open();
|
||||
using var transaction = connection.BeginTransaction();
|
||||
var queryInsert = @"INSERT INTO Statement11 (TeacherId,SubjectId,Date)
|
||||
VALUES (@TeacherId, @SubjectId,@Date);
|
||||
SELECT MAX(Id) FROM Statement11";
|
||||
var statementId = connection.QueryFirst<int>(queryInsert, statement, transaction);
|
||||
var querySubInsert = @"INSERT INTO Markkk(Value,StudentId)
|
||||
VALUES (@Value,@StudentId)";
|
||||
foreach (var elem in statement.Mark)
|
||||
{
|
||||
connection.Execute(querySubInsert, new
|
||||
{
|
||||
|
||||
elem.Value,
|
||||
elem.StudentId
|
||||
}, transaction);
|
||||
}
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void DeleteStatement(int id)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"DELETE FROM Statement11
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
public IEnumerable<Statement> ReadStatements()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM Statement11";
|
||||
var statements = connection.Query<Statement>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(statements));
|
||||
return statements;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Statement> ReadStatement(DateTime? dateFrom = null, DateTime? dateTo = null)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT inv.*, ipr.StudentId, ipr.Value FROM Statement11 inv
|
||||
INNER JOIN Markkk ipr ON ipr.Id = inv.Id";
|
||||
var statement = connection.Query<TempMarks>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(statement));
|
||||
return statement.GroupBy(x => x.Id, y => y,
|
||||
(key, value) => Statement.CreateOperation(value.First(),
|
||||
value.Select(z => Mark.CreateElement(0, z.StudentId, z.Value)))).ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
/// _logger.LogInformation("Получение всех объектов");
|
||||
/// try
|
||||
/// {
|
||||
/// using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
//// var statements = connection.Query<Statement>(querySelect);
|
||||
//// _logger.LogDebug("Полученные объекты: {json}",
|
||||
/// JsonConvert.SerializeObject(statements));
|
||||
/// return statements;
|
||||
/// }
|
||||
/// catch (Exception ex)
|
||||
/// {
|
||||
/// _logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
/// throw;
|
||||
/// }
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
using Academic_Performance.Entities;
|
||||
using Academic_Performance.Entities.Enums;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Academic_Performance.Repositories.Implementations
|
||||
{
|
||||
public class StudentRepository : IStudentRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<StudentRepository> _logger;
|
||||
public StudentRepository(IConnectionString connectionString, ILogger<StudentRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void AddStudent(Student student)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(student));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"INSERT INTO Studentt (Name, Groupp, Flow)
|
||||
VALUES (@Name, @Groupp, @Flow)";
|
||||
connection.Execute(queryInsert, student);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void DeleteStudent(int id)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"DELETE FROM Studentt WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Student GetStudentById(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM Studentt WHERE Id=@id";
|
||||
var student = connection.QueryFirst<Student>(querySelect, new
|
||||
{
|
||||
id
|
||||
});
|
||||
_logger.LogDebug("Найденный объект: {json}",
|
||||
JsonConvert.SerializeObject(student));
|
||||
return student;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void UpdateStudent(Student student)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}",
|
||||
JsonConvert.SerializeObject(student));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"UPDATE Studentt SET
|
||||
Name=@Name,
|
||||
Groupp=@Groupp,
|
||||
Flow=@Flow
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryUpdate, student);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
IEnumerable<Student> IStudentRepository.ReadStudent()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Studentt";
|
||||
var students = connection.Query<Student>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(students));
|
||||
return students;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,120 @@
|
||||
using Academic_Performance.Entities;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.VisualBasic.Devices;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Repositories.Implementations
|
||||
{
|
||||
public class SubjectRepository : ISubjectRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<SubjectRepository> _logger;
|
||||
public SubjectRepository(IConnectionString connectionString, ILogger<SubjectRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void AddSubject(Subject subject)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(subject));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"INSERT INTO Subject(Name)
|
||||
VALUES (@Name)";
|
||||
connection.Execute(queryInsert, subject);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void DeleteSubject(int id)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"DELETE FROM Subject WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public Subject GetSubjectById(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM Subject WHERE Id=@id";
|
||||
var subject = connection.QueryFirst<Subject>(querySelect, new
|
||||
{
|
||||
id
|
||||
});
|
||||
_logger.LogDebug("Найденный объект: {json}",
|
||||
JsonConvert.SerializeObject(subject));
|
||||
return subject;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void UpdateSubject(Subject subject)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}",
|
||||
JsonConvert.SerializeObject(subject));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"UPDATE Subject SET
|
||||
Name=@Name
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryUpdate, subject);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public IEnumerable<Subject> ReadSubject()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Subject";
|
||||
var subjects = connection.Query<Subject>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(subjects));
|
||||
return subjects;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
using Academic_Performance.Entities;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Academic_Performance.Repositories.Implementations
|
||||
{
|
||||
public class TeacherRepository : ITeacherRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<TeacherRepository> _logger;
|
||||
public TeacherRepository(IConnectionString connectionString, ILogger<TeacherRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateTeacher(Teacher teacher)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(teacher));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"INSERT INTO Teacher(Name)
|
||||
VALUES (@Name)";
|
||||
connection.Execute(queryInsert, teacher);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void UpdateTeacher(Teacher teacher)
|
||||
{
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}",
|
||||
JsonConvert.SerializeObject(teacher));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"UPDATE Teacher SET
|
||||
Name=@Name
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryUpdate, teacher);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void DeleteTeacher(int id)
|
||||
{
|
||||
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"DELETE FROM Teacher WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Teacher GetTeacherById(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM Teacher WHERE Id=@id";
|
||||
var teacher = connection.QueryFirst<Teacher>(querySelect, new
|
||||
{
|
||||
id
|
||||
});
|
||||
_logger.LogDebug("Найденный объект: {json}",
|
||||
JsonConvert.SerializeObject(teacher));
|
||||
return teacher;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public IEnumerable<Teacher> ReadTeachers()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Teacher";
|
||||
var teachers = connection.Query<Teacher>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(teachers));
|
||||
return teachers;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
BIN
Academic_Performance/Academic_Performance/Resources/Add.png
Normal file
BIN
Academic_Performance/Academic_Performance/Resources/Add.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 69 KiB |
BIN
Academic_Performance/Academic_Performance/Resources/Del.png
Normal file
BIN
Academic_Performance/Academic_Performance/Resources/Del.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.7 KiB |
BIN
Academic_Performance/Academic_Performance/Resources/Upd.png
Normal file
BIN
Academic_Performance/Academic_Performance/Resources/Upd.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
Academic_Performance/Academic_Performance/Resources/unnamed.jpg
Normal file
BIN
Academic_Performance/Academic_Performance/Resources/unnamed.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 111 KiB |
15
Academic_Performance/Academic_Performance/appsettings.json
Normal file
15
Academic_Performance/Academic_Performance/appsettings.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": [ "Serilog.Sinks.File" ],
|
||||
"MinimumLevel": "Debug",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "Logs/Academic_log.txt",
|
||||
"rollingInterval": "Day"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user