KomMethods 1.0.0
dotnet add package KomMethods --version 1.0.0
NuGet\Install-Package KomMethods -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="KomMethods" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="KomMethods" Version="1.0.0" />
<PackageReference Include="KomMethods" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add KomMethods --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: KomMethods, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package KomMethods@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=KomMethods&version=1.0.0
#tool nuget:?package=KomMethods&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
using shoes.model;
using System;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace shoes
{
public partial class Products : Page
{
private int _roleId;
private int? _userId;
private SolidColorBrush _discBg = (SolidColorBrush)new BrushConverter().ConvertFrom("#2E8B57");
public Products(int roleId, int? userId)
{
InitializeComponent();
_roleId = roleId;
_userId = userId;
SetupByRole();
LoadProducts();
}
private void SetupByRole()
{
if (_roleId == 0 || _roleId == 3)
{
PanelTools.Visibility = Visibility.Collapsed;
PanelSimple.Visibility = Visibility.Visible;
GridProducts.IsReadOnly = true;
GridProducts.CanUserSortColumns = false;
return;
}
PanelTools.Visibility = Visibility.Visible;
PanelSimple.Visibility = Visibility.Collapsed;
GridProducts.CanUserSortColumns = true;
if (_roleId == 2)
GridProducts.IsReadOnly = true;
if (_roleId == 1)
GridProducts.IsReadOnly = false;
BtnOrders.Visibility = (_roleId == 1 || _roleId == 2) ? Visibility.Visible : Visibility.Collapsed;
BtnAdd.Visibility = BtnDelete.Visibility = BtnSave.Visibility =
(_roleId == 1) ? Visibility.Visible : Visibility.Collapsed;
CbCategory.Items.Clear();
CbCategory.Items.Add("Все");
foreach (var c in MainWindow.bd.Category.OrderBy(x => x.Name).ToList())
CbCategory.Items.Add(c);
CbCategory.SelectedIndex = 0;
CbSort.Items.Clear();
CbSort.Items.Add("Без сортировки");
CbSort.Items.Add("Цена ↑");
CbSort.Items.Add("Цена ↓");
CbSort.Items.Add("Скидка ↓");
CbSort.Items.Add("Артикул A→Z");
CbSort.Items.Add("Артикул Z→A");
CbSort.SelectedIndex = 0;
}
private void LoadProducts()
{
var q = MainWindow.bd.Product.AsQueryable();
if (_roleId == 0 || _roleId == 3)
{
GridProducts.ItemsSource = q.ToList();
return;
}
// Поиск
string s = (TbSearch.Text ?? "").Trim();
if (s.Length > 0)
q = q.Where(x => x.Article.Contains(s) || x.DescriptionText.Contains(s));
// Фильтр категории
if (CbCategory.SelectedItem != null && !(CbCategory.SelectedItem is string))
{
var cat = CbCategory.SelectedItem as Category;
if (cat != null)
q = q.Where(x => x.CategoryId == cat.CategoryId);
}
string sort = CbSort.SelectedItem as string;
if (sort == "Цена ↑") q = q.OrderBy(x => x.Cost);
else if (sort == "Цена ↓") q = q.OrderByDescending(x => x.Cost);
else if (sort == "Скидка ↓") q = q.OrderByDescending(x => x.DiscountPercent);
else if (sort == "Артикул A→Z") q = q.OrderBy(x => x.Article);
else if (sort == "Артикул Z→A") q = q.OrderByDescending(x => x.Article);
GridProducts.ItemsSource = q.ToList();
}
private void AnyFilterChanged(object sender, EventArgs e)
{
LoadProducts();
}
private void GridProducts_LoadingRow(object sender, DataGridRowEventArgs e)
{
var p = e.Row.Item as Product;
if (p == null) return;
if (e.Row.GetIndex() % 2 == 0) e.Row.Background = Brushes.White;
else e.Row.Background = (SolidColorBrush)new BrushConverter().ConvertFrom("#F7F7F7");
e.Row.Foreground = Brushes.Black;
if (p.DiscountPercent >= 15)
{
e.Row.Background = _discBg;
e.Row.Foreground = Brushes.White;
}
}
private void Orders_Click(object sender, RoutedEventArgs e)
{
if (!(_roleId == 1 || _roleId == 2))
{
MessageBox.Show("Доступно только менеджеру/администратору.");
return;
}
NavigationService.Navigate(new OrdersPage(_roleId, _userId));
}
private void Logout_Click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Login());
}
private void Add_Click(object sender, RoutedEventArgs e)
{
if (_roleId != 1) return;
var pt = MainWindow.bd.ProductType.FirstOrDefault();
var c = MainWindow.bd.Category.FirstOrDefault();
var m = MainWindow.bd.Maker.FirstOrDefault();
var pr = MainWindow.bd.Provider.FirstOrDefault();
if (pt == null || c == null || m == null || pr == null)
{
MessageBox.Show("Не заполнены справочники (Category/Maker/Provider/ProductType).");
return;
}
var p = new Product();
p.Article = "NEW_" + DateTime.Now.Ticks;
p.ProductTypeId = pt.ProductTypeId;
p.CategoryId = c.CategoryId;
p.MakerId = m.MakerId;
p.ProviderId = pr.ProviderId;
p.Unit = "шт.";
p.Cost = 0;
p.DiscountPercent = 0;
p.QuantityStock = 0;
p.DescriptionText = "";
p.PhotoFile = null;
MainWindow.bd.Product.Add(p);
MainWindow.bd.SaveChanges();
LoadProducts();
}
private void Delete_Click(object sender, RoutedEventArgs e)
{
if (_roleId != 1) return;
var p = GridProducts.SelectedItem as Product;
if (p == null) return;
if (MessageBox.Show("Удалить выбранный товар?", "Подтверждение",
MessageBoxButton.YesNo) != MessageBoxResult.Yes) return;
try
{
MainWindow.bd.Product.Remove(p);
MainWindow.bd.SaveChanges();
LoadProducts();
}
catch (Exception ex)
{
MessageBox.Show("Не удалось удалить (возможно, товар используется в заказах).\n" + ex.Message);
}
}
private void Save_Click(object sender, RoutedEventArgs e)
{
if (_roleId != 1) return;
try
{
MainWindow.bd.SaveChanges();
LoadProducts();
}
catch (Exception ex)
{
MessageBox.Show("Ошибка сохранения:\n" + ex.Message);
}
}
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 134 | 6/18/2026 |