Example #1
0
        /// <summary>
        /// Draws the room, painting the seats green, red or blue depending on free, occupied or reserved
        /// </summary>
        private void Sala_Load()
        {
            // List with seats disposition or selected Screen
            List <Seat> seats = BoxOfficeHelper.Select_Seats_byScreen(selectedView_Session.IdScreen);

            // List with tickets sold for selected session
            List <View_Ticket> tickets = BoxOfficeHelper.Select_Tickets_bySession(selectedView_Session.IdScreen, selectedView_Session.IdMovie, selectedView_Session.Date);

            if (seats != null)
            {
                // Verifies number and disposition of seats for selected screen, enables them for selection and paints them green.
                foreach (Seat seat in seats)
                {
                    PaintSeat(seat);
                }
            }

            if (tickets != null)
            {
                foreach (View_Ticket vt in tickets)
                {
                    Ticket ticket = new Ticket()
                    {
                        IdScreen = vt.IdScreen,
                        Row      = vt.Row,
                        Number   = vt.Number,
                        IdMovie  = vt.IdMovie,
                        Date     = vt.Date,
                        IdClient = vt.IdClient
                    };
                    // paints occupied and reserved seats
                    PaintSeat(ticket);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Inserts a movie into the database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Insert_Movie_Click(object sender, EventArgs e)
        {
            Movie movie = new Movie();
            int   id;

            if (txt_Title.Text != "" && txt_Runtime.Text != "")
            {
                try
                {
                    movie.Title   = txt_Title.Text;
                    movie.Runtime = int.Parse(txt_Runtime.Text);
                    id            = BoxOfficeHelper.Movie_Insert(movie);
                    if (id > 0)
                    {
                        MessageBox.Show("Filme Inserido com sucesso", "Filme inserido", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("A inserção do filme falhou", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Duração tem de ser um número inteiro", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Dados Inválidos", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #3
0
 /// <summary>
 /// Buys or Reserves selected tickets
 /// </summary>
 private void Buy_Tickets()
 {
     foreach (Ticket ticket in selected_tickets)
     {
         BoxOfficeHelper.Ticket_Insert(ticket);
     }
     selected_tickets.Clear(); // clears the list after inserting the tickets into the database
     Sala_Load();              // Re
 }
Example #4
0
        /// <summary>
        /// Paints the seat blue or red for reserver or sold
        /// </summary>
        /// <param name="ticket">Ticket</param>
        private void PaintSeat(Ticket ticket)
        {
            bool disabled = false;
            Seat seat     = new Seat()
            {
                IdScreen = ticket.IdScreen, Number = ticket.Number, Row = ticket.Row
            };

            string     pbName = "pb_" + ticket.Row + "_" + ticket.Number;  // cria o label do picture box
            PictureBox pb     = (PictureBox)this.Controls[pbName];         // aponta para o controlo com o nome da picture box

            disabled = BoxOfficeHelper.IsDisabledSeat(seat);


            if (ticket.IdClient.HasValue)
            {
                if (disabled)
                {
                    pb.Image   = Properties.Resources.Seat_Disabled_Reserved;
                    pb.Enabled = false;                     // TEMPORARIO  disables picture box because sit is already reserved
                }
                else
                {
                    pb.Image   = Properties.Resources.Seat_Reserved;
                    pb.Enabled = false;                     // TEMPORARIO  disables picture box because sit is already reserved
                }
            }
            else
            {
                if (disabled)
                {
                    pb.Image   = Properties.Resources.Seat_Disabled_Occupied;
                    pb.Enabled = false;                     // disables picture box because sit is already sold
                }
                else
                {
                    pb.Image   = Properties.Resources.Seat_Occupied;
                    pb.Enabled = false;                     // disables picture box because sit is already sold
                }
            }
        }
Example #5
0
        /// <summary>
        /// Verifies number and disposition of seats for selected screen, enables them for selection and paints them green.
        /// </summary>
        /// <param name="seat">Seat</param>
        private void PaintSeat(Seat seat)
        {
            bool disabled = false;

            string     pbName = "pb_" + seat.Row + "_" + seat.Number;      // creats label for picture box
            PictureBox pb     = (PictureBox)this.Controls[pbName];         // points to the control with the name of the picture box

            disabled = BoxOfficeHelper.IsDisabledSeat(seat);

            if (pb != null)             // if it's a seat on the selected screen
            {
                if (disabled)
                {
                    pb.Image = Properties.Resources.Seat_Disabled_Free;
                }
                else
                {
                    pb.Image = Properties.Resources.Seat_Free;
                }
                pb.Enabled = true;                 // enables the seats that are valid for selected screen
            }
        }
Example #6
0
        /// <summary>
        /// Places movies in cb_movie for selection
        /// </summary>
        private void Populate_Movie_CBox()
        {
            DateTime date = dTPicker_Sessao.Value.Date;

            sessions = BoxOfficeHelper.Select_Session_byDate(date);

            cb_Movie.Items.Clear();         // clears preious movie selection
            cb_Movie.Text = "";             // clears the last selection

            foreach (DataRow row in sessions.Rows)
            {
                cb_Movie.Items.Add(row.ItemArray[0]);                 // index 0 = movie titles
            }

            if (cb_Movie.Items.Count > 0)
            {
                cb_Movie.SelectedIndex = 0;                 // pre-selects the first movie, in case it exists (=> automaticaly runs On_Movie_Selection)
            }
            else
            {
                btn_SelectSeats.Enabled = false;                 // disables to button to go to seat selection because no session is selected
            }
        }
Example #7
0
        private void btn_Reserve_Tickets_Click(object sender, EventArgs e)
        {
            int idClient;

            FormClientInfo formClientInfo = new FormClientInfo();

            if (formClientInfo.ShowDialog() == DialogResult.OK)             // calls the form to select seats and passes the information regarding selected session
            {
                idClient = BoxOfficeHelper.Client_Insert(formClientInfo.Client);
                foreach (Ticket ticket in selected_tickets)
                {
                    ticket.IdClient = idClient;
                }
                Buy_Tickets();                 // Places a reservation instead of bouting, because we have attibuted an IdClient to each teicket
            }
            else
            {
            }



            formClientInfo.Dispose();
        }
Example #8
0
        /// <summary>
        /// Paints the seat black when the user selects it and green if he cancels the seletin
        /// </summary>
        /// <param name="ticket">Ticket</param>
        /// <param name="selection">Selection - True, is seat is being selected by user</param>
        private void PaintSeat(Ticket ticket, bool selection)
        {
            bool disabled = false;
            Seat seat     = new Seat()
            {
                IdScreen = ticket.IdScreen, Number = ticket.Number, Row = ticket.Row
            };

            string     pbName = "pb_" + ticket.Row + "_" + ticket.Number; // cria o label do picture box
            PictureBox pb     = (PictureBox)this.Controls[pbName];        // aponta para o controlo com o nome da picture box

            disabled = BoxOfficeHelper.IsDisabledSeat(seat);              // checks if it's a disabled seat

            // paint the selected seat black
            if (selection)
            {
                if (disabled)
                {
                    pb.Image = Properties.Resources.Seat_Disabled_Selected;
                }
                else
                {
                    pb.Image = Properties.Resources.Seat_Selected;
                }
            }
            else
            {
                if (disabled)
                {
                    pb.Image = Properties.Resources.Seat_Disabled_Free;
                }
                else
                {
                    pb.Image = Properties.Resources.Seat_Free;
                }
            }
        }