예제 #1
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);
            }
        }
예제 #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);
            }
        }