demo
This commit is contained in:
parent
cb48f05a53
commit
4ba7d31e91
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.vs/tiron_demo/DesignTimeBuild/.dtbcache.v2
Normal file
BIN
.vs/tiron_demo/DesignTimeBuild/.dtbcache.v2
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -3,8 +3,8 @@
|
||||
"WorkspaceRootPath": "C:\\Users\\Profi\\Desktop\\tiron_demo\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{B5EE34CD-8D12-443D-98D2-8B30C47ECC47}|tiron_demo.csproj|c:\\users\\profi\\desktop\\tiron_demo\\mainwindow.axaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{B5EE34CD-8D12-443D-98D2-8B30C47ECC47}|tiron_demo.csproj|solutionrelative:mainwindow.axaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
"AbsoluteMoniker": "D:0:0:{B5EE34CD-8D12-443D-98D2-8B30C47ECC47}|tiron_demo.csproj|c:\\users\\profi\\desktop\\tiron_demo\\tiron_demo.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|",
|
||||
"RelativeMoniker": "D:0:0:{B5EE34CD-8D12-443D-98D2-8B30C47ECC47}|tiron_demo.csproj|solutionrelative:tiron_demo.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
@ -19,14 +19,14 @@
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "MainWindow.axaml.cs",
|
||||
"DocumentMoniker": "C:\\Users\\Profi\\Desktop\\tiron_demo\\MainWindow.axaml.cs",
|
||||
"RelativeDocumentMoniker": "MainWindow.axaml.cs",
|
||||
"ToolTip": "C:\\Users\\Profi\\Desktop\\tiron_demo\\MainWindow.axaml.cs",
|
||||
"RelativeToolTip": "MainWindow.axaml.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-25T07:56:30.322Z",
|
||||
"Title": "tiron_demo",
|
||||
"DocumentMoniker": "C:\\Users\\Profi\\Desktop\\tiron_demo\\tiron_demo.csproj",
|
||||
"RelativeDocumentMoniker": "tiron_demo.csproj",
|
||||
"ToolTip": "C:\\Users\\Profi\\Desktop\\tiron_demo\\tiron_demo.csproj",
|
||||
"RelativeToolTip": "tiron_demo.csproj",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAcAAAAeAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000758|",
|
||||
"WhenOpened": "2025-03-25T12:35:19.155Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
|
@ -1,12 +1,37 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\Users\\Profi\\Desktop\\tiron_demo\\",
|
||||
"Documents": [],
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{B5EE34CD-8D12-443D-98D2-8B30C47ECC47}|tiron_demo.csproj|c:\\users\\profi\\desktop\\tiron_demo\\tiron_demo.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|",
|
||||
"RelativeMoniker": "D:0:0:{B5EE34CD-8D12-443D-98D2-8B30C47ECC47}|tiron_demo.csproj|solutionrelative:tiron_demo.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": []
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 0,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "tiron_demo",
|
||||
"DocumentMoniker": "C:\\Users\\Profi\\Desktop\\tiron_demo\\tiron_demo.csproj",
|
||||
"RelativeDocumentMoniker": "tiron_demo.csproj",
|
||||
"ToolTip": "C:\\Users\\Profi\\Desktop\\tiron_demo\\tiron_demo.csproj",
|
||||
"RelativeToolTip": "tiron_demo.csproj",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAcAAAAeAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000758|",
|
||||
"WhenOpened": "2025-03-25T12:35:19.155Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
31
AddPartner.axaml
Normal file
31
AddPartner.axaml
Normal file
@ -0,0 +1,31 @@
|
||||
<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="tiron_demo.AddPartner"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Icon="avares://tiron_demo/Resources/icon.ico"
|
||||
Title="Добавление/редактирование партнёра">
|
||||
<Grid Margin="10" RowDefinitions="*, auto">
|
||||
<StackPanel Spacing="10" Grid.Row="0" Name="PartnerPanel">
|
||||
<TextBlock HorizontalAlignment="Center" FontWeight="Bold" Text="Добавление/редактирование продукта" />
|
||||
<TextBox Watermark="Наименование" Text="{Binding Name}" />
|
||||
<TextBox Watermark="Рейтинг" Text="{Binding Rating}" />
|
||||
<TextBox Watermark="Адрес" Text="{Binding Address}" />
|
||||
<TextBox Watermark="ФИО директора" Text="{Binding Director}" />
|
||||
<TextBox Watermark="Телефон" Text="{Binding Phone}" />
|
||||
<TextBox Watermark="E-mail" Text="{Binding Email}" />
|
||||
<ComboBox Name="PartnerTypeComboBox" SelectedItem="{Binding TypeNavigation}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
|
||||
<Button Grid.Row="1" HorizontalAlignment="Left" Content="Назад" Click="Button_Click_Back" />
|
||||
<Button Grid.Row="1" HorizontalAlignment="Right" Content="Сохранить" Click="Button_Click_Save" />
|
||||
</Grid>
|
||||
</Window>
|
67
AddPartner.axaml.cs
Normal file
67
AddPartner.axaml.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using System.Linq;
|
||||
using tiron_demo.Context;
|
||||
using tiron_demo.Models;
|
||||
|
||||
namespace tiron_demo;
|
||||
|
||||
public partial class AddPartner : Window
|
||||
{
|
||||
private short _ratingBackup;
|
||||
private Partner _partner;
|
||||
|
||||
public AddPartner()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_partner = new Partner();
|
||||
_ratingBackup = 0;
|
||||
|
||||
PartnerTypeComboBox.ItemsSource = Helper.context.PartnerTypes;
|
||||
PartnerPanel.DataContext = _partner;
|
||||
}
|
||||
|
||||
public AddPartner(Partner partner)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_partner = partner;
|
||||
_ratingBackup = partner.Rating;
|
||||
|
||||
PartnerTypeComboBox.ItemsSource = Helper.context.PartnerTypes;
|
||||
PartnerPanel.DataContext = _partner;
|
||||
}
|
||||
|
||||
private void Button_Click_Back(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
_partner.Rating = _ratingBackup;
|
||||
|
||||
PartnersWindow partnersWindow = new PartnersWindow();
|
||||
partnersWindow.Show();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Button_Click_Save(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
if (_partner.Rating >= 0)
|
||||
{
|
||||
if (_partner.Id == 0)
|
||||
{
|
||||
Helper.context.Partners.Add(_partner);
|
||||
Helper.context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
Helper.context.Partners.Update(_partner);
|
||||
Helper.context.SaveChanges();
|
||||
}
|
||||
|
||||
PartnersWindow partnersWindow = new PartnersWindow();
|
||||
partnersWindow.Show();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
28
AddProduct.axaml
Normal file
28
AddProduct.axaml
Normal file
@ -0,0 +1,28 @@
|
||||
<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="tiron_demo.AddProduct"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Icon="avares://tiron_demo/Resources/icon.ico"
|
||||
Title="Добавление/редактирование продукта">
|
||||
<Grid Margin="10" RowDefinitions="*, auto">
|
||||
<StackPanel Spacing="10" Grid.Row="0" Name="ProductPanel">
|
||||
<TextBlock HorizontalAlignment="Center" FontWeight="Bold" Text="Добавление/редактирование продукта" />
|
||||
<TextBox Watermark="Наименование" Text="{Binding Name}" />
|
||||
<TextBox IsEnabled="False" Watermark="Артикул" Text="{Binding Articul}" />
|
||||
<TextBox Watermark="Минимальная стоимость для партнёра" Text="{Binding MinCost}" />
|
||||
<ComboBox Name="ProductTypeComboBox" SelectedItem="{Binding TypeNavigation}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
|
||||
<Button Grid.Row="1" HorizontalAlignment="Left" Content="Назад" Click="Button_Click_Back" />
|
||||
<Button Grid.Row="1" HorizontalAlignment="Right" Content="Сохранить" Click="Button_Click_Save" />
|
||||
</Grid>
|
||||
</Window>
|
86
AddProduct.axaml.cs
Normal file
86
AddProduct.axaml.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using tiron_demo.Context;
|
||||
using tiron_demo.Models;
|
||||
|
||||
namespace tiron_demo;
|
||||
|
||||
public partial class AddProduct : Window
|
||||
{
|
||||
private float _minCostBackup;
|
||||
private Product _product;
|
||||
|
||||
public AddProduct()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_product = new Product();
|
||||
_product.Articul = GenerateArticul();
|
||||
_minCostBackup = 0;
|
||||
|
||||
ProductTypeComboBox.ItemsSource = Helper.context.ProductTypes;
|
||||
ProductPanel.DataContext = _product;
|
||||
}
|
||||
|
||||
public AddProduct(Product product)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_product = product;
|
||||
_minCostBackup = product.MinCost;
|
||||
|
||||
ProductTypeComboBox.ItemsSource = Helper.context.ProductTypes;
|
||||
ProductPanel.DataContext = _product;
|
||||
}
|
||||
|
||||
private string GenerateArticul()
|
||||
{
|
||||
Random rnd = new Random();
|
||||
string articul = "";
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
articul += rnd.Next(10);
|
||||
}
|
||||
|
||||
if (Helper.context.Products.Where(x => x.Articul == articul).Count() > 0)
|
||||
{
|
||||
articul = GenerateArticul();
|
||||
}
|
||||
|
||||
return articul;
|
||||
}
|
||||
|
||||
private void Button_Click_Back(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
_product.MinCost = _minCostBackup;
|
||||
|
||||
ProductsWindow productsWindow = new ProductsWindow();
|
||||
productsWindow.Show();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Button_Click_Save(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
if (_product.MinCost >= 0)
|
||||
{
|
||||
if (_product.Id == 0)
|
||||
{
|
||||
Helper.context.Products.Add(_product);
|
||||
Helper.context.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
Helper.context.Products.Update(_product);
|
||||
Helper.context.SaveChanges();
|
||||
}
|
||||
|
||||
ProductsWindow productsWindow = new ProductsWindow();
|
||||
productsWindow.Show();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
13
Context/Helper.cs
Normal file
13
Context/Helper.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace tiron_demo.Context
|
||||
{
|
||||
public class Helper
|
||||
{
|
||||
public static User20Context context = new User20Context();
|
||||
}
|
||||
}
|
222
Context/User20Context.cs
Normal file
222
Context/User20Context.cs
Normal file
@ -0,0 +1,222 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using tiron_demo.Models;
|
||||
|
||||
namespace tiron_demo.Context;
|
||||
|
||||
public partial class User20Context : DbContext
|
||||
{
|
||||
public User20Context()
|
||||
{
|
||||
}
|
||||
|
||||
public User20Context(DbContextOptions<User20Context> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual DbSet<Material> Materials { get; set; }
|
||||
|
||||
public virtual DbSet<MaterialType> MaterialTypes { get; set; }
|
||||
|
||||
public virtual DbSet<Partner> Partners { get; set; }
|
||||
|
||||
public virtual DbSet<PartnerProduct> PartnerProducts { get; set; }
|
||||
|
||||
public virtual DbSet<PartnerType> PartnerTypes { get; set; }
|
||||
|
||||
public virtual DbSet<Product> Products { get; set; }
|
||||
|
||||
public virtual DbSet<ProductType> ProductTypes { get; set; }
|
||||
|
||||
public virtual DbSet<ProductsMinCostHistory> ProductsMinCostHistories { 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=45.67.56.214;Port=5456;Database=user20;Username=user20;Password=uFTJmxd5");
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Material>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("materials_pk");
|
||||
|
||||
entity.ToTable("materials");
|
||||
|
||||
entity.HasIndex(e => e.Name, "materials_unique").IsUnique();
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.AmountPerPackage).HasColumnName("amount_per_package");
|
||||
entity.Property(e => e.Cost).HasColumnName("cost");
|
||||
entity.Property(e => e.MeasureUnit)
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("measure_unit");
|
||||
entity.Property(e => e.MinAmount)
|
||||
.HasDefaultValue(0)
|
||||
.HasColumnName("min_amount");
|
||||
entity.Property(e => e.Name)
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("name");
|
||||
entity.Property(e => e.StorageAmount)
|
||||
.HasDefaultValue(0)
|
||||
.HasColumnName("storage_amount");
|
||||
entity.Property(e => e.Type).HasColumnName("type");
|
||||
|
||||
entity.HasOne(d => d.TypeNavigation).WithMany(p => p.Materials)
|
||||
.HasForeignKey(d => d.Type)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("materials_material_type_fk");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<MaterialType>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("material_type_pk");
|
||||
|
||||
entity.ToTable("material_type");
|
||||
|
||||
entity.HasIndex(e => e.Name, "material_type_unique").IsUnique();
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.DefectRate).HasColumnName("defect_rate");
|
||||
entity.Property(e => e.Name)
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("name");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Partner>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("partners_pk");
|
||||
|
||||
entity.ToTable("partners");
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.Address)
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("address");
|
||||
entity.Property(e => e.Director)
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("director");
|
||||
entity.Property(e => e.Email)
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("email");
|
||||
entity.Property(e => e.Inn)
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("inn");
|
||||
entity.Property(e => e.Name)
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("name");
|
||||
entity.Property(e => e.Phone)
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("phone");
|
||||
entity.Property(e => e.Rating)
|
||||
.HasDefaultValue((short)0)
|
||||
.HasColumnName("rating");
|
||||
entity.Property(e => e.Type).HasColumnName("type");
|
||||
|
||||
entity.HasOne(d => d.TypeNavigation).WithMany(p => p.Partners)
|
||||
.HasForeignKey(d => d.Type)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("partners_partner_type_fk");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<PartnerProduct>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("partner_products_pk");
|
||||
|
||||
entity.ToTable("partner_products");
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.Amount)
|
||||
.HasDefaultValue(0)
|
||||
.HasColumnName("amount");
|
||||
entity.Property(e => e.Partner).HasColumnName("partner");
|
||||
entity.Property(e => e.Product).HasColumnName("product");
|
||||
entity.Property(e => e.SellDate).HasColumnName("sell_date");
|
||||
|
||||
entity.HasOne(d => d.PartnerNavigation).WithMany(p => p.PartnerProducts)
|
||||
.HasForeignKey(d => d.Partner)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("partner_products_partners_fk");
|
||||
|
||||
entity.HasOne(d => d.ProductNavigation).WithMany(p => p.PartnerProducts)
|
||||
.HasForeignKey(d => d.Product)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("partner_products_products_fk");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<PartnerType>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("partner_type_pk");
|
||||
|
||||
entity.ToTable("partner_type");
|
||||
|
||||
entity.HasIndex(e => e.Name, "partner_type_unique").IsUnique();
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.Name)
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("name");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Product>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("products_pk");
|
||||
|
||||
entity.ToTable("products");
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.Articul)
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("articul");
|
||||
entity.Property(e => e.MinCost).HasColumnName("min_cost");
|
||||
entity.Property(e => e.Name)
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("name");
|
||||
entity.Property(e => e.Type).HasColumnName("type");
|
||||
|
||||
entity.HasOne(d => d.TypeNavigation).WithMany(p => p.Products)
|
||||
.HasForeignKey(d => d.Type)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("products_product_type_fk");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ProductType>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("product_type_pk");
|
||||
|
||||
entity.ToTable("product_type");
|
||||
|
||||
entity.HasIndex(e => e.Name, "product_type_unique").IsUnique();
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.K).HasColumnName("k");
|
||||
entity.Property(e => e.Name)
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("name");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ProductsMinCostHistory>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("products_min_cost_history_pk");
|
||||
|
||||
entity.ToTable("products_min_cost_history");
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.Date)
|
||||
.HasColumnType("timestamp without time zone")
|
||||
.HasColumnName("date");
|
||||
entity.Property(e => e.MinCost).HasColumnName("min_cost");
|
||||
entity.Property(e => e.Product).HasColumnName("product");
|
||||
|
||||
entity.HasOne(d => d.ProductNavigation).WithMany(p => p.ProductsMinCostHistories)
|
||||
.HasForeignKey(d => d.Product)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("products_min_cost_history_products_fk");
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||
}
|
37
History.axaml
Normal file
37
History.axaml
Normal file
@ -0,0 +1,37 @@
|
||||
<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="tiron_demo.History"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Icon="avares://tiron_demo/Resources/icon.ico"
|
||||
Title="История реалицазии продукции">
|
||||
<Grid Margin="10" RowDefinitions="*, auto">
|
||||
<ListBox Grid.Row="0" Name="HistoryBox" Margin="10">
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem:pointerover /template/ ContentPresenter">
|
||||
<Setter Property="Background" Value="#F4E8D3"/>
|
||||
</Style>
|
||||
<Style Selector="ListBoxItem:selected /template/ ContentPresenter">
|
||||
<Setter Property="Background" Value="#67BA80"/>
|
||||
</Style>
|
||||
</ListBox.Styles>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border Padding="10" BorderBrush="Black" BorderThickness="1">
|
||||
<StackPanel>
|
||||
<TextBlock FontFamily="fonts:SystemFonts#Segoe UI" Text="{Binding PartnerNavigation.Name}" HorizontalAlignment="Right" />
|
||||
<TextBlock FontFamily="fonts:SystemFonts#Segoe UI" Text="{Binding ProductNavigation.Name}" />
|
||||
<TextBlock FontFamily="fonts:SystemFonts#Segoe UI" Text="{Binding Amount}" />
|
||||
<TextBlock FontFamily="fonts:SystemFonts#Segoe UI" Text="{Binding SellDate}" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
|
||||
<Button FontFamily="fonts:SystemFonts#Segoe UI" Margin="10" Grid.Row="1" HorizontalAlignment="Left" Content="Назад" Click="Button_Click_Back" />
|
||||
</Grid>
|
||||
</Window>
|
71
History.axaml.cs
Normal file
71
History.axaml.cs
Normal file
@ -0,0 +1,71 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using tiron_demo.Context;
|
||||
using tiron_demo.Models;
|
||||
|
||||
namespace tiron_demo;
|
||||
|
||||
public partial class History : Window
|
||||
{
|
||||
private short _previousWindow;
|
||||
|
||||
public History()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_previousWindow = 0;
|
||||
|
||||
HistoryBox.ItemsSource = Helper.context.PartnerProducts.Include(x => x.PartnerNavigation).Include(x => x.ProductNavigation);
|
||||
}
|
||||
|
||||
public History(Window previousWindow, int partnerId, int productId)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (previousWindow is ProductsWindow)
|
||||
{
|
||||
_previousWindow = 1;
|
||||
} else if (previousWindow is PartnersWindow)
|
||||
{
|
||||
_previousWindow = 2;
|
||||
}
|
||||
|
||||
if (productId != 0)
|
||||
{
|
||||
var source = Helper.context.PartnerProducts.Where(x => x.Product == productId);
|
||||
if (partnerId != 0)
|
||||
{
|
||||
source = source.Where(x => x.Partner == partnerId);
|
||||
}
|
||||
HistoryBox.ItemsSource = source.Include(x => x.PartnerNavigation).Include(x => x.ProductNavigation);
|
||||
} else if (partnerId != 0)
|
||||
{
|
||||
HistoryBox.ItemsSource = Helper.context.PartnerProducts.Where(x => x.Partner == partnerId).Include(x => x.PartnerNavigation).Include(x => x.ProductNavigation);
|
||||
} else
|
||||
{
|
||||
HistoryBox.ItemsSource = Helper.context.PartnerProducts.Include(x => x.PartnerNavigation).Include(x => x.ProductNavigation);
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_Click_Back(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
if (_previousWindow == 0)
|
||||
{
|
||||
MainWindow mainWindow = new MainWindow();
|
||||
mainWindow.Show();
|
||||
} else if (_previousWindow == 1)
|
||||
{
|
||||
ProductsWindow productsWindow = new ProductsWindow();
|
||||
productsWindow.Show();
|
||||
} else if (_previousWindow == 2)
|
||||
{
|
||||
PartnersWindow partnersWindow = new PartnersWindow();
|
||||
partnersWindow.Show();
|
||||
}
|
||||
Close();
|
||||
}
|
||||
}
|
@ -4,6 +4,16 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="tiron_demo.MainWindow"
|
||||
Title="tiron_demo">
|
||||
Welcome to Avalonia!
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Icon="avares://tiron_demo/Resources/icon.ico"
|
||||
Title="Главная страница">
|
||||
<Grid Margin="10" RowDefinitions="*, auto">
|
||||
<TextBlock FontFamily="fonts:SystemFonts#Segoe UI" Text="Главная страница" HorizontalAlignment="Center" FontWeight="Bold" />
|
||||
|
||||
<Button FontFamily="fonts:SystemFonts#Segoe UI" Margin="10" Grid.Row="1" HorizontalAlignment="Right" Content="Продукты" Click="Button_Click_Products" />
|
||||
|
||||
<Button FontFamily="fonts:SystemFonts#Segoe UI" Margin="10" Grid.Row="1" HorizontalAlignment="Center" Content="История" Click="Button_Click_History" />
|
||||
|
||||
<Button FontFamily="fonts:SystemFonts#Segoe UI" Margin="10" Grid.Row="1" HorizontalAlignment="Left" Content="Партнёры" Click="Button_Click_Partners" />
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -1,4 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using tiron_demo.Context;
|
||||
using tiron_demo.Models;
|
||||
|
||||
namespace tiron_demo;
|
||||
|
||||
@ -8,4 +12,25 @@ public partial class MainWindow : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Button_Click_Products(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
ProductsWindow productsWindow = new ProductsWindow();
|
||||
productsWindow.Show();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Button_Click_Partners(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
PartnersWindow partnersWindow = new PartnersWindow();
|
||||
partnersWindow.Show();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Button_Click_History(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
History history = new History();
|
||||
history.Show();
|
||||
Close();
|
||||
}
|
||||
}
|
25
Models/Material.cs
Normal file
25
Models/Material.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace tiron_demo.Models;
|
||||
|
||||
public partial class Material
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
public int Type { get; set; }
|
||||
|
||||
public int AmountPerPackage { get; set; }
|
||||
|
||||
public string MeasureUnit { get; set; } = null!;
|
||||
|
||||
public float Cost { get; set; }
|
||||
|
||||
public int StorageAmount { get; set; }
|
||||
|
||||
public int MinAmount { get; set; }
|
||||
|
||||
public virtual MaterialType TypeNavigation { get; set; } = null!;
|
||||
}
|
15
Models/MaterialType.cs
Normal file
15
Models/MaterialType.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace tiron_demo.Models;
|
||||
|
||||
public partial class MaterialType
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
public float DefectRate { get; set; }
|
||||
|
||||
public virtual ICollection<Material> Materials { get; set; } = new List<Material>();
|
||||
}
|
51
Models/Partner.cs
Normal file
51
Models/Partner.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace tiron_demo.Models;
|
||||
|
||||
public partial class Partner
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
public string Director { get; set; } = null!;
|
||||
|
||||
public string? Email { get; set; }
|
||||
|
||||
public string? Phone { get; set; }
|
||||
|
||||
public string? Address { get; set; }
|
||||
|
||||
public string? Inn { get; set; }
|
||||
|
||||
public short Rating { get; set; }
|
||||
|
||||
public int Type { get; set; }
|
||||
|
||||
public int Discount => GetDiscount();
|
||||
|
||||
public virtual ICollection<PartnerProduct> PartnerProducts { get; set; } = new List<PartnerProduct>();
|
||||
|
||||
public virtual PartnerType TypeNavigation { get; set; } = null!;
|
||||
|
||||
private int GetDiscount()
|
||||
{
|
||||
int sum = PartnerProducts.Select(x => x.Amount).Sum();
|
||||
|
||||
if (sum < 10000)
|
||||
{
|
||||
return 0;
|
||||
} else if (sum < 50000)
|
||||
{
|
||||
return 5;
|
||||
} else if (sum < 300000)
|
||||
{
|
||||
return 10;
|
||||
} else
|
||||
{
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
}
|
21
Models/PartnerProduct.cs
Normal file
21
Models/PartnerProduct.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace tiron_demo.Models;
|
||||
|
||||
public partial class PartnerProduct
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int Product { get; set; }
|
||||
|
||||
public int Partner { get; set; }
|
||||
|
||||
public int Amount { get; set; }
|
||||
|
||||
public DateOnly? SellDate { get; set; }
|
||||
|
||||
public virtual Partner PartnerNavigation { get; set; } = null!;
|
||||
|
||||
public virtual Product ProductNavigation { get; set; } = null!;
|
||||
}
|
13
Models/PartnerType.cs
Normal file
13
Models/PartnerType.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace tiron_demo.Models;
|
||||
|
||||
public partial class PartnerType
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
public virtual ICollection<Partner> Partners { get; set; } = new List<Partner>();
|
||||
}
|
43
Models/Product.cs
Normal file
43
Models/Product.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using Avalonia.Media;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace tiron_demo.Models;
|
||||
|
||||
public partial class Product
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int Type { get; set; }
|
||||
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
public string Articul { get; set; } = null!;
|
||||
|
||||
public float MinCost { get; set; }
|
||||
|
||||
public SolidColorBrush ProductBackground => GetProductBackground();
|
||||
|
||||
public virtual ICollection<PartnerProduct> PartnerProducts { get; set; } = new List<PartnerProduct>();
|
||||
|
||||
public virtual ICollection<ProductsMinCostHistory> ProductsMinCostHistories { get; set; } = new List<ProductsMinCostHistory>();
|
||||
|
||||
public virtual ProductType TypeNavigation { get; set; } = null!;
|
||||
|
||||
private SolidColorBrush GetProductBackground()
|
||||
{
|
||||
int sum = PartnerProducts.Where(x => x.SellDate.Value.Year == 2024).Sum(x => x.Amount);
|
||||
|
||||
if (sum < 10000)
|
||||
{
|
||||
return SolidColorBrush.Parse("Red");
|
||||
} else if (sum < 60000)
|
||||
{
|
||||
return SolidColorBrush.Parse("Orange");
|
||||
} else
|
||||
{
|
||||
return SolidColorBrush.Parse("Green");
|
||||
}
|
||||
}
|
||||
}
|
15
Models/ProductType.cs
Normal file
15
Models/ProductType.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace tiron_demo.Models;
|
||||
|
||||
public partial class ProductType
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
public float K { get; set; }
|
||||
|
||||
public virtual ICollection<Product> Products { get; set; } = new List<Product>();
|
||||
}
|
17
Models/ProductsMinCostHistory.cs
Normal file
17
Models/ProductsMinCostHistory.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace tiron_demo.Models;
|
||||
|
||||
public partial class ProductsMinCostHistory
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public int MinCost { get; set; }
|
||||
|
||||
public int Product { get; set; }
|
||||
|
||||
public virtual Product ProductNavigation { get; set; } = null!;
|
||||
}
|
54
PartnersWindow.axaml
Normal file
54
PartnersWindow.axaml
Normal file
@ -0,0 +1,54 @@
|
||||
<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="tiron_demo.PartnersWindow"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Icon="avares://tiron_demo/Resources/icon.ico"
|
||||
Title="Партнёры">
|
||||
<Grid Margin="10" RowDefinitions="*, auto">
|
||||
<ListBox Grid.Row="0" Name="Partners" Margin="10" DoubleTapped="ListBox_DoubleTapped">
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem:pointerover /template/ ContentPresenter">
|
||||
<Setter Property="Background" Value="#F4E8D3"/>
|
||||
</Style>
|
||||
<Style Selector="ListBoxItem:selected /template/ ContentPresenter">
|
||||
<Setter Property="Background" Value="#67BA80"/>
|
||||
</Style>
|
||||
</ListBox.Styles>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border Padding="10" BorderBrush="Black" BorderThickness="1">
|
||||
<StackPanel>
|
||||
<Grid ColumnDefinitions="*, auto">
|
||||
<TextBlock FontFamily="fonts:SystemFonts#Segoe UI">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding StringFormat="{}{0} | {1}">
|
||||
<Binding Path="TypeNavigation.Name" />
|
||||
<Binding Path="Name" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
<TextBlock FontFamily="fonts:SystemFonts#Segoe UI" Grid.Column="1">
|
||||
<TextBlock.Text>
|
||||
<Binding Path="Discount" StringFormat="{}{0}%" />
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
<TextBlock FontFamily="fonts:SystemFonts#Segoe UI" Text="{Binding Director}" />
|
||||
<TextBlock FontFamily="fonts:SystemFonts#Segoe UI" Text="{Binding Phone}" />
|
||||
<TextBlock FontFamily="fonts:SystemFonts#Segoe UI" Text="{Binding Rating}" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<Button FontFamily="fonts:SystemFonts#Segoe UI" Margin="10" Grid.Row="1" HorizontalAlignment="Right" Content="Добавить" Click="Button_Click_Add" />
|
||||
|
||||
<Button FontFamily="fonts:SystemFonts#Segoe UI" Margin="10" Grid.Row="1" HorizontalAlignment="Center" Content="История" Click="Button_Click_History" />
|
||||
|
||||
<Button FontFamily="fonts:SystemFonts#Segoe UI" Margin="10" Grid.Row="1" HorizontalAlignment="Left" Content="Назад" Click="Button_Click_Back" />
|
||||
</Grid>
|
||||
</Window>
|
56
PartnersWindow.axaml.cs
Normal file
56
PartnersWindow.axaml.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using tiron_demo.Context;
|
||||
using tiron_demo.Models;
|
||||
|
||||
namespace tiron_demo;
|
||||
|
||||
public partial class PartnersWindow : Window
|
||||
{
|
||||
public PartnersWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Partners.ItemsSource = Helper.context.Partners.Include(x => x.TypeNavigation).Include(x => x.PartnerProducts);
|
||||
}
|
||||
|
||||
private void Button_Click_Add(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
AddPartner partnerWindow = new AddPartner();
|
||||
partnerWindow.Show();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Button_Click_Back(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
MainWindow mainWindow = new MainWindow();
|
||||
mainWindow.Show();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ListBox_DoubleTapped(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
var partner = Partners.SelectedItem as Partner;
|
||||
|
||||
if (partner != null)
|
||||
{
|
||||
AddPartner partnerWindow = new AddPartner(partner);
|
||||
partnerWindow.Show();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_Click_History(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
if (Partners.SelectedItem != null)
|
||||
{
|
||||
Partner partner = Partners.SelectedItem as Partner;
|
||||
History history = new History(this, partner.Id, 0);
|
||||
history.Show();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
39
ProductsWindow.axaml
Normal file
39
ProductsWindow.axaml
Normal file
@ -0,0 +1,39 @@
|
||||
<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="tiron_demo.ProductsWindow"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Icon="avares://tiron_demo/Resources/icon.ico"
|
||||
Title="Продукты">
|
||||
<Grid Margin="10" RowDefinitions="*, auto">
|
||||
<ListBox Grid.Row="0" Name="Products" Margin="10" DoubleTapped="ListBox_DoubleTapped">
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem:pointerover /template/ ContentPresenter">
|
||||
<Setter Property="Background" Value="#F4E8D3"/>
|
||||
</Style>
|
||||
<Style Selector="ListBoxItem:selected /template/ ContentPresenter">
|
||||
<Setter Property="Background" Value="#67BA80"/>
|
||||
</Style>
|
||||
</ListBox.Styles>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border Padding="10" BorderBrush="Black" BorderThickness="1" Background="{Binding ProductBackground}">
|
||||
<StackPanel>
|
||||
<TextBlock FontFamily="fonts:SystemFonts#Segoe UI" Text="{Binding Articul}" HorizontalAlignment="Right" />
|
||||
<TextBlock FontFamily="fonts:SystemFonts#Segoe UI" Text="{Binding Name}" />
|
||||
<TextBlock FontFamily="fonts:SystemFonts#Segoe UI" Text="{Binding TypeNavigation.Name}" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<Button FontFamily="fonts:SystemFonts#Segoe UI" Margin="10" Grid.Row="1" HorizontalAlignment="Right" Content="Добавить" Click="Button_Click_Add" />
|
||||
|
||||
<Button FontFamily="fonts:SystemFonts#Segoe UI" Margin="10" Grid.Row="1" HorizontalAlignment="Center" Content="История" Click="Button_Click_History" />
|
||||
|
||||
<Button FontFamily="fonts:SystemFonts#Segoe UI" Margin="10" Grid.Row="1" HorizontalAlignment="Left" Content="Назад" Click="Button_Click_Back" />
|
||||
</Grid>
|
||||
</Window>
|
54
ProductsWindow.axaml.cs
Normal file
54
ProductsWindow.axaml.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using tiron_demo.Context;
|
||||
using tiron_demo.Models;
|
||||
|
||||
namespace tiron_demo;
|
||||
|
||||
public partial class ProductsWindow : Window
|
||||
{
|
||||
public ProductsWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Products.ItemsSource = Helper.context.Products.Include(x => x.TypeNavigation).Include(x => x.PartnerProducts);
|
||||
}
|
||||
|
||||
private void Button_Click_Add(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
AddProduct productWindow = new AddProduct();
|
||||
productWindow.Show();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Button_Click_Back(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
MainWindow mainWindow = new MainWindow();
|
||||
mainWindow.Show();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ListBox_DoubleTapped(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
var product = Products.SelectedItem as Product;
|
||||
|
||||
if (product != null)
|
||||
{
|
||||
AddProduct productWindow = new AddProduct(product);
|
||||
productWindow.Show();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_Click_History(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
if (Products.SelectedItem != null)
|
||||
{
|
||||
Product product = Products.SelectedItem as Product;
|
||||
History history = new History(this, 0, product.Id);
|
||||
history.Show();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
BIN
Resources/icon.ico
Normal file
BIN
Resources/icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
Resources/icon.png
Normal file
BIN
Resources/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 158 KiB |
1
UpdateContextAndModels.bat
Normal file
1
UpdateContextAndModels.bat
Normal file
@ -0,0 +1 @@
|
||||
dotnet-ef dbcontext scaffold "Host=45.67.56.214;Port=5456;Database=user20;Username=user20;Password=uFTJmxd5" Npgsql.EntityFrameworkCore.PostgreSQL --schema public --context-dir Context --output-dir Models -f
|
BIN
bin/Debug/net8.0/Avalonia.Base.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Base.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Controls.ColorPicker.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Controls.ColorPicker.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Controls.DataGrid.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Controls.DataGrid.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Controls.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Controls.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.DesignerSupport.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.DesignerSupport.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Desktop.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Desktop.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Diagnostics.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Diagnostics.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Dialogs.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Dialogs.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Fonts.Inter.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Fonts.Inter.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.FreeDesktop.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.FreeDesktop.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Markup.Xaml.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Markup.Xaml.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Markup.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Markup.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Metal.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Metal.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.MicroCom.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.MicroCom.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Native.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Native.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.OpenGL.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.OpenGL.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Remote.Protocol.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Remote.Protocol.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Skia.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Skia.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Themes.Fluent.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Themes.Fluent.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Themes.Simple.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Themes.Simple.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Vulkan.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Vulkan.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.Win32.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.Win32.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.X11.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.X11.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Avalonia.dll
Normal file
BIN
bin/Debug/net8.0/Avalonia.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/HarfBuzzSharp.dll
Normal file
BIN
bin/Debug/net8.0/HarfBuzzSharp.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Humanizer.dll
Normal file
BIN
bin/Debug/net8.0/Humanizer.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/MicroCom.Runtime.dll
Normal file
BIN
bin/Debug/net8.0/MicroCom.Runtime.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.Bcl.AsyncInterfaces.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.Bcl.AsyncInterfaces.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.Build.Locator.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.Build.Locator.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.CodeAnalysis.CSharp.Scripting.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.CodeAnalysis.CSharp.Scripting.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.CodeAnalysis.CSharp.Workspaces.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.CodeAnalysis.CSharp.Workspaces.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.CodeAnalysis.CSharp.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.CodeAnalysis.CSharp.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.CodeAnalysis.Scripting.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.CodeAnalysis.Scripting.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.CodeAnalysis.Workspaces.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.CodeAnalysis.Workspaces.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.CodeAnalysis.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.CodeAnalysis.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.EntityFrameworkCore.Abstractions.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.EntityFrameworkCore.Abstractions.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.EntityFrameworkCore.Design.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.EntityFrameworkCore.Design.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.EntityFrameworkCore.Relational.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.EntityFrameworkCore.Relational.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.EntityFrameworkCore.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.EntityFrameworkCore.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.Extensions.Caching.Abstractions.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.Extensions.Caching.Abstractions.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.Extensions.Caching.Memory.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.Extensions.Caching.Memory.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.Extensions.DependencyInjection.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.Extensions.DependencyInjection.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.Extensions.DependencyModel.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.Extensions.DependencyModel.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.Extensions.Logging.Abstractions.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.Extensions.Logging.Abstractions.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.Extensions.Logging.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.Extensions.Logging.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.Extensions.Options.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.Extensions.Options.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Microsoft.Extensions.Primitives.dll
Normal file
BIN
bin/Debug/net8.0/Microsoft.Extensions.Primitives.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Mono.TextTemplating.dll
Normal file
BIN
bin/Debug/net8.0/Mono.TextTemplating.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Npgsql.EntityFrameworkCore.PostgreSQL.dll
Normal file
BIN
bin/Debug/net8.0/Npgsql.EntityFrameworkCore.PostgreSQL.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/Npgsql.dll
Normal file
BIN
bin/Debug/net8.0/Npgsql.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/SkiaSharp.dll
Normal file
BIN
bin/Debug/net8.0/SkiaSharp.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/System.CodeDom.dll
Normal file
BIN
bin/Debug/net8.0/System.CodeDom.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/System.Composition.AttributedModel.dll
Normal file
BIN
bin/Debug/net8.0/System.Composition.AttributedModel.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/System.Composition.Convention.dll
Normal file
BIN
bin/Debug/net8.0/System.Composition.Convention.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/System.Composition.Hosting.dll
Normal file
BIN
bin/Debug/net8.0/System.Composition.Hosting.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/System.Composition.Runtime.dll
Normal file
BIN
bin/Debug/net8.0/System.Composition.Runtime.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net8.0/System.Composition.TypedParts.dll
Normal file
BIN
bin/Debug/net8.0/System.Composition.TypedParts.dll
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user