Exemplo n.º 1
0
 private void AddShow_btn_Click(object sender, RoutedEventArgs e)
 {
     if(ShowNameTextBox.Text != String.Empty && TypeShowTextBox.Text != String.Empty && DescriptionTextBox.Text != String.Empty && 
         TroupeNameComboBox.Text != String.Empty && PutNumberPlacesTxtBox.Text != String.Empty && !GetInfos.IsShowNameExisting(ShowNameTextBox.Text))
     {
         using (var context = new CircusContext())
         {
             Troupe troupe = GetInfos.GetTroupeByName(TroupeNameComboBox.Text);
             Show newShow = new Show();
             newShow.ShowName = ShowNameTextBox.Text;
             newShow.ShowType = TypeShowTextBox.Text;
             newShow.TroupeName = troupe.NameTroupe;
             newShow.Description = DescriptionTextBox.Text;
             TicketOffice ticketOffice = new TicketOffice();
             ticketOffice.NameTroupe = troupe.NameTroupe;
             ticketOffice.ShowName = newShow.ShowName;
             ticketOffice.AvailableTickets = Convert.ToInt32(PutNumberPlacesTxtBox.Text);
             ticketOffice.SoldTickets = 0;
             troupe.ShowsList.Add(newShow);
             context.Add(newShow);
             context.Add(ticketOffice);
             context.Update(troupe);
             context.SaveChanges();
         }
         MessageBox.Show("Your show is save.");
     }
     else
     {
         MessageBox.Show("Have you complete all cases ?");
     }
 }
Exemplo n.º 2
0
 private void AddTroupe_Click(object sender, RoutedEventArgs e)
 {
     if(TroupeNameTxtBox.Text!=String.Empty && ShowTypeTxtBox.Text != String.Empty && MembersListView.Items.Count > 0)
     {
         newTroupe.NameTroupe = TroupeNameTxtBox.Text;
         newTroupe.ShowType = ShowTypeTxtBox.Text;
         using (var context = new CircusContext())
         {
             context.Add(newTroupe);
             context.AddRange(memberTroupes);
             context.SaveChanges();
         }
         ClearComboBox();
         MessageBox.Show("You have save your Troupe !");
     }
     else
     {
         MessageBox.Show("Have you complete all cases ?");
     }
 }