mda
This commit is contained in:
parent
d823905d6c
commit
fe0ba9320c
@ -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)
|
||||
|
@ -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>();
|
||||
|
@ -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
|
||||
{
|
||||
@ -100,15 +101,13 @@ public partial class DatabaseContext : DbContext
|
||||
entity.Property(e => e.Email)
|
||||
.HasMaxLength(100)
|
||||
.HasColumnName("email");
|
||||
entity.Property(e => e.EventId).HasColumnName("event_id");
|
||||
entity.Property(e => e.Fio)
|
||||
.HasMaxLength(200)
|
||||
.HasColumnName("fio");
|
||||
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)
|
||||
.HasColumnName("password");
|
||||
@ -119,19 +118,25 @@ public partial class DatabaseContext : DbContext
|
||||
.HasMaxLength(100)
|
||||
.HasColumnName("photopath");
|
||||
entity.Property(e => e.Role).HasColumnName("role");
|
||||
entity.Property(e => e.Spec)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("spec");
|
||||
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.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 =>
|
||||
|
@ -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>();
|
||||
}
|
||||
|
@ -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>();
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -10,45 +10,51 @@
|
||||
<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>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("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")]
|
||||
|
@ -1 +1 @@
|
||||
24a6a02c857323065555cf2adff2f30d21c3351bda097b2a5c06f3a37503196d
|
||||
ad77349803af53c5bfc1e7ca37edc522319a7f41648c37032eba4b36ce3ef074
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user