CreateEvent.xaml.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. PlaceEv.ItemsSource = Database.entities.Place.ToList();
  30. PlaceEv.DisplayMemberPath = "title_place";
  31. PlaceEv.SelectedValuePath = "id_place";
  32. PlaceEv.SelectedIndex = 0;
  33. }
  34. private void CBPeople_Loaded(object sender, RoutedEventArgs e)
  35. {
  36. List<People> peoples = Database.entities.People.ToList();
  37. foreach(var peop in peoples)
  38. {
  39. CBPeople.Items.Add(peop.Ttitle);
  40. }
  41. CBPeople.SelectedIndex = 0;
  42. }
  43. private void Save_Click(object sender, RoutedEventArgs e)
  44. {
  45. switch (MessageBox.Show("Уверены в своем решении?", "Организация мероприятия", MessageBoxButton.YesNo))
  46. {
  47. case MessageBoxResult.Yes:
  48. Event events = new Event()
  49. {
  50. Description_event = DescEv.Text,
  51. Id_user = UserID.userid,
  52. Id_events_type = CBTypeEv.SelectedIndex + 1,
  53. Date_event = dob.SelectedDate.Value,
  54. Id_status_event = 2,
  55. Title_event = TitleEv.Text,
  56. Id_people = CBPeople.SelectedIndex,
  57. };
  58. Database.entities.Event.Add(events);
  59. Database.entities.SaveChanges();
  60. Place_event plev = new Place_event();
  61. plev.id_event = events.Id_event;
  62. plev.id_place = ((Place)PlaceEv.SelectedItem).id_place;
  63. Database.entities.Place_event.Add(plev);
  64. Database.entities.SaveChanges();
  65. MessageBox.Show("Мероприятие успешно запланировано"); break;
  66. case MessageBoxResult.No:
  67. MessageBox.Show("Вы отказались от мероприятия");
  68. break;
  69. }
  70. }
  71. private void Exit_Click(object sender, RoutedEventArgs e)
  72. {
  73. FrameClass.MainFrame.Navigate(new ApplicationsListUser());
  74. }
  75. }
  76. }