private void cmbTheatreList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbTheatreList.SelectedIndex > -1)
            {
                MovieTheatre theatre = (MovieTheatre)cmbTheatreList.SelectedItem;

                lblTheatreNumber.Text = theatre.MovieTheatreID.ToString();
                lblTheatreName.Text   = theatre.MovieTheatreName;
                lblCapacity.Text      = theatre.SeatingCapacity.ToString();
            }

            ClearForm.DisposePanels(this);

            if (cmbTheatreList.SelectedIndex == 0)
            {
                CreateTheatre.TheatreA(this);
            }
            else if (cmbTheatreList.SelectedIndex == 1)
            {
                ;
                CreateTheatre.TheatreB(this);
            }
            if (cmbTheatreList.SelectedIndex == 2)
            {
                CreateTheatre.TheatreC(this);
            }
        }
示例#2
0
        public static List <MovieTheatre> GetTheatreList()
        {
            List <MovieTheatre> theatreList = new List <MovieTheatre>();

            SqlConnection sqlConnection = new SqlConnection(ConfigurationManager
                                                            .ConnectionStrings["MasterCinemaConnection"].ConnectionString);

            SqlCommand selectCommand = new SqlCommand("SELECT ID, Name, SeatingCapacity FROM MovieTheater");

            selectCommand.Connection = sqlConnection;

            try
            {
                if (sqlConnection.State == System.Data.ConnectionState.Closed)
                {
                    sqlConnection.Open();
                }


                SqlDataReader dataReader = selectCommand.ExecuteReader();
                MovieTheatre  theatre;
                while (dataReader.Read())
                {
                    theatre = new MovieTheatre();
                    theatre.MovieTheatreID   = (int)dataReader["ID"];
                    theatre.MovieTheatreName = (string)dataReader["Name"];
                    theatre.SeatingCapacity  = (byte)dataReader["SeatingCapacity"];

                    theatreList.Add(theatre);
                }
            }
            catch (Exception) { throw; }
            finally { sqlConnection.Close(); }

            return(theatreList);
        }