This commit is contained in:
zxc
2026-10-19 16:40:51 +03:00
parent a6829fb2cb
commit bdc3cda4e0
71 changed files with 517 additions and 1482 deletions
+16
View File
@@ -0,0 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "demka", "demka\demka.csproj", "{BE29E09C-CEF5-40A7-B437-DF98152650C1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BE29E09C-CEF5-40A7-B437-DF98152650C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BE29E09C-CEF5-40A7-B437-DF98152650C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE29E09C-CEF5-40A7-B437-DF98152650C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE29E09C-CEF5-40A7-B437-DF98152650C1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
+15
View File
@@ -0,0 +1,15 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="demka.App"
xmlns:local="using:demka"
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>
+28
View File
@@ -0,0 +1,28 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using demka.ViewModels;
using demka.Views;
namespace demka;
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,11 @@
using System;
using System.Collections.Generic;
namespace demka.Models;
public partial class IdCategory
{
public int? IdCategory1 { get; set; }
public string? NameCategory { get; set; }
}
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
namespace demka.Models;
public partial class IdManufacturer
{
public int? IdManufacturer1 { get; set; }
public string? NameManufacturer { get; set; }
}
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace demka.Models;
public partial class IdOrder
{
public int? IdOrder1 { get; set; }
public int? IdProduct { get; set; }
public int? Quantity { get; set; }
}
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
namespace demka.Models;
public partial class IdProduct
{
public int? IdProduct1 { get; set; }
public string? Article { get; set; }
public string? Name { get; set; }
public int? IdUnit { get; set; }
public int? Price { get; set; }
public int? IdSupplier { get; set; }
public int? IdManufacturer { get; set; }
public int? IdCategory { get; set; }
public int? Discount { get; set; }
public int? StockQty { get; set; }
public string? Description { get; set; }
public string? Photo { get; set; }
}
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
namespace demka.Models;
public partial class IdStatus
{
public int? IdStatus1 { get; set; }
public string? NameStatus { get; set; }
}
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
namespace demka.Models;
public partial class IdSupplier
{
public int? IdSupplier1 { get; set; }
public string? NameSupplier { get; set; }
}
+11
View File
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
namespace demka.Models;
public partial class IdUnit
{
public int? IdUnit1 { get; set; }
public string? NameUnit { get; set; }
}
@@ -0,0 +1,222 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
namespace demka.Models;
public partial class PostgresContext : DbContext
{
public PostgresContext()
{
}
public PostgresContext(DbContextOptions<PostgresContext> options)
: base(options)
{
}
public virtual DbSet<IdCategory> IdCategories { get; set; }
public virtual DbSet<IdManufacturer> IdManufacturers { get; set; }
public virtual DbSet<IdOrder> IdOrders { get; set; }
public virtual DbSet<IdProduct> IdProducts { get; set; }
public virtual DbSet<IdStatus> IdStatuses { get; set; }
public virtual DbSet<IdSupplier> IdSuppliers { get; set; }
public virtual DbSet<IdUnit> IdUnits { get; set; }
public virtual DbSet<RoleId> RoleIds { get; set; }
public virtual DbSet<Tovar> Tovars { get; set; }
public virtual DbSet<UserId> UserIds { get; set; }
public virtual DbSet<ЗаказImport> ЗаказImports { 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=mysecretpassword");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<IdCategory>(entity =>
{
entity
.HasNoKey()
.ToTable("id_category");
entity.Property(e => e.IdCategory1).HasColumnName("id_category");
entity.Property(e => e.NameCategory)
.HasMaxLength(50)
.HasColumnName("name_category");
});
modelBuilder.Entity<IdManufacturer>(entity =>
{
entity
.HasNoKey()
.ToTable("id_manufacturer");
entity.Property(e => e.IdManufacturer1).HasColumnName("id_manufacturer");
entity.Property(e => e.NameManufacturer)
.HasMaxLength(50)
.HasColumnName("name_manufacturer");
});
modelBuilder.Entity<IdOrder>(entity =>
{
entity
.HasNoKey()
.ToTable("id_order");
entity.Property(e => e.IdOrder1).HasColumnName("id_order");
entity.Property(e => e.IdProduct).HasColumnName("id_product");
entity.Property(e => e.Quantity).HasColumnName("quantity");
});
modelBuilder.Entity<IdProduct>(entity =>
{
entity
.HasNoKey()
.ToTable("id_product");
entity.Property(e => e.Article)
.HasMaxLength(50)
.HasColumnName("article");
entity.Property(e => e.Description)
.HasMaxLength(128)
.HasColumnName("description");
entity.Property(e => e.Discount).HasColumnName("discount");
entity.Property(e => e.IdCategory).HasColumnName("id_category");
entity.Property(e => e.IdManufacturer).HasColumnName("id_manufacturer");
entity.Property(e => e.IdProduct1).HasColumnName("id_product");
entity.Property(e => e.IdSupplier).HasColumnName("id_supplier");
entity.Property(e => e.IdUnit).HasColumnName("id_unit");
entity.Property(e => e.Name)
.HasMaxLength(50)
.HasColumnName("name");
entity.Property(e => e.Photo)
.HasMaxLength(50)
.HasColumnName("photo");
entity.Property(e => e.Price).HasColumnName("price");
entity.Property(e => e.StockQty).HasColumnName("stock_qty");
});
modelBuilder.Entity<IdStatus>(entity =>
{
entity
.HasNoKey()
.ToTable("id_status");
entity.Property(e => e.IdStatus1).HasColumnName("id_status");
entity.Property(e => e.NameStatus)
.HasMaxLength(50)
.HasColumnName("name_status");
});
modelBuilder.Entity<IdSupplier>(entity =>
{
entity
.HasNoKey()
.ToTable("id_supplier");
entity.Property(e => e.IdSupplier1).HasColumnName("id_supplier");
entity.Property(e => e.NameSupplier)
.HasMaxLength(50)
.HasColumnName("name_supplier");
});
modelBuilder.Entity<IdUnit>(entity =>
{
entity
.HasNoKey()
.ToTable("id_unit");
entity.Property(e => e.IdUnit1).HasColumnName("id_unit");
entity.Property(e => e.NameUnit)
.HasMaxLength(50)
.HasColumnName("name_unit");
});
modelBuilder.Entity<RoleId>(entity =>
{
entity
.HasNoKey()
.ToTable("role_id");
entity.Property(e => e.IdRole).HasColumnName("id_role");
entity.Property(e => e.NameRole)
.HasMaxLength(50)
.HasColumnName("name_role");
});
modelBuilder.Entity<Tovar>(entity =>
{
entity
.HasNoKey()
.ToTable("tovar");
entity.Property(e => e.City)
.HasMaxLength(50)
.HasColumnName("city");
entity.Property(e => e.Column10).HasMaxLength(50);
entity.Property(e => e.Column11).HasMaxLength(50);
entity.Property(e => e.Column6).HasMaxLength(50);
entity.Property(e => e.Column7).HasMaxLength(50);
entity.Property(e => e.Column8).HasMaxLength(50);
entity.Property(e => e.Column9).HasMaxLength(50);
entity.Property(e => e.House).HasColumnName("house");
entity.Property(e => e.IdPoint).HasColumnName("id_point");
entity.Property(e => e.Index).HasColumnName("index");
entity.Property(e => e.Street)
.HasMaxLength(50)
.HasColumnName("street");
});
modelBuilder.Entity<UserId>(entity =>
{
entity
.HasNoKey()
.ToTable("user_id");
entity.Property(e => e.FullName)
.HasMaxLength(50)
.HasColumnName("full_name");
entity.Property(e => e.IdRole).HasColumnName("id_role");
entity.Property(e => e.IdUser).HasColumnName("id_user");
entity.Property(e => e.Login)
.HasMaxLength(50)
.HasColumnName("login");
entity.Property(e => e.Password)
.HasMaxLength(50)
.HasColumnName("password");
});
modelBuilder.Entity<ЗаказImport>(entity =>
{
entity
.HasNoKey()
.ToTable("заказ_import");
entity.Property(e => e.DeliveryDate)
.HasMaxLength(50)
.HasColumnName("delivery_date");
entity.Property(e => e.IdOrder).HasColumnName("id_order");
entity.Property(e => e.IdPoint).HasColumnName("id_point");
entity.Property(e => e.IdStatus).HasColumnName("id_status");
entity.Property(e => e.IdUser).HasColumnName("id_user");
entity.Property(e => e.OrderDate)
.HasMaxLength(50)
.HasColumnName("order_date");
entity.Property(e => e.ReceiveCode).HasColumnName("receive_code");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
+11
View File
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
namespace demka.Models;
public partial class RoleId
{
public int? IdRole { get; set; }
public string? NameRole { get; set; }
}
+29
View File
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
namespace demka.Models;
public partial class Tovar
{
public int? IdPoint { get; set; }
public int? Index { get; set; }
public string? City { get; set; }
public string? Street { get; set; }
public int? House { get; set; }
public string? Column6 { get; set; }
public string? Column7 { get; set; }
public string? Column8 { get; set; }
public string? Column9 { get; set; }
public string? Column10 { get; set; }
public string? Column11 { get; set; }
}
+17
View File
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
namespace demka.Models;
public partial class UserId
{
public int? IdUser { get; set; }
public string? FullName { get; set; }
public string? Login { get; set; }
public string? Password { get; set; }
public int? IdRole { get; set; }
}
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
namespace demka.Models;
public partial class ЗаказImport
{
public int? IdOrder { get; set; }
public string? OrderDate { get; set; }
public string? DeliveryDate { get; set; }
public int? IdPoint { get; set; }
public int? IdUser { get; set; }
public int? ReceiveCode { get; set; }
public int? IdStatus { get; set; }
}
+24
View File
@@ -0,0 +1,24 @@
using Avalonia;
using System;
namespace demka;
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();
}
+37
View File
@@ -0,0 +1,37 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using demka.ViewModels;
namespace demka;
/// <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 demka.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 demka.ViewModels;
public abstract class ViewModelBase : ObservableObject
{
}
@@ -0,0 +1,43 @@
<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"
xmlns:models="clr-namespace:demka.Models"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="demka.Views.MainWindow"
Title="demka">
<!-- главный каркас топ-бар и список -->
<Grid RowDefinitions="Auto, *" Margin="20">
<!-- топ-бар поиск, сортировка, фильтр -->
<Grid Grid.Row="0" ColumnDefinitions="*, Auto, Auto" ColumnSpacing="10" Margin="0,0,0,20">
<TextBox Grid.Column="0" Watermark="Введите для поиска" />
<ComboBox Grid.Column="1" PlaceholderText="Сортировка" MinWidth="120" HorizontalAlignment="Stretch" />
<ComboBox Grid.Column="2" PlaceholderText="Фильтрация" MinWidth="120" HorizontalAlignment="Stretch" />
</Grid>
<!-- Список элементов ListBox -->
<ListBox Grid.Row="1" x:Name="ProductList">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type models:Tovar}">
<StackPanel Margin="8" Spacing="4">
<!-- Основная информация об адресе / пункте -->
<StackPanel Orientation="Horizontal" Spacing="10">
<TextBlock Text="{Binding City, StringFormat='Город: {0}'}" FontWeight="SemiBold" FontSize="16" />
<TextBlock Text="{Binding Street, StringFormat='Улица: {0}'}" FontSize="16" />
<TextBlock Text="{Binding House, StringFormat='Д. {0}'}" FontSize="16" />
</StackPanel>
<!-- Дополнительные поля -->
<StackPanel Orientation="Horizontal" Spacing="15">
<TextBlock Text="{Binding Index, StringFormat='Индекс: {0}', TargetNullValue='—'}" Foreground="Gray" FontSize="12" />
<TextBlock Text="{Binding IdPoint, StringFormat='ID пункта: {0}', TargetNullValue='—'}" Foreground="Gray" FontSize="12" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Window>
@@ -0,0 +1,24 @@
using Avalonia.Controls;
using Microsoft.EntityFrameworkCore;
using demka.Models;
using System.Linq;
namespace demka.Views
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
// создание контекста базы данных
using var context = new PostgresContext();
var items = context.Tovars.ToList();
// установка источника данных в code-behind
ProductList.ItemsSource = items;
}
}
}
+18
View File
@@ -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="demka.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>
+30
View File
@@ -0,0 +1,30 @@
<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.*">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.*" />
</ItemGroup>
</Project>