Улучшайзинги 1
This commit is contained in:
parent
8ff8fd8444
commit
f64f34aadd
@ -1,12 +1,19 @@
|
|||||||
using ProjectShedule.Entities.Enums;
|
using ProjectShedule.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectShedule.Entities;
|
namespace ProjectShedule.Entities;
|
||||||
|
|
||||||
public class Classroom
|
public class Classroom
|
||||||
{
|
{
|
||||||
public int Id { get;private set; }
|
public int Id { get;private set; }
|
||||||
|
|
||||||
|
[DisplayName ("Вместимость")]
|
||||||
public int Size { get; private set; }
|
public int Size { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Номер аудитории")]
|
||||||
public string Name { get; private set; } = String.Empty;
|
public string Name { get; private set; } = String.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Тип аудитории")]
|
||||||
public ClassType ClassType { get; private set; }
|
public ClassType ClassType { get; private set; }
|
||||||
|
|
||||||
public static Classroom CreateClassroom(int id, int size, string name, ClassType classtype)
|
public static Classroom CreateClassroom(int id, int size, string name, ClassType classtype)
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
namespace ProjectShedule.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProjectShedule.Entities;
|
||||||
|
|
||||||
public class Curriculum
|
public class Curriculum
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Направление")]
|
||||||
public string Direction { get; private set; } = string.Empty;
|
public string Direction { get; private set; } = string.Empty;
|
||||||
public static Curriculum CreateCurriculum(int id, string direction)
|
public static Curriculum CreateCurriculum(int id, string direction)
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,30 @@
|
|||||||
using ProjectShedule.Entities.Enums;
|
using ProjectShedule.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectShedule.Entities;
|
namespace ProjectShedule.Entities;
|
||||||
|
|
||||||
public class CurriculumSubject
|
public class CurriculumSubject
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Дата составления")]
|
||||||
public DateTime Date { get; private set; }
|
public DateTime Date { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int CurriculumId { get; private set; }
|
public int CurriculumId { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Направление")]
|
||||||
|
public string CurriculumName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Предметы")]
|
||||||
|
public string Subject => SubjectSubject != null ?
|
||||||
|
string.Join(", ",SubjectSubject.Select(x => $"{x.SubjectName} {x.LessonsCount}")) :
|
||||||
|
string.Empty;
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public IEnumerable<SubjectSubject> SubjectSubject { get; private set; } = [];
|
public IEnumerable<SubjectSubject> SubjectSubject { get; private set; } = [];
|
||||||
|
|
||||||
|
[DisplayName("Курс")]
|
||||||
public Course Course { get; private set; }
|
public Course Course { get; private set; }
|
||||||
|
|
||||||
public static CurriculumSubject CreateCurriculumSubject(int id, DateTime date, int curriculumId, Course course, IEnumerable<SubjectSubject> subjectSubjects)
|
public static CurriculumSubject CreateCurriculumSubject(int id, DateTime date, int curriculumId, Course course, IEnumerable<SubjectSubject> subjectSubjects)
|
||||||
@ -21,15 +38,11 @@ public class CurriculumSubject
|
|||||||
SubjectSubject = subjectSubjects
|
SubjectSubject = subjectSubjects
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public static CurriculumSubject CreateCurriculumSubject(TempCurriculumSubject tempCurriculumSubject, IEnumerable<SubjectSubject> subjectSubject)
|
public void SetSubjectSubject(IEnumerable<SubjectSubject> subjectSubject)
|
||||||
{
|
{
|
||||||
return new CurriculumSubject
|
if (subjectSubject != null && subjectSubject.Any())
|
||||||
{
|
{
|
||||||
Id = tempCurriculumSubject.Id,
|
SubjectSubject = subjectSubject;
|
||||||
Date = tempCurriculumSubject.Date,
|
}
|
||||||
CurriculumId = tempCurriculumSubject.CurriculumId,
|
|
||||||
Course = tempCurriculumSubject.Course,
|
|
||||||
SubjectSubject = subjectSubject
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace ProjectShedule.Entities.Enums;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectShedule.Entities.Enums;
|
|
||||||
|
|
||||||
public enum ClassType
|
public enum ClassType
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace ProjectShedule.Entities.Enums;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectShedule.Entities.Enums;
|
|
||||||
|
|
||||||
public enum Course
|
public enum Course
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace ProjectShedule.Entities.Enums;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectShedule.Entities.Enums;
|
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum PairNumber
|
public enum PairNumber
|
||||||
|
@ -1,18 +1,48 @@
|
|||||||
using ProjectShedule.Entities.Enums;
|
using System.ComponentModel;
|
||||||
|
using ProjectShedule.Entities.Enums;
|
||||||
|
|
||||||
namespace ProjectShedule.Entities;
|
namespace ProjectShedule.Entities;
|
||||||
|
|
||||||
public class Shedule
|
public class Shedule
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
[DisplayName("Дата")]
|
||||||
public DateTime Date { get; private set; }
|
public DateTime Date { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
[DisplayName("Номера пар")]
|
||||||
public PairNumber PairNumber { get; private set; }
|
public PairNumber PairNumber { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
[DisplayName("Количество пар")]
|
||||||
public int PairCount { get; private set; }
|
public int PairCount { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int StudentsGroupId { get; private set; }
|
public int StudentsGroupId { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int TeacherId { get; private set; }
|
public int TeacherId { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int SubjectId { get; private set; }
|
public int SubjectId { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int ClassroomId { get; private set; }
|
public int ClassroomId { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Грппа студентов")]
|
||||||
|
public string StudentsGroupName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Преподаватель")]
|
||||||
|
public string TeacherName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Предмет")]
|
||||||
|
public string SubjectName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Аудитория")]
|
||||||
|
public string ClassroomName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
public static Shedule CreateOperation(int id, DateTime date, PairNumber pairNumber, int pairCount
|
public static Shedule CreateOperation(int id, DateTime date, PairNumber pairNumber, int pairCount
|
||||||
, int studentsGroupId, int teacherId, int subjectId, int classroomId)
|
, int studentsGroupId, int teacherId, int subjectId, int classroomId)
|
||||||
|
@ -1,14 +1,27 @@
|
|||||||
using ProjectShedule.Entities.Enums;
|
using ProjectShedule.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectShedule.Entities;
|
namespace ProjectShedule.Entities;
|
||||||
|
|
||||||
public class StudentsGroup
|
public class StudentsGroup
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Количество студентов")]
|
||||||
public int StudentsCount { get; private set; }
|
public int StudentsCount { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Номер группы")]
|
||||||
public string GroupNumber { get; private set; } = String.Empty;
|
public string GroupNumber { get; private set; } = String.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Курс")]
|
||||||
public Course Course { get; private set; }
|
public Course Course { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int CurriculumId { get; private set; }
|
public int CurriculumId { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Направление")]
|
||||||
|
public string CurriculumName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public static StudentsGroup CreateGroup(int id, int studentsCount, string groupNumber, Course course, int curriculumId)
|
public static StudentsGroup CreateGroup(int id, int studentsCount, string groupNumber, Course course, int curriculumId)
|
||||||
{
|
{
|
||||||
return new StudentsGroup
|
return new StudentsGroup
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
namespace ProjectShedule.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProjectShedule.Entities;
|
||||||
|
|
||||||
public class Subject
|
public class Subject
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Название предмета")]
|
||||||
public string Name { get; private set; } = String.Empty;
|
public string Name { get; private set; } = String.Empty;
|
||||||
public static Subject CreateSubject(int id, string name)
|
public static Subject CreateSubject(int id, string name)
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
|
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ProjectShedule.Entities;
|
namespace ProjectShedule.Entities;
|
||||||
|
|
||||||
public class SubjectSubject
|
public class SubjectSubject
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
public int SubjectId { get; private set; }
|
public int SubjectId { get; private set; }
|
||||||
|
|
||||||
public int LessonsCount { get; private set; }
|
public int LessonsCount { get; private set; }
|
||||||
|
|
||||||
|
public string SubjectName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public static SubjectSubject CreateOperation(int id, int subjectId, int lessonsCount)
|
public static SubjectSubject CreateOperation(int id, int subjectId, int lessonsCount)
|
||||||
{
|
{
|
||||||
return new SubjectSubject
|
return new SubjectSubject
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
namespace ProjectShedule.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProjectShedule.Entities;
|
||||||
|
|
||||||
public class Teacher
|
public class Teacher
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Имя")]
|
||||||
public string FirstName { get; private set; } = string.Empty;
|
public string FirstName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Фамилия")]
|
||||||
public string LastName { get; private set; } = string.Empty;
|
public string LastName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string FullName => $"{FirstName} {LastName}";
|
||||||
public static Teacher CreateTeacher(int id, string firstName, string lastName)
|
public static Teacher CreateTeacher(int id, string firstName, string lastName)
|
||||||
{
|
{
|
||||||
return new Teacher
|
return new Teacher
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
using ProjectShedule.Entities.Enums;
|
|
||||||
|
|
||||||
namespace ProjectShedule.Entities;
|
|
||||||
|
|
||||||
public class TempCurriculumSubject
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public DateTime Date { get; private set; }
|
|
||||||
public int CurriculumId { get; private set; }
|
|
||||||
public int SubjectId { get; private set; }
|
|
||||||
public int LessonsCount { get; private set; }
|
|
||||||
public Course Course { get; private set; }
|
|
||||||
}
|
|
@ -87,9 +87,9 @@
|
|||||||
dataGridView.AllowUserToDeleteRows = false;
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
dataGridView.AllowUserToResizeColumns = false;
|
dataGridView.AllowUserToResizeColumns = false;
|
||||||
dataGridView.AllowUserToResizeRows = false;
|
dataGridView.AllowUserToResizeRows = false;
|
||||||
|
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Dock = DockStyle.Fill;
|
|
||||||
dataGridView.Location = new Point(0, 0);
|
dataGridView.Location = new Point(0, 0);
|
||||||
dataGridView.MultiSelect = false;
|
dataGridView.MultiSelect = false;
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
|
@ -79,7 +79,11 @@ namespace ProjectShedule.Forms
|
|||||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridView.DataSource = _classroomRepository.ReadClassroom();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = _classroomRepository.ReadClassroom();
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -74,6 +74,7 @@
|
|||||||
dataGridView.AllowUserToDeleteRows = false;
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
dataGridView.AllowUserToResizeColumns = false;
|
dataGridView.AllowUserToResizeColumns = false;
|
||||||
dataGridView.AllowUserToResizeRows = false;
|
dataGridView.AllowUserToResizeRows = false;
|
||||||
|
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Location = new Point(0, 0);
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
@ -40,7 +40,12 @@ namespace ProjectShedule.Forms
|
|||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridView.DataSource = _curriculumSubjectRepository.ReadCurriculumSubject();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = _curriculumSubjectRepository.ReadCurriculumSubject();
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["Date"].DefaultCellStyle.Format = "dd MMMM yyyy";
|
||||||
|
}
|
||||||
|
|
||||||
private void buttonDel_Click(object sender, EventArgs e)
|
private void buttonDel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -87,6 +87,7 @@
|
|||||||
dataGridView.AllowUserToDeleteRows = false;
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
dataGridView.AllowUserToResizeColumns = false;
|
dataGridView.AllowUserToResizeColumns = false;
|
||||||
dataGridView.AllowUserToResizeRows = false;
|
dataGridView.AllowUserToResizeRows = false;
|
||||||
|
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Location = new Point(0, 0);
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
@ -80,7 +80,12 @@ namespace ProjectShedule.Forms
|
|||||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridView.DataSource = _curriculumRepository.ReadCurriculum();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = _curriculumRepository.ReadCurriculum();
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
|
@ -87,6 +87,7 @@
|
|||||||
dataGridView.AllowUserToDeleteRows = false;
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
dataGridView.AllowUserToResizeColumns = false;
|
dataGridView.AllowUserToResizeColumns = false;
|
||||||
dataGridView.AllowUserToResizeRows = false;
|
dataGridView.AllowUserToResizeRows = false;
|
||||||
|
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Location = new Point(0, 0);
|
dataGridView.Location = new Point(0, 0);
|
||||||
@ -96,7 +97,7 @@
|
|||||||
dataGridView.RowHeadersVisible = false;
|
dataGridView.RowHeadersVisible = false;
|
||||||
dataGridView.RowHeadersWidth = 51;
|
dataGridView.RowHeadersWidth = 51;
|
||||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridView.Size = new Size(626, 354);
|
dataGridView.Size = new Size(627, 354);
|
||||||
dataGridView.TabIndex = 5;
|
dataGridView.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// FormGroups
|
// FormGroups
|
||||||
|
@ -79,7 +79,11 @@ namespace ProjectShedule.Forms
|
|||||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridView.DataSource = _groupRepository.ReadGroup();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = _groupRepository.ReadGroup();
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,7 @@ namespace ProjectShedule.Forms
|
|||||||
comboBoxGroup.ValueMember = "Id";
|
comboBoxGroup.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxTeacher.DataSource = teacherRepository.ReadTeacher();
|
comboBoxTeacher.DataSource = teacherRepository.ReadTeacher();
|
||||||
comboBoxTeacher.DisplayMember = "LastName";
|
comboBoxTeacher.DisplayMember = "FullName";
|
||||||
comboBoxTeacher.ValueMember = "Id";
|
comboBoxTeacher.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxSubject.DataSource = subjectRepository.ReadSubject();
|
comboBoxSubject.DataSource = subjectRepository.ReadSubject();
|
||||||
|
@ -42,7 +42,12 @@ namespace ProjectShedule.Forms
|
|||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridView.DataSource = _sheduleRepository.ReadShedule();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = _sheduleRepository.ReadShedule();
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["Date"].DefaultCellStyle.Format = "dd MMMM yyyy";
|
||||||
|
}
|
||||||
|
|
||||||
private void buttonDel_Click(object sender, EventArgs e)
|
private void buttonDel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -87,9 +87,10 @@
|
|||||||
dataGridView.AllowUserToDeleteRows = false;
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
dataGridView.AllowUserToResizeColumns = false;
|
dataGridView.AllowUserToResizeColumns = false;
|
||||||
dataGridView.AllowUserToResizeRows = false;
|
dataGridView.AllowUserToResizeRows = false;
|
||||||
|
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Location = new Point(0, 0);
|
dataGridView.Location = new Point(3, 12);
|
||||||
dataGridView.MultiSelect = false;
|
dataGridView.MultiSelect = false;
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView.ReadOnly = true;
|
dataGridView.ReadOnly = true;
|
||||||
|
@ -79,7 +79,12 @@ namespace ProjectShedule.Forms
|
|||||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridView.DataSource = _subjectRepository.ReadSubject();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = _subjectRepository.ReadSubject();
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
|
@ -87,9 +87,9 @@
|
|||||||
dataGridView.AllowUserToDeleteRows = false;
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
dataGridView.AllowUserToResizeColumns = false;
|
dataGridView.AllowUserToResizeColumns = false;
|
||||||
dataGridView.AllowUserToResizeRows = false;
|
dataGridView.AllowUserToResizeRows = false;
|
||||||
|
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Dock = DockStyle.Fill;
|
|
||||||
dataGridView.Location = new Point(0, 0);
|
dataGridView.Location = new Point(0, 0);
|
||||||
dataGridView.MultiSelect = false;
|
dataGridView.MultiSelect = false;
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
@ -97,7 +97,7 @@
|
|||||||
dataGridView.RowHeadersVisible = false;
|
dataGridView.RowHeadersVisible = false;
|
||||||
dataGridView.RowHeadersWidth = 51;
|
dataGridView.RowHeadersWidth = 51;
|
||||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridView.Size = new Size(800, 353);
|
dataGridView.Size = new Size(625, 353);
|
||||||
dataGridView.TabIndex = 3;
|
dataGridView.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// FormTeachers
|
// FormTeachers
|
||||||
|
@ -79,7 +79,13 @@ namespace ProjectShedule.Forms
|
|||||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridView.DataSource = _teacherRepository.ReadTeacher();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = _teacherRepository.ReadTeacher();
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["FullName"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
|
@ -81,19 +81,46 @@ public class CurriculumSubjectRepository : ICurriculumSubjectRepository
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public IEnumerable<CurriculumSubject> ReadCurriculumSubject(DateTime? dateForm = null, DateTime? dateTo = null, int? subjectId = null)
|
public IEnumerable<CurriculumSubject> ReadCurriculumSubject(DateTime? dateFrom = null, DateTime? dateTo = null, int? subjectId = null)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Получение всех объектов");
|
_logger.LogInformation("Получение всех объектов");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"SELECT cs.*, ss.SubjectId, ss.LessonsCount FROM CurriculumSubject cs
|
var querySelect = $@"SELECT
|
||||||
INNER JOIN SubjectSubject ss on ss.CurriculumSubjectId = cs.Id";
|
cs.*,
|
||||||
var curriculumSubjects = connection.Query<TempCurriculumSubject>(querySelect);
|
c.Direction as CurriculumName,
|
||||||
|
ss.SubjectId,
|
||||||
|
ss.LessonsCount,
|
||||||
|
s.Name as SubjectName
|
||||||
|
FROM CurriculumSubject cs
|
||||||
|
LEFT JOIN Curriculum c on c.Id = cs.CurriculumId
|
||||||
|
INNER JOIN SubjectSubject ss on ss.CurriculumSubjectId = cs.Id
|
||||||
|
LEFT JOIN Subject s on s.Id = ss.SubjectId";
|
||||||
|
// {builder.Build()}";
|
||||||
|
var subjectsDict = new Dictionary<int, List<SubjectSubject>>();
|
||||||
|
|
||||||
|
var curriculumSubjects = connection.Query<CurriculumSubject, SubjectSubject, CurriculumSubject>(querySelect,
|
||||||
|
(subject, curriculumSubject) =>
|
||||||
|
{
|
||||||
|
if (!subjectsDict.TryGetValue(subject.Id, out var cs))
|
||||||
|
{
|
||||||
|
cs = [];
|
||||||
|
subjectsDict.Add(subject.Id, cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
cs.Add(curriculumSubject);
|
||||||
|
return subject;
|
||||||
|
}, splitOn: "SubjectId", param: new { dateFrom, dateTo, subjectId });
|
||||||
_logger.LogDebug("Полученные объекты: {json}",
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
JsonConvert.SerializeObject(curriculumSubjects));
|
JsonConvert.SerializeObject(curriculumSubjects));
|
||||||
return curriculumSubjects.GroupBy(x => x.Id, y => y, (key, value) => CurriculumSubject.CreateCurriculumSubject(value.First(),
|
|
||||||
value.Select(z => SubjectSubject.CreateOperation(0, z.SubjectId, z.LessonsCount)))).ToList();
|
return subjectsDict.Select(x =>
|
||||||
|
{
|
||||||
|
var ss = curriculumSubjects.First(y => y.Id == x.Key);
|
||||||
|
ss.SetSubjectSubject(x.Value);
|
||||||
|
return ss;
|
||||||
|
}).ToArray();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,12 @@ public class GroupRepository : IGroupRepository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM StudentsGroup";
|
var querySelect = @"SELECT
|
||||||
|
sg.*,
|
||||||
|
cn.Direction as CurriculumName
|
||||||
|
FROM StudentsGroup sg
|
||||||
|
LEFT JOIN Curriculum cn on cn.Id = sg.CurriculumId
|
||||||
|
";
|
||||||
var groups = connection.Query<StudentsGroup>(querySelect);
|
var groups = connection.Query<StudentsGroup>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}",
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
JsonConvert.SerializeObject(groups));
|
JsonConvert.SerializeObject(groups));
|
||||||
|
@ -59,7 +59,18 @@ public class SheduleRepository : ISheduleRepository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM Shedule";
|
var querySelect = @"SELECT
|
||||||
|
sh.*,
|
||||||
|
s.GroupNumber as StudentsGroupName,
|
||||||
|
CONCAT(t.LastName, ' ', t.FirstName) as TeacherName,
|
||||||
|
su.Name as SubjectName,
|
||||||
|
c.Name as ClassroomName
|
||||||
|
FROM Shedule sh
|
||||||
|
LEFT JOIN StudentsGroup s on s.Id = sh.StudentsGroupId
|
||||||
|
LEFT JOIN Teacher t on t.Id = sh.TeacherId
|
||||||
|
LEFT JOIN Subject su on su.Id = sh.SubjectId
|
||||||
|
LEFT JOIN Classroom c on c.Id = sh.ClassroomId
|
||||||
|
";
|
||||||
var shedule = connection.Query<Shedule>(querySelect);
|
var shedule = connection.Query<Shedule>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}",
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
JsonConvert.SerializeObject(shedule));
|
JsonConvert.SerializeObject(shedule));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user