add more
This commit is contained in:
parent
9adf371994
commit
13cb67d3a6
@ -16,5 +16,6 @@
|
|||||||
|
|
||||||
<Application.Styles>
|
<Application.Styles>
|
||||||
<FluentTheme />
|
<FluentTheme />
|
||||||
|
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml"/>
|
||||||
</Application.Styles>
|
</Application.Styles>
|
||||||
</Application>
|
</Application>
|
8
IposiGospodDemo/Dtos/SponsorshipOverViewCharityDto.cs
Normal file
8
IposiGospodDemo/Dtos/SponsorshipOverViewCharityDto.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace IposiGospodDemo.Dtos;
|
||||||
|
|
||||||
|
public class SponsorshipOverViewCharityDto
|
||||||
|
{
|
||||||
|
public string CharityName { get; set; }
|
||||||
|
public string? CharityLogo { get; set; }
|
||||||
|
public decimal SponsorshipAmount { get; set; }
|
||||||
|
}
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="11.2.1"/>
|
<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.Desktop" Version="11.2.1"/>
|
||||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.2.1" />
|
<PackageReference Include="Avalonia.ReactiveUI" Version="11.2.1" />
|
||||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.1"/>
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.1"/>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using IposiGospodDemo.Context;
|
using IposiGospodDemo.Context;
|
||||||
|
|
||||||
namespace IposiGospodDemo;
|
namespace IposiGospodDemo;
|
||||||
@ -11,7 +12,9 @@ public static class Session
|
|||||||
public static readonly String Data = "Вторник 1 апреля 2025";
|
public static readonly String Data = "Вторник 1 апреля 2025";
|
||||||
public static String RemainingTime = CalculateRemaningTime();
|
public static String RemainingTime = CalculateRemaningTime();
|
||||||
public static string AssetsPath = null!;
|
public static string AssetsPath = null!;
|
||||||
|
|
||||||
public static User User = null;
|
public static User User = null;
|
||||||
|
public static Runner Runner = null;
|
||||||
|
|
||||||
public static String CalculateRemaningTime()
|
public static String CalculateRemaningTime()
|
||||||
{
|
{
|
||||||
@ -20,4 +23,10 @@ public static class Session
|
|||||||
? $"{timeLeft.Days} д. {timeLeft.Hours} ч. {timeLeft.Minutes} мин. до старта марафона"
|
? $"{timeLeft.Days} д. {timeLeft.Hours} ч. {timeLeft.Minutes} мин. до старта марафона"
|
||||||
: "Марафон уже начался!";
|
: "Марафон уже начался!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Logout()
|
||||||
|
{
|
||||||
|
User = null;
|
||||||
|
Runner = null;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,5 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
using IposiGospodDemo.Context;
|
using IposiGospodDemo.Context;
|
||||||
|
using IposiGospodDemo.Helpers;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Npgsql;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace IposiGospodDemo.ViewModels;
|
namespace IposiGospodDemo.ViewModels;
|
||||||
@ -7,16 +13,34 @@ namespace IposiGospodDemo.ViewModels;
|
|||||||
public class MySponsorshipWindowViewModel : ViewModelBase
|
public class MySponsorshipWindowViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
|
||||||
private ObservableCollection<Registration> _registrations;
|
private ObservableCollection<Sponsorship> _sponsorships;
|
||||||
|
|
||||||
public ObservableCollection<Registration> Registrations
|
public ObservableCollection<Sponsorship> Sponsorships
|
||||||
{
|
{
|
||||||
get => _registrations;
|
get => _sponsorships;
|
||||||
set => this.RaiseAndSetIfChanged(ref _registrations, value);
|
set => this.RaiseAndSetIfChanged(ref _sponsorships, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Charity RunnerCharity { get; set; }
|
||||||
|
|
||||||
|
public decimal TotalAmount { get; set; }
|
||||||
|
|
||||||
public MySponsorshipWindowViewModel()
|
public MySponsorshipWindowViewModel()
|
||||||
{
|
{
|
||||||
|
Sponsorships = new(DbHelper.Database.Sponsorships
|
||||||
|
.Include(s => s.Registration)
|
||||||
|
.Where(s => s.Registration.RunnerId == Session.Runner.RunnerId).ToList());
|
||||||
|
|
||||||
|
TotalAmount = Sponsorships?.Sum(s => s.Amount) ?? 0;
|
||||||
|
List<Registration> regs = new (DbHelper.Database.Registrations.Where(r => r.RunnerId == Session.Runner.RunnerId));
|
||||||
|
Console.WriteLine(regs.Count);
|
||||||
|
Console.WriteLine(regs);
|
||||||
|
var registration = DbHelper.Database.Registrations
|
||||||
|
.Include(r => r.Charity) // Убедитесь, что Charity загружается
|
||||||
|
.FirstOrDefault(r => r.RunnerId == Session.Runner.RunnerId);
|
||||||
|
|
||||||
|
RunnerCharity = registration?.Charity; // Предотвращаем NullReferenceException
|
||||||
|
|
||||||
|
Console.WriteLine("Runner Charity = " + RunnerCharity.CharityName);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using IposiGospodDemo.Dtos;
|
||||||
|
using IposiGospodDemo.Helpers;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
|
namespace IposiGospodDemo.ViewModels;
|
||||||
|
|
||||||
|
public class SponsorshipOverviewWindowViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
private ObservableCollection<SponsorshipOverViewCharityDto> _charities;
|
||||||
|
public ObservableCollection<SponsorshipOverViewCharityDto> Charities
|
||||||
|
{
|
||||||
|
get => _charities;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _charities, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private decimal _charitiesSum;
|
||||||
|
|
||||||
|
public decimal CharitiesSum
|
||||||
|
{
|
||||||
|
get => _charitiesSum;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _charitiesSum, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SponsorshipOverviewWindowViewModel()
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
Charities = new(DbHelper.Database.Charities
|
||||||
|
.Select(c => new SponsorshipOverViewCharityDto
|
||||||
|
{
|
||||||
|
CharityName = c.CharityName,
|
||||||
|
CharityLogo = c.CharityLogo,
|
||||||
|
SponsorshipAmount = c.Registrations
|
||||||
|
.SelectMany(r => r.Sponsorships)
|
||||||
|
.Sum(s => s.Amount)
|
||||||
|
})
|
||||||
|
.ToList());
|
||||||
|
CharitiesSum = Charities.Sum(c => c.SponsorshipAmount);
|
||||||
|
Console.WriteLine(Charities.Count);
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,7 @@ public partial class AdministratorMenuWindow : Window
|
|||||||
|
|
||||||
private void Logout_OnClick(object? sender, RoutedEventArgs e)
|
private void Logout_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Session.User = null;
|
Session.Logout();
|
||||||
new MainWindow().Show();
|
new MainWindow().Show();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<TextBlock Text="{Binding Name}" HorizontalAlignment="Center" FontSize="18" FontWeight="Bold"/>
|
<TextBlock Text="{Binding Name}" HorizontalAlignment="Center" FontSize="18" FontWeight="Bold"/>
|
||||||
|
|
||||||
<Border Height="100" ClipToBounds="True">
|
<Border Height="100" ClipToBounds="True">
|
||||||
<Image Source="{Binding ImagePath, Converter={StaticResource ImageConverter}}" Stretch="UniformToFill"/>
|
<Image Source="{Binding ImagePath, Converter={StaticResource ImageConverter}}" Stretch="Uniform"/>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<TextBlock Text="{Binding Description}" TextWrapping="WrapWithOverflow" TextAlignment="Center" Width="400"/>
|
<TextBlock Text="{Binding Description}" TextWrapping="WrapWithOverflow" TextAlignment="Center" Width="400"/>
|
||||||
|
@ -20,9 +20,22 @@
|
|||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
|
||||||
<StackPanel Grid.Row="1" Orientation="Vertical">
|
<DockPanel Grid.Row="1">
|
||||||
|
<TextBlock Text="Меню коориднатора" DockPanel.Dock="Top" HorizontalAlignment="Center" TextAlignment="Center"
|
||||||
</StackPanel>
|
FontSize="32" Margin="0 0 0 100"/>
|
||||||
|
<StackPanel HorizontalAlignment="Center" DockPanel.Dock="Top" Spacing="20">
|
||||||
|
<Button Padding="20" HorizontalAlignment="Center" Click="SwapToRunnersWindow_OnClick"
|
||||||
|
Background="LightGray" BorderThickness="1" BorderBrush="Black"
|
||||||
|
FontSize="24" CornerRadius="15" MinWidth="450" HorizontalContentAlignment="Center">
|
||||||
|
Бегуны
|
||||||
|
</Button>
|
||||||
|
<Button Padding="20" HorizontalAlignment="Center" Click="SwapToSponsorshipOverviewWindow_OnClick"
|
||||||
|
Background="LightGray" BorderThickness="1" BorderBrush="Black"
|
||||||
|
FontSize="24" CornerRadius="15" MinWidth="450" HorizontalContentAlignment="Center">
|
||||||
|
Спонсоры
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</DockPanel>
|
||||||
|
|
||||||
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
|
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
|
||||||
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
|
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
|
||||||
|
@ -20,8 +20,19 @@ public partial class CoordinatorMenuWindow : Window
|
|||||||
|
|
||||||
private void Logout_OnClick(object? sender, RoutedEventArgs e)
|
private void Logout_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Session.User = null;
|
Session.Logout();
|
||||||
new MainWindow().Show();
|
new MainWindow().Show();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SwapToRunnersWindow_OnClick(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SwapToSponsorshipOverviewWindow_OnClick(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
new SponsorshipOverviewWindow().Show();
|
||||||
|
Close();
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,7 +20,7 @@ public partial class EditRunnerProfileWindow : Window
|
|||||||
|
|
||||||
private void Logout_OnClick(object? sender, RoutedEventArgs e)
|
private void Logout_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Session.User = null;
|
Session.Logout();
|
||||||
new MainWindow().Show();
|
new MainWindow().Show();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Border HorizontalAlignment="Left">
|
<Border HorizontalAlignment="Left">
|
||||||
<StackPanel Orientation="Horizontal" Spacing="10" HorizontalAlignment="Left" Width="800">
|
<StackPanel Orientation="Horizontal" Spacing="10" HorizontalAlignment="Left" Width="800">
|
||||||
<Image MaxHeight="100" MaxWidth="100" Stretch="UniformToFill" HorizontalAlignment="Left"
|
<Image MaxHeight="100" MaxWidth="100" Stretch="Uniform" HorizontalAlignment="Left"
|
||||||
Source="{Binding CharityLogo, Converter={StaticResource ImageConverter}}"
|
Source="{Binding CharityLogo, Converter={StaticResource ImageConverter}}"
|
||||||
VerticalAlignment="Center"/>
|
VerticalAlignment="Center"/>
|
||||||
<StackPanel Orientation="Vertical" Spacing="10" Width="700">
|
<StackPanel Orientation="Vertical" Spacing="10" Width="700">
|
||||||
|
@ -32,10 +32,11 @@ public partial class LoginWindow : Window
|
|||||||
PasswordBox.Text != null && u.Password == PasswordBox.Text.Trim());
|
PasswordBox.Text != null && u.Password == PasswordBox.Text.Trim());
|
||||||
|
|
||||||
Session.User = user;
|
Session.User = user;
|
||||||
Console.WriteLine("USERROLEID: " + user.Role.RoleId.ToString());
|
|
||||||
switch (user.Role.RoleId)
|
switch (user.Role.RoleId)
|
||||||
{
|
{
|
||||||
case 'R':
|
case 'R':
|
||||||
|
Session.Runner = DbHelper.Database.Runners.Single(r => r.EmailNavigation.Email == user.Email);
|
||||||
new RunnerMenuWindow().Show();
|
new RunnerMenuWindow().Show();
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
@ -46,35 +47,6 @@ public partial class LoginWindow : Window
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Close();
|
Close();
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// User user = DbHelper.Database.Users
|
|
||||||
// .Include(u => u.Role)
|
|
||||||
// .Single(u =>
|
|
||||||
// EmailBox.Text != null && u.Email == EmailBox.Text.Trim() &&
|
|
||||||
// PasswordBox.Text != null && u.Password == PasswordBox.Text.Trim());
|
|
||||||
//
|
|
||||||
// Session.User = user;
|
|
||||||
// Console.WriteLine("USERROLEID: " + user.Role.RoleId.ToString());
|
|
||||||
// switch (user.Role.RoleId)
|
|
||||||
// {
|
|
||||||
// case 'R':
|
|
||||||
// new RunnerMenuWindow().Show();
|
|
||||||
// break;
|
|
||||||
// case 'C':
|
|
||||||
// new CoordinatorMenuWindow().Show();
|
|
||||||
// break;
|
|
||||||
// case 'A':
|
|
||||||
// new AdministratorMenuWindow().Show();
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// Close();
|
|
||||||
// }
|
|
||||||
// catch (Exception exception)
|
|
||||||
// {
|
|
||||||
// Console.WriteLine("Unlucky");
|
|
||||||
// Console.WriteLine(exception.Message);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Cancel_OnClick(object? sender, RoutedEventArgs e)
|
private void Cancel_OnClick(object? sender, RoutedEventArgs e)
|
||||||
|
@ -20,7 +20,7 @@ public partial class MyResultsWindow : Window
|
|||||||
|
|
||||||
private void Logout_OnClick(object? sender, RoutedEventArgs e)
|
private void Logout_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Session.User = null;
|
Session.Logout();
|
||||||
new MainWindow().Show();
|
new MainWindow().Show();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
@ -2,38 +2,85 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:vm="using:IposiGospodDemo.ViewModels"
|
||||||
xmlns:local="using:IposiGospodDemo"
|
xmlns:local="using:IposiGospodDemo"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="IposiGospodDemo.Views.MySponsorshipWindow"
|
x:Class="IposiGospodDemo.Views.MySponsorshipWindow"
|
||||||
Title="MySponsorshipWindow">
|
x:DataType="vm:MySponsorshipWindowViewModel"
|
||||||
|
Title="MySponsorshipWindow" Padding="10">
|
||||||
<Grid RowDefinitions="Auto * Auto">
|
<Grid RowDefinitions="Auto * Auto">
|
||||||
<Border Grid.Row="0" Background="DarkGray" Padding="10">
|
<Border Grid.Row="0" Background="DarkGray" Padding="10">
|
||||||
<DockPanel VerticalAlignment="Center">
|
<DockPanel VerticalAlignment="Center">
|
||||||
<StackPanel DockPanel.Dock="Left" Orientation="Horizontal" Spacing="10">
|
<StackPanel DockPanel.Dock="Left" Orientation="Horizontal" Spacing="10">
|
||||||
<Button Content="Назад" Click="GoBack_OnClick"/>
|
<Button Content="Назад" Click="GoBack_OnClick"/>
|
||||||
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
|
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
|
||||||
FontSize="24" FontWeight="Bold" Foreground="White"/>
|
FontSize="24" FontWeight="Bold" Foreground="White"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Button Content="Logout" VerticalAlignment="Center" HorizontalAlignment="Right" DockPanel.Dock="Right"
|
<Button Content="Logout" VerticalAlignment="Center" HorizontalAlignment="Right" DockPanel.Dock="Right"
|
||||||
Click="Logout_OnClick"/>
|
Click="Logout_OnClick"/>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<DockPanel Grid.Row="1">
|
<DockPanel Grid.Row="1">
|
||||||
<TextBlock DockPanel.Dock="Top" Text="Мои спонсоры" HorizontalAlignment="Center" FontSize="24" Margin="0 20"/>
|
<TextBlock DockPanel.Dock="Top" Text="Мои спонсоры" HorizontalAlignment="Center" FontSize="24" Margin="0 20"/>
|
||||||
<TextBlock DockPanel.Dock="Top" Text="Здесь показаны все ваши спонсоры в Marathon Skills 2016"
|
<TextBlock DockPanel.Dock="Top" Text="Здесь показаны все ваши спонсоры в Marathon Skills 2016"
|
||||||
HorizontalAlignment="Center" Margin="0 0 0 20"/>
|
HorizontalAlignment="Center" Margin="0 0 0 20"/>
|
||||||
<StackPanel Orientation="Vertical" DockPanel.Dock="Right">
|
<StackPanel Orientation="Vertical" DockPanel.Dock="Left" Spacing="10" Width="400" Margin="0 0 50 0">
|
||||||
<DataGrid>
|
<TextBlock HorizontalAlignment="Center" FontSize="24" Text="{Binding RunnerCharity.CharityName}"
|
||||||
|
TextAlignment="Center" TextWrapping="Wrap"/>
|
||||||
|
<Image Width="200" Stretch="Uniform" HorizontalAlignment="Center"
|
||||||
|
Source="{Binding RunnerCharity.CharityLogo, Converter={StaticResource ImageConverter}}"
|
||||||
|
VerticalAlignment="Center"/>
|
||||||
|
<TextBlock Text="{Binding RunnerCharity.CharityDescription}"
|
||||||
|
TextWrapping="Wrap"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
</DataGrid>
|
<StackPanel Orientation="Vertical" DockPanel.Dock="Right" IsVisible="{Binding Sponsorships.Count}">
|
||||||
</StackPanel>
|
<!-- Заголовки -->
|
||||||
</DockPanel>
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Text="Спонсор" Grid.Column="0" HorizontalAlignment="Left"/>
|
||||||
|
<TextBlock Text="Взнос" Grid.Column="1" HorizontalAlignment="Right"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
|
<!-- Список -->
|
||||||
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
|
<ListBox ItemsSource="{Binding Sponsorships}" Height="200">
|
||||||
VerticalAlignment="Center" Foreground="White"/>
|
<ListBox.ItemTemplate>
|
||||||
</StackPanel>
|
<DataTemplate>
|
||||||
|
<Border Padding="5">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Text="{Binding SponsorName}" Grid.Column="0" HorizontalAlignment="Left"/>
|
||||||
|
<TextBlock Text="{Binding Amount}" Grid.Column="1" HorizontalAlignment="Right"/>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
|
||||||
</Grid>
|
<Border Height="2" Background="Black"/>
|
||||||
|
|
||||||
|
<!-- Итог -->
|
||||||
|
<TextBlock HorizontalAlignment="Right" Margin="0 10 0 0">
|
||||||
|
<Run Text="Всего $" />
|
||||||
|
<Run Text="{Binding TotalAmount}" />
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Vertical" IsVisible="{Binding Sponsorships.Count}">
|
||||||
|
<TextBlock Text="Нет пожертвований" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
|
</StackPanel>
|
||||||
|
</DockPanel>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
|
||||||
|
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center" Foreground="White"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
@ -2,6 +2,7 @@ using Avalonia;
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using IposiGospodDemo.ViewModels;
|
||||||
|
|
||||||
namespace IposiGospodDemo.Views;
|
namespace IposiGospodDemo.Views;
|
||||||
|
|
||||||
@ -10,6 +11,7 @@ public partial class MySponsorshipWindow : Window
|
|||||||
public MySponsorshipWindow()
|
public MySponsorshipWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
DataContext = new MySponsorshipWindowViewModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
|
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
|
||||||
@ -20,7 +22,7 @@ public partial class MySponsorshipWindow : Window
|
|||||||
|
|
||||||
private void Logout_OnClick(object? sender, RoutedEventArgs e)
|
private void Logout_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Session.User = null;
|
Session.Logout();
|
||||||
new MainWindow().Show();
|
new MainWindow().Show();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public partial class RegistrationForAnEventWindow : Window
|
|||||||
|
|
||||||
private void Logout_OnClick(object? sender, RoutedEventArgs e)
|
private void Logout_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Session.User = null;
|
Session.Logout();
|
||||||
new MainWindow().Show();
|
new MainWindow().Show();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public partial class RunnerMenuWindow : Window
|
|||||||
|
|
||||||
private void Logout_OnClick(object? sender, RoutedEventArgs e)
|
private void Logout_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Session.User = null;
|
Session.Logout();
|
||||||
new MainWindow().Show();
|
new MainWindow().Show();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,7 @@ public partial class SponsorARunnerWindow : Window
|
|||||||
newSponsorship.Registration = _viewModel.SelectedRunner.Registrations.FirstOrDefault()!;
|
newSponsorship.Registration = _viewModel.SelectedRunner.Registrations.FirstOrDefault()!;
|
||||||
newSponsorship.Amount = _viewModel.Sum;
|
newSponsorship.Amount = _viewModel.Sum;
|
||||||
DbHelper.Database.Sponsorships.Add(newSponsorship);
|
DbHelper.Database.Sponsorships.Add(newSponsorship);
|
||||||
|
DbHelper.Database.SaveChanges();
|
||||||
|
|
||||||
new SponsorshipConfirmationWindow(_viewModel.SelectedRunner.EmailNavigation, _viewModel.Sum, _viewModel.SelectedCharity.CharityName).Show();
|
new SponsorshipConfirmationWindow(_viewModel.SelectedRunner.EmailNavigation, _viewModel.Sum, _viewModel.SelectedCharity.CharityName).Show();
|
||||||
Close();
|
Close();
|
||||||
|
75
IposiGospodDemo/Views/SponsorshipOverviewWindow.axaml
Normal file
75
IposiGospodDemo/Views/SponsorshipOverviewWindow.axaml
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<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"
|
||||||
|
xmlns:vm="using:IposiGospodDemo.ViewModels"
|
||||||
|
xmlns:local="using:IposiGospodDemo"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="IposiGospodDemo.Views.SponsorshipOverviewWindow"
|
||||||
|
x:DataType="vm:SponsorshipOverviewWindowViewModel"
|
||||||
|
Title="SponsorshipOverviewWindow">
|
||||||
|
<Grid RowDefinitions="Auto * Auto">
|
||||||
|
|
||||||
|
<Border Grid.Row="0" Background="DarkGray" Padding="10">
|
||||||
|
<DockPanel VerticalAlignment="Center">
|
||||||
|
<StackPanel DockPanel.Dock="Left" Orientation="Horizontal" Spacing="10">
|
||||||
|
<Button Content="Назад" Click="GoBack_OnClick"/>
|
||||||
|
<TextBlock Text="{x:Static local:Session.Title}" VerticalAlignment="Center"
|
||||||
|
FontSize="24" FontWeight="Bold" Foreground="White"/>
|
||||||
|
</StackPanel>
|
||||||
|
<Button Content="Logout" VerticalAlignment="Center" HorizontalAlignment="Right" DockPanel.Dock="Right"
|
||||||
|
Click="Logout_OnClick"/>
|
||||||
|
</DockPanel>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<DockPanel Grid.Row="1">
|
||||||
|
<Grid HorizontalAlignment="Stretch">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!-- Заголовки -->
|
||||||
|
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" Grid.Row="0">
|
||||||
|
<TextBlock FontSize="20" FontWeight="Bold" HorizontalAlignment="Center">
|
||||||
|
<Run Text="Благотворительные организации: "/>
|
||||||
|
<Run Text="{Binding Charities.Count}"/>
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock FontSize="20" FontWeight="Bold" HorizontalAlignment="Center" Margin="0,0,0,10">
|
||||||
|
<Run Text="Всего спонсорских взносов: "/>
|
||||||
|
<Run Text="{Binding CharitiesSum, StringFormat=N0}"/>
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- DataGrid -->
|
||||||
|
<DataGrid Grid.Row="1" ItemsSource="{Binding Charities}" AutoGenerateColumns="False"
|
||||||
|
HeadersVisibility="Column" GridLinesVisibility="All"
|
||||||
|
HorizontalAlignment="Stretch" MinWidth="600" Height="400">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTemplateColumn Header="Логотип" Width="Auto">
|
||||||
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Border Height="100" ClipToBounds="True">
|
||||||
|
<Image Source="{Binding CharityLogo, Converter={StaticResource ImageConverter}}"
|
||||||
|
Stretch="Uniform"/>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
|
</DataGridTemplateColumn>
|
||||||
|
|
||||||
|
<DataGridTextColumn Header="Наименование" Binding="{Binding CharityName}" Width="*"/>
|
||||||
|
<DataGridTextColumn Header="Сумма" Binding="{Binding SponsorshipAmount, StringFormat=' $#,##0'}" Width="Auto"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
</Grid>
|
||||||
|
</DockPanel>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="2" Orientation="Vertical" Background="DarkGray" VerticalAlignment="Center">
|
||||||
|
<TextBlock Text="{x:Static local:Session.RemainingTime}" FontSize="20" HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center" Foreground="White"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
29
IposiGospodDemo/Views/SponsorshipOverviewWindow.axaml.cs
Normal file
29
IposiGospodDemo/Views/SponsorshipOverviewWindow.axaml.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
using IposiGospodDemo.ViewModels;
|
||||||
|
|
||||||
|
namespace IposiGospodDemo.Views;
|
||||||
|
|
||||||
|
public partial class SponsorshipOverviewWindow : Window
|
||||||
|
{
|
||||||
|
public SponsorshipOverviewWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
DataContext = new SponsorshipOverviewWindowViewModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GoBack_OnClick(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
new CoordinatorMenuWindow().Show();
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Logout_OnClick(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Session.Logout();
|
||||||
|
new MainWindow().Show();
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user