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.Interactivity;
using Avalonia.Media.Imaging;
using AvaloniaApplication2.Models;
using demo15012025.Models;
using demo15012025.ModelsMine;
@ -22,6 +23,7 @@ public partial class MainWindow : Window
public List<string> DirectionsList { get; }
public List<DateTime> DatesList { get; }
public static ObservableCollection<ClientAuth> ClientAuthList { get; set; }
public static ObservableCollection<EventPresenter> EventAuthList { get; set; }
public MainWindow()
{
@ -101,6 +103,7 @@ public partial class MainWindow : Window
authClients.Add(item);
}
ClientAuthList = authClients;
EventAuthList = events;
}
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? Spec { get; set; }
public string? Meropriyatie { get; set; }
public string Photopath { get; set; } = null!;
public char Gender { 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 Event? Event { get; set; }
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<Event> Events { get; set; } = new List<Event>();

View File

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

View File

@ -9,5 +9,7 @@ public partial class Direction
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>();
}

View File

@ -21,6 +21,8 @@ public partial class Event
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 ICollection<Client> Winners { get; set; } = new List<Client>();

View File

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

View File

@ -8,47 +8,53 @@
<DockPanel>
<Grid>
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Margin="15">
<TextBlock Text="Id Number:" VerticalAlignment="Top"/>
<TextBox Width="250" HorizontalAlignment="Left"/>
<TextBox Width="250" HorizontalAlignment="Left" x:Name="TextId"/>
<TextBlock Text="Фио:" VerticalAlignment="Top"/>
<TextBox Width="250" HorizontalAlignment="Left"/>
<TextBox Width="250" HorizontalAlignment="Left" x:Name="TextFio"/>
<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"/>
<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"/>
<TextBox Width="250" HorizontalAlignment="Left"/>
<TextBox Width="250" HorizontalAlignment="Left" x:Name="TextEmail"/>
<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"/>
<TextBox Width="250" HorizontalAlignment="Left"/>
<ComboBox Width="250" HorizontalAlignment="Left" x:Name="ComboBoxDirection"/>
<CheckBox Content="Прикрепить к мероприятию" HorizontalAlignment="Right"/>
<TextBlock Text="Мероприятие:" VerticalAlignment="Top"/>
<ComboBox Width="250" HorizontalAlignment="Left"/>
<ComboBox Width="250" HorizontalAlignment="Left" x:Name="ComboBoxEvent"/>
</StackPanel>
<StackPanel Orientation="Vertical" HorizontalAlignment="Right" Margin="15">
<Rectangle Width="200" Height="250" Fill="Gray" HorizontalAlignment="Right"/>
<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"/>
<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"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="10">
<Button Content="Ok" HorizontalAlignment="Right"/>
<Button Content="Ok" HorizontalAlignment="Right" Click="OkButton_OnClick"/>
<Button Content="Отмена" HorizontalAlignment="Right"/>
</StackPanel>
</StackPanel>

View File

@ -1,38 +1,111 @@
using System;
using System.Linq;
using System.Text.RegularExpressions;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using AvaloniaApplication2.Models;
using demo15012025.Models;
namespace demo15012025;
public partial class RegJhuri : Window
{
public string gender { get; set; }
public string role { get; set; }
public Client returnClient { get; set; }
public RegJhuri()
{
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)
{
if (sender is TextBox textBox)
{
// Убираем все символы, кроме цифр
string digitsOnly = Regex.Replace(textBox.Text, @"\D", "");
// Формируем текст с маской
string formatted = "+7 ";
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 > 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));
// Сохраняем текст с маской
textBox.Text = formatted;
// Перемещаем курсор в конец текста
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.AssemblyConfigurationAttribute("Debug")]
[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.AssemblyTitleAttribute("demo15012025")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
24a6a02c857323065555cf2adff2f30d21c3351bda097b2a5c06f3a37503196d
ad77349803af53c5bfc1e7ca37edc522319a7f41648c37032eba4b36ce3ef074