|
@@ -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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|