Example #1
0
        void UpdateStatistic()
        {
            int revenue   = 0;
            int emptySeat = 0;
            int busySeat  = 0;

            if (cbbTicketCinemaMovie.Items.Count != 0)
            {
                string      cinemaMovieIndex = ((KeyValuePair <string, string>)cbbTicketCinemaMovie.SelectedItem).Key;
                CinemaMovie cinemaMovie      = cinemaMovies.Find(x => x.id == cinemaMovieIndex);

                for (int i = 0; i < cinemaMovie.room.seats.Count; ++i)
                {
                    if (cinemaMovie.room.seats[i].status == SeatStatus.Available)
                    {
                        ++emptySeat;
                    }
                    else
                    {
                        ++busySeat;
                        revenue += cinemaMovie.room.seats[i].price;
                    }
                }
            }
            lbRevenue.Text        = "Doanh thu: " + revenue;
            lbEmptySeatCount.Text = "Ghế còn trống: " + emptySeat;
            lbBusySeatCount.Text  = "Đã đặt chỗ: " + busySeat;
        }
Example #2
0
        private void btnBook_Click(object sender, EventArgs e)
        {
            Seat selectedSeat = GetSelectedSeat();

            if (selectedSeat == null)
            {
                MessageBox.Show("Vui lòng chọn ghế", "Lỗi");
                lbBookingNotify.Text      = "Đặt vé không thành công: Vui lòng chọn ghế";
                lbBookingNotify.BackColor = failNotifyColor;
                return;
            }

            if (selectedSeat.status == SeatStatus.Unavailable)
            {
                MessageBox.Show("Vui lòng chọn ghế TRỐNG", "Lỗi");
                lbBookingNotify.Text      = "Đặt vé không thành công: Vui lòng chọn ghế TRỐNG";
                lbBookingNotify.BackColor = failNotifyColor;
                return;
            }

            selectedSeat.status = SeatStatus.Unavailable;                   // backend
            lvSeats.SelectedItems[0].ImageIndex = (int)selectedSeat.status; // frontend

            CinemaMovie selectedCinemaMovie = cinemaMovies.Find(
                x => x.id == ((KeyValuePair <string, string>)cbbTicketCinemaMovie.SelectedItem).Key);

            MessageBox.Show("Đã đặt vé vị trí " + selectedSeat.id + " phòng " + selectedCinemaMovie.room.roomName + " Có giá: " + selectedSeat.price + " VND", "Thông tin vé");

            lbBookingNotify.Text      = "Đặt vé thành công";
            lbBookingNotify.BackColor = successNotifyColor;

            UpdateStatistic();
            SetControlsStateForSeats();
        }
Example #3
0
        private void cbbTicketCinemaMovie_SelectedIndexChanged(object sender, EventArgs e)
        {
            lvSeats.Items.Clear();
            string      cinemaMovieIndex = ((KeyValuePair <string, string>)cbbTicketCinemaMovie.SelectedItem).Key;
            CinemaMovie cinemaMovie      = cinemaMovies.Find(x => x.id == cinemaMovieIndex);
            int         index            = 0;

            if (cinemaMovie != null)
            {
                int row    = cinemaMovie.room.row;
                int column = cinemaMovie.room.column;
                for (int i = 0; i < row; ++i)
                {
                    for (int j = 0; j < column + 2; ++j)
                    {
                        if (j == 2 || j == 6)
                        {
                            lvSeats.Items.Add(new ListViewItem());
                            continue;
                        }
                        Seat seat = cinemaMovie.room.seats[index];
                        lvSeats.Items.Add(seat.id, seat.id, (int)seat.status);
                        ++index;
                    }
                }
            }

            UpdateStatistic();
        }
Example #4
0
 Seat GetSelectedSeat()
 {
     if (lvSeats.SelectedItems.Count > 0)
     {
         CinemaMovie selectedCinemaMovie = cinemaMovies.Find(
             x => x.id == ((KeyValuePair <string, string>)cbbTicketCinemaMovie.SelectedItem).Key);
         string seatId = lvSeats.SelectedItems[0].Name;
         return(selectedCinemaMovie.room.seats.Find(x => x.id == seatId));
     }
     else
     {
         return(null);
     }
 }
Example #5
0
        private void lvCinemaMovie_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvCinemaMovie.SelectedItems.Count > 0)
            {
                CinemaMovie selected = cinemaMovies.Find(x => x.id == lvCinemaMovie.SelectedItems[0].Name);

                dtpCinemaDate.Value = selected.date;
                dtpCinemaTime.Value = selected.time;
                cbbMovies.Text      = selected.movie.id + " - " + selected.movie.name;
                cbbRoom.Text        = selected.room.roomName;
            }

            SetButtonsEnableForCinemaMovies();
        }
Example #6
0
        private void btnAddCinemaMovie_Click(object sender, EventArgs e)
        {
            string      movieId        = ((KeyValuePair <string, string>)cbbMovies.SelectedItem).Key;
            Movie       movie          = movies.Find(x => x.id == movieId);
            CinemaMovie newCinemaMovie = new CinemaMovie((currentCinemaMovieId++).ToString(), movie, dtpCinemaDate.Value, dtpCinemaTime.Value, cbbRoom.Text);

            // add backend
            cinemaMovies.Add(newCinemaMovie);

            // add frontend
            lvCinemaMovie.Items.Add(newCinemaMovie.id, newCinemaMovie.movie.name, newCinemaMovie.movie.imageIndex);
            lvCinemaMovie.Refresh();
            lvCinemaMovie.Invalidate();

            lbCinemaNotify.BackColor = successNotifyColor;
            lbCinemaNotify.Text      = "Thêm xuất chiếu thành công";
        }
Example #7
0
        private void btnDeleteCinemaMovie_Click(object sender, EventArgs e)
        {
            if (lvCinemaMovie.SelectedItems.Count > 0)
            {
                CinemaMovie selected = cinemaMovies.Find(x => x.id == lvCinemaMovie.SelectedItems[0].Name);

                if (selected != null)
                {
                    // change cinema movie on backend
                    cinemaMovies.Remove(selected);

                    // change movie on frontend
                    lvCinemaMovie.Items.Remove(lvCinemaMovie.SelectedItems[0]);
                    lbCinemaNotify.BackColor = successNotifyColor;
                    lbCinemaNotify.Text      = "Xóa suất chiếu thành công";
                }
            }
        }
Example #8
0
        private void btnEditCinemaMovie_Click(object sender, EventArgs e)
        {
            if (lvCinemaMovie.SelectedItems.Count > 0)
            {
                CinemaMovie selected = cinemaMovies.Find(x => x.id == lvCinemaMovie.SelectedItems[0].Name);

                if (selected != null)
                {
                    // change cinema movie on backend
                    DateTime date = dtpCinemaDate.Value;
                    DateTime time = dtpCinemaTime.Value;
                    selected.date          = date;
                    selected.time          = time;
                    selected.room.roomName = cbbRoom.Text;

                    // change movie on frontend
                    lbCinemaNotify.BackColor = successNotifyColor;
                    lbCinemaNotify.Text      = "Sửa suất chiếu thành công";
                }
            }
        }