示例#1
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            // The user clicked on the AddAlbum OK button

            int albumYear;

            int.TryParse(this.yearTextBox.Text, out albumYear);
            int artistId;

            int.TryParse(artistComboBox.SelectedValue.ToString(), out artistId);
            string albumTitle  = this.albumTitleTextBox.Text;
            int    albumRating = ratingComboBox.SelectedIndex;
            int    genreId;

            int.TryParse(genreComboBox.SelectedValue.ToString(), out genreId);

            // todo: validation

            int    AlbumId = Album.AddAlbum(albumYear, artistId, albumTitle, albumRating, genreId);
            string msg     = "AlbumID=" + AlbumId.ToString();

            MessageBox.Show(msg);

            if (AlbumId > 0)
            {
                bool repeat = true;
                while (repeat)
                {
                    // This creates an AddSong pop-up.
                    AddSongWF    frm = new AddSongWF();
                    DialogResult dr  = frm.ShowDialog(this);

                    // If the user clicked the OK button on the AddSong pop-up
                    if (dr == DialogResult.Yes)
                    {
                        MessageBox.Show("AddAlbum: AddSong - User clicked Yes button");
                        repeat = true;
                    }
                    else if (dr == DialogResult.OK)
                    {
                        MessageBox.Show("AddAlbum: AddSong - User clicked OK button");
                        this.Close();
                        repeat = false;
                    }
                    // if the Cancel button or the X was clicked on the AddSong pop-up...
                    else if (dr == DialogResult.Cancel)
                    {
                        MessageBox.Show("AddAlbum: AddSong - User clicked Cancel button");
                        this.Close();
                        repeat = false;
                    }
                }
            }

            // Close the AddAlbum form
            this.Close();
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddSongButton_Click(object sender, EventArgs e)
        {
            bool repeat = true;

            while (repeat)
            {
                DialogResult dr  = new DialogResult();
                AddSongWF    frm = new AddSongWF();

                dr = frm.ShowDialog();
                if (dr == DialogResult.Yes)
                {
                    MessageBox.Show("Main: AddSong: User clicked YES button");
                    this.songViewTableAdapter.Fill(this.cDCatalogDataSet1.SongView);

                    // the following did not work with selecting a row and did not fill the entire grid (of course):
                    // List<CDCatalogEF.Song> songList = Song.GetAllSongs();
                    // this.songDataGridView.DataSource = songList;
                    repeat = true;
                }
                if (dr == DialogResult.OK)
                {
                    MessageBox.Show("Main: AddSong: User clicked OK button");
                    this.songViewTableAdapter.Fill(this.cDCatalogDataSet1.SongView);

                    // the following did not work with selecting a row and did not fill the entire grid (of course):
                    // List<CDCatalogEF.Song> songList = Song.GetAllSongs();
                    // this.songDataGridView.DataSource = songList;
                    repeat = false;
                }
                else if (dr == DialogResult.Cancel)
                {
                    MessageBox.Show("Main: AddSong: User clicked Cancel button");
                    repeat = false;
                }
            }
        }
示例#3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddSongButton_Click(object sender, EventArgs e)
        {
            bool repeat = true;
            while (repeat)
            {
                DialogResult dr = new DialogResult();
                AddSongWF frm = new AddSongWF();

                dr = frm.ShowDialog();
                if (dr == DialogResult.Yes)
                {
                    MessageBox.Show("Main: AddSong: User clicked YES button");
                    this.songViewTableAdapter.Fill(this.cDCatalogDataSet1.SongView);

                    // the following did not work with selecting a row and did not fill the entire grid (of course):
                    // List<CDCatalogEF.Song> songList = Song.GetAllSongs();
                    // this.songDataGridView.DataSource = songList;
                    repeat = true;
                }
                if (dr == DialogResult.OK)
                {
                    MessageBox.Show("Main: AddSong: User clicked OK button");
                    this.songViewTableAdapter.Fill(this.cDCatalogDataSet1.SongView);

                    // the following did not work with selecting a row and did not fill the entire grid (of course):
                    // List<CDCatalogEF.Song> songList = Song.GetAllSongs();
                    // this.songDataGridView.DataSource = songList;
                    repeat = false;
                }
                else if (dr == DialogResult.Cancel)
                {
                    MessageBox.Show("Main: AddSong: User clicked Cancel button");
                    repeat = false;
                }
            }
        }