Пример #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 ?");
     }
 }
Пример #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string show           = ShowNameComboBox.Text;
            int    numberTicket   = Convert.ToInt32(NumberTicketBox.Text);
            int    availablePlace = GetInfos.GetNumberAvailableTickets(show);

            if (availablePlace > 0 && numberTicket <= availablePlace)
            {
                int price        = Convert.ToInt32(priceTextBox.Text);
                int ticketNumber = numberTicket;
                TotalTextBox.Text = Convert.ToString(price * ticketNumber);
                int availablePlaces = Convert.ToInt32(RemainingPlacesTextBox.Text);
                int numberPlace     = availablePlaces - ticketNumber;
                RemainingPlacesTextBox.Text = numberPlace.ToString();
            }
            else
            {
                MessageBox.Show("There is no place you can't sold it.");
            }
            if (availablePlace <= 0)
            {
                RemainingPlacesTextBox.Text = "0";
            }
            using (var context = new CircusContext())
            {
                TicketOfficesList = GetInfos.GetTicketOffices();
                TicketOffice ticketOffice = TicketOfficesList.FirstOrDefault(s => s.ShowName == ShowNameComboBox.Text);
                ticketOffice.AvailableTickets = Convert.ToInt32(RemainingPlacesTextBox.Text);
                ticketOffice.SoldTickets      = ticketOffice.SoldTickets + Convert.ToInt32(NumberTicketBox.Text);
                context.Update(ticketOffice);
                context.SaveChanges();
            }
        }
Пример #3
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 ?");
     }
 }