This commit is contained in:
1billy17 2025-04-16 00:00:02 +03:00
commit ca4fe7686e
335 changed files with 7296 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

29
AddAgentWindow.axaml Normal file
View File

@ -0,0 +1,29 @@
<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="demko_v.AddAgentWindow"
Title="AddAgentWindow">
<StackPanel Spacing="5" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBox Width="300" x:Name="TitleTextBox" Watermark="Наименование"/>
<TextBox Width="300" x:Name="AddressTextBox" Watermark="Адрес"/>
<TextBox Width="300" x:Name="InnTextBox" Watermark="ИНН"/>
<TextBox Width="300" x:Name="KppTextBox" Watermark="КПП"/>
<TextBox Width="300" x:Name="PriorityTextBox" Watermark="Приоритет"/>
<TextBox Width="300" x:Name="DirectorNameTextBox" Watermark="Имя директора"/>
<TextBox Width="300" x:Name="EmailTextBox" Watermark="Почта"/>
<TextBox Width="300" x:Name="PhoneNumberTextBox" Watermark="Номер телефона"/>
<ComboBox Width="300" x:Name="TypeAgentAddCombobox">
<ComboBoxItem Content="ООО"/>
<ComboBoxItem Content="МФО"/>
<ComboBoxItem Content="ЗАО"/>
<ComboBoxItem Content="МКК"/>
<ComboBoxItem Content="ПАО"/>
<ComboBoxItem Content="ОАО"/>
</ComboBox>
<Button Width="125" x:Name="SelectImageButton" Click="SelectImage" Content="Выбрать фото"/>
<Image Width="60" Height="60" x:Name="AgentImage"/>
<Button Width="125" x:Name="SaveButton" Content="Сохранить" Click="AddAgent_OnClick"/>
</StackPanel>
</Window>

98
AddAgentWindow.axaml.cs Normal file
View File

@ -0,0 +1,98 @@
using System;
using System.IO;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Media.Imaging;
using System.Linq;
using Avalonia.Platform.Storage;
using demko_v.Models;
namespace demko_v;
public partial class AddAgentWindow : Window
{
public string PathToImage = string.Empty;
public AddAgentWindow()
{
InitializeComponent();
}
private async Task<Bitmap?> SelectAndSaveImage()
{
var showDialog = StorageProvider.OpenFilePickerAsync(
options: new Avalonia.Platform.Storage.FilePickerOpenOptions()
{
Title = "Select an image",
FileTypeFilter = new[] { FilePickerFileTypes.ImageAll }
});
var storageFile = await showDialog;
try
{
var bmp = new Bitmap(storageFile.First().TryGetLocalPath());
string shortGuid = Guid.NewGuid().ToString("N").Substring(0, 8);
string path = $"/Users/feitanportor/dev/C#/demko_v/demko_v/bin/Debug/net8.0/agents/{shortGuid}.jpg";
bmp.Save(path);
PathToImage = path;
return bmp;
}
catch
{
return null;
}
}
public void AddAgent_OnClick(object? sender, RoutedEventArgs e)
{
using var ctx = new DemoAgentsContext();
if (string.IsNullOrWhiteSpace(TitleTextBox.Text) ||
string.IsNullOrWhiteSpace(AddressTextBox.Text) ||
string.IsNullOrWhiteSpace(InnTextBox.Text) ||
string.IsNullOrWhiteSpace(KppTextBox.Text) ||
string.IsNullOrWhiteSpace(PriorityTextBox.Text) ||
string.IsNullOrWhiteSpace(EmailTextBox.Text) ||
string.IsNullOrWhiteSpace(PhoneNumberTextBox.Text) ||
string.IsNullOrWhiteSpace(PathToImage))
{
return;
}
if (TypeAgentAddCombobox.SelectedItem is not ComboBoxItem selectedItem)
return;
string selectedType = selectedItem.Content.ToString();
var agentType = ctx.AgentTypes.FirstOrDefault(at => at.Title == selectedType);
if (agentType is null)
{
return;
}
var newAgent = new Agent
{
Title = TitleTextBox.Text,
Address = AddressTextBox.Text,
Inn = InnTextBox.Text,
Kpp = KppTextBox.Text,
Priority = int.Parse(PriorityTextBox.Text),
Email = EmailTextBox.Text,
Phone = PhoneNumberTextBox.Text,
Logo = PathToImage,
DirectorName = DirectorNameTextBox.Text,
AgentTypeId = agentType.Id
};
ctx.Agents.Add(newAgent);
ctx.SaveChanges();
Close();
}
private async void SelectImage(object? sender, RoutedEventArgs e)
{
AgentImage.Source = await SelectAndSaveImage();
}
}

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="demko_v.App"
RequestedThemeVariant="Default">
<!-- "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 demko_v;
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();
}
}

22
EditAgentWindow.axaml Normal file
View File

@ -0,0 +1,22 @@
<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="demko_v.EditAgentWindow"
Title="AddAgentWindow">
<StackPanel Spacing="5" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBox Width="300" x:Name="TitleTextBox" Watermark="Наименование"/>
<TextBox Width="300" x:Name="AddressTextBox" Watermark="Адрес"/>
<TextBox Width="300" x:Name="InnTextBox" Watermark="ИНН"/>
<TextBox Width="300" x:Name="KppTextBox" Watermark="КПП"/>
<TextBox Width="300" x:Name="PriorityTextBox" Watermark="Приоритет"/>
<TextBox Width="300" x:Name="DirectorNameTextBox" Watermark="Имя директора"/>
<TextBox Width="300" x:Name="EmailTextBox" Watermark="Почта"/>
<TextBox Width="300" x:Name="PhoneNumberTextBox" Watermark="Номер телефона"/>
<ComboBox Width="300" x:Name="TypeAgentAddCombobox" SelectionChanged="TypeAgentAddCombobox_OnSelectionChanged"/>
<Button Width="125" x:Name="SelectImageButton" Click="SelectImage" Content="Выбрать фото"/>
<Image Width="60" Height="60" x:Name="AgentImage"/>
<Button Width="125" x:Name="SaveButton" Content="Сохранить" Click="EditAgent_OnClick"/>
</StackPanel>
</Window>

152
EditAgentWindow.axaml.cs Normal file
View File

@ -0,0 +1,152 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Media.Imaging;
using System.Linq;
using Avalonia.Platform.Storage;
using demko_v.Models;
namespace demko_v;
public partial class EditAgentWindow : Window
{
public string PathToImage = string.Empty;
public Agent agentPresenter;
public List<string> AgentTypesList { get; }
public EditAgentWindow(Agent agentInput)
{
using var ctx = new DemoAgentsContext();
InitializeComponent();
agentPresenter = agentInput;
AgentTypesList = ctx.AgentTypes.Select(a => a.Title).ToList();
TypeAgentAddCombobox.ItemsSource = AgentTypesList;
Otrisovka();
}
private async void EditAgent_OnClick(object? sender, RoutedEventArgs e)
{
using var ctx = new DemoAgentsContext();
if (string.IsNullOrWhiteSpace(TitleTextBox.Text)) return;
agentPresenter.Title = TitleTextBox.Text;
if (!int.TryParse(PriorityTextBox.Text, out int priority)) return;
agentPresenter.Priority = priority;
if (string.IsNullOrWhiteSpace(AddressTextBox.Text)) return;
agentPresenter.Address = AddressTextBox.Text;
if (string.IsNullOrWhiteSpace(InnTextBox.Text)) return;
agentPresenter.Inn = InnTextBox.Text;
if (string.IsNullOrWhiteSpace(KppTextBox.Text)) return;
agentPresenter.Kpp = KppTextBox.Text;
if (string.IsNullOrWhiteSpace(DirectorNameTextBox.Text)) return;
agentPresenter.DirectorName = DirectorNameTextBox.Text;
if (string.IsNullOrWhiteSpace(PhoneNumberTextBox.Text)) return;
agentPresenter.Phone = PhoneNumberTextBox.Text;
if (string.IsNullOrWhiteSpace(EmailTextBox.Text)) return;
agentPresenter.Email = EmailTextBox.Text;
if (TypeAgentAddCombobox.SelectedItem is AgentType selectedAgentType)
{
agentPresenter.AgentTypeId = selectedAgentType.Id;
}
if (!string.IsNullOrEmpty(PathToImage))
{
agentPresenter.Logo = PathToImage;
}
ctx.Agents.Update(agentPresenter);
await ctx.SaveChangesAsync();
Close(agentPresenter);
}
private async Task<Bitmap?> SelectAndSaveImage()
{
var showDialog = StorageProvider.OpenFilePickerAsync(
options: new Avalonia.Platform.Storage.FilePickerOpenOptions()
{
Title = "Select an image",
FileTypeFilter = new[] { FilePickerFileTypes.ImageAll }
});
var storageFile = await showDialog;
try
{
var bmp = new Bitmap(storageFile.First().TryGetLocalPath());
string shortGuid = Guid.NewGuid().ToString("N").Substring(0, 8);
string path = $"/Users/feitanportor/dev/C#/demko_v/demko_v/bin/Debug/net8.0/agents/{shortGuid}.jpg";
bmp.Save(path);
PathToImage = $"agents/{shortGuid}.jpg";
return bmp;
}
catch
{
return null;
}
}
private async void SelectImage(object? sender, RoutedEventArgs e)
{
AgentImage.Source = await SelectAndSaveImage();
}
private void TypeAgentAddCombobox_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
using var ctx = new DemoAgentsContext();
if (TypeAgentAddCombobox.SelectedItem is string selectedTitle)
{
var agentType = ctx.AgentTypes.FirstOrDefault(t => t.Title == selectedTitle);
if (agentType != null)
{
agentPresenter.AgentTypeId = agentType.Id;
}
}
}
private void Otrisovka()
{
using var ctx = new DemoAgentsContext();
TitleTextBox.Text = agentPresenter.Title;
PriorityTextBox.Text = agentPresenter.Priority.ToString();
AddressTextBox.Text = agentPresenter.Address;
InnTextBox.Text = agentPresenter.Inn;
KppTextBox.Text = agentPresenter.Kpp;
DirectorNameTextBox.Text = agentPresenter.DirectorName;
PhoneNumberTextBox.Text = agentPresenter.Phone;
EmailTextBox.Text = agentPresenter.Email;
if (!string.IsNullOrEmpty(agentPresenter.Logo))
{
string imagePath = Path.Combine(Environment.CurrentDirectory, agentPresenter.Logo);
if (File.Exists(imagePath))
{
var bitmap = new Bitmap(imagePath);
AgentImage.Source = bitmap;
PathToImage = agentPresenter.Logo;
}
}
if (agentPresenter.AgentTypeId != 0)
{
var selectedType = ctx.AgentTypes.FirstOrDefault(t => t.Id == agentPresenter.AgentTypeId)?.Title;
if (selectedType != null)
{
TypeAgentAddCombobox.SelectedItem = selectedType;
}
}
}
}

92
MainWindow.axaml Normal file
View File

@ -0,0 +1,92 @@
<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="demko_v.MainWindow"
x:CompileBindings="False"
Title="demko_agents">
<DockPanel>
<StackPanel
HorizontalAlignment="Center"
Orientation="Horizontal"
DockPanel.Dock="Top"
Spacing="10"
Height="50">
<TextBox Width="200" x:Name="SearchTextBox" TextChanging="SearchTextBox_OnTextChanging" Watermark="Поиск"/>
<TextBlock VerticalAlignment="Center" Text="Имя:"/>
<ComboBox VerticalAlignment="Center" Width="100" x:Name="TitleAgentSortComboBox" SelectionChanged="TitleAgentSortComboBox_OnSelectionChanged">
<ComboBoxItem Content="Дефолт"/>
<ComboBoxItem Content="А - я"/>
<ComboBoxItem Content="Я - а"/>
</ComboBox>
<TextBlock VerticalAlignment="Center" Text="Скидка:"/>
<ComboBox VerticalAlignment="Center" Width="100" x:Name="SaleSortComboBox" SelectionChanged="SaleSortComboBox_OnSelectionChanged">
<ComboBoxItem Content="Дефолт"/>
<ComboBoxItem Content="Убывание"/>
<ComboBoxItem Content="Возрастание"/>
</ComboBox>
<TextBlock VerticalAlignment="Center" Text="Приоритет:"/>
<ComboBox VerticalAlignment="Center" Width="100" x:Name="PrioritySortCombobox" SelectionChanged="PrioritySortCombobox_OnSelectionChanged">
<ComboBoxItem Content="Дефолт"/>
<ComboBoxItem Content="Убывание"/>
<ComboBoxItem Content="Возрастание"/>
</ComboBox>
<TextBlock VerticalAlignment="Center" Text="Тип агента:"/>
<ComboBox VerticalAlignment="Center" Width="100" x:Name="TypeAgentSortCombobox" SelectionChanged="TypeAgentSortCombobox_OnSelectionChanged">
<ComboBoxItem Content="Все"/>
<ComboBoxItem Content="ООО"/>
<ComboBoxItem Content="МФО"/>
<ComboBoxItem Content="ЗАО"/>
<ComboBoxItem Content="МКК"/>
<ComboBoxItem Content="ПАО"/>
<ComboBoxItem Content="ОАО"/>
</ComboBox>
<Button HorizontalContentAlignment="Right" VerticalContentAlignment="Center" x:Name="AddAgent" Click="AddAgent_OnClick" Content="Добавить агента"/>
</StackPanel>
<StackPanel
Spacing="10"
HorizontalAlignment="Center"
Orientation="Horizontal"
DockPanel.Dock="Bottom" Height="40">
<Button HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Width="70" x:Name="BackButton" Click="Back_OnClick" Content="Назад"/>
<TextBlock VerticalAlignment="Center" x:Name="CountAgentsTextBlock"/>
<Button HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Width="70" x:Name="NextButton" Click="Next_OnClick" Content="Вперед"/>
</StackPanel>
<Border>
<ListBox x:Name="AgentListBox">
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Gray" BorderThickness="1" Padding="10" CornerRadius="5">
<Grid ColumnDefinitions="120, *" Margin="5" HorizontalAlignment="Center">
<Image Grid.Column="0" Width="100" Height="100"
Source="{Binding Image}"
Stretch="UniformToFill"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Margin="5"/>
<StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Spacing="5">
<TextBlock Text="{Binding Title}" FontSize="18" FontWeight="Bold"/>
<TextBlock Text="{Binding SalesYear}" FontWeight="Bold"/>
<TextBlock Text="{Binding SalesQuantity}"/>
<TextBlock Text="{Binding CountSales}"/>
<TextBlock Text="{Binding Sale}"/>
<TextBlock Text="{Binding Phone}"/>
<TextBlock Text="{Binding AgentType}"/>
<TextBlock Text="{Binding Priority}"/>
</StackPanel>
</Grid>
<Border.ContextMenu>
<ContextMenu>
<MenuItem Header="edit" Click="EditMenuItem_OnClick"/>
<MenuItem Header="priority" Click="PriorityMenuItem_OnClick"/>
</ContextMenu>
</Border.ContextMenu>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
</DockPanel>
</Window>

244
MainWindow.axaml.cs Normal file
View File

@ -0,0 +1,244 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.Media.Imaging;
using Microsoft.EntityFrameworkCore;
using demko_v.Models;
namespace demko_v;
public partial class MainWindow : Window
{
ObservableCollection<AgentPresenter> agents = new ObservableCollection<AgentPresenter>();
List<AgentPresenter> dataSourceAgents;
private const int ItemsPerPage = 10;
private int currentPage = 1;
public MainWindow()
{
InitializeComponent();
LoadData();
TitleAgentSortComboBox.SelectedIndex = 0;
SaleSortComboBox.SelectedIndex = 0;
PrioritySortCombobox.SelectedIndex = 0;
TypeAgentSortCombobox.SelectedIndex = 0;
DisplayAgents();
}
private void LoadData()
{
using var ctx = new DemoAgentsContext();
dataSourceAgents = ctx.Agents
.Include(a => a.ProductSales)
.ThenInclude(ps => ps.Product)
.Select(agent => new AgentPresenter
{
Id = agent.Id,
Title = agent.Title,
Phone = "+" + agent.Phone,
AgentType = agent.AgentType.Title,
Priority = agent.Priority,
SalesYear = agent.ProductSales.Any() ? agent.ProductSales.Max(ps => ps.SaleDate.Year) : 0,
SalesQuantity = agent.ProductSales.Sum(ps => ps.ProductCount * (int)ps.Product.MinCostForAgent),
CountSales = agent.ProductSales.Sum(ps => ps.ProductCount),
Sale = agent.ProductSales.Any() ? CalculateSale(agent.ProductSales.Sum(ps => ps.Product.MinCostForAgent * ps.ProductCount)) + "%" : "0%",
Logo = agent.Logo
}).ToList();
}
public void DisplayAgents()
{
LoadData();
var temp = dataSourceAgents;
agents.Clear();
switch (TitleAgentSortComboBox.SelectedIndex)
{
case 0: break;
case 1: temp = temp.OrderBy(a => a.Title).ToList(); break;
case 2: temp = temp.OrderByDescending(a => a.Title).ToList(); break;
}
switch (SaleSortComboBox.SelectedIndex)
{
case 0: break;
case 1: temp = temp.OrderByDescending(a => int.Parse(a.Sale.Replace("%", ""))).ToList(); break;
case 2: temp = temp.OrderBy(a => int.Parse(a.Sale.Replace("%", ""))).ToList(); break;
}
switch (PrioritySortCombobox.SelectedIndex)
{
case 0: break;
case 1: temp = temp.OrderByDescending(a => a.Priority).ToList(); break;
case 2: temp = temp.OrderBy(a => a.Priority).ToList(); break;
}
switch (TypeAgentSortCombobox.SelectedIndex)
{
case 0: break;
case 1: temp = temp.Where(a => a.AgentType == "ООО").ToList(); break;
case 2: temp = temp.Where(a => a.AgentType == "МФО").ToList(); break;
case 3: temp = temp.Where(a => a.AgentType == "ЗАО").ToList(); break;
case 4: temp = temp.Where(a => a.AgentType == "МКК").ToList(); break;
case 5: temp = temp.Where(a => a.AgentType == "ПАО").ToList(); break;
case 6: temp = temp.Where(a => a.AgentType == "ОАО").ToList(); break;
}
if (!string.IsNullOrEmpty(SearchTextBox.Text))
{
var search = SearchTextBox.Text;
temp = temp.Where(a => IsContains(a.Title, a.Phone, search)).ToList();
}
foreach (var item in temp)
{
agents.Add(item);
}
currentPage = 0;
UpdateListBox();
}
public class AgentPresenter : Agent
{
Bitmap? Image
{
get
{
try
{
string absolutePath = Path.Combine(AppContext.BaseDirectory, Logo);
return new Bitmap(absolutePath);
}
catch
{
return null;
}
}
}
public int SalesYear { get; set; }
public int? SalesQuantity { get; set; }
public string? Sale { get; set; }
public string? AgentType { get; set; }
public int CountSales { get; set; }
}
public void UpdateListBox()
{
var pagedAgents = agents.Skip(currentPage * ItemsPerPage).Take(ItemsPerPage).ToList();
AgentListBox.ItemsSource = pagedAgents;
CountAgentsTextBlock.Text = $"{currentPage + 1} / {Math.Ceiling((double)agents.Count / ItemsPerPage)}";
BackButton.IsEnabled = currentPage > 0;
NextButton.IsEnabled = (currentPage + 1) * ItemsPerPage < agents.Count;
}
public void Back_OnClick(object? sender, RoutedEventArgs e)
{
if (currentPage > 0)
{
currentPage--;
UpdateListBox();
}
}
public void Next_OnClick(object? sender, RoutedEventArgs e)
{
if ((currentPage + 1) * ItemsPerPage < agents.Count)
{
currentPage++;
UpdateListBox();
}
}
public bool IsContains(string title, string phone, string search)
{
string message = (title + phone).ToLower();
search = search.ToLower();
return message.Contains(search);
}
private static int CalculateSale(decimal totalSales)
{
if (totalSales < 10000) return 0;
if (totalSales < 50000) return 5;
if (totalSales < 150000) return 10;
if (totalSales < 500000) return 20;
return 25;
}
public void SearchTextBox_OnTextChanging(object? sender, RoutedEventArgs e)
{
DisplayAgents();
}
public void TitleAgentSortComboBox_OnSelectionChanged(object? sender, RoutedEventArgs e)
{
DisplayAgents();
}
public void SaleSortComboBox_OnSelectionChanged(object? sender, RoutedEventArgs e)
{
DisplayAgents();
}
public void PrioritySortCombobox_OnSelectionChanged(object? sender, RoutedEventArgs e)
{
DisplayAgents();
}
public void TypeAgentSortCombobox_OnSelectionChanged(object? sender, RoutedEventArgs e)
{
DisplayAgents();
}
public void AddAgent_OnClick(object? sender, RoutedEventArgs e)
{
AddAgentWindow attendanceButton = new AddAgentWindow();
attendanceButton.ShowDialog(this); ;
}
private async void EditMenuItem_OnClick(object? sender, RoutedEventArgs e)
{
using var ctx = new DemoAgentsContext();
if (AgentListBox.SelectedItem is AgentPresenter selectedAgentPresenter)
{
var agent = ctx.Agents.FirstOrDefault(a => a.Id == selectedAgentPresenter.Id);
EditAgentWindow editAgentWindow = new EditAgentWindow(agent);
var updatedAgent = await editAgentWindow.ShowDialog<Agent>(this);
}
DisplayAgents();
}
private async void PriorityMenuItem_OnClick(object? sender, RoutedEventArgs e)
{
if (AgentListBox.SelectedItem is AgentPresenter selectedAgentPresenter)
{
PriorityWindow priorityWindow = new PriorityWindow(selectedAgentPresenter.Id);
await priorityWindow.ShowDialog(this);
}
DisplayAgents();
}
}

33
Models/Agent.cs Normal file
View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
namespace demko_v.Models;
public partial class Agent
{
public int Id { get; set; }
public string Title { get; set; } = null!;
public int AgentTypeId { get; set; }
public string? Address { get; set; }
public string Inn { get; set; } = null!;
public string? Kpp { get; set; }
public string? DirectorName { get; set; }
public string Phone { get; set; } = null!;
public string? Email { get; set; }
public string? Logo { get; set; }
public int Priority { get; set; }
public virtual AgentType AgentType { get; set; } = null!;
public virtual ICollection<ProductSale> ProductSales { get; set; } = new List<ProductSale>();
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace demko_v.Models;
public partial class AgentPriorityHistory
{
public int Id { get; set; }
public int AgentId { get; set; }
public DateTime ChangeDate { get; set; }
public int PriorityValue { get; set; }
}

17
Models/AgentType.cs Normal file
View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
namespace demko_v.Models;
public partial class AgentType
{
public int Id { get; set; }
public string Title { get; set; } = null!;
public string? Image { get; set; }
public string? ТипАгента { get; set; }
public virtual ICollection<Agent> Agents { get; set; } = new List<Agent>();
}

282
Models/DatabaseContext.cs Normal file
View File

@ -0,0 +1,282 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
namespace demko_v.Models;
public partial class DatabaseContext : DbContext
{
public DatabaseContext()
{
}
public DatabaseContext(DbContextOptions<DatabaseContext> options)
: base(options)
{
}
public virtual DbSet<Agent> Agents { get; set; }
public virtual DbSet<AgentPriorityHistory> AgentPriorityHistories { get; set; }
public virtual DbSet<AgentType> AgentTypes { get; set; }
public virtual DbSet<Material> Materials { get; set; }
public virtual DbSet<MaterialCountHistory> MaterialCountHistories { get; set; }
public virtual DbSet<MaterialType> MaterialTypes { get; set; }
public virtual DbSet<Product> Products { get; set; }
public virtual DbSet<ProductCostHistory> ProductCostHistories { get; set; }
public virtual DbSet<ProductMaterial> ProductMaterials { get; set; }
public virtual DbSet<ProductSale> ProductSales { get; set; }
public virtual DbSet<ProductType> ProductTypes { get; set; }
public virtual DbSet<Shop> Shops { get; set; }
public virtual DbSet<Supplier> Suppliers { 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;Database=demo_agents;Username=demo_agents;Password=demo_agents;Port=5445");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Agent>(entity =>
{
entity.HasKey(e => e.Id).HasName("Agent_pkey");
entity.ToTable("Agent");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Address).HasMaxLength(300);
entity.Property(e => e.AgentTypeId).HasColumnName("AgentTypeID");
entity.Property(e => e.DirectorName).HasMaxLength(100);
entity.Property(e => e.Email).HasMaxLength(255);
entity.Property(e => e.Inn)
.HasMaxLength(12)
.HasColumnName("INN");
entity.Property(e => e.Kpp)
.HasMaxLength(9)
.HasColumnName("KPP");
entity.Property(e => e.Logo).HasMaxLength(100);
entity.Property(e => e.Phone).HasMaxLength(20);
entity.Property(e => e.Title).HasMaxLength(150);
entity.HasOne(d => d.AgentType).WithMany(p => p.Agents)
.HasForeignKey(d => d.AgentTypeId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Agent_AgentTypeID_fkey");
});
modelBuilder.Entity<AgentPriorityHistory>(entity =>
{
entity.HasKey(e => e.Id).HasName("AgentPriorityHistory_pkey");
entity.ToTable("AgentPriorityHistory");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.AgentId).HasColumnName("AgentID");
entity.Property(e => e.ChangeDate).HasColumnType("timestamp without time zone");
});
modelBuilder.Entity<AgentType>(entity =>
{
entity.HasKey(e => e.Id).HasName("AgentType_pkey");
entity.ToTable("AgentType");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Image).HasMaxLength(100);
entity.Property(e => e.Title).HasMaxLength(50);
entity.Property(e => e.ТипАгента)
.HasMaxLength(50)
.HasColumnName("Тип агента");
});
modelBuilder.Entity<Material>(entity =>
{
entity.HasKey(e => e.Id).HasName("Material_pkey");
entity.ToTable("Material");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Cost).HasPrecision(10, 2);
entity.Property(e => e.Image).HasMaxLength(100);
entity.Property(e => e.MaterialTypeId).HasColumnName("MaterialTypeID");
entity.Property(e => e.Title).HasMaxLength(100);
entity.Property(e => e.Unit).HasMaxLength(10);
entity.HasOne(d => d.MaterialType).WithMany(p => p.Materials)
.HasForeignKey(d => d.MaterialTypeId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Material_MaterialTypeID_fkey");
entity.HasMany(d => d.Suppliers).WithMany(p => p.Materials)
.UsingEntity<Dictionary<string, object>>(
"MaterialSupplier",
r => r.HasOne<Supplier>().WithMany()
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("MaterialSupplier_SupplierID_fkey"),
l => l.HasOne<Material>().WithMany()
.HasForeignKey("MaterialId")
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("MaterialSupplier_MaterialID_fkey"),
j =>
{
j.HasKey("MaterialId", "SupplierId").HasName("MaterialSupplier_pkey");
j.ToTable("MaterialSupplier");
j.IndexerProperty<int>("MaterialId").HasColumnName("MaterialID");
j.IndexerProperty<int>("SupplierId").HasColumnName("SupplierID");
});
});
modelBuilder.Entity<MaterialCountHistory>(entity =>
{
entity.HasKey(e => e.Id).HasName("MaterialCountHistory_pkey");
entity.ToTable("MaterialCountHistory");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.ChangeDate).HasColumnType("timestamp without time zone");
entity.Property(e => e.MaterialId).HasColumnName("MaterialID");
entity.HasOne(d => d.Material).WithMany(p => p.MaterialCountHistories)
.HasForeignKey(d => d.MaterialId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("MaterialCountHistory_MaterialID_fkey");
});
modelBuilder.Entity<MaterialType>(entity =>
{
entity.HasKey(e => e.Id).HasName("MaterialType_pkey");
entity.ToTable("MaterialType");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Title).HasMaxLength(50);
});
modelBuilder.Entity<Product>(entity =>
{
entity.HasKey(e => e.Id).HasName("Product_pkey");
entity.ToTable("Product");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.ArticleNumber).HasMaxLength(10);
entity.Property(e => e.Image).HasMaxLength(100);
entity.Property(e => e.MinCostForAgent).HasPrecision(10, 2);
entity.Property(e => e.ProductTypeId).HasColumnName("ProductTypeID");
entity.Property(e => e.Title).HasMaxLength(100);
entity.HasOne(d => d.ProductType).WithMany(p => p.Products)
.HasForeignKey(d => d.ProductTypeId)
.HasConstraintName("Product_ProductTypeID_fkey");
});
modelBuilder.Entity<ProductCostHistory>(entity =>
{
entity.HasKey(e => e.Id).HasName("ProductCostHistory_pkey");
entity.ToTable("ProductCostHistory");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.ChangeDate).HasColumnType("timestamp without time zone");
entity.Property(e => e.CostValue).HasPrecision(10, 2);
entity.Property(e => e.ProductId).HasColumnName("ProductID");
entity.HasOne(d => d.Product).WithMany(p => p.ProductCostHistories)
.HasForeignKey(d => d.ProductId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("ProductCostHistory_ProductID_fkey");
});
modelBuilder.Entity<ProductMaterial>(entity =>
{
entity.HasKey(e => new { e.ProductId, e.MaterialId }).HasName("ProductMaterial_pkey");
entity.ToTable("ProductMaterial");
entity.Property(e => e.ProductId).HasColumnName("ProductID");
entity.Property(e => e.MaterialId).HasColumnName("MaterialID");
entity.HasOne(d => d.Material).WithMany(p => p.ProductMaterials)
.HasForeignKey(d => d.MaterialId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("ProductMaterial_MaterialID_fkey");
entity.HasOne(d => d.Product).WithMany(p => p.ProductMaterials)
.HasForeignKey(d => d.ProductId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("ProductMaterial_ProductID_fkey");
});
modelBuilder.Entity<ProductSale>(entity =>
{
entity.HasKey(e => e.Id).HasName("ProductSale_pkey");
entity.ToTable("ProductSale");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.AgentId).HasColumnName("AgentID");
entity.Property(e => e.ProductId).HasColumnName("ProductID");
entity.HasOne(d => d.Agent).WithMany(p => p.ProductSales)
.HasForeignKey(d => d.AgentId)
.HasConstraintName("fk_productsale_agent");
entity.HasOne(d => d.Product).WithMany(p => p.ProductSales)
.HasForeignKey(d => d.ProductId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("ProductSale_ProductID_fkey");
});
modelBuilder.Entity<ProductType>(entity =>
{
entity.HasKey(e => e.Id).HasName("ProductType_pkey");
entity.ToTable("ProductType");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Percent).HasColumnName("percent");
entity.Property(e => e.Title).HasMaxLength(50);
});
modelBuilder.Entity<Shop>(entity =>
{
entity.HasKey(e => e.Id).HasName("Shop_pkey");
entity.ToTable("Shop");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Address).HasMaxLength(300);
entity.Property(e => e.AgentId).HasColumnName("AgentID");
entity.Property(e => e.Title).HasMaxLength(150);
});
modelBuilder.Entity<Supplier>(entity =>
{
entity.HasKey(e => e.Id).HasName("Supplier_pkey");
entity.ToTable("Supplier");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Inn)
.HasMaxLength(12)
.HasColumnName("INN");
entity.Property(e => e.SupplierType).HasMaxLength(20);
entity.Property(e => e.Title).HasMaxLength(150);
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}

278
Models/DemoAgentsContext.cs Normal file
View File

@ -0,0 +1,278 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
namespace demko_v.Models;
public partial class DemoAgentsContext : DbContext
{
public DemoAgentsContext()
{
}
public DemoAgentsContext(DbContextOptions<DemoAgentsContext> options)
: base(options)
{
}
public virtual DbSet<Agent> Agents { get; set; }
public virtual DbSet<AgentPriorityHistory> AgentPriorityHistories { get; set; }
public virtual DbSet<AgentType> AgentTypes { get; set; }
public virtual DbSet<Material> Materials { get; set; }
public virtual DbSet<MaterialCountHistory> MaterialCountHistories { get; set; }
public virtual DbSet<MaterialType> MaterialTypes { get; set; }
public virtual DbSet<Product> Products { get; set; }
public virtual DbSet<ProductCostHistory> ProductCostHistories { get; set; }
public virtual DbSet<ProductMaterial> ProductMaterials { get; set; }
public virtual DbSet<ProductSale> ProductSales { get; set; }
public virtual DbSet<ProductType> ProductTypes { get; set; }
public virtual DbSet<Shop> Shops { get; set; }
public virtual DbSet<Supplier> Suppliers { 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;Database=demo_agents;Username=demo_agents;Password=demo_agents;Port=5445");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Agent>(entity =>
{
entity.HasKey(e => e.Id).HasName("Agent_pkey");
entity.ToTable("Agent");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Address).HasMaxLength(300);
entity.Property(e => e.AgentTypeId).HasColumnName("AgentTypeID");
entity.Property(e => e.DirectorName).HasMaxLength(100);
entity.Property(e => e.Email).HasMaxLength(255);
entity.Property(e => e.Inn)
.HasMaxLength(12)
.HasColumnName("INN");
entity.Property(e => e.Kpp)
.HasMaxLength(9)
.HasColumnName("KPP");
entity.Property(e => e.Logo).HasMaxLength(100);
entity.Property(e => e.Phone).HasMaxLength(20);
entity.Property(e => e.Title).HasMaxLength(150);
entity.HasOne(d => d.AgentType).WithMany(p => p.Agents)
.HasForeignKey(d => d.AgentTypeId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Agent_AgentTypeID_fkey");
});
modelBuilder.Entity<AgentPriorityHistory>(entity =>
{
entity.HasKey(e => e.Id).HasName("AgentPriorityHistory_pkey");
entity.ToTable("AgentPriorityHistory");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.AgentId).HasColumnName("AgentID");
entity.Property(e => e.ChangeDate).HasColumnType("timestamp without time zone");
});
modelBuilder.Entity<AgentType>(entity =>
{
entity.HasKey(e => e.Id).HasName("AgentType_pkey");
entity.ToTable("AgentType");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Image).HasMaxLength(100);
entity.Property(e => e.Title).HasMaxLength(50);
entity.Property(e => e.ТипАгента)
.HasMaxLength(50)
.HasColumnName("Тип агента");
});
modelBuilder.Entity<Material>(entity =>
{
entity.HasKey(e => e.Id).HasName("Material_pkey");
entity.ToTable("Material");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Cost).HasPrecision(10, 2);
entity.Property(e => e.Image).HasMaxLength(100);
entity.Property(e => e.MaterialTypeId).HasColumnName("MaterialTypeID");
entity.Property(e => e.Title).HasMaxLength(100);
entity.Property(e => e.Unit).HasMaxLength(10);
entity.HasOne(d => d.MaterialType).WithMany(p => p.Materials)
.HasForeignKey(d => d.MaterialTypeId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Material_MaterialTypeID_fkey");
entity.HasMany(d => d.Suppliers).WithMany(p => p.Materials)
.UsingEntity<Dictionary<string, object>>(
"MaterialSupplier",
r => r.HasOne<Supplier>().WithMany()
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("MaterialSupplier_SupplierID_fkey"),
l => l.HasOne<Material>().WithMany()
.HasForeignKey("MaterialId")
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("MaterialSupplier_MaterialID_fkey"),
j =>
{
j.HasKey("MaterialId", "SupplierId").HasName("MaterialSupplier_pkey");
j.ToTable("MaterialSupplier");
j.IndexerProperty<int>("MaterialId").HasColumnName("MaterialID");
j.IndexerProperty<int>("SupplierId").HasColumnName("SupplierID");
});
});
modelBuilder.Entity<MaterialCountHistory>(entity =>
{
entity.HasKey(e => e.Id).HasName("MaterialCountHistory_pkey");
entity.ToTable("MaterialCountHistory");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.ChangeDate).HasColumnType("timestamp without time zone");
entity.Property(e => e.MaterialId).HasColumnName("MaterialID");
entity.HasOne(d => d.Material).WithMany(p => p.MaterialCountHistories)
.HasForeignKey(d => d.MaterialId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("MaterialCountHistory_MaterialID_fkey");
});
modelBuilder.Entity<MaterialType>(entity =>
{
entity.HasKey(e => e.Id).HasName("MaterialType_pkey");
entity.ToTable("MaterialType");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Title).HasMaxLength(50);
});
modelBuilder.Entity<Product>(entity =>
{
entity.HasKey(e => e.Id).HasName("Product_pkey");
entity.ToTable("Product");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.ArticleNumber).HasMaxLength(10);
entity.Property(e => e.Image).HasMaxLength(100);
entity.Property(e => e.MinCostForAgent).HasPrecision(10, 2);
entity.Property(e => e.ProductTypeId).HasColumnName("ProductTypeID");
entity.Property(e => e.Title).HasMaxLength(100);
entity.HasOne(d => d.ProductType).WithMany(p => p.Products)
.HasForeignKey(d => d.ProductTypeId)
.HasConstraintName("Product_ProductTypeID_fkey");
});
modelBuilder.Entity<ProductCostHistory>(entity =>
{
entity.HasKey(e => e.Id).HasName("ProductCostHistory_pkey");
entity.ToTable("ProductCostHistory");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.ChangeDate).HasColumnType("timestamp without time zone");
entity.Property(e => e.CostValue).HasPrecision(10, 2);
entity.Property(e => e.ProductId).HasColumnName("ProductID");
entity.HasOne(d => d.Product).WithMany(p => p.ProductCostHistories)
.HasForeignKey(d => d.ProductId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("ProductCostHistory_ProductID_fkey");
});
modelBuilder.Entity<ProductMaterial>(entity =>
{
entity.HasKey(e => new { e.ProductId, e.MaterialId }).HasName("ProductMaterial_pkey");
entity.ToTable("ProductMaterial");
entity.Property(e => e.ProductId).HasColumnName("ProductID");
entity.Property(e => e.MaterialId).HasColumnName("MaterialID");
entity.HasOne(d => d.Material).WithMany(p => p.ProductMaterials)
.HasForeignKey(d => d.MaterialId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("ProductMaterial_MaterialID_fkey");
entity.HasOne(d => d.Product).WithMany(p => p.ProductMaterials)
.HasForeignKey(d => d.ProductId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("ProductMaterial_ProductID_fkey");
});
modelBuilder.Entity<ProductSale>(entity =>
{
entity.HasKey(e => e.Id).HasName("ProductSale_pkey");
entity.ToTable("ProductSale");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.AgentId).HasColumnName("AgentID");
entity.Property(e => e.ProductId).HasColumnName("ProductID");
entity.HasOne(d => d.Product).WithMany(p => p.ProductSales)
.HasForeignKey(d => d.ProductId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("ProductSale_ProductID_fkey");
});
modelBuilder.Entity<ProductType>(entity =>
{
entity.HasKey(e => e.Id).HasName("ProductType_pkey");
entity.ToTable("ProductType");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Percent).HasColumnName("percent");
entity.Property(e => e.Title).HasMaxLength(50);
});
modelBuilder.Entity<Shop>(entity =>
{
entity.HasKey(e => e.Id).HasName("Shop_pkey");
entity.ToTable("Shop");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Address).HasMaxLength(300);
entity.Property(e => e.AgentId).HasColumnName("AgentID");
entity.Property(e => e.Title).HasMaxLength(150);
});
modelBuilder.Entity<Supplier>(entity =>
{
entity.HasKey(e => e.Id).HasName("Supplier_pkey");
entity.ToTable("Supplier");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Inn)
.HasMaxLength(12)
.HasColumnName("INN");
entity.Property(e => e.SupplierType).HasMaxLength(20);
entity.Property(e => e.Title).HasMaxLength(150);
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}

35
Models/Material.cs Normal file
View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
namespace demko_v.Models;
public partial class Material
{
public int Id { get; set; }
public string Title { get; set; } = null!;
public int CountInPack { get; set; }
public string Unit { get; set; } = null!;
public double? CountInStock { get; set; }
public double MinCount { get; set; }
public string? Description { get; set; }
public decimal Cost { get; set; }
public string? Image { get; set; }
public int MaterialTypeId { get; set; }
public virtual ICollection<MaterialCountHistory> MaterialCountHistories { get; set; } = new List<MaterialCountHistory>();
public virtual MaterialType MaterialType { get; set; } = null!;
public virtual ICollection<ProductMaterial> ProductMaterials { get; set; } = new List<ProductMaterial>();
public virtual ICollection<Supplier> Suppliers { get; set; } = new List<Supplier>();
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
namespace demko_v.Models;
public partial class MaterialCountHistory
{
public int Id { get; set; }
public int MaterialId { get; set; }
public DateTime ChangeDate { get; set; }
public double CountValue { get; set; }
public virtual Material Material { get; set; } = null!;
}

15
Models/MaterialType.cs Normal file
View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace demko_v.Models;
public partial class MaterialType
{
public int Id { get; set; }
public string Title { get; set; } = null!;
public double DefectedPercent { get; set; }
public virtual ICollection<Material> Materials { get; set; } = new List<Material>();
}

33
Models/Product.cs Normal file
View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
namespace demko_v.Models;
public partial class Product
{
public int Id { get; set; }
public string Title { get; set; } = null!;
public int? ProductTypeId { get; set; }
public string ArticleNumber { get; set; } = null!;
public string? Description { get; set; }
public string? Image { get; set; }
public int? ProductionPersonCount { get; set; }
public int? ProductionWorkshopNumber { get; set; }
public decimal MinCostForAgent { get; set; }
public virtual ICollection<ProductCostHistory> ProductCostHistories { get; set; } = new List<ProductCostHistory>();
public virtual ICollection<ProductMaterial> ProductMaterials { get; set; } = new List<ProductMaterial>();
public virtual ICollection<ProductSale> ProductSales { get; set; } = new List<ProductSale>();
public virtual ProductType? ProductType { get; set; }
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
namespace demko_v.Models;
public partial class ProductCostHistory
{
public int Id { get; set; }
public int ProductId { get; set; }
public DateTime ChangeDate { get; set; }
public decimal CostValue { get; set; }
public virtual Product Product { get; set; } = null!;
}

17
Models/ProductMaterial.cs Normal file
View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
namespace demko_v.Models;
public partial class ProductMaterial
{
public int ProductId { get; set; }
public int MaterialId { get; set; }
public double? Count { get; set; }
public virtual Material Material { get; set; } = null!;
public virtual Product Product { get; set; } = null!;
}

21
Models/ProductSale.cs Normal file
View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
namespace demko_v.Models;
public partial class ProductSale
{
public int Id { get; set; }
public int AgentId { get; set; }
public int ProductId { get; set; }
public DateOnly SaleDate { get; set; }
public int ProductCount { get; set; }
public virtual Agent Agent { get; set; } = null!;
public virtual Product Product { get; set; } = null!;
}

17
Models/ProductType.cs Normal file
View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
namespace demko_v.Models;
public partial class ProductType
{
public int Id { get; set; }
public string Title { get; set; } = null!;
public double DefectedPercent { get; set; }
public int? Percent { get; set; }
public virtual ICollection<Product> Products { get; set; } = new List<Product>();
}

15
Models/Shop.cs Normal file
View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace demko_v.Models;
public partial class Shop
{
public int Id { get; set; }
public string Title { get; set; } = null!;
public string? Address { get; set; }
public int AgentId { get; set; }
}

21
Models/Supplier.cs Normal file
View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
namespace demko_v.Models;
public partial class Supplier
{
public int Id { get; set; }
public string Title { get; set; } = null!;
public string Inn { get; set; } = null!;
public DateOnly StartDate { get; set; }
public int? QualityRating { get; set; }
public string? SupplierType { get; set; }
public virtual ICollection<Material> Materials { get; set; } = new List<Material>();
}

13
PriorityWindow.axaml Normal file
View File

@ -0,0 +1,13 @@
<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="demko_v.PriorityWindow"
Title="PriorityWindow">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="10">
<TextBlock Text="Введите новый приоритет:"/>
<TextBox x:Name="PriorityTextBox" Width="100" HorizontalAlignment="Center"/>
<Button Content="OK" Click="Ok_OnClick" HorizontalAlignment="Center"/>
</StackPanel>
</Window>

38
PriorityWindow.axaml.cs Normal file
View File

@ -0,0 +1,38 @@
using System;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using demko_v.Models;
using Microsoft.EntityFrameworkCore;
namespace demko_v;
public partial class PriorityWindow : Window
{
private int AgentId;
public int? Priority { get; private set; }
public PriorityWindow(int agentId)
{
InitializeComponent();
AgentId = agentId;
}
private void Ok_OnClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
if (int.TryParse(PriorityTextBox.Text, out int priority))
{
Priority = priority;
using var ctx = new DemoAgentsContext();
ctx.Agents.Where(a => a.Id == AgentId)
.ExecuteUpdate(setters => setters.SetProperty(a => a.Priority, Priority));
ctx.SaveChanges();
Close();
}
else
{
Console.WriteLine("Invalid priority number");
}
}
}

21
Program.cs Normal file
View File

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

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="demko_v.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>

BIN
bin/.DS_Store vendored Normal file

Binary file not shown.

BIN
bin/Debug/.DS_Store vendored Normal file

Binary file not shown.

BIN
bin/Debug/net8.0/.DS_Store vendored 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.

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/Avalonia.X11.dll Executable file

Binary file not shown.

BIN
bin/Debug/net8.0/Avalonia.dll Executable file

Binary file not shown.

Binary file not shown.

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

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 Executable file

Binary file not shown.

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

BIN
bin/Debug/net8.0/agents/.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

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