allWindowsWithoutPasswordValidation

This commit is contained in:
Your Name 2025-01-30 22:54:28 +03:00
parent fe0ba9320c
commit 1057a643f8
31 changed files with 231 additions and 181 deletions

BIN
demo15012025/.DS_Store vendored

Binary file not shown.

View File

@ -7,7 +7,7 @@
Title="Auth"> Title="Auth">
<DockPanel Background="Bisque"> <DockPanel Background="Bisque">
<StackPanel Spacing="5" HorizontalAlignment="Center" VerticalAlignment="Center"> <StackPanel Spacing="5" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBox x:Name="Id" Width="200" Watermark="id"/> <TextBox x:Name="Id" Width="200" Watermark="login"/>
<TextBox x:Name="Password" Width="200" Watermark="password"/> <TextBox x:Name="Password" Width="200" Watermark="password"/>
<Button Click="AuthButton_OnClick" Content="auth" Foreground="Black" Background="LightGray"/> <Button Click="AuthButton_OnClick" Content="auth" Foreground="Black" Background="LightGray"/>
</StackPanel> </StackPanel>

View File

@ -8,7 +8,6 @@ using Avalonia.Controls;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Media.Imaging; using Avalonia.Media.Imaging;
using AvaloniaApplication2.Models;
using demo15012025.Models; using demo15012025.Models;
using demo15012025.ModelsMine; using demo15012025.ModelsMine;

View File

@ -1,9 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using demo15012025.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace AvaloniaApplication2.Models; namespace demo15012025.Models;
public partial class DatabaseContext : DbContext public partial class DatabaseContext : DbContext
{ {
@ -47,24 +46,24 @@ public partial class DatabaseContext : DbContext
modelBuilder.Entity<Activity>(entity => modelBuilder.Entity<Activity>(entity =>
{ {
entity.HasKey(e => e.Id).HasName("activity_pkey"); entity.HasKey(e => e.Id).HasName("activity_pkey");
entity.ToTable("activity"); entity.ToTable("activity");
entity.Property(e => e.Id).HasColumnName("id"); entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Name) entity.Property(e => e.Name)
.HasMaxLength(100) .HasMaxLength(100)
.HasColumnName("name"); .HasColumnName("name");
entity.HasMany(d => d.Moderators).WithMany(p => p.Activities) entity.HasMany(d => d.Moderators).WithMany(p => p.Activities)
.UsingEntity<Dictionary<string, object>>( .UsingEntity<Dictionary<string, object>>(
"Activitymoderator", "Activitymoderator",
r => r.HasOne<Client>().WithMany() r => r.HasOne<Client>().WithMany()
.HasForeignKey("Moderatorid") .HasForeignKey("Moderatorid")
.OnDelete(DeleteBehavior.ClientSetNull) .OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("fk_moderator"), .HasConstraintName("fk_moderator"),
l => l.HasOne<Activity>().WithMany() l => l.HasOne<Activity>().WithMany()
.HasForeignKey("Activityid") .HasForeignKey("Activityid")
.OnDelete(DeleteBehavior.ClientSetNull) .OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("fk_activity"), .HasConstraintName("fk_activity"),
j => j =>
{ {
@ -74,146 +73,146 @@ public partial class DatabaseContext : DbContext
j.IndexerProperty<int>("Moderatorid").HasColumnName("moderatorid"); j.IndexerProperty<int>("Moderatorid").HasColumnName("moderatorid");
}); });
}); });
modelBuilder.Entity<City>(entity => modelBuilder.Entity<City>(entity =>
{ {
entity.HasKey(e => e.Id).HasName("city_pkey"); entity.HasKey(e => e.Id).HasName("city_pkey");
entity.ToTable("city"); entity.ToTable("city");
entity.Property(e => e.Id).HasColumnName("id"); entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Name) entity.Property(e => e.Name)
.HasMaxLength(100) .HasMaxLength(100)
.HasColumnName("name"); .HasColumnName("name");
}); });
modelBuilder.Entity<Client>(entity => modelBuilder.Entity<Client>(entity =>
{ {
entity.HasKey(e => e.Id).HasName("clients_pkey"); entity.HasKey(e => e.Id).HasName("clients_pkey");
entity.ToTable("clients"); entity.ToTable("clients");
entity.Property(e => e.Id).HasColumnName("id"); entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Country).HasColumnName("country"); entity.Property(e => e.Country).HasColumnName("country");
entity.Property(e => e.Date) entity.Property(e => e.Date)
.HasColumnType("timestamp(6) without time zone") .HasColumnType("timestamp(6) without time zone")
.HasColumnName("date"); .HasColumnName("date");
entity.Property(e => e.Email) entity.Property(e => e.Email)
.HasMaxLength(100) .HasMaxLength(100)
.HasColumnName("email"); .HasColumnName("email");
entity.Property(e => e.EventId).HasColumnName("event_id"); entity.Property(e => e.EventId).HasColumnName("event_id");
entity.Property(e => e.Fio) entity.Property(e => e.Fio)
.HasMaxLength(200) .HasMaxLength(200)
.HasColumnName("fio"); .HasColumnName("fio");
entity.Property(e => e.Gender) entity.Property(e => e.Gender)
.HasMaxLength(1) .HasMaxLength(1)
.HasColumnName("gender"); .HasColumnName("gender");
entity.Property(e => e.Password) entity.Property(e => e.Password)
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnName("password"); .HasColumnName("password");
entity.Property(e => e.Phone) entity.Property(e => e.Phone)
.HasMaxLength(20) .HasMaxLength(20)
.HasColumnName("phone"); .HasColumnName("phone");
entity.Property(e => e.Photopath) entity.Property(e => e.Photopath)
.HasMaxLength(100) .HasMaxLength(100)
.HasColumnName("photopath"); .HasColumnName("photopath");
entity.Property(e => e.Role).HasColumnName("role"); entity.Property(e => e.Role).HasColumnName("role");
entity.Property(e => e.SpecId).HasColumnName("spec_id"); entity.Property(e => e.SpecId).HasColumnName("spec_id");
entity.HasOne(d => d.CountryNavigation).WithMany(p => p.Clients) entity.HasOne(d => d.CountryNavigation).WithMany(p => p.Clients)
.HasForeignKey(d => d.Country) .HasForeignKey(d => d.Country)
.OnDelete(DeleteBehavior.ClientSetNull) .OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("fk_country"); .HasConstraintName("fk_country");
entity.HasOne(d => d.Event).WithMany(p => p.Clients) entity.HasOne(d => d.Event).WithMany(p => p.Clients)
.HasForeignKey(d => d.EventId) .HasForeignKey(d => d.EventId)
.HasConstraintName("fk_event_id"); .HasConstraintName("fk_event_id");
entity.HasOne(d => d.RoleNavigation).WithMany(p => p.Clients) entity.HasOne(d => d.RoleNavigation).WithMany(p => p.Clients)
.HasForeignKey(d => d.Role) .HasForeignKey(d => d.Role)
.OnDelete(DeleteBehavior.ClientSetNull) .OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("fk_role"); .HasConstraintName("fk_role");
entity.HasOne(d => d.Spec).WithMany(p => p.Clients) entity.HasOne(d => d.Spec).WithMany(p => p.Clients)
.HasForeignKey(d => d.SpecId) .HasForeignKey(d => d.SpecId)
.HasConstraintName("fk_spec_id"); .HasConstraintName("fk_spec_id");
}); });
modelBuilder.Entity<Country>(entity => modelBuilder.Entity<Country>(entity =>
{ {
entity.HasKey(e => e.Id).HasName("country_pkey"); entity.HasKey(e => e.Id).HasName("country_pkey");
entity.ToTable("country"); entity.ToTable("country");
entity.HasIndex(e => e.Code2, "country_code2_key").IsUnique(); entity.HasIndex(e => e.Code2, "country_code2_key").IsUnique();
entity.Property(e => e.Id).HasColumnName("id"); entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Code) entity.Property(e => e.Code)
.HasMaxLength(5) .HasMaxLength(5)
.HasColumnName("code"); .HasColumnName("code");
entity.Property(e => e.Code2).HasColumnName("code2"); entity.Property(e => e.Code2).HasColumnName("code2");
entity.Property(e => e.EnName) entity.Property(e => e.EnName)
.HasMaxLength(100) .HasMaxLength(100)
.HasColumnName("en_name"); .HasColumnName("en_name");
entity.Property(e => e.Name) entity.Property(e => e.Name)
.HasMaxLength(100) .HasMaxLength(100)
.HasColumnName("name"); .HasColumnName("name");
}); });
modelBuilder.Entity<Direction>(entity => modelBuilder.Entity<Direction>(entity =>
{ {
entity.HasKey(e => e.Id).HasName("direction_pkey"); entity.HasKey(e => e.Id).HasName("direction_pkey");
entity.ToTable("direction"); entity.ToTable("direction");
entity.Property(e => e.Id).HasColumnName("id"); entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Name) entity.Property(e => e.Name)
.HasMaxLength(255) .HasMaxLength(255)
.HasColumnName("name"); .HasColumnName("name");
}); });
modelBuilder.Entity<Event>(entity => modelBuilder.Entity<Event>(entity =>
{ {
entity.HasKey(e => e.Id).HasName("event_pkey"); entity.HasKey(e => e.Id).HasName("event_pkey");
entity.ToTable("event"); entity.ToTable("event");
entity.HasIndex(e => e.Date, "event_date_key").IsUnique(); entity.HasIndex(e => e.Date, "event_date_key").IsUnique();
entity.Property(e => e.Id).HasColumnName("id"); entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.City).HasColumnName("city"); entity.Property(e => e.City).HasColumnName("city");
entity.Property(e => e.Date) entity.Property(e => e.Date)
.HasColumnType("timestamp(6) without time zone") .HasColumnType("timestamp(6) without time zone")
.HasColumnName("date"); .HasColumnName("date");
entity.Property(e => e.Days).HasColumnName("days"); entity.Property(e => e.Days).HasColumnName("days");
entity.Property(e => e.DirectionId).HasColumnName("direction_id"); entity.Property(e => e.DirectionId).HasColumnName("direction_id");
entity.Property(e => e.Photopath) entity.Property(e => e.Photopath)
.HasMaxLength(255) .HasMaxLength(255)
.HasColumnName("photopath"); .HasColumnName("photopath");
entity.Property(e => e.Sobitie) entity.Property(e => e.Sobitie)
.HasMaxLength(200) .HasMaxLength(200)
.HasColumnName("sobitie"); .HasColumnName("sobitie");
entity.HasOne(d => d.CityNavigation).WithMany(p => p.Events) entity.HasOne(d => d.CityNavigation).WithMany(p => p.Events)
.HasForeignKey(d => d.City) .HasForeignKey(d => d.City)
.OnDelete(DeleteBehavior.ClientSetNull) .OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("fk_city"); .HasConstraintName("fk_city");
entity.HasOne(d => d.Direction).WithMany(p => p.Events) entity.HasOne(d => d.Direction).WithMany(p => p.Events)
.HasForeignKey(d => d.DirectionId) .HasForeignKey(d => d.DirectionId)
.OnDelete(DeleteBehavior.SetNull) .OnDelete(DeleteBehavior.SetNull)
.HasConstraintName("fk_event_direction"); .HasConstraintName("fk_event_direction");
entity.HasMany(d => d.Winners).WithMany(p => p.Events) entity.HasMany(d => d.Winners).WithMany(p => p.Events)
.UsingEntity<Dictionary<string, object>>( .UsingEntity<Dictionary<string, object>>(
"Eventwinner", "Eventwinner",
r => r.HasOne<Client>().WithMany() r => r.HasOne<Client>().WithMany()
.HasForeignKey("Winnerid") .HasForeignKey("Winnerid")
.OnDelete(DeleteBehavior.ClientSetNull) .OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("fk_moderator"), .HasConstraintName("fk_moderator"),
l => l.HasOne<Event>().WithMany() l => l.HasOne<Event>().WithMany()
.HasForeignKey("Eventid") .HasForeignKey("Eventid")
.OnDelete(DeleteBehavior.ClientSetNull) .OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("fk_event"), .HasConstraintName("fk_event"),
j => j =>
{ {
@ -223,78 +222,78 @@ public partial class DatabaseContext : DbContext
j.IndexerProperty<int>("Winnerid").HasColumnName("winnerid"); j.IndexerProperty<int>("Winnerid").HasColumnName("winnerid");
}); });
}); });
modelBuilder.Entity<Eventactivity>(entity => modelBuilder.Entity<Eventactivity>(entity =>
{ {
entity entity
.HasNoKey() .HasNoKey()
.ToTable("eventactivity"); .ToTable("eventactivity");
entity.Property(e => e.Activityid).HasColumnName("activityid"); entity.Property(e => e.Activityid).HasColumnName("activityid");
entity.Property(e => e.Eventid).HasColumnName("eventid"); entity.Property(e => e.Eventid).HasColumnName("eventid");
entity.HasOne(d => d.Activity).WithMany() entity.HasOne(d => d.Activity).WithMany()
.HasForeignKey(d => d.Activityid) .HasForeignKey(d => d.Activityid)
.OnDelete(DeleteBehavior.ClientSetNull) .OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("fk_activity"); .HasConstraintName("fk_activity");
entity.HasOne(d => d.Event).WithMany() entity.HasOne(d => d.Event).WithMany()
.HasForeignKey(d => d.Eventid) .HasForeignKey(d => d.Eventid)
.OnDelete(DeleteBehavior.ClientSetNull) .OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("fk_event"); .HasConstraintName("fk_event");
}); });
modelBuilder.Entity<Jhuriactivity>(entity => modelBuilder.Entity<Jhuriactivity>(entity =>
{ {
entity entity
.HasNoKey() .HasNoKey()
.ToTable("jhuriactivity"); .ToTable("jhuriactivity");
entity.Property(e => e.Activityid).HasColumnName("activityid"); entity.Property(e => e.Activityid).HasColumnName("activityid");
entity.Property(e => e.Jhuriid).HasColumnName("jhuriid"); entity.Property(e => e.Jhuriid).HasColumnName("jhuriid");
entity.HasOne(d => d.Activity).WithMany() entity.HasOne(d => d.Activity).WithMany()
.HasForeignKey(d => d.Activityid) .HasForeignKey(d => d.Activityid)
.OnDelete(DeleteBehavior.ClientSetNull) .OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("fk_activity"); .HasConstraintName("fk_activity");
entity.HasOne(d => d.Jhuri).WithMany() entity.HasOne(d => d.Jhuri).WithMany()
.HasForeignKey(d => d.Jhuriid) .HasForeignKey(d => d.Jhuriid)
.HasConstraintName("fk_moderator"); .HasConstraintName("fk_moderator");
}); });
modelBuilder.Entity<Role>(entity => modelBuilder.Entity<Role>(entity =>
{ {
entity.HasKey(e => e.Id).HasName("roles_pkey"); entity.HasKey(e => e.Id).HasName("roles_pkey");
entity.ToTable("roles"); entity.ToTable("roles");
entity.Property(e => e.Id).HasColumnName("id"); entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Name) entity.Property(e => e.Name)
.HasMaxLength(20) .HasMaxLength(20)
.HasColumnName("name"); .HasColumnName("name");
}); });
modelBuilder.Entity<ValidActivityJhuri>(entity => modelBuilder.Entity<ValidActivityJhuri>(entity =>
{ {
entity entity
.HasNoKey() .HasNoKey()
.ToView("valid_activity_jhuri"); .ToView("valid_activity_jhuri");
entity.Property(e => e.Activityid).HasColumnName("activityid"); entity.Property(e => e.Activityid).HasColumnName("activityid");
entity.Property(e => e.Jhuriid).HasColumnName("jhuriid"); entity.Property(e => e.Jhuriid).HasColumnName("jhuriid");
}); });
modelBuilder.Entity<ValidActivityModerator>(entity => modelBuilder.Entity<ValidActivityModerator>(entity =>
{ {
entity entity
.HasNoKey() .HasNoKey()
.ToView("valid_activity_moderators"); .ToView("valid_activity_moderators");
entity.Property(e => e.Activityid).HasColumnName("activityid"); entity.Property(e => e.Activityid).HasColumnName("activityid");
entity.Property(e => e.Moderatorid).HasColumnName("moderatorid"); entity.Property(e => e.Moderatorid).HasColumnName("moderatorid");
}); });
OnModelCreatingPartial(modelBuilder); OnModelCreatingPartial(modelBuilder);
} }

View File

@ -5,59 +5,59 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="demo15012025.RegJhuri" x:Class="demo15012025.RegJhuri"
Title="RegJhuri"> Title="RegJhuri">
<DockPanel> <DockPanel Background="Beige">
<TextBlock Text="Регистрация жюри/модераторов" FontSize="22" HorizontalAlignment="Center" VerticalAlignment="Center" DockPanel.Dock="Top" Foreground="Black"/>
<Grid> <Grid>
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Margin="15"> <StackPanel Orientation="Vertical" HorizontalAlignment="Left" Margin="15">
<TextBlock Text="Id Number:" VerticalAlignment="Top"/> <TextBlock Text="Id Number:" VerticalAlignment="Top" Foreground="Black"/>
<TextBox Width="250" HorizontalAlignment="Left" x:Name="TextId"/> <TextBox Width="250" HorizontalAlignment="Left" x:Name="TextId" IsReadOnly="True" Background="Gray"/>
<TextBlock Text="Фио:" VerticalAlignment="Top"/> <TextBlock Text="Фио:" VerticalAlignment="Top" Foreground="Black"/>
<TextBox Width="250" HorizontalAlignment="Left" x:Name="TextFio"/> <TextBox Width="250" HorizontalAlignment="Left" x:Name="TextFio"/>
<TextBlock Text="Пол:" VerticalAlignment="Top"/> <TextBlock Text="Пол:" VerticalAlignment="Top" Foreground="Black"/>
<ComboBox Width="250" HorizontalAlignment="Left" x:Name="TextGender" SelectionChanged="OnGenderSelectionChanged"> <ComboBox Width="250" HorizontalAlignment="Left" x:Name="TextGender" SelectionChanged="OnGenderSelectionChanged">
<ComboBoxItem Content="Мужской" x:Name="M"/> <ComboBoxItem Content="Мужской" x:Name="M"/>
<ComboBoxItem Content="Женский" x:Name="F"/> <ComboBoxItem Content="Женский" x:Name="F"/>
</ComboBox> </ComboBox>
<TextBlock Text="Роль:" VerticalAlignment="Top"/> <TextBlock Text="Роль:" VerticalAlignment="Top" Foreground="Black"/>
<ComboBox Width="250" HorizontalAlignment="Left" x:Name="TextRole" SelectionChanged="OnRoleSelectionChanged"> <ComboBox Width="250" HorizontalAlignment="Left" x:Name="TextRole" SelectionChanged="OnRoleSelectionChanged">
<ComboBoxItem Content="Жюри" x:Name="Jhuri"/> <ComboBoxItem Content="Жюри" x:Name="Jhuri"/>
<ComboBoxItem Content="Модератор" x:Name="Moderator"/> <ComboBoxItem Content="Модератор" x:Name="Moderator"/>
</ComboBox> </ComboBox>
<TextBlock Text="Email:" VerticalAlignment="Top"/> <TextBlock Text="Email:" VerticalAlignment="Top" Foreground="Black"/>
<TextBox Width="250" HorizontalAlignment="Left" x:Name="TextEmail"/> <TextBox Width="250" HorizontalAlignment="Left" x:Name="TextEmail"/>
<TextBlock Text="Телефон:" VerticalAlignment="Top"/> <TextBlock Text="Телефон:" VerticalAlignment="Top" Foreground="Black"/>
<TextBox Width="250" Name="PhoneTextBox" Text="+7 " KeyUp="PhoneTextBox_OnKeyUp" HorizontalAlignment="Left" x:Name="TextPhone"/> <TextBox Width="250" Name="PhoneTextBox" Text="+7 " KeyUp="PhoneTextBox_OnKeyUp" HorizontalAlignment="Left" x:Name="TextPhone"/>
<TextBlock Text="Направление:" VerticalAlignment="Top"/> <TextBlock Text="Направление:" VerticalAlignment="Top" Foreground="Black"/>
<ComboBox Width="250" HorizontalAlignment="Left" x:Name="ComboBoxDirection"/> <ComboBox Width="250" HorizontalAlignment="Left" x:Name="ComboBoxDirection"/>
<CheckBox Content="Прикрепить к мероприятию" HorizontalAlignment="Right"/> <TextBlock Text="Мероприятие:" VerticalAlignment="Top" Foreground="Black"/>
<TextBlock Text="Мероприятие:" VerticalAlignment="Top"/>
<ComboBox Width="250" HorizontalAlignment="Left" x:Name="ComboBoxEvent"/> <ComboBox Width="250" HorizontalAlignment="Left" x:Name="ComboBoxEvent"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Vertical" HorizontalAlignment="Right" Margin="15"> <StackPanel Orientation="Vertical" HorizontalAlignment="Right" Margin="15">
<Rectangle Width="200" Height="250" Fill="Gray" HorizontalAlignment="Right"/> <Button Width="105" x:Name="SelectImageButton" Content="Select Image" Click="SelectImage" Foreground="Black" Background="LightGray"/>
<Image Width="200" Height="250" x:Name="ServiceImage"/>
<TextBlock Text="Пароль:" VerticalAlignment="Top"/> <TextBlock Text="Пароль:" VerticalAlignment="Top" Foreground="Black"/>
<TextBox Width="250" HorizontalAlignment="Left" Watermark="Password" x:Name="TextPassword"/> <TextBox Width="250" HorizontalAlignment="Left" Watermark="Password" x:Name="TextPassword"/>
<TextBlock Text="Повтор пароля:" VerticalAlignment="Top"/> <TextBlock Text="Повтор пароля:" VerticalAlignment="Top" Foreground="Black"/>
<TextBox Width="250" HorizontalAlignment="Left" Watermark="Re-enter password" x:Name="TextRePassword"/> <TextBox Width="250" HorizontalAlignment="Left" Watermark="Re-enter password" x:Name="TextRePassword"/>
<CheckBox Content="Видимый пароль" HorizontalAlignment="Right"/> <CheckBox Content="Видимый пароль" HorizontalAlignment="Right" Foreground="Black"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="10"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="10">
<Button Content="Ok" HorizontalAlignment="Right" Click="OkButton_OnClick"/> <Button Content="Ok" HorizontalAlignment="Right" Click="OkButton_OnClick" Foreground="Black" Background="LightGray"/>
<Button Content="Отмена" HorizontalAlignment="Right"/> <Button Content="Отмена" HorizontalAlignment="Right" Foreground="Black" Background="LightGray"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</Grid> </Grid>
</DockPanel> </DockPanel>
</Window> </Window>

View File

@ -1,12 +1,15 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using AvaloniaApplication2.Models; using Avalonia.Media.Imaging;
using Avalonia.Platform.Storage;
using demo15012025.Models; using demo15012025.Models;
namespace demo15012025; namespace demo15012025;
@ -16,18 +19,20 @@ public partial class RegJhuri : Window
public string gender { get; set; } public string gender { get; set; }
public string role { get; set; } public string role { get; set; }
public Client returnClient { get; set; } public Client returnClient { get; set; }
public List<string> SpecList { get; }
public List<string> EventList { get; }
public string PathToImage = string.Empty;
public Guid newGuidPhoto;
public RegJhuri() public RegJhuri()
{ {
InitializeComponent(); InitializeComponent();
using var context = new DatabaseContext(); using var context = new DatabaseContext();
var events = MainWindow.EventAuthList; SpecList = context.Directions.Select(it => it.Name).ToList();
var spec = context.Directions.Select(it => new Direction ComboBoxDirection.ItemsSource = SpecList;
{ EventList = context.Events.Select(it => it.Sobitie).ToList();
Id = it.Id, ComboBoxEvent.ItemsSource = EventList;
Name = it.Name, var maxId = context.Clients.Max(it => it.Id);
}); TextId.Text = maxId.ToString();
ComboBoxDirection.ItemsSource = spec;
ComboBoxEvent.ItemsSource = events;
} }
private void OnGenderSelectionChanged(object? sender, SelectionChangedEventArgs e) private void OnGenderSelectionChanged(object? sender, SelectionChangedEventArgs e)
@ -38,8 +43,7 @@ public partial class RegJhuri : Window
if (selectedItem != null) if (selectedItem != null)
{ {
string content = selectedItem.Content.ToString(); string content = selectedItem.Content.ToString();
gender = content == "Мужской" ? "M" : "F";
string gender = content == "Мужской" ? "M" : "F";
} }
} }
@ -51,10 +55,7 @@ public partial class RegJhuri : Window
if (selectedItem != null) if (selectedItem != null)
{ {
string content = selectedItem.Content.ToString(); string content = selectedItem.Content.ToString();
role = content == "Жюри" ? "3" : content == "Модератор" ? "4" : "0"; // Обновляем свойство role
int role = content == "Жюри" ? 3 : content == "Модератор" ? 4 : 0;
Console.WriteLine($"Выбрана роль с ID: {role}");
} }
} }
@ -72,10 +73,11 @@ public partial class RegJhuri : Window
textBox.CaretIndex = formatted.Length; textBox.CaretIndex = formatted.Length;
} }
} }
private void OkButton_OnClick(object? sender, RoutedEventArgs e) private void OkButton_OnClick(object? sender, RoutedEventArgs e)
{ {
using var context = new DatabaseContext(); using var context = new DatabaseContext();
var maxId = context.Clients.Max(client => client.Id); var maxId = context.Clients.Max(client => client.Id);
var returnId = maxId + 1; var returnId = maxId + 1;
var returnFio = TextFio.Text; var returnFio = TextFio.Text;
@ -83,29 +85,79 @@ public partial class RegJhuri : Window
var returnRole = role; var returnRole = role;
var returnEmail = TextEmail.Text; var returnEmail = TextEmail.Text;
var returnPhone = PhoneTextBox.Text; var returnPhone = PhoneTextBox.Text;
var returnSpec = ComboBoxDirection.SelectedItem; var returnSpec = ComboBoxDirection.SelectedItem;
var returnEvent = ComboBoxEvent.SelectedItem; var returnEvent = ComboBoxEvent.SelectedItem;
if (returnSpec == null || returnEvent == null)
{
Console.WriteLine("Направление или мероприятие не выбрано.");
return;
}
var returnPassword = TextPassword.Text; var returnPassword = TextPassword.Text;
var returnPassword2 = TextRePassword.Text; var returnPassword2 = TextRePassword.Text;
if (returnPassword != returnPassword2) if (returnPassword != returnPassword2)
{ {
Console.WriteLine("wrong passwords"); Console.WriteLine("Пароли не совпадают.");
return;
} }
else
var specId = context.Directions.FirstOrDefault(it => it.Name == returnSpec)?.Id;
var eventId = context.Events.FirstOrDefault(it => it.Sobitie == returnEvent)?.Id;
if (specId == null || eventId == null)
{ {
returnClient = new Client() Console.WriteLine("Направление или мероприятие не найдено.");
return;
}
returnClient = new Client()
{
Id = returnId,
Fio = returnFio,
Gender = returnGender[0],
Role = int.Parse(returnRole),
Email = returnEmail,
Phone = returnPhone,
SpecId = specId.Value,
EventId = eventId.Value,
Password = returnPassword,
Photopath = $"{newGuidPhoto}.jpg",
Country = 1,
};
context.Clients.Add(returnClient);
context.SaveChanges();
}
private async void SelectImage(object? sender, RoutedEventArgs e)
{
ServiceImage.Source = await SelectAndSaveImage();
}
private async Task<Bitmap?> SelectAndSaveImage()
{
var showDialog = StorageProvider.OpenFilePickerAsync(
options: new Avalonia.Platform.Storage.FilePickerOpenOptions()
{ {
Id = returnId, Title = "Select an image",
Fio = returnFio, FileTypeFilter = new[] { FilePickerFileTypes.ImageAll }
Gender = returnGender[0], });
Role = int.Parse(returnRole), var storageFile = await showDialog;
Email = returnEmail, try
Phone = returnPhone, {
SpecId = context.Directions.FirstOrDefault(it => it.Name == returnSpec).Id, var bmp = new Bitmap(storageFile.First().TryGetLocalPath());
EventId = context.Events.FirstOrDefault(it => it.Sobitie == returnEvent).Id, newGuidPhoto = Guid.NewGuid();
Password = returnPassword, string path = $"/Users/rinchi/RiderProjects/demo15012025/demo15012025/bin/Debug/net8.0/{newGuidPhoto}.jpg";
}; bmp.Save(path);
context.Clients.Add(returnClient); PathToImage = path;
Console.WriteLine(PathToImage);
return bmp;
}
catch
{
return null;
} }
} }
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

View File

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

View File

@ -1 +1 @@
ad77349803af53c5bfc1e7ca37edc522319a7f41648c37032eba4b36ce3ef074 9be47889b8d73cd0463d35e7868addd6cbb3ce57cb06c77fc2cd288c4821de5c