CheckReport.xaml.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using PP_Ven_MosS.Classes;
  2. using PP_Ven_MosS.ModelBase;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Media;
  8. using System.Windows.Shapes;
  9. namespace PP_Ven_MosS.Pages
  10. {
  11. /// <summary>
  12. /// Логика взаимодействия для CheckReport.xaml
  13. /// </summary>
  14. public partial class CheckReport : Page
  15. {
  16. public CheckReport()
  17. {
  18. InitializeComponent();
  19. Sort();
  20. }
  21. async public void Sort()
  22. {
  23. int k = 0;
  24. Place_event plev = Database.entities.Place_event.ToList().FirstOrDefault();
  25. List<Rectangle> rectangles = new List<Rectangle>();
  26. List<Place> place = Database.entities.Place.ToList();
  27. List<Place_event> plevs = Database.entities.Place_event.ToList();
  28. int[] mass = new int[plevs.Count];
  29. foreach (var pl in plevs)
  30. {
  31. Rectangle newRectangle = new Rectangle();
  32. newRectangle.Width = 100;
  33. for (int i = 0; i < mass.Length; i++)
  34. {
  35. if (pl.id_place == plev.id_place)
  36. {
  37. k++;
  38. }
  39. }
  40. newRectangle.Height = k * 30;
  41. if (k > 5)
  42. {
  43. newRectangle.Fill = new SolidColorBrush(Colors.Green);
  44. }
  45. else if (k < 2)
  46. {
  47. newRectangle.Fill = new SolidColorBrush(Colors.Red);
  48. }
  49. else
  50. {
  51. newRectangle.Fill = new SolidColorBrush(Colors.Blue);
  52. }
  53. newRectangle.Margin = new Thickness(20, 0, 0, 0);
  54. newRectangle.VerticalAlignment = VerticalAlignment.Bottom;
  55. diag.Children.Add(newRectangle);
  56. rectangles.Add(newRectangle);
  57. }
  58. foreach (var pl in place)
  59. {
  60. if (pl.id_place == plev.id_place)
  61. {
  62. TextBlock block = new TextBlock
  63. {
  64. Text = pl.title_place,
  65. HorizontalAlignment = HorizontalAlignment.Center,
  66. VerticalAlignment = VerticalAlignment.Bottom,
  67. Width = 100,
  68. Margin = new Thickness(20, 250, 0, 0)
  69. };
  70. diagr.Children.Add(block);
  71. }
  72. }
  73. }
  74. private void Button_Click(object sender, RoutedEventArgs e)
  75. {
  76. System.Windows.Controls.PrintDialog printDialog = new PrintDialog();
  77. if (printDialog.ShowDialog() == true)
  78. {
  79. printDialog.PrintVisual(Report, "Отчет");
  80. }
  81. }
  82. private void Exit_Click(object sender, RoutedEventArgs e)
  83. {
  84. FrameClass.MainFrame.Navigate(new MenuAdmin());
  85. }
  86. }
  87. }