This commit is contained in:
Your Name 2025-01-30 11:15:08 +03:00
parent d823905d6c
commit fe0ba9320c
20 changed files with 262 additions and 166 deletions

View File

@ -8,6 +8,7 @@ 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;
@ -22,6 +23,7 @@ public partial class MainWindow : Window
public List<string> DirectionsList { get; } public List<string> DirectionsList { get; }
public List<DateTime> DatesList { get; } public List<DateTime> DatesList { get; }
public static ObservableCollection<ClientAuth> ClientAuthList { get; set; } public static ObservableCollection<ClientAuth> ClientAuthList { get; set; }
public static ObservableCollection<EventPresenter> EventAuthList { get; set; }
public MainWindow() public MainWindow()
{ {
@ -101,6 +103,7 @@ public partial class MainWindow : Window
authClients.Add(item); authClients.Add(item);
} }
ClientAuthList = authClients; ClientAuthList = authClients;
EventAuthList = events;
} }
private void AuthButton_OnClick(object? sender, RoutedEventArgs e) private void AuthButton_OnClick(object? sender, RoutedEventArgs e)

View File

@ -19,20 +19,24 @@ public partial class Client
public string Password { get; set; } = null!; public string Password { get; set; } = null!;
public string? Spec { get; set; }
public string? Meropriyatie { get; set; }
public string Photopath { get; set; } = null!; public string Photopath { get; set; } = null!;
public char Gender { get; set; } public char Gender { get; set; }
public int Role { get; set; } public int Role { get; set; }
public int? SpecId { get; set; }
public int? EventId { get; set; }
public virtual Country CountryNavigation { get; set; } = null!; public virtual Country CountryNavigation { get; set; } = null!;
public virtual Event? Event { get; set; }
public virtual Role RoleNavigation { get; set; } = null!; public virtual Role RoleNavigation { get; set; } = null!;
public virtual Direction? Spec { get; set; }
public virtual ICollection<Activity> Activities { get; set; } = new List<Activity>(); public virtual ICollection<Activity> Activities { get; set; } = new List<Activity>();
public virtual ICollection<Event> Events { get; set; } = new List<Event>(); public virtual ICollection<Event> Events { get; set; } = new List<Event>();

View File

@ -1,8 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using demo15012025.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace demo15012025.Models; namespace AvaloniaApplication2.Models;
public partial class DatabaseContext : DbContext public partial class DatabaseContext : DbContext
{ {
@ -46,24 +47,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 =>
{ {
@ -73,142 +74,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.Fio) entity.Property(e => e.EventId).HasColumnName("event_id");
.HasMaxLength(200) entity.Property(e => e.Fio)
.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.Meropriyatie) entity.Property(e => e.Password)
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnName("meropriyatie");
entity.Property(e => e.Password)
.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.Spec) entity.Property(e => e.SpecId).HasColumnName("spec_id");
.HasMaxLength(50)
.HasColumnName("spec"); entity.HasOne(d => d.CountryNavigation).WithMany(p => p.Clients)
.HasForeignKey(d => d.Country)
entity.HasOne(d => d.CountryNavigation).WithMany(p => p.Clients) .OnDelete(DeleteBehavior.ClientSetNull)
.HasForeignKey(d => d.Country)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("fk_country"); .HasConstraintName("fk_country");
entity.HasOne(d => d.RoleNavigation).WithMany(p => p.Clients) entity.HasOne(d => d.Event).WithMany(p => p.Clients)
.HasForeignKey(d => d.Role) .HasForeignKey(d => d.EventId)
.OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("fk_event_id");
entity.HasOne(d => d.RoleNavigation).WithMany(p => p.Clients)
.HasForeignKey(d => d.Role)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("fk_role"); .HasConstraintName("fk_role");
entity.HasOne(d => d.Spec).WithMany(p => p.Clients)
.HasForeignKey(d => d.SpecId)
.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 =>
{ {
@ -218,78 +223,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

@ -9,5 +9,7 @@ public partial class Direction
public string Name { get; set; } = null!; public string Name { get; set; } = null!;
public virtual ICollection<Client> Clients { get; set; } = new List<Client>();
public virtual ICollection<Event> Events { get; set; } = new List<Event>(); public virtual ICollection<Event> Events { get; set; } = new List<Event>();
} }

View File

@ -21,6 +21,8 @@ public partial class Event
public virtual City CityNavigation { get; set; } = null!; public virtual City CityNavigation { get; set; } = null!;
public virtual ICollection<Client> Clients { get; set; } = new List<Client>();
public virtual Direction? Direction { get; set; } public virtual Direction? Direction { get; set; }
public virtual ICollection<Client> Winners { get; set; } = new List<Client>(); public virtual ICollection<Client> Winners { get; set; } = new List<Client>();

View File

@ -3,6 +3,7 @@ using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using demo15012025.Models;
using demo15012025.ModelsMine; using demo15012025.ModelsMine;
using Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.Mapping; using Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.Mapping;
@ -33,7 +34,7 @@ public partial class OrganizatorWindow : Window
private void _3Button_OnClick(object? sender, RoutedEventArgs e) private void _3Button_OnClick(object? sender, RoutedEventArgs e)
{ {
RegJhuri regJhuri = new RegJhuri(); var regJhuri = new RegJhuri();
regJhuri.ShowDialog(this); regJhuri.ShowDialog(this);
} }

View File

@ -8,47 +8,53 @@
<DockPanel> <DockPanel>
<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"/>
<TextBox Width="250" HorizontalAlignment="Left"/> <TextBox Width="250" HorizontalAlignment="Left" x:Name="TextId"/>
<TextBlock Text="Фио:" VerticalAlignment="Top"/> <TextBlock Text="Фио:" VerticalAlignment="Top"/>
<TextBox Width="250" HorizontalAlignment="Left"/> <TextBox Width="250" HorizontalAlignment="Left" x:Name="TextFio"/>
<TextBlock Text="Пол:" VerticalAlignment="Top"/> <TextBlock Text="Пол:" VerticalAlignment="Top"/>
<ComboBox Width="250" HorizontalAlignment="Left"/> <ComboBox Width="250" HorizontalAlignment="Left" x:Name="TextGender" SelectionChanged="OnGenderSelectionChanged">
<ComboBoxItem Content="Мужской" x:Name="M"/>
<ComboBoxItem Content="Женский" x:Name="F"/>
</ComboBox>
<TextBlock Text="Роль:" VerticalAlignment="Top"/> <TextBlock Text="Роль:" VerticalAlignment="Top"/>
<ComboBox Width="250" HorizontalAlignment="Left"/> <ComboBox Width="250" HorizontalAlignment="Left" x:Name="TextRole" SelectionChanged="OnRoleSelectionChanged">
<ComboBoxItem Content="Жюри" x:Name="Jhuri"/>
<ComboBoxItem Content="Модератор" x:Name="Moderator"/>
</ComboBox>
<TextBlock Text="Email:" VerticalAlignment="Top"/> <TextBlock Text="Email:" VerticalAlignment="Top"/>
<TextBox Width="250" HorizontalAlignment="Left"/> <TextBox Width="250" HorizontalAlignment="Left" x:Name="TextEmail"/>
<TextBlock Text="Телефон:" VerticalAlignment="Top"/> <TextBlock Text="Телефон:" VerticalAlignment="Top"/>
<TextBox Width="250" Name="PhoneTextBox" Text="+7 " KeyUp="PhoneTextBox_OnKeyUp" HorizontalAlignment="Left"/> <TextBox Width="250" Name="PhoneTextBox" Text="+7 " KeyUp="PhoneTextBox_OnKeyUp" HorizontalAlignment="Left" x:Name="TextPhone"/>
<TextBlock Text="Направление:" VerticalAlignment="Top"/> <TextBlock Text="Направление:" VerticalAlignment="Top"/>
<TextBox Width="250" HorizontalAlignment="Left"/> <ComboBox Width="250" HorizontalAlignment="Left" x:Name="ComboBoxDirection"/>
<CheckBox Content="Прикрепить к мероприятию" HorizontalAlignment="Right"/> <CheckBox Content="Прикрепить к мероприятию" HorizontalAlignment="Right"/>
<TextBlock Text="Мероприятие:" VerticalAlignment="Top"/> <TextBlock Text="Мероприятие:" VerticalAlignment="Top"/>
<ComboBox Width="250" HorizontalAlignment="Left"/> <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"/> <Rectangle Width="200" Height="250" Fill="Gray" HorizontalAlignment="Right"/>
<TextBlock Text="Пароль:" VerticalAlignment="Top"/> <TextBlock Text="Пароль:" VerticalAlignment="Top"/>
<TextBox Width="250" HorizontalAlignment="Left" Watermark="Password"/> <TextBox Width="250" HorizontalAlignment="Left" Watermark="Password" x:Name="TextPassword"/>
<TextBlock Text="Повтор пароля:" VerticalAlignment="Top"/> <TextBlock Text="Повтор пароля:" VerticalAlignment="Top"/>
<TextBox Width="250" HorizontalAlignment="Left" Watermark="Re-enter password"/> <TextBox Width="250" HorizontalAlignment="Left" Watermark="Re-enter password" x:Name="TextRePassword"/>
<CheckBox Content="Видимый пароль" HorizontalAlignment="Right"/> <CheckBox Content="Видимый пароль" HorizontalAlignment="Right"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="10"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="10">
<Button Content="Ok" HorizontalAlignment="Right"/> <Button Content="Ok" HorizontalAlignment="Right" Click="OkButton_OnClick"/>
<Button Content="Отмена" HorizontalAlignment="Right"/> <Button Content="Отмена" HorizontalAlignment="Right"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>

View File

@ -1,38 +1,111 @@
using System; using System;
using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using AvaloniaApplication2.Models;
using demo15012025.Models;
namespace demo15012025; namespace demo15012025;
public partial class RegJhuri : Window public partial class RegJhuri : Window
{ {
public string gender { get; set; }
public string role { get; set; }
public Client returnClient { get; set; }
public RegJhuri() public RegJhuri()
{ {
InitializeComponent(); InitializeComponent();
using var context = new DatabaseContext();
var events = MainWindow.EventAuthList;
var spec = context.Directions.Select(it => new Direction
{
Id = it.Id,
Name = it.Name,
});
ComboBoxDirection.ItemsSource = spec;
ComboBoxEvent.ItemsSource = events;
}
private void OnGenderSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
var comboBox = sender as ComboBox;
var selectedItem = comboBox?.SelectedItem as ComboBoxItem;
if (selectedItem != null)
{
string content = selectedItem.Content.ToString();
string gender = content == "Мужской" ? "M" : "F";
}
}
private void OnRoleSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
var comboBox = sender as ComboBox;
var selectedItem = comboBox?.SelectedItem as ComboBoxItem;
if (selectedItem != null)
{
string content = selectedItem.Content.ToString();
int role = content == "Жюри" ? 3 : content == "Модератор" ? 4 : 0;
Console.WriteLine($"Выбрана роль с ID: {role}");
}
} }
private void PhoneTextBox_OnKeyUp(object? sender, KeyEventArgs e) private void PhoneTextBox_OnKeyUp(object? sender, KeyEventArgs e)
{ {
if (sender is TextBox textBox) if (sender is TextBox textBox)
{ {
// Убираем все символы, кроме цифр
string digitsOnly = Regex.Replace(textBox.Text, @"\D", ""); string digitsOnly = Regex.Replace(textBox.Text, @"\D", "");
// Формируем текст с маской
string formatted = "+7 "; string formatted = "+7 ";
if (digitsOnly.Length > 1) formatted += "(" + digitsOnly.Substring(1, Math.Min(3, digitsOnly.Length - 1)) + ")"; if (digitsOnly.Length > 1) formatted += "(" + digitsOnly.Substring(1, Math.Min(3, digitsOnly.Length - 1)) + ")";
if (digitsOnly.Length > 4) formatted += " " + digitsOnly.Substring(4, Math.Min(3, digitsOnly.Length - 4)); if (digitsOnly.Length > 4) formatted += " " + digitsOnly.Substring(4, Math.Min(3, digitsOnly.Length - 4));
if (digitsOnly.Length > 7) formatted += "-" + digitsOnly.Substring(7, Math.Min(2, digitsOnly.Length - 7)); if (digitsOnly.Length > 7) formatted += "-" + digitsOnly.Substring(7, Math.Min(2, digitsOnly.Length - 7));
if (digitsOnly.Length > 9) formatted += "-" + digitsOnly.Substring(9, Math.Min(2, digitsOnly.Length - 9)); if (digitsOnly.Length > 9) formatted += "-" + digitsOnly.Substring(9, Math.Min(2, digitsOnly.Length - 9));
// Сохраняем текст с маской
textBox.Text = formatted; textBox.Text = formatted;
// Перемещаем курсор в конец текста
textBox.CaretIndex = formatted.Length; textBox.CaretIndex = formatted.Length;
} }
} }
}
private void OkButton_OnClick(object? sender, RoutedEventArgs e)
{
using var context = new DatabaseContext();
var maxId = context.Clients.Max(client => client.Id);
var returnId = maxId + 1;
var returnFio = TextFio.Text;
var returnGender = gender;
var returnRole = role;
var returnEmail = TextEmail.Text;
var returnPhone = PhoneTextBox.Text;
var returnSpec = ComboBoxDirection.SelectedItem;
var returnEvent = ComboBoxEvent.SelectedItem;
var returnPassword = TextPassword.Text;
var returnPassword2 = TextRePassword.Text;
if (returnPassword != returnPassword2)
{
Console.WriteLine("wrong passwords");
}
else
{
returnClient = new Client()
{
Id = returnId,
Fio = returnFio,
Gender = returnGender[0],
Role = int.Parse(returnRole),
Email = returnEmail,
Phone = returnPhone,
SpecId = context.Directions.FirstOrDefault(it => it.Name == returnSpec).Id,
EventId = context.Events.FirstOrDefault(it => it.Sobitie == returnEvent).Id,
Password = returnPassword,
};
context.Clients.Add(returnClient);
}
}
}

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+3db87ed23d758d9ce8019736887da1a5ffeb7ca9")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d823905d6c3ec8eb41766b1ca3e569530bce21a7")]
[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 @@
24a6a02c857323065555cf2adff2f30d21c3351bda097b2a5c06f3a37503196d ad77349803af53c5bfc1e7ca37edc522319a7f41648c37032eba4b36ce3ef074