Esempio n. 1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            String      keyword = textKeyword.Text.Trim();
            List <Song> songs   = new SongBUS().Search(keyword);

            gridSong.DataSource = songs;
        }
Esempio n. 2
0
 private void gridSong_SelectionChanged(object sender, EventArgs e)
 {
     if (gridSong.SelectedRows.Count > 0)
     {
         int  id   = int.Parse(gridSong.SelectedRows[0].Cells["Id"].Value.ToString());
         Song song = new SongBUS().GetDetails(id);
         if (song != null)
         {
             txtId.Text     = song.Id.ToString();
             txtTitle.Text  = song.Title;
             txtSinger.Text = song.Singer;
             txtAlbum.Text  = song.Album;
             txtGenre.Text  = song.Genre;
         }
     }
 }
Esempio n. 3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                int id = int.Parse(txtId.Text.Trim());

                bool result = new SongBUS().Delete(id);
                if (result)
                {
                    List <Song> songs = new SongBUS().GetAll();
                    gridSong.DataSource = songs;
                }
                else
                {
                    MessageBox.Show("Error");
                }
            }
        }
Esempio n. 4
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Song newSong = new Song()
            {
                Id     = int.Parse(txtId.Text.Trim()),
                Title  = txtTitle.Text.Trim(),
                Singer = txtSinger.Text.Trim(),
                Album  = txtAlbum.Text.Trim(),
                Genre  = txtGenre.Text.Trim(),
            };

            bool result = new SongBUS().Update(newSong);

            if (result)
            {
                List <Song> songs = new SongBUS().GetAll();
                gridSong.DataSource = songs;
            }
            else
            {
                MessageBox.Show("Error");
            }
        }
Esempio n. 5
0
        private void SongForm_Load(object sender, EventArgs e)
        {
            List <Song> songs = new SongBUS().GetAll();

            gridSong.DataSource = songs;
        }