generated from 328/demo-template
day24
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prielb", "Prielb\Prielb.csproj", "{F5F7AA02-B6C0-4B68-8A0C-0ED26C18AE2B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F5F7AA02-B6C0-4B68-8A0C-0ED26C18AE2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F5F7AA02-B6C0-4B68-8A0C-0ED26C18AE2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F5F7AA02-B6C0-4B68-8A0C-0ED26C18AE2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F5F7AA02-B6C0-4B68-8A0C-0ED26C18AE2B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,15 @@
|
||||
<Application xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Prielb.App"
|
||||
xmlns:local="using:Prielb"
|
||||
RequestedThemeVariant="Default">
|
||||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||
|
||||
<Application.DataTemplates>
|
||||
<local:ViewLocator />
|
||||
</Application.DataTemplates>
|
||||
|
||||
<Application.Styles>
|
||||
<FluentTheme />
|
||||
</Application.Styles>
|
||||
</Application>
|
||||
@@ -0,0 +1,28 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Prielb.ViewModels;
|
||||
using Prielb.Views;
|
||||
|
||||
namespace Prielb;
|
||||
|
||||
public partial class App : Application
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
desktop.MainWindow = new MainWindow
|
||||
{
|
||||
DataContext = new MainViewModel(),
|
||||
};
|
||||
}
|
||||
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 172 KiB |
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Prielb.Models;
|
||||
|
||||
namespace Prielb.Data;
|
||||
|
||||
public partial class StudentDbContext : DbContext
|
||||
{
|
||||
public StudentDbContext()
|
||||
{
|
||||
}
|
||||
|
||||
public StudentDbContext(DbContextOptions<StudentDbContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
public virtual DbSet<City> Cities { get; set; }
|
||||
|
||||
public virtual DbSet<Client> Clients { get; set; }
|
||||
|
||||
public virtual DbSet<Dolzhnost> Dolzhnosts { get; set; }
|
||||
|
||||
|
||||
|
||||
public virtual DbSet<Sotrudnik> Sotrudniks { get; set; }
|
||||
|
||||
public virtual DbSet<StatusOrd> StatusOrds { get; set; }
|
||||
|
||||
|
||||
|
||||
public virtual DbSet<Tupe> Tupes { get; set; }
|
||||
|
||||
|
||||
|
||||
public virtual DbSet<Yslygi> Yslygis { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
|
||||
=> optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=postgres;Username=postgres;Password=ffr404ffr");
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
|
||||
|
||||
modelBuilder.Entity<City>(entity =>
|
||||
{
|
||||
entity
|
||||
.HasNoKey()
|
||||
.ToTable("cities", "prielb");
|
||||
|
||||
entity.Property(e => e.CitiId)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("Citi_id");
|
||||
entity.Property(e => e.Id).HasColumnName("ID");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Client>(entity =>
|
||||
{
|
||||
entity
|
||||
.HasNoKey()
|
||||
.ToTable("clients", "prielb");
|
||||
|
||||
entity.Property(e => e.ClientId).HasColumnName("Client_id");
|
||||
entity.Property(e => e.EMail)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("e-mail");
|
||||
entity.Property(e => e.Index).HasColumnName("index");
|
||||
entity.Property(e => e.NumberStreet).HasColumnName("Number_street");
|
||||
entity.Property(e => e.Pasport).HasMaxLength(50);
|
||||
entity.Property(e => e.Password)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("password");
|
||||
entity.Property(e => e.Street).HasMaxLength(50);
|
||||
entity.Property(e => e.ДатаРождения)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("Дата рождения");
|
||||
entity.Property(e => e.Фио)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("ФИО");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Dolzhnost>(entity =>
|
||||
{
|
||||
entity
|
||||
.HasNoKey()
|
||||
.ToTable("dolzhnost", "prielb");
|
||||
|
||||
entity.Property(e => e.DolzhnostId)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("Dolzhnost_id");
|
||||
entity.Property(e => e.Id).HasColumnName("ID");
|
||||
});
|
||||
|
||||
|
||||
|
||||
modelBuilder.Entity<Sotrudnik>(entity =>
|
||||
{
|
||||
entity
|
||||
.HasNoKey()
|
||||
.ToTable("sotrudnik", "prielb");
|
||||
|
||||
entity.Property(e => e.КодСотрудника)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("Код сотрудника");
|
||||
entity.Property(e => e.Логин)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("Логин ");
|
||||
entity.Property(e => e.Пароль).HasMaxLength(50);
|
||||
entity.Property(e => e.ПоследнийВход)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("Последний вход");
|
||||
entity.Property(e => e.ТипВхода).HasColumnName("Тип входа");
|
||||
entity.Property(e => e.Фио)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("ФИО ");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<StatusOrd>(entity =>
|
||||
{
|
||||
entity
|
||||
.HasNoKey()
|
||||
.ToTable("status_ord", "prielb");
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("ID");
|
||||
entity.Property(e => e.StatusId)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("Status_id");
|
||||
});
|
||||
|
||||
|
||||
|
||||
modelBuilder.Entity<Yslygi>(entity =>
|
||||
{
|
||||
entity
|
||||
.HasNoKey()
|
||||
.ToTable("yslygi", "prielb");
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("ID");
|
||||
entity.Property(e => e.КодУслуги)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("Код услуги");
|
||||
entity.Property(e => e.НаименованиеУслуги)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("Наименование услуги");
|
||||
entity.Property(e => e.СтоимостьРубЗаЧас).HasColumnName("Стоимость, руб. за час ");
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Prielb.Models;
|
||||
|
||||
public partial class City
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? CitiId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Prielb.Models;
|
||||
|
||||
public partial class Client
|
||||
{
|
||||
public string? Фио { get; set; }
|
||||
|
||||
public int? ClientId { get; set; }
|
||||
|
||||
public string? Pasport { get; set; }
|
||||
|
||||
public string? ДатаРождения { get; set; }
|
||||
|
||||
public int? Index { get; set; }
|
||||
|
||||
public int? Cities { get; set; }
|
||||
|
||||
public int? NumberStreet { get; set; }
|
||||
|
||||
public int? Appart { get; set; }
|
||||
|
||||
public string? Street { get; set; }
|
||||
|
||||
public string? EMail { get; set; }
|
||||
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Prielb.Models;
|
||||
|
||||
public partial class Dolzhnost
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? DolzhnostId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Prielb.Models;
|
||||
|
||||
public partial class Sotrudnik
|
||||
{
|
||||
public string? КодСотрудника { get; set; }
|
||||
|
||||
public int? Должность { get; set; }
|
||||
|
||||
public string? Фио { get; set; }
|
||||
|
||||
public string? Логин { get; set; }
|
||||
|
||||
public string? Пароль { get; set; }
|
||||
|
||||
public string? ПоследнийВход { get; set; }
|
||||
|
||||
public int? ТипВхода { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Prielb.Models;
|
||||
|
||||
public partial class StatusOrd
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? StatusId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Prielb.Models;
|
||||
|
||||
public partial class Tupe
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? TupeId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Prielb.Models;
|
||||
|
||||
public partial class Yslygi
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? НаименованиеУслуги { get; set; }
|
||||
|
||||
public string? КодУслуги { get; set; }
|
||||
|
||||
public int? СтоимостьРубЗаЧас { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
<AvaloniaResource Include="Assets\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="12.1.4" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="12.1.4" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="12.1.4" />
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="12.1.4" />
|
||||
<PackageReference Include="AvaloniaUI.DiagnosticsSupport" Version="2.2.3">
|
||||
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
||||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="11.0.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.*" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,24 @@
|
||||
using Avalonia;
|
||||
using System;
|
||||
|
||||
namespace Prielb;
|
||||
|
||||
sealed class Program
|
||||
{
|
||||
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
||||
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
||||
// yet and stuff might break.
|
||||
[STAThread]
|
||||
public static void Main(string[] args) => BuildAvaloniaApp()
|
||||
.StartWithClassicDesktopLifetime(args);
|
||||
|
||||
// Avalonia configuration, don't remove; also used by visual designer.
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
#if DEBUG
|
||||
.WithDeveloperTools()
|
||||
#endif
|
||||
.WithInterFont()
|
||||
.LogToTrace();
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Templates;
|
||||
using Prielb.ViewModels;
|
||||
|
||||
namespace Prielb;
|
||||
|
||||
/// <summary>
|
||||
/// Given a view model, returns the corresponding view if possible.
|
||||
/// </summary>
|
||||
[RequiresUnreferencedCode(
|
||||
"Default implementation of ViewLocator involves reflection which may be trimmed away.",
|
||||
Url = "https://docs.avaloniaui.net/docs/concepts/view-locator")]
|
||||
public class ViewLocator : IDataTemplate
|
||||
{
|
||||
public Control? Build(object? param)
|
||||
{
|
||||
if (param is null)
|
||||
return null;
|
||||
|
||||
var name = param.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
|
||||
var type = Type.GetType(name);
|
||||
|
||||
if (type != null)
|
||||
{
|
||||
return (Control)Activator.CreateInstance(type)!;
|
||||
}
|
||||
|
||||
return new TextBlock { Text = "Not Found: " + name };
|
||||
}
|
||||
|
||||
public bool Match(object? data)
|
||||
{
|
||||
return data is ViewModelBase;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace Prielb.ViewModels;
|
||||
|
||||
public partial class MainViewModel : ViewModelBase
|
||||
{
|
||||
[ObservableProperty] public partial string Greeting { get; set; } = "Welcome to Avalonia!";
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace Prielb.ViewModels;
|
||||
|
||||
public abstract class ViewModelBase : ObservableObject
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Prielb.ViewModels"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Prielb.Views.MainWindow"
|
||||
x:DataType="vm:MainViewModel"
|
||||
Icon="/Assets/avalonia-logo.ico"
|
||||
Title="Авторизация">
|
||||
|
||||
<StackPanel Spacing="10" Margin="20">
|
||||
|
||||
<!-- Заголовок -->
|
||||
<TextBlock Text="Вход"
|
||||
FontSize="22"
|
||||
FontWeight="Bold" />
|
||||
|
||||
<!-- Поле имени -->
|
||||
<TextBlock Text="Логин:" />
|
||||
<TextBox x:Name="NameTextBox"
|
||||
PlaceholderText="Введите ваш логин" />
|
||||
|
||||
<!-- Поле пароля -->
|
||||
<TextBlock Text="Пароль:" />
|
||||
<TextBox x:Name="PasswordTextBox"
|
||||
PasswordChar="•" />
|
||||
|
||||
<!-- Кнопки -->
|
||||
<StackPanel Orientation="Horizontal" Spacing="10">
|
||||
<Button x:Name="SubmitButton"
|
||||
Content="Вход"
|
||||
Click="OnSubmitClick" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Сообщение о результате -->
|
||||
<TextBlock x:Name="MessageText"
|
||||
Foreground="Gray"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
</StackPanel>
|
||||
</Window>
|
||||
@@ -0,0 +1,36 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Prielb.Data;
|
||||
|
||||
namespace Prielb.Views;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
private async void OnSubmitClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
using var db = new StudentDbContext();
|
||||
var user = await db.Sotrudniks.FirstOrDefaultAsync(p =>
|
||||
p.Логин == NameTextBox.Text && p.Пароль == PasswordTextBox.Text);
|
||||
if (user != null)
|
||||
{
|
||||
new Window().ShowDialog(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<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"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Prielb.Views.cyk"
|
||||
Title="cyk">
|
||||
Welcome to Avalonia!
|
||||
</Window>
|
||||
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Prielb.Views;
|
||||
|
||||
public partial class cyk : Window
|
||||
{
|
||||
public cyk()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<!-- This manifest is used on Windows only.
|
||||
Don't remove it as it might cause problems with window transparency and embedded controls.
|
||||
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
|
||||
<assemblyIdentity version="1.0.0.0" name="Prielb.Desktop"/>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- A list of the Windows versions that this application has been tested on
|
||||
and is designed to work with. Uncomment the appropriate elements
|
||||
and Windows will automatically select the most compatible environment. -->
|
||||
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||
</application>
|
||||
</compatibility>
|
||||
</assembly>
|
||||
Reference in New Issue
Block a user