예제 #1
0
파일: FrmSong.cs 프로젝트: windygu/KtvMS
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbDelete_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtId.Text))
            {
                MessageBox.Show("请选择要删除的歌曲!!!", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (dgvSongs.SelectedRows.Count > 0)
            {
                if (MessageBox.Show("会永久删除本地歌曲!!确定要继续删除该歌曲吗?", "温馨提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
                {
                    int    SongId   = Convert.ToInt32(dgvSongs.SelectedRows[0].Cells["编号"].Value);
                    String songName = dgvSongs.SelectedRows[0].Cells["歌曲全名"].Value.ToString();
                    if (songManager.DeleteSongById(SongId) > 0)
                    {
                        String songPath = filePath + songName;
                        System.IO.File.Delete(songPath);//删除该行歌曲

                        bindDgvSongs();
                        Reset();
                    }
                }
            }
        }