2025-06-09 15:55:31 +00:00
|
|
|
using System;
|
2025-04-11 10:14:28 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.Linq;
|
|
|
|
using Avalonia;
|
|
|
|
using Avalonia.Controls;
|
|
|
|
using Avalonia.Interactivity;
|
|
|
|
using Avalonia.Markup.Xaml;
|
|
|
|
using kursovaya.Models;
|
2025-06-09 20:05:33 +00:00
|
|
|
using kursovaya.ModelsLocal;
|
2025-04-11 10:14:28 +00:00
|
|
|
|
|
|
|
namespace kursovaya;
|
|
|
|
|
|
|
|
public partial class AdminWindow : Window
|
|
|
|
{
|
|
|
|
List<Discipline> Disciplines = new List<Discipline>();
|
|
|
|
List<Group> Groups = new List<Group>();
|
|
|
|
List<Teacher> Teachers = new List<Teacher>();
|
2025-06-09 20:05:33 +00:00
|
|
|
|
|
|
|
public List<DisciplineGroupTeacher> dataSourceDisciplineGroupTeachers = new List<DisciplineGroupTeacher>();
|
|
|
|
public ObservableCollection<DisciplineGroupTeacher> DisciplineGroupTeachers = new ObservableCollection<DisciplineGroupTeacher>();
|
2025-04-11 10:14:28 +00:00
|
|
|
public AdminWindow()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
var ctx = new DatabaseContext();
|
|
|
|
|
|
|
|
Disciplines = ctx.Disciplines.ToList();
|
|
|
|
Groups = ctx.Groups.ToList();
|
|
|
|
Teachers = ctx.Teachers.ToList();
|
|
|
|
|
|
|
|
var disciplineTeachers = ctx.DisciplineTeachers.ToList();
|
|
|
|
|
|
|
|
foreach (DisciplineTeacher disciplineTeacher in disciplineTeachers)
|
|
|
|
{
|
|
|
|
var teacher = ctx.Teachers.FirstOrDefault(t => t.Id == disciplineTeacher.IdTeacher);
|
|
|
|
var discipline = ctx.Disciplines.FirstOrDefault(d => d.Id == disciplineTeacher.IdDiscipline);
|
2025-06-09 15:55:31 +00:00
|
|
|
var groups = ctx.Groups.Where(g => ctx.Attestations.Any(at => ctx.Students.Any(s => s.Id == at.IdUser && s.IdGroup == g.Id) && at.IdDiscipline == discipline.Id));
|
|
|
|
foreach (Group group in groups)
|
|
|
|
{
|
2025-06-09 20:05:33 +00:00
|
|
|
dataSourceDisciplineGroupTeachers.Add(new DisciplineGroupTeacher(){Teacher = teacher, Discipline = discipline, Group = group});
|
2025-06-09 15:55:31 +00:00
|
|
|
}
|
2025-04-11 10:14:28 +00:00
|
|
|
}
|
|
|
|
|
2025-06-09 20:05:33 +00:00
|
|
|
DisplayAll();
|
|
|
|
|
2025-06-09 15:55:31 +00:00
|
|
|
MultComboBox.ItemsSource = DisciplineGroupTeachers.Select(dg => dg.NameComboBox).ToList();
|
2025-04-11 10:14:28 +00:00
|
|
|
FlatGrid.ItemsSource = DisciplineGroupTeachers;
|
|
|
|
}
|
2025-06-09 20:05:33 +00:00
|
|
|
|
|
|
|
public void DisplayAll()
|
2025-04-11 10:14:28 +00:00
|
|
|
{
|
2025-06-09 20:05:33 +00:00
|
|
|
var ctx = new DatabaseContext();
|
|
|
|
var temp = dataSourceDisciplineGroupTeachers;
|
|
|
|
DisciplineGroupTeachers.Clear();
|
|
|
|
|
|
|
|
foreach (var item in temp)
|
2025-04-11 10:14:28 +00:00
|
|
|
{
|
2025-06-09 20:05:33 +00:00
|
|
|
DisciplineGroupTeachers.Add(item);
|
2025-06-09 15:55:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Display()
|
|
|
|
{
|
|
|
|
if (MultComboBox.SelectionBoxItem != null)
|
|
|
|
{
|
|
|
|
var selectedDiscGroupTeacher = DisciplineGroupTeachers.FirstOrDefault(dg => dg.NameComboBox == MultComboBox.SelectedItem.ToString());
|
|
|
|
var filteredData = DisciplineGroupTeachers.Where(dg => dg.Discipline.Name == selectedDiscGroupTeacher.Discipline.Name && dg.Group.Id == selectedDiscGroupTeacher.Group.Id && dg.Teacher.Fio == selectedDiscGroupTeacher.Teacher.Fio).ToList();
|
|
|
|
FlatGrid.ItemsSource = filteredData;
|
2025-04-11 10:14:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ButtonBack_OnClick(object? sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
Close();
|
|
|
|
}
|
2025-06-09 15:55:31 +00:00
|
|
|
|
|
|
|
private void ButtonCheck_OnClick(object? sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
Display();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ButtonCheckGroups_OnClick(object? sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
GroupsFromAdminWindow groupsFromAdminWindow = new GroupsFromAdminWindow();
|
|
|
|
groupsFromAdminWindow.ShowDialog(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ButtonCheckStudents_OnClick(object? sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
StudentsFromAdminWindow studentsFromAdminWindow = new StudentsFromAdminWindow();
|
|
|
|
studentsFromAdminWindow.ShowDialog(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
private async void ButtonCheckTeachers_OnClick(object? sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
TeachersFromAdminWindow teachersFromAdminWindow = new TeachersFromAdminWindow();
|
2025-06-09 20:05:33 +00:00
|
|
|
var result = await teachersFromAdminWindow.ShowDialog<List<DisciplineGroupTeacher>>(this);
|
|
|
|
|
|
|
|
dataSourceDisciplineGroupTeachers.AddRange(result);
|
|
|
|
DisplayAll();
|
2025-06-09 15:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void ButtonCheckDiscipline_OnClick(object? sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
AddDiscipline addDiscipline = new AddDiscipline();
|
|
|
|
addDiscipline.ShowDialog(this);
|
|
|
|
}
|
|
|
|
}
|