diff --git a/ProjectTimeTable/ProjectTimeTable/Entites/Auditorium.cs b/ProjectTimeTable/ProjectTimeTable/Entites/Auditorium.cs new file mode 100644 index 0000000..5f9e28d --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Entites/Auditorium.cs @@ -0,0 +1,24 @@ +using ProjectTimeTable.Entites.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Entites; + +public class Auditorium +{ + public int Id { get; private set; } + public string Name { get; private set; } = string.Empty; + + public ClassType ClassType { get; private set; } + + public int Size { get; private set; } + + public static Auditorium CreateEntity(int id, string name, ClassType classType, int size) + { + return new Auditorium + { Id = id, Name = name ?? string.Empty, ClassType = classType, Size=size}; + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Entites/Discipline.cs b/ProjectTimeTable/ProjectTimeTable/Entites/Discipline.cs new file mode 100644 index 0000000..32c31a3 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Entites/Discipline.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Entites; + +public class Discipline +{ + public int ID { get; private set; } + public string Name { get; private set; } = string.Empty; + public static Discipline CreateEntity(int id, string name) + { + return new Discipline { ID = id, Name = name ?? string.Empty }; + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Entites/DisciplinePlan.cs b/ProjectTimeTable/ProjectTimeTable/Entites/DisciplinePlan.cs new file mode 100644 index 0000000..152b75e --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Entites/DisciplinePlan.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Entites; + +public class DisciplinePlan +{ + public int PlanId { get; private set; } + public int DisciplineId { get; private set; } + public int CountLesson { get; private set; } + public int Course { get; private set; } + + public static DisciplinePlan CreateElement(int planId, int disciplineId, int countLesson, int course) + { + return new DisciplinePlan() + { + PlanId = planId, + DisciplineId = disciplineId, + CountLesson = countLesson, + Course = course + }; + } + + + + + +} diff --git a/ProjectTimeTable/ProjectTimeTable/Entites/Enums/ClassType.cs b/ProjectTimeTable/ProjectTimeTable/Entites/Enums/ClassType.cs new file mode 100644 index 0000000..4945a80 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Entites/Enums/ClassType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Entites.Enums; +[Flags] +public enum ClassType +{ + None = 0, + Lection = 1, + Computer =2, + Standart = 3 +} diff --git a/ProjectTimeTable/ProjectTimeTable/Entites/Enums/TeacherPost.cs b/ProjectTimeTable/ProjectTimeTable/Entites/Enums/TeacherPost.cs new file mode 100644 index 0000000..ea38feb --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Entites/Enums/TeacherPost.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Entites.Enums; + +public enum TeacherPost +{ + None = 0, + Senior =1, + Docent =2, + Candidate =3 + +} diff --git a/ProjectTimeTable/ProjectTimeTable/Entites/Group.cs b/ProjectTimeTable/ProjectTimeTable/Entites/Group.cs new file mode 100644 index 0000000..32b4901 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Entites/Group.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Entites; + +public class Group +{ + public int Id { get; private set; } + public string Name { get; private set; } = string.Empty; + public int Course { get; private set; } + public int CountPeople { get; private set; } + public int PlanID { get; private set; } + + public static Group CreateEntity(int id, string name, int course, int countPeople, int planId) + { + return new + Group { Id = id, Name = name, Course = course, CountPeople = countPeople, PlanID=planId }; + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Entites/GroupTimetable.cs b/ProjectTimeTable/ProjectTimeTable/Entites/GroupTimetable.cs new file mode 100644 index 0000000..51b51c4 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Entites/GroupTimetable.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Entites; +public class GroupTimetable +{ + public int GroupId { get; private set; } + + public int TimeTableId { get; private set; } + + public static GroupTimetable CreateElement(int idGroup, int idTimeTable) + { + return new GroupTimetable() + { + GroupId = idGroup, + TimeTableId = idTimeTable + }; + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Entites/Plan.cs b/ProjectTimeTable/ProjectTimeTable/Entites/Plan.cs new file mode 100644 index 0000000..d3d9974 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Entites/Plan.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Entites; + +public class Plan +{ + public int Id { get; private set; } + public string Name { get; private set; } = string.Empty; + public IEnumerable DisciplinePlan + { + get; + private set; + } = []; + + public static Plan CreateOperation(int id, string name, IEnumerable disciplinePlan) + { + return new Plan() + { + Id = id, + Name = name ?? string.Empty, + DisciplinePlan = disciplinePlan + }; + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Entites/Teacher.cs b/ProjectTimeTable/ProjectTimeTable/Entites/Teacher.cs new file mode 100644 index 0000000..32052e0 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Entites/Teacher.cs @@ -0,0 +1,28 @@ +using ProjectTimeTable.Entites.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Entites; + +public class Teacher +{ + public int Id { get; private set; } + public string FirstName { get; private set; } = string.Empty; + public string SecondName { get; private set; } = string.Empty; + public string LastName { get; private set; } = string.Empty; + public TeacherPost TeacherPost { get; private set; } + + + public static Teacher CreateEntity(int id, string firstname, string secondname, string lastname, TeacherPost teacherPost) + { + return new Teacher + { Id = id, + FirstName = firstname ?? string.Empty, + SecondName = secondname ?? string.Empty, + LastName = lastname ?? string.Empty, + TeacherPost = teacherPost }; + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Entites/TimeTable.cs b/ProjectTimeTable/ProjectTimeTable/Entites/TimeTable.cs new file mode 100644 index 0000000..5a26338 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Entites/TimeTable.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Entites; + +public class TimeTable +{ + public int Id { get; private set; } + public int NumberLesson { get; private set; } + public int Day { get; private set; } + public int Week { get; private set; } + public int DisciplineID { get; private set; } + public int ClassID { get; private set; } + public int GroupID { get; private set; } + public int TeacherID { get; private set; } + public IEnumerable GroupTimetable + { + get; + private set; + } = []; + + + + public static TimeTable CreateOperation(int id, int numberLesson, int day, int week, int disciplineID, int classID, int groupID, int teacherID, IEnumerable groupTimetable) + { + return new TimeTable() + { + Id = id, + NumberLesson = numberLesson, + Day = day, + Week = week, + DisciplineID = disciplineID, + ClassID = classID, + GroupID = groupID, + TeacherID = teacherID, + GroupTimetable = groupTimetable + }; + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Form1.Designer.cs b/ProjectTimeTable/ProjectTimeTable/Form1.Designer.cs deleted file mode 100644 index c763a27..0000000 --- a/ProjectTimeTable/ProjectTimeTable/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ProjectTimeTable -{ - 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/ProjectTimeTable/ProjectTimeTable/Form1.cs b/ProjectTimeTable/ProjectTimeTable/Form1.cs deleted file mode 100644 index d68499d..0000000 --- a/ProjectTimeTable/ProjectTimeTable/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ProjectTimeTable -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/ProjectTimeTable/ProjectTimeTable/FormTimeTableMain.Designer.cs b/ProjectTimeTable/ProjectTimeTable/FormTimeTableMain.Designer.cs new file mode 100644 index 0000000..c896b57 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/FormTimeTableMain.Designer.cs @@ -0,0 +1,147 @@ +namespace ProjectTimeTable +{ + partial class FormTimeTableMain + { + /// + /// 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(); + FileToolStripMenuItem = new ToolStripMenuItem(); + GroupToolStripMenuItem = new ToolStripMenuItem(); + TeacherToolStripMenuItem = new ToolStripMenuItem(); + DisciplineToolStripMenuItem = new ToolStripMenuItem(); + AuditoriumToolStripMenuItem = new ToolStripMenuItem(); + OperationToolStripMenuItem = new ToolStripMenuItem(); + TimeTableToolStripMenuItem = new ToolStripMenuItem(); + PlanToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + menuStrip.SuspendLayout(); + SuspendLayout(); + // + // menuStrip + // + menuStrip.ImageScalingSize = new Size(20, 20); + menuStrip.Items.AddRange(new ToolStripItem[] { FileToolStripMenuItem, OperationToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(782, 28); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; + // + // FileToolStripMenuItem + // + FileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { GroupToolStripMenuItem, TeacherToolStripMenuItem, DisciplineToolStripMenuItem, AuditoriumToolStripMenuItem }); + FileToolStripMenuItem.Name = "FileToolStripMenuItem"; + FileToolStripMenuItem.Size = new Size(117, 24); + FileToolStripMenuItem.Text = "Справочники"; + // + // GroupToolStripMenuItem + // + GroupToolStripMenuItem.Name = "GroupToolStripMenuItem"; + GroupToolStripMenuItem.Size = new Size(224, 26); + GroupToolStripMenuItem.Text = "Группы"; + GroupToolStripMenuItem.Click += GroupToolStripMenuItem_Click; + // + // TeacherToolStripMenuItem + // + TeacherToolStripMenuItem.Name = "TeacherToolStripMenuItem"; + TeacherToolStripMenuItem.Size = new Size(224, 26); + TeacherToolStripMenuItem.Text = "Преподаватели"; + TeacherToolStripMenuItem.Click += TeacherToolStripMenuItem_Click; + // + // DisciplineToolStripMenuItem + // + DisciplineToolStripMenuItem.Name = "DisciplineToolStripMenuItem"; + DisciplineToolStripMenuItem.Size = new Size(224, 26); + DisciplineToolStripMenuItem.Text = "Дисциплины"; + DisciplineToolStripMenuItem.Click += DisciplineToolStripMenuItem_Click; + // + // AuditoriumToolStripMenuItem + // + AuditoriumToolStripMenuItem.Name = "AuditoriumToolStripMenuItem"; + AuditoriumToolStripMenuItem.Size = new Size(224, 26); + AuditoriumToolStripMenuItem.Text = "Аудитории"; + AuditoriumToolStripMenuItem.Click += AuditoriumToolStripMenuItem_Click; + // + // OperationToolStripMenuItem + // + OperationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { TimeTableToolStripMenuItem, PlanToolStripMenuItem }); + OperationToolStripMenuItem.Name = "OperationToolStripMenuItem"; + OperationToolStripMenuItem.Size = new Size(95, 24); + OperationToolStripMenuItem.Text = "Операции"; + // + // TimeTableToolStripMenuItem + // + TimeTableToolStripMenuItem.Name = "TimeTableToolStripMenuItem"; + TimeTableToolStripMenuItem.Size = new Size(224, 26); + TimeTableToolStripMenuItem.Text = "Расписание"; + TimeTableToolStripMenuItem.Click += TimeTableToolStripMenuItem_Click; + // + // PlanToolStripMenuItem + // + PlanToolStripMenuItem.Name = "PlanToolStripMenuItem"; + PlanToolStripMenuItem.Size = new Size(224, 26); + PlanToolStripMenuItem.Text = "Учебный план"; + PlanToolStripMenuItem.Click += PlanToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(73, 24); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // FormTimeTable + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.ulgtu; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(782, 453); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormTimeTable"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Расписание"; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip; + private ToolStripMenuItem FileToolStripMenuItem; + private ToolStripMenuItem GroupToolStripMenuItem; + private ToolStripMenuItem TeacherToolStripMenuItem; + private ToolStripMenuItem DisciplineToolStripMenuItem; + private ToolStripMenuItem AuditoriumToolStripMenuItem; + private ToolStripMenuItem OperationToolStripMenuItem; + private ToolStripMenuItem TimeTableToolStripMenuItem; + private ToolStripMenuItem PlanToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/FormTimeTableMain.cs b/ProjectTimeTable/ProjectTimeTable/FormTimeTableMain.cs new file mode 100644 index 0000000..04a72f8 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/FormTimeTableMain.cs @@ -0,0 +1,97 @@ +using ProjectTimeTable.Forms; +using System.ComponentModel; +using Unity; + +namespace ProjectTimeTable +{ + public partial class FormTimeTableMain : Form + { + private readonly IUnityContainer _container; + public FormTimeTableMain(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + } + + private void GroupToolStripMenuItem_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 DisciplineToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void AuditoriumToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void TimeTableToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void PlanToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/FormTimeTableMain.resx b/ProjectTimeTable/ProjectTimeTable/FormTimeTableMain.resx new file mode 100644 index 0000000..6c82d08 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/FormTimeTableMain.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/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditorium.Designer.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditorium.Designer.cs new file mode 100644 index 0000000..92c120e --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditorium.Designer.cs @@ -0,0 +1,145 @@ +namespace ProjectTimeTable.Forms +{ + partial class FormAuditorium + { + /// + /// 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() + { + checkedListBoxClassType = new CheckedListBox(); + label1 = new Label(); + textBoxName = new TextBox(); + label2 = new Label(); + label3 = new Label(); + numericUpDownCount = new NumericUpDown(); + ButtonSave = new Button(); + ButtonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit(); + SuspendLayout(); + // + // checkedListBoxClassType + // + checkedListBoxClassType.FormattingEnabled = true; + checkedListBoxClassType.Location = new Point(182, 91); + checkedListBoxClassType.Name = "checkedListBoxClassType"; + checkedListBoxClassType.Size = new Size(150, 114); + checkedListBoxClassType.TabIndex = 0; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(33, 47); + label1.Name = "label1"; + label1.Size = new Size(77, 20); + label1.TabIndex = 1; + label1.Text = "Название"; + // + // textBoxName + // + textBoxName.Location = new Point(182, 47); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(150, 27); + textBoxName.TabIndex = 2; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(33, 115); + label2.Name = "label2"; + label2.Size = new Size(113, 20); + label2.TabIndex = 3; + label2.Text = "Тип аудитории"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(33, 231); + label3.Name = "label3"; + label3.Size = new Size(126, 20); + label3.TabIndex = 4; + label3.Text = "Количество мест"; + // + // numericUpDownCount + // + numericUpDownCount.Location = new Point(182, 224); + numericUpDownCount.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownCount.Name = "numericUpDownCount"; + numericUpDownCount.Size = new Size(150, 27); + numericUpDownCount.TabIndex = 5; + numericUpDownCount.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // + // ButtonSave + // + ButtonSave.Location = new Point(49, 270); + 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(238, 270); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(94, 29); + ButtonCancel.TabIndex = 7; + ButtonCancel.Text = "Отмена"; + ButtonCancel.UseVisualStyleBackColor = true; + ButtonCancel.Click += ButtonCancel_Click; + // + // FormAuditorium + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(372, 311); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(numericUpDownCount); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(textBoxName); + Controls.Add(label1); + Controls.Add(checkedListBoxClassType); + Name = "FormAuditorium"; + StartPosition = FormStartPosition.CenterParent; + Text = "Аудитория"; + ((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private CheckedListBox checkedListBoxClassType; + private Label label1; + private TextBox textBoxName; + private Label label2; + private Label label3; + private NumericUpDown numericUpDownCount; + private Button ButtonSave; + private Button ButtonCancel; + } +} \ No newline at end of file diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditorium.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditorium.cs new file mode 100644 index 0000000..6570845 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditorium.cs @@ -0,0 +1,108 @@ +using Microsoft.VisualBasic.FileIO; +using ProjectTimeTable.Entites; +using ProjectTimeTable.Entites.Enums; +using ProjectTimeTable.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 ProjectTimeTable.Forms +{ + public partial class FormAuditorium : Form + { + private readonly IAuditoriumRepositories _auditoriumRepository; + private int? _auditoriumId; + public int Id + { + set + { + try + { + var auditorium = _auditoriumRepository.ReadAuditoriumById(value); + if (auditorium == null) + { + throw new InvalidDataException(nameof(auditorium)); + } + foreach (ClassType elem in Enum.GetValues(typeof(ClassType))) + { + if ((elem & auditorium.ClassType) != 0) + { + + checkedListBoxClassType.SetItemChecked(checkedListBoxClassType.Items.IndexOf(elem), true); + } + } + + textBoxName.Text = auditorium.Name; + numericUpDownCount.Value = auditorium.Size; + _auditoriumId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormAuditorium(IAuditoriumRepositories auditoriumRepository) + { + InitializeComponent(); + _auditoriumRepository = auditoriumRepository ?? throw new ArgumentNullException(nameof(auditoriumRepository)); + + foreach (var elem in Enum.GetValues(typeof(ClassType))) + { + checkedListBoxClassType.Items.Add(elem); + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text) || + checkedListBoxClassType.CheckedItems.Count == 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_auditoriumId.HasValue) + { + + _auditoriumRepository.UpdateAuditorium(CreateAuditorium(_auditoriumId.Value)); + } + else + { + _auditoriumRepository.CreateAuditorium(CreateAuditorium(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private Auditorium CreateAuditorium(int id) + { + ClassType classType = ClassType.None; + foreach (var elem in checkedListBoxClassType.CheckedItems) + { + classType |= (ClassType)elem; + } + + return Auditorium.CreateEntity(id, textBoxName.Text, classType, Convert.ToInt32(numericUpDownCount.Value)); + + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Form1.resx b/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditorium.resx similarity index 93% rename from ProjectTimeTable/ProjectTimeTable/Form1.resx rename to ProjectTimeTable/ProjectTimeTable/Forms/FormAuditorium.resx index 1af7de1..af32865 100644 --- a/ProjectTimeTable/ProjectTimeTable/Form1.resx +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditorium.resx @@ -1,17 +1,17 @@  - diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditoriums.Designer.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditoriums.Designer.cs new file mode 100644 index 0000000..385a803 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditoriums.Designer.cs @@ -0,0 +1,128 @@ +namespace ProjectTimeTable.Forms +{ + partial class FormAuditoriums + { + /// + /// 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(); + buttonUpg = new Button(); + buttonRemove = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonUpg); + panel1.Controls.Add(buttonRemove); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(680, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(120, 450); + panel1.TabIndex = 0; + // + // buttonUpg + // + buttonUpg.BackgroundImage = Properties.Resources.red; + buttonUpg.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpg.Location = new Point(25, 204); + buttonUpg.Name = "buttonUpg"; + buttonUpg.Size = new Size(66, 59); + buttonUpg.TabIndex = 2; + buttonUpg.UseVisualStyleBackColor = true; + buttonUpg.Click += ButtonUpg_Click; + // + // buttonRemove + // + buttonRemove.BackgroundImage = Properties.Resources.remove; + buttonRemove.BackgroundImageLayout = ImageLayout.Stretch; + buttonRemove.Location = new Point(25, 112); + buttonRemove.Name = "buttonRemove"; + buttonRemove.Size = new Size(66, 61); + buttonRemove.TabIndex = 1; + buttonRemove.UseVisualStyleBackColor = true; + buttonRemove.Click += ButtonRemove_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(25, 28); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(66, 57); + 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.BackgroundColor = Color.Gray; + 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(680, 450); + dataGridView.TabIndex = 1; + // + // FormAuditoriums + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormAuditoriums"; + StartPosition = FormStartPosition.CenterParent; + Text = "Аудитории"; + Load += FormAuditoriums_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private DataGridView dataGridView; + private Button buttonUpg; + private Button buttonRemove; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditoriums.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditoriums.cs new file mode 100644 index 0000000..f5dd710 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditoriums.cs @@ -0,0 +1,115 @@ +using ProjectTimeTable.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace ProjectTimeTable.Forms +{ + public partial class FormAuditoriums : Form + { + private readonly IUnityContainer _container; + private readonly IAuditoriumRepositories _auditoriumRepository; + public FormAuditoriums(IUnityContainer container, IAuditoriumRepositories auditoriumRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _auditoriumRepository = auditoriumRepository ?? throw new ArgumentNullException(nameof(auditoriumRepository)); + } + + private void FormAuditoriums_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridView.DataSource = _auditoriumRepository.ReadAuditorium(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + + 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 ButtonRemove_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _auditoriumRepository.DeleteAuditorium(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpg_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); + } + } + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditoriums.resx b/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditoriums.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormAuditoriums.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/ProjectTimeTable/ProjectTimeTable/Forms/FormDiscipline.Designer.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormDiscipline.Designer.cs new file mode 100644 index 0000000..85d1461 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormDiscipline.Designer.cs @@ -0,0 +1,96 @@ +namespace ProjectTimeTable.Forms +{ + partial class FormDiscipline + { + /// + /// 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(); + textBoxName = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 46); + label1.Name = "label1"; + label1.Size = new Size(77, 20); + label1.TabIndex = 0; + label1.Text = "Название"; + // + // textBoxName + // + textBoxName.Location = new Point(118, 39); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(186, 27); + textBoxName.TabIndex = 1; + // + // buttonSave + // + buttonSave.Location = new Point(60, 110); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 2; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(186, 110); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 3; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormDiscipline + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(359, 190); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxName); + Controls.Add(label1); + Name = "FormDiscipline"; + StartPosition = FormStartPosition.CenterParent; + Text = "Дисциплина"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private TextBox textBoxName; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormDiscipline.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormDiscipline.cs new file mode 100644 index 0000000..40964c2 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormDiscipline.cs @@ -0,0 +1,83 @@ +using ProjectTimeTable.Entites.Enums; +using ProjectTimeTable.Entites; +using ProjectTimeTable.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 ProjectTimeTable.Forms +{ + public partial class FormDiscipline : Form + { + private readonly IDisciplineRepositories _disciplineRepository; + + private int? _disciplineId; + + public int Id + { + set + { + try + { + var discipline = _disciplineRepository.ReadDisciplineById(value); + if (discipline == null) + { + throw new InvalidDataException(nameof(discipline)); + } + + textBoxName.Text = discipline.Name; + _disciplineId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormDiscipline(IDisciplineRepositories disciplineRepository) + { + InitializeComponent(); + _disciplineRepository = disciplineRepository ?? throw new ArgumentNullException(nameof(disciplineRepository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_disciplineId.HasValue) + { + + _disciplineRepository.UpdateDiscipline(CreateDiscipline(_disciplineId.Value)); + } + else + { + + _disciplineRepository.CreateDiscipline(CreateDiscipline(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + private Discipline CreateDiscipline(int id) => Discipline.CreateEntity(id, textBoxName.Text); + + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormDiscipline.resx b/ProjectTimeTable/ProjectTimeTable/Forms/FormDiscipline.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormDiscipline.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/ProjectTimeTable/ProjectTimeTable/Forms/FormDisciplines.Designer.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormDisciplines.Designer.cs new file mode 100644 index 0000000..4046fe6 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormDisciplines.Designer.cs @@ -0,0 +1,128 @@ +namespace ProjectTimeTable.Forms +{ + partial class FormDisciplines + { + /// + /// 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(); + buttonUpg = new Button(); + buttonRemove = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonUpg); + panel1.Controls.Add(buttonRemove); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(680, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(120, 450); + panel1.TabIndex = 0; + // + // buttonUpg + // + buttonUpg.BackgroundImage = Properties.Resources.red; + buttonUpg.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpg.Location = new Point(25, 204); + buttonUpg.Name = "buttonUpg"; + buttonUpg.Size = new Size(66, 59); + buttonUpg.TabIndex = 2; + buttonUpg.UseVisualStyleBackColor = true; + buttonUpg.Click += ButtonUpg_Click; + // + // buttonRemove + // + buttonRemove.BackgroundImage = Properties.Resources.remove; + buttonRemove.BackgroundImageLayout = ImageLayout.Stretch; + buttonRemove.Location = new Point(25, 112); + buttonRemove.Name = "buttonRemove"; + buttonRemove.Size = new Size(66, 61); + buttonRemove.TabIndex = 1; + buttonRemove.UseVisualStyleBackColor = true; + buttonRemove.Click += ButtonRemove_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(25, 28); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(66, 57); + 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.BackgroundColor = Color.Gray; + 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(680, 450); + dataGridView.TabIndex = 1; + // + // FormDisciplines + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormDisciplines"; + StartPosition = FormStartPosition.CenterParent; + Text = "FormDisciplines"; + Load += FormDisciplines_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private DataGridView dataGridView; + private Button buttonUpg; + private Button buttonRemove; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormDisciplines.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormDisciplines.cs new file mode 100644 index 0000000..92dc3be --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormDisciplines.cs @@ -0,0 +1,115 @@ +using ProjectTimeTable.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace ProjectTimeTable.Forms +{ + public partial class FormDisciplines : Form + { + private readonly IUnityContainer _container; + private readonly IDisciplineRepositories _disciplineRepository; + public FormDisciplines(IUnityContainer container, IDisciplineRepositories disciplineRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _disciplineRepository = disciplineRepository ?? throw new ArgumentNullException(nameof(disciplineRepository)); + } + + private void FormDisciplines_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridView.DataSource = _disciplineRepository.ReadDiscipline(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + + 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 ButtonRemove_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _disciplineRepository.DeleteDiscipline(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpg_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); + } + } + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormDisciplines.resx b/ProjectTimeTable/ProjectTimeTable/Forms/FormDisciplines.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormDisciplines.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/ProjectTimeTable/ProjectTimeTable/Forms/FormGroup.Designer.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormGroup.Designer.cs new file mode 100644 index 0000000..e291351 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormGroup.Designer.cs @@ -0,0 +1,174 @@ +namespace ProjectTimeTable.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() + { + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + label4 = new Label(); + TextBoxName = new TextBox(); + numericUpDownCourse = new NumericUpDown(); + numericUpDownCount = new NumericUpDown(); + comboBoxPlan = new ComboBox(); + ButtonSave = new Button(); + ButtonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownCourse).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(29, 35); + label1.Name = "label1"; + label1.Size = new Size(77, 20); + label1.TabIndex = 0; + label1.Text = "Название"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(29, 82); + label2.Name = "label2"; + label2.Size = new Size(41, 20); + label2.TabIndex = 1; + label2.Text = "Курс"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(29, 126); + label3.Name = "label3"; + label3.Size = new Size(150, 20); + label3.TabIndex = 2; + label3.Text = "Количество человек"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(29, 171); + label4.Name = "label4"; + label4.Size = new Size(110, 20); + label4.TabIndex = 3; + label4.Text = "Учебный план"; + // + // TextBoxName + // + TextBoxName.Location = new Point(242, 35); + TextBoxName.Name = "TextBoxName"; + TextBoxName.Size = new Size(150, 27); + TextBoxName.TabIndex = 4; + // + // numericUpDownCourse + // + numericUpDownCourse.Location = new Point(242, 80); + numericUpDownCourse.Maximum = new decimal(new int[] { 6, 0, 0, 0 }); + numericUpDownCourse.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownCourse.Name = "numericUpDownCourse"; + numericUpDownCourse.Size = new Size(150, 27); + numericUpDownCourse.TabIndex = 5; + numericUpDownCourse.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // + // numericUpDownCount + // + numericUpDownCount.Location = new Point(242, 126); + numericUpDownCount.Maximum = new decimal(new int[] { 30, 0, 0, 0 }); + numericUpDownCount.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownCount.Name = "numericUpDownCount"; + numericUpDownCount.Size = new Size(150, 27); + numericUpDownCount.TabIndex = 6; + numericUpDownCount.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // + // comboBoxPlan + // + comboBoxPlan.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxPlan.FormattingEnabled = true; + comboBoxPlan.Location = new Point(242, 171); + comboBoxPlan.Name = "comboBoxPlan"; + comboBoxPlan.Size = new Size(150, 28); + comboBoxPlan.TabIndex = 7; + // + // ButtonSave + // + ButtonSave.Location = new Point(55, 218); + 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(261, 218); + 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(435, 266); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(comboBoxPlan); + Controls.Add(numericUpDownCount); + Controls.Add(numericUpDownCourse); + Controls.Add(TextBoxName); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormGroup"; + StartPosition = FormStartPosition.CenterParent; + Text = "Группа"; + ((System.ComponentModel.ISupportInitialize)numericUpDownCourse).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private Label label4; + private TextBox TextBoxName; + private NumericUpDown numericUpDownCourse; + private NumericUpDown numericUpDownCount; + private ComboBox comboBoxPlan; + private Button ButtonSave; + private Button ButtonCancel; + } +} \ No newline at end of file diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormGroup.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormGroup.cs new file mode 100644 index 0000000..6ddc387 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormGroup.cs @@ -0,0 +1,92 @@ +using Microsoft.VisualBasic.FileIO; +using ProjectTimeTable.Entites; +using ProjectTimeTable.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 ProjectTimeTable.Forms +{ + public partial class FormGroup : Form + { + private readonly IGroupRepositories _groupRepository; + + + private int? _groupId; + public int Id + { + set + { + try + { + var group = _groupRepository.ReadGroupById(value); + if (group == null) + { + throw new InvalidDataException(nameof(group)); + } + + TextBoxName.Text = group.Name; + numericUpDownCourse.Value = group.Course; + numericUpDownCount.Value = group.CountPeople; + _groupId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormGroup(IGroupRepositories groupRepository, IPlanRepositories planRepository) + { + InitializeComponent(); + _groupRepository = groupRepository ?? throw new ArgumentNullException(nameof(groupRepository)); + + comboBoxPlan.DataSource = planRepository.ReadPlan(); + comboBoxPlan.DisplayMember = "Name"; + comboBoxPlan.ValueMember = "Id"; + + + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(TextBoxName.Text) || comboBoxPlan.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_groupId.HasValue) + { + + _groupRepository.UpdateGroup(CreateGroup(_groupId.Value)); + } + else + { + _groupRepository.CreateGroup(CreateGroup(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + private Group CreateGroup(int id) => Group.CreateEntity(0, TextBoxName.Text, + Convert.ToInt32(numericUpDownCourse.Value), Convert.ToInt32(numericUpDownCount.Value), (int)comboBoxPlan.SelectedValue!); + + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormGroup.resx b/ProjectTimeTable/ProjectTimeTable/Forms/FormGroup.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/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/ProjectTimeTable/ProjectTimeTable/Forms/FormGroups.Designer.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormGroups.Designer.cs new file mode 100644 index 0000000..e071fb7 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormGroups.Designer.cs @@ -0,0 +1,128 @@ +namespace ProjectTimeTable.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(); + buttonUpg = new Button(); + buttonRemove = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonUpg); + panel1.Controls.Add(buttonRemove); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(680, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(120, 450); + panel1.TabIndex = 0; + // + // buttonUpg + // + buttonUpg.BackgroundImage = Properties.Resources.red; + buttonUpg.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpg.Location = new Point(25, 204); + buttonUpg.Name = "buttonUpg"; + buttonUpg.Size = new Size(66, 59); + buttonUpg.TabIndex = 2; + buttonUpg.UseVisualStyleBackColor = true; + buttonUpg.Click += ButtonUpg_Click; + // + // buttonRemove + // + buttonRemove.BackgroundImage = Properties.Resources.remove; + buttonRemove.BackgroundImageLayout = ImageLayout.Stretch; + buttonRemove.Location = new Point(25, 112); + buttonRemove.Name = "buttonRemove"; + buttonRemove.Size = new Size(66, 61); + buttonRemove.TabIndex = 1; + buttonRemove.UseVisualStyleBackColor = true; + buttonRemove.Click += ButtonRemove_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(25, 28); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(66, 57); + 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.BackgroundColor = Color.Gray; + 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(680, 450); + dataGridView.TabIndex = 1; + // + // FormGroups + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormGroups"; + StartPosition = FormStartPosition.CenterParent; + Text = "Группы"; + Load += FormGroups_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private DataGridView dataGridView; + private Button buttonUpg; + private Button buttonRemove; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormGroups.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormGroups.cs new file mode 100644 index 0000000..edd58c7 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormGroups.cs @@ -0,0 +1,115 @@ +using ProjectTimeTable.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace ProjectTimeTable.Forms +{ + public partial class FormGroups : Form + { + private readonly IUnityContainer _container; + private readonly IGroupRepositories _groupRepository; + public FormGroups(IUnityContainer container, IGroupRepositories 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 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 false; + } + + id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + + 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 ButtonRemove_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 ButtonUpg_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); + } + } + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormGroups.resx b/ProjectTimeTable/ProjectTimeTable/Forms/FormGroups.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/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/ProjectTimeTable/ProjectTimeTable/Forms/FormPlan.Designer.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormPlan.Designer.cs new file mode 100644 index 0000000..a5e1ae5 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormPlan.Designer.cs @@ -0,0 +1,160 @@ +namespace ProjectTimeTable.Forms +{ + partial class FormPlan + { + /// + /// 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(); + textBoxName = new TextBox(); + groupBoxDiscipline = new GroupBox(); + dataGridViewDiscipline = new DataGridView(); + ColumnDiscipline = new DataGridViewComboBoxColumn(); + ColumnCountLesson = new DataGridViewTextBoxColumn(); + ColumnCourse = new DataGridViewTextBoxColumn(); + ButtonSave = new Button(); + ButtonCancel = new Button(); + groupBoxDiscipline.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewDiscipline).BeginInit(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(36, 35); + label1.Name = "label1"; + label1.Size = new Size(123, 20); + label1.TabIndex = 0; + label1.Text = "Название плана"; + // + // textBoxName + // + textBoxName.Location = new Point(195, 32); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(243, 27); + textBoxName.TabIndex = 1; + // + // groupBoxDiscipline + // + groupBoxDiscipline.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBoxDiscipline.Controls.Add(dataGridViewDiscipline); + groupBoxDiscipline.Location = new Point(26, 87); + groupBoxDiscipline.Name = "groupBoxDiscipline"; + groupBoxDiscipline.Size = new Size(433, 363); + groupBoxDiscipline.TabIndex = 2; + groupBoxDiscipline.TabStop = false; + groupBoxDiscipline.Text = "Дисциплины"; + // + // dataGridViewDiscipline + // + dataGridViewDiscipline.AllowUserToResizeColumns = false; + dataGridViewDiscipline.AllowUserToResizeRows = false; + dataGridViewDiscipline.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewDiscipline.Columns.AddRange(new DataGridViewColumn[] { ColumnDiscipline, ColumnCountLesson, ColumnCourse }); + dataGridViewDiscipline.Dock = DockStyle.Fill; + dataGridViewDiscipline.Location = new Point(3, 23); + dataGridViewDiscipline.MultiSelect = false; + dataGridViewDiscipline.Name = "dataGridViewDiscipline"; + dataGridViewDiscipline.RowHeadersWidth = 51; + dataGridViewDiscipline.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewDiscipline.Size = new Size(427, 337); + dataGridViewDiscipline.TabIndex = 0; + // + // ColumnDiscipline + // + ColumnDiscipline.HeaderText = "Дисциплина"; + ColumnDiscipline.MinimumWidth = 6; + ColumnDiscipline.Name = "ColumnDiscipline"; + ColumnDiscipline.Width = 125; + // + // ColumnCountLesson + // + ColumnCountLesson.HeaderText = "Количество часов"; + ColumnCountLesson.MinimumWidth = 6; + ColumnCountLesson.Name = "ColumnCountLesson"; + ColumnCountLesson.Width = 125; + // + // ColumnCourse + // + ColumnCourse.HeaderText = "Курс"; + ColumnCourse.MinimumWidth = 6; + ColumnCourse.Name = "ColumnCourse"; + ColumnCourse.Width = 125; + // + // ButtonSave + // + ButtonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + ButtonSave.Location = new Point(68, 478); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(94, 29); + ButtonSave.TabIndex = 3; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += ButtonSave_Click; + // + // ButtonCancel + // + ButtonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + ButtonCancel.Location = new Point(302, 478); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(94, 29); + ButtonCancel.TabIndex = 4; + ButtonCancel.Text = "Отмена"; + ButtonCancel.UseVisualStyleBackColor = true; + ButtonCancel.Click += ButtonCancel_Click; + // + // FormPlan + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(488, 528); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(groupBoxDiscipline); + Controls.Add(textBoxName); + Controls.Add(label1); + Name = "FormPlan"; + StartPosition = FormStartPosition.CenterParent; + Text = "Учебный план"; + groupBoxDiscipline.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewDiscipline).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private TextBox textBoxName; + private GroupBox groupBoxDiscipline; + private DataGridView dataGridViewDiscipline; + private DataGridViewComboBoxColumn ColumnDiscipline; + private DataGridViewTextBoxColumn ColumnCountLesson; + private DataGridViewTextBoxColumn ColumnCourse; + private Button ButtonSave; + private Button ButtonCancel; + } +} \ No newline at end of file diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormPlan.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormPlan.cs new file mode 100644 index 0000000..f71f8cd --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormPlan.cs @@ -0,0 +1,95 @@ +using ProjectTimeTable.Entites; +using ProjectTimeTable.Entites.Enums; +using ProjectTimeTable.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 ProjectTimeTable.Forms +{ + public partial class FormPlan : Form + { + private readonly IPlanRepositories _planRepository; + private int? _planId; + public int Id + { + set + { + try + { + var plan = _planRepository.ReadPlanById(value); + if (plan == null) + { + throw new InvalidDataException(nameof(plan)); + } + + textBoxName.Text = plan.Name; + _planId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormPlan(IPlanRepositories planRepository, IDisciplineRepositories disciplineRepository) + { + InitializeComponent(); + _planRepository = planRepository ?? throw new ArgumentNullException(nameof(planRepository)); + ColumnDiscipline.DataSource = disciplineRepository.ReadDiscipline(); + ColumnDiscipline.DisplayMember = "Name"; + ColumnDiscipline.ValueMember = "Id"; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (dataGridViewDiscipline.RowCount < 1 || + string.IsNullOrWhiteSpace(textBoxName.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + _planRepository.CreatePlan(Plan.CreateOperation(0, textBoxName.Text, CreateListDisciplinePlanFromDataGrid())); + + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private List CreateListDisciplinePlanFromDataGrid() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridViewDiscipline.Rows) + { + if (row.Cells["ColumnDiscipline"].Value == null || row.Cells["ColumnCountLesson"].Value == null || row.Cells["ColumnCourse"].Value == null) + { + continue; + } + + list.Add(DisciplinePlan.CreateElement(0, Convert.ToInt32(row.Cells["ColumnDiscipline"].Value), + + Convert.ToInt32(row.Cells["ColumnCountLesson"].Value), Convert.ToInt32(row.Cells["ColumnCourse"].Value))); + } + + return list; + } + + + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormPlan.resx b/ProjectTimeTable/ProjectTimeTable/Forms/FormPlan.resx new file mode 100644 index 0000000..e1bb7d8 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormPlan.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormPlans.Designer.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormPlans.Designer.cs new file mode 100644 index 0000000..a45a557 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormPlans.Designer.cs @@ -0,0 +1,100 @@ +namespace ProjectTimeTable.Forms +{ + partial class FormPlans + { + /// + /// 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(680, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(120, 450); + panel1.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(25, 28); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(66, 57); + 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.BackgroundColor = Color.Gray; + 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(680, 450); + dataGridView.TabIndex = 1; + // + // FormPlans + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormPlans"; + StartPosition = FormStartPosition.CenterParent; + Text = "Учебные Планы"; + Load += FormPlans_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private DataGridView dataGridView; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormPlans.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormPlans.cs new file mode 100644 index 0000000..6410260 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormPlans.cs @@ -0,0 +1,55 @@ +using ProjectTimeTable.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace ProjectTimeTable.Forms +{ + public partial class FormPlans : Form + { + private readonly IUnityContainer _container; + private readonly IPlanRepositories _planRepository; + public FormPlans(IUnityContainer container, IPlanRepositories planRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _planRepository = planRepository ?? throw new ArgumentNullException(nameof(planRepository)); + } + + private void FormPlans_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridView.DataSource = _planRepository.ReadPlan(); + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormPlans.resx b/ProjectTimeTable/ProjectTimeTable/Forms/FormPlans.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormPlans.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/ProjectTimeTable/ProjectTimeTable/Forms/FormTeacher.Designer.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormTeacher.Designer.cs new file mode 100644 index 0000000..7898a8a --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormTeacher.Designer.cs @@ -0,0 +1,173 @@ +namespace ProjectTimeTable.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() + { + components = new System.ComponentModel.Container(); + label1 = new Label(); + label2 = new Label(); + textBoxFirstName = new TextBox(); + Save = new Button(); + Cancel = new Button(); + contextMenuStrip1 = new ContextMenuStrip(components); + comboBoxPost = new ComboBox(); + label3 = new Label(); + label4 = new Label(); + textBoxSecondName = new TextBox(); + textBoxLastName = new TextBox(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(47, 51); + label1.Name = "label1"; + label1.Size = new Size(73, 20); + label1.TabIndex = 0; + label1.Text = "Фамилия"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(47, 199); + label2.Name = "label2"; + label2.Size = new Size(86, 20); + label2.TabIndex = 1; + label2.Text = "Должность"; + // + // textBoxFirstName + // + textBoxFirstName.Location = new Point(145, 51); + textBoxFirstName.Name = "textBoxFirstName"; + textBoxFirstName.Size = new Size(151, 27); + textBoxFirstName.TabIndex = 2; + // + // Save + // + Save.Location = new Point(47, 261); + Save.Name = "Save"; + Save.Size = new Size(94, 29); + Save.TabIndex = 3; + Save.Text = "Сохранить"; + Save.UseVisualStyleBackColor = true; + Save.Click += ButtonSave_Click; + // + // Cancel + // + Cancel.Location = new Point(190, 261); + Cancel.Name = "Cancel"; + Cancel.Size = new Size(94, 29); + Cancel.TabIndex = 4; + Cancel.Text = "Отмена"; + Cancel.UseVisualStyleBackColor = true; + Cancel.Click += ButtonCancel_Click; + // + // contextMenuStrip1 + // + contextMenuStrip1.ImageScalingSize = new Size(20, 20); + contextMenuStrip1.Name = "contextMenuStrip1"; + contextMenuStrip1.Size = new Size(61, 4); + // + // comboBoxPost + // + comboBoxPost.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxPost.FormattingEnabled = true; + comboBoxPost.Location = new Point(145, 199); + comboBoxPost.Name = "comboBoxPost"; + comboBoxPost.Size = new Size(151, 28); + comboBoxPost.TabIndex = 5; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(47, 98); + label3.Name = "label3"; + label3.Size = new Size(39, 20); + label3.TabIndex = 6; + label3.Text = "Имя"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(47, 145); + label4.Name = "label4"; + label4.Size = new Size(72, 20); + label4.TabIndex = 7; + label4.Text = "Отчество"; + // + // textBoxSecondName + // + textBoxSecondName.Location = new Point(143, 97); + textBoxSecondName.Name = "textBoxSecondName"; + textBoxSecondName.Size = new Size(153, 27); + textBoxSecondName.TabIndex = 8; + // + // textBoxLastName + // + textBoxLastName.Location = new Point(142, 144); + textBoxLastName.Name = "textBoxLastName"; + textBoxLastName.Size = new Size(154, 27); + textBoxLastName.TabIndex = 9; + // + // FormTeacher + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(356, 309); + Controls.Add(textBoxLastName); + Controls.Add(textBoxSecondName); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(comboBoxPost); + Controls.Add(Cancel); + Controls.Add(Save); + Controls.Add(textBoxFirstName); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormTeacher"; + StartPosition = FormStartPosition.CenterParent; + Text = "Преподаватели"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private TextBox textBoxFirstName; + private Button Save; + private Button Cancel; + private ContextMenuStrip contextMenuStrip1; + private ComboBox comboBoxPost; + private Label label3; + private Label label4; + private TextBox textBoxSecondName; + private TextBox textBoxLastName; + } +} \ No newline at end of file diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormTeacher.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormTeacher.cs new file mode 100644 index 0000000..20f6373 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormTeacher.cs @@ -0,0 +1,92 @@ +using ProjectTimeTable.Entites; +using ProjectTimeTable.Entites.Enums; +using ProjectTimeTable.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 ProjectTimeTable.Forms +{ + public partial class FormTeacher : Form + { + private readonly ITeacherRepositories _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; + textBoxSecondName.Text = teacher.SecondName; + textBoxLastName.Text = teacher.LastName; + comboBoxPost.SelectedItem =teacher.TeacherPost; + _teacherId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormTeacher(ITeacherRepositories teacherRepository) + { + InitializeComponent(); + _teacherRepository = teacherRepository ?? throw new ArgumentNullException(nameof(teacherRepository)); + + comboBoxPost.DataSource =Enum.GetValues(typeof(TeacherPost)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxSecondName.Text) || + string.IsNullOrWhiteSpace(textBoxLastName.Text) || comboBoxPost.SelectedIndex < 1) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_teacherId.HasValue) + { + + _teacherRepository.UpdateTeacher(CreateTeacher(_teacherId.Value)); + } + else + { + + _teacherRepository.CreateTeacher(CreateTeacher(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + + private Teacher CreateTeacher(int id) => Teacher.CreateEntity(id, textBoxFirstName.Text, textBoxSecondName.Text, + textBoxLastName.Text, (TeacherPost)comboBoxPost.SelectedItem!); + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormTeacher.resx b/ProjectTimeTable/ProjectTimeTable/Forms/FormTeacher.resx new file mode 100644 index 0000000..8b39395 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormTeacher.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/ProjectTimeTable/ProjectTimeTable/Forms/FormTeachers.Designer.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormTeachers.Designer.cs new file mode 100644 index 0000000..9b76ab0 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormTeachers.Designer.cs @@ -0,0 +1,127 @@ +namespace ProjectTimeTable.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(); + ButtonUpd = new Button(); + buttonRemove = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(ButtonUpd); + panel1.Controls.Add(buttonRemove); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(698, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(102, 450); + panel1.TabIndex = 0; + // + // ButtonUpd + // + ButtonUpd.BackgroundImage = Properties.Resources.red; + ButtonUpd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonUpd.Location = new Point(18, 210); + ButtonUpd.Name = "ButtonUpd"; + ButtonUpd.Size = new Size(61, 58); + ButtonUpd.TabIndex = 2; + ButtonUpd.UseVisualStyleBackColor = true; + ButtonUpd.Click += ButtonUpd_Click; + // + // buttonRemove + // + buttonRemove.BackgroundImage = Properties.Resources.remove; + buttonRemove.BackgroundImageLayout = ImageLayout.Stretch; + buttonRemove.Location = new Point(18, 127); + buttonRemove.Name = "buttonRemove"; + buttonRemove.Size = new Size(61, 57); + buttonRemove.TabIndex = 1; + buttonRemove.UseVisualStyleBackColor = true; + buttonRemove.Click += ButtonRemove_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(18, 41); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(61, 55); + 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(698, 450); + dataGridView.TabIndex = 1; + // + // FormTeachers + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormTeachers"; + StartPosition = FormStartPosition.CenterParent; + Text = "Преподаватели"; + Load += FormTeachers_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button ButtonUpd; + private Button buttonRemove; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormTeachers.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormTeachers.cs new file mode 100644 index 0000000..6ae5a62 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormTeachers.cs @@ -0,0 +1,122 @@ +using ProjectTimeTable.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace ProjectTimeTable.Forms +{ + public partial class FormTeachers : Form + { + private readonly IUnityContainer _container; + private readonly ITeacherRepositories _teacherRepository; + public FormTeachers(IUnityContainer container, ITeacherRepositories teacherRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _teacherRepository = teacherRepository ?? + throw new ArgumentNullException(nameof(teacherRepository)); + + } + + 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 ButtonRemove_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 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 FormTeachers_Load(object sender, EventArgs e) + { + try + { + 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 false; + } + + id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormTeachers.resx b/ProjectTimeTable/ProjectTimeTable/Forms/FormTeachers.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/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/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTable.Designer.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTable.Designer.cs new file mode 100644 index 0000000..f59079c --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTable.Designer.cs @@ -0,0 +1,234 @@ +namespace ProjectTimeTable.Forms +{ + partial class FormTimeTable + { + /// + /// 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(); + label2 = new Label(); + label3 = new Label(); + numericUpDownCountLesson = new NumericUpDown(); + numericUpDownWeek = new NumericUpDown(); + numericUpDownDay = new NumericUpDown(); + ButtonSave = new Button(); + ButtonCancel = new Button(); + groupBoxTimeTable = new GroupBox(); + dataGridViewTimeTable = new DataGridView(); + ColumnDiscipline = new DataGridViewComboBoxColumn(); + ColumnAuditorium = new DataGridViewComboBoxColumn(); + ColumnGroup = new DataGridViewComboBoxColumn(); + ColumnTeacher = new DataGridViewComboBoxColumn(); + ((System.ComponentModel.ISupportInitialize)numericUpDownCountLesson).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeek).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownDay).BeginInit(); + groupBoxTimeTable.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewTimeTable).BeginInit(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(25, 25); + label1.Name = "label1"; + label1.Size = new Size(120, 20); + label1.TabIndex = 0; + label1.Text = "Количество пар"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(25, 71); + label2.Name = "label2"; + label2.Size = new Size(60, 20); + label2.TabIndex = 1; + label2.Text = "Неделя"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(25, 117); + label3.Name = "label3"; + label3.Size = new Size(44, 20); + label3.TabIndex = 2; + label3.Text = "День"; + // + // numericUpDownCountLesson + // + numericUpDownCountLesson.Location = new Point(203, 23); + numericUpDownCountLesson.Maximum = new decimal(new int[] { 9, 0, 0, 0 }); + numericUpDownCountLesson.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownCountLesson.Name = "numericUpDownCountLesson"; + numericUpDownCountLesson.Size = new Size(150, 27); + numericUpDownCountLesson.TabIndex = 7; + numericUpDownCountLesson.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // + // numericUpDownWeek + // + numericUpDownWeek.Location = new Point(203, 69); + numericUpDownWeek.Maximum = new decimal(new int[] { 2, 0, 0, 0 }); + numericUpDownWeek.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownWeek.Name = "numericUpDownWeek"; + numericUpDownWeek.Size = new Size(150, 27); + numericUpDownWeek.TabIndex = 8; + numericUpDownWeek.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // + // numericUpDownDay + // + numericUpDownDay.Location = new Point(203, 115); + numericUpDownDay.Maximum = new decimal(new int[] { 7, 0, 0, 0 }); + numericUpDownDay.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownDay.Name = "numericUpDownDay"; + numericUpDownDay.Size = new Size(150, 27); + numericUpDownDay.TabIndex = 9; + numericUpDownDay.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // + // ButtonSave + // + ButtonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + ButtonSave.Location = new Point(95, 498); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(94, 29); + ButtonSave.TabIndex = 18; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + // + // ButtonCancel + // + ButtonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + ButtonCancel.Location = new Point(364, 498); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(94, 29); + ButtonCancel.TabIndex = 19; + ButtonCancel.Text = "Отмена"; + ButtonCancel.UseVisualStyleBackColor = true; + // + // groupBoxTimeTable + // + groupBoxTimeTable.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBoxTimeTable.Controls.Add(dataGridViewTimeTable); + groupBoxTimeTable.Location = new Point(12, 160); + groupBoxTimeTable.Name = "groupBoxTimeTable"; + groupBoxTimeTable.Size = new Size(557, 319); + groupBoxTimeTable.TabIndex = 20; + groupBoxTimeTable.TabStop = false; + groupBoxTimeTable.Text = "Расписание"; + // + // dataGridViewTimeTable + // + dataGridViewTimeTable.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridViewTimeTable.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewTimeTable.Columns.AddRange(new DataGridViewColumn[] { ColumnDiscipline, ColumnAuditorium, ColumnGroup, ColumnTeacher }); + dataGridViewTimeTable.Location = new Point(0, 26); + dataGridViewTimeTable.Name = "dataGridViewTimeTable"; + dataGridViewTimeTable.RowHeadersWidth = 51; + dataGridViewTimeTable.Size = new Size(551, 287); + dataGridViewTimeTable.TabIndex = 0; + // + // ColumnDiscipline + // + ColumnDiscipline.HeaderText = "Дисциплина"; + ColumnDiscipline.MinimumWidth = 6; + ColumnDiscipline.Name = "ColumnDiscipline"; + ColumnDiscipline.Width = 125; + // + // ColumnAuditorium + // + ColumnAuditorium.HeaderText = "Аудитория"; + ColumnAuditorium.MinimumWidth = 6; + ColumnAuditorium.Name = "ColumnAuditorium"; + ColumnAuditorium.Width = 125; + // + // ColumnGroup + // + ColumnGroup.HeaderText = "Группа"; + ColumnGroup.MinimumWidth = 6; + ColumnGroup.Name = "ColumnGroup"; + ColumnGroup.Width = 125; + // + // ColumnTeacher + // + ColumnTeacher.HeaderText = "Преподаватель"; + ColumnTeacher.MinimumWidth = 6; + ColumnTeacher.Name = "ColumnTeacher"; + ColumnTeacher.Width = 125; + // + // FormTimeTable + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(585, 548); + Controls.Add(groupBoxTimeTable); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(numericUpDownDay); + Controls.Add(numericUpDownWeek); + Controls.Add(numericUpDownCountLesson); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormTimeTable"; + StartPosition = FormStartPosition.CenterParent; + Text = "Расписание"; + ((System.ComponentModel.ISupportInitialize)numericUpDownCountLesson).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeek).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownDay).EndInit(); + groupBoxTimeTable.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewTimeTable).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private NumericUpDown numericUpDownCountLesson; + private NumericUpDown numericUpDownWeek; + private NumericUpDown numericUpDownDay; + private Label label4; + private Label label5; + private Label label6; + private Label label7; + private ComboBox comboBoxDiscipline; + private ComboBox comboBoxAuditorium; + private ComboBox comboBoxGroup; + private ComboBox comboBoxTeacher; + private Button ButtonSave; + private Button ButtonCancel; + private ComboBox comboBoxCountLesson; + private ComboBox comboBox2; + private ComboBox comboBox3; + private GroupBox groupBox1; + private GroupBox groupBoxTimeTable; + private DataGridView dataGridViewTimeTable; + private DataGridViewComboBoxColumn ColumnDiscipline; + private DataGridViewComboBoxColumn ColumnAuditorium; + private DataGridViewComboBoxColumn ColumnGroup; + private DataGridViewComboBoxColumn ColumnTeacher; + } +} \ No newline at end of file diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTable.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTable.cs new file mode 100644 index 0000000..9ef751f --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTable.cs @@ -0,0 +1,92 @@ +using ProjectTimeTable.Entites; +using ProjectTimeTable.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 ProjectTimeTable.Forms +{ + public partial class FormTimeTable : Form + { + private readonly ITimeTableRepositories _timeTableRepository; + + public FormTimeTable(ITimeTableRepositories timeTableRepository, IGroupRepositories groupRepository, ITeacherRepositories + teacherRepository, IAuditoriumRepositories auditoriumRepository, IDisciplineRepositories disciplineRepository) + { + InitializeComponent(); + _timeTableRepository = timeTableRepository ?? throw new ArgumentNullException(nameof(timeTableRepository)); + + + ColumnDiscipline.DataSource =disciplineRepository.ReadDiscipline(); + ColumnDiscipline.DisplayMember = "Name"; + ColumnDiscipline.ValueMember = "Id"; + + ColumnAuditorium.DataSource = auditoriumRepository.ReadAuditorium(); + ColumnAuditorium.DisplayMember = "Name"; + ColumnAuditorium.ValueMember = "Id"; + + ColumnGroup.DataSource = groupRepository.ReadGroup(); + ColumnGroup.DisplayMember = "Name"; + ColumnGroup.ValueMember = "Id"; + + ColumnTeacher.DataSource = teacherRepository.ReadTeacher(); + ColumnTeacher.DisplayMember = "FirstName"; + ColumnTeacher.ValueMember = "Id"; + } + + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (dataGridViewTimeTable.RowCount < 1) + { + throw new Exception("Имеются незаполненные поля"); + } + + + _timeTableRepository.CreateTimeTable(TimeTable.CreateOperation(0, Convert.ToInt32(numericUpDownCountLesson.Value), + Convert.ToInt32(numericUpDownDay.Value), Convert.ToInt32(numericUpDownWeek.Value), (int)comboBoxDiscipline.SelectedValue!, + (int)comboBoxAuditorium.SelectedValue!, (int)comboBoxGroup.SelectedValue!, (int)comboBoxTeacher.SelectedValue!, + CreateListGroupTimeTableFromDataGrid())); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => + Close(); + + + private List CreateListGroupTimeTableFromDataGrid() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridViewTimeTable.Rows) + { + if (row.Cells["ColumnDiscipline"].Value == null || row.Cells["ColumnGroup"].Value == null || row.Cells["ColumnAuditorium"].Value == null || + row.Cells["ColumnTeacher"].Value == null) + { + continue; + } + + list.Add(GroupTimetable.CreateElement(Convert.ToInt32(comboBoxGroup.SelectedIndex), 0)); + } + + return list; + } + + + + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTable.resx b/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTable.resx new file mode 100644 index 0000000..a8daa5e --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTable.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/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTables.Designer.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTables.Designer.cs new file mode 100644 index 0000000..daff052 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTables.Designer.cs @@ -0,0 +1,114 @@ +namespace ProjectTimeTable.Forms +{ + partial class FormTimeTables + { + /// + /// 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(); + buttonRemove = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonRemove); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(1049, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(120, 534); + panel1.TabIndex = 0; + // + // buttonRemove + // + buttonRemove.BackgroundImage = Properties.Resources.remove; + buttonRemove.BackgroundImageLayout = ImageLayout.Stretch; + buttonRemove.Location = new Point(25, 112); + buttonRemove.Name = "buttonRemove"; + buttonRemove.Size = new Size(66, 61); + buttonRemove.TabIndex = 1; + buttonRemove.UseVisualStyleBackColor = true; + buttonRemove.Click += ButtonRemove_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(25, 28); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(66, 57); + 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.BackgroundColor = Color.Gray; + 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(1049, 534); + dataGridView.TabIndex = 1; + // + // FormTimeTables + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1169, 534); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormTimeTables"; + StartPosition = FormStartPosition.CenterParent; + Text = "Расписание"; + Load += FormTimeTables_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private DataGridView dataGridView; + private Button buttonRemove; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTables.cs b/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTables.cs new file mode 100644 index 0000000..766806e --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTables.cs @@ -0,0 +1,97 @@ +using ProjectTimeTable.Repositories; +using ProjectTimeTable.Repositories.Implementation; +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 ProjectTimeTable.Forms +{ + public partial class FormTimeTables : Form + { + private readonly IUnityContainer _container; + private readonly ITimeTableRepositories _timeTableRepository; + public FormTimeTables(IUnityContainer container, ITimeTableRepositories timeTablesRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _timeTableRepository = timeTablesRepository ?? throw new ArgumentNullException(nameof(timeTablesRepository)); + } + + private void FormTimeTables_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridView.DataSource = _timeTableRepository.ReadTimeTable(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + + 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 ButtonRemove_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + try + { + _timeTableRepository.DeleteTimeTable(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTables.resx b/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTables.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Forms/FormTimeTables.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/ProjectTimeTable/ProjectTimeTable/Program.cs b/ProjectTimeTable/ProjectTimeTable/Program.cs index 8cdf907..f275dce 100644 --- a/ProjectTimeTable/ProjectTimeTable/Program.cs +++ b/ProjectTimeTable/ProjectTimeTable/Program.cs @@ -1,3 +1,7 @@ +using ProjectTimeTable.Repositories; +using ProjectTimeTable.Repositories.Implementation; +using Unity; + namespace ProjectTimeTable { internal static class Program @@ -11,7 +15,20 @@ namespace ProjectTimeTable // 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(); + return container; + } } } \ No newline at end of file diff --git a/ProjectTimeTable/ProjectTimeTable/ProjectTimeTable.csproj b/ProjectTimeTable/ProjectTimeTable/ProjectTimeTable.csproj index 663fdb8..1bfb289 100644 --- a/ProjectTimeTable/ProjectTimeTable/ProjectTimeTable.csproj +++ b/ProjectTimeTable/ProjectTimeTable/ProjectTimeTable.csproj @@ -8,4 +8,27 @@ enable + + + + + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/ProjectTimeTable/ProjectTimeTable/Properties/Resources.Designer.cs b/ProjectTimeTable/ProjectTimeTable/Properties/Resources.Designer.cs new file mode 100644 index 0000000..a0dbd6e --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectTimeTable.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("ProjectTimeTable.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 add { + get { + object obj = ResourceManager.GetObject("add", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap red { + get { + object obj = ResourceManager.GetObject("red", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap remove { + get { + object obj = ResourceManager.GetObject("remove", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ulgtu { + get { + object obj = ResourceManager.GetObject("ulgtu", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Properties/Resources.resx b/ProjectTimeTable/ProjectTimeTable/Properties/Resources.resx new file mode 100644 index 0000000..c285c85 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/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\ulgtu.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\red.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\remove.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\add.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ProjectTimeTable/ProjectTimeTable/Repositories/IAuditoriumRepositories.cs b/ProjectTimeTable/ProjectTimeTable/Repositories/IAuditoriumRepositories.cs new file mode 100644 index 0000000..9cf6575 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Repositories/IAuditoriumRepositories.cs @@ -0,0 +1,23 @@ +using ProjectTimeTable.Entites; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Repositories; + +public interface IAuditoriumRepositories +{ + IEnumerable ReadAuditorium(); + + Auditorium ReadAuditoriumById(int id); + + void CreateAuditorium(Auditorium classs); + + void UpdateAuditorium(Auditorium classs); + + void DeleteAuditorium(int id); + + +} diff --git a/ProjectTimeTable/ProjectTimeTable/Repositories/IDisciplineRepositories.cs b/ProjectTimeTable/ProjectTimeTable/Repositories/IDisciplineRepositories.cs new file mode 100644 index 0000000..f4150e1 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Repositories/IDisciplineRepositories.cs @@ -0,0 +1,21 @@ +using ProjectTimeTable.Entites; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Repositories; + +public interface IDisciplineRepositories +{ + IEnumerable ReadDiscipline(); + + Discipline ReadDisciplineById(int id); + + void CreateDiscipline(Discipline discipline); + + void UpdateDiscipline(Discipline discipline); + + void DeleteDiscipline(int id); +} diff --git a/ProjectTimeTable/ProjectTimeTable/Repositories/IGroupRepositories.cs b/ProjectTimeTable/ProjectTimeTable/Repositories/IGroupRepositories.cs new file mode 100644 index 0000000..35ef25a --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Repositories/IGroupRepositories.cs @@ -0,0 +1,20 @@ +using ProjectTimeTable.Entites; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Repositories; + +public interface IGroupRepositories +{ + IEnumerable ReadGroup(); + Group ReadGroupById(int id); + + void CreateGroup(Group group); + + void UpdateGroup(Group group); + + void DeleteGroup(int id); +} diff --git a/ProjectTimeTable/ProjectTimeTable/Repositories/IPlanRepositories.cs b/ProjectTimeTable/ProjectTimeTable/Repositories/IPlanRepositories.cs new file mode 100644 index 0000000..051c0b5 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Repositories/IPlanRepositories.cs @@ -0,0 +1,18 @@ +using ProjectTimeTable.Entites; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Repositories; + +public interface IPlanRepositories +{ + IEnumerable ReadPlan(int? groupId = null, int? disciplineId=null); + Plan ReadPlanById(int id); + + void CreatePlan(Plan plan); + +} + diff --git a/ProjectTimeTable/ProjectTimeTable/Repositories/ITeacherRepositories.cs b/ProjectTimeTable/ProjectTimeTable/Repositories/ITeacherRepositories.cs new file mode 100644 index 0000000..6464a63 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Repositories/ITeacherRepositories.cs @@ -0,0 +1,20 @@ +using ProjectTimeTable.Entites; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Repositories; + +public interface ITeacherRepositories +{ + IEnumerable ReadTeacher(); + Teacher ReadTeacherById(int id); + + void CreateTeacher(Teacher teacher); + + void UpdateTeacher(Teacher teacher); + + void DeleteTeacher(int id); +} diff --git a/ProjectTimeTable/ProjectTimeTable/Repositories/ITimeTableRepositories.cs b/ProjectTimeTable/ProjectTimeTable/Repositories/ITimeTableRepositories.cs new file mode 100644 index 0000000..3ef1080 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Repositories/ITimeTableRepositories.cs @@ -0,0 +1,17 @@ +using ProjectTimeTable.Entites; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Repositories; + +public interface ITimeTableRepositories +{ + IEnumerable ReadTimeTable(int? week=null, int? day=null, int? groupId = null, int? classId = null, int? teacherId = null); + + void CreateTimeTable(TimeTable timeTable); + + void DeleteTimeTable(int id); +} diff --git a/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/AuditoriumRepositories.cs b/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/AuditoriumRepositories.cs new file mode 100644 index 0000000..6bf515c --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/AuditoriumRepositories.cs @@ -0,0 +1,31 @@ +using ProjectTimeTable.Entites; +using ProjectTimeTable.Entites.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Repositories.Implementation; +public class AuditoriumRepositories : IAuditoriumRepositories +{ + public void CreateAuditorium(Auditorium classs) + { + } + + public void DeleteAuditorium(int id) + { + } + + public IEnumerable ReadAuditorium() + { + return []; + } + + public Auditorium ReadAuditoriumById(int id) { return Auditorium.CreateEntity(0, string.Empty, ClassType.None, 0); } + + + public void UpdateAuditorium(Auditorium classs) + { + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/DisciplineRepositories.cs b/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/DisciplineRepositories.cs new file mode 100644 index 0000000..ab75ba0 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/DisciplineRepositories.cs @@ -0,0 +1,33 @@ +using ProjectTimeTable.Entites; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Repositories.Implementation; + +public class DisciplineRepositories : IDisciplineRepositories +{ + public void CreateDiscipline(Discipline discipline) + { + } + + public void DeleteDiscipline(int id) + { + } + + public IEnumerable ReadDiscipline() + { + return []; + } + + public Discipline ReadDisciplineById(int id) + { + return Discipline.CreateEntity(0, string.Empty); + } + + public void UpdateDiscipline(Discipline discipline) + { + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/GroupRepositories.cs b/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/GroupRepositories.cs new file mode 100644 index 0000000..8af9593 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/GroupRepositories.cs @@ -0,0 +1,33 @@ +using ProjectTimeTable.Entites; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Repositories.Implementation; + +public class GroupRepositories : IGroupRepositories +{ + public void CreateGroup(Group group) + { + } + + public void DeleteGroup(int id) + { + } + + public IEnumerable ReadGroup() + { + return []; + } + + public Group ReadGroupById(int id) + { + return Group.CreateEntity(0, string.Empty, 0, 0, 0); + } + + public void UpdateGroup(Group group) + { + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/PlanRepositories.cs b/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/PlanRepositories.cs new file mode 100644 index 0000000..c6de4c0 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/PlanRepositories.cs @@ -0,0 +1,26 @@ +using ProjectTimeTable.Entites; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Repositories.Implementation; + +public class PlanRepositories : IPlanRepositories +{ + public void CreatePlan(Plan plan) + { + } + + public IEnumerable ReadPlan(int? groupId = null, int? disciplineId = null) + { + return []; + } + + public Plan ReadPlanById(int id) + { + return Plan.CreateOperation(0, string.Empty,[]); + + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/TeacherRepositories.cs b/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/TeacherRepositories.cs new file mode 100644 index 0000000..25f0010 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/TeacherRepositories.cs @@ -0,0 +1,34 @@ +using ProjectTimeTable.Entites; +using ProjectTimeTable.Entites.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Repositories.Implementation; + +public class TeacherRepositories : ITeacherRepositories +{ + public void CreateTeacher(Teacher teacher) + { + } + + public void DeleteTeacher(int id) + { + } + + public IEnumerable ReadTeacher() + { + return []; + } + + public Teacher ReadTeacherById(int id) + { + return Teacher.CreateEntity(0, string.Empty, string.Empty, string.Empty, TeacherPost.None); + } + + public void UpdateTeacher(Teacher teacher) + { + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/TimeTableRepositories.cs b/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/TimeTableRepositories.cs new file mode 100644 index 0000000..4f8c545 --- /dev/null +++ b/ProjectTimeTable/ProjectTimeTable/Repositories/Implementation/TimeTableRepositories.cs @@ -0,0 +1,24 @@ +using ProjectTimeTable.Entites; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectTimeTable.Repositories.Implementation; + +public class TimeTableRepositories : ITimeTableRepositories +{ + public void CreateTimeTable(TimeTable timeTable) + { + } + + public void DeleteTimeTable(int id) + { + } + + public IEnumerable ReadTimeTable(int? week = null, int? day = null, int? groupId = null, int? classId = null, int? teacherId = null) + { + return []; + } +} diff --git a/ProjectTimeTable/ProjectTimeTable/Resources/add.jpg b/ProjectTimeTable/ProjectTimeTable/Resources/add.jpg new file mode 100644 index 0000000..f480d64 Binary files /dev/null and b/ProjectTimeTable/ProjectTimeTable/Resources/add.jpg differ diff --git a/ProjectTimeTable/ProjectTimeTable/Resources/red.png b/ProjectTimeTable/ProjectTimeTable/Resources/red.png new file mode 100644 index 0000000..8cdd191 Binary files /dev/null and b/ProjectTimeTable/ProjectTimeTable/Resources/red.png differ diff --git a/ProjectTimeTable/ProjectTimeTable/Resources/remove.png b/ProjectTimeTable/ProjectTimeTable/Resources/remove.png new file mode 100644 index 0000000..ff24015 Binary files /dev/null and b/ProjectTimeTable/ProjectTimeTable/Resources/remove.png differ diff --git a/ProjectTimeTable/ProjectTimeTable/Resources/ulgtu.jpg b/ProjectTimeTable/ProjectTimeTable/Resources/ulgtu.jpg new file mode 100644 index 0000000..1f0a4bb Binary files /dev/null and b/ProjectTimeTable/ProjectTimeTable/Resources/ulgtu.jpg differ