Пример #1
0
        private void AddMovieToDbButton1_Click(object sender, EventArgs e)
        {
            wcfHostService wcfs = new wcfHostService();
            Movie mov;
            //List<Movie> movList = new List<Movie>();
            try
            {
                string title;
                string director;
                string category;
                int releaseDate;
                int movLength;
                int movId;

                title = TitleTextBox.Text;
                director = DirectorTextBox.Text;
                category = CategoryTextBox.Text;
                releaseDate = int.Parse(ReleaseDateTextBox.Text);
                movLength = int.Parse(LengthTextBox.Text);
                movId = int.Parse(textBox1.Text);

                mov = new Movie(movId, director, title, category, movLength, releaseDate);
                //movList.Add(mov);

                wcfs.InsertMovie(mov);

            }
            catch (Exception)
            {
                throw;
            }
            //if this shows up you got all the types right
            MessageBox.Show("Movie added");
        }
Пример #2
0
        //Method to return all movies.
        public List<Movie> ShowAllMovies()
        {
            Movie mov = null;
            SqlDataReader reader = null;
            List<Movie> allMovList = new List<Movie>();
            try
            {
                dbConn.Open();
                SqlCommand command = new SqlCommand(("SELECT * FROM CinemaMovie"), dbConn);
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    mov = new Movie((int)reader["movieId"], (string)reader["director"], (string)reader["Title"], (string)reader["category"], (int)reader["movlength"], (int)reader["releaseDate"]);

                    allMovList.Add(mov);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                reader.Close();
                dbConn.Close();
            }
            return allMovList;
        }
Пример #3
0
 public Movie(Movie movie)
 {
     this.title = title;
     this.director = director;
     this.releaseDate = releaseDate;
     this.category = category;
     this.length = length;
     this.minAge = minAge;
     this.movId = movId;
     this.movie = movie;
     this.screenNo = screenNo;
 }
Пример #4
0
 public Order(Movie title, String date, int time, Screen screenNo, int seatAmount, double price, int orderId, Person empId, Costumer cosId, Costumer phoneNo)
 {
     this.title = title;
     this.date = date;
     this.time = time;
     this.screenNo = screenNo;
     this.seatAmount = seatAmount;
     this.price = price;
     this.orderId = orderId;
     this.empId = empId;
     this.cosId = cosId;
     this.phoneNo = phoneNo;
 }
Пример #5
0
        public Movie MovieObject(Movie title, Movie director, Movie releaseDate, Movie category, Movie length, Movie movId)
        {
            Movie mov = new Movie();
            Console.WriteLine(mov.ToString(title));
            Console.WriteLine(mov.ToString(director));
            Console.WriteLine(mov.ToString(releaseDate));
            Console.WriteLine(mov.ToString(category));
            Console.WriteLine(mov.ToString(length));

            Console.WriteLine(mov.ToString(movId));

            return mov;
        }
Пример #6
0
        //Method to delete a Movie.
        //same lazy errorhandling as InsertMovie
        public int DeleteMovie(int movId, Movie mov)
        {
            int result = 0;
            try
            {
                dbConn.Open();
                SqlCommand command = new SqlCommand("DELETE FROM CinemaMovie WHERE VALUES (@movMovId)", dbConn);
                command.Parameters.Add("@movMovId", SqlDbType.VarChar).Value = mov.movId;
                result = command.ExecuteNonQuery();
            }

            catch (SqlException)
            {
                result = -1;
            }
            finally
            {
                if (dbConn != null) { dbConn.Close(); }
            }
            return result;
        }
Пример #7
0
 public Movie MovieObject(Movie title, Movie director, Movie releaseDate, Movie category, Movie length, Movie minAge, Movie movId, Movie screenNo)
 {
     Movie mov = new Movie();
     Console.WriteLine(mov.ToString(title));
     Console.WriteLine(mov.ToString(director));
     Console.WriteLine(mov.ToString(releaseDate));
     Console.WriteLine(mov.ToString(category));
     Console.WriteLine(mov.ToString(length));
     Console.WriteLine(mov.ToString(minAge));
     Console.WriteLine(mov.ToString(movId));
     Console.WriteLine(mov.ToString(screenNo));
     //mov.title = title;
     //mov.director = director;
     //mov.releaseDate = releaseDate;
     //mov.category = category;
     //mov.length = length;
     //mov.minAge = minAge;
     //mov.movId = movId;
     //mov.screenNo = screenNo;
     return mov;
 }
Пример #8
0
 internal string ToString(Movie title)
 {
     throw new NotImplementedException();
 }
Пример #9
0
 public Movie(Movie movie)
 {
     // TODO: Complete member initialization
     this.movie = movie;
 }
Пример #10
0
 public int InsertMovie(Movie mov)
 {
     return mctrh.InsertMovie(mov);
 }
Пример #11
0
        //Method to return all movies.
        public List<Movie> ShowAllMovies()
        {
            Movie mov;
            SqlDataReader reader = null;
            List<Movie> allMovList = new List<Movie>();

            try
            {
                dbConn.Open();
                SqlCommand command = new SqlCommand(selectMov, dbConn);
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    mov = new Movie((Movie)reader["movId"]);
                    //if (reader["title" + "director" + "releaseDate" + "category" + "length" + "minAge"] != null)
                    //{
                    //    mov.title = (Movie)reader["Title"];
                    //    mov.director = (Movie)reader["director"];
                    //    mov.releaseDate = (Movie)reader["releaseDate"];
                    //    mov.category = (Movie)reader["category"];
                    //    mov.length = (Movie)reader["length"];
                    //    mov.minAge = (Movie)reader["minAge"];
                    //}

                    allMovList.Add(mov);
                }
            }

            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return allMovList;
        }
Пример #12
0
 //Method to insert Costumer. Takes movId, title, director, releaseDate, category, length and minAge - though only a movId is needed.
 // 0 = default state. 1 = success. -1 = error. Perhaps should implement more usefull errorhandling.
 //(See SQLException class on msdn)
 internal int InsertMovie(Movie mov)
 {
     int result = 0;
     try
     {
         dbConn.Open();
         SqlCommand command = new SqlCommand("INSERT INTO CinemaMovie VALUES (@movieId, @Title, @director, @releaseDate, @category, @length, @minAge)", dbConn);
         command.CommandType = CommandType.Text;
         command.Parameters.Add("@movieId", SqlDbType.VarChar).Value = mov.movId;
         command.Parameters.Add("@Title", SqlDbType.Text).Value = mov.title;
         command.Parameters.Add("@director", SqlDbType.Text).Value = mov.director;
         command.Parameters.Add("@releaseDate", SqlDbType.Text).Value = mov.releaseDate;
         command.Parameters.Add("@category", SqlDbType.Text).Value = mov.category;
         command.Parameters.Add("@length", SqlDbType.VarChar).Value = mov.length;
         command.Parameters.Add("@minAge", SqlDbType.VarChar).Value = mov.minAge;
         command.Parameters.Add("@screenNo", SqlDbType.VarChar).Value = mov.screenNo;
         result = command.ExecuteNonQuery();
     }
     catch (SqlException)
     {
         result = -1;
     }
     finally
     {
         if (dbConn != null) { dbConn.Close(); }
     }
     return result;
 }
Пример #13
0
        //private string insertMov = "INSERT INTO CinemaMovie VALUES (@cosPhoneNo, @cosFname, @cosLname, @cosEmail)";
        //private string deleteMov = "DELETE FROM CinemaMovie";
        //Method to return movie by movieID as input.
        public List<Movie> ShowMovie(int movId)
        {
            Movie mov;
            SqlDataReader reader = null;
            List<Movie> movList = new List<Movie>();
            try
            {
                dbConn.Open();
                SqlCommand command = new SqlCommand(("SELECT (@movieId) FROM CinemaMovie"), dbConn);
                command.Parameters.Add("@movId", SqlDbType.VarChar).Value = "%" + movId + "%";
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    mov = new Movie((Movie)reader["movId"]);
                    //if (reader["title" + "director" + "releaseDate" + "category" + "length" + "minAge" ] != null)
                    //{
                    //    mov.title = (Movie)reader["title"];
                    //    mov.director = (Movie)reader["director"];
                    //    mov.releaseDate = (Movie)reader["releaseDate"];
                    //    mov.category = (Movie)reader["category"];
                    //    mov.length = (Movie)reader["length"];
                    //    mov.minAge = (Movie)reader["minAge"];
                    //}

                    movList.Add(mov);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (dbConn != null)
                {
                    dbConn.Close();
                }
            }
            return movList;
        }
Пример #14
0
 public int InsertMovie(Movie mov)
 {
     // insert movie not made in MovieDB yet
     return mDB.InsertMovie(mov);
 }
Пример #15
0
        //Method to return movie by movieID as input.
        public List<Movie> ShowMovie(int movId)
        {
            Movie mov = null;
            SqlDataReader reader = null;
            List<Movie> movList = new List<Movie>();
            try
            {
                dbConn.Open();
                SqlCommand command = new SqlCommand(("SELECT * FROM CinemaMovie WHERE (@movieId) = (movieId)"), dbConn);
                command.Parameters.Add("@movieId", SqlDbType.Int).Value = movId;
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    mov = new Movie((int)reader["movieId"], (string)reader["director"], (string)reader["Title"], (string)reader["category"], (int)reader["movlength"], (int)reader["releaseDate"]);

                    movList.Add(mov);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                reader.Close();
                dbConn.Close();
            }
            return movList;
        }
Пример #16
0
        //Method to insert Costumer. Takes movId, title, director, releaseDate, category, length and minAge - though only a movId is needed.
        // 0 = default state. 1 = success. -1 = error. Perhaps should implement more usefull errorhandling.
        //(See SQLException class on msdn)
        internal int InsertMovie(Movie mov)
        {
            int result = 0;
            try
            {
                Monitor.TryEnter(obj);
                SqlCommand command = new SqlCommand(("INSERT INTO CinemaMovie (movieId, Title, director, releaseDate, category, movlength) VALUES ((@movieId), (@Title), (@director), (@releaseDate), (@category), (@movlength))"), dbConn);

                command.Parameters.Add("@movieId", SqlDbType.Int).Value = mov.movId;
                command.Parameters.Add("@director", SqlDbType.VarChar).Value = mov.director;
                command.Parameters.Add("@Title", SqlDbType.VarChar).Value = mov.title;
                command.Parameters.Add("@releaseDate", SqlDbType.Int).Value = mov.releaseDate;
                command.Parameters.Add("@category", SqlDbType.VarChar).Value = mov.category;
                command.Parameters.Add("@movlength", SqlDbType.Int).Value = mov.length;

                dbConn.Open();
                result = command.ExecuteNonQuery();
            }

            catch (SqlException)
            {
                throw;
                result = -1;

            }
            finally
            {
                dbConn.Close();
                Monitor.Exit(obj);

            }
            return result;
        }