Simplelastdayprog 1.0.0
dotnet add package Simplelastdayprog --version 1.0.0
NuGet\Install-Package Simplelastdayprog -Version 1.0.0
<PackageReference Include="Simplelastdayprog" Version="1.0.0" />
<PackageVersion Include="Simplelastdayprog" Version="1.0.0" />
<PackageReference Include="Simplelastdayprog" />
paket add Simplelastdayprog --version 1.0.0
#r "nuget: Simplelastdayprog, 1.0.0"
#:package Simplelastdayprog@1.0.0
#addin nuget:?package=Simplelastdayprog&version=1.0.0
#tool nuget:?package=Simplelastdayprog&version=1.0.0
MAINWINDOW.XAML
<Grid> <StackPanel> <TextBox x:Name="login"></TextBox> <PasswordBox x:Name="password"></PasswordBox> <StackPanel> <Button Height="20 " Click="Button_Click_1"> Авторизироваться</Button> <Button Height="20" Click="Button_Click" Content="Войти как гость"/> </StackPanel> </StackPanel> </Grid>
MAINWINDOW.XAML.CS
public partial class MainWindow : Window { ShoeStoreContext db = new ShoeStoreContext(); Window productWindow; public MainWindow() { InitializeComponent(); }
private void Button_Click(object sender, RoutedEventArgs e)
{
productWindow = new ProductWindow(null);
productWindow.Show();
this.Close();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
var user = db.Users.FirstOrDefault(u => u.FirstName == login.Text && u.LastName == password.Password);
if (user != null)
{
productWindow = new ProductWindow(user);
productWindow.Show();
this.Close();
}
else
{
MessageBox.Show("ошибка");
}
}
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ PRODUCTCONTROL.XAML \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
<Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="10">
<TextBox x:Name="txtsearch" Margin="5" Height="30"/>
<ComboBox x:Name="cmbsort" Margin="5" Height="30">
<ComboBoxItem Content="по имени вверх"/>
<ComboBoxItem Content="по имени вниз"/>
</ComboBox>
<TextBlock x:Name="txtuser" Margin="5"/>
<Button Height="40" Margin="5" Content="Выход" Click="Button_Click"/>
</StackPanel>
<ScrollViewer Grid.Row="1">
<ItemsControl x:Name="productsControl">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Background="LightGray" BorderBrush="Gray"
BorderThickness="1" Margin="10" Padding="10" CornerRadius="10">
<StackPanel Orientation="Horizontal">
<Image Width="129" Height="100" Stretch="UniformToFill"
Source="C:\Users\rqiza\source\repos\last_test_demo\last_test_demo\picture.png"
Margin="0,0,10,0"/>
<StackPanel VerticalAlignment="Center">
<TextBlock Text="{Binding Name}" FontSize="16" FontWeight="Bold"/>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Цена: "/>
<TextBlock Text="{Binding Price}" Foreground="Red"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Артикул: "/>
<TextBlock Text="{Binding Article}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
<Button Content="Редактировать" Click="EditProduct_Click"
Background="LightBlue" Width="100" Margin="0,0,5,0"/>
<Button Content="Удалить" Click="DeleteProduct_Click"
Background="LightCoral" Width="100"/>
</StackPanel>
</StackPanel>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsSource d:IsDesignTimeCreatable="True">
<x:Array Type="{x:Type models:Product}">
<models:Product Name="Nike Air Max" Price="8999" Article="NK-001"/>
</x:Array>
</ItemsControl.ItemsSource>
</ItemsControl>
</ScrollViewer>
</Grid>
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ PRODUCTCONTROL.XAML.CS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
public partial class ProductControl : UserControl { ShoeStoreContext db = new ShoeStoreContext();
public ProductControl(User user)
{
InitializeComponent();
txtuser.Text = user == null ? "Гость" : $"{user.FirstName}:{user.LastName}";
cmbsort.SelectedIndex = 0;
LoadProducts();
txtsearch.TextChanged += txtsearch_TextChanged;
cmbsort.SelectionChanged += cmbsort_SelectionChanged;
}
void LoadProducts()
{
var q = db.Products.AsQueryable();
if (txtsearch.Text != "") q = q.Where(p => p.Name.Contains(txtsearch.Text));
if (cmbsort.SelectedIndex == 0) q = q.OrderBy(p => p.Name);
if (cmbsort.SelectedIndex == 1) q = q.OrderByDescending(p => p.Name);
productsControl.ItemsSource = q.ToList();
}
void txtsearch_TextChanged(object s, TextChangedEventArgs e) => LoadProducts();
void cmbsort_SelectionChanged(object s, SelectionChangedEventArgs e) => LoadProducts();
void Button_Click(object s, RoutedEventArgs e) { new MainWindow().Show(); Window.GetWindow(this).Close(); }
// РЕДАКТИРОВАНИЕ
void EditProduct_Click(object s, RoutedEventArgs e)
{
var product = (Product)((Button)s).DataContext;
var editWindow = new EditProductWindow(product, db);
editWindow.ShowDialog();
LoadProducts();
}
// УДАЛЕНИЕ
void DeleteProduct_Click(object s, RoutedEventArgs e)
{
var product = (Product)((Button)s).DataContext;
if (MessageBox.Show($"Удалить товар {product.Name}?", "Подтверждение",
MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
{
db.Products.Remove(product);
db.SaveChanges();
LoadProducts();
MessageBox.Show("Удалено!");
}
}
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ PRODUCTWINDOW.XAML.CS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
public partial class ProductWindow : Window { public ProductWindow(User user) { InitializeComponent(); var control = new ProductControl(user); Content = control; } }
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ EDITPRODUCTWINDOW.XAML \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
<Grid Margin="10"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Название:" Margin="5"/>
<TextBox x:Name="txtName" Grid.Row="1" Margin="5"/>
<TextBlock Grid.Row="2" Text="Цена:" Margin="5"/>
<TextBox x:Name="txtPrice" Grid.Row="3" Margin="5"/>
<TextBlock Grid.Row="4" Text="Артикул:" Margin="5"/>
<TextBox x:Name="txtArticle" Grid.Row="5" Margin="5"/>
<StackPanel Grid.Row="6" Orientation="Horizontal" HorizontalAlignment="Right" Margin="5">
<Button x:Name="btnSave" Content="Сохранить" Width="80" Margin="5" Click="btnSave_Click"/>
<Button x:Name="btnCancel" Content="Отмена" Width="80" Margin="5" Click="btnCancel_Click"/>
</StackPanel>
</Grid>
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ EDITPRODUCTWINDOW.XAML.CS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
public partial class EditProductWindow : Window { Product product; ShoeStoreContext db;
public EditProductWindow(Product prod, ShoeStoreContext context)
{
InitializeComponent();
db = context;
product = prod;
txtName.Text = product.Name;
txtPrice.Text = product.Price.ToString();
txtArticle.Text = product.Article;
}
void btnSave_Click(object s, RoutedEventArgs e)
{
try
{
product.Name = txtName.Text;
product.Price = decimal.Parse(txtPrice.Text);
product.Article = txtArticle.Text;
db.SaveChanges();
MessageBox.Show("Сохранено!");
this.Close();
}
catch (Exception ex)
{
MessageBox.Show("Ошибка: " + ex.Message);
}
}
void btnCancel_Click(object s, RoutedEventArgs e) => this.Close();
}
| 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. |
-
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 | 153 | 4/17/2026 |