Esempio n. 1
0
        public static bool ChooseSeat(object sender, RoomMainForm main_form, bool availability)
        {
            Button b = sender as Button;

            if (availability)
            {
                if (b.Background == Brushes.Gray || b.Background == Brushes.Yellow || b.Background == Brushes.Red)
                {
                    MessageBox.Show("Nie można wybrać tego miejsca!!!", "Błąd", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                if (b.Background == Brushes.Green)
                {
                    string namebutton = b.Name;
                    namebutton = namebutton.Substring(6);
                    var newstr = namebutton.Split('_');
                    main_form.Seat = new Tuple <int, int>(Convert.ToInt32(newstr[1]), Convert.ToInt32(newstr[0]));
                    main_form.SetSeatLabel();
                    return(true);
                }

                return(false);
            }
            else
            {
                if (b.Background == Brushes.Gray || b.Background == Brushes.Green)
                {
                    MessageBox.Show("Nie można usunąć nieobsadzonych miejsc!!!", "Błąd", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    string namebutton = b.Name;
                    namebutton = namebutton.Substring(6);
                    var newstr = namebutton.Split('_');
                    Tuple <int, int> thiseat  = new Tuple <int, int>(Convert.ToInt32(newstr[1]), Convert.ToInt32(newstr[0]));
                    var object_with_this_seat = main_form.ListWithOneMovieOnly.Find(x => x.Seat.Equals(thiseat));
                    MessageBoxResult result   = MessageBox.Show("Czy na pewno chcesz usunąć wpis o nazwie: " + object_with_this_seat.Name, "Potwierdzenie usunięcia", MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (result == MessageBoxResult.Yes)
                    {
                        main_form.ListWithOneMovieOnly.Remove(object_with_this_seat);
                        main_form.RoomMovies.Remove(object_with_this_seat);
                        CinemaService.DeleteEntry(object_with_this_seat);
                        return(true);
                    }
                }
                return(false);
            }
        }
Esempio n. 2
0
 /********Get movies from selected room and print to ListBox***********/
 private void PrintMovies()
 {
     ListBoxMovies.Items.Clear();
     RoomMovies = CinemaService.GetMoviesByRoom(roomNumber);
     foreach (var it in RoomMovies)
     {
         bool is_in_list = false;
         foreach (var it1 in ListBoxMovies.Items)
         {
             if (it1.ToString() == it.Movie)
             {
                 is_in_list = true;
                 break;
             }
         }
         if (!is_in_list)
         {
             ListBoxMovies.Items.Add(it.Movie);
         }
     }
 }
Esempio n. 3
0
        /***********************************************/

        /******Button to add a new client and sale a ticket****/
        private void AddButton_Click_2(object sender, RoutedEventArgs e)
        {
            if (movie_read.Content.Equals("") || typeCombo.Text.ToString().Equals("") || NameTextBox.Text.ToString().Equals("") || seatLabel.Content.Equals(""))
            {
                MessageBox.Show("Wszytkie pola muszą być uzupełnione!!!", "Błąd", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                TicketType convert_type(string val)
                {
                    switch (val)
                    {
                    case "sprzedaż":
                        return(TicketType.sale);

                    case "rezerwacja":
                        return(TicketType.reservation);

                    default:
                        return(TicketType.reservation);
                    }
                }

                long   epochTicks = new DateTime(1970, 1, 1).Ticks;
                long   unixTime   = ((DateTime.UtcNow.Ticks - epochTicks) / TimeSpan.TicksPerSecond);
                string type       = typeCombo.Text.ToString();

                /****New entry to our list of ticket*********/
                CinemaModel entry = new CinemaModel(unixTime, convert_type(type), NameTextBox.Text.ToString(), movie_read.Content.ToString(), roomNumber, Seat);
                CinemaService.AddEntry(entry);

                RoomMovies.Add(entry);
                ListWithOneMovieOnly.Add(entry);

                /********Clear labels*****/
                typeCombo.Text = "";
                NameTextBox.Clear();
                seatLabel.Content = "";
            }
        }