public fclsMain() { // // Required for Windows Form Designer support // InitializeComponent(); fileDB = new OleDbConnection(); albumApp = new fclsAlbum(); my_ListView.Items.Clear(); my_table = new DataTable(); // my_player = new AxWMPLib.AxWindowsMediaPlayer(); // // TODO: Add any constructor code after InitializeComponent call // }
private void toolBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) { if (e.Button == toolBarButton1) { if (dbOpen.ShowDialog() == DialogResult.OK ) { dbLocation = dbOpen.FileName; OpenDatabase(fileDB,dbLocation); albumApp = new fclsAlbum(dbLocation); my_table = new DataTable(); fileDB.Close(); ShowAlbums(); } } else if (e.Button == toolBarButton2) { NewAlbum(); } else if (e.Button == toolBarButton3) { EditAlbum(); } else if (e.Button == toolBarButton4) { DeleteAlbum(); } else if (e.Button == toolBarButton5) { PlayAlbum(); } }
public void EditAlbum() { try { if (my_ListView.SelectedItems.Count == 0) { MessageBox.Show("There is no album selected.", "Album Catalog", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // Find the album in the database. if (my_ListView.SelectedItems[0].SubItems[3].Text == "") { MessageBox.Show("Could not find artwork for album"); string noArtString = " "; albumApp = new fclsAlbum(dbLocation,my_ListView.SelectedItems[0].SubItems[0].Text,my_ListView.SelectedItems[0].SubItems[1].Text,my_ListView.SelectedItems[0].SubItems[2].Text,noArtString); } else albumApp = new fclsAlbum(dbLocation,my_ListView.SelectedItems[0].SubItems[0].Text,my_ListView.SelectedItems[0].SubItems[1].Text,my_ListView.SelectedItems[0].SubItems[2].Text,my_ListView.SelectedItems[0].SubItems[3].Text); if (albumApp.ShowDialog()==DialogResult.OK) { my_table.BeginLoadData(); for(int i=0; i<my_table.Rows.Count;i++) { if(my_table.Rows[i]["Title"].ToString() == my_ListView.SelectedItems[0].Text) { //MessageBox.Show("Deleting" + my_table.Rows[i]["Title"].ToString()); my_table.Rows[i].Delete(); } } my_ListView.SelectedItems[0].Remove(); my_table.LoadDataRow(albumApp.Row.ItemArray,false); my_table.EndLoadData(); my_adapter.Update(my_table); ShowAlbums(); } } catch (Exception ex) { MessageBox.Show("An error has occurred! Error: " + ex.Message, "Album Catalog", MessageBoxButtons.OK, MessageBoxIcon.Error); } }