Compare commits

...

5 Commits

Author SHA1 Message Date
8ff8fd8444 PdfBuilder 2024-11-26 14:40:16 +04:00
733040c716 ExcelBuilder 2024-11-26 13:13:02 +04:00
7e70458d08 Первый отчет 2024-11-25 19:22:26 +04:00
0fc8f3fd47 Рабочая версия 2024-11-11 23:50:40 +04:00
fab7c37b85 Рабочая версия. 2024-11-06 20:02:15 +04:00
99 changed files with 8309 additions and 75 deletions

View File

@ -0,0 +1,22 @@
using ProjectShedule.Entities.Enums;
namespace ProjectShedule.Entities;
public class Classroom
{
public int Id { get;private set; }
public int Size { get; private set; }
public string Name { get; private set; } = String.Empty;
public ClassType ClassType { get; private set; }
public static Classroom CreateClassroom(int id, int size, string name, ClassType classtype)
{
return new Classroom
{
Id = id,
Size = size,
Name = name,
ClassType = classtype
};
}
}

View File

@ -0,0 +1,15 @@
namespace ProjectShedule.Entities;
public class Curriculum
{
public int Id { get; private set; }
public string Direction { get; private set; } = string.Empty;
public static Curriculum CreateCurriculum(int id, string direction)
{
return new Curriculum
{
Id = id,
Direction = direction,
};
}
}

View File

@ -0,0 +1,35 @@
using ProjectShedule.Entities.Enums;
namespace ProjectShedule.Entities;
public class CurriculumSubject
{
public int Id { get; set; }
public DateTime Date { get; private set; }
public int CurriculumId { get; private set; }
public IEnumerable<SubjectSubject> SubjectSubject { get; private set; } = [];
public Course Course { get; private set; }
public static CurriculumSubject CreateCurriculumSubject(int id, DateTime date, int curriculumId, Course course, IEnumerable<SubjectSubject> subjectSubjects)
{
return new CurriculumSubject()
{
Id = id,
Date = date,
CurriculumId = curriculumId,
Course = course,
SubjectSubject = subjectSubjects
};
}
public static CurriculumSubject CreateCurriculumSubject(TempCurriculumSubject tempCurriculumSubject, IEnumerable<SubjectSubject> subjectSubject)
{
return new CurriculumSubject
{
Id = tempCurriculumSubject.Id,
Date = tempCurriculumSubject.Date,
CurriculumId = tempCurriculumSubject.CurriculumId,
Course = tempCurriculumSubject.Course,
SubjectSubject = subjectSubject
};
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectShedule.Entities.Enums;
public enum ClassType
{
LectureHall = 1,
ComputerClass = 2
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectShedule.Entities.Enums;
public enum Course
{
None = 0,
First = 1,
Second = 2,
Third = 3,
Fourth = 4,
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectShedule.Entities.Enums;
[Flags]
public enum PairNumber
{
None = 0,
First = 1,
Second = 2,
Third = 4,
Fourth = 8,
Fifth = 16,
Sixth = 32,
Seveth = 64
}

View File

@ -0,0 +1,33 @@
using ProjectShedule.Entities.Enums;
namespace ProjectShedule.Entities;
public class Shedule
{
public int Id { get; private set; }
public DateTime Date { get; private set; }
public PairNumber PairNumber { get; private set; }
public int PairCount { get; private set; }
public int StudentsGroupId { get; private set; }
public int TeacherId { get; private set; }
public int SubjectId { get; private set; }
public int ClassroomId { get; private set; }
public static Shedule CreateOperation(int id, DateTime date, PairNumber pairNumber, int pairCount
, int studentsGroupId, int teacherId, int subjectId, int classroomId)
{
return new Shedule
{
Id = id,
Date = date,
PairNumber = pairNumber,
PairCount = pairCount,
StudentsGroupId = studentsGroupId,
TeacherId = teacherId,
SubjectId = subjectId,
ClassroomId = classroomId
};
}
}

View File

@ -0,0 +1,25 @@
using ProjectShedule.Entities.Enums;
namespace ProjectShedule.Entities;
public class StudentsGroup
{
public int Id { get; private set; }
public int StudentsCount { get; private set; }
public string GroupNumber { get; private set; } = String.Empty;
public Course Course { get; private set; }
public int CurriculumId { get; private set; }
public static StudentsGroup CreateGroup(int id, int studentsCount, string groupNumber, Course course, int curriculumId)
{
return new StudentsGroup
{
Id = id,
StudentsCount = studentsCount,
GroupNumber = groupNumber,
Course = course,
CurriculumId = curriculumId
};
}
}

View File

@ -0,0 +1,15 @@
namespace ProjectShedule.Entities;
public class Subject
{
public int Id { get; private set; }
public string Name { get; private set; } = String.Empty;
public static Subject CreateSubject(int id, string name)
{
return new Subject
{
Id = id,
Name = name
};
}
}

View File

@ -0,0 +1,19 @@

namespace ProjectShedule.Entities;
public class SubjectSubject
{
public int Id { get; private set; }
public int SubjectId { get; private set; }
public int LessonsCount { get; private set; }
public static SubjectSubject CreateOperation(int id, int subjectId, int lessonsCount)
{
return new SubjectSubject
{
Id = id,
SubjectId = subjectId,
LessonsCount = lessonsCount
};
}
}

View File

@ -0,0 +1,17 @@
namespace ProjectShedule.Entities;
public class Teacher
{
public int Id { get; private set; }
public string FirstName { get; private set; } = string.Empty;
public string LastName { get; private set; } = string.Empty;
public static Teacher CreateTeacher(int id, string firstName, string lastName)
{
return new Teacher
{
Id = id,
FirstName = firstName,
LastName = lastName
};
}
}

View File

@ -0,0 +1,13 @@
using ProjectShedule.Entities.Enums;
namespace ProjectShedule.Entities;
public class TempCurriculumSubject
{
public int Id { get; private set; }
public DateTime Date { get; private set; }
public int CurriculumId { get; private set; }
public int SubjectId { get; private set; }
public int LessonsCount { get; private set; }
public Course Course { get; private set; }
}

View File

@ -1,39 +0,0 @@
namespace ProjectShedule
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

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

View File

@ -0,0 +1,187 @@
namespace ProjectShedule
{
partial class FormSchedulingBureau
{
/// <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()
{
menuStrip = new MenuStrip();
справочникиToolStripMenuItem = new ToolStripMenuItem();
classroomToolStripMenuItem = new ToolStripMenuItem();
teacherToolStripMenuItem = new ToolStripMenuItem();
subjectsToolStripMenuItem = new ToolStripMenuItem();
curriculumsToolStripMenuItem = new ToolStripMenuItem();
studentGroupsToolStripMenuItem = new ToolStripMenuItem();
операцииToolStripMenuItem = new ToolStripMenuItem();
createSheduleToolStripMenuItem = new ToolStripMenuItem();
createCurriculumToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
directoryReportToolStripMenuItem = new ToolStripMenuItem();
sheduleReportToolStripMenuItem = new ToolStripMenuItem();
lessonsCountToolStripMenuItem = new ToolStripMenuItem();
menuStrip.SuspendLayout();
SuspendLayout();
//
// menuStrip
//
menuStrip.ImageScalingSize = new Size(20, 20);
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(800, 28);
menuStrip.TabIndex = 0;
menuStrip.Text = "menuStrip1";
//
// справочникиToolStripMenuItem
//
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { classroomToolStripMenuItem, teacherToolStripMenuItem, subjectsToolStripMenuItem, curriculumsToolStripMenuItem, studentGroupsToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(117, 24);
справочникиToolStripMenuItem.Text = "Справочники";
//
// classroomToolStripMenuItem
//
classroomToolStripMenuItem.Name = "classroomToolStripMenuItem";
classroomToolStripMenuItem.Size = new Size(216, 26);
classroomToolStripMenuItem.Text = "Аудитории";
classroomToolStripMenuItem.Click += classroomToolStripMenuItem_Click;
//
// teacherToolStripMenuItem
//
teacherToolStripMenuItem.Name = "teacherToolStripMenuItem";
teacherToolStripMenuItem.Size = new Size(216, 26);
teacherToolStripMenuItem.Text = "Преподаватели";
teacherToolStripMenuItem.Click += teacherToolStripMenuItem_Click;
//
// subjectsToolStripMenuItem
//
subjectsToolStripMenuItem.Name = "subjectsToolStripMenuItem";
subjectsToolStripMenuItem.Size = new Size(216, 26);
subjectsToolStripMenuItem.Text = "Дисциплины";
subjectsToolStripMenuItem.Click += subjectsToolStripMenuItem_Click;
//
// curriculumsToolStripMenuItem
//
curriculumsToolStripMenuItem.Name = "curriculumsToolStripMenuItem";
curriculumsToolStripMenuItem.Size = new Size(216, 26);
curriculumsToolStripMenuItem.Text = "Направлении";
curriculumsToolStripMenuItem.Click += curriculumsToolStripMenuItem_Click;
//
// studentGroupsToolStripMenuItem
//
studentGroupsToolStripMenuItem.Name = "studentGroupsToolStripMenuItem";
studentGroupsToolStripMenuItem.Size = new Size(216, 26);
studentGroupsToolStripMenuItem.Text = "Группы студентов";
studentGroupsToolStripMenuItem.Click += studentGroupsToolStripMenuItem_Click;
//
// операцииToolStripMenuItem
//
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { createSheduleToolStripMenuItem, createCurriculumToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(95, 24);
операцииToolStripMenuItem.Text = "Операции";
//
// createSheduleToolStripMenuItem
//
createSheduleToolStripMenuItem.Name = "createSheduleToolStripMenuItem";
createSheduleToolStripMenuItem.Size = new Size(296, 26);
createSheduleToolStripMenuItem.Text = "Составление расписания";
createSheduleToolStripMenuItem.Click += createSheduleToolStripMenuItem_Click;
//
// createCurriculumToolStripMenuItem
//
createCurriculumToolStripMenuItem.Name = "createCurriculumToolStripMenuItem";
createCurriculumToolStripMenuItem.Size = new Size(296, 26);
createCurriculumToolStripMenuItem.Text = "Составление учебного плана";
createCurriculumToolStripMenuItem.Click += createCurriculumToolStripMenuItem_Click;
//
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { directoryReportToolStripMenuItem, sheduleReportToolStripMenuItem, lessonsCountToolStripMenuItem });
отчеты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(432, 26);
directoryReportToolStripMenuItem.Text = "Документ со справочниками ";
directoryReportToolStripMenuItem.Click += directoryReportToolStripMenuItem_Click;
//
// sheduleReportToolStripMenuItem
//
sheduleReportToolStripMenuItem.Name = "sheduleReportToolStripMenuItem";
sheduleReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
sheduleReportToolStripMenuItem.Size = new Size(432, 26);
sheduleReportToolStripMenuItem.Text = "Cводка по прохождению учебного плана";
sheduleReportToolStripMenuItem.Click += sheduleReportToolStripMenuItem_Click;
//
// lessonsCountToolStripMenuItem
//
lessonsCountToolStripMenuItem.Name = "lessonsCountToolStripMenuItem";
lessonsCountToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;
lessonsCountToolStripMenuItem.Size = new Size(432, 26);
lessonsCountToolStripMenuItem.Text = "Количество занятий для дисциплин";
lessonsCountToolStripMenuItem.Click += lessonsCountToolStripMenuItem_Click;
//
// FormSchedulingBureau
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.back;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(800, 450);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormSchedulingBureau";
StartPosition = FormStartPosition.CenterParent;
Text = "Бюро составления расписаний";
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip;
private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem classroomToolStripMenuItem;
private ToolStripMenuItem teacherToolStripMenuItem;
private ToolStripMenuItem subjectsToolStripMenuItem;
private ToolStripMenuItem curriculumsToolStripMenuItem;
private ToolStripMenuItem studentGroupsToolStripMenuItem;
private ToolStripMenuItem операцииToolStripMenuItem;
private ToolStripMenuItem createSheduleToolStripMenuItem;
private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem createCurriculumToolStripMenuItem;
private ToolStripMenuItem directoryReportToolStripMenuItem;
private ToolStripMenuItem sheduleReportToolStripMenuItem;
private ToolStripMenuItem lessonsCountToolStripMenuItem;
}
}

View File

@ -0,0 +1,146 @@
using ProjectShedule.Forms;
using Unity;
namespace ProjectShedule
{
public partial class FormSchedulingBureau : Form
{
private readonly IUnityContainer _container;
public FormSchedulingBureau(IUnityContainer container)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void classroomToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormClassrooms>().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 subjectsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormSubjects>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void curriculumsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormCurriculums>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void studentGroupsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormGroups>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void createSheduleToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormShedules>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void createCurriculumToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormCurriculumSubjects>().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 sheduleReportToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormSheduleReport>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void lessonsCountToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormCurriculumSubjectDistributionReport>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,145 @@
namespace ProjectShedule.Forms
{
partial class FormClassroom
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
label1 = new Label();
numericUpDownClassroomSize = new NumericUpDown();
label2 = new Label();
textBoxClassroomNumber = new TextBox();
label3 = new Label();
comboBoxTypeClassroom = new ComboBox();
buttonSave = new Button();
buttonCancel = new Button();
((System.ComponentModel.ISupportInitialize)numericUpDownClassroomSize).BeginInit();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(47, 63);
label1.Name = "label1";
label1.Size = new Size(103, 20);
label1.TabIndex = 0;
label1.Text = "Вместимость:";
//
// numericUpDownClassroomSize
//
numericUpDownClassroomSize.Location = new Point(219, 56);
numericUpDownClassroomSize.Name = "numericUpDownClassroomSize";
numericUpDownClassroomSize.Size = new Size(150, 27);
numericUpDownClassroomSize.TabIndex = 1;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(47, 109);
label2.Name = "label2";
label2.Size = new Size(138, 20);
label2.TabIndex = 2;
label2.Text = "Номер аудитории:";
//
// textBoxClassroomNumber
//
textBoxClassroomNumber.Location = new Point(219, 102);
textBoxClassroomNumber.Name = "textBoxClassroomNumber";
textBoxClassroomNumber.Size = new Size(150, 27);
textBoxClassroomNumber.TabIndex = 3;
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(47, 154);
label3.Name = "label3";
label3.Size = new Size(116, 20);
label3.TabIndex = 4;
label3.Text = "Тип аудитории:";
//
// comboBoxTypeClassroom
//
comboBoxTypeClassroom.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxTypeClassroom.FormattingEnabled = true;
comboBoxTypeClassroom.Location = new Point(218, 146);
comboBoxTypeClassroom.Name = "comboBoxTypeClassroom";
comboBoxTypeClassroom.Size = new Size(151, 28);
comboBoxTypeClassroom.TabIndex = 5;
//
// buttonSave
//
buttonSave.Location = new Point(119, 206);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 6;
buttonSave.Text = "Создать";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(219, 206);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// FormClassroom
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = SystemColors.Menu;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(428, 276);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(comboBoxTypeClassroom);
Controls.Add(label3);
Controls.Add(textBoxClassroomNumber);
Controls.Add(label2);
Controls.Add(numericUpDownClassroomSize);
Controls.Add(label1);
Name = "FormClassroom";
Text = "Аудитория";
((System.ComponentModel.ISupportInitialize)numericUpDownClassroomSize).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private NumericUpDown numericUpDownClassroomSize;
private Label label2;
private TextBox textBoxClassroomNumber;
private Label label3;
private ComboBox comboBoxTypeClassroom;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,74 @@
using ProjectShedule.Entities;
using ProjectShedule.Entities.Enums;
using ProjectShedule.Repositories;
namespace ProjectShedule.Forms
{
public partial class FormClassroom : Form
{
private readonly IClassroomRepository _classroomRepository;
private int? _classroomId;
public int Id
{
set
{
try
{
var classroom = _classroomRepository.ReadClassroomById(value);
if (classroom == null)
{
throw new InvalidDataException(nameof(classroom));
}
numericUpDownClassroomSize.Value = classroom.Size;
textBoxClassroomNumber.Text = classroom.Name;
comboBoxTypeClassroom.SelectedItem = classroom.ClassType;
_classroomId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormClassroom(IClassroomRepository classroomRepository)
{
InitializeComponent();
_classroomRepository = classroomRepository ??
throw new ArgumentNullException(nameof(classroomRepository));
comboBoxTypeClassroom.DataSource = Enum.GetValues(typeof(ClassType));
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxClassroomNumber.Text) || comboBoxTypeClassroom.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
if (_classroomId.HasValue)
{
_classroomRepository.UpdateClassroom(CreateClassroom(_classroomId.Value));
}
else
{
_classroomRepository.CreateClassroom(CreateClassroom(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
private Classroom CreateClassroom(int id) => Classroom.CreateClassroom(
id,
Convert.ToInt32(numericUpDownClassroomSize.Value),
textBoxClassroomNumber.Text,
(ClassType)comboBoxTypeClassroom.SelectedItem!);
}
}

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -0,0 +1,128 @@
namespace ProjectShedule.Forms
{
partial class FormClassrooms
{
/// <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();
buttonAdd = 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(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(663, 0);
panel1.Name = "panel1";
panel1.Size = new Size(178, 353);
panel1.TabIndex = 0;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.minus_PNG39;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(42, 248);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(94, 93);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources._3712684;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(42, 129);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(94, 93);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Ambox_plus_svg;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(42, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 93);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_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.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(663, 353);
dataGridView.TabIndex = 1;
//
// FormClassrooms
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(841, 353);
Controls.Add(dataGridView);
Controls.Add(panel1);
Name = "FormClassrooms";
StartPosition = FormStartPosition.CenterParent;
Text = "Аудитории";
Load += FormClassrooms_Load;
Click += FormClassrooms_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,99 @@
using ProjectShedule.Repositories;
using Unity;
namespace ProjectShedule.Forms
{
public partial class FormClassrooms : Form
{
private readonly IUnityContainer _container;
private readonly IClassroomRepository _classroomRepository;
public FormClassrooms(IUnityContainer container, IClassroomRepository classroomRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_classroomRepository = classroomRepository ??
throw new ArgumentNullException(nameof(classroomRepository));
}
private void FormClassrooms_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormClassroom>().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<FormClassroom>();
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
{
_classroomRepository.DeleteClassroom(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _classroomRepository.ReadClassroom();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return true;
}
else
{
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[id].Value);
return false;
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,95 @@
namespace ProjectShedule.Forms
{
partial class FormCurriculum
{
/// <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()
{
buttonCancel = new Button();
buttonSave = new Button();
label2 = new Label();
textBoxCurriculumName = new TextBox();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(239, 104);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 15;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(117, 104);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 14;
buttonSave.Text = "Создать";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(34, 54);
label2.Name = "label2";
label2.Size = new Size(177, 20);
label2.TabIndex = 10;
label2.Text = "Название направления:";
//
// textBoxCurriculumName
//
textBoxCurriculumName.Location = new Point(239, 51);
textBoxCurriculumName.Name = "textBoxCurriculumName";
textBoxCurriculumName.Size = new Size(150, 27);
textBoxCurriculumName.TabIndex = 11;
//
// FormCurriculum
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(441, 167);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxCurriculumName);
Controls.Add(label2);
Name = "FormCurriculum";
Text = "Учебный план(направление)";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private Label label2;
private TextBox textBoxCurriculumName;
}
}

View File

@ -0,0 +1,67 @@
using ProjectShedule.Entities;
using ProjectShedule.Repositories;
namespace ProjectShedule.Forms
{
public partial class FormCurriculum : Form
{
private readonly ICurriculumRepository _curriculumRepository;
private int? _curriculumId;
public int Id
{
set
{
try
{
var curriculum = _curriculumRepository.ReadCurriculumById(value);
if (curriculum == null)
{
throw new InvalidDataException(nameof(curriculum));
}
textBoxCurriculumName.Text = curriculum.Direction;
_curriculumId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormCurriculum(ICurriculumRepository curriculumRepository)
{
InitializeComponent();
_curriculumRepository = curriculumRepository ??
throw new ArgumentNullException(nameof(curriculumRepository));
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxCurriculumName.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_curriculumId.HasValue)
{
_curriculumRepository.UpdateCurriculum(CreateCurriculum(_curriculumId.Value));
}
else
{
_curriculumRepository.CreateCurriculum(CreateCurriculum(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
private Curriculum CreateCurriculum(int id) => Curriculum.CreateCurriculum(
id,
textBoxCurriculumName.Text);
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,233 @@
namespace ProjectShedule.Forms
{
partial class FormCurriculumSubject
{
/// <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()
{
buttonCancel = new Button();
buttonSave = new Button();
label4 = new Label();
label1 = new Label();
comboBoxDirection = new ComboBox();
comboBoxCourse = new ComboBox();
groupBoxCurriculum = new GroupBox();
dataGridView = new DataGridView();
ColumnSubject = new DataGridViewComboBoxColumn();
ColumnLessons = new DataGridViewTextBoxColumn();
dataGridViewCur = new DataGridView();
Column1 = new DataGridViewComboBoxColumn();
Column2 = new DataGridViewTextBoxColumn();
dateTimePicker1 = new DateTimePicker();
label2 = new Label();
groupBoxCurriculum.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
((System.ComponentModel.ISupportInitialize)dataGridViewCur).BeginInit();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(200, 465);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 19;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(91, 465);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 18;
buttonSave.Text = "Создать";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(115, 113);
label4.Name = "label4";
label4.Size = new Size(44, 20);
label4.TabIndex = 16;
label4.Text = "Курс:";
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(52, 73);
label1.Name = "label1";
label1.Size = new Size(107, 20);
label1.TabIndex = 11;
label1.Text = "Направление:";
//
// comboBoxDirection
//
comboBoxDirection.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxDirection.FormattingEnabled = true;
comboBoxDirection.Location = new Point(165, 65);
comboBoxDirection.Name = "comboBoxDirection";
comboBoxDirection.Size = new Size(150, 28);
comboBoxDirection.TabIndex = 10;
//
// comboBoxCourse
//
comboBoxCourse.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxCourse.FormattingEnabled = true;
comboBoxCourse.Location = new Point(165, 110);
comboBoxCourse.Name = "comboBoxCourse";
comboBoxCourse.Size = new Size(150, 28);
comboBoxCourse.TabIndex = 20;
//
// groupBoxCurriculum
//
groupBoxCurriculum.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
groupBoxCurriculum.Controls.Add(dataGridView);
groupBoxCurriculum.Controls.Add(dataGridViewCur);
groupBoxCurriculum.Location = new Point(12, 144);
groupBoxCurriculum.Name = "groupBoxCurriculum";
groupBoxCurriculum.Size = new Size(360, 315);
groupBoxCurriculum.TabIndex = 21;
groupBoxCurriculum.TabStop = false;
groupBoxCurriculum.Text = "Учбеный план";
//
// dataGridView
//
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnSubject, ColumnLessons });
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(3, 23);
dataGridView.Margin = new Padding(3, 4, 3, 4);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(354, 289);
dataGridView.TabIndex = 1;
//
// ColumnSubject
//
ColumnSubject.HeaderText = "Дисциплина";
ColumnSubject.MinimumWidth = 6;
ColumnSubject.Name = "ColumnSubject";
//
// ColumnLessons
//
ColumnLessons.HeaderText = "Кол-во занятий";
ColumnLessons.MinimumWidth = 6;
ColumnLessons.Name = "ColumnLessons";
//
// dataGridViewCur
//
dataGridViewCur.AllowUserToResizeColumns = false;
dataGridViewCur.AllowUserToResizeRows = false;
dataGridViewCur.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewCur.Columns.AddRange(new DataGridViewColumn[] { Column1, Column2 });
dataGridViewCur.Dock = DockStyle.Fill;
dataGridViewCur.Location = new Point(3, 23);
dataGridViewCur.Name = "dataGridViewCur";
dataGridViewCur.RowHeadersWidth = 51;
dataGridViewCur.Size = new Size(354, 289);
dataGridViewCur.TabIndex = 0;
//
// Column1
//
Column1.HeaderText = "Column1";
Column1.MinimumWidth = 6;
Column1.Name = "Column1";
Column1.Width = 125;
//
// Column2
//
Column2.HeaderText = "Column2";
Column2.MinimumWidth = 6;
Column2.Name = "Column2";
Column2.Width = 125;
//
// dateTimePicker1
//
dateTimePicker1.Location = new Point(165, 23);
dateTimePicker1.Name = "dateTimePicker1";
dateTimePicker1.Size = new Size(150, 27);
dateTimePicker1.TabIndex = 22;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(24, 30);
label2.Name = "label2";
label2.Size = new Size(135, 20);
label2.TabIndex = 23;
label2.Text = "Дата составления:";
//
// FormCurriculumSubject
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(384, 522);
Controls.Add(label2);
Controls.Add(dateTimePicker1);
Controls.Add(groupBoxCurriculum);
Controls.Add(comboBoxCourse);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(label4);
Controls.Add(label1);
Controls.Add(comboBoxDirection);
Name = "FormCurriculumSubject";
Text = "Составление учебного плана";
groupBoxCurriculum.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
((System.ComponentModel.ISupportInitialize)dataGridViewCur).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private Label label4;
private Label label1;
private ComboBox comboBoxDirection;
private ComboBox comboBoxCourse;
private GroupBox groupBoxCurriculum;
private DataGridView dataGridViewCur;
private DataGridViewComboBoxColumn Column1;
private DataGridViewTextBoxColumn Column2;
private DataGridView dataGridView;
private DataGridViewComboBoxColumn ColumnSubject;
private DataGridViewTextBoxColumn ColumnLessons;
private DateTimePicker dateTimePicker1;
private Label label2;
}
}

View File

@ -0,0 +1,74 @@
using ProjectShedule.Entities;
using ProjectShedule.Entities.Enums;
using ProjectShedule.Repositories;
using System.Linq;
namespace ProjectShedule.Forms
{
public partial class FormCurriculumSubject : Form
{
private readonly ICurriculumSubjectRepository _curriculumSubjectRepository;
public FormCurriculumSubject(ICurriculumSubjectRepository curriculumSubjectRepository,
ICurriculumRepository curriculumRepository,
ISubjectRepository subjectRepository)
{
InitializeComponent();
_curriculumSubjectRepository = curriculumSubjectRepository ??
throw new ArgumentNullException(nameof(curriculumSubjectRepository));
comboBoxDirection.DataSource = curriculumRepository.ReadCurriculum();
comboBoxDirection.DisplayMember = "Direction";
comboBoxDirection.ValueMember = "Id";
comboBoxCourse.DataSource = Enum.GetValues(typeof(Course));
ColumnSubject.DataSource = subjectRepository.ReadSubject();
ColumnSubject.DisplayMember = "Name";
ColumnSubject.ValueMember = "Id";
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxDirection.SelectedIndex < 0 ||
comboBoxCourse.SelectedIndex < 1 || dataGridView.RowCount < 1)
{
throw new Exception("Есть незаполненные поля");
}
_curriculumSubjectRepository.CreateCurriculumSubject(CurriculumSubject.CreateCurriculumSubject(0,
dateTimePicker1.Value,
(int)comboBoxDirection.SelectedValue!,
(Course)comboBoxCourse.SelectedItem!,
CreateListSubjectSubjectFromDataGrid()));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
private List<SubjectSubject> CreateListSubjectSubjectFromDataGrid()
{
var list = new List<SubjectSubject>();
foreach (DataGridViewRow row in dataGridView.Rows)
{
if (row.Cells["ColumnSubject"].Value == null ||
row.Cells["ColumnLessons"].Value == null)
{
continue;
}
list.Add(SubjectSubject.CreateOperation(
0,
Convert.ToInt32(row.Cells["ColumnSubject"].Value),
Convert.ToInt32(row.Cells["ColumnLessons"].Value)));
}
return list.GroupBy(x => x.SubjectId, x => x.LessonsCount, (id, counts) =>
SubjectSubject.CreateOperation(0, id, counts.Sum())).ToList();
}
}
}

View File

@ -0,0 +1,144 @@
<?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="ColumnSubject.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnLessons.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnSubject.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnLessons.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,110 @@
namespace ProjectShedule.Forms
{
partial class FormCurriculumSubjectDistributionReport
{
/// <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()
{
buttonBuild = new Button();
buttonFile = new Button();
labelFileName = new Label();
label1 = new Label();
dateTimePicker = new DateTimePicker();
SuspendLayout();
//
// buttonBuild
//
buttonBuild.Location = new Point(21, 111);
buttonBuild.Margin = new Padding(3, 4, 3, 4);
buttonBuild.Name = "buttonBuild";
buttonBuild.Size = new Size(275, 31);
buttonBuild.TabIndex = 9;
buttonBuild.Text = "Сформировать";
buttonBuild.UseVisualStyleBackColor = true;
buttonBuild.Click += buttonBuild_Click;
//
// buttonFile
//
buttonFile.Location = new Point(21, 14);
buttonFile.Margin = new Padding(3, 4, 3, 4);
buttonFile.Name = "buttonFile";
buttonFile.Size = new Size(86, 31);
buttonFile.TabIndex = 8;
buttonFile.Text = "Выбрать";
buttonFile.UseVisualStyleBackColor = true;
buttonFile.Click += buttonFile_Click;
//
// labelFileName
//
labelFileName.AutoSize = true;
labelFileName.Location = new Point(115, 19);
labelFileName.Name = "labelFileName";
labelFileName.Size = new Size(45, 20);
labelFileName.TabIndex = 7;
labelFileName.Text = "Файл";
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(21, 62);
label1.Name = "label1";
label1.Size = new Size(44, 20);
label1.TabIndex = 6;
label1.Text = "Дата:";
//
// dateTimePicker
//
dateTimePicker.Location = new Point(68, 57);
dateTimePicker.Margin = new Padding(3, 4, 3, 4);
dateTimePicker.Name = "dateTimePicker";
dateTimePicker.Size = new Size(228, 27);
dateTimePicker.TabIndex = 5;
//
// FormCurriculumSubjectDistributionReport
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(323, 162);
Controls.Add(buttonBuild);
Controls.Add(buttonFile);
Controls.Add(labelFileName);
Controls.Add(label1);
Controls.Add(dateTimePicker);
Name = "FormCurriculumSubjectDistributionReport";
Text = "FormCurriculumSubjectDistributionReport";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonBuild;
private Button buttonFile;
private Label labelFileName;
private Label label1;
private DateTimePicker dateTimePicker;
}
}

View File

@ -0,0 +1,59 @@
using ProjectShedule.Reports;
using Unity;
namespace ProjectShedule.Forms
{
public partial class FormCurriculumSubjectDistributionReport : Form
{
private string _fileName = string.Empty;
private readonly IUnityContainer _container;
public FormCurriculumSubjectDistributionReport(IUnityContainer container)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void buttonFile_Click(object sender, EventArgs e)
{
var sfd = new SaveFileDialog()
{
Filter = "Pdf Files | *.pdf"
};
if (sfd.ShowDialog() == DialogResult.OK)
{
_fileName = sfd.FileName;
labelFileName.Text = Path.GetFileName(_fileName);
}
}
private void buttonBuild_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(_fileName))
{
throw new Exception("Отсутствует имя файла для отчета");
}
if
(_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePicker.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);
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,111 @@
namespace ProjectShedule.Forms
{
partial class FormCurriculumSubjects
{
/// <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();
buttonAdd = new Button();
dataGridView = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(600, 0);
panel1.Name = "panel1";
panel1.Size = new Size(200, 352);
panel1.TabIndex = 2;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.minus_PNG39;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(42, 214);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(94, 93);
buttonDel.TabIndex = 4;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Ambox_plus_svg;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(42, 45);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 93);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(601, 352);
dataGridView.TabIndex = 3;
//
// FormCurriculumSubjects
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 352);
Controls.Add(panel1);
Controls.Add(dataGridView);
Name = "FormCurriculumSubjects";
Text = "Учебные планы";
Load += FormCurriculumSubjects_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonAdd;
private DataGridView dataGridView;
private Button buttonDel;
}
}

View File

@ -0,0 +1,81 @@
using ProjectShedule.Repositories;
using Unity;
namespace ProjectShedule.Forms
{
public partial class FormCurriculumSubjects : Form
{
private readonly IUnityContainer _container;
private readonly ICurriculumSubjectRepository _curriculumSubjectRepository;
public FormCurriculumSubjects(IUnityContainer container, ICurriculumSubjectRepository curriculumSubjectRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_curriculumSubjectRepository = curriculumSubjectRepository ??
throw new ArgumentNullException(nameof(curriculumSubjectRepository));
}
private void FormCurriculumSubjects_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormCurriculumSubject>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _curriculumSubjectRepository.ReadCurriculumSubject();
private void buttonDel_Click(object sender, EventArgs e)
{
if (TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_curriculumSubjectRepository.DeleteCurriculumSubject(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return true;
}
else
{
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[id].Value);
return false;
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,125 @@
namespace ProjectShedule.Forms
{
partial class FormCurriculums
{
/// <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();
buttonAdd = 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(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(622, 0);
panel1.Name = "panel1";
panel1.Size = new Size(178, 353);
panel1.TabIndex = 2;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.minus_PNG39;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(42, 248);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(94, 93);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources._3712684;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(42, 129);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(94, 93);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Ambox_plus_svg;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(42, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 93);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(625, 353);
dataGridView.TabIndex = 3;
//
// FormCurriculums
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 353);
Controls.Add(panel1);
Controls.Add(dataGridView);
Name = "FormCurriculums";
Text = "Учебные планы(дисциплины)";
Load += FormCurriculums_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,99 @@
using ProjectShedule.Repositories;
using Unity;
namespace ProjectShedule.Forms
{
public partial class FormCurriculums : Form
{
private readonly IUnityContainer _container;
private readonly ICurriculumRepository _curriculumRepository;
public FormCurriculums(IUnityContainer container, ICurriculumRepository curriculumRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_curriculumRepository = curriculumRepository ??
throw new ArgumentNullException(nameof(curriculumRepository));
}
private void FormCurriculums_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormCurriculum>().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<FormCurriculum>();
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
{
_curriculumRepository.DeleteCurriculum(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _curriculumRepository.ReadCurriculum();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return true;
}
else
{
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[id].Value);
return false;
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,131 @@
namespace ProjectShedule.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()
{
checkBoxGroups = new CheckBox();
buttonBuild = new Button();
checkBoxCurriculums = new CheckBox();
checkBoxSubjects = new CheckBox();
checkBoxTeachers = new CheckBox();
checkBoxClassrooms = new CheckBox();
SuspendLayout();
//
// checkBoxGroups
//
checkBoxGroups.AutoSize = true;
checkBoxGroups.Location = new Point(12, 203);
checkBoxGroups.Margin = new Padding(3, 4, 3, 4);
checkBoxGroups.Name = "checkBoxGroups";
checkBoxGroups.Size = new Size(83, 24);
checkBoxGroups.TabIndex = 11;
checkBoxGroups.Text = "Группы";
checkBoxGroups.UseVisualStyleBackColor = true;
//
// buttonBuild
//
buttonBuild.Location = new Point(10, 254);
buttonBuild.Margin = new Padding(3, 4, 3, 4);
buttonBuild.Name = "buttonBuild";
buttonBuild.Size = new Size(159, 31);
buttonBuild.TabIndex = 10;
buttonBuild.Text = "Сформировать";
buttonBuild.UseVisualStyleBackColor = true;
buttonBuild.Click += buttonBuild_Click;
//
// checkBoxCurriculums
//
checkBoxCurriculums.AutoSize = true;
checkBoxCurriculums.Location = new Point(12, 154);
checkBoxCurriculums.Margin = new Padding(3, 4, 3, 4);
checkBoxCurriculums.Name = "checkBoxCurriculums";
checkBoxCurriculums.Size = new Size(127, 24);
checkBoxCurriculums.TabIndex = 9;
checkBoxCurriculums.Text = "Направлении";
checkBoxCurriculums.UseVisualStyleBackColor = true;
//
// checkBoxSubjects
//
checkBoxSubjects.AutoSize = true;
checkBoxSubjects.Location = new Point(12, 106);
checkBoxSubjects.Margin = new Padding(3, 4, 3, 4);
checkBoxSubjects.Name = "checkBoxSubjects";
checkBoxSubjects.Size = new Size(121, 24);
checkBoxSubjects.TabIndex = 8;
checkBoxSubjects.Text = "Дисциплины";
checkBoxSubjects.UseVisualStyleBackColor = true;
//
// checkBoxTeachers
//
checkBoxTeachers.AutoSize = true;
checkBoxTeachers.Location = new Point(12, 58);
checkBoxTeachers.Margin = new Padding(3, 4, 3, 4);
checkBoxTeachers.Name = "checkBoxTeachers";
checkBoxTeachers.Size = new Size(140, 24);
checkBoxTeachers.TabIndex = 7;
checkBoxTeachers.Text = "Преподаватели";
checkBoxTeachers.UseVisualStyleBackColor = true;
//
// checkBoxClassrooms
//
checkBoxClassrooms.AutoSize = true;
checkBoxClassrooms.Location = new Point(12, 13);
checkBoxClassrooms.Margin = new Padding(3, 4, 3, 4);
checkBoxClassrooms.Name = "checkBoxClassrooms";
checkBoxClassrooms.Size = new Size(107, 24);
checkBoxClassrooms.TabIndex = 6;
checkBoxClassrooms.Text = "Аудитории";
checkBoxClassrooms.UseVisualStyleBackColor = true;
//
// FormDirectoryReport
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(187, 300);
Controls.Add(checkBoxGroups);
Controls.Add(buttonBuild);
Controls.Add(checkBoxCurriculums);
Controls.Add(checkBoxSubjects);
Controls.Add(checkBoxTeachers);
Controls.Add(checkBoxClassrooms);
Name = "FormDirectoryReport";
Text = "FormDirectoryReport";
ResumeLayout(false);
PerformLayout();
}
#endregion
private CheckBox checkBoxGroups;
private Button buttonBuild;
private CheckBox checkBoxCurriculums;
private CheckBox checkBoxSubjects;
private CheckBox checkBoxTeachers;
private CheckBox checkBoxClassrooms;
}
}

View File

@ -0,0 +1,52 @@
using ProjectShedule.Reports;
using Unity;
namespace ProjectShedule.Forms
{
public partial class FormDirectoryReport : Form
{
private readonly IUnityContainer _container;
public FormDirectoryReport(IUnityContainer container)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void buttonBuild_Click(object sender, EventArgs e)
{
try
{
if (!checkBoxClassrooms.Checked && !checkBoxTeachers.Checked && !checkBoxSubjects.Checked && !checkBoxCurriculums.Checked && !checkBoxGroups.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, checkBoxClassrooms.Checked, checkBoxTeachers.Checked, checkBoxSubjects.Checked, checkBoxCurriculums.Checked, checkBoxGroups.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);
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,167 @@
namespace ProjectShedule.Forms
{
partial class FormGroup
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
comboBoxCourse = new ComboBox();
label1 = new Label();
label2 = new Label();
numericUpDownStudentsCount = new NumericUpDown();
label3 = new Label();
textBoxGroupName = new TextBox();
label4 = new Label();
comboBoxCurriculum = new ComboBox();
buttonSave = new Button();
buttonCancel = new Button();
((System.ComponentModel.ISupportInitialize)numericUpDownStudentsCount).BeginInit();
SuspendLayout();
//
// comboBoxCourse
//
comboBoxCourse.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxCourse.FormattingEnabled = true;
comboBoxCourse.Location = new Point(179, 142);
comboBoxCourse.Name = "comboBoxCourse";
comboBoxCourse.Size = new Size(150, 28);
comboBoxCourse.TabIndex = 0;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(40, 42);
label1.Name = "label1";
label1.Size = new Size(133, 20);
label1.TabIndex = 1;
label1.Text = "Кол-во студентов:";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(40, 98);
label2.Name = "label2";
label2.Size = new Size(135, 20);
label2.TabIndex = 2;
label2.Text = "Название группы:";
//
// numericUpDownStudentsCount
//
numericUpDownStudentsCount.Location = new Point(179, 35);
numericUpDownStudentsCount.Name = "numericUpDownStudentsCount";
numericUpDownStudentsCount.Size = new Size(150, 27);
numericUpDownStudentsCount.TabIndex = 3;
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(129, 150);
label3.Name = "label3";
label3.Size = new Size(44, 20);
label3.TabIndex = 4;
label3.Text = "Курс:";
//
// textBoxGroupName
//
textBoxGroupName.Location = new Point(179, 91);
textBoxGroupName.Name = "textBoxGroupName";
textBoxGroupName.Size = new Size(150, 27);
textBoxGroupName.TabIndex = 5;
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(60, 202);
label4.Name = "label4";
label4.Size = new Size(113, 20);
label4.TabIndex = 6;
label4.Text = "Учебный план:";
//
// comboBoxCurriculum
//
comboBoxCurriculum.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxCurriculum.FormattingEnabled = true;
comboBoxCurriculum.Location = new Point(179, 194);
comboBoxCurriculum.Name = "comboBoxCurriculum";
comboBoxCurriculum.Size = new Size(150, 28);
comboBoxCurriculum.TabIndex = 7;
//
// buttonSave
//
buttonSave.Location = new Point(97, 250);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 8;
buttonSave.Text = "Создать";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(206, 250);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 9;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// FormGroup
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(397, 313);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(comboBoxCurriculum);
Controls.Add(label4);
Controls.Add(textBoxGroupName);
Controls.Add(label3);
Controls.Add(numericUpDownStudentsCount);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(comboBoxCourse);
Name = "FormGroup";
Text = "Группа студентов";
((System.ComponentModel.ISupportInitialize)numericUpDownStudentsCount).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private ComboBox comboBoxCourse;
private Label label1;
private Label label2;
private NumericUpDown numericUpDownStudentsCount;
private Label label3;
private TextBox textBoxGroupName;
private Label label4;
private ComboBox comboBoxCurriculum;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,79 @@
using ProjectShedule.Entities;
using ProjectShedule.Entities.Enums;
using ProjectShedule.Repositories;
namespace ProjectShedule.Forms
{
public partial class FormGroup : Form
{
private readonly IGroupRepository _groupRepository;
private int? _groupId;
public int Id
{
set
{
try
{
var group = _groupRepository.ReadGroupById(value);
if (group == null)
{
throw new InvalidDataException(nameof(group));
}
numericUpDownStudentsCount.Value = group.StudentsCount;
textBoxGroupName.Text = group.GroupNumber;
comboBoxCourse.SelectedItem = group.Course;
comboBoxCurriculum.SelectedValue = group.CurriculumId;
_groupId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormGroup(IGroupRepository groupRepository, ICurriculumRepository curriculumRepository)
{
InitializeComponent();
_groupRepository = groupRepository ??
throw new ArgumentNullException(nameof(groupRepository));
comboBoxCourse.DataSource = Enum.GetValues(typeof(Course));
comboBoxCurriculum.DataSource = curriculumRepository.ReadCurriculum();
comboBoxCurriculum.DisplayMember = "Direction";
comboBoxCurriculum.ValueMember = "Id";
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxGroupName.Text) || comboBoxCourse.SelectedIndex < 1 ||
comboBoxCurriculum.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
if (_groupId.HasValue)
{
_groupRepository.UpdateGroup(CreateGroup(_groupId.Value));
}
else
{
_groupRepository.CreateGroup(CreateGroup(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
private StudentsGroup CreateGroup(int id) => StudentsGroup.CreateGroup(
id,
Convert.ToInt32(numericUpDownStudentsCount.Value),
textBoxGroupName.Text,
(Course)comboBoxCourse.SelectedItem!,
(int)comboBoxCurriculum.SelectedValue!);
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,125 @@
namespace ProjectShedule.Forms
{
partial class FormGroups
{
/// <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();
buttonAdd = 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(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(622, 0);
panel1.Name = "panel1";
panel1.Size = new Size(178, 354);
panel1.TabIndex = 4;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.minus_PNG39;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(42, 248);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(94, 93);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources._3712684;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(42, 129);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(94, 93);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Ambox_plus_svg;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(42, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 93);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(626, 354);
dataGridView.TabIndex = 5;
//
// FormGroups
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 354);
Controls.Add(panel1);
Controls.Add(dataGridView);
Name = "FormGroups";
Text = "Группы студентов";
Load += FormGroups_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,101 @@
using ProjectShedule.Repositories;
using Unity;
namespace ProjectShedule.Forms
{
public partial class FormGroups : Form
{
private readonly IUnityContainer _container;
private readonly IGroupRepository _groupRepository;
public FormGroups(IUnityContainer container, IGroupRepository groupRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_groupRepository = groupRepository ??
throw new ArgumentNullException(nameof(groupRepository));
}
private void FormGroups_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormGroup>().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<FormGroup>();
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
{
_groupRepository.DeleteGroup(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _groupRepository.ReadGroup();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return true;
}
else
{
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[id].Value);
return false;
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,210 @@
namespace ProjectShedule.Forms
{
partial class FormShedule
{
/// <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()
{
dateTimePicker = new DateTimePicker();
labelData = new Label();
comboBoxClassroom = new ComboBox();
comboBoxTeacher = new ComboBox();
comboBoxGroup = new ComboBox();
comboBoxSubject = new ComboBox();
checkedListBox = new CheckedListBox();
label1 = new Label();
label2 = new Label();
label3 = new Label();
label4 = new Label();
label5 = new Label();
buttonCancel = new Button();
buttonSave = new Button();
SuspendLayout();
//
// dateTimePicker
//
dateTimePicker.Location = new Point(163, 37);
dateTimePicker.Name = "dateTimePicker";
dateTimePicker.Size = new Size(159, 27);
dateTimePicker.TabIndex = 0;
//
// labelData
//
labelData.AutoSize = true;
labelData.Location = new Point(103, 44);
labelData.Name = "labelData";
labelData.Size = new Size(44, 20);
labelData.TabIndex = 1;
labelData.Text = "Дата:";
//
// comboBoxClassroom
//
comboBoxClassroom.FormattingEnabled = true;
comboBoxClassroom.Location = new Point(163, 252);
comboBoxClassroom.Name = "comboBoxClassroom";
comboBoxClassroom.Size = new Size(159, 28);
comboBoxClassroom.TabIndex = 3;
//
// comboBoxTeacher
//
comboBoxTeacher.FormattingEnabled = true;
comboBoxTeacher.Location = new Point(163, 147);
comboBoxTeacher.Name = "comboBoxTeacher";
comboBoxTeacher.Size = new Size(159, 28);
comboBoxTeacher.TabIndex = 4;
//
// comboBoxGroup
//
comboBoxGroup.FormattingEnabled = true;
comboBoxGroup.Location = new Point(163, 91);
comboBoxGroup.Name = "comboBoxGroup";
comboBoxGroup.Size = new Size(159, 28);
comboBoxGroup.TabIndex = 5;
//
// comboBoxSubject
//
comboBoxSubject.FormattingEnabled = true;
comboBoxSubject.Location = new Point(163, 200);
comboBoxSubject.Name = "comboBoxSubject";
comboBoxSubject.Size = new Size(159, 28);
comboBoxSubject.TabIndex = 6;
//
// checkedListBox
//
checkedListBox.FormattingEnabled = true;
checkedListBox.Location = new Point(455, 37);
checkedListBox.Name = "checkedListBox";
checkedListBox.Size = new Size(150, 246);
checkedListBox.TabIndex = 7;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(27, 155);
label1.Name = "label1";
label1.Size = new Size(120, 20);
label1.TabIndex = 8;
label1.Text = "Преподаватель:";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(86, 99);
label2.Name = "label2";
label2.Size = new Size(61, 20);
label2.TabIndex = 9;
label2.Text = "Группа:";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(74, 208);
label3.Name = "label3";
label3.Size = new Size(73, 20);
label3.TabIndex = 10;
label3.Text = "Предмет:";
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(63, 260);
label4.Name = "label4";
label4.Size = new Size(84, 20);
label4.TabIndex = 11;
label4.Text = "Аудитория";
//
// label5
//
label5.AutoSize = true;
label5.Location = new Point(370, 44);
label5.Name = "label5";
label5.Size = new Size(69, 20);
label5.TabIndex = 12;
label5.Text = "Пара(ы):";
//
// buttonCancel
//
buttonCancel.Location = new Point(323, 315);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 14;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(223, 315);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 13;
buttonSave.Text = "Создать";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// FormShedule
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(642, 368);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(label5);
Controls.Add(label4);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(checkedListBox);
Controls.Add(comboBoxSubject);
Controls.Add(comboBoxGroup);
Controls.Add(comboBoxTeacher);
Controls.Add(comboBoxClassroom);
Controls.Add(labelData);
Controls.Add(dateTimePicker);
Name = "FormShedule";
Text = "Составление расписания";
ResumeLayout(false);
PerformLayout();
}
#endregion
private DateTimePicker dateTimePicker;
private Label labelData;
private ComboBox comboBoxClassroom;
private ComboBox comboBoxTeacher;
private ComboBox comboBoxGroup;
private ComboBox comboBoxSubject;
private CheckedListBox checkedListBox;
private Label label1;
private Label label2;
private Label label3;
private Label label4;
private Label label5;
private Button buttonCancel;
private Button buttonSave;
}
}

View File

@ -0,0 +1,73 @@
using ProjectShedule.Entities;
using ProjectShedule.Entities.Enums;
using ProjectShedule.Repositories;
namespace ProjectShedule.Forms
{
public partial class FormShedule : Form
{
private readonly ISheduleRepository _sheduleRepository;
public FormShedule(ISheduleRepository sheduleRepository, IGroupRepository groupRepository, ITeacherRepository teacherRepository,
ISubjectRepository subjectRepository, IClassroomRepository classroomRepository)
{
InitializeComponent();
_sheduleRepository = sheduleRepository ??
throw new ArgumentNullException(nameof(sheduleRepository));
foreach (PairNumber pairNumber in Enum.GetValues(typeof(PairNumber)))
{
if (pairNumber == PairNumber.None) continue;
checkedListBox.Items.Add(pairNumber);
}
comboBoxGroup.DataSource = groupRepository.ReadGroup();
comboBoxGroup.DisplayMember = "GroupNumber";
comboBoxGroup.ValueMember = "Id";
comboBoxTeacher.DataSource = teacherRepository.ReadTeacher();
comboBoxTeacher.DisplayMember = "LastName";
comboBoxTeacher.ValueMember = "Id";
comboBoxSubject.DataSource = subjectRepository.ReadSubject();
comboBoxSubject.DisplayMember = "Name";
comboBoxSubject.ValueMember = "Id";
comboBoxClassroom.DataSource = classroomRepository.ReadClassroom();
comboBoxClassroom.DisplayMember = "Name";
comboBoxClassroom.ValueMember = "Id";
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxGroup.SelectedIndex < 0 || comboBoxTeacher.SelectedIndex < 0 || comboBoxSubject.SelectedIndex < 0 ||
comboBoxClassroom.SelectedIndex < 0 || checkedListBox.CheckedItems.Count == 0)
{
throw new Exception("Имеются незаполненные поля");
}
PairNumber pairNumber = PairNumber.None;
int pairCount = 0;
foreach (var elem in checkedListBox.CheckedItems)
{
pairNumber |= (PairNumber)elem;
pairCount++;
}
_sheduleRepository.CreateShedule(Shedule.CreateOperation(0,
dateTimePicker.Value,
pairNumber,
pairCount,
(int)comboBoxGroup.SelectedValue!,
(int)comboBoxTeacher.SelectedValue!,
(int)comboBoxSubject.SelectedValue!,
(int)comboBoxClassroom.SelectedValue!));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,168 @@
namespace ProjectShedule.Forms
{
partial class FormSheduleReport
{
/// <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()
{
label4 = new Label();
label3 = new Label();
label2 = new Label();
label1 = new Label();
buttonBuild = new Button();
buttonFile = new Button();
textBoxFilePath = new TextBox();
comboBoxSubject = new ComboBox();
dateTimePickerStart = new DateTimePicker();
dateTimePickerEnd = new DateTimePicker();
SuspendLayout();
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(27, 183);
label4.Name = "label4";
label4.Size = new Size(90, 20);
label4.TabIndex = 19;
label4.Text = "Дата конца:";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(27, 132);
label3.Name = "label3";
label3.Size = new Size(97, 20);
label3.TabIndex = 18;
label3.Text = "Дата начала:";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(27, 75);
label2.Name = "label2";
label2.Size = new Size(73, 20);
label2.TabIndex = 17;
label2.Text = "Предмет:";
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(27, 23);
label1.Name = "label1";
label1.Size = new Size(112, 20);
label1.TabIndex = 16;
label1.Text = "Путь до файла:";
//
// buttonBuild
//
buttonBuild.Location = new Point(27, 233);
buttonBuild.Margin = new Padding(3, 4, 3, 4);
buttonBuild.Name = "buttonBuild";
buttonBuild.Size = new Size(338, 31);
buttonBuild.TabIndex = 15;
buttonBuild.Text = "Сформировать";
buttonBuild.UseVisualStyleBackColor = true;
buttonBuild.Click += buttonBuild_Click;
//
// buttonFile
//
buttonFile.Location = new Point(333, 19);
buttonFile.Margin = new Padding(3, 4, 3, 4);
buttonFile.Name = "buttonFile";
buttonFile.Size = new Size(30, 31);
buttonFile.TabIndex = 14;
buttonFile.Text = "...";
buttonFile.UseVisualStyleBackColor = true;
buttonFile.Click += buttonFile_Click;
//
// textBoxFilePath
//
textBoxFilePath.Location = new Point(137, 19);
textBoxFilePath.Margin = new Padding(3, 4, 3, 4);
textBoxFilePath.Name = "textBoxFilePath";
textBoxFilePath.Size = new Size(189, 27);
textBoxFilePath.TabIndex = 13;
//
// comboBoxSubject
//
comboBoxSubject.FormattingEnabled = true;
comboBoxSubject.Location = new Point(137, 71);
comboBoxSubject.Margin = new Padding(3, 4, 3, 4);
comboBoxSubject.Name = "comboBoxSubject";
comboBoxSubject.Size = new Size(226, 28);
comboBoxSubject.TabIndex = 12;
//
// dateTimePickerStart
//
dateTimePickerStart.Location = new Point(137, 124);
dateTimePickerStart.Margin = new Padding(3, 4, 3, 4);
dateTimePickerStart.Name = "dateTimePickerStart";
dateTimePickerStart.Size = new Size(228, 27);
dateTimePickerStart.TabIndex = 11;
//
// dateTimePickerEnd
//
dateTimePickerEnd.Location = new Point(137, 175);
dateTimePickerEnd.Margin = new Padding(3, 4, 3, 4);
dateTimePickerEnd.Name = "dateTimePickerEnd";
dateTimePickerEnd.Size = new Size(228, 27);
dateTimePickerEnd.TabIndex = 10;
//
// FormSheduleReport
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(402, 278);
Controls.Add(label4);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(buttonBuild);
Controls.Add(buttonFile);
Controls.Add(textBoxFilePath);
Controls.Add(comboBoxSubject);
Controls.Add(dateTimePickerStart);
Controls.Add(dateTimePickerEnd);
Name = "FormSheduleReport";
Text = "Отчет по прохождению учебного плана";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label4;
private Label label3;
private Label label2;
private Label label1;
private Button buttonBuild;
private Button buttonFile;
private TextBox textBoxFilePath;
private ComboBox comboBoxSubject;
private DateTimePicker dateTimePickerStart;
private DateTimePicker dateTimePickerEnd;
}
}

View File

@ -0,0 +1,70 @@
using ProjectShedule.Reports;
using ProjectShedule.Repositories;
using Unity;
namespace ProjectShedule.Forms
{
public partial class FormSheduleReport : Form
{
private readonly IUnityContainer _container;
public FormSheduleReport(IUnityContainer container, ISubjectRepository subjectRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
comboBoxSubject.DataSource = subjectRepository.ReadSubject();
comboBoxSubject.DisplayMember = "Name";
comboBoxSubject.ValueMember = "Id";
}
private void buttonFile_Click(object sender, EventArgs e)
{
var sfd = new SaveFileDialog()
{
Filter = "Excel Files | *.xlsx"
};
if (sfd.ShowDialog() != DialogResult.OK)
{
return;
}
textBoxFilePath.Text = sfd.FileName;
}
private void buttonBuild_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxFilePath.Text))
{
throw new Exception("Отсутствует имя файла для отчета");
}
if (comboBoxSubject.SelectedIndex < 0)
{
throw new Exception("Не выбран корм");
}
if (dateTimePickerEnd.Value <= dateTimePickerStart.Value)
{
throw new Exception("Дата начала должна быть раньше даты окончания");
}
if (_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, (int)comboBoxSubject.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);
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,112 @@
namespace ProjectShedule.Forms
{
partial class FormShedules
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
dataGridView = new DataGridView();
buttonAdd = new Button();
panel1 = new Panel();
buttonDel = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// 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.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(622, 315);
dataGridView.TabIndex = 5;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Ambox_plus_svg;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(42, 46);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 93);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// panel1
//
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(622, 0);
panel1.Name = "panel1";
panel1.Size = new Size(178, 315);
panel1.TabIndex = 4;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.minus_PNG39;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(42, 175);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(94, 93);
buttonDel.TabIndex = 4;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// FormShedules
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 315);
Controls.Add(dataGridView);
Controls.Add(panel1);
Name = "FormShedules";
Text = "Расписании";
Load += FormShedules_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonAdd;
private Panel panel1;
private Button buttonDel;
}
}

View File

@ -0,0 +1,84 @@
using ProjectShedule.Repositories;
using Unity;
namespace ProjectShedule.Forms
{
public partial class FormShedules : Form
{
private readonly IUnityContainer _container;
private readonly ISheduleRepository _sheduleRepository;
public FormShedules(IUnityContainer container, ISheduleRepository sheduleRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_sheduleRepository = sheduleRepository ??
throw new ArgumentNullException(nameof(sheduleRepository));
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormShedule>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormShedules_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _sheduleRepository.ReadShedule();
private void buttonDel_Click(object sender, EventArgs e)
{
if (TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_sheduleRepository.DeleteShedule(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return true;
}
else
{
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[id].Value);
return false;
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,95 @@
namespace ProjectShedule.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()
{
buttonCancel = new Button();
buttonSave = new Button();
textBoxSubjectName = new TextBox();
label2 = new Label();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(251, 136);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 15;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(96, 136);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 14;
buttonSave.Text = "Создать";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// textBoxSubjectName
//
textBoxSubjectName.Location = new Point(216, 63);
textBoxSubjectName.Name = "textBoxSubjectName";
textBoxSubjectName.Size = new Size(150, 27);
textBoxSubjectName.TabIndex = 11;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(57, 66);
label2.Name = "label2";
label2.Size = new Size(151, 20);
label2.TabIndex = 10;
label2.Text = "Название предмета:";
//
// FormSubject
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(445, 210);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxSubjectName);
Controls.Add(label2);
Name = "FormSubject";
Text = "Дициплина";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private TextBox textBoxSubjectName;
private Label label2;
}
}

View File

@ -0,0 +1,67 @@
using ProjectShedule.Entities;
using ProjectShedule.Repositories;
namespace ProjectShedule.Forms;
public partial class FormSubject : Form
{
private readonly ISubjectRepository _subjectRepository;
private int? _subjectId;
public int Id
{
set
{
try
{
var subject = _subjectRepository.ReadSubjectById(value);
if (subject == null)
{
throw new InvalidDataException(nameof(subject));
}
textBoxSubjectName.Text = subject.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(textBoxSubjectName.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_subjectId.HasValue)
{
_subjectRepository.UpdateSubject(CreateSubject(_subjectId.Value));
}
else
{
_subjectRepository.CreateSubject(CreateSubject(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
private Subject CreateSubject(int id) => Subject.CreateSubject(
id,
textBoxSubjectName.Text);
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,126 @@
namespace ProjectShedule.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();
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = 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(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(622, 0);
panel1.Name = "panel1";
panel1.Size = new Size(178, 354);
panel1.TabIndex = 2;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.minus_PNG39;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(42, 248);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(94, 93);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources._3712684;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(42, 129);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(94, 93);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Ambox_plus_svg;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(42, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 93);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(623, 354);
dataGridView.TabIndex = 3;
//
// FormSubjects
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 354);
Controls.Add(panel1);
Controls.Add(dataGridView);
Name = "FormSubjects";
StartPosition = FormStartPosition.CenterParent;
Text = "Дисциплины";
Load += FormSubjects_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,99 @@
using ProjectShedule.Repositories;
using Unity;
namespace ProjectShedule.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 FormSubjects_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormSubject>().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<FormSubject>();
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
{
_subjectRepository.DeleteSubject(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _subjectRepository.ReadSubject();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return true;
}
else
{
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[id].Value);
return false;
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,120 @@
namespace ProjectShedule.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()
{
buttonCancel = new Button();
buttonSave = new Button();
label3 = new Label();
textBoxFirstName = new TextBox();
label2 = new Label();
textBoxLastName = new TextBox();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(223, 146);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 15;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(94, 146);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 14;
buttonSave.Text = "Создать";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(50, 98);
label3.Name = "label3";
label3.Size = new Size(76, 20);
label3.TabIndex = 12;
label3.Text = "Фамилия:";
//
// textBoxFirstName
//
textBoxFirstName.Location = new Point(223, 49);
textBoxFirstName.Name = "textBoxFirstName";
textBoxFirstName.Size = new Size(150, 27);
textBoxFirstName.TabIndex = 11;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(50, 56);
label2.Name = "label2";
label2.Size = new Size(42, 20);
label2.TabIndex = 10;
label2.Text = "Имя:";
//
// textBoxLastName
//
textBoxLastName.Location = new Point(223, 91);
textBoxLastName.Name = "textBoxLastName";
textBoxLastName.Size = new Size(150, 27);
textBoxLastName.TabIndex = 16;
//
// FormTeacher
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(411, 203);
Controls.Add(textBoxLastName);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(label3);
Controls.Add(textBoxFirstName);
Controls.Add(label2);
Name = "FormTeacher";
Text = "Преподаватель";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private ComboBox comboBoxTypeClassroom;
private Label label3;
private TextBox textBoxFirstName;
private Label label2;
private TextBox textBoxLastName;
private NumericUpDown numericUpDownClassroomSize;
private Label label1;
}
}

View File

@ -0,0 +1,72 @@
using ProjectShedule.Entities;
using ProjectShedule.Repositories;
namespace ProjectShedule.Forms
{
public partial class FormTeacher : Form
{
private readonly ITeacherRepository _teacherRepository;
private int? _teacherId;
public int Id
{
set
{
try
{
var teacher = _teacherRepository.ReadTeacherById(value);
if (teacher == null)
{
throw new InvalidDataException(nameof(teacher));
}
textBoxFirstName.Text = teacher.FirstName;
textBoxLastName.Text = teacher.LastName;
_teacherId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormTeacher(ITeacherRepository teacherRepository)
{
InitializeComponent();
_teacherRepository = teacherRepository ??
throw new ArgumentNullException(nameof(teacherRepository));
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) ||
string.IsNullOrWhiteSpace(textBoxLastName.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 void buttonCancel_Click(object sender, EventArgs e) => Close();
private Teacher CreateTeacher(int id) => Teacher.CreateTeacher(
id,
textBoxFirstName.Text,
textBoxLastName.Text);
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,126 @@
namespace ProjectShedule.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();
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = 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(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(622, 0);
panel1.Name = "panel1";
panel1.Size = new Size(178, 353);
panel1.TabIndex = 2;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.minus_PNG39;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(42, 248);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(94, 93);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources._3712684;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(42, 129);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(94, 93);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Ambox_plus_svg;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(42, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 93);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_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.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(800, 353);
dataGridView.TabIndex = 3;
//
// FormTeachers
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 353);
Controls.Add(panel1);
Controls.Add(dataGridView);
Name = "FormTeachers";
Text = "Преподаватели";
Load += FormTeachers_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,99 @@
using ProjectShedule.Repositories;
using Unity;
namespace ProjectShedule.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 FormTeachers_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormTeacher>().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<FormTeacher>();
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
{
_teacherRepository.DeleteTeacher(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _teacherRepository.ReadTeacher();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return true;
}
else
{
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[id].Value);
return false;
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,3 +1,11 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using ProjectShedule.Repositories;
using ProjectShedule.Repositories.Implementations;
using Serilog;
using Unity;
using Unity.Microsoft.Logging;
namespace ProjectShedule
{
internal static class Program
@ -11,7 +19,37 @@ namespace ProjectShedule
// 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<FormSchedulingBureau>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.AddExtension(new
LoggingExtension(CreateLoggerFactory()));
container.RegisterType<IClassroomRepository, ClassroomRepository>();
container.RegisterType<ICurriculumRepository, CurriculumRepository>();
container.RegisterType<IGroupRepository, GroupRepository>();
container.RegisterType<ISheduleRepository, SheduleRepository>();
container.RegisterType<ISubjectRepository, SubjectRepository>();
container.RegisterType<ITeacherRepository, TeacherRepository>();
container.RegisterType<ICurriculumSubjectRepository, CurriculumSubjectRepository>();
container.RegisterType<IConnectionString, ConnectionString>();
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;
}
}
}

View File

@ -8,4 +8,45 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql" Version="8.0.5" />
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
<PackageReference Include="Serilog" Version="4.1.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<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>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="https://json.schemastore.org/appsscript.json" /></VisualStudio></ProjectExtensions>
</Project>

View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectShedule.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("ProjectShedule.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 _3712684 {
get {
object obj = ResourceManager.GetObject("3712684", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Ambox_plus_svg {
get {
object obj = ResourceManager.GetObject("Ambox_plus.svg", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap back {
get {
object obj = ResourceManager.GetObject("back", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap minus_PNG39 {
get {
object obj = ResourceManager.GetObject("minus_PNG39", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -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="back" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\back.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="3712684" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\3712684.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Ambox_plus.svg" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Ambox_plus.svg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="minus_PNG39" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\minus_PNG39.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,48 @@
using Microsoft.Extensions.Logging;
using ProjectShedule.Repositories;
namespace ProjectShedule.Reports;
internal class ChartReport
{
private readonly ICurriculumSubjectRepository _curriculumSubjectRepository;
private readonly ISubjectRepository _subjectRepository;
private readonly ILogger<ChartReport> _logger;
public ChartReport(ICurriculumSubjectRepository curriculumSubjectRepository, ISubjectRepository subjectRepository, ILogger<ChartReport> logger)
{
_curriculumSubjectRepository = curriculumSubjectRepository ?? throw new ArgumentNullException(nameof(curriculumSubjectRepository));
_subjectRepository = subjectRepository ?? throw new ArgumentNullException(nameof(subjectRepository));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public bool CreateChart(string filePath, DateTime dateTime)
{
try
{
new PdfBuilder(filePath)
.AddHeader("Распределение занятий")
.AddPieChart("Дисциплины", GetData(dateTime))
.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при формировании документа");
return false;
}
}
private List<(string Caption, double Value)> GetData(DateTime dateTime)
{
var subjectNames = _subjectRepository.ReadSubject()
.ToDictionary(f => f.Id, f => f.Name);
return _curriculumSubjectRepository
.ReadCurriculumSubject()
.Where(x => x.Date.Date == dateTime.Date)
.SelectMany(x => x.SubjectSubject)
.GroupBy(x => x.SubjectId)
.Select(g => (Caption: subjectNames[g.Key].ToString(), Value: (double)g.Sum(x => x.LessonsCount)))
.ToList();
}
}

View File

@ -0,0 +1,120 @@
using Microsoft.Extensions.Logging;
using ProjectShedule.Repositories;
namespace ProjectShedule.Reports;
internal class DocReport
{
private readonly IClassroomRepository _classroomRepository;
private readonly ITeacherRepository _teacherRepository;
private readonly ISubjectRepository _subjectRepository;
private readonly ICurriculumRepository _curriculumRepository;
private readonly IGroupRepository _groupRepository;
private readonly ILogger<DocReport> _logger;
public DocReport(IClassroomRepository classroomRepository,
ITeacherRepository teacherRepository,
ISubjectRepository subjectRepository,
ICurriculumRepository curriculumRepository,
IGroupRepository groupRepository,
ILogger<DocReport> logger)
{
_classroomRepository = classroomRepository ??
throw new ArgumentNullException(nameof(classroomRepository));
_teacherRepository = teacherRepository ??
throw new ArgumentNullException(nameof(teacherRepository));
_subjectRepository = subjectRepository ??
throw new ArgumentNullException(nameof(subjectRepository));
_curriculumRepository = curriculumRepository ??
throw new ArgumentNullException(nameof(curriculumRepository));
_groupRepository = groupRepository ??
throw new ArgumentNullException(nameof(groupRepository));
_logger = logger ??
throw new ArgumentNullException(nameof(logger));
}
public bool CreateDoc(string filePath, bool includeClassrooms,
bool includeTeachers, bool includeSubjects,
bool includeCurriculums, bool includeGroups)
{
try
{
var builder = new WordBuilder(filePath)
.AddHeader("Документ со справочниками");
if (includeClassrooms)
{
builder.AddParagraph("Аудитории")
.AddTable([2400, 1200, 2400],
GetClassrooms());
}
if (includeTeachers)
{
builder.AddParagraph("Преподаватели")
.AddTable([2400, 2400],
GetTeachers());
}
if (includeSubjects)
{
builder.AddParagraph("Дисциплины")
.AddTable([2400],
GetSubjects());
}
if (includeCurriculums)
{
builder.AddParagraph("Направлении")
.AddTable([2400],
GetCurriculums());
}
if (includeGroups)
{
builder.AddParagraph("Группы студентов")
.AddTable([2400, 2400, 1200, 2400],
GetGroups());
}
builder.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при формировании документа");
return false;
}
}
private List<string[]> GetClassrooms()
{
return [
["Размер", "Номер аудитории", "Тип"],
.. _classroomRepository.ReadClassroom().Select(x => new string[]
{ x.Size.ToString(), x.Name, x.ClassType.ToString() }),
];
}
private List<string[]> GetTeachers()
{
return [
["Имя", "Фамилия"],
.. _teacherRepository.ReadTeacher().Select(x => new string[] { x.FirstName, x.LastName }),
];
}
private List<string[]> GetSubjects()
{
return [
["Название предмета"],
.. _subjectRepository.ReadSubject().Select(x => new string[]
{ x.Name }),
];
}
private List<string[]> GetCurriculums()
{
return [
["Направление"],
.. _curriculumRepository.ReadCurriculum().Select(x => new string[]
{ x.Direction }),
];
}
private List<string[]> GetGroups()
{
return [
["Количество студентов", "Номер группы", "Курс", "Направление"],
.. _groupRepository.ReadGroup().Select(x => new string[]
{ x.StudentsCount.ToString(),x.GroupNumber.ToString(), x.Course.ToString(), x.CurriculumId.ToString()}),
];
}
}

View File

@ -0,0 +1,311 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;
namespace ProjectShedule.Reports;
internal 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 count)
{
CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithoutBorder);
for (int i = startIndex + 1; i < startIndex + count; ++i)
{
CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder);
}
_mergeCells.Append(new MergeCell()
{
Reference = new StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 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;
}
}

View File

@ -0,0 +1,76 @@
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Shapes.Charts;
using MigraDoc.Rendering;
using System.Text;
namespace ProjectShedule.Reports;
public class PdfBuilder
{
private readonly string _filePath;
private readonly Document _document;
public PdfBuilder(string filePath)
{
if (string.IsNullOrWhiteSpace(filePath))
{
throw new ArgumentNullException(nameof(filePath));
}
if (File.Exists(filePath))
{
File.Delete(filePath);
}
_filePath = filePath;
_document = new Document();
DefineStyles();
}
public PdfBuilder AddHeader(string header)
{
_document.AddSection().AddParagraph(header, "NormalBold");
return this;
}
public PdfBuilder AddPieChart(string title, List<(string Caption, double Value)> data)
{
if (data == null || data.Count == 0)
{
return this;
}
var chart = new Chart(ChartType.Pie2D);
var series = chart.SeriesCollection.AddSeries();
series.Add(data.Select(x => x.Value).ToArray());
var xseries = chart.XValues.AddXSeries();
xseries.Add(data.Select(x => x.Caption).ToArray());
chart.DataLabel.Type = DataLabelType.Percent;
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
chart.Width = Unit.FromCentimeter(16);
chart.Height = Unit.FromCentimeter(12);
chart.TopArea.AddParagraph(title);
chart.XAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.HasMajorGridlines = true;
chart.PlotArea.LineFormat.Width = 1;
chart.PlotArea.LineFormat.Visible = true;
chart.TopArea.AddLegend();
_document.LastSection.Add(chart);
return this;
}
public void Build()
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var renderer = new PdfDocumentRenderer(true)
{
Document = _document
};
renderer.RenderDocument();
renderer.PdfDocument.Save(_filePath);
}
private void DefineStyles()
{
var headerStyle = _document.Styles.AddStyle("NormalBold", "Normal");
headerStyle.Font.Bold = true;
headerStyle.Font.Size = 14;
}
}

View File

@ -0,0 +1,71 @@
using Microsoft.Extensions.Logging;
using ProjectShedule.Repositories;
namespace ProjectShedule.Reports;
internal class TableReport
{
private readonly ICurriculumSubjectRepository _curriculumSubjectRepository;
private readonly ISheduleRepository _sheduleRepository;
private readonly ILogger<TableReport> _logger;
internal static readonly string[] item = ["Дата", "Количество установленных занятий", "Количество поставленных занятий"];
public TableReport(ICurriculumSubjectRepository curriculumSubjectRepository, ISheduleRepository sheduleRepository, ILogger<TableReport> logger)
{
_curriculumSubjectRepository = curriculumSubjectRepository ?? throw new ArgumentNullException(nameof(curriculumSubjectRepository));
_sheduleRepository = sheduleRepository ?? throw new ArgumentNullException(nameof(sheduleRepository));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public bool CreateTable(string filePath, int subjectId, DateTime startDate, DateTime endDate)
{
try
{
new ExcelBuilder(filePath)
.AddHeader("Сводка по прохождению учебного плана", 0, 3)
.AddParagraph("за период", 0)
.AddTable([10, 15, 15], GetData(subjectId, startDate, endDate))
.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при формировании документа");
return false;
}
}
private List<string[]> GetData(int subjectId, DateTime startDate, DateTime endDate)
{
var data = _curriculumSubjectRepository
.ReadCurriculumSubject()
.Where(x => x.Date >= startDate && x.Date <= endDate && x.SubjectSubject.Any(y => y.SubjectId == subjectId))
.Select(x => new {Date = x.Date, CountIn = x.SubjectSubject.FirstOrDefault(y => y.SubjectId == subjectId)?.LessonsCount, CountOut = (int?)null})
.Union(
_sheduleRepository
.ReadShedule()
.Where(x => x.Date >= startDate && x.Date <= endDate && x.SubjectId == subjectId)
.Select(x => new { Date = x.Date, CountIn = (int?)null, CountOut = x?.PairCount})
)
.OrderBy(x => x.Date);
var groupedData = data
.GroupBy(x => x.Date)
.Select(g => new
{
Date = g.Key,
TotalIn = g.Sum(x => x.CountIn),
TotalOut = g.Sum(x => x.CountOut)
})
.OrderBy(x => x.Date);
return
new List<string[]>() { item }
.Union( groupedData
.Select(x => new string[] { x.Date.ToString("dd.MM.yyyy"), x.TotalIn.ToString()!, x.TotalOut.ToString()! }))
.Union(
new[] { new string[] { "Всего", groupedData.Sum(x => x.TotalIn).ToString()!, groupedData.Sum(x => x.TotalOut).ToString()! } }
)
.ToList();
}
}

View File

@ -0,0 +1,125 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml;
namespace ProjectShedule.Reports;
internal 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());
var runProperties = run.AppendChild(new RunProperties());
runProperties.AppendChild(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;
}
}

View File

@ -0,0 +1,12 @@
using ProjectShedule.Entities;
namespace ProjectShedule.Repositories;
public interface IClassroomRepository
{
IEnumerable<Classroom> ReadClassroom();
Classroom ReadClassroomById(int id);
void CreateClassroom(Classroom classroom);
void UpdateClassroom(Classroom classroom);
void DeleteClassroom(int id);
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectShedule.Repositories;
public interface IConnectionString
{
public string ConnectionString { get;}
}

View File

@ -0,0 +1,12 @@
using ProjectShedule.Entities;
namespace ProjectShedule.Repositories;
public interface ICurriculumRepository
{
IEnumerable<Curriculum> ReadCurriculum();
Curriculum ReadCurriculumById(int id);
void CreateCurriculum(Curriculum curriculum);
void UpdateCurriculum(Curriculum curriculum);
void DeleteCurriculum(int id);
}

View File

@ -0,0 +1,10 @@
using ProjectShedule.Entities;
namespace ProjectShedule.Repositories;
public interface ICurriculumSubjectRepository
{
IEnumerable<CurriculumSubject> ReadCurriculumSubject(DateTime? dateForm = null, DateTime? dateTo = null, int? subjectId = null);
void DeleteCurriculumSubject(int id);
void CreateCurriculumSubject(CurriculumSubject curriculumSubject);
}

View File

@ -0,0 +1,12 @@
using ProjectShedule.Entities;
namespace ProjectShedule.Repositories;
public interface IGroupRepository
{
IEnumerable<StudentsGroup> ReadGroup();
StudentsGroup ReadGroupById(int id);
void CreateGroup(StudentsGroup group);
void UpdateGroup(StudentsGroup group);
void DeleteGroup(int id);
}

View File

@ -0,0 +1,10 @@
using ProjectShedule.Entities;
namespace ProjectShedule.Repositories;
public interface ISheduleRepository
{
IEnumerable<Shedule> ReadShedule(DateTime? dateForm = null, DateTime? dateTo = null, int? subjectId = null);
void CreateShedule(Shedule shedule);
void DeleteShedule(int id);
}

View File

@ -0,0 +1,12 @@
using ProjectShedule.Entities;
namespace ProjectShedule.Repositories;
public interface ISubjectRepository
{
IEnumerable<Subject> ReadSubject();
Subject ReadSubjectById(int id);
void CreateSubject(Subject subject);
void UpdateSubject(Subject subject);
void DeleteSubject(int id);
}

View File

@ -0,0 +1,12 @@
using ProjectShedule.Entities;
namespace ProjectShedule.Repositories;
public interface ITeacherRepository
{
IEnumerable<Teacher> ReadTeacher();
Teacher ReadTeacherById(int id);
void CreateTeacher(Teacher teacher);
void UpdateTeacher(Teacher teacher);
void DeleteTeacher(int id);
}

View File

@ -0,0 +1,124 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectShedule.Entities;
namespace ProjectShedule.Repositories.Implementations;
public class ClassroomRepository : IClassroomRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<ClassroomRepository> _logger;
public ClassroomRepository(IConnectionString connectionString, ILogger<ClassroomRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateClassroom(Classroom classroom)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(classroom));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Classroom (Size, Name, ClassType)
VALUES (@Size, @Name, @ClassType)";
connection.Execute(queryInsert, classroom);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteClassroom(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Classroom
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<Classroom> ReadClassroom()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Classroom";
var classroms = connection.Query<Classroom>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(classroms));
return classroms;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
public Classroom ReadClassroomById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Classroom
WHERE Id= @id";
var classroom = connection.QueryFirst<Classroom>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}",
JsonConvert.SerializeObject(classroom));
return classroom;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public void UpdateClassroom(Classroom classroom)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(classroom));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Classroom
SET
Size= @Size,
Name= @Name,
ClassType = @ClassType
WHERE Id= @Id";
connection.Execute(queryUpdate, classroom);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
}

View File

@ -0,0 +1,6 @@
namespace ProjectShedule.Repositories.Implementations;
public class ConnectionString : IConnectionString
{
string IConnectionString.ConnectionString => "Host=localhost;Port=5432;Username=postgres;Password=Xaliullov05;Database=otp;Include Error Detail=true";
}

View File

@ -0,0 +1,119 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectShedule.Entities;
namespace ProjectShedule.Repositories.Implementations;
public class CurriculumRepository : ICurriculumRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<CurriculumRepository> _logger;
public CurriculumRepository(IConnectionString connectionString, ILogger<CurriculumRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateCurriculum(Curriculum curriculum)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(curriculum));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Curriculum (Direction)
VALUES (@Direction)";
connection.Execute(queryInsert, curriculum);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteCurriculum(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Curriculum
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<Curriculum> ReadCurriculum()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Curriculum";
var curriculums = connection.Query<Curriculum>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(curriculums));
return curriculums;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
public Curriculum ReadCurriculumById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Curriculum
WHERE Id= @id";
var curriculum = connection.QueryFirst<Curriculum>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}",
JsonConvert.SerializeObject(curriculum));
return curriculum;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public void UpdateCurriculum(Curriculum curriculum)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(curriculum));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Curriculum
SET
Direction= @Direction
WHERE Id= @Id";
connection.Execute(queryUpdate, curriculum);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
}

View File

@ -0,0 +1,104 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectShedule.Entities;
namespace ProjectShedule.Repositories.Implementations;
public class CurriculumSubjectRepository : ICurriculumSubjectRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<CurriculumSubjectRepository> _logger;
public CurriculumSubjectRepository(IConnectionString connectionString, ILogger<CurriculumSubjectRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateCurriculumSubject(CurriculumSubject curriculumSubject)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(curriculumSubject));
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
var queryInsert =
@"
INSERT INTO CurriculumSubject (Date, CurriculumId, Course)
VALUES (@Date, @CurriculumId, @Course);
SELECT MAX(Id) FROM CurriculumSubject";
var curriculumSubjectId =
connection.QueryFirst<int>(queryInsert, curriculumSubject, transaction);
var querySubInsert = @"
INSERT INTO SubjectSubject (CurriculumSubjectId, SubjectId, LessonsCount)
VALUES (@CurriculumSubjectId, @SubjectId, @LessonsCount)";
foreach (var elem in curriculumSubject.SubjectSubject)
{
connection.Execute(querySubInsert, new
{
curriculumSubjectId,
elem.SubjectId,
elem.LessonsCount
}, transaction);
}
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteCurriculumSubject(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
var queryDeleteSub = @"
DELETE FROM SubjectSubject
WHERE CurriculumSubjectId = @id";
connection.Execute(queryDeleteSub, new { id }, transaction);
var queryDelete = @"
DELETE FROM CurriculumSubject
WHERE Id = @id";
connection.Execute(queryDelete, new { id }, transaction);
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<CurriculumSubject> ReadCurriculumSubject(DateTime? dateForm = null, DateTime? dateTo = null, int? subjectId = null)
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"SELECT cs.*, ss.SubjectId, ss.LessonsCount FROM CurriculumSubject cs
INNER JOIN SubjectSubject ss on ss.CurriculumSubjectId = cs.Id";
var curriculumSubjects = connection.Query<TempCurriculumSubject>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(curriculumSubjects));
return curriculumSubjects.GroupBy(x => x.Id, y => y, (key, value) => CurriculumSubject.CreateCurriculumSubject(value.First(),
value.Select(z => SubjectSubject.CreateOperation(0, z.SubjectId, z.LessonsCount)))).ToList();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,123 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectShedule.Entities;
namespace ProjectShedule.Repositories.Implementations;
public class GroupRepository : IGroupRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<GroupRepository> _logger;
public GroupRepository(IConnectionString connectionString, ILogger<GroupRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateGroup(StudentsGroup group)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(group));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO StudentsGroup (StudentsCount, GroupNumber, Course, CurriculumId)
VALUES (@StudentsCount, @GroupNumber, @Course, @CurriculumId)";
connection.Execute(queryInsert, group);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteGroup(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM StudentsGroup
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<StudentsGroup> ReadGroup()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM StudentsGroup";
var groups = connection.Query<StudentsGroup>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(groups));
return groups;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
public StudentsGroup ReadGroupById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM StudentsGroup
WHERE Id= @id";
var group = connection.QueryFirst<StudentsGroup>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}",
JsonConvert.SerializeObject(group));
return group;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public void UpdateGroup(StudentsGroup group)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(group));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE StudentsGroup
SET
StudentsCount= @StudentsCount,
GroupNumber= @GroupNumber,
Course= @Course,
CurriculumId= @CurriculumId
WHERE Id= @Id";
connection.Execute(queryUpdate, group);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
}

View File

@ -0,0 +1,75 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectShedule.Entities;
namespace ProjectShedule.Repositories.Implementations;
public class SheduleRepository : ISheduleRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<SheduleRepository> _logger;
public SheduleRepository(IConnectionString connectionString, ILogger<SheduleRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateShedule(Shedule shedule)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(shedule));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Shedule (Date, PairNumber, PairCount, StudentsGroupId, TeacherId, SubjectId, ClassroomId)
VALUES (@Date, @PairNumber, @PairCount, @StudentsGroupId, @TeacherId, @SubjectId, @ClassroomId)";
connection.Execute(queryInsert, shedule);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteShedule(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Shedule
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<Shedule> ReadShedule(DateTime? dateForm = null, DateTime? dateTo = null, int? subjectId = null)
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Shedule";
var shedule = connection.Query<Shedule>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(shedule));
return shedule;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,119 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectShedule.Entities;
namespace ProjectShedule.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 CreateSubject(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 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;
}
}
public Subject ReadSubjectById(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;
}
}
}

View File

@ -0,0 +1,120 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectShedule.Entities;
namespace ProjectShedule.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 (FirstName, LastName)
VALUES (@FirstName, @LastName)";
connection.Execute(queryInsert, 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 IEnumerable<Teacher> ReadTeacher()
{
_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;
}
}
public Teacher ReadTeacherById(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 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
FirstName = @FirstName,
LastName = @FirstName,
WHERE Id= @Id";
connection.Execute(queryUpdate, teacher);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,15 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "Logs/log.txt",
"rollingInterval": "Day"
}
}
]
}
}