1 |
using System; |
2 |
using System.Windows.Forms; |
3 |
using System.IO; |
4 |
|
5 |
namespace MusicOrganiser |
6 |
{ |
7 |
public partial class NewEntry : Form |
8 |
{ |
9 |
|
10 |
|
11 |
Form1 mainForm; |
12 |
public NewEntry(Form1 mainForm) |
13 |
{ |
14 |
this.mainForm = mainForm; |
15 |
|
16 |
InitializeComponent(); |
17 |
} |
18 |
|
19 |
private void button1_Click(object sender, EventArgs e) |
20 |
{ |
21 |
this.folderBrowserDialog1.ShowNewFolderButton = false; |
22 |
DialogResult result = this.folderBrowserDialog1.ShowDialog(); |
23 |
if (result == DialogResult.OK) |
24 |
{ |
25 |
// retrieve the name of the selected folder |
26 |
DirectoryInfo dir = new DirectoryInfo(this.folderBrowserDialog1.SelectedPath); |
27 |
|
28 |
// Entries for the first table |
29 |
mainForm.categoryTextBox.Text = comboBox1.Text; |
30 |
mainForm.artistTextBox.Text = textBox1.Text; |
31 |
mainForm.albumTextBox.Text = dir.Name; |
32 |
|
33 |
DataMusicDataSet.SongFilesRow newrow = dataMusicDataSet1.SongFiles.NewSongFilesRow(); |
34 |
|
35 |
//Now to get every song in the folder or cd |
36 |
foreach (FileInfo fi in dir.GetFiles()) |
37 |
{ |
38 |
|
39 |
newrow.Song = fi.ToString(); // Getting filename |
40 |
newrow.SongUrl = fi.FullName; // Getting full path to play the song when click |
41 |
|
42 |
dataMusicDataSet1.SongFiles.Rows.Add(newrow); |
43 |
//mainForm.songbindingNavigator.BindingSource.Add(newrow); |
44 |
|
45 |
} |
46 |
} |
47 |
else |
48 |
{ |
49 |
//If cancel close form NewEntry |
50 |
this.Close(); |
51 |
} |
52 |
|
53 |
|
54 |
} |
55 |
|
56 |
private void OK_Click(object sender, EventArgs e) |
57 |
{ |
58 |
this.Close(); |
59 |
} |
60 |
|
61 |
|
62 |
} |
63 |
} |
64 |
|