123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- 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.Shapes;
- using static System.Net.Mime.MediaTypeNames;
- namespace UP43P_Krupina.Windows
- {
- /// <summary>
- /// Логика взаимодействия для OrdersWindow.xaml
- /// </summary>
- public partial class OrdersWindow : Window
- {
- User current_user;
- List<Order> orders = new List<Order>();
- List<string> discount_d = new List<string>() { "Все диапозоны (не робит)", "0-9,99%", "10-14,99%", "15% и более" };
- public OrdersWindow(User user)
- {
- InitializeComponent();
- current_user = user;
- if (current_user.UserRole == 1)
- {
- orders = Base.MyBase.Order.Where(x => x.UserID == current_user.UserID).ToList();
- TBNameUser.Text = "Заказы пользователя: " + user.UserName + " " + user.UserSurname;
- SPForAdminOrManager.Visibility = Visibility.Collapsed;
- }
- else
- {
- orders = Base.MyBase.Order.ToList();
- CBDiscount.ItemsSource = discount_d;
- CBDiscount.SelectedIndex = 0;
- RBUsial.IsChecked = true;
- }
- LVOrders.ItemsSource = orders;
- }
- private void Sort()
- {
- orders = Base.MyBase.Order.ToList();
- if (RBNew.IsChecked == true)
- {
- orders = orders.Where(x=>x.OrderStatus == 2).ToList();
- }
- if (RBFinished.IsChecked == true)
- {
- orders = orders.Where(x => x.OrderStatus == 1).ToList();
- }
- if (RBDrop.IsChecked == true)
- {
- RBDrop.IsChecked = false;
- RBFinished.IsChecked = false;
- RBFinished.IsChecked = false;
- RBUsial.IsChecked= true;
- CBDiscount.SelectedIndex=0;
- }
- LVOrders.ItemsSource= orders;
- }
- private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- Sort();
- }
- private void RadioButton_Checked(object sender, RoutedEventArgs e)
- {
- Sort();
- }
- private void Back_Click(object sender, RoutedEventArgs e)
- {
- this.Close();
- }
- private void Products_Loaded(object sender, RoutedEventArgs e)
- {
- TextBlock textBlock = (TextBlock)sender;
- List<OrderProduct> op = Base.MyBase.OrderProduct.Where(x=>x.OrderID.ToString() == textBlock.Uid).ToList();
- List<Product> products = new List<Product>();
- string text = "Товары: ";
- foreach (OrderProduct a in op)
- {
- Product b = Base.MyBase.Product.FirstOrDefault(x=>x.ProductArticleNumber == a.ProductArticleNumber);
- text += b.ProductName + " (" + b.ProductArticleNumber + ") " + op.Count + " шт., ";
- }
- text = text.Substring(0, text.Length - 2);
- textBlock.TextWrapping = TextWrapping.Wrap;
- textBlock.Text = text;
- }
- private void Summ_Loaded(object sender, RoutedEventArgs e)
- {
- TextBlock textBlock = (TextBlock)sender;
- List<OrderProduct> op = Base.MyBase.OrderProduct.Where(x => x.OrderID.ToString() == textBlock.Uid).ToList();
- string text = "";
- double all_cost = 0;
- double cost = 0;
- double discount = 0;
- foreach (OrderProduct a in op)
- {
- Product b = Base.MyBase.Product.FirstOrDefault(x => x.ProductArticleNumber == a.ProductArticleNumber);
- all_cost += Convert.ToDouble(b.ProductCost * a.ProductCount);
- discount += Convert.ToDouble(b.ProductCost * b.ProductDiscountAmount / 100);
- cost += Convert.ToDouble((b.ProductCost - b.ProductCost * b.ProductDiscountAmount / 100) * a.ProductCount);
- }
- if (discount == 0)
- {
- text = "Итого: " + all_cost.ToString() + " рублей";
- }
- else
- {
- text = "Общая сумма: " + all_cost.ToString() + " рублей\n" + "Скидка: " + discount.ToString() + " рублей\n" + "Итого: " + cost.ToString() + " рублей";
- }
-
- textBlock.Text = text;
- }
- private void UserName_Loaded(object sender, RoutedEventArgs e)
- {
- TextBlock textBlock = (TextBlock)sender;
- User user = Base.MyBase.User.FirstOrDefault(x => x.UserID.ToString() == textBlock.Uid);
- if (user != null)
- {
- textBlock.Text = "Заказчик: " + user.UserSurname + user.UserName + " " + user.UserPatronymic;
- }
- else
- {
- textBlock.Text = "Заказчик: не найдено";
- }
- if (current_user.UserRole == 1) textBlock.Text = "";
- }
- }
- }
|