Esempio n. 1
0
        public static Seat[,] GetBookedSeats(int scheduleId, Seat[,] seats)
        {
            queryToExecute = string.Format("SELECT id, row, position FROM tickets WHERE schedule_id = \"{0}\";", scheduleId);

            MySqlDataReader reader = queryExecutor.ExecuteQuery(queryToExecute);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Seat seat = new Seat(
                       reader.GetInt32(0),
                       reader.GetInt32(1),
                       reader.GetInt32(2)
                       );

                    seats[seat.Row, seat.Position] = seat;
                }
            }

            reader.Close();
            return seats;
        }
Esempio n. 2
0
        public void PlaceSeats(int scheduleId)
        {
            Seat[,] seats = new Seat[ROWS, POSITIONS];
            seats = Query.GetBookedSeats(scheduleId, seats);
            this.txtScheduleId.Text = scheduleId.ToString();

            for (int row = 1; row < ROWS; row++)
            {
                for (int position = 1; position < POSITIONS; position++)
                {
                    int currentRow = 11 - row;

                    Button btnSeat = new Button();
                    btnSeat.Uid = string.Format("row{0}position{1}", row, position);
                    Grid.SetRow(btnSeat, currentRow);
                    Grid.SetColumn(btnSeat, position);
                    btnSeat.BorderBrush = null;

                    if (seats[row, position] == null)
                    {
                        btnSeat.Background = freeSeat.Background;

                        btnSeat.Click += this.btnSeat_Click;
                    }
                    else
                    {
                        btnSeat.Background = bookedSeat.Background;
                    }

                    this.seatsContainer.Children.Add(btnSeat);
                }
            }

            for (int index = 1; index < ROWS; index++)
            {
                Label lblRow = new Label();
                lblRow.Foreground = Brushes.Yellow;
                lblRow.HorizontalAlignment = HorizontalAlignment.Center;
                lblRow.VerticalAlignment = VerticalAlignment.Center;
                lblRow.Content = index;
                Grid.SetRow(lblRow, ROWS - index);
                Grid.SetColumn(lblRow, 0);
                this.seatsContainer.Children.Add(lblRow);

                Label lblPosition = new Label();
                lblPosition.Foreground = Brushes.Yellow;
                lblPosition.HorizontalAlignment = HorizontalAlignment.Center;
                lblPosition.Content = index;
                Grid.SetRow(lblPosition, 0);
                Grid.SetColumn(lblPosition, index);
                this.seatsContainer.Children.Add(lblPosition);
            }

            TextBlock caption = new TextBlock();
            caption.Foreground = Brushes.Yellow;
            caption.Text = "Cols Rows";
            caption.TextWrapping = TextWrapping.Wrap;

            Grid.SetRow(caption, 0);
            Grid.SetColumn(caption, 0);

            this.seatsContainer.Children.Add(caption);
        }