Пример #1
0
        public bool RemoveMovie(MovieClass m)
        {
            foreach (MovieClass Name in Movie)
            {
                if (m.MovieName == Name.MovieName)
                {
                    Movie.Remove(m);

                    return(true);
                }
            }
            return(false);
        }
Пример #2
0
        //Add the movie - with input validation

        private void btnAdd_Click(object sender, EventArgs e)
        {
            //If the user left it blank => Inform to enter all the value

            if (string.IsNullOrWhiteSpace(txtNameMovie.Text) ||
                string.IsNullOrWhiteSpace(txtNameActor.Text) ||
                string.IsNullOrWhiteSpace(txtYear.Text) ||
                string.IsNullOrWhiteSpace(cmbGenre.Text))
            {
                MessageBox.Show("Please enter all the value", "Error");
            }
            else
            {
                if (Convert.ToInt32(txtYear.Text) > 2016 || Convert.ToInt32(txtYear.Text) < 1900)
                {
                    MessageBox.Show("Please enter a correct year", "Error");             //Input validation for year of the movie
                }
                else
                {
                    moviefun = new MovieClass(txtNameMovie.Text,
                                              cmbGenre.Text,
                                              txtNameActor.Text,
                                              Convert.ToInt32(txtYear.Text));

                    //Add movie into collection (temporary) - Close and that's it
                    movieLists.AddMovie(moviefun);
                    txtNameActor.Text = "";
                    txtNameMovie.Text = "";
                    txtYear.Text      = "";

                    //Write the movie into the text file. Case sensitive
                    bool success = movieLists.WriteIntoText();
                    if (success)
                    {
                        MessageBox.Show("Successed", "Result");
                    }
                    else
                    {
                        MessageBox.Show("Failed", "Result");
                    }
                }
            }
        }
Пример #3
0
 public void AddMovie(MovieClass m)
 {
     Movie.Add(m);
 }