CreateEvent.xaml.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using PP_Ven_MosS.Classes;
  2. using PP_Ven_MosS.ModelBase;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. namespace PP_Ven_MosS.Pages
  18. {
  19. /// <summary>
  20. /// Логика взаимодействия для CreateEvent.xaml
  21. /// </summary>
  22. public partial class CreateEvent : Page
  23. {
  24. public CreateEvent()
  25. {
  26. InitializeComponent();
  27. CBTypeEv.ItemsSource = new List<string>() { "Конференция", "Собрания", "Пленарное заседание", "Научная дискуссия", "Экспертно-оценочная сессия", "День открытых дверей", "Студентческое мероприятие" };
  28. CBTypeEv.SelectedIndex = 0;
  29. }
  30. private void CBPeople_Loaded(object sender, RoutedEventArgs e)
  31. {
  32. List<People> peoples = Database.entities.People.ToList();
  33. foreach(var peop in peoples)
  34. {
  35. CBPeople.Items.Add(peop.Ttitle);
  36. }
  37. CBPeople.SelectedIndex = 0;
  38. }
  39. private void Save_Click(object sender, RoutedEventArgs e)
  40. {
  41. Event events = new Event()
  42. {
  43. Description_event = DescEv.Text,
  44. Id_user = UserID.userid,
  45. Id_events_type = CBTypeEv.SelectedIndex + 1,
  46. Date_event = dob.SelectedDate.Value,
  47. Id_status_event = 2,
  48. Title_event = TitleEv.Text,
  49. Id_people = CBPeople.SelectedIndex,
  50. };
  51. Place_event plev = new Place_event()
  52. {
  53. id_event = events.Id_event,
  54. id_place = Convert.ToInt32(PlaceEv.Text),
  55. };
  56. switch (MessageBox.Show("Уверены в своем решении?", "Организация мероприятия", MessageBoxButton.YesNo))
  57. {
  58. case MessageBoxResult.Yes:
  59. Database.entities.Event.Add(events);
  60. Database.entities.Place_event.Add(plev);
  61. Database.entities.SaveChanges();
  62. MessageBox.Show("Мероприятие успешно запланировано"); break;
  63. case MessageBoxResult.No:
  64. MessageBox.Show("Вы отказались от мероприятия");
  65. break;
  66. }
  67. }
  68. private void Exit_Click(object sender, RoutedEventArgs e)
  69. {
  70. FrameClass.MainFrame.Navigate(new ApplicationsListUser());
  71. }
  72. private void PlaceEv_Loaded(object sender, RoutedEventArgs e)
  73. {
  74. List<Place> places = Database.entities.Place.ToList();
  75. foreach (var pla in places)
  76. {
  77. PlaceEv.Items.Add(pla.title_place);
  78. }
  79. PlaceEv.SelectedIndex = 0;
  80. }
  81. }
  82. }