Yoko _ toru 1 year ago
commit
d0eee9ecff
2 changed files with 1039 additions and 0 deletions
  1. 615 0
      Test.txt
  2. 424 0
      Test1.txt

+ 615 - 0
Test.txt

@@ -0,0 +1,615 @@
+!!!!!!!!!!!!!!!MainWindow.xaml
+
+<Window x:Class="Tren.MainWindow"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        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"
+        xmlns:local="clr-namespace:Tren"
+        mc:Ignorable="d"
+        Title="Название приложения" Height="700" Width="1000" MinHeight="450" MinWidth="800">
+    <Grid>
+        <Frame x:Name="MainFrame" NavigationUIVisibility="Hidden"/>
+    </Grid>
+</Window>
+
+
+!!!!!!!!!!!!!!!MainWindow.cs
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using Tren.Pages;
+
+namespace Tren
+{
+    /// <summary>
+    /// Логика взаимодействия для MainWindow.xaml
+    /// </summary>
+    public partial class MainWindow : Window
+    {
+        public MainWindow()
+        {
+            InitializeComponent();
+            Manager.frame = MainFrame;
+            Manager.frame.Navigate(new MainPage());
+        }
+    }
+}
+
+!!!!!!!!!!!!!!!Manager.cs
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+
+namespace Tren
+{
+    internal class Manager
+    {
+        public static Frame frame {  get; set; }
+    }
+}
+
+
+!!!!!!!!!!!!!!!CurrentList.cs
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tren
+{
+    internal class CurrentList
+    {
+        public static List<Products> products;
+        public static TreningDemoEntities db = new TreningDemoEntities();
+        public static decimal? priceTotal = 0; // итоговая цена корзины
+        public static int discountTotal = 0; // итоговая скидка
+        public static List<Products> basketProducts = new List<Products>();
+    }
+}
+
+
+!!!!!!!!!!!!!!!App.xaml
+
+<Application x:Class="Tren.App"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:local="clr-namespace:Tren"
+             StartupUri="MainWindow.xaml">
+    <Application.Resources>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="Styles.xaml"/>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </Application.Resources>
+</Application>
+
+
+!!!!!!!!!!!!!!!BasketPage.xaml
+
+<Page x:Class="Tren.Pages.BasketPage"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:Tren.Pages"
+      mc:Ignorable="d" 
+      d:DesignHeight="700" d:DesignWidth="1000"
+      Title="BasketPage">
+
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="150"/>
+            <RowDefinition/>
+        </Grid.RowDefinitions>
+        <Grid>
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="100"/>
+                <ColumnDefinition Width="250"/>
+                <ColumnDefinition Width="200"/>
+                <ColumnDefinition/>
+            </Grid.ColumnDefinitions>
+            <Button x:Name="OrderButton" Grid.Column="1" Style="{DynamicResource ButtonStyleBase}" Content="Сформировать заказ" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="15" Click="OrderButton_Click" />
+            <Button x:Name="ClearButton" Grid.Column="2" Style="{DynamicResource ButtonStyleBase}" Content="Очистить корзину" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="15" Click="ClearButton_Click" />
+            <Button x:Name="BackButton" Grid.Column="0" Style="{DynamicResource ButtonStyleBase}" Content="Назад" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="15" Click="BackButton_Click" />
+
+            <Grid Grid.Row="0" Grid.Column="3" HorizontalAlignment="Right" Margin="10">
+                <Grid.RowDefinitions>
+                    <RowDefinition/>
+                    <RowDefinition/>
+                    <RowDefinition/>
+                </Grid.RowDefinitions>
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition/>
+                    <ColumnDefinition/>
+                </Grid.ColumnDefinitions>
+                <Label Content="Количество выбранных книг: " Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Column="0"/>
+                <TextBlock x:Name="CountOfSelected" Text="0" Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Column="1"/>
+                <Label Content="Стоимость покупки: " Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Column="0"/>
+                <TextBlock x:Name="Price" Text="0" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Column="1"/>
+                <Label Content="Размер скидки: " Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Column="0"/>
+                <TextBlock x:Name="Discount" Text="0" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Column="1"/>
+            </Grid>
+        </Grid>
+        <ListView Grid.Row="1" x:Name="BasketList">
+            <ListView.ItemTemplate>
+                <DataTemplate>
+                    <Border 
+                        BorderThickness="1"
+                        BorderBrush="Black">
+                        <Grid HorizontalAlignment="Stretch" >
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition Width="170"/>
+                                <ColumnDefinition Width="650"/>
+                                <ColumnDefinition Width="150"/>
+                            </Grid.ColumnDefinitions>
+                            <Grid.RowDefinitions>
+                                <RowDefinition/>
+                            </Grid.RowDefinitions>
+                            <Image Stretch="Uniform"  HorizontalAlignment="Center" Margin="10">
+                                <Image.Source>
+                                    <Binding Path="Photo">
+                                        <Binding.TargetNullValue>
+                                            <ImageSource>/Images/NoPhoto.jpg</ImageSource>
+                                        </Binding.TargetNullValue>
+                                    </Binding>
+                                </Image.Source>
+                            </Image>
+                            <Grid Grid.Column="1" Margin="5">
+                                <Grid.RowDefinitions>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                </Grid.RowDefinitions>
+                                <TextBlock
+                                Text="{Binding ProductName,StringFormat= {}Название: {0:N2}}"
+                                Grid.Row="0"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock 
+                                Grid.Row="1"
+                                Text="{Binding ProductDescription,StringFormat= {}Описание товара: {0:N2}}"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock
+                                Text="{Binding Manufacturers.Name,StringFormat= {}Производитель: {0:N2}}"
+                                Grid.Row="2"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock
+                                Grid.Row="3"
+                                Text="{Binding Price, StringFormat= {}Цена: {0:N2} руб. }"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock 
+                                Grid.Row="4"
+                                Text="{Binding CountInShop,StringFormat= {}Количество в магазине: {0:N0} }"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock
+                                Grid.Row="5"
+                                Text="{Binding CountInStock, StringFormat= {}Количество на складе: {0:N0}}"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock
+                                Grid.Row="6"
+                                Text="{Binding Description, StringFormat= {}Описание: {0:N0}}"
+                                FontFamily="Bahnschrift"
+                                TextWrapping="Wrap"
+                                FontSize="20"/>
+                            </Grid>
+                            <Button x:Name="DeleteButton" Grid.Column="2" Content="Удалить" Style="{DynamicResource ButtonStyleBase}" Click="DeleteButton_Click"/>
+                        </Grid>
+                    </Border>
+                </DataTemplate>
+            </ListView.ItemTemplate>
+        </ListView>
+    </Grid>
+</Page>
+
+!!!!!!!!!!!!!!!BasketPage.cs
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Tren.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для BasketPage.xaml
+    /// </summary>
+    public partial class BasketPage : Page
+    {
+        decimal? help;
+
+        public BasketPage()
+        {
+            InitializeComponent();
+
+            BasketList.ItemsSource = CurrentList.basketProducts;
+            CountOfSelected.Text = (CurrentList.basketProducts.Count).ToString();
+            CurrentList.priceTotal = 0;
+            CurrentList.discountTotal = 0;
+            foreach (Products item in CurrentList.basketProducts)
+            {
+                CurrentList.priceTotal += item.Price;
+            }
+            help = CurrentList.priceTotal;
+            while (help > 0)
+            {
+                help -= 500;
+                CurrentList.discountTotal += 1;
+            }
+            CurrentList.discountTotal -= 1;
+            if (CurrentList.basketProducts.Count >= 3 && CurrentList.basketProducts.Count < 5)
+            {
+                CurrentList.discountTotal += 5;
+
+            }
+            Price.Text = CurrentList.priceTotal.ToString();
+            Discount.Text = CurrentList.discountTotal.ToString();
+        }
+
+        private void ClearButton_Click(object sender, RoutedEventArgs e)
+        {
+            BasketList.ItemsSource = null;
+            CurrentList.basketProducts.Clear();
+            CountOfSelected.Text = (CurrentList.basketProducts.Count).ToString();
+            CurrentList.priceTotal = 0;
+            CurrentList.discountTotal = 0;
+            foreach (Products item in CurrentList.basketProducts)
+            {
+                CurrentList.priceTotal += item.Price;
+            }
+            help = CurrentList.priceTotal;
+            while (help > 0)
+            {
+                help -= 500;
+                CurrentList.discountTotal += 1;
+            }
+            CurrentList.discountTotal -= 1;
+            if (CurrentList.basketProducts.Count >= 3 && CurrentList.basketProducts.Count < 5)
+            {
+                CurrentList.discountTotal += 5;
+
+            }
+            Price.Text = CurrentList.priceTotal.ToString();
+            Discount.Text = CurrentList.discountTotal.ToString();
+        }
+
+        private void OrderButton_Click(object sender, RoutedEventArgs e)
+        {
+            
+        }
+
+        private void BackButton_Click(object sender, RoutedEventArgs e)
+        {
+            Manager.frame.Navigate(new MainPage());
+        }
+
+        private void DeleteButton_Click(object sender, RoutedEventArgs e)
+        {
+            Products result = (sender as Button)?.DataContext as Products; // получение объекта, который нужно добавить
+            CurrentList.basketProducts.Remove(result); // добавляем элемент в лист корзины
+            BasketList.ItemsSource = null;
+            BasketList.ItemsSource = CurrentList.basketProducts;
+            CountOfSelected.Text = (CurrentList.basketProducts.Count).ToString();
+            CurrentList.priceTotal = 0;
+            CurrentList.discountTotal = 0;
+            foreach (Products item in CurrentList.basketProducts)
+            {
+                CurrentList.priceTotal += item.Price;
+            }
+            help = CurrentList.priceTotal;
+            while (help > 0)
+            {
+                help -= 500;
+                CurrentList.discountTotal += 1;
+            }
+            CurrentList.discountTotal -= 1;
+            if (CurrentList.basketProducts.Count >= 3 && CurrentList.basketProducts.Count < 5)
+            {
+                CurrentList.discountTotal += 5;
+
+            }
+            Price.Text = CurrentList.priceTotal.ToString();
+            Discount.Text = CurrentList.discountTotal.ToString();
+        }
+    }
+}
+
+!!!!!!!!!!!!!!!!!!MainPage.xaml
+
+<Page x:Class="Tren.Pages.MainPage"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:Tren.Pages"
+      mc:Ignorable="d" 
+      d:DesignHeight="700" d:DesignWidth="1000"
+      Title="MainPage">
+
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="150"/>
+            <RowDefinition/>
+        </Grid.RowDefinitions>
+        <Grid>
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="350"/>
+                <ColumnDefinition/>
+            </Grid.ColumnDefinitions>
+            <Button x:Name="BasketButton" Style="{DynamicResource ButtonStyleBase}" Content="Корзина" FontSize="35" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="15" Click="Button_Click" Visibility="Hidden"/>
+            <Grid Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" Margin="10">
+                <Grid.RowDefinitions>
+                    <RowDefinition/>
+                    <RowDefinition/>
+                    <RowDefinition/>
+                </Grid.RowDefinitions>
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition/>
+                    <ColumnDefinition/>
+                </Grid.ColumnDefinitions>
+                <Label Content="Количество выбранных книг: " Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Column="0"/>
+                <TextBlock x:Name="CountOfSelected" Text="100" Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Column="1"/>
+                <Label Content="Стоимость покупки: " Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Column="0"/>
+                <TextBlock x:Name="Price" Text="100" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Column="1"/>
+                <Label Content="Размер скидки: " Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Column="0"/>
+                <TextBlock x:Name="Discount" Text="100" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Column="1"/>
+            </Grid>
+        </Grid>
+        <ListView Grid.Row="1" x:Name="MainList">
+            <ListView.ItemTemplate >
+                <DataTemplate>
+                    <Border 
+                        BorderThickness="1"
+                        BorderBrush="Black">
+                        <Grid HorizontalAlignment="Stretch" >
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition Width="170"/>
+                                <ColumnDefinition Width="800"/>
+                            </Grid.ColumnDefinitions>
+                            <Grid.RowDefinitions>
+                                <RowDefinition/>
+                            </Grid.RowDefinitions>
+                            <Image Stretch="Uniform"  HorizontalAlignment="Center" Margin="10">
+                                <Image.Source>
+                                    <Binding Path="Photo">
+                                        <Binding.TargetNullValue>
+                                            <ImageSource>/Images/NoPhoto.jpg</ImageSource>
+                                        </Binding.TargetNullValue>
+                                    </Binding>
+                                </Image.Source>
+                            </Image>
+                            <Grid Grid.Column="1" Margin="5">
+                                <Grid.RowDefinitions>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                </Grid.RowDefinitions>
+                                <TextBlock
+                                Text="{Binding ProductName,StringFormat= {}Название: {0:N2}}"
+                                Grid.Row="0"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock 
+                                Grid.Row="1"
+                                Text="{Binding ProductDescription,StringFormat= {}Описание товара: {0:N2}}"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock
+                                Text="{Binding Manufacturers.Name,StringFormat= {}Производитель: {0:N2}}"
+                                Grid.Row="2"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock
+                                Grid.Row="3"
+                                Text="{Binding Price, StringFormat= {}Цена: {0:N2} руб. }"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock 
+                                Grid.Row="4"
+                                Text="{Binding CountInShop,StringFormat= {}Количество в магазине: {0:N0} }"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock
+                                Grid.Row="5"
+                                Text="{Binding CountInStock, StringFormat= {}Количество на складе: {0:N0}}"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock
+                                Grid.Row="6"
+                                Text="{Binding Description, StringFormat= {}Описание: {0:N0}}"
+                                FontFamily="Bahnschrift"
+                                TextWrapping="Wrap"
+                                FontSize="20"/>
+                            </Grid>
+                        </Grid>
+                    </Border>
+                </DataTemplate>
+            </ListView.ItemTemplate>
+            <ListView.ContextMenu>
+                <ContextMenu>
+                    <MenuItem Header="Добавить к заказу" Click="MenuItem_Click" ></MenuItem>
+                </ContextMenu>
+            </ListView.ContextMenu>
+        </ListView>
+    </Grid>
+</Page>
+
+
+!!!!!!!!!!!!!!!!!!!MainPage.cs
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Tren.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для MainPage.xaml
+    /// </summary>
+    public partial class MainPage : Page
+    {
+        
+        public MainPage()
+        {
+            InitializeComponent();
+            CurrentList.products = CurrentList.db.Products
+                .ToList();
+            MainList.ItemsSource = CurrentList.products;
+            if (CurrentList.basketProducts.Count != 0)
+            {
+                BasketButton.Visibility = Visibility.Visible;
+                CurrentList.priceTotal = 0;
+                CurrentList.discountTotal = 0;
+                CountOfSelected.Text = (CurrentList.basketProducts.Count).ToString();
+                foreach (Products item in CurrentList.basketProducts)
+                { 
+                    CurrentList.priceTotal += item.Price;
+                }
+                help = CurrentList.priceTotal;
+                while (help > 0)
+                {
+                    help -= 500;
+                    CurrentList.discountTotal += 1;
+                }
+                CurrentList.discountTotal -= 1;
+                if (CurrentList.basketProducts.Count >= 3 && CurrentList.basketProducts.Count < 5)
+                {
+                    CurrentList.discountTotal += 5;
+
+                }
+                Price.Text = CurrentList.priceTotal.ToString();
+                Discount.Text = CurrentList.discountTotal.ToString();
+            }
+        }
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            Manager.frame.Navigate(new BasketPage());
+        }
+        decimal? help;
+
+        private void MenuItem_Click(object sender, RoutedEventArgs e)
+        {
+            BasketButton.Visibility = Visibility.Visible;
+            CurrentList.basketProducts.Add(MainList.SelectedValue as Products);
+            Products product = MainList.SelectedValue as Products;
+            CountOfSelected.Text = (CurrentList.basketProducts.Count).ToString();
+            CurrentList.priceTotal += product.Price;
+            help = CurrentList.priceTotal;
+            while (help > 0)
+            {
+                help -= 500;
+                CurrentList.discountTotal += 1;
+            }
+            CurrentList.discountTotal -= 1;
+            if (CurrentList.basketProducts.Count >= 3 && CurrentList.basketProducts.Count < 5)
+            {
+                CurrentList.discountTotal += 5;
+
+            }
+            Price.Text = CurrentList.priceTotal.ToString();
+            Discount.Text = CurrentList.discountTotal.ToString();
+        }
+    }
+}
+
+!!!!!!!!!!!!!!! Model1.Context.cs что нужно чтобы работала база
+
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код создан по шаблону.
+//
+//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
+//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Tren
+{
+    using System;
+    using System.Data.Entity;
+    using System.Data.Entity.Infrastructure;
+    
+    public partial class TreningDemoEntities : DbContext
+    {
+        public TreningDemoEntities()
+            : base("name=TreningDemoEntities")
+        {
+        }
+
+        private static TreningDemoEntities _instance;
+        public static TreningDemoEntities GetContext()
+        {
+            if (_instance == null)
+                _instance = new TreningDemoEntities();
+            return _instance;
+        }
+        protected override void OnModelCreating(DbModelBuilder modelBuilder)
+        {
+            throw new UnintentionalCodeFirstException();
+        }
+    
+        public virtual DbSet<Manufacturers> Manufacturers { get; set; }
+        public virtual DbSet<Orders> Orders { get; set; }
+        public virtual DbSet<Points> Points { get; set; }
+        public virtual DbSet<ProductOrders> ProductOrders { get; set; }
+        public virtual DbSet<Products> Products { get; set; }
+        public virtual DbSet<Statuses> Statuses { get; set; }
+        public virtual DbSet<sysdiagrams> sysdiagrams { get; set; }
+    }
+}
+
+

+ 424 - 0
Test1.txt

@@ -0,0 +1,424 @@
+!!!!!!!!!!! Model1.Context.cs
+
+private static TreningDemoEntities _instance;
+
+        public static TreningDemoEntities GetContext()
+        {
+            if (_instance == null)
+                _instance = new TreningDemoEntities();
+            return _instance;
+        }
+
+!!!!!!!!!!!!! Создание листа с контектом 
+
+<ListView Grid.Row="1" x:Name="MainList">
+            <ListView.ItemTemplate >
+                <DataTemplate>
+                    <Border 
+                        BorderThickness="1"
+                        BorderBrush="Black">
+                        <Grid HorizontalAlignment="Stretch" >
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition Width="170"/>
+                                <ColumnDefinition Width="800"/>
+                            </Grid.ColumnDefinitions>
+                            <Grid.RowDefinitions>
+                                <RowDefinition/>
+                            </Grid.RowDefinitions>
+                            <Image Stretch="Uniform"  HorizontalAlignment="Center" Margin="10">
+                                <Image.Source>
+                                    <Binding Path="Photo">
+                                        <Binding.TargetNullValue>
+                                            <ImageSource>/Images/NoPhoto.jpg</ImageSource>
+                                        </Binding.TargetNullValue>
+                                    </Binding>
+                                </Image.Source>
+                            </Image>
+                            <Grid Grid.Column="1" Margin="5">
+                                <Grid.RowDefinitions>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                    <RowDefinition/>
+                                </Grid.RowDefinitions>
+                                <TextBlock
+                                Text="{Binding ProductName,StringFormat= {}Название: {0:N2}}"
+                                Grid.Row="0"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock 
+                                Grid.Row="1"
+                                Text="{Binding ProductDescription,StringFormat= {}Описание товара: {0:N2}}"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock
+                                Text="{Binding Manufacturers.Name,StringFormat= {}Производитель: {0:N2}}"
+                                Grid.Row="2"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock
+                                Grid.Row="3"
+                                Text="{Binding Price, StringFormat= {}Цена: {0:N2} руб. }"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock 
+                                Grid.Row="4"
+                                Text="{Binding CountInShop,StringFormat= {}Количество в магазине: {0:N0} }"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock
+                                Grid.Row="5"
+                                Text="{Binding CountInStock, StringFormat= {}Количество на складе: {0:N0}}"
+                                FontFamily="Bahnschrift"
+                                FontSize="20"/>
+                                <TextBlock
+                                Grid.Row="6"
+                                Text="{Binding Description, StringFormat= {}Описание: {0:N0}}"
+                                FontFamily="Bahnschrift"
+                                TextWrapping="Wrap"
+                                FontSize="20"/>
+                            </Grid>
+                        </Grid>
+                    </Border>
+                </DataTemplate>
+            </ListView.ItemTemplate>
+            <ListView.ContextMenu>
+                <ContextMenu>
+                    <MenuItem Header="Добавить к заказу" Click="MenuItem_Click" ></MenuItem>
+                </ContextMenu>
+            </ListView.ContextMenu>
+        </ListView>
+
+!!!!!!!!!!!! CurrentList.cs
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tren
+{
+    internal class CurrentList
+    {
+        public static List<Products> products;
+        public static TreningDemoEntities db = new TreningDemoEntities();
+        public static decimal? priceTotal = 0; // итоговая цена корзины
+        public static int discountTotal = 0; // итоговая скидка
+        public static List<Products> basketProducts = new List<Products>();
+    }
+}
+
+!!!!!!!!!!!!!!!!!!!!!!!! MainWindow.cs
+
+Manager.frame = MainFrame;
+            Manager.frame.Navigate(new MainPage());
+
+!!!!!!!!!!!!!!!!!!!!!!!!! MainWindow.xaml
+
+        <Frame x:Name="MainFrame" NavigationUIVisibility="Hidden"/>
+
+!!!!!!!!!!!!!!!!!!!!!!!!! App.xaml 
+
+<Application x:Class="Tren.App"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:local="clr-namespace:Tren"
+             StartupUri="MainWindow.xaml">
+    <Application.Resources>
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="Styles.xaml"/>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
+    </Application.Resources>
+</Application>
+
+!!!!!!!!!!!!!!!!!!!!!!! Получение элемента листа по кнопке
+Products result = (sender as Button)?.DataContext as Products; // получение объекта, который нужно добавить
+            CurrentList.basketProducts.Remove(result); // добавляем элемент в лист корзины
+
+!!!!!!!!!!!!!!!!!!!!!!!! Никита ПДФ И ФОРМИРОВАНИЕ ЗАКАЗА
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.Eventing.Reader;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using PdfSharp.Pdf;
+using PdfSharp;
+using PdfSharp.Drawing;
+using PdfSharp.Pdf.IO;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using Microsoft.Win32;
+using System.Diagnostics;
+
+namespace WriteReadProjectDemo
+{
+    /// <summary>
+    /// Логика взаимодействия для Window1.xaml
+    /// </summary>
+    public partial class Window1 : Window
+    {
+        List<Product> products = new List<Product>();
+        List<Article> articles = new List<Article>();
+
+        User user;
+
+        public Window1(User user)
+        {
+            InitializeComponent();
+            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
+            this.user = user;
+          
+            cmbOrderPoint.ItemsSource = db.tbe.Point.ToList();
+            cmbOrderPoint.SelectedValuePath = "idPickupPoint";
+            cmbOrderPoint.DisplayMemberPath = "displayPoint";
+            cmbOrderPoint.SelectedIndex = 0;
+            foreach (Product product in db.tbe.Product.ToList())
+            {
+
+                foreach (string item in PageProducts.articleProducts)
+                {
+
+                    if (product.ProductArticleNumber == item)
+                    {
+
+                        products.Add(product);
+                        Article article = new Article()
+                        {
+                            article = product.ProductArticleNumber,
+                            count = 1,
+
+                        };
+                        articles.Add(article);
+
+                    }
+                }
+            }
+            lvOrder.ItemsSource = products;
+            lvOrder.SelectedValuePath = "ProductArticleNumber";
+            summOrder();
+        }
+        private void summOrder() // вывод суммы заказа
+        {
+
+            double sum = 0;
+            double summWithDiscount = 0;
+            foreach (var item in articles)
+            {
+                sum += Convert.ToDouble(db.tbe.Product.FirstOrDefault(x => x.ProductArticleNumber == item.article).ProductCost * item.count);
+                summWithDiscount += Convert.ToDouble(((db.tbe.Product.FirstOrDefault(x => x.ProductArticleNumber == item.article).ProductCost - db.tbe.Product.FirstOrDefault(x => x.ProductArticleNumber == item.article).ProductCost / 100 * db.tbe.Product.FirstOrDefault(x => x.ProductArticleNumber == item.article).ProductDiscountAmount)) * item.count);
+            }
+            tbSaleZakaza.Text = "Общая скидка " + Convert.ToInt32((sum - summWithDiscount)).ToString() + "руб.";
+            tbSummaZakaza.Text = "Итоговая цена " + Convert.ToInt32(Math.Round(summWithDiscount)).ToString() + "руб.";
+            orderSummaSale = Convert.ToInt32((sum - summWithDiscount)).ToString() + "руб.";
+            orderSumma = Convert.ToInt32(Math.Round(summWithDiscount)).ToString() + "руб.";
+
+        }
+
+        public static string ordedDate;
+        public static int orderID;
+        public static string orderSostav;
+        public static string orderSumma;
+        public static string orderSummaSale;
+        public static string orderPoint;
+
+        private void btnFormOrder_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                Random random = new Random();
+                int codeRND = random.Next(100, 999);
+                Order order = new Order();
+                order.OrderID = db.tbe.Order.Max(x => x.OrderID) + 1;
+                order.OrderStatus = 1;
+                order.OrderPickupPoint = (int)cmbOrderPoint.SelectedValue;
+                if (user != null)
+                {
+                    order.OrderClientsId = user.UserID;
+                }
+                else
+                {
+                   
+                }
+
+                order.Code = codeRND;
+                order.OrderDate = DateTime.Now;
+
+                foreach (Product item in products)
+                {
+                    if (item.ProductQuantityInStock < 3 || item.ProductQuantityInStock == 0)
+                    {
+                        order.OrderDeliveryDate = DateTime.Now.AddDays(6);
+                    }
+                    else
+                    {
+                        order.OrderDeliveryDate = DateTime.Now.AddDays(3);
+                    }
+                }
+
+
+                db.tbe.Order.Add(order);
+                db.tbe.SaveChanges();
+                string orderPoint = cmbOrderPoint.Text;
+                int orderID = order.OrderID;
+                // формирование для смежной таблицы
+                foreach (var item in articles)
+                {
+                    OrderProduct orderProduct = new OrderProduct();
+                    orderProduct.OrderID = order.OrderID;
+                    orderProduct.ProductArticleNumber = item.article;
+                    orderProduct.Count = item.count;
+                    db.tbe.OrderProduct.Add(orderProduct);
+                }
+                string ordedDate = order.OrderDeliveryDate.ToString();
+                db.tbe.SaveChanges();
+
+                PageProducts.articleProducts.Clear();
+                var ok = MessageBox.Show("Ваш заказ сформирован. Вам доступен талон для получения заказа. ", "Системное сообщение", MessageBoxButton.OK, MessageBoxImage.Information);
+
+
+                // формирование состава заказа
+                string nameOrderProduct = "";
+                List<OrderProduct> orderProductSostav = db.tbe.OrderProduct.Where(x => x.OrderID == order.OrderID).ToList();
+                foreach (var item in orderProductSostav)
+                {
+
+                    Product product1 = db.tbe.Product.FirstOrDefault(x => x.ProductArticleNumber == item.ProductArticleNumber);
+
+                    nameOrderProduct += product1.ProductName + $"({item.Count} шт.) ";
+
+
+                }
+
+
+
+                if (ok == MessageBoxResult.OK)
+                {
+                    pdfSharp(codeRND, ordedDate, nameOrderProduct, orderPoint, orderID, orderSumma, orderSummaSale);
+                    this.Close();
+                }
+
+
+
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+            }
+
+        }
+
+        private void pdfSharp(int codeRND, string ordedDate, string nameOrderProduct, string orderPoint, int orderID, string orderSumma, string orderSummaSale) // формирование пдф
+        {
+
+            SaveFileDialog sfd = new SaveFileDialog();
+            sfd.Filter = "PDF files(*.pdf)|*.pdf|All files(*.*)|*.*";
+
+            if (sfd.ShowDialog() == true)
+            {
+
+                // string txt = "Код для получения заказа: " + codeRND.ToString() + "\n" + "Дата заказа: \t" + ordedDate.ToString();
+                PdfDocument pdf = new PdfDocument();
+                pdf.Info.Title = "Талон для получения заказа";
+                PdfPage pdfPage = pdf.AddPage();
+                XGraphics gfx = XGraphics.FromPdfPage(pdfPage);
+                XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
+                XFont font = new XFont("Comic Sans MS", 20);
+                XFont fontCode = new XFont("Comic Sans MS", 20, XFontStyle.Bold, options);
+
+                string fileText = "Формирование талона получения для заказа " + orderID.ToString();
+                gfx.DrawString("Дата заказа: " + ordedDate.ToString(), font, XBrushes.Black, new XRect(0, -355, pdfPage.Width, pdfPage.Height), XStringFormat.Center);
+                gfx.DrawString("Номер заказа: " + orderID.ToString(), font, XBrushes.Black, new XRect(0, -320, pdfPage.Width, pdfPage.Height), XStringFormat.Center);
+                gfx.DrawString("Состав заказа: " + nameOrderProduct.ToString(), font, XBrushes.Black, new XRect(0, -300, pdfPage.Width, pdfPage.Height), XStringFormat.Center);
+                gfx.DrawString("Сумма заказа: " + orderSumma.ToString(), font, XBrushes.Black, new XRect(0, -255, pdfPage.Width, pdfPage.Height), XStringFormat.Center);
+                gfx.DrawString("Сумма скидки: " + orderSummaSale.ToString(), font, XBrushes.Black, new XRect(0, -200, pdfPage.Width, pdfPage.Height), XStringFormat.Center);
+                gfx.DrawString("Пункт выдачи: " + orderPoint.ToString(), font, XBrushes.Black, new XRect(0, -155, pdfPage.Width, pdfPage.Height), XStringFormat.Center);
+                gfx.DrawString("Ваш код для получения заказа " + codeRND.ToString(), fontCode, XBrushes.Black, new XRect(0, -100, pdfPage.Width, pdfPage.Height), XStringFormat.Center);
+                sfd.FileName = fileText;
+                MessageBox.Show("Ваш заказ сформирован. Вам доступен талон для получения заказа. ", "Системное сообщение", MessageBoxButton.OK, MessageBoxImage.Information);
+                string filename = "TicketPDF.pdf";
+                pdf.Save(filename);
+                Process.Start(filename);
+
+
+            }
+        }
+
+
+        private void deleteMethod(string id) // метод удаления из списка добавленных
+        { 
+
+            PageProducts.articleProducts.Remove(id);
+            if (PageProducts.articleProducts.Count == 0)
+            {
+                this.Close();
+            }
+            else
+            {
+                products.Clear();
+                foreach (Product product in db.tbe.Product.ToList())
+                {
+
+                    foreach (string item in PageProducts.articleProducts)
+                    {
+
+                        if (product.ProductArticleNumber == item)
+                        {
+
+                            products.Add(product);
+                            Article article = new Article()
+                            {
+                                article = product.ProductArticleNumber,
+                                count = 1,
+
+                            };
+                            articles.Add(article);
+                            MessageBox.Show(article.article);
+                        }
+                    }
+                }
+                lvOrder.Items.Refresh();
+                lvOrder.ItemsSource = products;
+                lvOrder.SelectedValuePath = "ProductArticleNumber";
+                lvOrder.Items.Refresh();
+                summOrder();
+            }
+        }
+        private void btnDelete_Click(object sender, RoutedEventArgs e)
+        {
+
+            Button button = (Button)sender;
+            string id = button.Uid;
+            deleteMethod(id);
+        }
+
+        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            TextBox textBox = (TextBox)sender;
+            string id = textBox.Uid;
+            articles.FirstOrDefault(x => x.article == id).count = Convert.ToInt32(textBox.Text);
+            if (!string.IsNullOrEmpty(textBox.Text))
+            {
+                summOrder();
+            }
+            if (textBox.Text.Equals("0"))
+            {
+                deleteMethod(id);
+            }
+
+        }
+    }
+}