SysAdmin.xaml.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. using Microsoft.Win32;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Windows;
  7. using System.Windows.Media.Imaging;
  8. using Word = Microsoft.Office.Interop.Word;
  9. namespace mateo
  10. {
  11. public partial class SysAdmin : Window
  12. {
  13. byte[] image; //очищать!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  14. int idattraction = 0;
  15. int idemployees = 0;
  16. public SysAdmin()
  17. {
  18. InitializeComponent();
  19. var fio = DB.GetContext().Employees.FirstOrDefault(x => x.IDEmployees == DB.Idemployees);
  20. if (DB.Idemployees != 0)
  21. {
  22. txtFio_Admin.Text = DB.GetContext().Role.FirstOrDefault(x => x.IDRole == fio.FKRole).Role1 + "\n" + fio.LastName + " " + fio.FirstName + " " + fio.MiddleName;
  23. if (fio.FKRole == 2) //если простто админ скрываем доб сотрудников
  24. tabEmployees.Visibility = Visibility.Collapsed;
  25. }
  26. datagridAttraction.ItemsSource = DB.GetContext().Attraction.ToList();
  27. datagridEmployees.ItemsSource = DB.GetContext().Employees.Where(x => x.IDEmployees != DB.Idemployees).ToList();
  28. comboboxChange_StatusAttraction.ItemsSource = comboboxStatus_Attraction.ItemsSource = DB.GetContext().StatusAttraction.ToList();
  29. comboboxChange_TypeAttraction.ItemsSource = comboboxType_Attraction.ItemsSource = DB.GetContext().Type.ToList();
  30. comboboxNameAttraction.ItemsSource = DB.GetContext().Attraction.ToList();//для отчета
  31. }
  32. #region Для тестов
  33. public byte[] AddImage()
  34. {
  35. string imageLoc;
  36. OpenFileDialog dld = new OpenFileDialog();
  37. dld.Filter = "JPG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png|JPEG Files (*.jpeg)|*.jpeg";
  38. dld.Title = "Выберите изображение пользователя";
  39. bool? result = dld.ShowDialog();
  40. if (result == true)
  41. {
  42. imageLoc = dld.FileName;
  43. imageAdd_Attraction.Source = new BitmapImage(new Uri(imageLoc));
  44. FileStream fs = new FileStream(imageLoc, FileMode.Open, FileAccess.Read);
  45. BinaryReader br = new BinaryReader(fs);
  46. image = br.ReadBytes((int)fs.Length);
  47. }
  48. return image;
  49. }
  50. public bool AddAttraction(int idemp, string name, string description, string quantity, string priceold, string pricebaby, byte[] image, string statusa, string typea)
  51. {
  52. bool tf = false;
  53. try
  54. {
  55. if (name != "" && description != "" && quantity != "" && priceold != "" &&
  56. pricebaby != "" && image != null && statusa != "" && typea != "")
  57. {
  58. var status = DB.GetContext().StatusAttraction.Where(x => x.StatusAttraction1 == statusa).FirstOrDefault();
  59. var type = DB.GetContext().Type.Where(x => x.Type1 == typea).FirstOrDefault();
  60. Attraction attraction = new Attraction
  61. {
  62. NameAttraction = name,
  63. Description = description,
  64. QuantityAttraction = Convert.ToInt32(quantity),
  65. PriceOld = Convert.ToDecimal(priceold),
  66. PriceBaby = Convert.ToDecimal(pricebaby),
  67. ImageAttraction = image,
  68. FKEmployees = idemp,
  69. FKStatusAttraction = status.IDStatusAttraction,
  70. FKType = type.IDType
  71. };
  72. DB.GetContext().Attraction.Add(attraction);
  73. DB.GetContext().SaveChanges();
  74. MessageBox.Show("Аттракцион добавлен", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
  75. datagridAttraction.ItemsSource = DB.GetContext().Attraction.ToList();
  76. gridAddAttraction.Visibility = Visibility.Hidden;
  77. tf = true;
  78. }
  79. else MessageBox.Show("Пустые поля!", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
  80. return tf;
  81. }
  82. catch (Exception ex)
  83. {
  84. MessageBox.Show(ex.ToString(), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
  85. return false;
  86. }
  87. }
  88. public bool AddEmployees(int idemp, string lname, string fname, string mname, string rolea, string statusa)
  89. {
  90. bool tf = false;
  91. try
  92. {
  93. if (lname != "" && fname != "" && rolea != "" && statusa != "")
  94. {
  95. var idemployees = DB.GetContext().Employees.OrderByDescending(x => x.IDEmployees).FirstOrDefault();
  96. string login = "admin" + (idemployees.IDEmployees + 1).ToString();
  97. Random random = new Random();
  98. int pass1 = random.Next(100, 999);
  99. var list = new List<string> { "a", "b", "c", "d", "e" };
  100. int index = random.Next(list.Count);
  101. int index1 = random.Next(list.Count);
  102. int index2 = random.Next(list.Count);
  103. int index3 = random.Next(list.Count);
  104. string password = list[index] + list[index1] + pass1 + list[index2] + list[index3];
  105. var status = DB.GetContext().StatusEmployees.Where(x => x.StatusEmployees1 == statusa).FirstOrDefault();
  106. var role = DB.GetContext().Role.Where(x => x.Role1 == rolea).FirstOrDefault();
  107. Employees employees = new Employees
  108. {
  109. LastName = lname,
  110. FirstName = fname,
  111. MiddleName = mname,
  112. Login = login,
  113. Password = password,
  114. FKRole = role.IDRole,
  115. FKStatusEmployees = status.IDStatusEmployees
  116. };
  117. DB.GetContext().Employees.Add(employees);
  118. DB.GetContext().SaveChanges();
  119. MessageBox.Show("Сотрудник добавлен", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
  120. datagridEmployees.ItemsSource = DB.GetContext().Employees.Where(x => x.IDEmployees != idemp).ToList();
  121. gridAddEmployees.Visibility = Visibility.Hidden;
  122. tf = true;
  123. }
  124. else MessageBox.Show("Пустые поля!", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
  125. return tf;
  126. }
  127. catch (Exception ex)
  128. {
  129. MessageBox.Show(ex.ToString(), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
  130. return false;
  131. }
  132. }
  133. public bool Report1(string dateP, string nameA)
  134. {
  135. DateTime datetime = DateTime.Now;
  136. if (dateP != "") datetime = Convert.ToDateTime(dateP);
  137. bool tf = false;
  138. var ticket = DB.GetContext().Tickets.ToList();
  139. if (dateP == "" && nameA != "")
  140. ticket = DB.GetContext().Tickets.Where(x => x.Attraction.NameAttraction == nameA).ToList();
  141. if (nameA == "" && dateP != "")
  142. ticket = DB.GetContext().Tickets.Where(x => x.Date == datetime).ToList();
  143. if (nameA != "" && dateP != "")
  144. ticket = DB.GetContext().Tickets.Where(x => x.Date == datetime && x.Attraction.NameAttraction == nameA).ToList();
  145. if (nameA == "" && dateP == "") ticket = DB.GetContext().Tickets.ToList();
  146. if (ticket.Count() <= 0)
  147. MessageBox.Show("Невозможно сформировать отчёт, проверьте дату и аттракцион");
  148. else
  149. {
  150. SaveFileDialog saveFileDialog = new SaveFileDialog();
  151. saveFileDialog.Title = "Выберите место для сохранения отчёта";
  152. saveFileDialog.FileName = "Отчет по истории за " + DateTime.Now.ToShortDateString() + " - PDF";
  153. saveFileDialog.Filter = "PDF Files |*.pdf";
  154. if (saveFileDialog.ShowDialog() == true)
  155. {
  156. var application = new Word.Application();
  157. Word.Document document = application.Documents.Add();
  158. Word.Paragraph paragraph = document.Paragraphs.Add();
  159. Word.Range cellrange = paragraph.Range;
  160. Word.InlineShape inlineShape = cellrange.InlineShapes.AddPicture(@"C:\Users\polin\OneDrive\Рабочий стол\mateo\mateo\image\logocheck.png");
  161. inlineShape.Width = 400;
  162. inlineShape.Height = 100;
  163. paragraph.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
  164. cellrange.InsertParagraphAfter();
  165. Word.Paragraph paragraph2 = document.Paragraphs.Add();
  166. Word.Range range2 = paragraph2.Range;
  167. range2.Text = "Отчёт по истории";
  168. paragraph2.set_Style("Заголовок");
  169. paragraph2.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
  170. range2.Font.Size = 18;
  171. range2.InsertParagraphAfter();
  172. var group = DB.GetContext().Tickets.GroupBy(x => new { x.Attraction.NameAttraction, x.TypeTickets.TypeTickets1 }).
  173. Select(x => new
  174. {
  175. x.Key,
  176. Sum = x.Sum(y => y.Summ * y.Quantity),
  177. NameA = x.Select(y => y.Attraction.NameAttraction),
  178. TypeA = x.Select(y => y.TypeTickets.TypeTickets1),
  179. Quantity = x.Sum(y => y.Quantity)
  180. }).ToList();
  181. decimal sum = DB.GetContext().Tickets.Where(x => x.FKStatusPuy == 1).Sum(x => x.Quantity * x.Summ);
  182. if (dateP != "" && nameA == "")
  183. {
  184. group = DB.GetContext().Tickets.Where(x => x.Date == datetime).
  185. GroupBy(x => new { x.Attraction.NameAttraction, x.TypeTickets.TypeTickets1 }).
  186. Select(x => new
  187. {
  188. x.Key,
  189. Sum = x.Sum(y => y.Summ * y.Quantity),
  190. NameA = x.Select(y => y.Attraction.NameAttraction),
  191. TypeA = x.Select(y => y.TypeTickets.TypeTickets1),
  192. Quantity = x.Sum(y => y.Quantity)
  193. }).ToList();
  194. sum = DB.GetContext().Tickets.Where(x => x.FKStatusPuy == 1 && x.Date == datetime).Sum(x => x.Quantity * x.Summ);
  195. }
  196. else if (dateP == "" && nameA != "")
  197. {
  198. group = DB.GetContext().Tickets.Where(x => x.Attraction.NameAttraction == nameA).
  199. GroupBy(x => new { x.Attraction.NameAttraction, x.TypeTickets.TypeTickets1 }).
  200. Select(x => new
  201. {
  202. x.Key,
  203. Sum = x.Sum(y => y.Summ * y.Quantity),
  204. NameA = x.Select(y => y.Attraction.NameAttraction),
  205. TypeA = x.Select(y => y.TypeTickets.TypeTickets1),
  206. Quantity = x.Sum(y => y.Quantity)
  207. }).ToList();
  208. sum = DB.GetContext().Tickets.Where(x => x.FKStatusPuy == 1 && x.Attraction.NameAttraction == nameA).Sum(x => x.Quantity * x.Summ);
  209. }
  210. else if (dateP != "" && nameA != "")
  211. {
  212. group = DB.GetContext().Tickets.Where(x => x.Date == datetime && x.Attraction.NameAttraction == nameA).
  213. GroupBy(x => new { x.Attraction.NameAttraction, x.TypeTickets.TypeTickets1 }).
  214. Select(x => new
  215. {
  216. x.Key,
  217. Sum = x.Sum(y => y.Summ * y.Quantity),
  218. NameA = x.Select(y => y.Attraction.NameAttraction),
  219. TypeA = x.Select(y => y.TypeTickets.TypeTickets1),
  220. Quantity = x.Sum(y => y.Quantity)
  221. }).ToList();
  222. sum = DB.GetContext().Tickets.Where(x => x.FKStatusPuy == 1 && x.Date == datetime && x.Attraction.NameAttraction == nameA).Sum(x => x.Quantity * x.Summ);
  223. }
  224. Word.Paragraph tableparagraph = document.Paragraphs.Add();
  225. Word.Range tablerange = tableparagraph.Range;
  226. Word.Table paymentstable = document.Tables.Add(tablerange, group.Count() + 2, 2);
  227. paymentstable.Borders.InsideLineStyle = paymentstable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
  228. paymentstable.PreferredWidth = 500;
  229. paymentstable.Rows.Alignment = Word.WdRowAlignment.wdAlignRowCenter;
  230. Word.Range cellRange;
  231. cellRange = paymentstable.Cell(1, 2).Range;
  232. cellRange.Text = "Дата формирования: " + DateTime.Now;
  233. paymentstable.Cell(1, 2).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;
  234. range2.Font.Size = 18;
  235. for (int i = 0; i < group.Count(); i++)
  236. {
  237. var orders = group[i];
  238. cellRange = paymentstable.Cell(i + 2, 1).Range;
  239. cellRange.Text = orders.NameA.FirstOrDefault() + " (" + orders.TypeA.FirstOrDefault() + ")" + " x" + orders.Quantity;
  240. cellRange.Font.Size = 12;
  241. cellRange = paymentstable.Cell(i + 2, 2).Range;
  242. cellRange.Text = String.Format("{0:0.00}", orders.Sum).ToString() + " руб.";
  243. }
  244. cellRange = paymentstable.Cell(group.Count() + 3, 1).Range;
  245. cellRange.Text = "Итого: " + String.Format("{0:0.00}", sum) + " руб.";
  246. cellRange.set_Style("Заголовок");
  247. cellRange.Bold = 1;
  248. paymentstable.Cell(group.Count() + 3, 1).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft;
  249. cellRange.Font.Size = 18;
  250. document.SaveAs2(saveFileDialog.FileName, Word.WdExportFormat.wdExportFormatPDF);
  251. MessageBox.Show("Отчёт сформирован", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
  252. tf = true;
  253. }
  254. }
  255. return tf;
  256. }
  257. #endregion
  258. #region Аттракционы
  259. #region Добавление
  260. private void BtnAddNewAttractionClick(object sender, RoutedEventArgs e)
  261. {
  262. gridAddAttraction.Visibility = Visibility.Visible;
  263. }
  264. private void BtnAddImage(object sender, RoutedEventArgs e) //выбираем и выводим изображение в imageAdd_Attraction
  265. {
  266. AddImage();
  267. }
  268. private void BtnAddAttractionClick(object sender, RoutedEventArgs e) //добавляем новый аттракцион в бд
  269. {
  270. AddAttraction(DB.Idemployees, txtName_Attraction.Text, txtDescription_Attraction.Text, txtQuantity_Attraction.Text, txtPriceOld_Attraction.Text, txtPriceBaby_Attraction.Text, image, comboboxStatus_Attraction.Text, comboboxType_Attraction.Text);
  271. }
  272. #endregion
  273. #region Изменение
  274. private void BtnChangeAttractionClick(object sender, RoutedEventArgs e) //выводим данные из datagrid в grid чтобы потом изменить
  275. {
  276. if (datagridAttraction.SelectedItem is Attraction attraction)
  277. {
  278. idattraction = attraction.IDAttraction;
  279. txtChange_NameAttraction.Text = attraction.NameAttraction;
  280. txtChange_Description.Text = attraction.Description;
  281. txtChange_Quantity.Text = attraction.QuantityAttraction.ToString();
  282. decimal price = Convert.ToDecimal(attraction.PriceOld);
  283. txtChange_PriceOldAttraction.Text = String.Format("{0:0.00}", price);
  284. price = Convert.ToDecimal(attraction.PriceBaby);
  285. txtChange_PriceBabyAttraction.Text = String.Format("{0:0.00}", price);
  286. comboboxChange_StatusAttraction.Text = attraction.StatusAttraction.StatusAttraction1;
  287. comboboxChange_TypeAttraction.Text = attraction.Type.Type1;
  288. image = attraction.ImageAttraction;
  289. MemoryStream ms = new MemoryStream(image);
  290. imageChange_Attraction.Source = BitmapFrame.Create(ms);
  291. datagridAttraction.Visibility = Visibility.Hidden;
  292. gridChangeAttraction.Visibility = Visibility.Visible;
  293. }
  294. }
  295. private void BtnChangeImageClick(object sender, RoutedEventArgs e) //выбираем и выводим изображение в imageChange_Attraction
  296. {
  297. string imageLoc;
  298. OpenFileDialog dld = new OpenFileDialog();
  299. dld.Filter = "JPG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png|JPEG Files (*.jpeg)|*.jpeg";
  300. dld.Title = "Выберите изображение пользователя";
  301. bool? result = dld.ShowDialog();
  302. if (result == true)
  303. {
  304. imageLoc = dld.FileName;
  305. imageChange_Attraction.Source = new BitmapImage(new Uri(imageLoc));
  306. FileStream fs = new FileStream(imageLoc, FileMode.Open, FileAccess.Read);
  307. BinaryReader br = new BinaryReader(fs);
  308. image = br.ReadBytes((int)fs.Length);
  309. }
  310. }
  311. private void BtnSaveChangeClick(object sender, RoutedEventArgs e) //вносим изменения из gridChangeAttraction в бд
  312. {
  313. if (txtChange_NameAttraction.Text != "" && txtChange_Description.Text != "" && txtChange_Quantity.Text != "" && txtChange_PriceOldAttraction.Text != "" &&
  314. txtChange_PriceBabyAttraction.Text != "" && imageChange_Attraction.Source != null && comboboxChange_StatusAttraction.Text != "" && comboboxChange_TypeAttraction.Text != "")
  315. {
  316. var attr = DB.GetContext().Attraction.Where(x => x.IDAttraction == idattraction).FirstOrDefault();
  317. var type = DB.GetContext().Type.Where(x => x.Type1 == comboboxChange_TypeAttraction.Text).FirstOrDefault();
  318. attr.NameAttraction = txtChange_NameAttraction.Text;
  319. attr.Description = txtChange_Description.Text;
  320. attr.QuantityAttraction = Convert.ToInt32(txtChange_Quantity.Text);
  321. attr.PriceOld = Convert.ToDecimal(txtChange_PriceOldAttraction.Text);
  322. attr.PriceBaby = Convert.ToDecimal(txtChange_PriceBabyAttraction.Text);
  323. //ищем в таблице StatusAttraction столбец с нужным статусом, затем записываем его id в FKStatusAttraction таблицы Attraction
  324. var status = DB.GetContext().StatusAttraction.Where(x => x.StatusAttraction1 == comboboxChange_StatusAttraction.Text).FirstOrDefault();
  325. attr.FKStatusAttraction = status.IDStatusAttraction;
  326. attr.FKType = type.IDType;
  327. attr.ImageAttraction = image;
  328. DB.GetContext().SaveChanges();
  329. MessageBox.Show("Изменения сохранены", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
  330. gridChangeAttraction.Visibility = Visibility.Hidden;
  331. datagridAttraction.Visibility = Visibility.Visible;
  332. datagridAttraction.ItemsSource = DB.GetContext().Attraction.ToList();
  333. }
  334. else MessageBox.Show("Пустые поля!", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
  335. }
  336. #endregion
  337. private void BtnBackAttractionClick(object sender, RoutedEventArgs e)
  338. {
  339. gridAddAttraction.Visibility = Visibility.Hidden;
  340. gridChangeAttraction.Visibility = Visibility.Hidden;
  341. datagridAttraction.Visibility = Visibility.Visible;
  342. }
  343. #endregion
  344. #region Сотрудники
  345. #region Добавление
  346. private void BtnAddEmployeesClick(object sender, RoutedEventArgs e) //добавляем нового администратора в бд
  347. {
  348. AddEmployees(DB.Idemployees, txtLastName_Employyes.Text, txtFirstName_Employyes.Text, txtMiddleName_Employees.Text, comboboxRole_Employees.Text, comboboxStatus_Employees.Text);
  349. }
  350. private void BtnAddNewEmployeesClick(object sender, RoutedEventArgs e)
  351. {
  352. gridAddEmployees.Visibility = Visibility.Visible;
  353. }
  354. #endregion
  355. #region Изменение
  356. private void BtnChangeEmployeesClick(object sender, RoutedEventArgs e) //выводим данные из datagrid в grid чтобы потом изменить
  357. {
  358. if (datagridEmployees.SelectedItem is Employees employees)
  359. {
  360. idemployees = employees.IDEmployees;
  361. datagridEmployees.Visibility = Visibility.Hidden;
  362. gridChangeEmployees.Visibility = Visibility.Visible;
  363. txtLastName_ChangeEmployyes.Text = employees.LastName;
  364. txtFirstName_ChangeEmployyes.Text = employees.FirstName;
  365. txtMiddleName_ChangeEmployees.Text = employees.MiddleName;
  366. comboboxRole_ChangeEmployees.Text = employees.Role.Role1;
  367. comboboxStatus_ChangeEmployees.Text = employees.StatusEmployees.StatusEmployees1;
  368. }
  369. }
  370. private void BtnSaveChangeEmployeesClick(object sender, RoutedEventArgs e)
  371. {
  372. if (txtLastName_ChangeEmployyes.Text != "" && txtFirstName_ChangeEmployyes.Text != "" &&
  373. comboboxRole_ChangeEmployees.Text != "" && comboboxStatus_ChangeEmployees.Text != "")
  374. {
  375. //вносим изменения из gridChangeEmployees в бд
  376. var attr = DB.GetContext().Employees.Where(x => x.IDEmployees == idemployees).FirstOrDefault();
  377. attr.LastName = txtLastName_ChangeEmployyes.Text;
  378. attr.FirstName = txtFirstName_ChangeEmployyes.Text;
  379. attr.MiddleName = txtMiddleName_ChangeEmployees.Text;
  380. //ищем в таблице StatusEmployees столбец с нужным статусом, затем записываем его id в FKStatusEmployees таблицы Employees
  381. var status = DB.GetContext().StatusEmployees.Where(x => x.StatusEmployees1 == comboboxStatus_ChangeEmployees.Text).FirstOrDefault();
  382. attr.FKStatusEmployees = status.IDStatusEmployees;
  383. var role = DB.GetContext().Role.Where(x => x.Role1 == comboboxRole_ChangeEmployees.Text).FirstOrDefault();
  384. attr.FKRole = role.IDRole;
  385. DB.GetContext().SaveChanges();
  386. MessageBox.Show("Изменения сохранены");
  387. gridChangeEmployees.Visibility = Visibility.Hidden;
  388. datagridEmployees.Visibility = Visibility.Visible;
  389. datagridEmployees.ItemsSource = DB.GetContext().Employees.Where(x => x.IDEmployees != DB.Idemployees).ToList();
  390. }
  391. else MessageBox.Show("Пустые поля!");
  392. }
  393. #endregion
  394. private void BtnBackEmployeesClick(object sender, RoutedEventArgs e)
  395. {
  396. gridAddEmployees.Visibility = Visibility.Hidden;
  397. datagridEmployees.Visibility = Visibility.Visible;
  398. gridChangeEmployees.Visibility = Visibility.Hidden;
  399. }
  400. #endregion
  401. private void BtnReport1(object sender, RoutedEventArgs e) //отчёт по истории
  402. {
  403. try
  404. {
  405. string dateP = "";
  406. string nameA = "";
  407. if (datepicker.SelectedDate == null) dateP = "";
  408. else dateP = datepicker.SelectedDate.ToString();
  409. if (comboboxNameAttraction.SelectedItem == null) nameA = "";
  410. else nameA = comboboxNameAttraction.SelectedItem.ToString();
  411. Report1(dateP, nameA);
  412. }
  413. catch (Exception ex)
  414. {
  415. MessageBox.Show(ex.ToString(), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
  416. }
  417. }
  418. private void btnLogout(object sender, RoutedEventArgs e)
  419. {
  420. First first = new First();
  421. first.Show();
  422. this.Close();
  423. }
  424. private void BtnExit(object sender, RoutedEventArgs e)
  425. {
  426. Application.Current.Shutdown();
  427. }
  428. }
  429. }