jhgkiuyjgkjyhg

This commit is contained in:
IsaykinEugene 2025-03-24 14:59:01 +03:00
commit aa240ad8cd
131 changed files with 5352 additions and 0 deletions

View File

@ -0,0 +1,21 @@
<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="demka2025_sedelnikov.AddEditPartnerWindow"
Icon="/Res/Мастер пол.ico"
Title="AddEditPartnerWindow">
<StackPanel Orientation="Vertical">
<TextBox x:Name="NameTX" Text="{Binding PartnerName}" Watermark="Наименование продукции"/>
<NumericUpDown AllowSpin="False" ShowButtonSpinner="False" x:Name="RatingTX" Text="{Binding Rating}" Watermark="Рейтинг"/>
<TextBox x:Name="DirectorNameTX" Text="{Binding DirectorName}" Watermark="Имя директора"/>
<TextBox x:Name="PhoneTX" Text="{Binding Phone}" Watermark="Телефон"/>
<TextBox x:Name="EmailTX" Text="{Binding Email}" Watermark="Эл. почта"/>
<TextBox x:Name="AddressTX" Text="{Binding Address}" Watermark="Адрес"/>
<ComboBox x:Name="ComboPartnerTypes" PlaceholderText="Тип партнера"/>
<Button Background="#67BA80" Content="Сохранить" Click="Button_Click"/>
<Button Background="#67BA80" Content="Показать историю продаж" x:Name="SellButton" Click="Button_Click_1"/>
</StackPanel>
</Window>

View File

@ -0,0 +1,98 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using demka2025_sedelnikov.Context;
using MsBox.Avalonia;
using System;
using System.Linq;
using System.Text;
namespace demka2025_sedelnikov;
public partial class AddEditPartnerWindow : Window
{
Partner currentPartner = new Partner();
User8Context context = new User8Context();
// äîáàâëåíèå
public AddEditPartnerWindow()
{
InitializeComponent();
SellButton.IsEnabled = false;
DataContext = currentPartner;
ComboPartnerTypes.ItemsSource = context.Partnertypes.Select(pt => pt.PartnerTypeName).ToList();
}
// ðåäàêòèðîâàíèå (çàïîëíåíèå ïîëåé)
public AddEditPartnerWindow(Partner partner)
{
InitializeComponent();
currentPartner = partner;
DataContext = currentPartner;
ComboPartnerTypes.ItemsSource = context.Partnertypes.Select(pt => pt.PartnerTypeName).ToList();
ComboPartnerTypes.SelectedValue = context.Partnertypes.FirstOrDefault(p => p.Id == currentPartner.PartnerTypeId);
ComboPartnerTypes.SelectedItem = context.Partnertypes.FirstOrDefault(p => p.Id == currentPartner.PartnerTypeId).PartnerTypeName;
ComboPartnerTypes.SelectedIndex = context.Partnertypes.FirstOrDefault(p => p.Id == currentPartner.PartnerTypeId).Id - 1;
}
private async void Button_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
try
{
StringBuilder errors = new StringBuilder();
if (!decimal.TryParse(RatingTX.Text, out decimal res) && res > 0)
errors.AppendLine("Ðåéòèíã íå ìîæåò áûòü îòðèöàòåëüíûì ÷èñëîì!");
if (string.IsNullOrEmpty(RatingTX.Text) || string.IsNullOrEmpty(NameTX.Text) ||
string.IsNullOrEmpty(DirectorNameTX.Text) || string.IsNullOrEmpty(PhoneTX.Text) ||
string.IsNullOrEmpty(EmailTX.Text) || string.IsNullOrEmpty(AddressTX.Text) ||
ComboPartnerTypes.SelectedIndex == -1)
errors.AppendLine("Äàííûå íå ìîãóò áûòü ïóñòûìè!");
if (errors.Length > 0)
{
await MessageBoxManager.GetMessageBoxStandard("Îøèáêà!", $"Ïðîèçîøëà îøèáêà: {errors.ToString()}").ShowWindowDialogAsync(this);
return;
}
//äîáàâëÿåì
if (currentPartner.Id == 0)
{
context.Partners.Add(currentPartner);
context.SaveChanges();
await MessageBoxManager.GetMessageBoxStandard("OK!", $"Ïàðòí¸ð áûë äîáàâëåí!").ShowWindowDialogAsync(this);
Close();
}
//ðåäàêòèðóåì
else
{
var edittedPartner = context.Partners.FirstOrDefault(p => p.Id == currentPartner.Id);
if (edittedPartner != null)
{
edittedPartner.PartnerName = currentPartner.PartnerName;
edittedPartner.PartnerTypeId = ComboPartnerTypes.SelectedIndex + 1;
edittedPartner.Rating = currentPartner.Rating;
edittedPartner.DirectorName = currentPartner.DirectorName;
edittedPartner.Phone = currentPartner.Phone;
edittedPartner.Email = currentPartner.Email;
edittedPartner.Address = currentPartner.Address;
}
context.SaveChanges();
await MessageBoxManager.GetMessageBoxStandard("OK!", $"Ïàðòí¸ð áûë èçìåí¸í!").ShowWindowDialogAsync(this);
Close();
}
}
catch (Exception ex)
{
await MessageBoxManager.GetMessageBoxStandard("Îøèáêà!", $"Ïðîèçîøëà îøèáêà: {ex.Message}!").ShowWindowDialogAsync(this);
return;
}
}
private async void Button_Click_1(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
await new PartnerProductHistoryWindow(currentPartner.Id).ShowDialog(this);
return;
}
}

View File

@ -0,0 +1,16 @@
<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="demka2025_sedelnikov.AddEditProductWindow"
Icon="/Res/Мастер пол.ico"
Title="AddEditProductWindow">
<StackPanel Orientation="Vertical">
<TextBox x:Name="NameTX" Text="{Binding ProductName}" Watermark="Наименование продукции"/>
<TextBox x:Name="MinCOstTX" Text="{Binding MinCost}" Watermark="Мин. стоимость для партнёра"/>
<NumericUpDown x:Name="ArticulTX" Text="{Binding Articul}" Watermark="Артикул"/>
<ComboBox x:Name="ComboPartnerTypes" PlaceholderText="Тип продукции"/>
<Button Content="Сохранить" Click="Button_Click"/>
</StackPanel>
</Window>

View File

@ -0,0 +1,84 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using demka2025_sedelnikov.Context;
using MsBox.Avalonia;
using System;
using System.Linq;
using System.Text;
namespace demka2025_sedelnikov;
public partial class AddEditProductWindow : Window
{
Product currentProduct = new Product();
User8Context context = new User8Context();
// äîáàâëåíèå
public AddEditProductWindow()
{
InitializeComponent();
DataContext = currentProduct;
ComboPartnerTypes.ItemsSource = context.Producttypes.Select(pt => pt.ProductTypeName).ToList();
ArticulTX.IsEnabled = false;
}
// ðåäàêòèðîâàíèå
public AddEditProductWindow(Product currentProduct)
{
InitializeComponent();
this.currentProduct = currentProduct;
DataContext = currentProduct;
ArticulTX.IsEnabled = false;
ComboPartnerTypes.ItemsSource = context.Producttypes.Select(pt => pt.ProductTypeName).ToList();
ComboPartnerTypes.SelectedValue = context.Producttypes.FirstOrDefault(p => p.Id == currentProduct.TypeId);
ComboPartnerTypes.SelectedItem = context.Producttypes.FirstOrDefault(p => p.Id == currentProduct.TypeId).ProductTypeName;
ComboPartnerTypes.SelectedIndex = context.Producttypes.FirstOrDefault(p => p.Id == currentProduct.TypeId).Id - 1;
}
private async void Button_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
try
{
StringBuilder errors = new StringBuilder();
if (!decimal.TryParse(MinCOstTX.Text, out decimal res) && res > 0)
errors.AppendLine("Íåâåðíî ââåäåíà ìèíèìàëüíàÿ ñòîèìîñòü!");
if (string.IsNullOrEmpty(MinCOstTX.Text) || string.IsNullOrEmpty(NameTX.Text) ||
ComboPartnerTypes.SelectedIndex == -1)
errors.AppendLine("Äàííûå íå ìîãóò áûòü ïóñòûìè!");
if (errors.Length > 0)
{
await MessageBoxManager.GetMessageBoxStandard("Îøèáêà!", $"Ïðîèçîøëà îøèáêà: {errors.ToString()}").ShowWindowDialogAsync(this);
return;
}
if (currentProduct.Id == 0)
{
currentProduct.Articul = new Random().Next(1, 100000).ToString();
context.Products.Add(currentProduct);
context.SaveChanges();
await MessageBoxManager.GetMessageBoxStandard("OK!", $"Ïðîäóêò áûë äîáàâëåí!").ShowWindowDialogAsync(this);
Close();
}
else
{
var edittedProduct = context.Products.FirstOrDefault(p => p.Id == currentProduct.Id);
if (edittedProduct != null)
{
edittedProduct.ProductName = currentProduct.ProductName;
edittedProduct.TypeId = ComboPartnerTypes.SelectedIndex + 1;
edittedProduct.MinCost = currentProduct.MinCost;
}
context.SaveChanges();
await MessageBoxManager.GetMessageBoxStandard("OK!", $"Ïðîäóêò áûë èçìåí¸í!").ShowWindowDialogAsync(this);
Close();
}
}
catch (Exception ex)
{
await MessageBoxManager.GetMessageBoxStandard("Îøèáêà!", $"Ïðîèçîøëà îøèáêà: {ex.Message}!").ShowWindowDialogAsync(this);
return;
}
}
}

10
App.axaml Normal file
View File

@ -0,0 +1,10 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="demka2025_sedelnikov.App"
RequestedThemeVariant="Light">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>

23
App.axaml.cs Normal file
View File

@ -0,0 +1,23 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
namespace demka2025_sedelnikov;
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();
}
base.OnFrameworkInitializationCompleted();
}
}

136
Context/User8Context.cs Normal file
View File

@ -0,0 +1,136 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using demka2025_sedelnikov;
namespace demka2025_sedelnikov.Context;
public partial class User8Context : DbContext
{
public User8Context()
{
}
public User8Context(DbContextOptions<User8Context> options)
: base(options)
{
}
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; }
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 http://go.microsoft.com/fwlink/?LinkId=723263.
=> optionsBuilder.UseNpgsql("Host=45.67.56.214;Database=user8;Username=user8;Password=i9ehyuJ3;Port=5456");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Materialtype>(entity =>
{
entity.HasKey(e => e.Id).HasName("materialtypes_pk");
entity.ToTable("materialtypes");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.BrakPercent).HasColumnName("brak_percent");
entity.Property(e => e.MaterialTypeName).HasColumnName("material_type_name");
});
modelBuilder.Entity<Partner>(entity =>
{
entity.HasKey(e => e.Id).HasName("partners_pk");
entity.ToTable("partners");
entity.HasIndex(e => e.Id, "partners_unique").IsUnique();
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Address).HasColumnName("address");
entity.Property(e => e.DirectorName).HasColumnName("director_name");
entity.Property(e => e.Email).HasColumnName("email");
entity.Property(e => e.Inn).HasColumnName("inn");
entity.Property(e => e.PartnerName).HasColumnName("partner_name");
entity.Property(e => e.PartnerTypeId).HasColumnName("partner_type_id");
entity.Property(e => e.Phone).HasColumnName("phone");
entity.Property(e => e.Rating).HasColumnName("rating");
entity.HasOne(d => d.PartnerType).WithMany(p => p.Partners)
.HasForeignKey(d => d.PartnerTypeId)
.HasConstraintName("partners_partnertypes_fk");
});
modelBuilder.Entity<Partnerproduct>(entity =>
{
entity.HasKey(e => e.Id).HasName("partnerproduct_pk");
entity.ToTable("partnerproduct");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.PartnerId).HasColumnName("partner_id");
entity.Property(e => e.ProductId).HasColumnName("product_id");
entity.Property(e => e.Quantity).HasColumnName("quantity");
entity.Property(e => e.SellDate).HasColumnName("sell_date");
entity.HasOne(d => d.Partner).WithMany(p => p.Partnerproducts)
.HasForeignKey(d => d.PartnerId)
.HasConstraintName("partnerproduct_partners_fk");
entity.HasOne(d => d.Product).WithMany(p => p.Partnerproducts)
.HasForeignKey(d => d.ProductId)
.HasConstraintName("partnerproduct_products_fk");
});
modelBuilder.Entity<Partnertype>(entity =>
{
entity.HasKey(e => e.Id).HasName("partnertypes_pk");
entity.ToTable("partnertypes");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.PartnerTypeName).HasColumnName("partner_type_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).HasColumnName("articul");
entity.Property(e => e.MinCost).HasColumnName("min_cost");
entity.Property(e => e.ProductName).HasColumnName("product_name");
entity.Property(e => e.TypeId).HasColumnName("type_id");
entity.HasOne(d => d.Type).WithMany(p => p.Products)
.HasForeignKey(d => d.TypeId)
.HasConstraintName("products_producttypes_fk");
});
modelBuilder.Entity<Producttype>(entity =>
{
entity.HasKey(e => e.Id).HasName("producttypes_pk");
entity.ToTable("producttypes");
entity.HasIndex(e => e.Id, "producttypes_unique").IsUnique();
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Coeff).HasColumnName("coeff");
entity.Property(e => e.ProductTypeName).HasColumnName("product_type_name");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}

18
MainWindow.axaml Normal file
View File

@ -0,0 +1,18 @@
<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"
Icon="/Res/Мастер пол.ico"
x:Class="demka2025_sedelnikov.MainWindow"
Title="demka2025_sedelnikov">
<Grid RowDefinitions="*, *" ColumnDefinitions="*, *">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.ColumnSpan="2" Grid.RowSpan="2">
<TextBlock Text="Выберите, с чем хотите работать"/>
<StackPanel Orientation="Horizontal">
<Button Click="Button_Click" Content="Продукты"/>
<Button Click="Button_Click_1" Content="Партнёры"/>
</StackPanel>
</StackPanel>
</Grid>
</Window>

24
MainWindow.axaml.cs Normal file
View File

@ -0,0 +1,24 @@
using Avalonia.Controls;
using System.Threading.Tasks;
namespace demka2025_sedelnikov;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private async void Button_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
await new ProductWindow().ShowDialog(this);
return;
}
private async void Button_Click_1(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
await new PartnerWindow().ShowDialog(this);
return;
}
}

13
Materialtype.cs Normal file
View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace demka2025_sedelnikov;
public partial class Materialtype
{
public int Id { get; set; }
public string? MaterialTypeName { get; set; }
public decimal? BrakPercent { get; set; }
}

30
Partner.cs Normal file
View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
namespace demka2025_sedelnikov;
public partial class Partner
{
public int Id { get; set; }
public string? PartnerName { get; set; }
public string? DirectorName { get; set; }
public string? Email { get; set; }
public string? Phone { get; set; }
public string? Address { get; set; }
public string? Inn { get; set; }
public int? Rating { get; set; }
public int? PartnerTypeId { get; set; }
public virtual Partnertype? PartnerType { get; set; }
public virtual ICollection<Partnerproduct> Partnerproducts { get; set; } = new List<Partnerproduct>();
}

View 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="demka2025_sedelnikov.PartnerProductHistoryWindow"
Icon="/Res/Мастер пол.ico"
Title="PartnerProductHistoryWindow">
<Grid RowDefinitions="*, 10*, *" ColumnDefinitions="*, 10*, *">
<ListBox Grid.Row="1" Grid.Column="1" x:Name="PartnerProductHistoryLB">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Арктикул продукта: "/>
<TextBlock Text="{Binding Articul}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Наименование продукта: "/>
<TextBlock Text="{Binding ProductName}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Кол-во: "/>
<TextBlock Text="{Binding Quantity}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Дата реализации: "/>
<TextBlock Text="{Binding SellDate}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Window>

View File

@ -0,0 +1,40 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using demka2025_sedelnikov.Context;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
namespace demka2025_sedelnikov;
public partial class PartnerProductHistoryWindow : Window
{
User8Context context = new User8Context();
public PartnerProductHistoryWindow(int index)
{
InitializeComponent();
LoadData(index);
}
public void LoadData(int index)
{
// ñîáèðàåì çàïèñè ñ ïðîäàæ îò äàííîãî ïàðòíåðà
var partnerProducts = context.Partnerproducts.Where(pp => pp.PartnerId == index)
.Include(p => p.Partner)
.Include(p => p.Product)
.Where(part => part.PartnerId == index)
.Select(p => new
{
p.Product.Articul,
p.Product.ProductName,
p.Quantity,
p.SellDate
})
.ToList();
PartnerProductHistoryLB.ItemsSource = partnerProducts;
}
}

45
PartnerWindow.axaml Normal file
View File

@ -0,0 +1,45 @@
<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="demka2025_sedelnikov.PartnerWindow"
Title="PartnerWindow">
<Grid RowDefinitions="*, 10*, *" ColumnDefinitions="*, 10*, *">
<ListBox Grid.Row="1" Grid.Column="1" x:Name="PartnerLB">
<ListBox.ItemTemplate>
<DataTemplate>
<ListBoxItem Background="#F4E8D3" Tag="{Binding Id}" DoubleTapped="ListBoxItem_DoubleTapped">
<Grid RowDefinitions="*, *, *, *" ColumnDefinitions="*, Auto">
<Grid ColumnDefinitions="*, *">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding PartnerTypeString, StringFormat='{}Тип: {0} | '}"/>
<TextBlock Text="{Binding PartnerName, StringFormat='{}Наим. партнёра: {0}'}"/>
</StackPanel>
</Grid>
<StackPanel Grid.Column="1">
<TextBlock Text="{Binding PartnerDiscount, StringFormat='{}Скидка: {0}%'}"/>
</StackPanel>
<StackPanel Grid.Row="1">
<TextBlock Text="{Binding DirectorName, StringFormat='{}Директор: {0}'}"/>
</StackPanel>
<StackPanel Grid.Row="2">
<TextBlock Text="{Binding Phone, StringFormat='{}Номер телефона: {0}'}"/>
</StackPanel>
<StackPanel Grid.Row="3">
<TextBlock Text="{Binding Rating, StringFormat='{}Рейтинг: {0}'}"/>
</StackPanel>
</Grid>
</ListBoxItem>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Background="#67BA80" Grid.Row="2" Grid.Column="1" Content="Добавить" Click="Button_Click"/>
</Grid>
</Window>

79
PartnerWindow.axaml.cs Normal file
View File

@ -0,0 +1,79 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using demka2025_sedelnikov.Context;
using Microsoft.EntityFrameworkCore;
using System.Linq;
namespace demka2025_sedelnikov;
public partial class PartnerWindow : Window
{
User8Context context = new User8Context();
public PartnerWindow()
{
InitializeComponent();
LoadPartners();
}
public void LoadPartners()
{
try
{
var products = context.Partners
.Include(pp => pp.Partnerproducts)
.Include(pt => pt.PartnerType)
.Select(pp => new
{
Id = pp.Id,
PartnerName = pp.PartnerName,
DirectorName = pp.DirectorName,
Phone = pp.Phone,
Rating = pp.Rating,
PartnerTypeString = pp.PartnerType.PartnerTypeName
})
.ToList();
PartnerLB.ItemsSource = products;
}
catch
{
return;
}
}
public static int? CalculateDiscount(int? quantity)
{
if (quantity < 10000)
return 0;
if (quantity > 10000 && quantity <= 50000)
return 5;
if (quantity > 50000 && quantity <= 300000)
return 10;
if (quantity > 300000)
return 15;
else
return 0;
}
private async void Button_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
await new AddEditPartnerWindow().ShowDialog(this);
LoadPartners();
}
private async void ListBoxItem_DoubleTapped(object? sender, Avalonia.Input.TappedEventArgs e)
{
int ind = (int)(sender as ListBoxItem).Tag;
var clickedPartner = context.Partners.Find(ind);
if (clickedPartner != null)
{
await new AddEditPartnerWindow(clickedPartner).ShowDialog(this);
LoadPartners();
}
}
}

21
Partnerproduct.cs Normal file
View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
namespace demka2025_sedelnikov;
public partial class Partnerproduct
{
public int Id { get; set; }
public int? ProductId { get; set; }
public int? PartnerId { get; set; }
public int? Quantity { get; set; }
public string? SellDate { get; set; }
public virtual Partner? Partner { get; set; }
public virtual Product? Product { get; set; }
}

13
Partnertype.cs Normal file
View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace demka2025_sedelnikov;
public partial class Partnertype
{
public int Id { get; set; }
public string? PartnerTypeName { get; set; }
public virtual ICollection<Partner> Partners { get; set; } = new List<Partner>();
}

21
Product.cs Normal file
View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
namespace demka2025_sedelnikov;
public partial class Product
{
public int Id { get; set; }
public string? ProductName { get; set; }
public string? Articul { get; set; }
public decimal? MinCost { get; set; }
public int? TypeId { get; set; }
public virtual ICollection<Partnerproduct> Partnerproducts { get; set; } = new List<Partnerproduct>();
public virtual Producttype? Type { get; set; }
}

54
ProductWindow.axaml Normal file
View 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="demka2025_sedelnikov.ProductWindow"
Icon="/Res/Мастер пол.ico"
Title="ProductWindow">
<Grid RowDefinitions="*, 10*, *" ColumnDefinitions="*, 10*, *">
<ListBox Grid.Row="1" Grid.Column="1" x:Name="ProductsLB">
<ListBox.ItemTemplate>
<DataTemplate>
<ListBoxItem Background="#F4E8D3" Tag="{Binding Id}" DoubleTapped="Grid_DoubleTapped">
<Grid RowDefinitions="Auto, Auto">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<TextBlock Text="Артикул продукта: " FontWeight="Bold"/>
<TextBlock Text="{Binding Articul}"/>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Row="1">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Название продукта: " FontWeight="Bold"/>
<TextBlock Text="{Binding ProductName}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Тип продукта: " FontWeight="Bold"/>
<TextBlock Text="{Binding ProductTypeString}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Коэффициент продукта: " FontWeight="Bold"/>
<TextBlock Text="{Binding ProductCoeffString}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Есть у следующих партнёров: " FontWeight="Bold"/>
<ComboBox ItemsSource="{Binding Partners}" PlaceholderText="Открыть">
</ComboBox>
</StackPanel>
</StackPanel>
</Grid>
</ListBoxItem>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Background="#67BA80" Grid.Row="2" Grid.Column="1" Content="Добавить" Click="Button_Click"/>
</Grid>
</Window>

67
ProductWindow.axaml.cs Normal file
View File

@ -0,0 +1,67 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using demka2025_sedelnikov.Context;
using Microsoft.EntityFrameworkCore;
using System.Linq;
namespace demka2025_sedelnikov;
public partial class ProductWindow : Window
{
User8Context context = new User8Context();
public ProductWindow()
{
InitializeComponent();
LoadProducts();
}
public void LoadProducts()
{
var products = context.Products
.Include(pp => pp.Partnerproducts)
.ThenInclude(pn => pn.Partner)
.Select(pp => new
{
Id = pp.Id,
ProductName = pp.ProductName,
Articul = pp.Articul,
MinCost = pp.MinCost,
ProductCoeffString = pp.Type.Coeff.ToString(),
ProductTypeString = pp.Type.ProductTypeName,
Partners = pp.Partnerproducts.Select(p => $"{p.Partner.PartnerName} - {p.Quantity}")
})
.ToList();
ProductsLB.ItemsSource = products;
}
public static string DefineColor(int? quantity)
{
if (quantity < 10000)
return "LightRed";
if (quantity > 10000 && quantity <= 60000)
return "LightOrange";
if (quantity > 60000)
return "LightGreen";
else
return "";
}
private async void Grid_DoubleTapped(object? sender, Avalonia.Input.TappedEventArgs e)
{
int ind = (int)
(sender as ListBoxItem).Tag;
var clickedProduct = context.Products.Find(ind);
if (clickedProduct != null)
{
await new AddEditProductWindow(clickedProduct).ShowDialog(this);
LoadProducts();
}
}
private async void Button_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
await new AddEditProductWindow().ShowDialog(this);
LoadProducts();
}
}

15
Producttype.cs Normal file
View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace demka2025_sedelnikov;
public partial class Producttype
{
public int Id { get; set; }
public string? ProductTypeName { get; set; }
public decimal? Coeff { get; set; }
public virtual ICollection<Product> Products { get; set; } = new List<Product>();
}

21
Program.cs Normal file
View File

@ -0,0 +1,21 @@
using Avalonia;
using System;
namespace demka2025_sedelnikov;
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()
.WithInterFont()
.LogToTrace();
}

BIN
Res/Мастер пол.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

18
app.manifest Normal file
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="demka2025_sedelnikov.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>

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.

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.

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.

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.

BIN
bin/Debug/net8.0/Npgsql.dll 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.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,14 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
"configProperties": {
"System.Reflection.NullabilityInfoContext.IsSupported": true,
"System.Runtime.InteropServices.BuiltInComInterop.IsSupported": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

Some files were not shown because too many files have changed in this diff Show More