allWithoutDebug;withComments;withoutUpdatingAdminWindow

This commit is contained in:
Your Name 2025-06-09 18:55:31 +03:00
parent 248d3e25d2
commit c5083481c6
35 changed files with 1164 additions and 67 deletions

23
AddDiscipline.axaml Normal file
View File

@ -0,0 +1,23 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="kursovaya.AddDiscipline"
Title="AddDiscipline">
<Grid Background="Bisque">
<Button Content="Назад" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10" Width="60" Click="ButtonBack_OnClick" Background="LightGray" Foreground="Black"/>
<Border Width="200" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Spacing="10">
<TextBlock x:Name="SuccessMessage" Foreground="Green" FontSize="14" Height="40" Width="300" TextWrapping="Wrap" TextAlignment="Center"/>
<TextBox x:Name="DisciplineNameTextBox" Watermark="Имя"/>
<!-- <ComboBox x:Name="GroupsComboBox" HorizontalAlignment="Center" Margin="0, 0, 5, 0"/> -->
<ListBox x:Name="ListBoxGroups" Margin="0,10,0,0" SelectionMode="Multiple" Height="150"/>
<ComboBox x:Name="FormAttestComboBox" HorizontalAlignment="Center" Margin="0, 0, 5, 0"/>
<Button Click="ButtonAdd_OnClick" Foreground="Black" Background="LightGray" Content="Добавить"/>
<TextBlock x:Name="ErrorMessage" Foreground="Red" FontSize="14" Height="40" Width="300" TextWrapping="Wrap" TextAlignment="Center"/>
</StackPanel>
</Border>
</Grid>
</Window>

90
AddDiscipline.axaml.cs Normal file
View File

@ -0,0 +1,90 @@
using System.Collections.Generic;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using kursovaya.Models;
namespace kursovaya;
public partial class AddDiscipline : Window
{
List<Group> _groups = new List<Group>();
List<FormAttest> _formAttests = new List<FormAttest>();
List<Student> _students = new List<Student>();
Discipline _discipline = new Discipline();
Attestation _attestation = new Attestation();
CalculateGrade calculateGrade = new CalculateGrade();
public AddDiscipline()
{
InitializeComponent();
using var ctx = new DatabaseContext();
_groups = ctx.Groups.ToList();
_formAttests = ctx.FormAttests.ToList();
_students = ctx.Students.ToList();
ListBoxGroups.ItemsSource = _groups.Select(it => it.Id);
FormAttestComboBox.ItemsSource = _formAttests.Select(g => g.Name).ToList();
}
private void ButtonAdd_OnClick(object? sender, RoutedEventArgs e)
{
// if (string.IsNullOrWhiteSpace(ListBoxGroups.SelectedItem.ToString()) || string.IsNullOrWhiteSpace(DisciplineNameTextBox.Text) || string.IsNullOrWhiteSpace(FormAttestComboBox.SelectedItem.ToString()))
// {
// ErrorMessage.Text = "Поля не должны быть пустыми!";
// return;
// }
if (FormAttestComboBox.SelectedItem == null ||
ListBoxGroups.SelectedItems == null ||
ListBoxGroups.SelectedItems.Count == 0 ||
string.IsNullOrWhiteSpace(DisciplineNameTextBox?.Text))
{
ErrorMessage.Text = "Поля не должны быть пустыми!";
return;
}
var ctx = new DatabaseContext();
var disciplineName = DisciplineNameTextBox.Text;
var selectedGroupIds = ListBoxGroups.SelectedItems.Cast<int>();
var selectedFormAttestId = ctx.FormAttests.FirstOrDefault(f => f.Name == FormAttestComboBox.SelectedItem.ToString()).Id;
int lastDisciplineId = ctx.Disciplines.Max(u => u.Id);
_discipline = new Discipline(){ Id = lastDisciplineId + 1, Name = disciplineName, IdFormAttest = selectedFormAttestId };
ctx.Disciplines.Add(_discipline);
foreach (var groupId in selectedGroupIds)
{
_students = ctx.Students.Where(s => s.IdGroup == groupId).ToList();
foreach (var student in _students)
{
_attestation = new Attestation(){ IdUser = student.Id, IdDiscipline = lastDisciplineId+1, AttestFirst = 0, AttestSecond = 0, AttestThird = 0, Total = 0, Grade = calculateGrade.CalculateGradeMethod(0, selectedFormAttestId)};
ctx.Attestations.Add(_attestation);
}
}
var changes = ctx.SaveChanges();
if (changes > 0)
{
SuccessMessage.Text = "дисциплина успешно добавлена!";
if (ErrorMessage != null)
{
ErrorMessage.Text = "";
}
}
else
{
ErrorMessage.Text = "Не удалось добавить дисциплину.";
SuccessMessage.Text = "";
}
}
private void ButtonBack_OnClick(object? sender, RoutedEventArgs e)
{
Close();
}
}

21
AddGroup.axaml Normal file
View File

@ -0,0 +1,21 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="kursovaya.AddGroup"
Title="AddGroup">
<Grid Background="Bisque">
<Button Content="Назад" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10" Width="60" Click="ButtonBack_OnClick" Background="LightGray" Foreground="Black"/>
<Border Width="200" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Spacing="10">
<TextBlock x:Name="SuccessMessage" Foreground="Green" FontSize="14" Height="40" Width="300" TextWrapping="Wrap" TextAlignment="Center"/>
<TextBox x:Name="IdTextBox" Watermark="Id"/>
<TextBox x:Name="YearTextBox" Watermark="Год поступления"/>
<Button Click="ButtonAdd_OnClick" Foreground="Black" Background="LightGray" Content="Добавить"/>
<TextBlock x:Name="ErrorMessage" Foreground="Red" FontSize="14" Height="40" Width="300" TextWrapping="Wrap" TextAlignment="Center"/>
</StackPanel>
</Border>
</Grid>
</Window>

67
AddGroup.axaml.cs Normal file
View File

@ -0,0 +1,67 @@
using System.Collections.Generic;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using kursovaya.Models;
namespace kursovaya;
public partial class AddGroup : Window
{
List<Group> groups = new List<Group>();
Group group = new Group();
public AddGroup()
{
InitializeComponent();
}
private void ButtonAdd_OnClick(object? sender, RoutedEventArgs e)
{
var id = IdTextBox.Text;
var year = YearTextBox.Text;
if (string.IsNullOrWhiteSpace(id) || string.IsNullOrWhiteSpace(year))
{
ErrorMessage.Text = "Поля не должны быть пустыми!";
return;
}
int.TryParse(id, out int idInt);
int.TryParse(year, out int yearInt);
var ctx = new DatabaseContext();
if (ctx.Groups.Any(x => x.Id == idInt))
{
ErrorMessage.Text = "Такая группа уже существует";
return;
}
group = new Group() { Id = idInt, YearAdmission = yearInt };
ctx.Groups.Add(group);
var changes = ctx.SaveChanges();
if (changes > 0)
{
SuccessMessage.Text = "Группа успешно добавлена!";
if (ErrorMessage != null)
{
ErrorMessage.Text = "";
}
groups.Add(group);
}
else
{
ErrorMessage.Text = "Не удалось добавить группу.";
SuccessMessage.Text = "";
}
}
private void ButtonBack_OnClick(object? sender, RoutedEventArgs e)
{
Close(groups);
}
}

21
AddStudent.axaml Normal file
View File

@ -0,0 +1,21 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="kursovaya.AddStudent"
Title="AddStudent">
<Grid Background="Bisque">
<Button Content="Назад" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10" Width="60" Click="ButtonBack_OnClick" Background="LightGray" Foreground="Black"/>
<Border Width="200" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Spacing="10">
<TextBlock x:Name="SuccessMessage" Foreground="Green" FontSize="14" Height="40" Width="300" TextWrapping="Wrap" TextAlignment="Center"/>
<TextBox x:Name="FioTextBox" Watermark="ФИО"/>
<ComboBox x:Name="GroupsComboBox" HorizontalAlignment="Center" Margin="0, 0, 5, 0"/>
<Button Click="ButtonAdd_OnClick" Foreground="Black" Background="LightGray" Content="Добавить"/>
<TextBlock x:Name="ErrorMessage" Foreground="Red" FontSize="14" Height="40" Width="300" TextWrapping="Wrap" TextAlignment="Center"/>
</StackPanel>
</Border>
</Grid>
</Window>

78
AddStudent.axaml.cs Normal file
View File

@ -0,0 +1,78 @@
using System.Collections.Generic;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using kursovaya.Models;
namespace kursovaya;
public partial class AddStudent : Window
{
List<Group> _groups = new List<Group>();
Group group = new Group();
List<Student> students = new List<Student>();
Student student = new Student();
User user = new User();
public AddStudent()
{
InitializeComponent();
using var ctx = new DatabaseContext();
_groups = ctx.Groups.ToList();
GroupsComboBox.ItemsSource = _groups.Select(g => g.Id).ToList();
}
private void ButtonAdd_OnClick(object? sender, RoutedEventArgs e)
{
// if (string.IsNullOrWhiteSpace(GroupsComboBox.SelectedItem.ToString()) || string.IsNullOrWhiteSpace(FioTextBox.Text))
// {
// ErrorMessage.Text = "Поля не должны быть пустыми!";
// return;
// }
if (GroupsComboBox.SelectedItem == null ||
string.IsNullOrWhiteSpace(FioTextBox?.Text))
{
ErrorMessage.Text = "Поля не должны быть пустыми!";
return;
}
var fio = FioTextBox.Text;
var selectedGroupId = (int)GroupsComboBox.SelectedItem;
var ctx = new DatabaseContext();
int lastUserId = ctx.Users.Max(u => u.Id);
user = new User() {Id = lastUserId+1, Login = $"user{lastUserId+1}", Password = "qwerty", Email = $"user{lastUserId+1}@mail.ru", RoleId = 1};
student = new Student() {Id = lastUserId+1, Fio = fio, IdGroup = selectedGroupId, Login = $"user{lastUserId+1}"};
ctx.Users.Add(user);
ctx.Students.Add(student);
var changes = ctx.SaveChanges();
if (changes > 0)
{
SuccessMessage.Text = "Ученик успешно добавлен!";
if (ErrorMessage != null)
{
ErrorMessage.Text = "";
}
students.Add(student);
}
else
{
ErrorMessage.Text = "Не удалось добавить ученика.";
SuccessMessage.Text = "";
}
}
private void ButtonBack_OnClick(object? sender, RoutedEventArgs e)
{
Close(students);
}
}

28
AddTeacher.axaml Normal file
View File

@ -0,0 +1,28 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="kursovaya.AddTeacher"
x:CompileBindings="False"
Title="AddTeacher">
<Grid Background="Bisque">
<Button Content="Назад" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10" Width="60" Click="ButtonBack_OnClick" Background="LightGray" Foreground="Black"/>
<Border Width="200" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Spacing="10">
<TextBlock x:Name="SuccessMessage" Foreground="Green" FontSize="14" Height="40" Width="300" TextWrapping="Wrap" TextAlignment="Center"/>
<TextBox x:Name="TeacherNameTextBox" Watermark="Имя" Width="600"/>
<ListBox x:Name="ListBoxDisciplineGroup" Margin="0,10,0,0" SelectionMode="Multiple" Height="150" Width="600">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding DisciplineName}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Click="ButtonAdd_OnClick" Foreground="Black" Background="LightGray" Content="Добавить" HorizontalAlignment="Center"/>
<TextBlock x:Name="ErrorMessage" Foreground="Red" FontSize="14" Height="40" Width="300" TextWrapping="Wrap" TextAlignment="Center"/>
</StackPanel>
</Border>
</Grid>
</Window>

92
AddTeacher.axaml.cs Normal file
View File

@ -0,0 +1,92 @@
using System.Collections.Generic;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using kursovaya.Models;
namespace kursovaya;
public partial class AddTeacher : Window
{
List<DisciplinePresenter> _disciplinePresenters = new List<DisciplinePresenter>();
Teacher _teacher = new Teacher();
List<Teacher> _teachers = new List<Teacher>();
public AddTeacher()
{
InitializeComponent();
using var ctx = new DatabaseContext();
var disciplineTeachers = ctx.DisciplineTeachers.ToList();
_disciplinePresenters = ctx.Disciplines.Select(it => new DisciplinePresenter()
{
Discipline = it,
}).ToList();
// ListBoxDisciplineGroup.ItemsSource = _disciplineGroups.Select(it => it.NameComboBox);
ListBoxDisciplineGroup.ItemsSource = _disciplinePresenters;
}
private void ButtonAdd_OnClick(object? sender, RoutedEventArgs e)
{
if (ListBoxDisciplineGroup.SelectedItems == null ||
ListBoxDisciplineGroup.SelectedItems.Count == 0 ||
string.IsNullOrWhiteSpace(TeacherNameTextBox?.Text))
{
ErrorMessage.Text = "Поля не должны быть пустыми!";
return;
}
var ctx = new DatabaseContext();
var teacherName = TeacherNameTextBox.Text;
var selectedItems = ListBoxDisciplineGroup.SelectedItems.Cast<DisciplinePresenter>().ToList();
int lastUserId = ctx.Users.Max(u => u.Id);
int lastTeacherId = ctx.Teachers.Max(u => u.Id);
var user = new User(){ Id = lastUserId + 1, Login = $"user{lastUserId+1}", Password = "qwerty", Email = $"user{lastUserId+1}@mail.ru", RoleId = 2};
ctx.Users.Add(user);
_teacher = new Teacher(){Id = lastTeacherId+1, Fio = teacherName, Login = $"user{lastUserId+1}"};
_teachers.Add(_teacher);
ctx.Teachers.Add(_teacher);
foreach (var item in selectedItems)
{
var disc_teach = new DisciplineTeacher() { IdDiscipline = item.Discipline.Id, IdTeacher = lastTeacherId+1 };
ctx.DisciplineTeachers.Add(disc_teach);
}
var changes = ctx.SaveChanges();
if (changes > 0)
{
SuccessMessage.Text = "Учитель успешно добавлен!";
if (ErrorMessage != null)
{
ErrorMessage.Text = "";
}
}
else
{
ErrorMessage.Text = "Не удалось добавить учителя.";
SuccessMessage.Text = "";
}
}
private void ButtonBack_OnClick(object? sender, RoutedEventArgs e)
{
Close(_teachers);
}
public class DisciplinePresenter()
{
public Discipline Discipline { get; set; }
public string DisciplineName
{
get => Discipline.Name;
}
}
}

View File

@ -9,13 +9,15 @@
<Border Background="Bisque">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Background="LightBlue" Height="30">
<Button DockPanel.Dock="Left" Content="Назад" Click="ButtonBack_OnClick" Width="100" HorizontalAlignment="Left" Foreground="Black" Background="LightGray"/>
<ComboBox x:Name="GroupComboBox" HorizontalAlignment="Center"/>
<ComboBox x:Name="DisciplineComboBox" HorizontalAlignment="Center"/>
<ComboBox x:Name="TeacherComboBox" HorizontalAlignment="Center"/>
<!-- <Button Content="Просмотр аттестации" Foreground="Black"/> -->
<Button DockPanel.Dock="Left" Content="Назад" Click="ButtonBack_OnClick" Width="100" Margin="5, 0, 5, 0" HorizontalAlignment="Left" Foreground="Black" Background="LightGray"/>
<ComboBox x:Name="MultComboBox" HorizontalAlignment="Center" Margin="0, 0, 5, 0"/>
<Button Content="Просмотр" Click="ButtonCheck_OnClick" Foreground="Black" Margin="0, 0, 5, 0" Background="LightGray"/>
<Button Foreground="Black" Background="LightGray" Content="Группы" Margin="0, 0, 5, 0" Click="ButtonCheckGroups_OnClick"/>
<Button Foreground="Black" Background="LightGray" Content="Студенты" Margin="0, 0, 5, 0" Click="ButtonCheckStudents_OnClick"/>
<Button Foreground="Black" Background="LightGray" Content="Преподаватели" Click="ButtonCheckTeachers_OnClick"/>
<Button Foreground="Black" Background="LightGray" Content="Дисциплина" Click="ButtonCheckDiscipline_OnClick"/>
</StackPanel>
<Grid DockPanel.Dock="Top" ColumnDefinitions="3*,1*,3*" Background="LightGray" Height="35">
<Grid DockPanel.Dock="Top" ColumnDefinitions="3*,1*,2*" Background="LightGray" Height="35">
<TextBlock Grid.Column="0" Text="Дисциплина" VerticalAlignment="Center" Margin="5" Foreground="Black" FontWeight="Bold"/>
<TextBlock Grid.Column="1" Text="Группа" VerticalAlignment="Center" Margin="5" Foreground="Black" FontWeight="Bold"/>
<TextBlock Grid.Column="2" Text="Преподаватель" VerticalAlignment="Center" Margin="5" Foreground="Black" FontWeight="Bold"/>
@ -24,7 +26,7 @@
<ItemsControl x:Name="FlatGrid" ItemsSource="{Binding DisciplineGroupTeachers}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid ColumnDefinitions="3*,1*,3*" Margin="2" Background="LightGray" Height="40">
<Grid ColumnDefinitions="3*,1*,2*" Margin="2" Background="LightGray" Height="40">
<Border Grid.Column="0" BorderBrush="Black" BorderThickness="0.5">
<TextBlock Text="{Binding DisciplineName}" VerticalAlignment="Center" Margin="10,0" Foreground="Black"/>
</Border>

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
@ -29,16 +30,16 @@ public partial class AdminWindow : Window
foreach (DisciplineTeacher disciplineTeacher in disciplineTeachers)
{
//todo
//var group =
var teacher = ctx.Teachers.FirstOrDefault(t => t.Id == disciplineTeacher.IdTeacher);
var discipline = ctx.Disciplines.FirstOrDefault(d => d.Id == disciplineTeacher.IdDiscipline);
DisciplineGroupTeachers.Add(new DisciplineGroupTeacher(){Teacher = teacher, Discipline = discipline, Group = new Group() {Id = 777, YearAdmission = 777}});
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)
{
DisciplineGroupTeachers.Add(new DisciplineGroupTeacher(){Teacher = teacher, Discipline = discipline, Group = group});
}
}
GroupComboBox.ItemsSource = Groups.Select(g => g.Id);
DisciplineComboBox.ItemsSource = Disciplines.Select(d => d.Name);
TeacherComboBox.ItemsSource = Teachers.Select(t => t.Fio);
MultComboBox.ItemsSource = DisciplineGroupTeachers.Select(dg => dg.NameComboBox).ToList();
FlatGrid.ItemsSource = DisciplineGroupTeachers;
}
@ -48,18 +49,34 @@ public partial class AdminWindow : Window
public Group Group { get; set; }
public Discipline Discipline { get; set; }
public Teacher Teacher { get; set; }
public string DisciplineName
{
get => Discipline.Name;
}
public int GroupId
{
get => Group.Id;
}
public string TeacherFio
{
get => Teacher.Fio;
}
public int GroupId
public string NameComboBox
{
get => Group.Id;
get
{
return $"{Discipline.Name} - {Group.Id} - {Teacher.Fio}";
}
}
}
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;
}
}
@ -67,4 +84,40 @@ public partial class AdminWindow : Window
{
Close();
}
}
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();
// teachersFromAdminWindow.ShowDialog(this);
TeachersFromAdminWindow teachersFromAdminWindow = new TeachersFromAdminWindow();
var result = await teachersFromAdminWindow.ShowDialog<Boolean>(this);
if (result == true)
{
Display();
}
}
private void ButtonCheckDiscipline_OnClick(object? sender, RoutedEventArgs e)
{
AddDiscipline addDiscipline = new AddDiscipline();
addDiscipline.ShowDialog(this);
}
}

29
CalculateGrade.cs Normal file
View File

@ -0,0 +1,29 @@
namespace kursovaya;
public class CalculateGrade
{
public string CalculateGradeMethod(int total, int formAttest)
{
string grade = "";
switch (formAttest)
{
case 1:
if (total >= 90) grade = "отлично";
else if (total >= 80) grade = "хорошо";
else if (total >= 70) grade = "удовлетворительно";
else grade = "неудовлетворительно";
break;
case 2:
if (total >= 90) grade = "отлично";
else if (total >= 80) grade = "хорошо";
else if (total >= 70) grade = "удовлетворительно";
else grade = "неудовлетворительно";
break;
case 3:
if (total >= 70) grade = "зачтено";
else grade = "не зачтено";
break;
}
return grade;
}
}

View File

@ -0,0 +1,38 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="kursovaya.GroupsFromAdminWindow"
x:CompileBindings="False"
Title="StudentsFromAdminWindow">
<Border Background="Bisque">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Background="LightBlue" Height="30">
<Button DockPanel.Dock="Left" Content="Назад" Click="ButtonBack_OnClick" Width="100" Margin="5, 0, 5, 0" HorizontalAlignment="Left" Foreground="Black" Background="LightGray"/>
<Button DockPanel.Dock="Left" Content="Добавить" Click="ButtonAddGroup_OnClick" Width="100" HorizontalAlignment="Left" Foreground="Black" Background="LightGray"/>
</StackPanel>
<Grid DockPanel.Dock="Top" ColumnDefinitions="1*,1*" Background="LightGray" Height="35">
<TextBlock Grid.Column="0" Text="Группа" VerticalAlignment="Center" Margin="5" Foreground="Black" FontWeight="Bold"/>
<TextBlock Grid.Column="1" Text="Год" VerticalAlignment="Center" Margin="5" Foreground="Black" FontWeight="Bold"/>
</Grid>
<ScrollViewer>
<ItemsControl x:Name="FlatGrid" ItemsSource="{Binding Groups}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid ColumnDefinitions="1*,1*" Margin="2" Background="LightGray" Height="40">
<Border Grid.Column="0" BorderBrush="Black" BorderThickness="0.5">
<TextBlock Text="{Binding Id}" VerticalAlignment="Center" Foreground="Black"/>
</Border>
<Border Grid.Column="1" BorderBrush="Black" BorderThickness="0.5">
<TextBlock Text="{Binding YearAdmission}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Black"/>
</Border>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</DockPanel>
</Border>
</Window>

View File

@ -0,0 +1,56 @@
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;
using Microsoft.EntityFrameworkCore.Scaffolding.Metadata;
namespace kursovaya;
public partial class GroupsFromAdminWindow : Window
{
public List<Group> dataSourceGroups = new List<Group>();
public ObservableCollection<Group> Groups = new ObservableCollection<Group>();
public GroupsFromAdminWindow()
{
InitializeComponent();
var ctx = new DatabaseContext();
dataSourceGroups = ctx.Groups.ToList();
DisplayGroups();
FlatGrid.ItemsSource = Groups;
}
public void DisplayGroups()
{
var ctx = new DatabaseContext();
var temp = dataSourceGroups;
Groups.Clear();
foreach (var group in temp)
{
Groups.Add(group);
}
}
private void ButtonBack_OnClick(object? sender, RoutedEventArgs e)
{
Close();
}
private async void ButtonAddGroup_OnClick(object? sender, RoutedEventArgs e)
{
AddGroup addGroup = new AddGroup();
var groups = await addGroup.ShowDialog<List<Group>>(this);
if (groups == null || groups.Count == 0)
{
return;
}
dataSourceGroups.AddRange(groups);
DisplayGroups();
}
}

View File

@ -9,9 +9,9 @@
<Border Background="Bisque">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Background="LightBlue" Height="30">
<Button DockPanel.Dock="Left" Content="Назад" Click="ButtonBack_OnClick" Width="100" HorizontalAlignment="Left" Foreground="Black" Background="LightGray"/>
<ComboBox x:Name="DisciplineComboBox" HorizontalAlignment="Center" SelectionChanged="DisciplineCombobox_OnSelectionChanged"/>
<Button Content="Просмотр аттестации" Click="CheckAttest_OnClick" Foreground="Black"/>
<Button DockPanel.Dock="Left" Content="Назад" Click="ButtonBack_OnClick" Width="100" HorizontalAlignment="Left" Foreground="Black" Background="LightGray" Margin="5, 0, 5, 0"/>
<ComboBox x:Name="DisciplineComboBox" HorizontalAlignment="Center" SelectionChanged="DisciplineCombobox_OnSelectionChanged" Margin="0, 0, 5, 0"/>
<Button Content="Просмотр аттестации" Click="CheckAttest_OnClick" Foreground="Black" Margin="0, 0, 5, 0"/>
<TextBlock x:Name="InfoTextBlock" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="15" DockPanel.Dock="Right" Foreground="Black"/>
</StackPanel>
<Grid DockPanel.Dock="Top" ColumnDefinitions="3*,3*,1*,1*,1*,1*,1*" Background="LightGray" Height="35">

View File

@ -0,0 +1,48 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="kursovaya.StudentsFromAdminWindow"
x:CompileBindings="False"
Title="StudentsFromAdminWindow">
<Border Background="Bisque">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Background="LightBlue" Height="30">
<Button DockPanel.Dock="Left" Content="Назад" Click="ButtonBack_OnClick" Width="100" Margin="5, 0, 5, 0" HorizontalAlignment="Left" Foreground="Black" Background="LightGray"/>
<Button DockPanel.Dock="Left" Content="Добавить" Click="ButtonAddStudent_OnClick" Width="100" HorizontalAlignment="Left" Foreground="Black" Background="LightGray"/>
</StackPanel>
<Grid DockPanel.Dock="Top" ColumnDefinitions="1*,3*,1*,1*" Background="LightGray" Height="35">
<TextBlock Grid.Column="0" Text="Id" VerticalAlignment="Center" Margin="5" Foreground="Black" FontWeight="Bold"/>
<TextBlock Grid.Column="1" Text="ФИО" VerticalAlignment="Center" Margin="5" Foreground="Black" FontWeight="Bold"/>
<TextBlock Grid.Column="2" Text="Группа" VerticalAlignment="Center" Margin="5" Foreground="Black" FontWeight="Bold"/>
<TextBlock Grid.Column="3" Text="Логин" VerticalAlignment="Center" Margin="5" Foreground="Black" FontWeight="Bold"/>
</Grid>
<ScrollViewer>
<ItemsControl x:Name="FlatGrid" ItemsSource="{Binding Students}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid ColumnDefinitions="1*,3*,1*,1*" Margin="2" Background="LightGray" Height="40">
<Border Grid.Column="0" BorderBrush="Black" BorderThickness="0.5">
<TextBlock Text="{Binding Id}" VerticalAlignment="Center" Foreground="Black"/>
</Border>
<Border Grid.Column="1" BorderBrush="Black" BorderThickness="0.5">
<TextBlock Text="{Binding Fio}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Black"/>
</Border>
<Border Grid.Column="2" BorderBrush="Black" BorderThickness="0.5">
<TextBlock Text="{Binding IdGroup}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Black"/>
</Border>
<Border Grid.Column="3" BorderBrush="Black" BorderThickness="0.5">
<TextBlock Text="{Binding Login}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Black"/>
</Border>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</DockPanel>
</Border>
</Window>

View File

@ -0,0 +1,62 @@
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;
namespace kursovaya;
public partial class StudentsFromAdminWindow : Window
{
public List<Student> dataSourceStudents = new List<Student>();
public ObservableCollection<Student> Students = new ObservableCollection<Student>();
public StudentsFromAdminWindow()
{
InitializeComponent();
// var ctx = new DatabaseContext();
//
// Students = ctx.Students.ToList();
// FlatGrid.ItemsSource = Students;
var ctx = new DatabaseContext();
dataSourceStudents = ctx.Students.ToList();
DisplayStudents();
FlatGrid.ItemsSource = Students;
}
public void DisplayStudents()
{
var ctx = new DatabaseContext();
var temp = dataSourceStudents;
Students.Clear();
foreach (var student in temp)
{
Students.Add(student);
}
}
private void ButtonBack_OnClick(object? sender, RoutedEventArgs e)
{
Close();
}
private async void ButtonAddStudent_OnClick(object? sender, RoutedEventArgs e)
{
AddStudent addStudent = new AddStudent();
var students = await addStudent.ShowDialog<List<Student>>(this);
if (students == null || students.Count == 0)
return;
dataSourceStudents.AddRange(students);
DisplayStudents();
}
}

View File

@ -9,9 +9,8 @@
<Border Background="Bisque">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Background="LightBlue" Height="30">
<Button DockPanel.Dock="Left" Content="Назад" Click="ButtonBack_OnClick" Width="100" HorizontalAlignment="Left" Foreground="Black" Background="LightGray"/>
<ComboBox x:Name="GroupComboBox" HorizontalAlignment="Center"/>
<ComboBox x:Name="DisciplineComboBox" HorizontalAlignment="Center"/>
<Button DockPanel.Dock="Left" Content="Назад" Click="ButtonBack_OnClick" Width="100" HorizontalAlignment="Left" Foreground="Black" Background="LightGray" Margin="5, 0, 5, 0"/>
<ComboBox x:Name="MultComboBox" HorizontalAlignment="Center" Margin="0, 0, 5, 0"/>
<Button Content="Просмотр аттестации" Click="CheckAttest_OnClick" Foreground="Black"/>
</StackPanel>

View File

@ -16,6 +16,7 @@ public partial class TeacherWindow : Window
List<DiscGroup> discGroups = new();
public ObservableCollection<AttestationPresenterTeacher> AttestationsTeachers = new ObservableCollection<AttestationPresenterTeacher>();
List<AttestationPresenterTeacher> dataSourceAttestationsTeachers;
CalculateGrade calculateGrade = new CalculateGrade();
public TeacherWindow()
{
InitializeComponent();
@ -55,8 +56,7 @@ public partial class TeacherWindow : Window
Console.WriteLine($"{discGroup.discipline.Name} - {discGroup.group.Id} - {discGroup.attestations.Count}");
}
GroupComboBox.ItemsSource = discGroups.Select(dg => dg.group.Id).Distinct().ToList();
DisciplineComboBox.ItemsSource = discGroups.Select(dg => dg.discipline.Name).Distinct().ToList();
MultComboBox.ItemsSource = discGroups.Select(dg => dg.NameComboBox).ToList();
FlatAttestationGrid.ItemsSource = AttestationsTeachers;
}
@ -69,6 +69,14 @@ public partial class TeacherWindow : Window
{
public Discipline discipline;
public Group group;
public string NameComboBox
{
get
{
return $"{discipline.Name} - {group.Id}";
}
}
public List<AttestationPresenterTeacher> attestations = new();
}
@ -78,17 +86,13 @@ public partial class TeacherWindow : Window
var temp = dataSourceAttestationsTeachers;
AttestationsTeachers.Clear();
if (GroupComboBox.SelectionBoxItem != null)
if (MultComboBox.SelectionBoxItem != null)
{
var selectedGroupId = Convert.ToInt32(GroupComboBox.SelectedItem);
temp = temp.Where(ap => ctx.Students.Any(s => s.Id == ap.IdUser && s.IdGroup == selectedGroupId)).ToList();
}
if (DisciplineComboBox.SelectionBoxItem != null)
{
var idDiscipline = ctx.Disciplines.Where(d => d.Name == DisciplineComboBox.SelectionBoxItem)
.Select(d => d.Id).FirstOrDefault();
temp = temp.Where(ap => ap.IdDiscipline == idDiscipline).ToList();
var selectedDiscGroupId = discGroups.FirstOrDefault(d => d.NameComboBox == MultComboBox.SelectedItem.ToString()).group.Id;
temp = temp.Where(ap => ctx.Students.Any(s => s.Id == ap.IdUser && s.IdGroup == selectedDiscGroupId)).ToList();
var selectedDiscGroupId2 = discGroups.FirstOrDefault(d => d.NameComboBox == MultComboBox.SelectedItem.ToString()).discipline.Id;
temp = temp.Where(ap => ap.IdDiscipline == selectedDiscGroupId2).ToList();
}
Console.WriteLine("Добавлено элементов: " + temp.Count);
@ -109,30 +113,30 @@ public partial class TeacherWindow : Window
DisplayAttestations();
}
private string CalculateGrade(int total, int formAttest)
{
string grade = "";
switch (formAttest)
{
case 1:
if (total >= 90) grade = "отлично";
else if (total >= 80) grade = "хорошо";
else if (total >= 70) grade = "удовлетворительно";
else grade = "неудовлетворительно";
break;
case 2:
if (total >= 90) grade = "отлично";
else if (total >= 80) grade = "хорошо";
else if (total >= 70) grade = "удовлетворительно";
else grade = "неудовлетворительно";
break;
case 3:
if (total >= 70) grade = "зачтено";
else grade = "не зачтено";
break;
}
return grade;
}
// public string CalculateGrade(int total, int formAttest)
// {
// string grade = "";
// switch (formAttest)
// {
// case 1:
// if (total >= 90) grade = "отлично";
// else if (total >= 80) grade = "хорошо";
// else if (total >= 70) grade = "удовлетворительно";
// else grade = "неудовлетворительно";
// break;
// case 2:
// if (total >= 90) grade = "отлично";
// else if (total >= 80) grade = "хорошо";
// else if (total >= 70) grade = "удовлетворительно";
// else grade = "неудовлетворительно";
// break;
// case 3:
// if (total >= 70) grade = "зачтено";
// else grade = "не зачтено";
// break;
// }
// return grade;
// }
private async void FirstAttest_OnClick(object? sender, RoutedEventArgs e)
{
@ -151,7 +155,8 @@ public partial class TeacherWindow : Window
AttestSecond = attestation.AttestSecond,
AttestThird = attestation.AttestThird,
Total = newFirstAttest + attestation.AttestSecond + attestation.AttestThird,
Grade = CalculateGrade(newFirstAttest + attestation.AttestSecond + attestation.AttestThird, formAttest),
// Grade = CalculateGrade(newFirstAttest + attestation.AttestSecond + attestation.AttestThird, formAttest),
Grade = calculateGrade.CalculateGradeMethod(newFirstAttest + attestation.AttestSecond + attestation.AttestThird, formAttest),
};
ctx.Attestations.Update(newAttestation);
@ -190,7 +195,9 @@ public partial class TeacherWindow : Window
AttestSecond = newSecondAttest,
AttestThird = attestation.AttestThird,
Total = attestation.AttestFirst + newSecondAttest + attestation.AttestThird,
Grade = CalculateGrade(attestation.AttestFirst + newSecondAttest + attestation.AttestThird, formAttest),
// Grade = CalculateGrade(attestation.AttestFirst + newSecondAttest + attestation.AttestThird, formAttest),
Grade = calculateGrade.CalculateGradeMethod(attestation.AttestFirst + newSecondAttest + attestation.AttestThird, formAttest),
};
ctx.Attestations.Update(newAttestation);
@ -229,7 +236,8 @@ public partial class TeacherWindow : Window
AttestSecond = attestation.AttestSecond,
AttestThird = newThirdAttest,
Total = attestation.AttestFirst + attestation.AttestSecond + newThirdAttest,
Grade = CalculateGrade(attestation.AttestFirst + attestation.AttestSecond + newThirdAttest, formAttest),
// Grade = CalculateGrade(attestation.AttestFirst + attestation.AttestSecond + newThirdAttest, formAttest),
Grade = calculateGrade.CalculateGradeMethod(attestation.AttestFirst + attestation.AttestSecond + newThirdAttest, formAttest),
};
ctx.Attestations.Update(newAttestation);
@ -250,4 +258,259 @@ public partial class TeacherWindow : Window
DisplayAttestations();
}
}
}
}
// using System;
// 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;
// using Microsoft.EntityFrameworkCore;
//
// namespace kursovaya;
//
// public partial class TeacherWindow : Window
// {
// List<DiscGroup> discGroups = new();
// public ObservableCollection<AttestationPresenterTeacher> AttestationsTeachers = new ObservableCollection<AttestationPresenterTeacher>();
// List<AttestationPresenterTeacher> dataSourceAttestationsTeachers;
// public TeacherWindow()
// {
// InitializeComponent();
// }
//
// public TeacherWindow(User user) : this()
// {
// var ctx = new DatabaseContext();
//
// var groups = ctx.Groups.ToList();
// var teacherId = ctx.Teachers.FirstOrDefault(t => t.Login == user.Login).Id;
// var disciplinesIds = ctx.Disciplines.Include(d => d.DisciplineTeachers).Where(d => d.DisciplineTeachers.Any(dt => dt.IdTeacher == teacherId)).Select(d => d.Id).ToList();
// var disciplines = ctx.Disciplines.Include(d => d.DisciplineTeachers).Where(d => d.DisciplineTeachers.Any(dt => dt.IdTeacher == teacherId)).ToList();
// dataSourceAttestationsTeachers = ctx.Attestations.Where(a => disciplinesIds.Contains(a.IdDiscipline)).Select(a => new AttestationPresenterTeacher()
// {
// IdUser = a.IdUser,
// IdDiscipline = a.IdDiscipline,
// AttestFirst = a.AttestFirst,
// AttestSecond = a.AttestSecond,
// AttestThird = a.AttestThird,
// Total = a.Total,
// Grade = a.Grade,
// StudentFIO = ctx.Students.Where(s => s.Id == a.IdUser).Select(s => s.Fio).FirstOrDefault(),
// }).ToList();
// foreach (var group in groups)
// {
// foreach (var discipline in disciplines)
// {
// var attestationsToDiscGroup = dataSourceAttestationsTeachers.Where(a => ctx.Students.Any(s => s.Id == a.IdUser && s.IdGroup == group.Id) && a.IdDiscipline == discipline.Id).ToList();
// discGroups.Add(new DiscGroup(){discipline = discipline, group = group, attestations = attestationsToDiscGroup});
// }
// }
// discGroups.RemoveAll(d => d.attestations.Count == 0);
//
// foreach (var discGroup in discGroups)
// {
// Console.WriteLine($"{discGroup.discipline.Name} - {discGroup.group.Id} - {discGroup.attestations.Count}");
// }
//
// GroupComboBox.ItemsSource = discGroups.Select(dg => dg.group.Id).Distinct().ToList();
// DisciplineComboBox.ItemsSource = discGroups.Select(dg => dg.discipline.Name).Distinct().ToList();
// FlatAttestationGrid.ItemsSource = AttestationsTeachers;
// }
//
// public class AttestationPresenterTeacher() : Attestation
// {
// public string StudentFIO { get; set; }
// }
//
// public class DiscGroup
// {
// public Discipline discipline;
// public Group group;
// public List<AttestationPresenterTeacher> attestations = new();
// }
//
// public void DisplayAttestations()
// {
// var ctx = new DatabaseContext();
// var temp = dataSourceAttestationsTeachers;
// AttestationsTeachers.Clear();
//
// if (GroupComboBox.SelectionBoxItem != null)
// {
// var selectedGroupId = Convert.ToInt32(GroupComboBox.SelectedItem);
// temp = temp.Where(ap => ctx.Students.Any(s => s.Id == ap.IdUser && s.IdGroup == selectedGroupId)).ToList();
// }
//
// if (DisciplineComboBox.SelectionBoxItem != null)
// {
// var idDiscipline = ctx.Disciplines.Where(d => d.Name == DisciplineComboBox.SelectionBoxItem)
// .Select(d => d.Id).FirstOrDefault();
// temp = temp.Where(ap => ap.IdDiscipline == idDiscipline).ToList();
// }
//
// Console.WriteLine("Добавлено элементов: " + temp.Count);
//
// foreach (var item in temp)
// {
// AttestationsTeachers.Add(item);
// }
// }
//
// private void ButtonBack_OnClick(object? sender, RoutedEventArgs e)
// {
// Close();
// }
//
// private void CheckAttest_OnClick(object? sender, RoutedEventArgs e)
// {
// DisplayAttestations();
// }
//
// private string CalculateGrade(int total, int formAttest)
// {
// string grade = "";
// switch (formAttest)
// {
// case 1:
// if (total >= 90) grade = "отлично";
// else if (total >= 80) grade = "хорошо";
// else if (total >= 70) grade = "удовлетворительно";
// else grade = "неудовлетворительно";
// break;
// case 2:
// if (total >= 90) grade = "отлично";
// else if (total >= 80) grade = "хорошо";
// else if (total >= 70) grade = "удовлетворительно";
// else grade = "неудовлетворительно";
// break;
// case 3:
// if (total >= 70) grade = "зачтено";
// else grade = "не зачтено";
// break;
// }
// return grade;
// }
//
// private async void FirstAttest_OnClick(object? sender, RoutedEventArgs e)
// {
// if (sender is Button button && button.Tag is AttestationPresenterTeacher attestation)
// {
// EditAttestWindow editAttestWindow = new EditAttestWindow(1);
// var newFirstAttest = await editAttestWindow.ShowDialog<int>(this);
// var ctx = new DatabaseContext();
// var formAttest = ctx.Disciplines.FirstOrDefault(d => d.Id == attestation.IdDiscipline).IdFormAttest;
//
// Attestation newAttestation = new Attestation()
// {
// IdUser = attestation.IdUser,
// IdDiscipline = attestation.IdDiscipline,
// AttestFirst = newFirstAttest,
// AttestSecond = attestation.AttestSecond,
// AttestThird = attestation.AttestThird,
// Total = newFirstAttest + attestation.AttestSecond + attestation.AttestThird,
// Grade = CalculateGrade(newFirstAttest + attestation.AttestSecond + attestation.AttestThird, formAttest),
// };
//
// ctx.Attestations.Update(newAttestation);
// await ctx.SaveChangesAsync();
//
// dataSourceAttestationsTeachers.Remove(attestation);
// dataSourceAttestationsTeachers.Add(new AttestationPresenterTeacher()
// {
// IdUser = newAttestation.IdUser,
// IdDiscipline = newAttestation.IdDiscipline,
// AttestFirst = newAttestation.AttestFirst,
// AttestSecond = newAttestation.AttestSecond,
// AttestThird = newAttestation.AttestThird,
// Total = newAttestation.Total,
// Grade = newAttestation.Grade,
// StudentFIO = ctx.Students.Where(s => s.Id == newAttestation.IdUser).Select(s => s.Fio).FirstOrDefault()
// });
// DisplayAttestations();
// }
// }
//
// private async void SecondAttest_OnClick(object? sender, RoutedEventArgs e)
// {
// if (sender is Button button && button.Tag is AttestationPresenterTeacher attestation)
// {
// EditAttestWindow editAttestWindow = new EditAttestWindow(2);
// var newSecondAttest = await editAttestWindow.ShowDialog<int>(this);
// var ctx = new DatabaseContext();
// var formAttest = ctx.Disciplines.FirstOrDefault(d => d.Id == attestation.IdDiscipline).IdFormAttest;
//
// Attestation newAttestation = new Attestation()
// {
// IdUser = attestation.IdUser,
// IdDiscipline = attestation.IdDiscipline,
// AttestFirst = attestation.AttestFirst,
// AttestSecond = newSecondAttest,
// AttestThird = attestation.AttestThird,
// Total = attestation.AttestFirst + newSecondAttest + attestation.AttestThird,
// Grade = CalculateGrade(attestation.AttestFirst + newSecondAttest + attestation.AttestThird, formAttest),
// };
//
// ctx.Attestations.Update(newAttestation);
// await ctx.SaveChangesAsync();
//
// dataSourceAttestationsTeachers.Remove(attestation);
// dataSourceAttestationsTeachers.Add(new AttestationPresenterTeacher()
// {
// IdUser = newAttestation.IdUser,
// IdDiscipline = newAttestation.IdDiscipline,
// AttestFirst = newAttestation.AttestFirst,
// AttestSecond = newAttestation.AttestSecond,
// AttestThird = newAttestation.AttestThird,
// Total = newAttestation.Total,
// Grade = newAttestation.Grade,
// StudentFIO = ctx.Students.Where(s => s.Id == newAttestation.IdUser).Select(s => s.Fio).FirstOrDefault()
// });
// DisplayAttestations();
// }
// }
//
// private async void ThirdAttest_OnClick(object? sender, RoutedEventArgs e)
// {
// if (sender is Button button && button.Tag is AttestationPresenterTeacher attestation)
// {
// EditAttestWindow editAttestWindow = new EditAttestWindow(3);
// var newThirdAttest = await editAttestWindow.ShowDialog<int>(this);
// var ctx = new DatabaseContext();
// var formAttest = ctx.Disciplines.FirstOrDefault(d => d.Id == attestation.IdDiscipline).IdFormAttest;
//
// Attestation newAttestation = new Attestation()
// {
// IdUser = attestation.IdUser,
// IdDiscipline = attestation.IdDiscipline,
// AttestFirst = attestation.AttestFirst,
// AttestSecond = attestation.AttestSecond,
// AttestThird = newThirdAttest,
// Total = attestation.AttestFirst + attestation.AttestSecond + newThirdAttest,
// Grade = CalculateGrade(attestation.AttestFirst + attestation.AttestSecond + newThirdAttest, formAttest),
// };
//
// ctx.Attestations.Update(newAttestation);
// await ctx.SaveChangesAsync();
//
// dataSourceAttestationsTeachers.Remove(attestation);
// dataSourceAttestationsTeachers.Add(new AttestationPresenterTeacher()
// {
// IdUser = newAttestation.IdUser,
// IdDiscipline = newAttestation.IdDiscipline,
// AttestFirst = newAttestation.AttestFirst,
// AttestSecond = newAttestation.AttestSecond,
// AttestThird = newAttestation.AttestThird,
// Total = newAttestation.Total,
// Grade = newAttestation.Grade,
// StudentFIO = ctx.Students.Where(s => s.Id == newAttestation.IdUser).Select(s => s.Fio).FirstOrDefault()
// });
// DisplayAttestations();
// }
// }
// }

View File

@ -0,0 +1,43 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="kursovaya.TeachersFromAdminWindow"
x:CompileBindings="False"
Title="TeachersFromAdminWindow">
<Border Background="Bisque">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Background="LightBlue" Height="30">
<Button DockPanel.Dock="Left" Content="Назад" Click="ButtonBack_OnClick" Width="100" Margin="5, 0, 5, 0" HorizontalAlignment="Left" Foreground="Black" Background="LightGray"/>
<Button DockPanel.Dock="Left" Content="Добавить" Click="ButtonAddTeacher_OnClick" Width="100" HorizontalAlignment="Left" Foreground="Black" Background="LightGray"/>
</StackPanel>
<Grid DockPanel.Dock="Top" ColumnDefinitions="1*,3*,1*" Background="LightGray" Height="35">
<TextBlock Grid.Column="0" Text="Id" VerticalAlignment="Center" Margin="5" Foreground="Black" FontWeight="Bold"/>
<TextBlock Grid.Column="1" Text="ФИО" VerticalAlignment="Center" Margin="5" Foreground="Black" FontWeight="Bold"/>
<TextBlock Grid.Column="2" Text="Логин" VerticalAlignment="Center" Margin="5" Foreground="Black" FontWeight="Bold"/>
</Grid>
<ScrollViewer>
<ItemsControl x:Name="FlatGrid" ItemsSource="{Binding Students}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid ColumnDefinitions="1*,3*,1*" Margin="2" Background="LightGray" Height="40">
<Border Grid.Column="0" BorderBrush="Black" BorderThickness="0.5">
<TextBlock Text="{Binding Id}" VerticalAlignment="Center" Foreground="Black"/>
</Border>
<Border Grid.Column="1" BorderBrush="Black" BorderThickness="0.5">
<TextBlock Text="{Binding Fio}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Black"/>
</Border>
<Border Grid.Column="2" BorderBrush="Black" BorderThickness="0.5">
<TextBlock Text="{Binding Login}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Black"/>
</Border>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</DockPanel>
</Border>
</Window>

View File

@ -0,0 +1,63 @@
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;
namespace kursovaya;
public partial class TeachersFromAdminWindow : Window
{
public List<Teacher> dataSourceTeachers = new List<Teacher>();
public ObservableCollection<Teacher> Teachers = new ObservableCollection<Teacher>();
List<Teacher> _addedTeachers = new List<Teacher>();
public TeachersFromAdminWindow()
{
InitializeComponent();
var ctx = new DatabaseContext();
dataSourceTeachers = ctx.Teachers.ToList();
DisplayTeachers();
FlatGrid.ItemsSource = Teachers;
}
private void ButtonBack_OnClick(object? sender, RoutedEventArgs e)
{
if (_addedTeachers == null || _addedTeachers.Count == 0)
{
Close(true);
}
else
{
Close(false);
}
}
public void DisplayTeachers()
{
var ctx = new DatabaseContext();
var temp = dataSourceTeachers;
Teachers.Clear();
foreach (var teacher in temp)
{
Teachers.Add(teacher);
}
}
private async void ButtonAddTeacher_OnClick(object? sender, RoutedEventArgs e)
{
AddTeacher addTeacher = new AddTeacher();
_addedTeachers = await addTeacher.ShowDialog<List<Teacher>>(this);
if (_addedTeachers == null || _addedTeachers.Count == 0)
{
return;
}
dataSourceTeachers.AddRange(_addedTeachers);
DisplayTeachers();
}
}

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
374a528495048d68bd0a3059a650683b9f05c3cfe090876e3034f1fa8ae41390
f0de6e47f368c7d2b430389bae7c7fda5f65514e38af332e1f0fd91696366f73

Binary file not shown.

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("kursovaya")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+248d3e25d22041172a479699a6cb9d4df419c579")]
[assembly: System.Reflection.AssemblyProductAttribute("kursovaya")]
[assembly: System.Reflection.AssemblyTitleAttribute("kursovaya")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
438ac02de57945e0a3ab2fd8d2a9cc154f00624a69c91b117844200878d4cd98
0fff8ebb88ae28dae7ded2aed1d582540b141e9a69d66b9f7cbf35239228691d

View File

@ -19,6 +19,18 @@ build_property.ProjectDir = /Users/rinchi/RiderProjects/kursovaya/kursovaya/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
[/Users/rinchi/RiderProjects/kursovaya/kursovaya/AddDiscipline.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[/Users/rinchi/RiderProjects/kursovaya/kursovaya/AddGroup.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[/Users/rinchi/RiderProjects/kursovaya/kursovaya/AddStudent.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[/Users/rinchi/RiderProjects/kursovaya/kursovaya/AddTeacher.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[/Users/rinchi/RiderProjects/kursovaya/kursovaya/AdminWindow.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
@ -28,11 +40,20 @@ build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[/Users/rinchi/RiderProjects/kursovaya/kursovaya/EditAttestWindow.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[/Users/rinchi/RiderProjects/kursovaya/kursovaya/GroupsFromAdminWindow.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[/Users/rinchi/RiderProjects/kursovaya/kursovaya/MainWindow.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[/Users/rinchi/RiderProjects/kursovaya/kursovaya/StudentsFromAdminWindow.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[/Users/rinchi/RiderProjects/kursovaya/kursovaya/StudentWindow.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[/Users/rinchi/RiderProjects/kursovaya/kursovaya/TeachersFromAdminWindow.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml
[/Users/rinchi/RiderProjects/kursovaya/kursovaya/TeacherWindow.axaml]
build_metadata.AdditionalFiles.SourceItemGroup = AvaloniaXaml

View File

@ -1 +1 @@
1c440020a6ab5de412bab6c06555c1126cb8caecb23b96c027088f5248e2106f
71f8c7885cc41c61509dddd287b6e947d22d2d15c24d98b288e9f7c66559ec2e

Binary file not shown.

Binary file not shown.

Binary file not shown.