Esempio n. 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!(validateUI(btnAdd)))
            {
                return;
            }

            try
            {
                Genre myGenre = new Genre();
                myGenre.id   = txtID.Text.Trim();
                myGenre.name = txtName.Text.Trim();

                bool status = GenreDB.AddGenre(myGenre);
                if (status) //returns true
                {
                    MessageBox.Show("Genre added to the database.", "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //Automatically refresh the data grid
                    this.btnBrowse_Click(null, null);
                }
                else //returns false
                {
                    MessageBox.Show("Genre was not added to the database.", "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //Automatically refresh the data grid
                    this.btnBrowse_Click(null, null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            //Validate the UI
            if (string.IsNullOrEmpty(txtGenreID.Text.Trim()))
            {
                MessageBox.Show("Please enter a genre id.");
                txtGenreID.Focus();
                return;
            }

            Genre objGenre = GenreDB.GetGenre(Convert.ToInt32(txtGenreID.Text.Trim()));

            //Step 2: Validate to make sure the Customer object is not null.
            if (objGenre != null)
            {
                //Populate the UI with the object values
                txtGenreName.Text = objGenre.Name;
                //make Genre ID field read-only to be used for updating and deleting records demo
                txtGenreID.ReadOnly = true;
            }
            else
            {
                MessageBox.Show("Genre ID " + txtGenreID.Text.Trim() + " not found in database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 3
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            if (!(validateUI(btnFind)))
            {
                return;
            }

            try
            {
                int   genreID  = Convert.ToInt32(txtID.Text.Trim());
                Genre objGenre = GenreDB.GetGenre(genreID);
                if (objGenre != null)
                {
                    txtName.Text   = objGenre.name;
                    txtID.ReadOnly = true;
                }
                else
                {
                    MessageBox.Show($"Genre ID(txtID.Text) not found in database.", "MeremacNetflix", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 4
0
        private void BrowseForm_Load(object sender, EventArgs e)
        {
            MovieList = MovieDB.GetMovies();
            genreList = GenreDB.GetGenres();

            ScrollDisplay(0);
        }
        private void populateGenreNames()
        {
            List <Genre> genres = GenreDB.GetGenres();

            cbGenre.DisplayMember = "Name";
            cbGenre.ValueMember   = "ID";
            cbGenre.DataSource    = genres;
        }
Esempio n. 6
0
 public MovieForm()
 {
     InitializeComponent();
     cmbGenre.DataSource    = GenreDB.GetGenres();
     cmbGenre.DisplayMember = "name";
     cmbGenre.SelectedIndex = -1;
     cmbGenre.Text          = "--Select--";
     cmbMovieRating.Text    = "--Select--";
     cmbRentalDuration.Text = "--Select--";
 }
Esempio n. 7
0
 public static List <BookDB> GenerateBooks(int count, AuthorDB author, GenreDB genre)
 {
     return(Fixture.Build <BookDB>()
            .With(x => x.Author, author)
            .With(x => x.AuthorId, author.Id)
            .With(x => x.Genre, genre)
            .With(x => x.GenreId, genre.Id)
            .CreateMany(count)
            .ToList());
 }
Esempio n. 8
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //Validate the UI
            if (string.IsNullOrEmpty(txtGenreID.Text.Trim()))
            {
                try
                {
                    List <Genre> genreList = new List <Genre>();
                    genreList = GenreDB.GetGenres();
                    int num = 1;
                    foreach (Genre genre in genreList)
                    {
                        if (num <= genre.ID)
                        {
                            num = genre.ID + 1;
                        }
                    }

                    txtGenreID.Text = num.ToString();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            if (string.IsNullOrEmpty(txtGenreName.Text.Trim()))
            {
                MessageBox.Show("Please enter a genre name.");
                txtGenreID.Focus();
                return;
            }

            Genre objGenre = new Genre();

            objGenre.ID   = Convert.ToInt32(txtGenreID.Text.Trim());
            objGenre.Name = txtGenreName.Text.Trim();
            try
            {
                bool status = GenreDB.AddGenre(objGenre);
                if (status) //You can use this syntax as well..if (status ==true)
                {
                    Reload_Data();
                    MessageBox.Show("Genre added to the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Genre was not added to database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void btn_Update_Click(object sender, EventArgs e)
 {
     if (GenreDB.UpdateGenre(GetGenreObjFromUI()))
     {
         MessageBox.Show("Update Successful.");
     }
     else
     {
         MessageBox.Show("Update Failed.");
     }
 }
 private void btn_Add_Click(object sender, EventArgs e)
 {
     if (GenreDB.AddGenre(GetGenreObjFromUI()))
     {
         MessageBox.Show("Add Successful.");
     }
     else
     {
         MessageBox.Show("Add Failed.");
     }
 }
Esempio n. 11
0
        private void movieForm_Load(object sender, EventArgs e)
        {
            Reload_Data();

            List <Genre> GenreList = GenreDB.GetGenres();

            foreach (Genre genre in GenreList)
            {
                cmbGenre.Items.Add(genre.Name);
            }
        }
Esempio n. 12
0
 private void genre_Load(object sender, EventArgs e)
 {
     try
     {
         List <Genre> genreList = new List <Genre>();
         genreList = GenreDB.GetGenres();
         dataGridView1.DataSource = genreList;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 13
0
 private void Reload_Data()
 {
     try
     {
         List <Genre> genreList = new List <Genre>();
         genreList = GenreDB.GetGenres();
         dataGridView1.DataSource = genreList;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 14
0
 private void PopulateGenreCB()
 {
     try
     {
         List <Genre> genres = GenreDB.GetGenres();
         cbGenre.DisplayMember = "Name";
         cbGenre.ValueMember   = "ID";
         cbGenre.DataSource    = genres;
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 15
0
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     //Call the GenreDB static class to fill the data grid
     try
     {
         List <Genre> genreList = new List <Genre>();
         genreList = GenreDB.GetGenres();
         dataGridView1.DataSource = genreList;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private void btn_Browse_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            foreach (Genre g in GenreDB.GetGenres())
            {
                //put each genre object into a datagridview row object
                DataGridViewRow newRow = new DataGridViewRow();

                //creates cells using dataGridView1 as a template
                newRow.CreateCells(dataGridView1);
                newRow.Cells[0].Value = g.id;
                newRow.Cells[1].Value = g.name;

                dataGridView1.Rows.Add(newRow);
            }
        }
Esempio n. 17
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            if (!(validateUI(btnBrowse)))
            {
                return;
            }

            try
            {
                List <Genre> myGenreList = new List <Genre>();
                myGenreList = GenreDB.GetGenres();
                dataGridView1.DataSource = myGenreList;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void MovieDataForm_Load(object sender, EventArgs e)
        {
            cmb_Rating.Items.Add("Select a rating");
            cmb_Rating.Items.Add("★☆☆☆☆");
            cmb_Rating.Items.Add("★★☆☆☆");
            cmb_Rating.Items.Add("★★★☆☆");
            cmb_Rating.Items.Add("★★★★☆");
            cmb_Rating.Items.Add("★★★★★");
            cmb_Rating.SelectedIndex = 0;

            genreList = GenreDB.GetGenres();
            cmb_Genre.Items.Add("Select a Genre");
            foreach (Genre g in genreList)
            {
                cmb_Genre.Items.Add(g.name);
            }
            cmb_Genre.SelectedIndex = 0;
        }
Esempio n. 19
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            //Validate the UI
            if (string.IsNullOrEmpty(txtGenreID.Text.Trim()))
            {
                MessageBox.Show("Please enter a genre id.");
                txtGenreID.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtGenreName.Text.Trim()))
            {
                MessageBox.Show("Please enter a genre name.");
                txtGenreID.Focus();
                return;
            }

            Genre objGenre = new Genre();

            objGenre.ID   = Convert.ToInt32(txtGenreID.Text.Trim());
            objGenre.Name = txtGenreName.Text.Trim();
            try
            {
                bool status = GenreDB.DeleteGenre(objGenre);
                if (status) //You can use this syntax as well..if (status ==true)
                {
                    Reload_Data();
                    MessageBox.Show("Genre was deleted from the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Genre was not deleted from the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 20
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            foreach (Control control in this.Controls)
            {
                if (control.GetType() != dataGridView1.GetType())
                {
                    if (string.IsNullOrEmpty(control.Text.Trim()))
                    {
                        MessageBox.Show("Please enter a value for " + control.Name.ToString());
                        control.Focus();
                        return;
                    }
                }
            }

            List <Genre> genreList = GenreDB.GetGenres();

            int genreid = 0;

            foreach (Genre genre in genreList)
            {
                if (genre.Name == cmbGenre.Text.Trim())
                {
                    genreid = genre.ID;
                }
            }



            Movie objMovie = new Movie();

            objMovie.movie_number      = Convert.ToInt32(txtMovieNumber.Text);
            objMovie.movie_title       = txtTitle.Text.ToString();
            objMovie.Description       = txtDescription.Text.ToString();
            objMovie.movie_year_made   = Convert.ToInt32(txtYear.Text);
            objMovie.genre_id          = genreid;
            objMovie.movie_rating      = cmbRating.Text;
            objMovie.media_type        = cmbMediaType.Text;
            objMovie.movie_retail_cost = returnDecimal(txtRetailCost.Text);
            objMovie.movie_rental_cost = returnDecimal(txtRentalCost.Text);
            objMovie.copies_on_hand    = Convert.ToInt32(txtCopies.Text);
            objMovie.image             = txtImage.Text;
            objMovie.trailer           = txtTrailer.Text;

            //if(lblPicture.Text != string.Empty)
            //{
            //    objMember.photo = lblPicture.Text;
            //}


            try
            {
                bool status = MovieDB.AddMovie(objMovie);
                if (status) //You can use this syntax as well..if (status ==true)
                {
                    Reload_Data();
                    MessageBox.Show("Movieadded to the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Movie was not added to database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }