示例#1
0
        private void addSeatToChosenList(ImageButton imgBtn)
        {
            System.Diagnostics.Debug.WriteLine(">> addSeatToChosenList( imgBtn.ID=" + imgBtn.ID + ")");
            //throw new NotImplementedException();
            SeatMovie aSeatMovie = null;
            int aSeatMovieID = int.MinValue, seatID;

            if (imgBtn.CommandArgument == string.Empty)
            {
                System.Diagnostics.Debug.WriteLine(">> addSeatToChosenList( imgBtn.ID=" + imgBtn.ID + ") if (imgBtn.CommandArgument == string.Empty)");
                // no SeatMovie instance for this RoomMovie hasn't been made before
                // therefore make new SeatMovie

                if (int.TryParse(imgBtn.CommandName, out seatID))
                {
                    System.Diagnostics.Debug.WriteLine(">> addSeatToChosenList( imgBtn.ID=" + imgBtn.ID + ") if (int.TryParse(imgBtn.CommandName, out seatID))");
                    aSeatMovie = new SeatMovie();

                    aSeatMovie.Seat_ID = seatID;
                    aSeatMovie.RoomMovie_ID = roomMovieID;
                    aSeatMovie.Occupied = false;
                    aSeatMovie.Active_Indicator = true;
                    aSeatMovie.Update_Datetime = DateTime.Now;

                    try
                    {
                        aSeatMovieID = Business_Logic.RoomMovieLogic.insertNewSeatMovie(aSeatMovie);
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(">> ERROR: addSeatToChosenList ex.Message=" + ex.Message);
                    }

                    if (aSeatMovieID > 0)
                    {
                        System.Diagnostics.Debug.WriteLine(">> addSeatToChosenList( imgBtn.ID=" + imgBtn.ID + ") if (aSeatMovieID > 0)");
                        // successful insertion into SeatMovie
                        aSeatMovie.SeatMovie_ID = aSeatMovieID;
                        imgBtn.CommandArgument = aSeatMovieID.ToString();
                        lblChosenSeatMovieID.Text = imgBtn.CommandArgument;

                        if (!listChosenSeatMovies.Contains(aSeatMovie))
                        {
                            System.Diagnostics.Debug.WriteLine(">> addSeatToChosenList( imgBtn.ID=" + imgBtn.ID + ") if (!listChosenSeatMovies.Contains(aSeatMovie))");
                            listChosenSeatMovies.Add(aSeatMovie);
                            updateLblChosenSeats();
                        }
                    }
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine(">> addSeatToChosenList( imgBtn.ID=" + imgBtn.ID + ") if (int.TryParse(imgBtn.CommandName, out seatID)) else");
                    // ERROR?!
                    // all free seats should have their own associated seatID
                    System.Diagnostics.Debug.WriteLine(">> addSeatToChosenList ERROR: Cannot Parse imgBtn.CommandName=" + imgBtn.CommandName);
                }
                
            }
            else
            {
                System.Diagnostics.Debug.WriteLine(">> addSeatToChosenList( imgBtn.ID=" + imgBtn.ID + ") if (imgBtn.CommandArgument == null) else");
                // there exists a SeatMovie instance for this RoomMovie already
                if (int.TryParse(imgBtn.CommandArgument, out aSeatMovieID))
                {
                    System.Diagnostics.Debug.WriteLine(">> addSeatToChosenList( imgBtn.ID=" + imgBtn.ID + ") if (int.TryParse(imgBtn.CommandArgument, out aSeatMovieID))");
                    try
                    {
                        aSeatMovie = Business_Logic.RoomMovieLogic.getSeatMovieByPK(aSeatMovieID);
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(">> ERROR: addSeatToChosenList ex.Message=" + ex.Message);
                    }

                    if (aSeatMovie != null)
                    {
                        System.Diagnostics.Debug.WriteLine(">> addSeatToChosenList( imgBtn.ID=" + imgBtn.ID + ") if (aSeatMovie != null)");
                        // found but have to check if it already exists in the list

                        if (!listChosenSeatMovies.Contains(aSeatMovie))
                        {
                            System.Diagnostics.Debug.WriteLine(">> addSeatToChosenList( imgBtn.ID=" + imgBtn.ID + ") if (!listChosenSeatMovies.Contains(aSeatMovie))");
                            listChosenSeatMovies.Add(aSeatMovie);
                            updateLblChosenSeats();
                        }
                    }
                }

            }
        }
示例#2
0
        private void processSeatMovie(SeatMovie seatMovie, out bool imgBtnEnabled, out System.Drawing.Color seatColour)
        {
            System.Diagnostics.Debug.WriteLine(">> processSeatMovie( seatMovieID=" + seatMovie.SeatMovie_ID + " .. )");
            //throw new NotImplementedException();

            imgBtnEnabled = true;
            seatColour = seatColourFree;

            if (seatMovie.Active_Indicator == true)
            {
                if (seatMovie.Occupied == true)
                {
                    // Booked
                    imgBtnEnabled = false;
                    seatColour = seatColourBooked;
                }
                else
                {
                    // Free
                    imgBtnEnabled = true;
                    seatColour = seatColourFree;
                }
            }
            else
            {
                if (seatMovie.Occupied == true)
                {
                    // OnHold
                    imgBtnEnabled = false;
                    seatColour = seatColourOnHold;
                }
                else
                {
                    // chosen
                    imgBtnEnabled = true;
                    //seatColour = seatColourChosen;
                    seatColour = seatColourFree; // ignore the chosen colour
                }

            }

        }