/// <summary> /// 根据user创建数据库,把昵称传给mainwindow /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { int user = Convert.ToInt32(textBox1.Text); MySQLConn.CreateDB(textBox3.Text); //根据昵称创建数据库 MySQLConn.InsertUser(user, textBox2.Text, textBox3.Text); //保存用户名和密码到数据库 MySQLConn.CreateTable(textBox3.Text, "love"); MySQLConn.CreateTable(textBox3.Text, "history"); MySQLConn.CreateTable(textBox3.Text, "songlist"); }
/// <summary> /// 删除歌单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeleteSongListItem_Click(object sender, EventArgs e) { int index = SongsList.SelectedIndex;//获取被选择的歌单的index if (index > 2) { MySQLConn.DeleteTable(label1.Text, SongLists[index].listName); MenuList.RemoveAt(index); SongsList.Items.RemoveAt(index); SongLists.RemoveAt(index); } else { MessageBox.Show(@"“我喜欢”,“播放历史”,“默认歌单” 不能删除"); } }
private void button1_Click(object sender, EventArgs e) { int user = Convert.ToInt32(textBox1.Text); string password = MySQLConn.QueryPassword(user); string name = MySQLConn.QueryName(user); if (password == textBox2.Text) { MainWindow mainWindow = new MainWindow(name); mainWindow.Show(); } else { MessageBox.Show("用户名或密码不正确!"); } }
/// <summary> /// 添加歌单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddList_Click(object sender, EventArgs e) { string name = null; NameDialog Dialog = new NameDialog("new_songlist"); if (Dialog.ShowDialog() == DialogResult.OK) //弹出命名对话框 { name = Dialog.Result; //获得新名字 } //添加新歌单控件 MenuList.Add(new Item(Resources.list, name)); SongsList.Items.Add(name); //添加新歌单 SongList songList = new SongList(name); SongLists.Add(songList); MySQLConn.CreateTable(label1.Text, name);//数据库创建一个表 }
/// <summary> /// 添加本地歌曲 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddSongItem_Click(object sender, EventArgs e) { int index = SongsList.SelectedIndex;//被选中的歌单 string ResultFile; openFileDialog1.InitialDirectory = "C:\\"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { ResultFile = openFileDialog1.FileName;//目标音乐文件地址 Song song = new Song(ResultFile); if (SongLists[index].songList.Contains(song)) { MessageBox.Show("不能重复添加相同歌曲!"); return; } SongLists[index].AddSong(song);//将音乐加入音乐列表 MySQLConn.InsertSong(label1.Text, SongLists[index].listName, song.URL); } DrawSongs(); }
public MainWindow(string userName) { InitializeComponent(); MenuList = new List <Item>(); SongLists = new List <SongList>(); List <string> temp = MySQLConn.GetTableName(userName); foreach (string s in temp) { MenuList.Add(new Item(Resources.love, s)); SongsList.Items.Add(s); SongLists.Add(MySQLConn.Getsonglist(userName, s)); } timer1.Start(); timer2.Start(); label1.Text = userName; label1.Visible = true; Initialize(userName); }