diff --git a/ProjectShedule/ProjectShedule/Entities/Classroom.cs b/ProjectShedule/ProjectShedule/Entities/Classroom.cs new file mode 100644 index 0000000..fb4730f --- /dev/null +++ b/ProjectShedule/ProjectShedule/Entities/Classroom.cs @@ -0,0 +1,28 @@ +using ProjectShedule.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +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 + }; + } +} diff --git a/ProjectShedule/ProjectShedule/Entities/Curriculum.cs b/ProjectShedule/ProjectShedule/Entities/Curriculum.cs new file mode 100644 index 0000000..7e7ec20 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Entities/Curriculum.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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, + }; + } +} diff --git a/ProjectShedule/ProjectShedule/Entities/CurriculumSubject.cs b/ProjectShedule/ProjectShedule/Entities/CurriculumSubject.cs new file mode 100644 index 0000000..b021065 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Entities/CurriculumSubject.cs @@ -0,0 +1,26 @@ +using ProjectShedule.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectShedule.Entities; + +public class CurriculumSubject +{ + public int CurriculumId { get; private set; } + public IEnumerable SubjectSubject { get; private set; } = []; + public Course Course { get; private set; } + + public static CurriculumSubject CreateCurriculumSubject(int curriculumId, Course course, IEnumerable subjectSubjects) + { + return new CurriculumSubject() + { + CurriculumId = curriculumId, + Course = course, + SubjectSubject = subjectSubjects + }; + } + +} diff --git a/ProjectShedule/ProjectShedule/Entities/Enums/ClassType.cs b/ProjectShedule/ProjectShedule/Entities/Enums/ClassType.cs new file mode 100644 index 0000000..6300a8f --- /dev/null +++ b/ProjectShedule/ProjectShedule/Entities/Enums/ClassType.cs @@ -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 +} diff --git a/ProjectShedule/ProjectShedule/Entities/Enums/Course.cs b/ProjectShedule/ProjectShedule/Entities/Enums/Course.cs new file mode 100644 index 0000000..4ee2861 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Entities/Enums/Course.cs @@ -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, +} diff --git a/ProjectShedule/ProjectShedule/Entities/Enums/PairNumber.cs b/ProjectShedule/ProjectShedule/Entities/Enums/PairNumber.cs new file mode 100644 index 0000000..4378958 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Entities/Enums/PairNumber.cs @@ -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 +} diff --git a/ProjectShedule/ProjectShedule/Entities/Group.cs b/ProjectShedule/ProjectShedule/Entities/Group.cs new file mode 100644 index 0000000..93b3ea0 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Entities/Group.cs @@ -0,0 +1,30 @@ +using ProjectShedule.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectShedule.Entities; + +public class Group +{ + 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 Group CreateGroup(int id, int studentsCount, string groupNumber, Course course, int curriculumId) + { + return new Group + { + Id = id, + StudentsCount = studentsCount, + GroupNumber = groupNumber, + Course = course, + CurriculumId = curriculumId + }; + } + + +} diff --git a/ProjectShedule/ProjectShedule/Entities/Shedule.cs b/ProjectShedule/ProjectShedule/Entities/Shedule.cs new file mode 100644 index 0000000..428e327 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Entities/Shedule.cs @@ -0,0 +1,35 @@ +using ProjectShedule.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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 GroupId { 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 groupId, int teacherId, int subjectId, int classroomId) + { + return new Shedule + { + Id = id, + Date = date, + PairNumber = pairNumber, + GroupId = groupId, + TeacherId = teacherId, + SubjectId = subjectId, + ClassroomId = classroomId + }; + } + +} diff --git a/ProjectShedule/ProjectShedule/Entities/Subject.cs b/ProjectShedule/ProjectShedule/Entities/Subject.cs new file mode 100644 index 0000000..ea6805a --- /dev/null +++ b/ProjectShedule/ProjectShedule/Entities/Subject.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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 + }; + } +} diff --git a/ProjectShedule/ProjectShedule/Entities/SubjectSubject.cs b/ProjectShedule/ProjectShedule/Entities/SubjectSubject.cs new file mode 100644 index 0000000..a3bb02d --- /dev/null +++ b/ProjectShedule/ProjectShedule/Entities/SubjectSubject.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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 + }; + } +} diff --git a/ProjectShedule/ProjectShedule/Entities/Teacher.cs b/ProjectShedule/ProjectShedule/Entities/Teacher.cs new file mode 100644 index 0000000..630bc54 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Entities/Teacher.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +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 + }; + } +} diff --git a/ProjectShedule/ProjectShedule/Form1.Designer.cs b/ProjectShedule/ProjectShedule/Form1.Designer.cs deleted file mode 100644 index b7789ca..0000000 --- a/ProjectShedule/ProjectShedule/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ProjectShedule -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - 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 - } -} diff --git a/ProjectShedule/ProjectShedule/Form1.cs b/ProjectShedule/ProjectShedule/Form1.cs deleted file mode 100644 index 962e363..0000000 --- a/ProjectShedule/ProjectShedule/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ProjectShedule -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/ProjectShedule/ProjectShedule/FormSchedulingBureau.Designer.cs b/ProjectShedule/ProjectShedule/FormSchedulingBureau.Designer.cs new file mode 100644 index 0000000..16658ef --- /dev/null +++ b/ProjectShedule/ProjectShedule/FormSchedulingBureau.Designer.cs @@ -0,0 +1,156 @@ +namespace ProjectShedule +{ + partial class FormSchedulingBureau + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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(); + 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(224, 26); + classroomToolStripMenuItem.Text = "Аудитории"; + classroomToolStripMenuItem.Click += classroomToolStripMenuItem_Click; + // + // teacherToolStripMenuItem + // + teacherToolStripMenuItem.Name = "teacherToolStripMenuItem"; + teacherToolStripMenuItem.Size = new Size(224, 26); + teacherToolStripMenuItem.Text = "Преподаватели"; + teacherToolStripMenuItem.Click += teacherToolStripMenuItem_Click; + // + // subjectsToolStripMenuItem + // + subjectsToolStripMenuItem.Name = "subjectsToolStripMenuItem"; + subjectsToolStripMenuItem.Size = new Size(224, 26); + subjectsToolStripMenuItem.Text = "Дисциплины"; + subjectsToolStripMenuItem.Click += subjectsToolStripMenuItem_Click; + // + // curriculumsToolStripMenuItem + // + curriculumsToolStripMenuItem.Name = "curriculumsToolStripMenuItem"; + curriculumsToolStripMenuItem.Size = new Size(224, 26); + curriculumsToolStripMenuItem.Text = "Учебные планы"; + curriculumsToolStripMenuItem.Click += curriculumsToolStripMenuItem_Click; + // + // studentGroupsToolStripMenuItem + // + studentGroupsToolStripMenuItem.Name = "studentGroupsToolStripMenuItem"; + studentGroupsToolStripMenuItem.Size = new Size(224, 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.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(73, 24); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // 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; + } +} diff --git a/ProjectShedule/ProjectShedule/FormSchedulingBureau.cs b/ProjectShedule/ProjectShedule/FormSchedulingBureau.cs new file mode 100644 index 0000000..1ea15a6 --- /dev/null +++ b/ProjectShedule/ProjectShedule/FormSchedulingBureau.cs @@ -0,0 +1,108 @@ +using ProjectShedule.Forms; +using System.ComponentModel; +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().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void teacherToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void subjectsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void curriculumsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void studentGroupsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void createSheduleToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void createCurriculumToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/ProjectShedule/ProjectShedule/FormSchedulingBureau.resx b/ProjectShedule/ProjectShedule/FormSchedulingBureau.resx new file mode 100644 index 0000000..6c82d08 --- /dev/null +++ b/ProjectShedule/ProjectShedule/FormSchedulingBureau.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormClassroom.Designer.cs b/ProjectShedule/ProjectShedule/Forms/FormClassroom.Designer.cs new file mode 100644 index 0000000..78c6ef7 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormClassroom.Designer.cs @@ -0,0 +1,146 @@ +namespace ProjectShedule.Forms +{ + partial class FormClassroom + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + 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, 149); + 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(219, 141); + 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; + } +} \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormClassroom.cs b/ProjectShedule/ProjectShedule/Forms/FormClassroom.cs new file mode 100644 index 0000000..b2461f2 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormClassroom.cs @@ -0,0 +1,83 @@ +using ProjectShedule.Entities; +using ProjectShedule.Entities.Enums; +using ProjectShedule.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +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.UpdateClassroom(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!); + } +} diff --git a/ProjectShedule/ProjectShedule/Form1.resx b/ProjectShedule/ProjectShedule/Forms/FormClassroom.resx similarity index 93% rename from ProjectShedule/ProjectShedule/Form1.resx rename to ProjectShedule/ProjectShedule/Forms/FormClassroom.resx index 1af7de1..af32865 100644 --- a/ProjectShedule/ProjectShedule/Form1.resx +++ b/ProjectShedule/ProjectShedule/Forms/FormClassroom.resx @@ -1,17 +1,17 @@  - diff --git a/ProjectShedule/ProjectShedule/Forms/FormClassrooms.Designer.cs b/ProjectShedule/ProjectShedule/Forms/FormClassrooms.Designer.cs new file mode 100644 index 0000000..945497d --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormClassrooms.Designer.cs @@ -0,0 +1,128 @@ +namespace ProjectShedule.Forms +{ + partial class FormClassrooms + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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; + } +} \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormClassrooms.cs b/ProjectShedule/ProjectShedule/Forms/FormClassrooms.cs new file mode 100644 index 0000000..9d0c8b6 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormClassrooms.cs @@ -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().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(); + 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; + } + } + } +} diff --git a/ProjectShedule/ProjectShedule/Forms/FormClassrooms.resx b/ProjectShedule/ProjectShedule/Forms/FormClassrooms.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormClassrooms.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormCurriculum.Designer.cs b/ProjectShedule/ProjectShedule/Forms/FormCurriculum.Designer.cs new file mode 100644 index 0000000..7ac90a5 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormCurriculum.Designer.cs @@ -0,0 +1,95 @@ +namespace ProjectShedule.Forms +{ + partial class FormCurriculum + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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; + } +} \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormCurriculum.cs b/ProjectShedule/ProjectShedule/Forms/FormCurriculum.cs new file mode 100644 index 0000000..a0c89c4 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormCurriculum.cs @@ -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.UpdateCurriculum(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); + } +} \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormCurriculum.resx b/ProjectShedule/ProjectShedule/Forms/FormCurriculum.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormCurriculum.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubject.Designer.cs b/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubject.Designer.cs new file mode 100644 index 0000000..ef6be25 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubject.Designer.cs @@ -0,0 +1,211 @@ +namespace ProjectShedule.Forms +{ + partial class FormCurriculumSubject + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + buttonCancel = new Button(); + buttonSave = new Button(); + label4 = new Label(); + label1 = new Label(); + comboBoxDirection = new ComboBox(); + comboBoxCourse = new ComboBox(); + groupBoxCurriculum = new GroupBox(); + dataGridViewCur = new DataGridView(); + Column1 = new DataGridViewComboBoxColumn(); + Column2 = new DataGridViewTextBoxColumn(); + dataGridView = new DataGridView(); + ColumnSubject = new DataGridViewComboBoxColumn(); + ColumnLessons = new DataGridViewTextBoxColumn(); + groupBoxCurriculum.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewCur).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dataGridView).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, 96); + label4.Name = "label4"; + label4.Size = new Size(44, 20); + label4.TabIndex = 16; + label4.Text = "Курс:"; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(52, 44); + 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, 36); + 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, 93); + 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 = "Учбеный план"; + // + // 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; + // + // 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"; + // + // FormCurriculumSubject + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(384, 522); + 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)dataGridViewCur).EndInit(); + ((System.ComponentModel.ISupportInitialize)dataGridView).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; + } +} \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubject.cs b/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubject.cs new file mode 100644 index 0000000..87ce6c8 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubject.cs @@ -0,0 +1,72 @@ +using ProjectShedule.Entities; +using ProjectShedule.Entities.Enums; +using ProjectShedule.Repositories; + + +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 < 0 || dataGridView.RowCount < 1) + { + throw new Exception("Есть незаполненные поля"); + } + _curriculumSubjectRepository.CreateCurriculumSubject(CurriculumSubject.CreateCurriculumSubject( + (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 CreateListSubjectSubjectFromDataGrid() + { + var list = new List(); + 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; + } + } +} diff --git a/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubject.resx b/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubject.resx new file mode 100644 index 0000000..35196f1 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubject.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubjects.Designer.cs b/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubjects.Designer.cs new file mode 100644 index 0000000..ddde3d4 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubjects.Designer.cs @@ -0,0 +1,98 @@ +namespace ProjectShedule.Forms +{ + partial class FormCurriculumSubjects + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(622, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(178, 352); + panel1.TabIndex = 2; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Ambox_plus_svg; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(42, 125); + 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, 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 = "FormCurriculumSubjects"; + Load += FormCurriculumSubjects_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubjects.cs b/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubjects.cs new file mode 100644 index 0000000..89f82bb --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubjects.cs @@ -0,0 +1,45 @@ +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().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridView.DataSource = _curriculumSubjectRepository.ReadCurriculumSubject(); + } +} diff --git a/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubjects.resx b/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubjects.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormCurriculumSubjects.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormCurriculums.Designer.cs b/ProjectShedule/ProjectShedule/Forms/FormCurriculums.Designer.cs new file mode 100644 index 0000000..2404735 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormCurriculums.Designer.cs @@ -0,0 +1,126 @@ +namespace ProjectShedule.Forms +{ + partial class FormCurriculums + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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; + // + // 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; + } +} \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormCurriculums.cs b/ProjectShedule/ProjectShedule/Forms/FormCurriculums.cs new file mode 100644 index 0000000..6f8b64e --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormCurriculums.cs @@ -0,0 +1,109 @@ +using ProjectShedule.Repositories; +using ProjectShedule.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace 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().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(); + 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; + } + } + } +} diff --git a/ProjectShedule/ProjectShedule/Forms/FormCurriculums.resx b/ProjectShedule/ProjectShedule/Forms/FormCurriculums.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormCurriculums.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormGroup.Designer.cs b/ProjectShedule/ProjectShedule/Forms/FormGroup.Designer.cs new file mode 100644 index 0000000..4687306 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormGroup.Designer.cs @@ -0,0 +1,167 @@ +namespace ProjectShedule.Forms +{ + partial class FormGroup + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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; + } +} \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormGroup.cs b/ProjectShedule/ProjectShedule/Forms/FormGroup.cs new file mode 100644 index 0000000..04e6b25 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormGroup.cs @@ -0,0 +1,90 @@ +using ProjectShedule.Entities; +using ProjectShedule.Entities.Enums; +using ProjectShedule.Repositories; +using ProjectShedule.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace 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 < 1) + { + 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 Group CreateGroup(int id) => Group.CreateGroup( + id, + Convert.ToInt32(numericUpDownStudentsCount.Value), + textBoxGroupName.Text, + (Course)comboBoxCourse.SelectedItem!, + (int)comboBoxCourse.SelectedValue!); + } +} diff --git a/ProjectShedule/ProjectShedule/Forms/FormGroup.resx b/ProjectShedule/ProjectShedule/Forms/FormGroup.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormGroup.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormGroups.Designer.cs b/ProjectShedule/ProjectShedule/Forms/FormGroups.Designer.cs new file mode 100644 index 0000000..3aeb5f2 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormGroups.Designer.cs @@ -0,0 +1,126 @@ +namespace ProjectShedule.Forms +{ + partial class FormGroups + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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.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, 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; + } +} \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormGroups.cs b/ProjectShedule/ProjectShedule/Forms/FormGroups.cs new file mode 100644 index 0000000..b048ce5 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormGroups.cs @@ -0,0 +1,111 @@ +using ProjectShedule.Repositories; +using ProjectShedule.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace 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().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(); + 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; + } + } + + } +} diff --git a/ProjectShedule/ProjectShedule/Forms/FormGroups.resx b/ProjectShedule/ProjectShedule/Forms/FormGroups.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormGroups.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormShedule.Designer.cs b/ProjectShedule/ProjectShedule/Forms/FormShedule.Designer.cs new file mode 100644 index 0000000..2a3a366 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormShedule.Designer.cs @@ -0,0 +1,210 @@ +namespace ProjectShedule.Forms +{ + partial class FormShedule + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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; + } +} \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormShedule.cs b/ProjectShedule/ProjectShedule/Forms/FormShedule.cs new file mode 100644 index 0000000..57b35a3 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormShedule.cs @@ -0,0 +1,72 @@ +using ProjectShedule.Entities; +using ProjectShedule.Entities.Enums; +using ProjectShedule.Repositories; +using System.Diagnostics.Contracts; +using System.Windows.Forms; + +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; + foreach (var elem in checkedListBox.CheckedItems) + { + pairNumber |= (PairNumber)elem; + } + _sheduleRepository.CreateShedule(Shedule.CreateOperation(0, + dateTimePicker.Value, + pairNumber, + (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(); + } +} diff --git a/ProjectShedule/ProjectShedule/Forms/FormShedule.resx b/ProjectShedule/ProjectShedule/Forms/FormShedule.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormShedule.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormShedules.Designer.cs b/ProjectShedule/ProjectShedule/Forms/FormShedules.Designer.cs new file mode 100644 index 0000000..b0d43be --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormShedules.Designer.cs @@ -0,0 +1,98 @@ +namespace ProjectShedule.Forms +{ + partial class FormShedules + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridView = new DataGridView(); + buttonAdd = new Button(); + panel1 = new Panel(); + ((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(48, 112); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(94, 93); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // panel1 + // + 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; + // + // 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; + } +} \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormShedules.cs b/ProjectShedule/ProjectShedule/Forms/FormShedules.cs new file mode 100644 index 0000000..9444ef1 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormShedules.cs @@ -0,0 +1,49 @@ + +using ProjectShedule.Repositories; +using ProjectShedule.Repositories.Implementations; +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().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(); + } +} diff --git a/ProjectShedule/ProjectShedule/Forms/FormShedules.resx b/ProjectShedule/ProjectShedule/Forms/FormShedules.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormShedules.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormSubject.Designer.cs b/ProjectShedule/ProjectShedule/Forms/FormSubject.Designer.cs new file mode 100644 index 0000000..db82d08 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormSubject.Designer.cs @@ -0,0 +1,95 @@ +namespace ProjectShedule.Forms +{ + partial class FormSubject + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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; + } +} \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormSubject.cs b/ProjectShedule/ProjectShedule/Forms/FormSubject.cs new file mode 100644 index 0000000..f07f7d5 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormSubject.cs @@ -0,0 +1,77 @@ +using ProjectShedule.Entities.Enums; +using ProjectShedule.Entities; +using ProjectShedule.Repositories; +using ProjectShedule.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace 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.UpdateSubject(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); +} diff --git a/ProjectShedule/ProjectShedule/Forms/FormSubject.resx b/ProjectShedule/ProjectShedule/Forms/FormSubject.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormSubject.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormSubjects.Designer.cs b/ProjectShedule/ProjectShedule/Forms/FormSubjects.Designer.cs new file mode 100644 index 0000000..ab0ff91 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormSubjects.Designer.cs @@ -0,0 +1,127 @@ +namespace ProjectShedule.Forms +{ + partial class FormSubjects + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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.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, 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; + } +} \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormSubjects.cs b/ProjectShedule/ProjectShedule/Forms/FormSubjects.cs new file mode 100644 index 0000000..391075a --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormSubjects.cs @@ -0,0 +1,109 @@ +using ProjectShedule.Repositories; +using ProjectShedule.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace 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().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(); + 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; + } + } + } +} + diff --git a/ProjectShedule/ProjectShedule/Forms/FormSubjects.resx b/ProjectShedule/ProjectShedule/Forms/FormSubjects.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormSubjects.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormTeacher.Designer.cs b/ProjectShedule/ProjectShedule/Forms/FormTeacher.Designer.cs new file mode 100644 index 0000000..558bc5a --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormTeacher.Designer.cs @@ -0,0 +1,120 @@ +namespace ProjectShedule.Forms +{ + partial class FormTeacher + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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; + } +} \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormTeacher.cs b/ProjectShedule/ProjectShedule/Forms/FormTeacher.cs new file mode 100644 index 0000000..646a3de --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormTeacher.cs @@ -0,0 +1,82 @@ +using ProjectShedule.Entities; +using ProjectShedule.Repositories; +using ProjectShedule.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace 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.UpdateTeacher(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); + + + } +} diff --git a/ProjectShedule/ProjectShedule/Forms/FormTeacher.resx b/ProjectShedule/ProjectShedule/Forms/FormTeacher.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormTeacher.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormTeachers.Designer.cs b/ProjectShedule/ProjectShedule/Forms/FormTeachers.Designer.cs new file mode 100644 index 0000000..a5cf6ef --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormTeachers.Designer.cs @@ -0,0 +1,126 @@ +namespace ProjectShedule.Forms +{ + partial class FormTeachers + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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; + } +} \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Forms/FormTeachers.cs b/ProjectShedule/ProjectShedule/Forms/FormTeachers.cs new file mode 100644 index 0000000..61fac0d --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormTeachers.cs @@ -0,0 +1,109 @@ +using ProjectShedule.Repositories; +using ProjectShedule.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace 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().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(); + 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; + } + } + + } +} diff --git a/ProjectShedule/ProjectShedule/Forms/FormTeachers.resx b/ProjectShedule/ProjectShedule/Forms/FormTeachers.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Forms/FormTeachers.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Program.cs b/ProjectShedule/ProjectShedule/Program.cs index aa9eae2..820317e 100644 --- a/ProjectShedule/ProjectShedule/Program.cs +++ b/ProjectShedule/ProjectShedule/Program.cs @@ -1,3 +1,7 @@ +using ProjectShedule.Repositories; +using ProjectShedule.Repositories.Implementations; +using Unity; + namespace ProjectShedule { internal static class Program @@ -11,7 +15,21 @@ 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()); + } + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + + return container; } } } \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/ProjectShedule.csproj b/ProjectShedule/ProjectShedule/ProjectShedule.csproj index 663fdb8..accbdf0 100644 --- a/ProjectShedule/ProjectShedule/ProjectShedule.csproj +++ b/ProjectShedule/ProjectShedule/ProjectShedule.csproj @@ -8,4 +8,23 @@ enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Properties/Resources.Designer.cs b/ProjectShedule/ProjectShedule/Properties/Resources.Designer.cs new file mode 100644 index 0000000..df37251 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectShedule.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом 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() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [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; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap _3712684 { + get { + object obj = ResourceManager.GetObject("3712684", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Ambox_plus_svg { + get { + object obj = ResourceManager.GetObject("Ambox_plus.svg", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap back { + get { + object obj = ResourceManager.GetObject("back", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap minus_PNG39 { + get { + object obj = ResourceManager.GetObject("minus_PNG39", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ProjectShedule/ProjectShedule/Properties/Resources.resx b/ProjectShedule/ProjectShedule/Properties/Resources.resx new file mode 100644 index 0000000..7f29c79 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\back.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\3712684.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Ambox_plus.svg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\minus_PNG39.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Repositories/IClassroomRepository.cs b/ProjectShedule/ProjectShedule/Repositories/IClassroomRepository.cs new file mode 100644 index 0000000..a459b04 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Repositories/IClassroomRepository.cs @@ -0,0 +1,12 @@ +using ProjectShedule.Entities; + +namespace ProjectShedule.Repositories; + +public interface IClassroomRepository +{ + IEnumerable ReadClassroom(); + Classroom ReadClassroomById(int id); + void CreateClassroom(Classroom classroom); + void UpdateClassroom(Classroom classroom); + void DeleteClassroom(int id); +} diff --git a/ProjectShedule/ProjectShedule/Repositories/ICurriculumRepository.cs b/ProjectShedule/ProjectShedule/Repositories/ICurriculumRepository.cs new file mode 100644 index 0000000..1acbc44 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Repositories/ICurriculumRepository.cs @@ -0,0 +1,12 @@ +using ProjectShedule.Entities; + +namespace ProjectShedule.Repositories; + +public interface ICurriculumRepository +{ + IEnumerable ReadCurriculum(); + Curriculum ReadCurriculumById(int id); + void CreateCurriculum(Curriculum curriculum); + void UpdateCurriculum(Curriculum curriculum); + void DeleteCurriculum(int id); +} \ No newline at end of file diff --git a/ProjectShedule/ProjectShedule/Repositories/ICurriculumSubjectRepository.cs b/ProjectShedule/ProjectShedule/Repositories/ICurriculumSubjectRepository.cs new file mode 100644 index 0000000..36af6d7 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Repositories/ICurriculumSubjectRepository.cs @@ -0,0 +1,9 @@ +using ProjectShedule.Entities; + +namespace ProjectShedule.Repositories; + +public interface ICurriculumSubjectRepository +{ + IEnumerable ReadCurriculumSubject(); + void CreateCurriculumSubject(CurriculumSubject curriculumSubject); +} diff --git a/ProjectShedule/ProjectShedule/Repositories/IGroupRepository.cs b/ProjectShedule/ProjectShedule/Repositories/IGroupRepository.cs new file mode 100644 index 0000000..1dbb0e5 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Repositories/IGroupRepository.cs @@ -0,0 +1,12 @@ +using ProjectShedule.Entities; + +namespace ProjectShedule.Repositories; + +public interface IGroupRepository +{ + IEnumerable ReadGroup(); + Group ReadGroupById(int id); + void CreateGroup(Group group); + void UpdateGroup(Group group); + void DeleteGroup(int id); +} diff --git a/ProjectShedule/ProjectShedule/Repositories/ISheduleRepository.cs b/ProjectShedule/ProjectShedule/Repositories/ISheduleRepository.cs new file mode 100644 index 0000000..bd2f01b --- /dev/null +++ b/ProjectShedule/ProjectShedule/Repositories/ISheduleRepository.cs @@ -0,0 +1,11 @@ +using ProjectShedule.Entities; + +namespace ProjectShedule.Repositories; + +public interface ISheduleRepository +{ + IEnumerable ReadShedule(DateTime? dateTime = null, int? groupId = null); + void CreateShedule(Shedule shedule); + void UpdateShedule(Shedule shedule); + void DeleteShedule(int id); +} diff --git a/ProjectShedule/ProjectShedule/Repositories/ISubjectRepository.cs b/ProjectShedule/ProjectShedule/Repositories/ISubjectRepository.cs new file mode 100644 index 0000000..c068c67 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Repositories/ISubjectRepository.cs @@ -0,0 +1,12 @@ +using ProjectShedule.Entities; + +namespace ProjectShedule.Repositories; + +public interface ISubjectRepository +{ + IEnumerable ReadSubject(); + Subject ReadSubjectById(int id); + void CreateSubject(Subject subject); + void UpdateSubject(Subject subject); + void DeleteSubject(int id); +} diff --git a/ProjectShedule/ProjectShedule/Repositories/ITeacherRepository.cs b/ProjectShedule/ProjectShedule/Repositories/ITeacherRepository.cs new file mode 100644 index 0000000..6a61495 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Repositories/ITeacherRepository.cs @@ -0,0 +1,12 @@ +using ProjectShedule.Entities; + +namespace ProjectShedule.Repositories; + +public interface ITeacherRepository +{ + IEnumerable ReadTeacher(); + Teacher ReadTeacherById(int id); + void CreateTeacher(Teacher teacher); + void UpdateTeacher(Teacher teacher); + void DeleteTeacher(int id); +} diff --git a/ProjectShedule/ProjectShedule/Repositories/Implementations/ClassroomRepository.cs b/ProjectShedule/ProjectShedule/Repositories/Implementations/ClassroomRepository.cs new file mode 100644 index 0000000..c733ac7 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Repositories/Implementations/ClassroomRepository.cs @@ -0,0 +1,28 @@ +using ProjectShedule.Entities; + +namespace ProjectShedule.Repositories.Implementations; + +public class ClassroomRepository : IClassroomRepository +{ + public void CreateClassroom(Classroom classroom) + { + } + + public void DeleteClassroom(int id) + { + } + + public IEnumerable ReadClassroom() + { + return []; + } + + public Classroom ReadClassroomById(int id) + { + return Classroom.CreateClassroom(0, 0, string.Empty, 0); + } + + public void UpdateClassroom(Classroom classroom) + { + } +} diff --git a/ProjectShedule/ProjectShedule/Repositories/Implementations/CurriculumRepository.cs b/ProjectShedule/ProjectShedule/Repositories/Implementations/CurriculumRepository.cs new file mode 100644 index 0000000..59935bc --- /dev/null +++ b/ProjectShedule/ProjectShedule/Repositories/Implementations/CurriculumRepository.cs @@ -0,0 +1,33 @@ +using ProjectShedule.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectShedule.Repositories.Implementations; + +public class CurriculumRepository : ICurriculumRepository +{ + public void CreateCurriculum(Curriculum curriculum) + { + } + + public void DeleteCurriculum(int id) + { + } + + public IEnumerable ReadCurriculum() + { + return []; + } + + public Curriculum ReadCurriculumById(int id) + { + return Curriculum.CreateCurriculum(0, string.Empty); + } + + public void UpdateCurriculum(Curriculum curriculum) + { + } +} diff --git a/ProjectShedule/ProjectShedule/Repositories/Implementations/CurriculumSubjectRepository.cs b/ProjectShedule/ProjectShedule/Repositories/Implementations/CurriculumSubjectRepository.cs new file mode 100644 index 0000000..67bc64c --- /dev/null +++ b/ProjectShedule/ProjectShedule/Repositories/Implementations/CurriculumSubjectRepository.cs @@ -0,0 +1,20 @@ +using ProjectShedule.Entities; +using ProjectShedule.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectShedule.Repositories.Implementations; + +public class CurriculumSubjectRepository : ICurriculumSubjectRepository +{ + public void CreateCurriculumSubject(CurriculumSubject curriculumSubject) + { + } + public IEnumerable ReadCurriculumSubject() + { + return []; + } +} diff --git a/ProjectShedule/ProjectShedule/Repositories/Implementations/GroupRepository.cs b/ProjectShedule/ProjectShedule/Repositories/Implementations/GroupRepository.cs new file mode 100644 index 0000000..30f3c2e --- /dev/null +++ b/ProjectShedule/ProjectShedule/Repositories/Implementations/GroupRepository.cs @@ -0,0 +1,33 @@ +using ProjectShedule.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectShedule.Repositories.Implementations; + +public class GroupRepository : IGroupRepository +{ + public void CreateGroup(Group group) + { + } + + public void DeleteGroup(int id) + { + } + + public IEnumerable ReadGroup() + { + return []; + } + + public Group ReadGroupById(int id) + { + return Group.CreateGroup(0, 0, string.Empty, 0, 0); + } + + public void UpdateGroup(Group group) + { + } +} diff --git a/ProjectShedule/ProjectShedule/Repositories/Implementations/SheduleRepository.cs b/ProjectShedule/ProjectShedule/Repositories/Implementations/SheduleRepository.cs new file mode 100644 index 0000000..429b15b --- /dev/null +++ b/ProjectShedule/ProjectShedule/Repositories/Implementations/SheduleRepository.cs @@ -0,0 +1,28 @@ +using ProjectShedule.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectShedule.Repositories.Implementations; +public class SheduleRepository : ISheduleRepository +{ + public void CreateShedule(Shedule shedule) + { + } + + public void DeleteShedule(int id) + { + } + + public IEnumerable ReadShedule(DateTime? dateTime = null, int? groupId = null) + { + return []; + } + + public void UpdateShedule(Shedule shedule) + { + } +} + diff --git a/ProjectShedule/ProjectShedule/Repositories/Implementations/SubjectRepository.cs b/ProjectShedule/ProjectShedule/Repositories/Implementations/SubjectRepository.cs new file mode 100644 index 0000000..751a977 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Repositories/Implementations/SubjectRepository.cs @@ -0,0 +1,33 @@ +using ProjectShedule.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectShedule.Repositories.Implementations; + +public class SubjectRepository : ISubjectRepository +{ + public void CreateSubject(Subject subject) + { + } + + public void DeleteSubject(int id) + { + } + + public IEnumerable ReadSubject() + { + return []; + } + + public Subject ReadSubjectById(int id) + { + return Subject.CreateSubject(0,string.Empty); + } + + public void UpdateSubject(Subject subject) + { + } +} diff --git a/ProjectShedule/ProjectShedule/Repositories/Implementations/TeacherRepository.cs b/ProjectShedule/ProjectShedule/Repositories/Implementations/TeacherRepository.cs new file mode 100644 index 0000000..37b3861 --- /dev/null +++ b/ProjectShedule/ProjectShedule/Repositories/Implementations/TeacherRepository.cs @@ -0,0 +1,33 @@ +using ProjectShedule.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectShedule.Repositories.Implementations; + +public class TeacherRepository : ITeacherRepository +{ + public void CreateTeacher(Teacher teacher) + { + } + + public void DeleteTeacher(int id) + { + } + + public IEnumerable ReadTeacher() + { + return []; + } + + public Teacher ReadTeacherById(int id) + { + return Teacher.CreateTeacher(0,string.Empty,string.Empty); + } + + public void UpdateTeacher(Teacher teacher) + { + } +} diff --git a/ProjectShedule/ProjectShedule/Resources/3712684.png b/ProjectShedule/ProjectShedule/Resources/3712684.png new file mode 100644 index 0000000..14175b5 Binary files /dev/null and b/ProjectShedule/ProjectShedule/Resources/3712684.png differ diff --git a/ProjectShedule/ProjectShedule/Resources/Ambox_plus.svg.png b/ProjectShedule/ProjectShedule/Resources/Ambox_plus.svg.png new file mode 100644 index 0000000..41673a1 Binary files /dev/null and b/ProjectShedule/ProjectShedule/Resources/Ambox_plus.svg.png differ diff --git a/ProjectShedule/ProjectShedule/Resources/back.jpg b/ProjectShedule/ProjectShedule/Resources/back.jpg new file mode 100644 index 0000000..fb7d788 Binary files /dev/null and b/ProjectShedule/ProjectShedule/Resources/back.jpg differ diff --git a/ProjectShedule/ProjectShedule/Resources/minus_PNG39.png b/ProjectShedule/ProjectShedule/Resources/minus_PNG39.png new file mode 100644 index 0000000..18ce9c8 Binary files /dev/null and b/ProjectShedule/ProjectShedule/Resources/minus_PNG39.png differ