done with part of the presence
This commit is contained in:
parent
eadf72b512
commit
ffb9d2134f
@ -5,6 +5,7 @@
|
||||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||
|
||||
<Application.Styles>
|
||||
<FluentTheme />
|
||||
</Application.Styles>
|
||||
<FluentTheme />
|
||||
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml"/>
|
||||
</Application.Styles>
|
||||
</Application>
|
@ -15,6 +15,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.2.1" />
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.2.1" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.2.1" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.1" />
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.1" />
|
||||
|
@ -8,6 +8,7 @@ using ReactiveUI;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
|
||||
namespace Presence.Desktop.ViewModels
|
||||
@ -22,6 +23,12 @@ namespace Presence.Desktop.ViewModels
|
||||
|
||||
public ObservableCollection<PresencePresenter> AttendanceRecords { get; set; } = new();
|
||||
public ObservableCollection<GroupPresenter> Groups { get; set; } = new();
|
||||
private ObservableCollection<PresencePresenter> _selectedItems = new();
|
||||
public ObservableCollection<PresencePresenter> SelectedItems
|
||||
{
|
||||
get => _selectedItems;
|
||||
set => this.RaiseAndSetIfChanged(ref _selectedItems, value);
|
||||
}
|
||||
|
||||
private GroupPresenter? _selectedGroup;
|
||||
public GroupPresenter? SelectedGroup
|
||||
@ -46,6 +53,7 @@ namespace Presence.Desktop.ViewModels
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> NavigateBackCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> DeleteSelectedPresenceCommand { get; }
|
||||
|
||||
public PresenceViewModel(GroupUseCase groupUseCase, PresenceUseCase presenceUseCase)
|
||||
{
|
||||
@ -55,12 +63,9 @@ namespace Presence.Desktop.ViewModels
|
||||
|
||||
|
||||
NavigateBackCommand = ReactiveCommand.Create(() => { });
|
||||
DeleteSelectedPresenceCommand = ReactiveCommand.Create(DeleteSelectedItems);
|
||||
|
||||
this.WhenAnyValue(vm => vm.SelectedGroup)
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
LoadGroups();
|
||||
});
|
||||
LoadGroups();
|
||||
}
|
||||
|
||||
private void LoadGroups()
|
||||
@ -80,7 +85,7 @@ namespace Presence.Desktop.ViewModels
|
||||
|
||||
private void FilterAttendanceRecords()
|
||||
{
|
||||
if (SelectedGroup == null)
|
||||
if (SelectedGroup == null || SelectedDate == null)
|
||||
{
|
||||
AttendanceRecords.Clear();
|
||||
return;
|
||||
@ -106,6 +111,21 @@ namespace Presence.Desktop.ViewModels
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Логирование для отладки
|
||||
Console.WriteLine($"Загружено записей посещаемости: {AttendanceRecords.Count}");
|
||||
}
|
||||
|
||||
private void DeleteSelectedItems()
|
||||
{
|
||||
if (SelectedItems.Any())
|
||||
{
|
||||
foreach (var item in SelectedItems.ToList())
|
||||
{
|
||||
_presenceUseCase.DeletePresenceByClassNumberAndDateAndUserId(item.ClassNumber, item.Date, item.User.Id); // Удаляем из базы данных
|
||||
AttendanceRecords.Remove(item); // Удаляем из коллекции
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,8 +7,8 @@
|
||||
x:Class="Presence.Desktop.Views.PresenceView"
|
||||
x:DataType="vm:PresenceViewModel">
|
||||
|
||||
<Grid RowDefinitions="Auto, Auto, *, Auto" Margin="10" Background="Aquamarine">
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="0" Spacing="10">
|
||||
<DockPanel Margin="10" Background="Aquamarine">
|
||||
<StackPanel Orientation="Horizontal" Spacing="10" DockPanel.Dock="Top">
|
||||
<!-- Выбор группы -->
|
||||
<ComboBox ItemsSource="{Binding Groups}" SelectedItem="{Binding SelectedGroup}" Width="200" PlaceholderText="Выберите группу">
|
||||
<ComboBox.ItemTemplate>
|
||||
@ -22,17 +22,18 @@
|
||||
<Calendar SelectedDate="{Binding SelectedDate}" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Vertical" Spacing="10">
|
||||
<!-- Таблица с посещаемостью -->
|
||||
<DataGrid Grid.Row="2" AutoGenerateColumns="False" ItemsSource="{Binding AttendanceRecords}" CanUserSortColumns="True">
|
||||
<DataGrid AutoGenerateColumns="False" ItemsSource="{Binding AttendanceRecords}" CanUserSortColumns="True"
|
||||
SelectionChanged="OnDataGridSelectionChanged">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Дата" Binding="{Binding Date}" Foreground="Black"/>
|
||||
<DataGridTextColumn Header="Дата" Binding="{Binding Date}"/>
|
||||
<DataGridTextColumn Header="Номер урока" Binding="{Binding ClassNumber}" />
|
||||
<DataGridTextColumn Header="ФИО" Binding="{Binding User.Name}" />
|
||||
|
||||
<!-- Тип посещаемости -->
|
||||
<DataGridCheckBoxColumn Header="Тип посещаемости" Binding="{Binding IsAttendence, Mode=TwoWay}" />
|
||||
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
<Button Content="Удалить" Margin="0,10,0,0" Command="{Binding DeleteSelectedPresenceCommand}" />
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
</UserControl>
|
@ -1,7 +1,9 @@
|
||||
using System.Linq;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Presence.Desktop.Models;
|
||||
using Presence.Desktop.ViewModels;
|
||||
using ReactiveUI;
|
||||
|
||||
@ -13,4 +15,17 @@ public partial class PresenceView : ReactiveUserControl<PresenceViewModel>
|
||||
{
|
||||
this.WhenActivated(disposables => { });
|
||||
AvaloniaXamlLoader.Load(this); }
|
||||
|
||||
private void OnDataGridSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (this.DataContext is PresenceViewModel viewModel)
|
||||
{
|
||||
// Обновляем выделенные элементы в ViewModel
|
||||
viewModel.SelectedItems.Clear();
|
||||
foreach (var item in e.AddedItems.OfType<PresencePresenter>())
|
||||
{
|
||||
viewModel.SelectedItems.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@
|
||||
"Presence.Desktop/1.0.0": {
|
||||
"dependencies": {
|
||||
"Avalonia": "11.2.1",
|
||||
"Avalonia.Controls.DataGrid": "11.2.1",
|
||||
"Avalonia.Desktop": "11.2.1",
|
||||
"Avalonia.Diagnostics": "11.2.1",
|
||||
"Avalonia.Fonts.Inter": "11.2.1",
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
8ff83d2bcb3cec6472dc66a2a69c5cfafb8cbd5996d3bbe796f44278fe829520
|
||||
56ae5ef5211e31f34c72fa8790282155735812ceabb8c9c1129ad7d327241a91
|
||||
|
Binary file not shown.
@ -13,10 +13,10 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Presence.Desktop")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+eadf72b51276624814f3e477c5bc69af93bf4792")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Presence.Desktop")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Presence.Desktop")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// Создано классом WriteCodeFragment MSBuild.
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
|
||||
|
@ -1 +1 @@
|
||||
a55713119259355cce81a2db571720adcd3acb7bc2009903ebf5dba4fbc71e3d
|
||||
72b577a16b1150e5587b14ce010e799430b278d0d3ab4eb8c333f7fdbbed0371
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -51,6 +51,10 @@
|
||||
"target": "Package",
|
||||
"version": "[11.2.1, )"
|
||||
},
|
||||
"Avalonia.Controls.DataGrid": {
|
||||
"target": "Package",
|
||||
"version": "[11.2.1, )"
|
||||
},
|
||||
"Avalonia.Desktop": {
|
||||
"target": "Package",
|
||||
"version": "[11.2.1, )"
|
||||
|
@ -2473,6 +2473,7 @@
|
||||
"projectFileDependencyGroups": {
|
||||
"net8.0": [
|
||||
"Avalonia >= 11.2.1",
|
||||
"Avalonia.Controls.DataGrid >= 11.2.1",
|
||||
"Avalonia.Desktop >= 11.2.1",
|
||||
"Avalonia.Diagnostics >= 11.2.1",
|
||||
"Avalonia.Fonts.Inter >= 11.2.1",
|
||||
@ -2531,6 +2532,10 @@
|
||||
"target": "Package",
|
||||
"version": "[11.2.1, )"
|
||||
},
|
||||
"Avalonia.Controls.DataGrid": {
|
||||
"target": "Package",
|
||||
"version": "[11.2.1, )"
|
||||
},
|
||||
"Avalonia.Desktop": {
|
||||
"target": "Package",
|
||||
"version": "[11.2.1, )"
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "yZq6gfkM/18=",
|
||||
"dgSpecHash": "bFYjHbhBv54=",
|
||||
"success": true,
|
||||
"projectFilePath": "/home/gara/csharp/BIGPROGECT/presence/Presence.Desktop/Presence.Desktop.csproj",
|
||||
"expectedPackageFiles": [
|
||||
|
@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("console_ui")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+eadf72b51276624814f3e477c5bc69af93bf4792")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("console_ui")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("console_ui")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
@ -1 +1 @@
|
||||
b646cd9abdfaed63b2c066937a57ee292758ed891f5a7c5830756fb43e02e2ee
|
||||
25bd5e432f9b076e16dc7af22f86b1c575c43db1e24524d1d4b9fb3399bfa759
|
||||
|
Binary file not shown.
@ -17,6 +17,8 @@ namespace presence.data.Repository
|
||||
bool DeletePresenceByGroup(int groupId);
|
||||
bool DeletePresenceByUser(int userId);
|
||||
bool DeletePresenceByDate(DateOnly startData, DateOnly endData);
|
||||
bool DeletePresenceByClassNumberAndDateAndUserId(int classNumber, DateOnly date, int userId);
|
||||
|
||||
void UpdateAttendance(PresenceDao presence);
|
||||
|
||||
|
||||
|
@ -122,6 +122,16 @@ namespace presence.data.Repository
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool DeletePresenceByClassNumberAndDateAndUserId(int classNumber, DateOnly date, int userId)
|
||||
{
|
||||
var PresenceToDelete = _remoteDatabaseContext.Presences.FirstOrDefault(x => x.Date == date && x.ClassNumber == classNumber && x.UserId == userId);
|
||||
_remoteDatabaseContext.Presences.Remove(PresenceToDelete);
|
||||
_remoteDatabaseContext.SaveChanges();
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void UpdateAttendance(PresenceDao presence)
|
||||
{
|
||||
if (presence == null) throw new ArgumentNullException(nameof(presence));
|
||||
|
Binary file not shown.
Binary file not shown.
@ -13,10 +13,10 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("data")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+eadf72b51276624814f3e477c5bc69af93bf4792")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("data")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("data")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// Создано классом WriteCodeFragment MSBuild.
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
|
||||
|
@ -1 +1 @@
|
||||
c7ce76312ceb7b78b59ab7c078914f3d4e8a1907cd4153da36c3432f01ff593b
|
||||
2253ca6854105c04db3820ffeca7fdaa0791fa00d7171656efaaad4bd95ee96a
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -230,6 +230,11 @@ namespace presence.domain.UseCase
|
||||
return _presenceRepository.DeletePresenceByDate(startData, endData);
|
||||
}
|
||||
|
||||
public bool DeletePresenceByClassNumberAndDateAndUserId(int ClassNumber, DateOnly date, int userId)
|
||||
{
|
||||
return _presenceRepository.DeletePresenceByClassNumberAndDateAndUserId(ClassNumber, date, userId);
|
||||
}
|
||||
|
||||
public void UpdateAttendance(PresenceDao presence)
|
||||
{
|
||||
_presenceRepository.UpdateAttendance(presence);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,10 +13,10 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("domain")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+eadf72b51276624814f3e477c5bc69af93bf4792")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("domain")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("domain")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// Создано классом WriteCodeFragment MSBuild.
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
|
||||
|
@ -1 +1 @@
|
||||
bdff4fbeccb346e2cf4a8dfcc1d45f5250114d880df44801d9b74b9d8ac7603a
|
||||
f91ca13c27f8a90a479f0970f684bcd6ea0ccda85726b424d8a614ad54287fba
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("presence_api")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+eadf72b51276624814f3e477c5bc69af93bf4792")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("presence_api")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("presence_api")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
@ -1 +1 @@
|
||||
1e75923e7041345eb2f77db14fdab7a996030a49a36f5debb66b329692ed2bc1
|
||||
aeb387e4e85ce3ac4715fe5bfffc5e4071ed545312f35b7345a437287364ca5e
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("ui")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+38cf16c345620460ae7f35458594b103cab78067")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+eadf72b51276624814f3e477c5bc69af93bf4792")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("ui")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("ui")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
@ -1 +1 @@
|
||||
6b630ab98cc90f908ad3afc0ecce6478a4e69213272d76fa17d581b71e586852
|
||||
34056f4ae144d0b6b9e005bea4d01e95d450e183e56708cb027e5d8487a4e243
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user