user228 há 1 ano atrás
commit
854801b275
4 ficheiros alterados com 3707 adições e 0 exclusões
  1. 770 0
      alex/hash-0d9KD93k12Ll32Ii3202.txt
  2. 898 0
      nick/deemo.txt
  3. 2039 0
      nick/Весь пиши стирай.txt
  4. 0 0
      readme.md

+ 770 - 0
alex/hash-0d9KD93k12Ll32Ii3202.txt

@@ -0,0 +1,770 @@
+/////////////// ОБЩЕЕ //////////////
+
+    internal class BaseClass
+    {
+
+        public static CookersShopEntities BD;
+    }
+
+    internal class FrameClass
+    {
+        public static Frame MainFrame;
+        public static string loginAutorizate;
+    }
+
+        public MainWindow()
+        {
+            InitializeComponent();
+            BaseClass.BD = new CookersShopEntities();
+            FrameClass.MainFrame = fMain;
+            FrameClass.MainFrame.Navigate(new MainPage());
+        }
+
+    <Grid>
+        <Grid.RowDefinitions>
+            
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+ <Frame Grid.Row="0" Name="fMain" NavigationUIVisibility="Hidden"></Frame>
+    </Grid>
+
+
+
+/////////// AUTORIZATE ///////////////
+
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="40"></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+        <Button Grid.Row="0" Style="{DynamicResource MainButtonStyle}" Margin="0,0,20,0" VerticalAlignment="Top" HorizontalAlignment="Right" Content="Вернуться на главную" FontSize="12" FontFamily="Roboto" FontWeight="DemiBold" Click="Button_Click" Padding="2"></Button>
+        <StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0 -40 0 0">
+            <TextBlock FontSize="48" FontFamily="Roboto" HorizontalAlignment="Center" VerticalAlignment="Top" FontWeight="UltraBold">Авторизация</TextBlock>
+            <GroupBox Header="Введите логин" Width="270">
+                <TextBox Name="tbLogin" MaxLength="25"></TextBox>
+            </GroupBox>
+            <GroupBox Header="Введите пароль" Width="270">
+                <PasswordBox Name="pbPassword" MaxLength="40"></PasswordBox>
+            </GroupBox>
+            <Button Style="{DynamicResource AcceptButtonStyle}" Margin="0,10,0,0" Padding="7 3 7 3" HorizontalAlignment="Center" VerticalAlignment="Center" Name="bRegistration" Content="Авторизоваться" Click="bRegistration_Click"></Button>
+        </StackPanel>
+    </Grid>
+
+
+ public AutoPage()
+        {
+            InitializeComponent();
+
+            //На случай сноса админского пароля
+            //Users searchUser = BaseClass.BD.Users.FirstOrDefault(x => x.login == "admin");
+            //var pass = "admin";
+            //searchUser.password = pass.GetHashCode();
+            //BaseClass.BD.SaveChanges();
+        }
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            FrameClass.MainFrame.Navigate(new MainPage());
+        }
+
+        private void bRegistration_Click(object sender, RoutedEventArgs e)
+        {
+            if (tbLogin.Text == "") MessageBox.Show("Заполните поле логина!", "", MessageBoxButton.OK, MessageBoxImage.Error); // Проверка на заполнение Логина
+            else if (pbPassword.Password == "") MessageBox.Show("Заполните поле логина!", "", MessageBoxButton.OK, MessageBoxImage.Error); // Проверка на заполнение Пароля
+            else
+            {
+                int pass = pbPassword.Password.GetHashCode();
+                Users searchUser = BaseClass.BD.Users.FirstOrDefault(x => x.login == tbLogin.Text); 
+                if (searchUser == null) MessageBox.Show("Такого пользователя не существует!", "", MessageBoxButton.OK, MessageBoxImage.Error);
+                else
+                {
+                    Users autoUser = BaseClass.BD.Users.FirstOrDefault(x => x.login == tbLogin.Text && x.password == pass);
+                    if (autoUser == null)
+                    {
+                        MessageBox.Show("Неправильно введён пароль!", "", MessageBoxButton.OK, MessageBoxImage.Error);
+                    }
+                    else
+                    {
+                        switch (autoUser.role)
+                        {
+                            // Обычный пользователь (0)
+                            case 0:
+                                FrameClass.loginAutorizate = tbLogin.Text;
+                                FrameClass.MainFrame.Navigate(new mainPageUsers());
+                                break;
+                            // Администратор (1)
+                            case 1:
+                                FrameClass.loginAutorizate = tbLogin.Text;
+                                FrameClass.MainFrame.Navigate(new AdminPanel());
+                                break;
+                            default: MessageBox.Show("Произошла неизвестная ошибка!\nПерезайдите в приложение!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); break;
+                        }
+                    }
+                }
+            }
+        }
+
+
+//////////// REGISTRATION CODE //////////////////
+
+
+private void bRegistration_Click(object sender, RoutedEventArgs e)
+        {
+            if (tbName.Text == "") MessageBox.Show("Заполните поле имени!", "", MessageBoxButton.OK, MessageBoxImage.Error);
+            else if (tbSurname.Text == "") MessageBox.Show("Заполните поле фамилии!", "", MessageBoxButton.OK, MessageBoxImage.Error);
+            else if (tbNumber.Text == "") MessageBox.Show("Заполните поле номера телефона!", "", MessageBoxButton.OK, MessageBoxImage.Error);
+            else if (tbLogin.Text == "") MessageBox.Show("Заполните поле логина!", "", MessageBoxButton.OK, MessageBoxImage.Error);
+            else if (pbPassword.Password == "") MessageBox.Show("Заполните поле пароля!", "", MessageBoxButton.OK, MessageBoxImage.Error);
+            else if (rbMan.IsChecked != true && rbWoman.IsChecked != true) MessageBox.Show("Убедитесь, что Вы выбрали пол!", "", MessageBoxButton.OK, MessageBoxImage.Error);
+            else if (tbNumber.Text.Length != 11) MessageBox.Show("Проверьте правильность введенного номера телефона!\nПримеры правильного формата:\n  • 79101426789\n  • 89101426789", "", MessageBoxButton.OK, MessageBoxImage.Error);
+            else
+            {
+                string checkPassword = pbPassword.Password;
+                Users searchUser = BaseClass.BD.Users.FirstOrDefault(x => x.login == tbLogin.Text);
+                if (searchUser != null) MessageBox.Show("Такой пользователь уже существует!", "", MessageBoxButton.OK, MessageBoxImage.Error);
+                else if (CheckPass(checkPassword) == false)
+                    MessageBox.Show("Ваш пароль очень простой!", "", MessageBoxButton.OK, MessageBoxImage.Error);
+                else
+                {
+                    int tempGender = 0;
+                    if (rbMan.IsChecked == true)
+                        tempGender = 1;
+                    if (rbWoman.IsChecked == true)
+                        tempGender = 2;
+                    Users user = new Users()
+                    {
+                        name_user = tbName.Text,
+                        surname_user = tbSurname.Text,
+                        gender = tempGender,
+                        login = tbLogin.Text,
+                        password = pbPassword.Password.GetHashCode(),
+                        phone = tbNumber.Text,
+                        date_reg = Convert.ToDateTime(DateTime.Today),
+                        role = 0,
+                        privilege = null
+                    };
+                    BaseClass.BD.Users.Add(user);
+                    BaseClass.BD.SaveChanges();
+                    MessageBox.Show("Вы зарегистрировались!");
+                    FrameClass.MainFrame.Navigate(new AutoPage());
+                }
+
+            }
+
+        }
+
+
+////////////// INPUT PRODUCT XAML ///////////////
+
+
+ <Page.Resources>
+        <BitmapImage x:Key="noimage" UriSource="/Resources/noimage.png"/>
+    </Page.Resources>
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="40"></RowDefinition>
+            <RowDefinition Height="370"></RowDefinition>
+            <RowDefinition Height="40"></RowDefinition>
+        </Grid.RowDefinitions>
+        <TextBlock Grid.Row="0" FontSize="28" HorizontalAlignment="Center" VerticalAlignment="Top" FontFamily="Roboto" FontWeight="Bold">Товар</TextBlock>
+        <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Right">
+            <Button x:Name="AddProduct" Style="{DynamicResource AcceptButtonStyle}" Grid.Row="0" Margin="0,0,20,0" Content="Добавить товар" FontSize="12" FontFamily="Roboto" FontWeight="DemiBold" Padding="3" Click="AddProduct_Click"></Button>
+            <Button x:Name="BackMain" Style="{DynamicResource MainButtonStyle}" Grid.Row="0" Margin="0,0,20,0" Content="Вернуться назад" FontSize="12" FontFamily="Roboto" FontWeight="DemiBold" Padding="2" Click="BackMain_Click"></Button>
+        </StackPanel>
+        <ListView Grid.Row="1" Name="listProduct" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
+            <ListView.ItemsPanel>
+                <ItemsPanelTemplate>
+                    <WrapPanel HorizontalAlignment="Center"></WrapPanel>
+                </ItemsPanelTemplate>
+            </ListView.ItemsPanel>
+            <ListView.ItemTemplate>
+                <DataTemplate>
+                    <Border Padding="5" CornerRadius="5" BorderThickness="1" BorderBrush="#304FFE">
+                        <Grid Name="gridProduct" Width="250" Height="auto">
+                            <StackPanel>
+                                <TextBlock FontFamily="Roboto" Text="{Binding name}" FontSize="16" FontWeight="Bold" TextDecorations="{x:Null}"/>
+                                <Image Width="100" Height="100" Source="{Binding image_product, TargetNullValue={StaticResource noimage}}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                <TextBlock FontFamily="Roboto" Text="{Binding Manufacturers.manufacturer_name, StringFormat=Производитель: {0}}" FontSize="14"/>
+                                <TextBlock Uid="{Binding product_code}" Name="price" Loaded="price_Loaded" FontFamily="Roboto" FontSize="14"></TextBlock>
+                                <TextBlock Text="{Binding amount, StringFormat=Количество: {0}}" FontFamily="Roboto" FontSize="14"/>
+                                <TextBlock Uid="{Binding product_code}" Name="ratingProduct" Loaded="rate_Loaded" FontFamily="Roboto" FontSize="18"/>
+                                <StackPanel HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Horizontal">
+                                    <Button Uid="{Binding product_code}" Style="{DynamicResource AcceptButtonStyle}" Margin="3" FontSize="12" FontFamily="Roboto" FontWeight="DemiBold" Padding="2" Click="Button_Click_1">Изменить</Button>
+                                    <Button Uid="{Binding product_code}" Style="{DynamicResource ExitButtonStyle}" Margin="3" FontSize="12" FontFamily="Roboto" FontWeight="DemiBold" Padding="2" Click="Button_Click">Удалить</Button>
+                                </StackPanel>
+                            </StackPanel>
+                        </Grid>
+                    </Border>
+                </DataTemplate>
+            </ListView.ItemTemplate>
+        </ListView>
+        <WrapPanel Grid.Row="2">
+            <StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10 0 45 0">
+                <TextBlock Text="Общая сумма товаров: " FontSize="14" FontFamily="Roboto" FontWeight="DemiBold" Loaded="TextBlock_Loaded"></TextBlock>
+            </StackPanel>
+            <StackPanel Orientation="Vertical" Height="40" HorizontalAlignment="Left" Margin="15 0 0 0">
+                <TextBlock Text="Фильтр" HorizontalAlignment="Center" FontFamily="Roboto" FontSize="12" Margin="0 0 0 2"></TextBlock>
+                <StackPanel Orientation="Horizontal" Height="20" HorizontalAlignment="Center" Margin="0 0 0 0">
+                    <ComboBox x:Name="Filter" Height="20" Width="120" VerticalContentAlignment="Center" Margin="0 0 0 0" FontSize="12" SelectionChanged="Filter_SelectionChanged">
+                        <Label Content="Все товары" FontFamily="Roboto" FontSize="12"/>
+                        <Label Content="Со скидкой" FontFamily="Roboto" FontSize="12"/>
+                        <Label Content="Без скидок" FontFamily="Roboto" FontSize="12"/>
+                    </ComboBox>
+                    <CheckBox x:Name="cbFilter" Content="С оценками" Margin="10 0 0 0" FontFamily="Roboto" FontSize="12" HorizontalAlignment="Center" VerticalAlignment="Center" Checked="cbFilter_Checked" Unchecked="cbFilter_Unchecked"></CheckBox>
+                    <TextBox x:Name="Search" Width="150" Margin="10 0 0 0" FontFamily="Roboto" FontSize="12" TextChanged="Search_TextChanged"></TextBox>
+                </StackPanel>
+            </StackPanel>
+            <StackPanel Orientation="Vertical" Height="40" HorizontalAlignment="Left" Margin="15 0 0 0">
+                <TextBlock Text="Сортировка" HorizontalAlignment="Center" FontFamily="Roboto" FontSize="12" Margin="0 0 0 2"></TextBlock>
+                <ComboBox x:Name="Sortirovka" Height="20" Width="120" VerticalContentAlignment="Center" Margin="0 0 0 0" FontSize="12" SelectionChanged="Sortirovka_SelectionChanged">
+                    <Label Content="По умолчанию" FontFamily="Roboto" FontSize="12"/>
+                    <Label Content="По возрастанию цены" FontFamily="Roboto" FontSize="12"/>
+                    <Label Content="По убыванию цены" FontFamily="Roboto" FontSize="12"/>
+                </ComboBox>
+            </StackPanel>
+        </WrapPanel>
+    </Grid>
+
+
+////////////// INPUT PRODUCT CODE ///////////////
+
+
+ public aListProduct()
+        {
+            InitializeComponent();
+            listProduct.ItemsSource = BaseClass.BD.Products.ToList();
+            Filter.SelectedIndex = 0;
+            Sortirovka.SelectedIndex = 0;
+        }
+
+        private void BackMain_Click(object sender, RoutedEventArgs e)
+        {
+            FrameClass.MainFrame.Navigate(new AdminPanel());
+        }
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            Button btn = (Button)sender;
+            int index = Convert.ToInt32(btn.Uid);
+
+            Products products = BaseClass.BD.Products.FirstOrDefault(x => x.product_code == index);
+            BaseClass.BD.Products.Remove(products);           
+            BaseClass.BD.SaveChanges();
+
+            FrameClass.MainFrame.Navigate(new aListProduct());
+        }
+
+        private void price_Loaded(object sender, RoutedEventArgs e)
+        {
+            TextBlock tb = (TextBlock)sender;
+            int index = Convert.ToInt32(tb.Uid);
+            int disc = 0;
+            int price = 0;
+            List<Products> DC = BaseClass.BD.Products.Where(x => x.product_code == index).ToList();
+            foreach(Products Product in DC)
+            {
+                disc = Convert.ToInt32(Product.discount);
+                price = Convert.ToInt32(Product.price);
+            }
+            if(disc <=0)
+                tb.Text = "Цена: " + price.ToString() + "₽";
+            if(disc > 0)
+            {
+                price = price * (100 - disc) / 100;
+                tb.Text = "Цена: " + price.ToString() + "₽";
+                tb.FontWeight = FontWeights.Bold;
+                tb.Foreground = Brushes.Red;
+            }
+        }
+
+        private void rate_Loaded(object sender, RoutedEventArgs e)
+        {
+            TextBlock tb = (TextBlock)sender;
+            int index = Convert.ToInt32(tb.Uid);
+            int rateID = 0;
+            List<Products> DC = BaseClass.BD.Products.Where(x => x.product_code == index).ToList();
+            foreach (Products Product in DC)
+                rateID = Convert.ToInt32(Product.rate);
+            List<Ratings> RN = BaseClass.BD.Ratings.Where(x => x.rate == rateID).ToList();
+            foreach (Ratings Ratings in RN)
+            {
+                if (Ratings.rating == 5)
+                    tb.Text = "★★★★★";
+                else if (Ratings.rating == 4)
+                    tb.Text = "★★★★";
+                else if (Ratings.rating == 3)
+                    tb.Text = "★★★";
+                else if (Ratings.rating == 2)
+                    tb.Text = "★★";
+                else if (Ratings.rating == 1)
+                    tb.Text = "★";
+                else
+                {
+                    tb.Text = "Рейтинг: 0";
+                    tb.Foreground = Brushes.DarkGray;
+                }
+                tb.Foreground = Brushes.DarkOrange;
+            }
+        }
+
+        private void TextBlock_Loaded(object sender, RoutedEventArgs e)
+        {
+            TextBlock tb = (TextBlock)sender;
+            int allSumProduct = 0;
+            List<Products> DC = BaseClass.BD.Products.ToList();
+            foreach (Products Product in DC)
+                allSumProduct += Convert.ToInt32(Product.price * Product.amount);
+            tb.Text = "Общая сумма товаров\n(без учета скидок): " + allSumProduct.ToString();
+        }
+
+        private void Button_Click_1(object sender, RoutedEventArgs e)
+        {
+            Button btn = (Button)sender;
+            int index = Convert.ToInt32(btn.Uid);
+            Products product = BaseClass.BD.Products.FirstOrDefault(x => x.product_code == index);
+            FrameClass.MainFrame.Navigate(new UpdateProduct(product));
+        }
+
+        private void AddProduct_Click(object sender, RoutedEventArgs e)
+        {
+            FrameClass.MainFrame.Navigate(new UpdateProduct());
+        }
+
+
+
+
+        void SearchMainMethod()
+        {
+            string strSearch = Search.Text.ToLower();
+            var regexSearch = new Regex($@"(^({strSearch}).*)");
+
+            if (Sortirovka.SelectedIndex == 0)
+            {
+                if (cbFilter.IsChecked == true)
+                {
+                    if (Filter.SelectedIndex == 0)
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true && x.rate != null);
+                    }
+                    else if (Filter.SelectedIndex == 1)
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true && x.discount > 0 && x.rate != null);
+                    }
+                    else
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true && x.discount == 0 && x.rate != null);
+                    }
+                }
+                else
+                {
+                    if (Filter.SelectedIndex == 0)
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true);
+                    }
+                    else if (Filter.SelectedIndex == 1)
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true && x.discount > 0);
+                    }
+                    else
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true && x.discount == 0);
+                    }
+                }
+            }
+            else if (Sortirovka.SelectedIndex == 1)
+            {
+                if (cbFilter.IsChecked == true)
+                {
+                    if (Filter.SelectedIndex == 0)
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.OrderBy(x => x.price * (100 - x.discount) / 100).ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true && x.rate != null);
+                    }
+                    else if (Filter.SelectedIndex == 1)
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.OrderBy(x => x.price * (100 - x.discount) / 100).ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true && x.discount > 0 && x.rate != null);
+                    }
+                    else
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.OrderBy(x => x.price * (100 - x.discount) / 100).ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true && x.discount == 0 && x.rate != null);
+                    }
+                }
+                else
+                {
+                    if (Filter.SelectedIndex == 0)
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.OrderBy(x => x.price * (100 - x.discount) / 100).ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true);
+                    }
+                    else if (Filter.SelectedIndex == 1)
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.OrderBy(x => x.price * (100 - x.discount) / 100).ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true && x.discount > 0);
+                    }
+                    else
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.OrderBy(x => x.price * (100 - x.discount) / 100).ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true && x.discount == 0);
+                    }
+                }
+            }
+            else if (Sortirovka.SelectedIndex == 2)
+            {
+                if (cbFilter.IsChecked == true)
+                {
+                    if (Filter.SelectedIndex == 0)
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.OrderByDescending(x => x.price * (100 - x.discount) / 100).ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true && x.rate != null);
+                    }
+                    else if (Filter.SelectedIndex == 1)
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.OrderByDescending(x => x.price * (100 - x.discount) / 100).ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true && x.discount > 0 && x.rate != null);
+                    }
+                    else
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.OrderByDescending(x => x.price * (100 - x.discount) / 100).ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true && x.discount == 0 && x.rate != null);
+                    }
+                }
+                else
+                {
+                    if (Filter.SelectedIndex == 0)
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.OrderByDescending(x => x.price * (100 - x.discount) / 100).ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true);
+                    }
+                    else if (Filter.SelectedIndex == 1)
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.OrderByDescending(x => x.price * (100 - x.discount) / 100).ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true && x.discount > 0);
+                    }
+                    else
+                    {
+                        listProduct.ItemsSource = BaseClass.BD.Products.OrderByDescending(x => x.price * (100 - x.discount) / 100).ToList().Where(x => regexSearch.IsMatch(x.name.ToLower()) == true && x.discount == 0);
+                    }
+                }
+            }
+        }
+
+
+/////////////  GRID INPUT XAML //////////////////
+
+
+<Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="40"></RowDefinition>
+            <RowDefinition Height="370"></RowDefinition>
+            <RowDefinition Height="40"></RowDefinition>
+        </Grid.RowDefinitions>
+        <TextBlock Grid.Row="0" FontSize="28" HorizontalAlignment="Center" VerticalAlignment="Top" FontFamily="Roboto" FontWeight="Bold">Пользователи</TextBlock>
+        <Button x:Name="BackMain" Style="{DynamicResource MainButtonStyle}" Grid.Row="0" Margin="0,0,20,0" VerticalAlignment="Top" HorizontalAlignment="Right" Content="Вернуться назад" FontSize="12" FontFamily="Roboto" FontWeight="DemiBold" Click="BackMain_Click" Padding="2"></Button>
+        <DataGrid Name="dgUser" Grid.Row="1" Margin="10,2,10,2" AutoGenerateColumns="False" CanUserAddRows="False" GridLinesVisibility="Horizontal" CanUserResizeColumns="False" CanUserResizeRows="False" CanUserSortColumns="False" CanUserDeleteRows="False" CanUserReorderColumns="False" IsReadOnly="True" HorizontalAlignment="Center">
+            <DataGrid.Columns>
+                <DataGridTextColumn Header="Логин" Binding="{Binding login}" Width="auto"></DataGridTextColumn>
+                <DataGridTextColumn Header="Имя" Binding="{Binding name_user}" Width="*"></DataGridTextColumn>
+                <DataGridTextColumn Header="Фамилия" Binding="{Binding surname_user}" Width="*"></DataGridTextColumn>
+                <DataGridTextColumn Header="Пол" Binding="{Binding Genders.name_gender}" Width="75"></DataGridTextColumn>
+                <DataGridTextColumn Header="Номер" Binding="{Binding phone}" Width="80"></DataGridTextColumn>
+                <DataGridTextColumn Header="Дата регистрации" Binding="{Binding date_reg, StringFormat=dd.MM.yyyy}" Width="*"></DataGridTextColumn>
+                    <DataGridTextColumn Header="Привилегия" Binding="{Binding Privilage.name_privilage}" Width="78"></DataGridTextColumn>
+                <DataGridTextColumn Header="Роль" Binding="{Binding Roles.name_role}" Width="*"></DataGridTextColumn>
+            </DataGrid.Columns>
+        </DataGrid>
+        <WrapPanel Grid.Row="2">
+            <StackPanel Orientation="Vertical" Height="40" HorizontalAlignment="Left" Margin="15 0 0 0">
+                <TextBlock Text="Сортировка по фамилии" HorizontalAlignment="Center" FontFamily="Roboto" FontSize="12" Margin="0 0 0 2"></TextBlock>
+                <ComboBox x:Name="VozrastYbivan" Height="20" Width="120" VerticalContentAlignment="Center" Margin="0 0 0 0" SelectionChanged="VozrastYbivan_SelectionChanged" FontSize="12">
+                    <Label Content="По умолчанию" FontFamily="Roboto" FontSize="12"/>
+                    <Label Content="По возрастанию" FontFamily="Roboto" FontSize="12"/>
+                    <Label Content="По убыванию" FontFamily="Roboto" FontSize="12"/>
+                </ComboBox>
+            </StackPanel>
+            <StackPanel Orientation="Horizontal" Height="40" HorizontalAlignment="Left" Margin="15 0 0 0">
+                <TextBox x:Name="Search" Width="150" Height="25" VerticalContentAlignment="Center" TextChanged="Search_TextChanged"></TextBox>
+                <StackPanel HorizontalAlignment="Center" Margin="10 0 0 0">
+                    <TextBlock Text="Фильтровать по полю" HorizontalAlignment="Center" FontFamily="Roboto" FontSize="12" Margin="0 0 0 2"></TextBlock>
+                    <ComboBox x:Name="typeSearch" Height="20" Width="80" VerticalContentAlignment="Center" Margin="0 0 0 0" FontSize="12" SelectionChanged="typeSearch_SelectionChanged">
+                        <Label Content="Имя" FontFamily="Roboto" FontSize="12"/>
+                        <Label Content="Фамилия" FontFamily="Roboto" FontSize="12"/>
+                    </ComboBox>
+                </StackPanel>
+            </StackPanel>
+            <StackPanel Orientation="Vertical" Width="150" VerticalAlignment="Center" Margin="10 0 0 0">
+                <TextBlock Text="Фильтрация по полу" HorizontalAlignment="Center" FontFamily="Roboto" FontSize="14"></TextBlock>
+                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+                    <CheckBox Name="rbMan" Content="Мужской" FontFamily="Roboto" Checked="rbMan_Checked" Unchecked="rbMan_Unchecked"></CheckBox>
+                    <CheckBox Name="rbWoman" Content="Женский" FontFamily="Roboto" Margin="10 0 0 0" Checked="rbWoman_Checked" Unchecked="rbWoman_Unchecked"></CheckBox>
+                </StackPanel>
+            </StackPanel>
+            <StackPanel Orientation="Vertical" Height="25" Width="70" Margin=" 15 10 0 0">
+                <Button Name="ButtonRefresh" Style="{DynamicResource AcceptButtonStyle}" FontFamily="Roboto" FontSize="12" Padding="2 0 2 0" Content="Сброс" Height="19" Width="70" Click="ButtonRefresh_Click" FontWeight="Bold"></Button>
+            </StackPanel>
+        </WrapPanel>
+    </Grid>
+
+
+
+//////////////////// GRID INPUT CODE ////////////////
+
+
+ public aListUser()
+        {
+            InitializeComponent();
+            dgUser.ItemsSource = BaseClass.BD.Users.ToList();
+            typeSearch.SelectedIndex = 0;
+            VozrastYbivan.SelectedIndex = 0;
+        }
+
+        private void BackMain_Click(object sender, RoutedEventArgs e)
+        {
+            FrameClass.MainFrame.Navigate(new AdminPanel());
+        }
+
+        private void Search_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            SearchMainMethod();
+        }
+
+        private void ButtonRefresh_Click(object sender, RoutedEventArgs e)
+        {
+            rbWoman.IsChecked = false;
+            rbMan.IsChecked = false;
+            Search.Clear();
+            VozrastYbivan.SelectedIndex = 0;
+            typeSearch.SelectedIndex = 0;
+            dgUser.ItemsSource = BaseClass.BD.Users.ToList();
+        }
+
+
+//////////// UPDATE PRODUCT /////////////
+
+
+ Products PRODUCT;
+        bool flagUpdate = false;
+        string path;
+
+        public void uploadFields()
+        {
+            cbManufacturer.ItemsSource = BaseClass.BD.Manufacturers.ToList();
+            cbManufacturer.SelectedValuePath = "manufacturer_code";
+            cbManufacturer.DisplayMemberPath = "manufacturer_name";
+            cbManufacturer.SelectedIndex = 0;
+            tbDiscount.Text = "0";
+        }
+
+        public UpdateProduct()
+        {
+            InitializeComponent();
+            uploadFields();
+        }
+
+        public UpdateProduct(Products product)
+        {
+            InitializeComponent();
+            uploadFields();
+            flagUpdate = true;
+            PRODUCT = product;
+            tbName.Text = PRODUCT.name;
+            tbPrice.Text = Convert.ToString(PRODUCT.price);
+            tbAmount.Text = Convert.ToString(PRODUCT.amount);
+            cbManufacturer.SelectedIndex = PRODUCT.manufacturer_code - 1;
+            tbDescription.Text = PRODUCT.description;
+            tbDiscount.Text = Convert.ToString(PRODUCT.discount);
+
+            if (product.image_product != null)
+            {
+                BitmapImage img = new BitmapImage(new Uri(product.image_product, UriKind.RelativeOrAbsolute));
+                imgProduct.Source = img;
+            }
+        }
+
+        private void BackMain_Click(object sender, RoutedEventArgs e)
+        {
+            FrameClass.MainFrame.Navigate(new aListProduct());
+        }
+
+        private void bRegistration_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                if (flagUpdate == false)
+                {
+                    PRODUCT = new Products();
+                }
+                PRODUCT.name = tbName.Text;
+                PRODUCT.description = tbDescription.Text;
+                PRODUCT.price = Convert.ToInt32(tbPrice.Text);
+                PRODUCT.amount = Convert.ToInt32(tbAmount.Text);
+                PRODUCT.manufacturer_code = cbManufacturer.SelectedIndex + 1;
+                PRODUCT.discount = Convert.ToInt32(tbDiscount.Text);
+                if (path!= null)
+                {
+                    PRODUCT.image_product = path;
+                }
+                if (flagUpdate == false)
+                {
+                    BaseClass.BD.Products.Add(PRODUCT);
+                }
+                BaseClass.BD.SaveChanges();
+                MessageBox.Show("Информация добавлена");
+
+            }
+            catch
+            {
+                MessageBox.Show("Что-то пошло не по плану");
+            }
+        }
+
+        private void bSavePhoto_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                OpenFileDialog OFD = new OpenFileDialog();
+                OFD.ShowDialog();
+                path = OFD.FileName;
+                string[] arrayPath = path.Split('\\');
+                path = "\\" + arrayPath[arrayPath.Length - 2] + "\\" + arrayPath[arrayPath.Length - 1];
+                BitmapImage bi3 = new BitmapImage();
+                bi3.BeginInit();
+                bi3.UriSource = new Uri("\\Resources\\icons8-new-100.png", UriKind.Relative);
+                bi3.EndInit();
+                imgProduct.Source = bi3;
+            }
+            catch { }
+        }
+
+
+
+
+/////////// СТИЛИ /////////////
+
+<Application.Resources>
+        <SolidColorBrush x:Key="PrimaryBlueColor" Color="#304FFE"></SolidColorBrush>
+        <SolidColorBrush x:Key="PrimaryTextColor" Color="White"></SolidColorBrush>
+        <SolidColorBrush x:Key="ButtonMouseOverColor" Color="#0026CA"></SolidColorBrush>
+        <SolidColorBrush x:Key="ButtonPressedColor" Color="#7a7cff"></SolidColorBrush>
+        <SolidColorBrush x:Key="PrimaryDarkTextColor" Color="#0026ca"></SolidColorBrush>
+        <SolidColorBrush x:Key="ButtonBorderBrushColor" Color="#0026ca"></SolidColorBrush>
+
+        <SolidColorBrush x:Key="PrimaryRedColor" Color="#f21818"></SolidColorBrush>
+        <SolidColorBrush x:Key="ButtonMouseOverColorRed" Color="#de1414"></SolidColorBrush>
+        <SolidColorBrush x:Key="ButtonPressedColorRed" Color="#f05454"></SolidColorBrush>
+
+        <Style x:Key="AcceptButtonStyle" TargetType="{x:Type Button}">
+            <Setter Property="Background" Value="{DynamicResource PrimaryBlueColor}"></Setter>
+            <Setter Property="Foreground" Value="{DynamicResource PrimaryTextColor}"></Setter>
+            <Setter Property="FontWeight" Value="SemiBold"></Setter>
+            <Setter Property="Padding" Value="12 6 12 6"></Setter>
+            <Setter Property="BorderThickness" Value="0"></Setter>
+            <Setter Property="MaxHeight" Value="70"></Setter>
+            <Setter Property="Width" Value="auto"></Setter>
+            <Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
+            <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
+            <Setter Property="Template">
+                <Setter.Value>
+                    <ControlTemplate TargetType="{x:Type Button}">
+                        <Border x:Name="btnBorder" CornerRadius="5"
+                                Background="{TemplateBinding Background}"
+                                Width="{TemplateBinding Width}"
+                                MaxHeight="{TemplateBinding MaxHeight   }"
+                                BorderThickness="{TemplateBinding BorderThickness}"
+                                SnapsToDevicePixels="True"
+                                Padding="{TemplateBinding Padding}">
+                            <ContentPresenter x:Name="ContentPresenter" Focusable="False"
+                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                                              Margin="{TemplateBinding Padding}"
+                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"></ContentPresenter>
+                        </Border>
+                        <ControlTemplate.Triggers>
+                            <Trigger Property="IsMouseOver" Value="True">
+                                <Setter TargetName="btnBorder" Property="Background" Value="{DynamicResource ButtonMouseOverColor}"></Setter>
+                            </Trigger>
+                            <Trigger Property="IsPressed" Value="True">
+                                <Setter TargetName="btnBorder" Property="Background" Value="{DynamicResource ButtonPressedColor}"></Setter>
+                            </Trigger>
+                        </ControlTemplate.Triggers>
+                    </ControlTemplate>
+                </Setter.Value>
+            </Setter>
+        </Style>
+
+        <Style x:Key="MainButtonStyle" TargetType="{x:Type Button}">
+            <Setter Property="Background" Value="Transparent"></Setter>
+            <Setter Property="BorderBrush" Value="{DynamicResource PrimaryBlueColor}"></Setter>
+            <Setter Property="Foreground" Value="{DynamicResource PrimaryBlueColor}"></Setter>
+            <Setter Property="FontWeight" Value="ExtraBold"></Setter>
+            <Setter Property="Padding" Value="11 5.2"></Setter>
+            <Setter Property="BorderThickness" Value="2"></Setter>
+            <Setter Property="MaxHeight" Value="70"></Setter>
+            <Setter Property="Width" Value="auto"></Setter>
+            <Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
+            <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
+            <Setter Property="Template">
+                <Setter.Value>
+                    <ControlTemplate TargetType="{x:Type Button}">
+                        <Border x:Name="btnBorder" CornerRadius="5"
+                                Background="{TemplateBinding Background}"
+                                Width="{TemplateBinding Width}"
+                                BorderBrush="{TemplateBinding BorderBrush}"
+                                MaxHeight="{TemplateBinding MaxHeight   }"
+                                BorderThickness="{TemplateBinding BorderThickness}"
+                                SnapsToDevicePixels="True"
+                                Padding="{TemplateBinding Padding}">
+                            <ContentPresenter x:Name="ContentPresenter" Focusable="False"
+                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                                              Margin="{TemplateBinding Padding}"
+                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"></ContentPresenter>
+                        </Border>
+                        <ControlTemplate.Triggers>
+                            <Trigger Property="IsMouseOver" Value="True">
+                                <Setter TargetName="btnBorder" Property="Background" Value="{DynamicResource ButtonMouseOverColor}"></Setter>
+                                <Setter TargetName="btnBorder" Property="BorderBrush" Value="{DynamicResource PrimaryBlueColor}"></Setter>
+                                <Setter Property="Foreground" Value="{DynamicResource PrimaryTextColor}"></Setter>
+                            </Trigger>
+                            <Trigger Property="IsPressed" Value="True">
+                                <Setter TargetName="btnBorder" Property="Background" Value="{DynamicResource ButtonPressedColor}"></Setter>
+                                <Setter TargetName="btnBorder" Property="BorderBrush" Value="{DynamicResource PrimaryBlueColor}"></Setter>
+                                <Setter Property="Foreground" Value="{DynamicResource PrimaryTextColor}"></Setter>
+                            </Trigger>
+                        </ControlTemplate.Triggers>
+                    </ControlTemplate>
+                </Setter.Value>
+            </Setter>
+        </Style>
+
+
+        <Style x:Key="ExitButtonStyle" TargetType="{x:Type Button}">
+            <Setter Property="Background" Value="{DynamicResource PrimaryRedColor}"></Setter>
+            <Setter Property="Foreground" Value="{DynamicResource PrimaryTextColor}"></Setter>
+            <Setter Property="FontWeight" Value="SemiBold"></Setter>
+            <Setter Property="Padding" Value="12 6 12 6"></Setter>
+            <Setter Property="BorderThickness" Value="0"></Setter>
+            <Setter Property="MaxHeight" Value="70"></Setter>
+            <Setter Property="Width" Value="auto"></Setter>
+            <Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
+            <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
+            <Setter Property="Template">
+                <Setter.Value>
+                    <ControlTemplate TargetType="{x:Type Button}">
+                        <Border x:Name="btnBorder" CornerRadius="5"
+                                Background="{TemplateBinding Background}"
+                                Width="{TemplateBinding Width}"
+                                MaxHeight="{TemplateBinding MaxHeight   }"
+                                BorderThickness="{TemplateBinding BorderThickness}"
+                                SnapsToDevicePixels="True"
+                                Padding="{TemplateBinding Padding}">
+                            <ContentPresenter x:Name="ContentPresenter" Focusable="False"
+                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+                                              Margin="{TemplateBinding Padding}"
+                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"></ContentPresenter>
+                        </Border>
+                        <ControlTemplate.Triggers>
+                            <Trigger Property="IsMouseOver" Value="True">
+                                <Setter TargetName="btnBorder" Property="Background" Value="{DynamicResource ButtonMouseOverColorRed}"></Setter>
+                            </Trigger>
+                            <Trigger Property="IsPressed" Value="True">
+                                <Setter TargetName="btnBorder" Property="Background" Value="{DynamicResource ButtonPressedColorRed}"></Setter>
+                            </Trigger>
+                        </ControlTemplate.Triggers>
+                    </ControlTemplate>
+                </Setter.Value>
+            </Setter>
+        </Style>
+
+    </Application.Resources>

+ 898 - 0
nick/deemo.txt

@@ -0,0 +1,898 @@
+Первоначальный алгоритм. Создали класс бд, создали класс frame. В MainWindow инициализировали бд и фрейм, сделали переход на следующее окно(авторизация)
+
+class db:
+ class db
+    {
+        public static Entities tbe;
+    }
+-----------------
+class Frame
+   class MainFrame
+    {
+        public static Frame frame;
+    }
+-----------------
+class User - объединить в одну строку
+public string FullName
+        {
+            get
+            {
+                return  UserSurname + " " + UserName + " " + UserPatronymic;
+            }
+        }
+-----------------
+style App
+  <Style x:Key="tbStyleFont" TargetType="TextBlock">
+            <Style.Setters>
+                <Setter Property="FontFamily" Value="Comic Sans MS"/>
+                <Setter Property="FontSize" Value="15"/>
+            </Style.Setters>
+        </Style>
+-----------------
+окно MainWindow
+public MainWindow()
+        {
+            InitializeComponent();
+            db.tbe = new Entities();
+            MainFrame.frame = fMain;
+            MainFrame.frame.Navigate(new AuthorizationPage());
+        }
+-----------------
+Капча AuthPage(первое окно)
+private DispatcherTimer dispatcher;
+public static bool checkedCaptcha;
+private int counter = 10;
+public AuthorizationPage()
+{
+InitializeComponent();
+dispatcher = new DispatcherTimer();
+dispatcher.Interval = new TimeSpan(0, 0, 0, 1);
+dispatcher.Tick += new EventHandler(TimerEnd);
+ }
+
+ private void TimerEnd(object sender, EventArgs e)
+        {
+            try
+            {
+              
+                if (counter != 0)
+                {
+                    
+                    tbAuth.Text = "Новый код доступен через \n\t" + string.Format("00:00:{0}", counter) + " секунд ";
+
+
+                }
+                else
+                {
+                    btnAuth.IsEnabled = true;
+                    gpPassword.IsEnabled = true;
+                    gpLogin.IsEnabled = true;
+                   
+                    tbAuth.Visibility = Visibility.Collapsed;
+                    dispatcher.Stop();
+                }
+                counter--;
+
+            }
+            catch
+            {
+                MessageBox.Show("Дваайте еще раз попробуем");
+            }
+
+
+
+        }
+  
+        private void btnAuth_Click(object sender, RoutedEventArgs e)
+        {
+            User user = db.tbe.User.FirstOrDefault(x => x.UserPassword == tbPassword.Text && x.UserLogin == tbLogin.Text);
+            try
+            {
+                if (user == null)
+                {
+                    //tbLogin.Text != user.UserLogin && tbPassword.Text != user.UserPassword
+                    MessageBox.Show("Введенный логин и/или пароль неверен");
+                    Captcha captcha = new Captcha();
+                    captcha.Show();
+                    captcha.Closing += (obj, args) =>
+                    {
+                        if (!checkedCaptcha)
+                        {
+                            btnAuth.IsEnabled = false;
+                            gpPassword.IsEnabled = false;
+                            gpLogin.IsEnabled = false;
+                            counter = 10;
+                            dispatcher.Start();
+                        }
+                        
+                    };
+
+                }
+                else
+                {
+                    if (!string.IsNullOrEmpty(tbLogin.Text) && !string.IsNullOrEmpty(tbPassword.Text))
+                    {
+                        if (tbLogin.Text != null && tbPassword.Text != null)
+                        {
+
+
+                            if (user.UserLogin == tbLogin.Text)
+                            {
+                                if (user.UserPassword == tbPassword.Text)
+                                {
+
+                                    NavigationService.Navigate(new PageProducts(user));
+                                  
+                                }
+                                else
+                                {
+                                    MessageBox.Show("Пароль в системе отсутствует");
+                                }
+                            }
+                            else
+                            {
+                                MessageBox.Show("Логин в системе отсутствует");
+                            }
+
+                        }
+
+                    }
+                    else
+                    {
+                        MessageBox.Show("Неверный логин и/или пароль!");
+                    }
+                }
+
+
+
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+            }
+        }
+-----------------
+Страница с выводом:
+В инициализации:
+db.tbe = new Entities();
+lvProduct.ItemsSource = db.tbe.Product.ToList();
+lvProduct.SelectedValuePath = "ProductArticleNumber";
+tblast.Text = db.tbe.Product.Count().ToString(); // вывод 15
+tbFirst.Text = lvProduct.Items.Count.ToString(); // вывод 47
+-----------------
+<Page.Resources>
+        <BitmapImage x:Key="noPhoto" UriSource="\resources\picture.png"></BitmapImage>
+    </Page.Resources>
+-----------------
+1.ListView
+2.ListView.ItemTemplate
+3.DataTemplate
+4.Grid
+В конце можно изьебнуться и вставить. При нажатии на контекстное меню добавляется товар в заказ
+ <ListView.ContextMenu>
+                    <ContextMenu>
+                        <MenuItem Header="Добавить к заказу" Click="MenuItem_Click" Uid="{Binding ProductArticleNumber}"></MenuItem>
+                    </ContextMenu>
+                </ListView.ContextMenu>
+            </ListView>
+
+а в коде
+   public static List<string> articleProducts = new List<string>();
+        private void MenuItem_Click(object sender, RoutedEventArgs e)
+        {
+            btnOrder.Visibility = Visibility.Visible;
+            articleProducts.Add(lvProduct.SelectedValue.ToString());
+
+        }
+Создать кнопку btnorder
+  private void btnOrder_Click(object sender, RoutedEventArgs e)
+        {
+            Window1 window = new Window1(user);
+            window.Show();
+            window.Closing += (obj, args) =>
+            {
+                if (articleProducts.Count == 0)
+                {
+                    btnOrder.Visibility = Visibility.Collapsed;
+
+                }
+                else
+                {
+                    btnOrder.Visibility = Visibility.Visible;
+                }
+            };
+
+        }
+
+-----------------
+Просмотр заказа (корзина)
+Разметка:
+  <Grid> 
+        <Grid>
+            <Grid.RowDefinitions>
+                <RowDefinition Height="*"></RowDefinition>
+                <RowDefinition Height="5*"></RowDefinition>
+                <RowDefinition Height="*"></RowDefinition>
+            </Grid.RowDefinitions>
+            <StackPanel Grid.Row="1">
+                <ListView  Name="lvOrder" ScrollViewer.VerticalScrollBarVisibility="Disabled" Height="230" Width="800"   >
+                    <ListView.ItemTemplate>
+                        <DataTemplate>
+                            <Grid  Background="{Binding colorBrush}" Width="770" >
+                                <Grid.ColumnDefinitions>
+                                    <ColumnDefinition Width="0.5*"/>
+                                    <ColumnDefinition Width="1*"/>
+                                    <ColumnDefinition Width="*"/>
+                                </Grid.ColumnDefinitions>
+                                <StackPanel Grid.Column="0">
+                                    <Image  Height="100" Source="{Binding ProductPhoto, TargetNullValue={StaticResource noPhoto}}"></Image>
+                                </StackPanel>
+
+                                <StackPanel Grid.Column="1">
+
+                                    <TextBlock Text="{Binding ProductName}"/>
+                                    <TextBlock Text="{Binding ProductDescription}" TextWrapping="Wrap"/>
+                                    <TextBlock Text="{Binding manufacture.manufactureName}"/>
+                                    <StackPanel Orientation="Horizontal">
+                                        <TextBlock Text=" "></TextBlock>
+                                        <TextBlock Text="{Binding ProductCost,  StringFormat={}{0:0}}" TextDecorations="Strikethrough" Uid="{Binding ProductDiscountAmount}"/>
+                                        <TextBlock Text="   "></TextBlock>
+                                        <TextBlock Text="{Binding ActualPrice, StringFormat={}{0:0}руб.}"/>
+                                    </StackPanel>
+                                </StackPanel>
+                                <StackPanel Grid.Column="2">
+                                    <Button  Background="#498c51" Content="Удалить из заказа" Name="btnDelete" Click="btnDelete_Click" Uid="{Binding ProductArticleNumber}"/>
+                                    <GroupBox Header="Количество товара">
+                                        <TextBox Text="1" TextChanged="TextBox_TextChanged" Uid="{Binding ProductArticleNumber}">
+                                            <TextBox.ToolTip>Введите количество товара</TextBox.ToolTip>
+                                        </TextBox>
+                                    </GroupBox>                                 
+                                </StackPanel>
+                            </Grid>
+                        </DataTemplate>
+                    </ListView.ItemTemplate>
+                </ListView>
+                <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center">
+                    <ComboBox Name="cmbOrderPoint"></ComboBox>
+                    <Button Margin="15 0 0 0" Background="#498c51" Content="Сформировать заказ" Name="btnFormOrder" Click="btnFormOrder_Click"/>
+                    <TextBlock Name="tbSummaZakaza"  FontWeight="Bold"></TextBlock>
+                    <TextBlock Name="tbSaleZakaza" Margin="15 0 0 0"></TextBlock>
+                </StackPanel>
+            </StackPanel>
+        </Grid>
+    </Grid>
+
+Код на корзину
+  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} шт.) ";
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+            }
+
+        }
+        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);
+            }
+
+        }
+-----------------
+-----------------
+Отсутствие фото:
+-----------------
+В гриде биндинг, нулевая фотка:
+ <StackPanel Grid.Column="0" >
+   <Image  Height="100" Source="{Binding ProductPhoto, TargetNullValue={StaticResource noPhoto}}"></Image>
+     </StackPanel>
+
+Вывод в комбобокс без контента на разметке:
+cmbOrderPoint.ItemsSource = db.tbe.Point.ToList();
+cmbOrderPoint.SelectedValuePath = "idPickupPoint";
+cmbOrderPoint.DisplayMemberPath = "displayPoint";
+cmbOrderPoint.SelectedIndex = 0;
+
+Вывод в комбобокс с добавлением через цикл
+ List<Raions> raions = Base.baseDate.Raions.ToList(); // Заполнение списка районов
+            cbFilterRaion.Items.Add("Все районы");
+            foreach(Raions raion in raions)
+            {
+                cbFilterRaion.Items.Add(raion.RaionName);
+            }
+            cbFilterRaion.SelectedIndex = 0;
+Вывод записей 15 из 47
+1. 15
+ private void tblast_Loaded(object sender, RoutedEventArgs e)
+        {
+
+            List<Product> products = db.tbe.Product.ToList();
+            tblast.Text = lvProduct.Items.Count.ToString();
+            lvProduct.ItemsSource = products;
+        }
+2. 47 
+
+        private void tbFirst_Loaded(object sender, RoutedEventArgs e)
+        {
+
+            List<Product> products = db.tbe.Product.ToList();
+            tbFirst.Text = db.tbe.Product.ToList().Count().ToString();
+            lvProduct.ItemsSource = products;
+        }
+-----------------
+Фильтрация и сортировка 
+-----------------
+ <GroupBox Header="Сортировка товаров">
+                <ComboBox Name="cmbSorted" SelectionChanged="cmbSorted_SelectionChanged">
+                    <ComboBoxItem Content="По умолчанию"/>
+                    <ComboBoxItem Content="По возрастанию стоимости"/>
+                    <ComboBoxItem Content="По убыванию стоимости"/>
+                </ComboBox>
+            </GroupBox>
+            <GroupBox Header="Фильтрация товаров">
+                <ComboBox Name="cmbFiltres" SelectionChanged="cmbSorted_SelectionChanged">
+                    <ComboBoxItem Content="Все диапазоны"/>
+                    <ComboBoxItem Content="0-9,99%"/>
+                    <ComboBoxItem Content="10-14,99%"/>
+                    <ComboBoxItem Content="15% и более"/>
+                </ComboBox>
+            </GroupBox>
+
+      private void filtresMethod() // общий метод сортировки и фильтрации
+        {
+            List<Product> products = db.tbe.Product.ToList();
+            if (cmbSorted.SelectedItem != null)
+            {
+                ComboBoxItem comboBoxItem = (ComboBoxItem)cmbSorted.SelectedItem;
+                switch (comboBoxItem.Content)
+                {
+
+                    case "По умолчанию":
+                        {
+                            products = products;
+                            break;
+                        }
+                    case "По возрастанию стоимости":
+                        {
+                            products = products.OrderBy(x => x.ProductCost).ToList();
+                            break;
+                        }
+                    case "По убыванию стоимости":
+                        {
+
+                            products = products.OrderByDescending(x => x.ProductCost).ToList();
+                            break;
+                        }
+                }
+
+
+            }
+            if (cmbFiltres.SelectedItem != null)
+            {
+                ComboBoxItem comboBoxItem = (ComboBoxItem)cmbFiltres.SelectedItem;
+                switch (comboBoxItem.Content)
+                {
+
+                    case "Все диапазоны":
+                        {
+                            products = products;
+                            break;
+                        }
+
+                    case "0-9,99%":
+                        {
+                            products = products.Where(x => x.ProductDiscountAmount >= 0 && x.ProductDiscountAmount <= 9.99).ToList();
+                            break;
+                        }
+                    case "10-14,99%":
+                        {
+                            products = products.Where(x => x.ProductDiscountAmount >= 10 && x.ProductDiscountAmount <= 14.99).ToList();
+
+                            break;
+                        }
+                    case "15% и более":
+                        {
+                            products = products.Where(x => x.ProductDiscountAmount >= 15).ToList();
+
+                            break;
+                        }
+
+                }
+            }
+            if (tbSearch.Text != null)
+            {
+                if (!string.IsNullOrEmpty(tbSearch.Text))
+                {
+                    products = products.Where(x => x.ProductName.ToLower().Contains(tbSearch.Text)).ToList();
+                }
+            }
+            if (products.Count == 0 || products.Count == null)
+            {
+                MessageBox.Show("Отсутствуют критерии, удовлетворяющие результатам поиска!");
+            }
+            lvProduct.ItemsSource = products;
+            tblast.Text = lvProduct.Items.Count.ToString();
+        }
+-----------------
+Удаление заказа
+-----------------
+Получаем UID кнопки, инициализируем объект БД, прогняем по циклу и удаляем
+Удаление со смежными таблицами
+Button button = (Button)sender;
+            string id = button.Uid;
+            Product product = db.tbe.Product.FirstOrDefault(x => x.ProductArticleNumber == id);
+            foreach (var item in db.tbe.OrderProduct.Where(x => x.ProductArticleNumber == id))
+            {
+
+                db.tbe.OrderProduct.Remove(item);
+            }
+            var result = MessageBox.Show("Подтвердите удаление товара", "Системное диалоговое окно", MessageBoxButton.YesNo, MessageBoxImage.Question);
+            if(result == MessageBoxResult.Yes)
+            {
+                db.tbe.Product.Remove(product);
+                db.tbe.SaveChanges();
+                MessageBox.Show("Товар " + product.ProductName + " был удален");
+                NavigationService.Navigate(new PageProducts(user));
+            }
+            else
+            {
+                MessageBox.Show("Товар " + product.ProductName + " не удален");
+                NavigationService.Navigate(new PageProducts(user));
+            }
+-----------------
+Изменение товара (создать новое окно)
+-----------------
+Button button = (Button)sender;
+string id = button.Uid;
+Product product = db.tbe.Product.FirstOrDefault(x => x.ProductArticleNumber == id);
+WindowChangeProduct windowChangeProduct = new WindowChangeProduct(product);
+windowChangeProduct.Show();
+windowChangeProduct.Closing += (bin, args) => // при закрытии окна применяем возможные изменения
+{
+NavigationService.Navigate(new PageProducts(user));
+lvProduct.ItemsSource = db.tbe.Product.ToList();
+};
+-----------------
+В самом окне windowChangeProduct создаем объекты текстбоксов, в коде следующее:
+В инициализации
+tbProductName.Text = product.ProductName;
+tbProductDescription.Text = product.ProductDescription;
+cmbProductSupplier.ItemsSource = db.tbe.supplier.ToList();
+cmbProductSupplier.SelectedValuePath = "idSupplier";
+cmbProductSupplier.DisplayMemberPath = "supplierName";
+cmbProductSupplier.SelectedValue = product.idSupplier.ToString();
+tbOldPrice.Text = product.ProductCost.ToString();
+tbSale.Text = product.ProductDiscountAmount.ToString();
+
+в кнопке для изменения
+
+            if(!string.IsNullOrEmpty(tbProductName.Text) && !string.IsNullOrEmpty(tbProductDescription.Text) && !string.IsNullOrEmpty(tbOldPrice.Text)  && !string.IsNullOrEmpty(tbSale.Text) && cmbProductSupplier.SelectedIndex != null && cmbProductSupplier != null)
+            {
+                product.ProductName = tbProductName.Text;
+                product.ProductDescription = tbProductDescription.Text;
+                product.idSupplier = Convert.ToInt32(cmbProductSupplier.SelectedValue);
+                product.ProductCost = Convert.ToDecimal(tbOldPrice.Text);
+                product.ProductDiscountAmount = Convert.ToInt32(tbSale.Text);
+                db.tbe.SaveChanges();
+                this.Close();
+                MessageBox.Show("Готово");
+              
+            }
+-----------------
+Добавление товара. Создаем нужны поля в разметке
+В инициализации определяем комбобоксы
+
+ cmbCategory.ItemsSource = db.tbe.ProductCategory.ToList();
+            cmbCategory.SelectedValuePath = "ProductCategoryID";
+            cmbCategory.DisplayMemberPath = "ProductCategoryName";
+
+            cmbManufacturer.ItemsSource = db.tbe.manufacture.ToList();
+            cmbManufacturer.SelectedValuePath = "idManufacture";
+            cmbManufacturer.DisplayMemberPath = "manufactureName";
+
+            cmbEdIzm.ItemsSource = db.tbe.edIzm.ToList();
+            cmbEdIzm.SelectedValuePath = "idEdIzm";
+            cmbEdIzm.DisplayMemberPath = "edenicaizm";
+
+            cmbSupplier.ItemsSource = db.tbe.supplier.ToList();
+            cmbSupplier.SelectedValuePath = "idSupplier";
+            cmbSupplier.DisplayMemberPath = "supplierName";
+            addProduct.Background = (SolidColorBrush)new SolidColorBrush(Color.FromRgb(73, 140, 81));
+
+В кнопке добавления проверяем все условия на !null и !string.IsNullOrEmpt? а после
+
+Product product = new Product();
+product.ProductArticleNumber = tbArcticle.Text;
+product.ProductName = tbNameProduct.Text;
+product.ProductDescription = tbDescriptionProduct.Text;
+product.ProductCategory = Convert.ToInt32(cmbCategory.SelectedValue);
+product.ProductManufacturer = Convert.ToInt32(cmbManufacturer.SelectedValue);
+product.ProductCost = Convert.ToDecimal(tbCost.Text);
+product.ProductDiscountAmount = Convert.ToInt32(tbSale.Text);
+product.ProductQuantityInStock = Convert.ToInt32(tbQuantity.Text);
+product.ProductStatus = null;
+product.idEdIzm = Convert.ToInt32(cmbEdIzm.SelectedValue);
+product.maxDiscount = Convert.ToInt32(tbMaxDiscount.Text);
+product.idSupplier = Convert.ToInt32(cmbSupplier.SelectedValue);
+product.ProductPhoto = null;
+db.tbe.Product.Add(product);
+db.tbe.SaveChanges();
+MessageBox.Show("Товар был успешно добавлен");
+ this.Close();
+-----------------
+
+-----------------
+Капча второе окно с выводом картинки:
+ <Grid>
+        <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
+            <Image Name="CaptchaImage" Height="100" Width="150"></Image>
+            <TextBox BorderBrush="Black" Name="tbCheckedCaptcha"></TextBox>
+            <Button Background="#498c51" Content="Проверить" Click="Button_Click"></Button>
+        </StackPanel>
+    </Grid>
+
+  public partial class Captcha : Window
+    {
+        public static bool checkedCaptcha;
+        int num = 0;
+        public Captcha()
+        {
+            InitializeComponent();
+            CreateImg();
+        }
+        private void CreateImg()
+        {
+            Random random = new Random();
+            num = random.Next(1000, 9999);
+            var pixels = new byte[Convert.ToInt32(CaptchaImage.Width) * Convert.ToInt32(CaptchaImage.Height) * 4];
+            random.NextBytes(pixels);
+            BitmapSource bitmapSource = BitmapSource.Create(Convert.ToInt32(CaptchaImage.Width), Convert.ToInt32(CaptchaImage.Height), 96, 96, PixelFormats.Bgra32, null, pixels, Convert.ToInt32(CaptchaImage.Width) * 4);
+            var visual = new DrawingVisual();
+            using (DrawingContext drawingContext = visual.RenderOpen())
+            {
+                drawingContext.DrawText(
+                    new FormattedText(num.ToString(), CultureInfo.InvariantCulture, FlowDirection.LeftToRight,
+                        new Typeface("Arial"), 100, System.Windows.Media.Brushes.Red), new System.Windows.Point(0, CaptchaImage.Height / 2));
+                drawingContext.DrawImage(bitmapSource, new Rect(0, 0, 256, 256));
+            }
+            var image = new DrawingImage(visual.Drawing);
+            CaptchaImage.Source = image;
+        }
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            if(num == Convert.ToInt32(tbCheckedCaptcha.Text))
+            {
+                if (!string.IsNullOrEmpty(tbCheckedCaptcha.Text))
+                {
+                    MessageBox.Show("Код введен верно.");
+                    AuthorizationPage.checkedCaptcha = true;
+                    
+                    this.Close();
+                }
+                else
+                {
+                    MessageBox.Show("Введите код для капчи");
+                }
+                
+                
+            }
+            else
+            {
+                MessageBox.Show("Код введен неверно.");
+
+                AuthorizationPage.checkedCaptcha = false;
+                this.Close();
+            }
+        }
+    }
+
+-----------------
+Классы
+-----------------
+Article
+  public  class Article
+    {
+
+        public string article
+        {
+            get;
+            set;
+        }
+        public int count
+        {
+            get;set;
+        }
+    }
+-----------------
+db
+    class db
+    {
+        public static Entities tbe;
+    }
+-----------------
+Frame
+class MainFrame
+    {
+        public static Frame frame;
+    }
+-----------------
+PartialEditedOrder - парш на смена цвета смену цвета
+-----------------
+  public partial class Product
+    {
+        public SolidColorBrush colorBrushes
+        {
+            get
+            {
+                if (ProductQuantityInStock > 3)
+                {
+
+                    SolidColorBrush scb = (SolidColorBrush)new BrushConverter().ConvertFromString("#20b2aa");
+
+                    return scb;
+
+
+
+                }
+                else
+                {
+                    SolidColorBrush scb1 = (SolidColorBrush)new BrushConverter().ConvertFromString("#ff8c00");
+                    return scb1;
+                }
+            }
+        }
+    }
+-----------------
+PartialProduct. Вывод скидки товра. Вывод скидка товара. Закрашивание на ListView
+-----------------
+ public double ActualPrice
+        {
+            get
+            {
+
+                if (ProductDiscountAmount != null)
+                {
+
+                    double ammount = Convert.ToDouble(ProductCost) - Convert.ToDouble(ProductCost) / 100 * Convert.ToDouble(ProductDiscountAmount);
+                    return ammount;
+                }
+                else
+                {
+                    return Convert.ToDouble(ProductCost);
+                }
+              
+            }
+        }
+        public SolidColorBrush colorBrush
+        {
+            get
+            {
+                if (ProductDiscountAmount > 15)
+                {
+                    SolidColorBrush solidColorBrush = new SolidColorBrush(Color.FromRgb(127, 255, 0));
+                    return solidColorBrush;
+                }
+                else
+                {
+                    SolidColorBrush solidColorBrush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
+                    return solidColorBrush;
+                }
+            }
+        }
+-----------------
+Объединение ФИО В одно
+ public partial class User 
+    {
+        public string FullName
+        {
+            get
+            {
+                return  UserSurname + " " + UserName + " " + UserPatronymic;
+            }
+        }
+    }
+-----------------
+SaleClass
+-----------------
+ public class SaleClass
+    {
+        public  Order order { get; set; }
+        public  double Sale { get; set; }
+
+
+    }
+-----------------
+SummClass
+ public  class SummClass
+    {
+        public  Order order { get; set; }
+        public  int Summa { get; set; }
+        public  double
+            SALE { get; set; }
+
+
+    }
+-----------------
+Объединение городов в комбобокс на странице WindowOrder
+ public partial class Point
+    {
+        public string displayPoint
+        {
+            get
+            {
+                string str = indexPoint.ToString() + " " + cityPoint + " " + streetPoint + " " + homePoint.ToString();
+                return str;
+            }
+        }
+    }
+-----------------
+
+Тут ведется вывод старой цены и новой цены с учетом скидки
+     <StackPanel Orientation="Horizontal">
+ <TextBlock Text=" "></TextBlock>
+ <TextBlock Text="{Binding ProductCost,  StringFormat={}{0:0}}" TextDecorations="Strikethrough" Uid="{Binding ProductDiscountAmount}" Loaded="TextBlock_Loaded"/>
+  <TextBlock Text="   "></TextBlock>
+ <TextBlock Text="{Binding ActualPrice, StringFormat={}{0:0}руб.}"/>
+ </StackPanel>

+ 2039 - 0
nick/Весь пиши стирай.txt

@@ -0,0 +1,2039 @@
+Классы:
+======================================================================
+Article.cs
+  public  class Article
+    {
+
+        public string article
+        {
+            get;
+            set;
+        }
+        public int count
+        {
+            get;set;
+        }
+    }
+======================================================================
+db.cs
+ class db
+    {
+        public static Entities tbe;
+    }
+======================================================================
+
+Frame.cs
+  class MainFrame
+    {
+        public static Frame frame;
+    }
+======================================================================
+PartialEditedOrder.cs // изменение цвета в эдиторе
+  public partial class Product
+    {
+        public SolidColorBrush colorBrushes
+        {
+            get
+            {
+                if (ProductQuantityInStock > 3)
+                {
+
+                    SolidColorBrush scb = (SolidColorBrush)new BrushConverter().ConvertFromString("#20b2aa");
+
+                    return scb;
+
+
+
+                }
+                else
+                {
+                    SolidColorBrush scb1 = (SolidColorBrush)new BrushConverter().ConvertFromString("#ff8c00");
+                    return scb1;
+                }
+            }
+        }
+    }
+======================================================================
+PartialPoint.cs
+ public partial class Point
+    {
+        public string displayPoint
+        {
+            get
+            {
+                string str = indexPoint.ToString() + " " + cityPoint + " " + streetPoint + " " + homePoint.ToString();
+                return str;
+            }
+        }
+    }
+
+======================================================================
+PartialProduct.cs
+  public partial class Product
+    {
+        public double ActualPrice
+        {
+            get
+            {
+
+                if (ProductDiscountAmount != null)
+                {
+
+                    double ammount = Convert.ToDouble(ProductCost) - Convert.ToDouble(ProductCost) / 100 * Convert.ToDouble(ProductDiscountAmount);
+                    return ammount;
+                }
+                else
+                {
+                    return Convert.ToDouble(ProductCost);
+                }
+              
+            }
+        }
+        public SolidColorBrush colorBrush
+        {
+            get
+            {
+                if (ProductDiscountAmount > 15)
+                {
+                    SolidColorBrush solidColorBrush = new SolidColorBrush(Color.FromRgb(127, 255, 0));
+                    return solidColorBrush;
+                }
+                else
+                {
+                    SolidColorBrush solidColorBrush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
+                    return solidColorBrush;
+                }
+            }
+        }
+    }
+
+======================================================================
+PartialUsers.cs
+ public partial class User 
+    {
+        public string FullName
+        {
+            get
+            {
+                return  UserSurname + " " + UserName + " " + UserPatronymic;
+            }
+        }
+    }
+======================================================================
+SaleClass.cs
+  public class SaleClass
+    {
+        public  Order order { get; set; }
+        public  double Sale { get; set; }
+
+
+    }
+======================================================================
+SummClass.cs
+ public  class SummClass
+    {
+        public  Order order { get; set; }
+        public  int Summa { get; set; }
+        public  double
+            SALE { get; set; }
+
+
+    }
+======================================================================
+App.xaml стили
+Style x:Key="tbStyleFont" TargetType="TextBlock">
+            <Style.Setters>
+                <Setter Property="FontFamily" Value="Comic Sans MS"/>
+                <Setter Property="FontSize" Value="15"/>
+            </Style.Setters>
+        </Style>
+======================================================================
+
+MainWindow
+   Icon="\resources\icon.ico"
+  <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="*"></RowDefinition>
+            <RowDefinition Height="6*"></RowDefinition>
+       
+        </Grid.RowDefinitions>
+        <StackPanel Grid.Row="0" HorizontalAlignment="Center" Orientation="Horizontal">
+            <Image Name="imgLogo" Source="\resources\logo.png" Height="60"></Image>
+            <TextBlock Margin="0 25 0 0" Style="{StaticResource tbStyleFont}" Text="Пиши - стирай"></TextBlock>
+        </StackPanel>
+
+        <Frame Name="fMain" NavigationUIVisibility="Hidden" Grid.Row="1">
+        </Frame>
+        
+    </Grid>
+--
+  public MainWindow()
+        {
+            InitializeComponent();
+            db.tbe = new Entities();
+            MainFrame.frame = fMain;
+            MainFrame.frame.Navigate(new AuthorizationPage());
+        }
+
+======================================================================
+PageProducts
+  <Page.Resources>
+        <BitmapImage x:Key="noPhoto" UriSource="\resources\picture.png"></BitmapImage>
+    </Page.Resources>
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="1*"/>
+            <RowDefinition Height="5*"/>
+            <RowDefinition Height="1*"/>
+        </Grid.RowDefinitions>
+        <StackPanel  Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" Height="30" >
+            <Button FontFamily="Comic Sans MS"  Background="#498c51" Loaded="btnAllOrder_Loaded" Name="btnAllOrder" Content="Все заказы" Click="Button_Click" Grid.Row="2"/>
+            <Button FontFamily="Comic Sans MS"  Background="#498c51" Margin="5 0 0 0" Name="btnAddProduct" Content="Добавить товар" Click="btnAddProduct_Click" Grid.Row="2"/>
+            <Button FontFamily="Comic Sans MS"  Background="#498c51" Margin="5 0 0 0" Content="Выйти" Name="btnExit" Click="btnExit_Click" Grid.Row="2" HorizontalAlignment="Center"></Button>
+
+        </StackPanel>
+        <Button HorizontalAlignment="Right" FontFamily="Comic Sans MS"  Background="#498c51" Visibility="Collapsed" Content="Просмотр заказа" Name="btnOrder" Click="btnOrder_Click" Grid.Row="2"  Height="50"></Button>
+        <StackPanel Grid.Row="0" Margin="25 0 0 0" Orientation="Horizontal">
+            <TextBlock x:Name="tblast" Loaded="tblast_Loaded"/>
+            <TextBlock Text=" из "/>
+            <TextBlock Name="tbFirst" Loaded="tbFirst_Loaded" />
+        </StackPanel>
+       
+        <TextBlock Name="tbNameUser" HorizontalAlignment="Right"></TextBlock>
+        
+        
+        <StackPanel Grid.Row="0" HorizontalAlignment="Center" Orientation="Horizontal">
+            <GroupBox Header="Сортировка товаров">
+                <ComboBox Name="cmbSorted" SelectionChanged="cmbSorted_SelectionChanged">
+                    <ComboBoxItem Content="По умолчанию"/>
+                    <ComboBoxItem Content="По возрастанию стоимости"/>
+                    <ComboBoxItem Content="По убыванию стоимости"/>
+                </ComboBox>
+            </GroupBox>
+            <GroupBox Header="Фильтрация товаров">
+                <ComboBox Name="cmbFiltres" SelectionChanged="cmbSorted_SelectionChanged">
+                    <ComboBoxItem Content="Все диапазоны"/>
+                    <ComboBoxItem Content="0-9,99%"/>
+                    <ComboBoxItem Content="10-14,99%"/>
+                    <ComboBoxItem Content="15% и более"/>
+                </ComboBox>
+            </GroupBox>
+            <GroupBox Header="Поисковая строка">
+                <TextBox Name="tbSearch" TextChanged="tbSearch_TextChanged"></TextBox>
+            </GroupBox>
+        </StackPanel>
+        <StackPanel Grid.Row="1">
+            <ListView   Name="lvProduct" ScrollViewer.VerticalScrollBarVisibility="Disabled" Height="230" Width="800">
+                <ListView.ItemTemplate>
+                    <DataTemplate>
+                        <Border  Background="{Binding colorBrush}">
+                            <Grid  Width="770" >
+                                <Grid.ColumnDefinitions>
+                                    <ColumnDefinition Width="0.5*"/>
+                                    <ColumnDefinition Width="0.5*"/>
+                                    <ColumnDefinition Width="0.2*"/>
+                                    <ColumnDefinition Width="0.6*"/>
+                                </Grid.ColumnDefinitions>
+                                <StackPanel Grid.Column="0" >
+                                    <Image  Height="100" Source="{Binding ProductPhoto, TargetNullValue={StaticResource noPhoto}}"></Image>
+                                </StackPanel>
+
+                                <StackPanel Grid.Column="1" HorizontalAlignment="Center">
+
+                                    <TextBlock Text="{Binding ProductName}"/>
+                                    <TextBlock Text="{Binding ProductDescription}" TextWrapping="Wrap"/>
+                                    <TextBlock Text="{Binding manufacture.manufactureName}"/>
+                                    <StackPanel Orientation="Horizontal">
+                                        <TextBlock Text=" "></TextBlock>
+                                        <TextBlock Text="{Binding ProductCost,  StringFormat={}{0:0}}" TextDecorations="Strikethrough" Uid="{Binding ProductDiscountAmount}" Loaded="TextBlock_Loaded"/>
+                                        <TextBlock Text="   "></TextBlock>
+                                        <TextBlock Text="{Binding ActualPrice, StringFormat={}{0:0}руб.}"/>
+
+                                    </StackPanel>
+
+
+
+                                </StackPanel>
+
+                                <StackPanel Name="stackButton" Grid.Column="3" Orientation="Horizontal" HorizontalAlignment="Center" Height="25">
+                                    <Button Background="#498c51" Loaded="btnDeleteProduct_Loaded" Name="btnDeleteProduct" Content="Удалить товар" Click="btnDeleteOrder_Click" Uid="{Binding ProductArticleNumber}"/>
+                                    <Button Background="#498c51"  Loaded="btnDeleteProduct_Loaded" Margin="5 0 0 0" Name="btnChangeProduct" Content="Изменить товар" Click="btnCHangeOrder_Click" Uid="{Binding ProductArticleNumber}"/>
+
+                                </StackPanel>
+                                <StackPanel Grid.Column="2" HorizontalAlignment="Center">
+                                    <TextBlock Name="tbSale" Uid="{Binding ProductDiscountAmount}" Loaded="tbSale_Loaded" Text="{Binding ProductDiscountAmount, StringFormat={}скидка - {0:}%}"/>
+                                </StackPanel>
+                            </Grid>
+                        </Border>
+                       
+                    </DataTemplate>
+                </ListView.ItemTemplate>
+                <ListView.ContextMenu>
+                    <ContextMenu>
+                        <MenuItem Header="Добавить к заказу" Click="MenuItem_Click" Uid="{Binding ProductArticleNumber}"></MenuItem>
+                    </ContextMenu>
+                </ListView.ContextMenu>
+            </ListView>
+        </StackPanel>
+
+    </Grid>
+----
+Xaml.cs
+public partial class PageProducts : Page
+    {
+        User user;
+        public static bool isGuest;
+        Product product1 = new Product();
+
+        public PageProducts(User user) // для авторизированного юзера
+        {
+            InitializeComponent();
+            this.user = user;
+            db.tbe = new Entities();
+            lvProduct.ItemsSource = db.tbe.Product.ToList();
+            lvProduct.SelectedValuePath = "ProductArticleNumber";
+            tbFirst.Text = lvProduct.Items.Count.ToString();
+            tblast.Text = db.tbe.Product.Count().ToString();
+            tbNameUser.Text = user.FullName;
+            isGuest = false;
+
+            if (user.UserRole == 3)
+            {
+                btnAllOrder.Visibility = Visibility.Collapsed;
+                btnAddProduct.Visibility = Visibility.Collapsed;
+
+
+            }
+            else if (user.UserRole == 2)
+            {
+                btnAllOrder.Visibility = Visibility.Visible;
+                btnAddProduct.Visibility = Visibility.Collapsed;
+            }
+
+
+        }
+        public PageProducts() // для гостя
+        {
+            InitializeComponent();
+            db.tbe = new Entities();
+            lvProduct.ItemsSource = db.tbe.Product.ToList();
+            lvProduct.SelectedValuePath = "ProductArticleNumber";
+            tbFirst.Text = lvProduct.Items.Count.ToString();
+            tblast.Text = db.tbe.Product.Count().ToString();
+            tbNameUser.Text = "Гость";
+            isGuest = true;
+
+            if (user == null)
+            {
+                btnAllOrder.Visibility = Visibility.Collapsed;
+                btnAddProduct.Visibility = Visibility.Collapsed;
+
+
+            }
+
+
+        }
+        private void cmbSorted_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            filtresMethod();
+        }
+
+        private void tbSearch_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            filtresMethod();
+        }
+
+
+        private void filtresMethod() // общий метод сортировки и фильтрации
+        {
+            List<Product> products = db.tbe.Product.ToList();
+            if (cmbSorted.SelectedItem != null)
+            {
+                ComboBoxItem comboBoxItem = (ComboBoxItem)cmbSorted.SelectedItem;
+                switch (comboBoxItem.Content)
+                {
+
+                    case "По умолчанию":
+                        {
+                            products = products;
+                            break;
+                        }
+                    case "По возрастанию стоимости":
+                        {
+                            products = products.OrderBy(x => x.ProductCost).ToList();
+                            break;
+                        }
+                    case "По убыванию стоимости":
+                        {
+
+                            products = products.OrderByDescending(x => x.ProductCost).ToList();
+                            break;
+                        }
+                }
+
+
+            }
+            if (cmbFiltres.SelectedItem != null)
+            {
+                ComboBoxItem comboBoxItem = (ComboBoxItem)cmbFiltres.SelectedItem;
+                switch (comboBoxItem.Content)
+                {
+
+                    case "Все диапазоны":
+                        {
+                            products = products;
+                            break;
+                        }
+
+                    case "0-9,99%":
+                        {
+                            products = products.Where(x => x.ProductDiscountAmount >= 0 && x.ProductDiscountAmount <= 9.99).ToList();
+                            break;
+                        }
+                    case "10-14,99%":
+                        {
+                            products = products.Where(x => x.ProductDiscountAmount >= 10 && x.ProductDiscountAmount <= 14.99).ToList();
+
+                            break;
+                        }
+                    case "15% и более":
+                        {
+                            products = products.Where(x => x.ProductDiscountAmount >= 15).ToList();
+
+                            break;
+                        }
+
+                }
+            }
+            if (tbSearch.Text != null)
+            {
+                if (!string.IsNullOrEmpty(tbSearch.Text))
+                {
+                    products = products.Where(x => x.ProductName.ToLower().Contains(tbSearch.Text)).ToList();
+                }
+            }
+            if (products.Count == 0 || products.Count == null)
+            {
+                MessageBox.Show("Отсутствуют критерии, удовлетворяющие результатам поиска!");
+            }
+            lvProduct.ItemsSource = products;
+            tblast.Text = lvProduct.Items.Count.ToString();
+        }
+
+        private void TextBlock_Loaded(object sender, RoutedEventArgs e)
+        {
+            TextBlock textBlock = (TextBlock)sender;
+            if (textBlock.Uid != null)
+            {
+                textBlock.Visibility = Visibility.Visible;
+            }
+            else
+            {
+                textBlock.Visibility = Visibility.Collapsed;
+            }
+
+        }
+
+        private void tbFirst_Loaded(object sender, RoutedEventArgs e)
+        {
+
+            List<Product> products = db.tbe.Product.ToList();
+            tbFirst.Text = db.tbe.Product.ToList().Count().ToString();
+            lvProduct.ItemsSource = products;
+        }
+
+        private void tblast_Loaded(object sender, RoutedEventArgs e)
+        {
+
+            List<Product> products = db.tbe.Product.ToList();
+            tblast.Text = lvProduct.Items.Count.ToString();
+            lvProduct.ItemsSource = products;
+        }
+
+        private void btnOrder_Click(object sender, RoutedEventArgs e)
+        {
+            Window1 window = new Window1(user);
+            window.Show();
+            window.Closing += (obj, args) =>
+            {
+                if (articleProducts.Count == 0)
+                {
+                    btnOrder.Visibility = Visibility.Collapsed;
+
+                }
+                else
+                {
+                    btnOrder.Visibility = Visibility.Visible;
+                }
+            };
+
+        }
+        public static List<string> articleProducts = new List<string>();
+        private void MenuItem_Click(object sender, RoutedEventArgs e)
+        {
+            btnOrder.Visibility = Visibility.Visible;
+            articleProducts.Add(lvProduct.SelectedValue.ToString());
+
+        }
+
+        private void tbSale_Loaded(object sender, RoutedEventArgs e)
+        {
+            TextBlock textBlock = (TextBlock)sender;
+            if (textBlock.Uid != null)
+            {
+                textBlock.Visibility = Visibility.Visible;
+
+            }
+            else
+            {
+                textBlock.Visibility = Visibility.Collapsed;
+            }
+        }
+
+        private void btnDeleteOrder_Click(object sender, RoutedEventArgs e)
+        {
+
+            Button button = (Button)sender;
+            string id = button.Uid;
+            Product product = db.tbe.Product.FirstOrDefault(x => x.ProductArticleNumber == id);
+            foreach (var item in db.tbe.OrderProduct.Where(x => x.ProductArticleNumber == id))
+            {
+
+                db.tbe.OrderProduct.Remove(item);
+            }
+            var result = MessageBox.Show("Подтвердите удаление товара", "Системное диалоговое окно", MessageBoxButton.YesNo, MessageBoxImage.Question);
+            if(result == MessageBoxResult.Yes)
+            {
+                db.tbe.Product.Remove(product);
+                db.tbe.SaveChanges();
+                MessageBox.Show("Товар " + product.ProductName + " был удален");
+                NavigationService.Navigate(new PageProducts(user));
+            }
+            else
+            {
+                MessageBox.Show("Товар " + product.ProductName + " не удален");
+                NavigationService.Navigate(new PageProducts(user));
+            }
+          
+
+
+        }
+
+        private void btnCHangeOrder_Click(object sender, RoutedEventArgs e)
+        {
+            Button button = (Button)sender;
+            string id = button.Uid;
+            Product product = db.tbe.Product.FirstOrDefault(x => x.ProductArticleNumber == id);
+            WindowChangeProduct windowChangeProduct = new WindowChangeProduct(product);
+            windowChangeProduct.Show();
+            windowChangeProduct.Closing += (bin, args) =>
+            {
+                NavigationService.Navigate(new PageProducts(user));
+                lvProduct.ItemsSource = db.tbe.Product.ToList();
+            };
+        }
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            NavigationService.Navigate(new EditedOrder());
+        }
+
+        private void btnAddProduct_Click(object sender, RoutedEventArgs e)
+        {
+            AddProductAdmin addProduct = new AddProductAdmin();
+            addProduct.Show();
+        }
+
+        private void btnDeleteProduct_Loaded(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                Button btnDeleteProduct = sender as Button;
+                Button btnChangeProduct = sender as Button;
+                if (user == null)
+                {
+
+
+                    btnDeleteProduct.Visibility = Visibility.Collapsed;
+                    btnChangeProduct.Visibility = Visibility.Collapsed;
+
+
+
+                }
+
+            }
+
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+            }
+
+        }
+
+        private void btnAllOrder_Loaded(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void btnExit_Click(object sender, RoutedEventArgs e)
+        {
+
+            NavigationService.Navigate(new AuthorizationPage());
+        }
+    }
+======================================================================
+======================================================================
+Auth page авторизация
+
+   <Grid>
+      
+            <Grid.RowDefinitions>
+                <RowDefinition Height="*"/>
+                <RowDefinition Height="5*"/>
+                <RowDefinition Height="*"/>
+            </Grid.RowDefinitions>
+            <StackPanel Grid.Row="0" HorizontalAlignment="Center">
+            <TextBlock FontFamily="Comic Sans MS"  Margin="0 15 0 0" Style="{StaticResource tbStyleFont}" Text="Авторизация" FontSize="25"></TextBlock>
+            </StackPanel>
+
+
+            <StackPanel Grid.Row="1" HorizontalAlignment="Center" >
+            <GroupBox FontFamily="Comic Sans MS"  Name="gpLogin" Margin="0 35 0 0" Header="Введите логин">
+                <TextBox FontFamily="Comic Sans MS"  MaxLength="15" Name="tbLogin" Text="loginDEpxl2018"/>
+                </GroupBox>
+            <GroupBox FontFamily="Comic Sans MS"  Name="gpPassword" Margin="0 35 0 0" Header="Введите пароль">
+                <TextBox FontFamily="Comic Sans MS" MaxLength="15" Name="tbPassword" Text="P6h4Jq"/>
+                </GroupBox>
+            <TextBlock FontFamily="Comic Sans MS"  Name="tbAuth" ></TextBlock>
+            </StackPanel>
+
+            <StackPanel Grid.Row="2" Orientation="Horizontal"  HorizontalAlignment="Center">
+            <Button FontFamily="Comic Sans MS"  Click="btnAuth_Click" Name="btnAuth" Content="Авторизоваться" Loaded="btnAuth_Loaded" Height="25"/>
+            <Button FontFamily="Comic Sans MS"  Margin="15 0 0 0" Name="goGuest" Content="Войти как гость" Click="goGuest_Click"  Loaded="btnAuth_Loaded" Height="25"/>
+
+            </StackPanel>
+    
+    </Grid>
+
+xaml.cs
+
+    public partial class AuthorizationPage : Page
+    {
+        public static bool UserRole;
+        private DispatcherTimer dispatcher;
+        public static bool checkedCaptcha;
+        private int counter = 10;
+        public AuthorizationPage()
+        {
+            InitializeComponent();
+            dispatcher = new DispatcherTimer();
+            dispatcher.Interval = new TimeSpan(0, 0, 0, 1);
+            dispatcher.Tick += new EventHandler(TimerEnd);
+
+        }
+      
+        private void TimerEnd(object sender, EventArgs e)
+        {
+            try
+            {
+              
+                if (counter != 0)
+                {
+                    
+                    tbAuth.Text = "Новый код доступен через \n\t" + string.Format("00:00:{0}", counter) + " секунд ";
+
+
+                }
+                else
+                {
+                    btnAuth.IsEnabled = true;
+                    gpPassword.IsEnabled = true;
+                    gpLogin.IsEnabled = true;
+                   
+                    tbAuth.Visibility = Visibility.Collapsed;
+                    dispatcher.Stop();
+                }
+                counter--;
+
+            }
+            catch
+            {
+                MessageBox.Show("Дваайте еще раз попробуем");
+            }
+
+
+
+        }
+  
+        private void btnAuth_Click(object sender, RoutedEventArgs e)
+        {
+            User user = db.tbe.User.FirstOrDefault(x => x.UserPassword == tbPassword.Text && x.UserLogin == tbLogin.Text);
+            try
+            {
+                if (user == null)
+                {
+                    //tbLogin.Text != user.UserLogin && tbPassword.Text != user.UserPassword
+                    MessageBox.Show("Введенный логин и/или пароль неверен");
+                    Captcha captcha = new Captcha();
+                    captcha.Show();
+                    captcha.Closing += (obj, args) =>
+                    {
+                        if (!checkedCaptcha)
+                        {
+                            btnAuth.IsEnabled = false;
+                            gpPassword.IsEnabled = false;
+                            gpLogin.IsEnabled = false;
+                            counter = 10;
+                            dispatcher.Start();
+                        }
+                        
+                    };
+
+                }
+                else
+                {
+                    if (!string.IsNullOrEmpty(tbLogin.Text) && !string.IsNullOrEmpty(tbPassword.Text))
+                    {
+                        if (tbLogin.Text != null && tbPassword.Text != null)
+                        {
+
+
+                            if (user.UserLogin == tbLogin.Text)
+                            {
+                                if (user.UserPassword == tbPassword.Text)
+                                {
+
+                                    NavigationService.Navigate(new PageProducts(user));
+                                  
+                                }
+                                else
+                                {
+                                    MessageBox.Show("Пароль в системе отсутствует");
+                                }
+                            }
+                            else
+                            {
+                                MessageBox.Show("Логин в системе отсутствует");
+                            }
+
+                        }
+
+                    }
+                    else
+                    {
+                        MessageBox.Show("Неверный логин и/или пароль!");
+                    }
+                }
+
+
+
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+            }
+        }
+
+        private void goGuest_Click(object sender, RoutedEventArgs e)
+        {
+            NavigationService.Navigate(new PageProducts());
+        }
+
+        private void btnAuth_Loaded(object sender, RoutedEventArgs e) // крашу кнопки
+        {
+            btnAuth.Background = (SolidColorBrush)new SolidColorBrush(Color.FromRgb(73, 140, 81));
+            goGuest.Background = (SolidColorBrush)new SolidColorBrush(Color.FromRgb(73, 140, 81));
+        }
+
+        
+    }
+======================================================================
+======================================================================
+======================================================================
+PageOrder корзина Basket basket
+
+  <Page.Resources>
+        <BitmapImage x:Key="noPhoto" UriSource="\resources\picture.png"></BitmapImage>
+    </Page.Resources>
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="*"></RowDefinition>
+            <RowDefinition Height="5*"></RowDefinition>
+            <RowDefinition Height="*"></RowDefinition>
+        </Grid.RowDefinitions>
+        <StackPanel Grid.Row="0" HorizontalAlignment="Center">
+            <TextBlock Text="Корзина" Style="{StaticResource tbStyleFont}" FontSize="36" ></TextBlock>
+        </StackPanel>
+        <StackPanel Grid.Row="1">
+            <ListView  Name="lvOrder" ScrollViewer.VerticalScrollBarVisibility="Disabled" Height="230" Width="800">
+                <ListView.ItemTemplate>
+                    <DataTemplate>
+                        <Border Name="border"  Background="{Binding colorBrush}" >
+                            <Grid >
+                                <Grid.ColumnDefinitions>
+                                    <ColumnDefinition Width="0.5*"/>
+                                    <ColumnDefinition Width="1*"/>
+                                    <ColumnDefinition Width="*"/>
+                                </Grid.ColumnDefinitions>
+                                <StackPanel Grid.Column="0">
+                                    <Image  Height="100" Source="{Binding ProductPhoto, TargetNullValue={StaticResource noPhoto}}"></Image>
+                                </StackPanel>
+
+                                <StackPanel Grid.Column="1">
+
+                                    <TextBlock Text="{Binding ProductName}"/>
+                                    <TextBlock Text="{Binding ProductDescription}"/>
+                                    <TextBlock Text="{Binding manufacture.manufactureName}"/>
+                                    <StackPanel Orientation="Horizontal">
+                                        <TextBlock Text=" "></TextBlock>
+                                        <TextBlock Text="{Binding ProductCost,  StringFormat={}{0:0}}" TextDecorations="Strikethrough" Uid="{Binding ProductDiscountAmount}" Loaded="TextBlock_Loaded"/>
+                                        <TextBlock Text="   "></TextBlock>
+                                        <TextBlock Text="{Binding ActualPrice, StringFormat={}{0:0}руб.}"/>
+                                    </StackPanel>
+                                </StackPanel>
+                                <StackPanel Grid.Column="2">
+                                    <Button Content="Удалить из заказа" Name="btnDelete" Click="btnDelete_Click"/>
+                                    <GroupBox Header="Количество товара">
+                                        <TextBox>
+                                            <TextBox.ToolTip>Введите количество товара</TextBox.ToolTip>
+                                        </TextBox>
+                                    </GroupBox>
+                                    <TextBlock Name="tbSummaZakaza"></TextBlock>
+                                    <TextBlock Name="tbSaleZakaza"></TextBlock>
+                                </StackPanel>
+                            </Grid>
+                        </Border>
+                    
+                    </DataTemplate>
+                </ListView.ItemTemplate>
+            </ListView>
+            <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center">
+                <GroupBox  Header="Выберите пункт выдачи (ПВЗ)">
+                    <ComboBox Name="cmbOrderPoint"></ComboBox>
+                </GroupBox>
+
+                <Button  FontFamily="Comic Sans MS"   Background="#498c51" Margin="15 0 0 0"  Content="Сформировать заказ" Name="btnFormOrder" Click="btnFormOrder_Click"/>
+            </StackPanel>
+         
+        </StackPanel>
+    </Grid>
+
+ public static  List<OrderProduct> orderProducts = db.tbe.OrderProduct.ToList();
+        public PadeOrder()
+        {
+            InitializeComponent();
+
+            cmbOrderPoint.ItemsSource = db.tbe.Point.ToList();
+            cmbOrderPoint.SelectedValuePath = "idPickupPoint";
+            cmbOrderPoint.DisplayMemberPath = "displayPoint";
+            cmbOrderPoint.SelectedIndex = 0;
+           
+        }
+
+        private void btnDelete_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void btnFormOrder_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void TextBlock_Loaded(object sender, RoutedEventArgs e)
+        {
+            TextBlock textBlock = (TextBlock)sender;
+            if (textBlock.Uid != null)
+            {
+                textBlock.Visibility = Visibility.Visible;
+            }
+            else
+            {
+                textBlock.Visibility = Visibility.Collapsed;
+            }
+        }
+
+
+======================================================================
+Edited Order работа с заказами
+
+  <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="*"></RowDefinition>
+            <RowDefinition Height="5*"></RowDefinition>
+            <RowDefinition Height="*"></RowDefinition>
+        </Grid.RowDefinitions>
+        <TextBlock Text="Работа с заказми" Style="{StaticResource tbStyleFont}" Grid.Row="0" HorizontalAlignment="Center" FontSize="36"></TextBlock>
+        <StackPanel Grid.Row="1">
+
+
+            <StackPanel Grid.Row="0" Margin="0 -5 0 0">
+
+                <ListView Name="lvOrderEdited" Width="750" Height="300" >
+                    <ListView.ItemTemplate>
+                        <DataTemplate>
+                            <Grid>
+                                <Grid.RowDefinitions>
+                                    <RowDefinition Height="*"></RowDefinition>
+                                    <RowDefinition Height="*"></RowDefinition>
+                                    <RowDefinition Height="*"></RowDefinition>
+                                </Grid.RowDefinitions>
+                                <Grid.ColumnDefinitions>
+                                    <ColumnDefinition Width="0*"></ColumnDefinition>
+                                    <ColumnDefinition Width="3*"></ColumnDefinition>
+                                </Grid.ColumnDefinitions>
+                                <Border x:Name="border" Loaded="border_Loaded" Uid="{Binding order.OrderID}" BorderThickness="3" CornerRadius="2">
+                                    <StackPanel Width="710" HorizontalAlignment="Center">
+                                        <StackPanel Grid.Row="0" Grid.Column="0">
+                                            <StackPanel >
+                                                <TextBlock   FontFamily="Comic Sans MS" Text="{Binding order.OrderID, StringFormat={}Номер заказа > {0:}}"></TextBlock>
+                                                <TextBlock   FontFamily="Comic Sans MS" TextWrapping="Wrap" Name="tbSostavZakaza" Uid="{Binding order.OrderID}"></TextBlock>
+                                            </StackPanel>
+                                            <StackPanel>
+                                                <TextBlock   FontFamily="Comic Sans MS" Text="{Binding order.OrderDate,  StringFormat={}Дата заказа > {0:dd MMMM yyyy}, ConverterCulture=ru}"></TextBlock>
+                                                <TextBlock   FontFamily="Comic Sans MS" Text="{Binding order.OrderDeliveryDate, StringFormat={}Дата выдачи заказа >  {0:dd MMMM yyyy}, ConverterCulture=ru}"></TextBlock>
+                                            </StackPanel>
+                                        </StackPanel>
+                                        <TextBlock   FontFamily="Comic Sans MS" Name="tbSummZakaza" Uid="{Binding order.OrderID}" Loaded="tbSummZakaza_Loaded"></TextBlock>
+                                        <TextBlock   FontFamily="Comic Sans MS" Name="tbAllSale" Uid="{Binding order.OrderID}" Loaded="tbAllSale_Loaded"></TextBlock>
+                                        <TextBlock   FontFamily="Comic Sans MS" Text="{Binding order.User.UserSurname, StringFormat={}Фамилия клиента > {0:}}"></TextBlock>
+                                        <StackPanel Grid.Column="1" Orientation="Horizontal" >
+                                            <Button   FontFamily="Comic Sans MS"   Background="#498c51" Name="btnChangeOrder" Content="Изменить детали заказа" Uid="{Binding order.OrderID}" Click="btnChangeOrder_Click"></Button>
+                                            <Button  Margin="15 0 0 0" FontFamily="Comic Sans MS"   Background="#498c51" Name="btnChange" Content="Изменить заказ" Uid="{Binding order.OrderID}" Click="btnChange_Click"></Button>
+
+                                        </StackPanel>
+                                    
+                                    </StackPanel>
+
+                                </Border>
+
+
+                            </Grid>
+                        </DataTemplate>
+                    </ListView.ItemTemplate>
+                </ListView>
+
+
+
+            </StackPanel>
+
+        </StackPanel>
+        <Grid Grid.Row="2">
+
+
+            <StackPanel HorizontalAlignment="Left" Height="50" Margin="25 25 0 0" Grid.Row="1">
+                <Button FontFamily="Comic Sans MS" Background="#498c51" Content="Назад" Name="btnBack" Click="btnBack_Click"/>
+            </StackPanel>
+            <StackPanel HorizontalAlignment="Center"  Grid.Row="0" Grid.Column="1" Orientation="Horizontal" Height="50">
+                <GroupBox FontFamily="Comic Sans MS"  Header="Сортировка заказа по стоимости">
+                    <ComboBox FontFamily="Comic Sans MS"  Name="cmbSorted" SelectionChanged="cmbSorted_SelectionChanged">
+                        <ComboBoxItem FontFamily="Comic Sans MS" >По умолчанию</ComboBoxItem>
+                        <ComboBoxItem FontFamily="Comic Sans MS" >По возрастанию</ComboBoxItem>
+                        <ComboBoxItem FontFamily="Comic Sans MS" >По убыванию</ComboBoxItem>
+                    </ComboBox>
+
+
+
+                </GroupBox>
+                <GroupBox Header="Фильтрация заказа по скидке">
+                    <ComboBox FontFamily="Comic Sans MS"  Name="cmbFiltres" SelectionChanged="cmbSorted_SelectionChanged">
+                        <ComboBoxItem FontFamily="Comic Sans MS" >Все диапазоны</ComboBoxItem>
+                        <ComboBoxItem FontFamily="Comic Sans MS">0-10%</ComboBoxItem>
+                        <ComboBoxItem FontFamily="Comic Sans MS">11-14%</ComboBoxItem>
+                        <ComboBoxItem FontFamily="Comic Sans MS">15% и более</ComboBoxItem>
+                    </ComboBox>
+                </GroupBox>
+            </StackPanel>
+            <StackPanel HorizontalAlignment="Right" Height="50" Margin="0 25 25 0" Grid.Row="1">
+                <Button FontFamily="Comic Sans MS"  Background="#498c51" Content="Сброс фильтров" Name="btnOutFiltres" Click="btnOutFiltres_Click"/>
+            </StackPanel>
+        </Grid>
+
+    </Grid>
+
+xaml.cs
+ public partial class EditedOrder : Page
+    {
+        List<SummClass> order = new List<SummClass>();
+        public EditedOrder()
+        {
+            InitializeComponent();
+            listSortedFiltres();
+            lvOrderEdited.ItemsSource = order;
+        }
+        public static bool quantinyinStock;
+        private void border_Loaded(object sender, RoutedEventArgs e) // загрузка рамки по цвету количества товаров на складе
+        {
+            Border border = sender as Border;
+            int id = Convert.ToInt32(border.Uid);
+
+            List<OrderProduct> orderProduct = db.tbe.OrderProduct.Where(x => x.OrderID == id).ToList();
+            foreach (var item in orderProduct)
+            {
+
+                Product product1 = db.tbe.Product.FirstOrDefault(x => x.ProductArticleNumber == item.ProductArticleNumber);
+                if (item.Product.ProductQuantityInStock > 3)
+                {
+                    quantinyinStock = true;
+
+                }
+                else
+                {
+                    quantinyinStock = false;
+                    break;
+
+                }
+
+            }
+            if (quantinyinStock)
+            {
+                SolidColorBrush scb = (SolidColorBrush)new BrushConverter().ConvertFromString("#20b2aa");
+                border.BorderBrush = scb;
+
+            }
+            else
+            {
+                SolidColorBrush scb1 = (SolidColorBrush)new BrushConverter().ConvertFromString("#ff8c00");
+                border.BorderBrush = scb1;
+
+            }
+        }
+        private void tbSostavZakaza_Loaded_1(object sender, RoutedEventArgs e) // вывод состава заказа
+        {
+
+            string nameOrderProduct = "";
+            TextBlock textBlock = sender as TextBlock;
+            int id = Convert.ToInt32(textBlock.Uid);
+            List<OrderProduct> orderProduct = db.tbe.OrderProduct.Where(x => x.OrderID == id).ToList();
+            foreach (var item in orderProduct)
+            {
+
+                Product product1 = db.tbe.Product.FirstOrDefault(x => x.ProductArticleNumber == item.ProductArticleNumber);
+
+                nameOrderProduct += product1.ProductName + $"({item.Count} шт.) ";
+
+
+            }
+            textBlock.Text = "Состав заказа >  " + nameOrderProduct;
+
+        }
+
+        private void tbSummZakaza_Loaded(object sender, RoutedEventArgs e) // вывод суммы заказа
+        {
+
+            int summa = 0;
+            TextBlock textBlock = sender as TextBlock;
+            int id = Convert.ToInt32(textBlock.Uid);
+            List<OrderProduct> orderProduct = db.tbe.OrderProduct.Where(x => x.OrderID == id).ToList();
+            foreach (var item in orderProduct)
+            {
+
+                Product product1 = db.tbe.Product.FirstOrDefault(x => x.ProductArticleNumber == item.ProductArticleNumber);
+
+                summa += (int)product1.ProductCost * item.Count;
+
+
+            }
+            textBlock.Text = "Сумма заказа > " + Convert.ToString(summa);
+        }
+
+        public static List<int> orderFIltresSumm;
+        private void tbAllSale_Loaded(object sender, RoutedEventArgs e) // вывод скидки
+        {
+            double summa = 0;
+            double summa1 = 0;
+            double procent = 0;
+            TextBlock textBlock = sender as TextBlock;
+            int id = Convert.ToInt32(textBlock.Uid);
+            if (textBlock.Uid != null)
+            {
+                List<OrderProduct> orderProduct = db.tbe.OrderProduct.Where(x => x.OrderID == id).ToList();
+                foreach (var item in orderProduct)
+                {
+                    Product product1 = db.tbe.Product.FirstOrDefault(x => x.ProductArticleNumber == item.ProductArticleNumber);
+                    summa += (int)product1.ProductCost * item.Count; // просто цена
+
+                    summa1 += (int)(product1.ProductCost - (product1.ProductCost * product1.ProductDiscountAmount / 100)) * item.Count; // с учетом скидки
+
+
+                }
+                procent = (summa - summa1) / (summa / 100);
+                textBlock.Text = "Сумма с учетом скидки > " + summa1.ToString() + $"({procent} %) ";
+            }
+            else
+            {
+                textBlock.Text = "";
+            }
+        }
+
+
+
+
+        private void btnChangeOrder_Click(object sender, RoutedEventArgs e)
+        {
+            Button button = sender as Button;
+            int id = Convert.ToInt32(button.Uid);
+            Order order = db.tbe.Order.FirstOrDefault(x => x.OrderID == id);
+            WindowChangeOrderADM orderADM = new WindowChangeOrderADM(order);
+            orderADM.Show();
+        }
+
+        private void btnBack_Click(object sender, RoutedEventArgs e)
+        {
+            NavigationService.GoBack();
+        }
+
+        void listSortedFiltres() // метод для того, чтобы осуществить фильтрацию и сортировку по цене и скидке
+        {
+            foreach (var item in db.tbe.Order.ToList())
+            {
+                SummClass opl = new SummClass();
+                opl.order = item;
+                double sum = 0, sumDis = 0;
+                double discount = 0;
+                int orderid = item.OrderID;
+                foreach (var item2 in db.tbe.OrderProduct.Where(x => x.OrderID == item.OrderID))
+                {
+                    sum += (double)item2.Product.ProductCost * item2.Count;
+                    sumDis += (double)(item2.Product.ProductCost - (item2.Product.ProductCost / 100 * item2.Product.ProductDiscountAmount)) * item2.Count;
+                    string prodID = item2.ProductArticleNumber;
+                }
+                discount = (sum - sumDis) / (sum / 100);
+                opl.Summa = Convert.ToInt32(sum);
+                opl.SALE = Convert.ToInt32(discount);
+                order.Add(opl);
+            }
+        }
+        public void filtres() // общий метод сортировки и фильтрации
+        {
+            try
+            {
+                order.Clear();
+                listSortedFiltres();
+
+                if (cmbFiltres != null)
+                {
+                    if (cmbFiltres.SelectedItem != null)
+                    {
+                        ComboBoxItem cmb1 = (ComboBoxItem)cmbFiltres.SelectedItem;
+                        switch (cmb1.Content)
+                        {
+                            case "0-10%":
+                                {
+                                    order = order.Where(x => x.SALE >= 0 && x.SALE < 10).ToList();
+                                    break;
+                                }
+                            case "11-14%":
+                                {
+                                    order = order.Where(x => x.SALE > 11 && x.SALE <= 14).ToList();
+
+                                    break;
+                                }
+                            case "15% и более":
+                                {
+                                    order = order.Where(x => x.SALE > 15).ToList();
+                                    break;
+                                }
+                        }
+                    }
+                }
+
+                if (cmbSorted != null)
+                {
+                    if (cmbSorted.SelectedItem != null)
+                    {
+                        ComboBoxItem cmb = (ComboBoxItem)cmbSorted.SelectedItem;
+                        switch (cmb.Content)
+                        {
+                            case "По возрастанию":
+                                {
+                                    order = order.OrderBy(x => x.Summa).ToList();
+                                    break;
+                                }
+                            case "По убыванию":
+                                {
+                                    order = order.OrderByDescending(x => x.Summa).ToList();
+
+                                    break;
+                                }
+                        }
+                    }
+
+                }
+                if(order.Count == null || order.Count == 0)
+                {
+                    MessageBox.Show("Отсутствуют критерии, удовлетворяющие результатам поиска!");
+                }
+                lvOrderEdited.ItemsSource = order;
+
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+            }
+           
+           
+
+
+          
+
+        }
+        private void cmbSorted_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            filtres();
+        }
+
+        private void btnOutFiltres_Click(object sender, RoutedEventArgs e) // сброс фильтров
+        {
+         
+
+            cmbSorted.SelectedValue = order;
+            cmbFiltres.SelectedValue = order;
+
+        }
+
+        private void btnChange_Click(object sender, RoutedEventArgs e)
+        {
+            Button button = sender as Button;
+            int id = Convert.ToInt32(button.Uid);
+            Order order = db.tbe.Order.FirstOrDefault(x => x.OrderID == id);
+            WindowChangeOrder orderchange = new WindowChangeOrder(order);
+            orderchange.Show();
+        }
+    }
+======================================================================
+AddProductAdmin добавление товаров добавление товара
+ <Grid >
+        <Grid.RowDefinitions>
+
+            <RowDefinition Height="5*"></RowDefinition>
+
+        </Grid.RowDefinitions>
+        <StackPanel Grid.Row="1" >
+            <GroupBox Header="Введите артикул товара" FontFamily="Comic Sans MS">
+                <TextBox FontFamily="Comic Sans MS" Name="tbArcticle" MaxLength="7"></TextBox>
+            </GroupBox>
+            <GroupBox FontFamily="Comic Sans MS" Header="Введите наименование товара">
+                <TextBox FontFamily="Comic Sans MS" Name="tbNameProduct"></TextBox>
+            </GroupBox>
+            <GroupBox FontFamily="Comic Sans MS" Header="Введите описание товара">
+                <TextBox FontFamily="Comic Sans MS" Name="tbDescriptionProduct" TextWrapping="Wrap" Height="50"></TextBox>
+            </GroupBox>
+            <GroupBox FontFamily="Comic Sans MS" Header="Выберите категорию добавляемого товара">
+                <ComboBox FontFamily="Comic Sans MS" Name="cmbCategory"></ComboBox>
+            </GroupBox>
+            <GroupBox FontFamily="Comic Sans MS" Header="Выберите производителя">
+                <ComboBox FontFamily="Comic Sans MS" Name="cmbManufacturer"></ComboBox>
+            </GroupBox>
+            <GroupBox FontFamily="Comic Sans MS" Header="Укажите цену товара">
+                <TextBox FontFamily="Comic Sans MS" Name="tbCost"></TextBox>
+            </GroupBox>
+            <GroupBox FontFamily="Comic Sans MS" Header="Укажите скидку товара  (%)">
+                <TextBox FontFamily="Comic Sans MS" Name="tbSale"></TextBox>
+            </GroupBox>
+            <GroupBox FontFamily="Comic Sans MS" Header="Укажите количество товара на складе (запас)">
+                <TextBox FontFamily="Comic Sans MS" Name="tbQuantity"></TextBox>
+            </GroupBox>
+            <GroupBox FontFamily="Comic Sans MS" Header="Укажите единицу измерения">
+                <ComboBox FontFamily="Comic Sans MS" Name="cmbEdIzm"></ComboBox>
+            </GroupBox>
+            <GroupBox FontFamily="Comic Sans MS" Header="Укажите максимальную скидку (%)">
+                <TextBox FontFamily="Comic Sans MS" Name="tbMaxDiscount"></TextBox>
+            </GroupBox>
+            <GroupBox FontFamily="Comic Sans MS" Header="Укажите поставщика">
+                <ComboBox FontFamily="Comic Sans MS" Name="cmbSupplier"></ComboBox>
+            </GroupBox>
+            <Button Background="#498c51" FontFamily="Comic Sans MS" Height="50" Content="Добавить" Name="addProduct" Click="addProduct_Click"></Button>
+        </StackPanel>
+    </Grid>
+  public partial class AddProductAdmin : Window
+    {
+        public AddProductAdmin()
+        {
+            InitializeComponent();
+            cmbCategory.ItemsSource = db.tbe.ProductCategory.ToList();
+            cmbCategory.SelectedValuePath = "ProductCategoryID";
+            cmbCategory.DisplayMemberPath = "ProductCategoryName";
+
+            cmbManufacturer.ItemsSource = db.tbe.manufacture.ToList();
+            cmbManufacturer.SelectedValuePath = "idManufacture";
+            cmbManufacturer.DisplayMemberPath = "manufactureName";
+
+            cmbEdIzm.ItemsSource = db.tbe.edIzm.ToList();
+            cmbEdIzm.SelectedValuePath = "idEdIzm";
+            cmbEdIzm.DisplayMemberPath = "edenicaizm";
+
+            cmbSupplier.ItemsSource = db.tbe.supplier.ToList();
+            cmbSupplier.SelectedValuePath = "idSupplier";
+            cmbSupplier.DisplayMemberPath = "supplierName";
+            addProduct.Background = (SolidColorBrush)new SolidColorBrush(Color.FromRgb(73, 140, 81));
+        }
+
+        private void addProduct_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                if (!string.IsNullOrEmpty(tbArcticle.Text))
+                {
+                    if (!string.IsNullOrEmpty(tbNameProduct.Text))
+                    {
+                        if (!string.IsNullOrEmpty(tbDescriptionProduct.Text))
+                        {
+
+                            if (cmbCategory.SelectedItem != null)
+                            {
+                                if (cmbCategory != null)
+                                {
+                                    if (cmbManufacturer.SelectedItem != null)
+                                    {
+                                        if (cmbManufacturer != null)
+                                        {
+                                            if (!string.IsNullOrEmpty(tbCost.Text))
+                                            {
+                                                if (!string.IsNullOrEmpty(tbMaxDiscount.Text))
+                                                {
+                                                    if (!string.IsNullOrEmpty(tbSale.Text))
+                                                    {
+                                                        if (!string.IsNullOrEmpty(tbQuantity.Text))
+                                                        {
+                                                            if (cmbEdIzm != null)
+                                                            {
+
+                                                                if (cmbEdIzm.SelectedItem != null)
+                                                                {
+                                                                    if (cmbSupplier.SelectedItem != null)
+                                                                    {
+                                                                        if (cmbSupplier != null)
+                                                                        {
+                                                                            Product product = new Product();
+                                                                            product.ProductArticleNumber = tbArcticle.Text;
+                                                                            product.ProductName = tbNameProduct.Text;
+                                                                            product.ProductDescription = tbDescriptionProduct.Text;
+                                                                            product.ProductCategory = Convert.ToInt32(cmbCategory.SelectedValue);
+                                                                            product.ProductManufacturer = Convert.ToInt32(cmbManufacturer.SelectedValue);
+                                                                            product.ProductCost = Convert.ToDecimal(tbCost.Text);
+                                                                            product.ProductDiscountAmount = Convert.ToInt32(tbSale.Text);
+                                                                            product.ProductQuantityInStock = Convert.ToInt32(tbQuantity.Text);
+                                                                            product.ProductStatus = null;
+                                                                            product.idEdIzm = Convert.ToInt32(cmbEdIzm.SelectedValue);
+                                                                            product.maxDiscount = Convert.ToInt32(tbMaxDiscount.Text);
+                                                                            product.idSupplier = Convert.ToInt32(cmbSupplier.SelectedValue);
+                                                                            product.ProductPhoto = null;
+                                                                            db.tbe.Product.Add(product);
+                                                                            db.tbe.SaveChanges();
+                                                                            MessageBox.Show("Товар был успешно добавлен");
+                                                                            this.Close();
+                                                                        }
+                                                                    }
+                                                                    else
+                                                                    {
+                                                                        MessageBox.Show("Заполните поставщика");
+                                                                    }
+                                                                }
+                                                                else
+                                                                {
+                                                                    MessageBox.Show("Заполните поставщика");
+                                                                }
+                                                            }
+                                                            else
+                                                            {
+                                                                MessageBox.Show("Заполните единицу измерения");
+                                                            }
+                                                        }
+                                                        else
+                                                        {
+                                                            MessageBox.Show("Заполните количество");
+                                                        }
+                                                    }
+                                                    else
+                                                    {
+                                                        MessageBox.Show("Заполните сумму");
+                                                    }
+                                                }
+                                                else
+                                                {
+                                                    MessageBox.Show("Заполните максимальную скидку");
+                                                }
+                                            }
+                                            else
+                                            {
+                                                MessageBox.Show("Заполните цену");
+                                            }
+                                        }
+                                        else
+                                        {
+                                            MessageBox.Show("Заполните производителя");
+                                        }
+                                    }
+                                    else
+                                    {
+                                        MessageBox.Show("Заполните производителя");
+                                    }
+                                }
+                                else
+                                {
+                                    MessageBox.Show("Заполните категорию");
+                                }
+                            }
+                            else
+                            {
+                                MessageBox.Show("Заполните категорию");
+                            }
+                        }
+                        else
+                        {
+                            MessageBox.Show("Заполните описание");
+                        }
+                    }
+                    else
+                    {
+                        MessageBox.Show("Заполните наименование");
+                    }
+                }
+                else
+                {
+                    MessageBox.Show("Заполните артикль");
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+            }
+         
+        }
+
+    }
+======================================================================
+WindowChangeOrder изменение заказа
+   <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="*"></RowDefinition>
+            <RowDefinition Height="5*"></RowDefinition>
+            <RowDefinition Height="*"></RowDefinition>
+        </Grid.RowDefinitions>
+        <StackPanel Grid.Row="1">
+            <GroupBox Header="Изменить статус заказа">
+                <ComboBox Name="cmbStatus" SelectionChanged="cmbStatus_SelectionChanged"></ComboBox>
+            </GroupBox>
+            <GroupBox Header="Изменить дату доставки">
+                <DatePicker Name="dpDeliveryDate"></DatePicker>
+            </GroupBox>
+            <GroupBox Header="Изменить дату оформления заказа">
+                <DatePicker Name="dpOrderDate"></DatePicker>
+            </GroupBox>
+            <GroupBox Header="Изменить пункт выдачи">
+                <ComboBox Name="cmbChangeOrderPoing" SelectionChanged="changeOrderPoint_SelectionChanged"></ComboBox>
+            </GroupBox>
+
+            <GroupBox Header="Изменить получателя">
+                <ComboBox Name="cmbChangeClient" SelectionChanged="changeOrderPoint_SelectionChanged"></ComboBox>
+            </GroupBox>
+            <GroupBox Header="Изменить код получения">
+                <TextBox Name="tbCode" MaxLength="3"></TextBox>
+            </GroupBox>
+            <Button Background="#498c51"  HorizontalAlignment="Center" Name="changeOrder" Content="Изменить" Click="changeOrder_Click"></Button>
+        </StackPanel> 
+    </Grid>
+   public partial class WindowChangeOrder : Window
+    {
+        Order order;
+        public WindowChangeOrder(Order order)
+        {
+            InitializeComponent();
+            this.order = order;
+            cmbStatus.ItemsSource = db.tbe.statusChange.ToList();
+            cmbStatus.SelectedValuePath = "idStatus";
+            cmbStatus.DisplayMemberPath = "statusName";
+            cmbStatus.SelectedValue = order.OrderStatus;
+
+            dpDeliveryDate.SelectedDate = order.OrderDeliveryDate;
+            dpOrderDate.SelectedDate = order.OrderDate;
+            cmbChangeOrderPoing.ItemsSource = db.tbe.Point.ToList();
+            cmbChangeOrderPoing.SelectedValuePath = "idPickupPoint";
+            cmbChangeOrderPoing.DisplayMemberPath = "displayPoint";
+            cmbChangeOrderPoing.SelectedValue = order.OrderPickupPoint;
+            
+            cmbChangeClient.ItemsSource = db.tbe.User.ToList();
+            cmbChangeClient.SelectedValuePath = "UserID";
+            cmbChangeClient.DisplayMemberPath = "FullName";
+            if (order.OrderClientsId != null)
+            {
+                cmbChangeClient.SelectedValue = order.OrderClientsId;   
+            }
+
+            tbCode.Text = order.Code.ToString();
+          
+
+
+
+
+
+        }
+
+        private void cmbStatus_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+
+        }
+
+        private void changeOrderPoint_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+
+        }
+
+        private void changeOrder_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                order.OrderStatus = Convert.ToInt32(cmbStatus.SelectedValue);
+                order.OrderDeliveryDate = (DateTime)dpDeliveryDate.SelectedDate;
+                order.OrderDate = (DateTime)dpOrderDate.SelectedDate;
+                order.OrderPickupPoint = Convert.ToInt32(cmbChangeOrderPoing.SelectedValue);
+                order.OrderClientsId = Convert.ToInt32(cmbChangeClient.SelectedValue);
+                order.Code = Convert.ToInt32(tbCode.Text);
+                db.tbe.SaveChanges();
+                MessageBox.Show("Я изменилъ");
+
+
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);    
+            }
+          
+        }
+    }
+======================================================================
+WindowChageOrderADM изменение деталей заказа
+  <Grid>
+        <StackPanel>
+            <GroupBox Header="Изменение статуса заказа">
+                <ComboBox Name="cmbStatus" SelectionChanged="cmb_SelectionChanged">
+
+                </ComboBox>
+            </GroupBox>
+            <GroupBox Header="Изменение даты доставки">
+                <DatePicker Name="datePicker" SelectedDateChanged="datePicker_SelectedDateChanged" SelectedDateFormat="Short">
+
+                </DatePicker>
+            </GroupBox>
+            <StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
+              
+                <Button Background="#498c51" Content="Выйти" Name="btnBack" Click="btnBack_Click"></Button>
+                <Button Margin="15 0 0 0" Background="#498c51" Content="Сохранить" Name="btnChange" Click="btnChange_Click"></Button>
+            </StackPanel>
+            
+        </StackPanel>
+        
+    </Grid>
+    public partial class WindowChangeOrderADM : Window
+    {
+        Order order;
+        public WindowChangeOrderADM(Order order)
+        {
+            InitializeComponent();
+            this.order = order;
+
+            datePicker.SelectedDate = order.OrderDate;
+            cmbStatus.ItemsSource = db.tbe.statusChange.ToList();
+            cmbStatus.SelectedValuePath = "idStatus";
+            cmbStatus.DisplayMemberPath = "statusName";
+            cmbStatus.SelectedValue = order.OrderStatus;
+
+
+
+        }
+
+        private void cmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+
+        }
+
+        private void btnChange_Click(object sender, RoutedEventArgs e)
+        {
+
+            if (cmbStatus != null)
+            {
+                if (cmbStatus.SelectedIndex != -1)
+                {
+                    if (datePicker != null)
+                    {
+                        if (datePicker.SelectedDate != null)
+                        {
+
+                            DateTime dt = datePicker.SelectedDate.Value;
+
+                            order.OrderStatus = Convert.ToInt32(cmbStatus.SelectedValue);
+                            order.OrderDate = dt;
+                            db.tbe.SaveChanges();
+                            MessageBox.Show("ок");
+                            this.Close();
+                        }
+
+                    }
+                }
+            }
+
+
+        }
+
+        private void btnBack_Click(object sender, RoutedEventArgs e)
+        {
+            this.Close();
+        }
+
+        private void datePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
+        {
+
+        }
+    }
+
+
+======================================================================
+WindowChangeProduct.xaml
+   <Grid>
+        <Grid.RowDefinitions>
+        
+            <RowDefinition Height="5*"/>
+        </Grid.RowDefinitions>
+        <StackPanel Grid.Row="0">
+            <GroupBox Header="Изменить наименование товара">
+                <TextBox Name="tbProductName"></TextBox>
+            </GroupBox>
+            <GroupBox Header="Изменить описание товара">
+                <TextBox Name="tbProductDescription"></TextBox>
+            </GroupBox>
+            <GroupBox Header="Изменить поставщика">
+                <ComboBox Name="cmbProductSupplier"></ComboBox>
+            </GroupBox>
+            <GroupBox Header="Изменить старую цену">
+                <TextBox Name="tbOldPrice"></TextBox>
+            </GroupBox>
+           
+            <GroupBox Header="Изменить процент скидки">
+                <TextBox Name="tbSale"></TextBox>
+            </GroupBox>
+            <Button  FontFamily="Comic Sans MS"  Background="#498c51" Content="Изменить" Name="btnChange" Click="btnChange_Click"/>
+        </StackPanel>
+    </Grid>
+
+ public partial class WindowChangeProduct : Window
+    {
+        Product product;
+        public WindowChangeProduct(Product product)
+        {
+            InitializeComponent();
+            this.product = product;
+            tbProductName.Text = product.ProductName;
+            tbProductDescription.Text = product.ProductDescription;
+            cmbProductSupplier.ItemsSource = db.tbe.supplier.ToList();
+            cmbProductSupplier.SelectedValuePath = "idSupplier";
+            cmbProductSupplier.DisplayMemberPath = "supplierName";
+            cmbProductSupplier.SelectedValue = product.idSupplier.ToString();
+            tbOldPrice.Text = product.ProductCost.ToString();
+            tbSale.Text = product.ProductDiscountAmount.ToString();
+        }
+
+        private void btnChange_Click(object sender, RoutedEventArgs e)
+        {
+            if(!string.IsNullOrEmpty(tbProductName.Text) && !string.IsNullOrEmpty(tbProductDescription.Text) && !string.IsNullOrEmpty(tbOldPrice.Text)  && !string.IsNullOrEmpty(tbSale.Text) && cmbProductSupplier.SelectedIndex != null && cmbProductSupplier != null)
+            {
+                product.ProductName = tbProductName.Text;
+                product.ProductDescription = tbProductDescription.Text;
+                product.idSupplier = Convert.ToInt32(cmbProductSupplier.SelectedValue);
+                product.ProductCost = Convert.ToDecimal(tbOldPrice.Text);
+                product.ProductDiscountAmount = Convert.ToInt32(tbSale.Text);
+                db.tbe.SaveChanges();
+                this.Close();
+                MessageBox.Show("Готово");
+              
+            }
+
+        }
+    }
+
+======================================================================
+WindowOrder формирование заказа заказ формирование
+
+  <Window.Resources>
+      
+            <BitmapImage x:Key="noPhoto" UriSource="\resources\picture.png"></BitmapImage>
+
+    </Window.Resources>
+    <Grid>
+      
+    
+        <Grid>
+            <Grid.RowDefinitions>
+                <RowDefinition Height="*"></RowDefinition>
+                <RowDefinition Height="5*"></RowDefinition>
+                <RowDefinition Height="*"></RowDefinition>
+            </Grid.RowDefinitions>
+           
+            <StackPanel Grid.Row="1">
+                <ListView  Name="lvOrder" ScrollViewer.VerticalScrollBarVisibility="Disabled" Height="230" Width="800"   >
+                    <ListView.ItemTemplate>
+                        <DataTemplate>
+                            <Grid  Background="{Binding colorBrush}" Width="770" >
+                                <Grid.ColumnDefinitions>
+                                    <ColumnDefinition Width="0.5*"/>
+                                    <ColumnDefinition Width="1*"/>
+                                    <ColumnDefinition Width="*"/>
+                                </Grid.ColumnDefinitions>
+                                <StackPanel Grid.Column="0">
+                                    <Image  Height="100" Source="{Binding ProductPhoto, TargetNullValue={StaticResource noPhoto}}"></Image>
+                                </StackPanel>
+
+                                <StackPanel Grid.Column="1">
+
+                                    <TextBlock Text="{Binding ProductName}"/>
+                                    <TextBlock Text="{Binding ProductDescription}" TextWrapping="Wrap"/>
+                                    <TextBlock Text="{Binding manufacture.manufactureName}"/>
+                                    <StackPanel Orientation="Horizontal">
+                                        <TextBlock Text=" "></TextBlock>
+                                        <TextBlock Text="{Binding ProductCost,  StringFormat={}{0:0}}" TextDecorations="Strikethrough" Uid="{Binding ProductDiscountAmount}"/>
+                                        <TextBlock Text="   "></TextBlock>
+                                        <TextBlock Text="{Binding ActualPrice, StringFormat={}{0:0}руб.}"/>
+                                    </StackPanel>
+                                </StackPanel>
+                                <StackPanel Grid.Column="2">
+                                    <Button  Background="#498c51" Content="Удалить из заказа" Name="btnDelete" Click="btnDelete_Click" Uid="{Binding ProductArticleNumber}"/>
+                                    <GroupBox Header="Количество товара">
+                                        <TextBox Text="1" TextChanged="TextBox_TextChanged" Uid="{Binding ProductArticleNumber}">
+                                            <TextBox.ToolTip>Введите количество товара</TextBox.ToolTip>
+                                        </TextBox>
+                                    </GroupBox>
+                                  
+                                </StackPanel>
+                            </Grid>
+                        </DataTemplate>
+                    </ListView.ItemTemplate>
+                </ListView>
+                <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center">
+                    <ComboBox Name="cmbOrderPoint"></ComboBox>
+                    <Button Margin="15 0 0 0" Background="#498c51" Content="Сформировать заказ" Name="btnFormOrder" Click="btnFormOrder_Click"/>
+                    <TextBlock Name="tbSummaZakaza"  FontWeight="Bold"></TextBlock>
+                    <TextBlock Name="tbSaleZakaza" Margin="15 0 0 0"></TextBlock>
+                </StackPanel>
+
+            </StackPanel>
+        </Grid>
+    </Grid>
+
+   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);
+            }
+
+        }
+    }
+
+======================================================================
+капча
+Captcha
+   <Grid>
+        <StackPanel HorizontalAlignment="Center" Orientation="Vertical">
+            <Image Name="CaptchaImage" Height="100" Width="150"></Image>
+            <TextBox BorderBrush="Black" Name="tbCheckedCaptcha"></TextBox>
+            <Button Background="#498c51" Content="Проверить" Click="Button_Click"></Button>
+        </StackPanel>
+    </Grid>
+    public partial class Captcha : Window
+    {
+        public static bool checkedCaptcha;
+        int num = 0;
+        public Captcha()
+        {
+            InitializeComponent();
+            CreateImg();
+        }
+        private void CreateImg()
+        {
+            Random random = new Random();
+            num = random.Next(1000, 9999);
+            var pixels = new byte[Convert.ToInt32(CaptchaImage.Width) * Convert.ToInt32(CaptchaImage.Height) * 4];
+            random.NextBytes(pixels);
+            BitmapSource bitmapSource = BitmapSource.Create(Convert.ToInt32(CaptchaImage.Width), Convert.ToInt32(CaptchaImage.Height), 96, 96, PixelFormats.Bgra32, null, pixels, Convert.ToInt32(CaptchaImage.Width) * 4);
+            var visual = new DrawingVisual();
+            using (DrawingContext drawingContext = visual.RenderOpen())
+            {
+                drawingContext.DrawText(
+                    new FormattedText(num.ToString(), CultureInfo.InvariantCulture, FlowDirection.LeftToRight,
+                        new Typeface("Arial"), 100, System.Windows.Media.Brushes.Red), new System.Windows.Point(0, CaptchaImage.Height / 2));
+                drawingContext.DrawImage(bitmapSource, new Rect(0, 0, 256, 256));
+            }
+            var image = new DrawingImage(visual.Drawing);
+            CaptchaImage.Source = image;
+        }
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            if(num == Convert.ToInt32(tbCheckedCaptcha.Text))
+            {
+                if (!string.IsNullOrEmpty(tbCheckedCaptcha.Text))
+                {
+                    MessageBox.Show("Код введен верно.");
+                    AuthorizationPage.checkedCaptcha = true;
+                    
+                    this.Close();
+                }
+                else
+                {
+                    MessageBox.Show("Введите код для капчи");
+                }
+                
+                
+            }
+            else
+            {
+                MessageBox.Show("Код введен неверно.");
+
+                AuthorizationPage.checkedCaptcha = false;
+                this.Close();
+            }
+        }
+    }

+ 0 - 0
readme.md