OrderNew.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. using Sessioa.BaseModel;
  16. using Sessioa.Classes;
  17. using System.Data.Entity;
  18. namespace Sessioa.Pages
  19. {
  20. /// <summary>
  21. /// Логика взаимодействия для OrderNew.xaml
  22. /// </summary>
  23. public partial class OrderNew : Page
  24. {
  25. User user = null;
  26. public OrderNew(User userSign)
  27. {
  28. InitializeComponent();
  29. user = userSign;
  30. if(userSign.UserRole == 2)
  31. {
  32. LB_OrderProduct.ItemsSource = BaseClass.C_Base.Order.Include(x => x.PointsOfIssue).Include(x=>x.User).ToList();
  33. }
  34. else if (userSign.UserRole == 1)
  35. LB_OrderProduct.ItemsSource = BaseClass.C_Base.Order.Include(x => x.PointsOfIssue).Where(x => x.UserID == userSign.UserID).ToList();
  36. }
  37. private void UserOrder_Loaded(object sender, RoutedEventArgs e)
  38. {
  39. TextBlock tb = (TextBlock)sender;
  40. if(tb.Uid != null && user.UserRole == 2)
  41. {
  42. User us = BaseClass.C_Base.User.FirstOrDefault(x => x.UserID.ToString() == tb.Uid);
  43. tb.Text = $"Заказчик: {us.UserSurname} {us.UserName[0]}.{(us.UserPatronymic != null && us.UserPatronymic != string.Empty ? $"{us.UserPatronymic[0]}." : "")}";
  44. }
  45. }
  46. private void B_Back_Click(object sender, RoutedEventArgs e)
  47. {
  48. FrameClass.C_Frame.Navigate(new ProductsPage(user));
  49. }
  50. }
  51. }