/// <summary> /// Deletes the selected folder in the TreeView /// </summary> private void albumDeletion() { if (tvFolders.Nodes.Count > 0) { if (tvFolders.SelectedNode != null && tvFolders.SelectedNode.Parent != null) { if (SQLRequests.isFolderExisting(tvFolders.SelectedNode.Text, Int32.Parse(tvFolders.SelectedNode.Parent.Text))) { DialogResult dialogResult = MessageBox.Show("Do you really want to delete this album ?", "Album delete", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { int res = SQLRequests.deleteFolder(tvFolders.SelectedNode.Text, Int32.Parse(tvFolders.SelectedNode.Parent.Text)); Directory.Delete(@".\Cache\" + tvFolders.SelectedNode.Parent.Text + @"\" + tvFolders.SelectedNode.Text, true); updateTreeViewNodes(); imageList.Images.Clear(); lvImages.Clear(); } } else { MessageBox.Show("Please select a valid folder"); } } else { MessageBox.Show("Please select a valid folder"); } } else { MessageBox.Show("Please select a valid folder"); } }
/// <summary> /// Opens new folder dialog and insert it into DB /// </summary> private void bNewAlbum_Click(object sender, EventArgs e) { SelectNewFolder f = new GalleryApp.SelectNewFolder(); f.ShowDialog(); String fullPath = f.getFolderPath(); int year = f.getYear(); String place = f.getPlace(); if (fullPath != null && year != -1) { if (!SQLRequests.isFolderExisting(fullPath)) { SQLRequests.insertNewFolder(fullPath, year, place); updateTreeViewNodes(); } else { MessageBox.Show("This album already exists"); } } }