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