using PP_Ven_MosS.Classes; using PP_Ven_MosS.ModelBase; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace PP_Ven_MosS.Pages { /// /// Логика взаимодействия для CreateEvent.xaml /// public partial class CreateEvent : Page { public CreateEvent() { InitializeComponent(); CBTypeEv.ItemsSource = new List() { "Конференция", "Собрания", "Пленарное заседание", "Научная дискуссия", "Экспертно-оценочная сессия", "День открытых дверей", "Студентческое мероприятие" }; CBTypeEv.SelectedIndex = 0; } private void CBPeople_Loaded(object sender, RoutedEventArgs e) { List peoples = Database.entities.People.ToList(); foreach(var peop in peoples) { CBPeople.Items.Add(peop.Ttitle); } CBPeople.SelectedIndex = 0; } private void Save_Click(object sender, RoutedEventArgs e) { Event events = new Event() { Description_event = DescEv.Text, Id_user = UserID.userid, Id_events_type = CBTypeEv.SelectedIndex + 1, Date_event = dob.SelectedDate.Value, Id_status_event = 2, Title_event = TitleEv.Text, Id_people = CBPeople.SelectedIndex, }; Place_event plev = new Place_event() { id_event = events.Id_event, id_place = Convert.ToInt32(PlaceEv.Text), }; switch (MessageBox.Show("Уверены в своем решении?", "Организация мероприятия", MessageBoxButton.YesNo)) { case MessageBoxResult.Yes: Database.entities.Event.Add(events); Database.entities.Place_event.Add(plev); Database.entities.SaveChanges(); MessageBox.Show("Мероприятие успешно запланировано"); break; case MessageBoxResult.No: MessageBox.Show("Вы отказались от мероприятия"); break; } } private void Exit_Click(object sender, RoutedEventArgs e) { FrameClass.MainFrame.Navigate(new ApplicationsListUser()); } private void PlaceEv_Loaded(object sender, RoutedEventArgs e) { List places = Database.entities.Place.ToList(); foreach (var pla in places) { PlaceEv.Items.Add(pla.title_place); } PlaceEv.SelectedIndex = 0; } } }