第一步:创建数据库连接方法和打开方法和关闭方法!

 1  public class DBHelper
 2     {
 3        private  string str = "server=.;database=MyKtv;uid=sa";
 4        private SqlConnection _conection;
 5
 6        public SqlConnection Conection
 7        {
 8            get
 9            {
10                if (_conection==null)
11                {
12                    _conection = new SqlConnection(str);
13                }
14                return _conection;
15            }
16        }
17        /// <summary>
18        /// 打开方法
19        /// </summary>
20        public void OpenConnection()
21        {
22            if (Conection.State == ConnectionState.Closed)
23            {
24                Conection.Open();
25            } if (Conection.State == ConnectionState.Broken)
26            {
27                Conection.Close();
28                Conection.Open();
29            }
30        }
31        /// <summary>
32        /// 关闭方法`
33        /// </summary>
34        public void CloseConnection()
35        {
36            if (Conection.State == ConnectionState.Open && Conection.State == ConnectionState.Broken)
37            {
38                Conection.Close();
39            }
40
41        }

第二步:歌曲首页

歌曲首页:用到了窗体之间的转换和读取路径表中的图片路径放到filepath上

 1 public partial class FormMain : Form
 2     {
 3         DBHelper db = new DBHelper();
 4         public FormMain()
 5         {
 6             InitializeComponent();
 7         }
 8         private void Form1_Load(object sender, EventArgs e)
 9         {
10             //读取路径表中的图片路径放到filepath上
11             string sql = "select resource_path from resource_path where resource_id=1";
12             SqlCommand cmd = new SqlCommand(sql,db.Conection);
13             db.OpenConnection();
14             KtvUtil.FilePath = cmd.ExecuteScalar().ToString();
15             db.CloseConnection();
16         }
17
18         private void pictureBox1_Click(object sender, EventArgs e)
19         {
20             //打开明星点歌窗体
21             FrmSinger frmSinger = new FrmSinger();
22             frmSinger.Show();
23         }
24
25         private void toolStripButton4_Click(object sender, EventArgs e)
26         {
27             this.Close();
28         }
29
30         private void pictureBox4_Click(object sender, EventArgs e)
31         {
32             //打开拼音点歌窗体
33             FrmOrderBySongName fobsn = new FrmOrderBySongName();
34             fobsn.ShowDialog();
35         }

第三步:歌星点歌

歌星点歌:用到了3个ListView之间的跳转,

  1 public partial class FrmSinger : Form
  2     {
  3         DBHelper db = new DBHelper();
  4         public string SingerType = "组合";
  5         public int SingerId = 0;
  6
  7         public FrmSinger()
  8         {
  9             InitializeComponent();
 10         }
 11
 12         private void panel1_Paint(object sender, PaintEventArgs e)
 13         {
 14
 15         }
 16         /// <summary>
 17         /// 点击歌手类型后加载相应的信息
 18         /// </summary>
 19         public void ShowSingerDiQu()
 20         {
 21              if (lvtype.SelectedItems[0]!=null)
 22             {
 23                 lvtype.Visible = false;
 24                 lvSinger.Visible = true;
 25                 lvSinger.Location = lvtype.Location;
 26
 27
 28                 this.SingerType = Convert.ToString(lvtype.SelectedItems[0].Tag);
 29             }
 30             string sql = "select singertype_name,singertype_id from singer_type";
 31             SqlCommand cmd = new SqlCommand(sql,db.Conection);
 32             SqlDataReader sdr;
 33             try
 34             {
 35                 db.OpenConnection();
 36                 sdr = cmd.ExecuteReader();
 37                 lvtype.Items.Clear();
 38                 if (sdr.HasRows)
 39                 {
 40                     int result = 0;
 41                     while (sdr.Read())
 42                     {
 43                         ListViewItem lvitem = new ListViewItem();
 44                         string typename = Convert.ToString(sdr["singertype_name"]);
 45                         int typeid = Convert.ToInt32(sdr["singertype_id"]);
 46                         lvitem.Text = typename;
 47                         lvitem.Tag = typeid;
 48                         lvitem.ImageIndex = result;
 49                         lvSinger.Items.Add(lvitem);
 50                         result++;
 51                     }
 52                     sdr.Close();
 53                 }
 54             }
 55             catch (Exception ex)
 56             {
 57                 MessageBox.Show("第二个系统报错" + ex.Message);
 58             }
 59             finally
 60             {
 61                 db.CloseConnection();
 62             }
 63         }
 64
 65         private void listView2_SelectedIndexChanged(object sender, EventArgs e)
 66         {
 67
 68         }
 69
 70         private void FrmOrderBySinger_Load(object sender, EventArgs e)
 71         {
 72             this.lvSinger.Visible = false;
 73             this.lvContry.Visible=false;
 74         }
 75
 76         private void listView1_Click(object sender, EventArgs e)
 77         {
 78              ShowSingerDiQu();
 79         }
 80         /// <summary>
 81         /// 读取对应地区的歌手名称
 82         /// </summary>
 83         public void ShowSingerName()
 84         {
 85             if (lvSinger.SelectedItems[0]!=null)
 86             {
 87                 lvSinger.Visible = false;
 88                 lvContry.Visible = true;
 89                 lvContry.Location = lvtype.Location;
 90                 SingerId = Convert.ToInt32(lvSinger.SelectedItems[0].Tag);
 91                 StringBuilder sb = new StringBuilder();
 92                 string sum = SingerType;
 93                 if (sum!="组合")
 94                 {
 95                     sum = SingerType == "女歌手" ? "男" : "女";
 96                 }
 97                 string sql = string.Format("select singer_name,singer_photo_url,singer_id from singer_info where singertype_id='{0}' and singer_sex='{1}'", SingerId,sum);
 98                 SqlCommand cmd = new SqlCommand(sql, db.Conection);
 99                 try
100                 {
101                     db.OpenConnection();
102                     SqlDataReader read = cmd.ExecuteReader();
103                     if (read.HasRows)
104                     {
105                         //歌手头像索引
106                         int imageindex = 0;
107                         //清空图片集合
108                         imageName.Images.Clear();
109                         //清空listview列表集合
110                         lvContry.Items.Clear();
111                         if (read.HasRows)
112                         {
113                             while (read.Read())
114                             {
115                                 //图片的地址
116                                 string path = KtvUtil.FilePath + @"" + Convert.ToString(read["singer_photo_url"]);
117                                 imageName.Images.Add(Image.FromFile(path));
118                                 ListViewItem lvitem = new ListViewItem();
119                                 string typename = Convert.ToString(read["singer_name"]);
120                                 int typeid = Convert.ToInt32(read["singer_id"]);
121                                 lvitem.Text = typename;
122                                 lvitem.Tag = typeid;
123                                 lvitem.ImageIndex = imageindex;
124                                 lvContry.Items.Add(lvitem);
125                                 imageindex++;
126                             }
127                             read.Close();
128                         }
129                     }
130
131                 }
132                 catch (Exception ex)
133                 {
134                     MessageBox.Show("第三个系统报错!" + ex.Message);
135                 }
136                 finally
137                 {
138                     db.CloseConnection();
139                 }
140             }
141
142         }
143         private void lvName_Click(object sender, EventArgs e)
144         {
145             ShowList();
146         }
147
148         private void listView2_Click(object sender, EventArgs e)
149         {
150             ShowSingerName();
151         }
152
153         private void listView1_ChangeUICues(object sender, UICuesEventArgs e)
154         {
155
156         }
157         /// <summary>
158         /// 打开第三层ListView
159         /// </summary>
160         public void ShowList()
161         {
162             //定义一个StringBuilder对象
163             StringBuilder sb = new StringBuilder();
164             //sql语句
165             string sql = string.Format("select song_id,song_name,singer_name='{0}',song_url from song_info where singer_id={1}",lvContry.SelectedItems[0].Text,Convert.ToInt32(lvContry.SelectedItems[0].Tag));
166             //定义歌曲列表窗体的对象
167             FrmSongList sl=new FrmSongList();
168            //把sql语句传到第三个窗体上
169             sl.Sql=sql;
170             sl.ShowDialog();
171             this.Close();
172         }
173
174         private void toolStripButton4_Click(object sender, EventArgs e)
175         {
176             this.Close();
177         }
178
179         private void toolStripButton1_Click(object sender, EventArgs e)
180         {
181             if (lvSinger.Visible)
182             {
183                 lvSinger.Visible = false;
184                 lvContry.Visible = true;
185             }
186             else if (lvContry.Visible)
187             {
188                 lvContry.Visible = false;
189                 lvtype.Visible = true;
190             }
191             else if (lvtype.Visible)
192             {
193                 FormMain dd = new FormMain();
194                 dd.Show();
195                 this.Close();
196             }
197         }

第四步:歌曲列表

双击DateGrilView选中的一行,提示:

歌曲列表:实现点击一下歌曲列表中的一行信息就到以点里面

 1 public partial class FrmSongList : Form
 2     {
 3         DBHelper db = new DBHelper();
 4         DataSet ds = new DataSet();
 5
 6         private string sql = "";
 7         //歌曲的查询语句
 8         public string Sql
 9         {
10             get { return sql; }
11             set { sql = value; }
12         }
13         public FrmSongList()
14         {
15             InitializeComponent();
16         }
17
18         private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
19         {
20             //第一步判断datagridView有没有选中的行
21             //第二步从实例化SongList类
22             //第三步调取歌曲song类的字段进行赋值(从datagridview中的列赋值);
23             //第四部把从datagridview中获取到的数据添加到播放类里的数组中
24             if (this.dataGridView1.SelectedRows[0]!=null)
25             {
26                 SongList song = new SongList();
27                 song.SongName1 = this.dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
28                 song.SongUl1 = this.dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
29                 PalyList.AddSong(song);
30             }
31
32         }
33
34         private void FrmSongList_Load(object sender, EventArgs e)
35         {
36             SqlDataAdapter sda = new SqlDataAdapter(sql,db.Conection);
37             sda.Fill(ds,"songinfo");
38             dataGridView1.DataSource = ds.Tables["songinfo"];
39         }
40
41         private void toolStripButton4_Click(object sender, EventArgs e)
42         {
43             this.Close();
44         }
45
46         private void toolStripButton6_Click(object sender, EventArgs e)
47         {
48             FrmSong frm = new FrmSong();
49             frm.ShowDialog();
50         }

第五步:已点歌曲

已点歌曲:进入了就是已播放状态一次往下添加都是未播放,如果到了下面的播放状态就还得改变成已播放

 1   private void FrmOrderedSongList_Load(object sender, EventArgs e)
 2         {
 3             //遍历播放类里面的数组
 4             foreach (SongList item in PalyList.song)
 5             {
 6
 7                 if (item!=null)
 8                 {
 9                     ListViewItem lvitem = new ListViewItem(item.SongName1);
10                     string type = item.PlaySong == PalySongState.unplayed ? "未播放" : "已播放";
11                     lvitem.SubItems.Add(type);
12                     this.listView1.Items.Add(lvitem);
13                 }
14
15             }
16         }
17
18         private void toolStripButton1_Click(object sender, EventArgs e)
19         {
20             FrmSinger dd = new FrmSinger();
21             dd.Show();
22         }

第六步:拼音点歌

  1     public partial class FrmSpeall : Form
  2     {
  3         private DBOpetion db = new DBOpetion();
  4         private SqlDataAdapter adapter = null;
  5         private DataSet ds = new DataSet();
  6         public FrmSpeall()
  7         {
  8             InitializeComponent();
  9         }
 10         [DllImportAttribute("user32.dll")]
 11         private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
 12         private void FrmSpeall_Load(object sender, EventArgs e)
 13         {
 14             AnimateWindow(this.Handle, 300, FrmMain.AW_SLIDE + FrmMain.AW_VER_POSITIVE);
 15         //动态效果可以取消注释
 16             //for (int i = 97; i < 123; i++)
 17             //{
 18             //    for (int j = 0; j < 4; j++)
 19             //    {
 20             //        Label label = new Label();
 21             //        label.BackColor = Color.Yellow;
 22             //        label.Font=new System.Drawing.Font("宋体",14.25F,System.Drawing.FontStyle.Regular,
 23             //            System.Drawing.GraphicsUnit.Point,((byte)(134)));
 24             //        label.AutoSize = false;
 25             //        label.Size = new System.Drawing.Size(50, 25);
 26             //        label.Text = ((char)i).ToString();
 27             //        label.TextAlign = ContentAlignment.MiddleCenter;
 28             //        label.Location = new Point(60 + (i * 90), 60 + (j * 60));
 29             //        label.Parent = panel1;
 30             //    }
 31             //}
 32             ////for (int i = 97; i < 123; i++)
 33             ////{
 34             ////    Console.WriteLine((char)i);
 35             ////}
 36         }
 37
 38         private void pictureBox1_Click(object sender, EventArgs e)
 39         {
 40             this.textBox1.Text = this.textBox1.Text + "a";
 41         }
 42
 43         private void pictureBox2_Click(object sender, EventArgs e)
 44         {
 45             this.textBox1.Text = this.textBox1.Text + "b";
 46         }
 47
 48         private void pictureBox3_Click(object sender, EventArgs e)
 49         {
 50             this.textBox1.Text = this.textBox1.Text + "c";
 51         }
 52
 53         private void pictureBox4_Click(object sender, EventArgs e)
 54         {
 55             this.textBox1.Text = this.textBox1.Text + "d";
 56         }
 57
 58         private void pictureBox5_Click(object sender, EventArgs e)
 59         {
 60             this.textBox1.Text = this.textBox1.Text + "e";
 61         }
 62
 63         private void pictureBox6_Click(object sender, EventArgs e)
 64         {
 65             this.textBox1.Text = this.textBox1.Text + "f";
 66         }
 67
 68         private void pictureBox7_Click(object sender, EventArgs e)
 69         {
 70             this.textBox1.Text = this.textBox1.Text + "g";
 71         }
 72
 73         private void pictureBox8_Click(object sender, EventArgs e)
 74         {
 75             this.textBox1.Text = this.textBox1.Text + "h";
 76         }
 77
 78         private void pictureBox9_Click(object sender, EventArgs e)
 79         {
 80             this.textBox1.Text = this.textBox1.Text + "i";
 81         }
 82
 83         private void pictureBox10_Click(object sender, EventArgs e)
 84         {
 85             this.textBox1.Text = this.textBox1.Text + "j";
 86         }
 87
 88         private void pictureBox11_Click(object sender, EventArgs e)
 89         {
 90             this.textBox1.Text = this.textBox1.Text + "k";
 91         }
 92
 93         private void pictureBox12_Click(object sender, EventArgs e)
 94         {
 95             this.textBox1.Text = this.textBox1.Text + "l";
 96         }
 97
 98         private void pictureBox13_Click(object sender, EventArgs e)
 99         {
100             this.textBox1.Text = this.textBox1.Text + "m";
101         }
102
103         private void pictureBox14_Click(object sender, EventArgs e)
104         {
105             this.textBox1.Text = this.textBox1.Text + "n";
106         }
107
108         private void pictureBox15_Click(object sender, EventArgs e)
109         {
110             this.textBox1.Text = this.textBox1.Text + "o";
111         }
112
113         private void pictureBox16_Click(object sender, EventArgs e)
114         {
115             this.textBox1.Text = this.textBox1.Text + "p";
116         }
117
118         private void pictureBox17_Click(object sender, EventArgs e)
119         {
120             this.textBox1.Text = this.textBox1.Text + "q";
121         }
122
123         private void pictureBox18_Click(object sender, EventArgs e)
124         {
125             this.textBox1.Text = this.textBox1.Text + "r";
126         }
127
128         private void pictureBox19_Click(object sender, EventArgs e)
129         {
130             this.textBox1.Text = this.textBox1.Text + "s";
131         }
132
133         private void pictureBox20_Click(object sender, EventArgs e)
134         {
135             this.textBox1.Text = this.textBox1.Text + "t";
136         }
137
138         private void pictureBox21_Click(object sender, EventArgs e)
139         {
140             this.textBox1.Text = this.textBox1.Text + "u";
141         }
142
143         private void pictureBox22_Click(object sender, EventArgs e)
144         {
145             this.textBox1.Text = this.textBox1.Text + "v";
146         }
147
148         private void pictureBox23_Click(object sender, EventArgs e)
149         {
150             this.textBox1.Text = this.textBox1.Text + "w";
151         }
152
153         private void pictureBox24_Click(object sender, EventArgs e)
154         {
155             this.textBox1.Text = this.textBox1.Text + "x";
156         }
157
158         private void pictureBox25_Click(object sender, EventArgs e)
159         {
160             this.textBox1.Text = this.textBox1.Text + "y";
161         }
162
163         private void pictureBox26_Click(object sender, EventArgs e)
164         {
165             this.textBox1.Text = this.textBox1.Text + "z";
166         }
167         private void button1_Click(object sender, EventArgs e)
168         {
169             string text = this.textBox1.Text;
170             int index = text.Length - 1;
171             if (index >= 0)
172             {
173                 textBox1.Text = text.Remove(index);
174             }
175         }
176         /// <summary>
177         /// 按拼音查找歌曲
178         /// </summary>
179         private void SeleSong()
180         {
181             string sql =string.Format("select song_id,song_name,song_url,singer_name from song_info,singer_info" +
182 " where song_info.singer_id=singer_info.singer_id and song_ab like '%{0}%'",this.textBox1.Text);
183             adapter = new SqlDataAdapter(sql, db.Conntion);
184             if (ds.Tables["song_info"]!=null)
185             {
186                 ds.Tables.Clear();
187             }
188             adapter.Fill(ds, "song_info");
189             this.dataGridView1.DataSource = ds.Tables["song_info"];
190         }
191         private void textBox1_TextChanged(object sender, EventArgs e)
192         {
193             if (this.textBox1.Text !=string.Empty)
194             {
195                 SeleSong();
196                 this.dataGridView1.AutoGenerateColumns = false;
197             }
198             else
199             {
200                 this.dataGridView1.DataSource = null;
201             }
202
203         }
204
205         private void FrmSpeall_FormClosing(object sender, FormClosingEventArgs e)
206         {
207             AnimateWindow(this.Handle, 300, FrmMain.AW_SLIDE + FrmMain.AW_VER_POSITIVE);
208         }
209
210         private void dataGridView1_DoubleClick(object sender, EventArgs e)
211         {
212             if (this.dataGridView1.SelectedRows[0] != null)
213             {
214                 Song song = new Song();
215                 song.SongName = this.dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
216                 song.SongPath = this.dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
217                 ListSong.AddSong(song);
218                 MessageBox.Show("添加成功,请在已点歌曲中查看!!!");
219                 this.Close();
220             }
221         }

第七部:金榜排行

 1    DataSet sb = new DataSet();
 2         SqlDataAdapter adapter = new SqlDataAdapter();
 3         public FrmOrderWordText()
 4         {
 5             InitializeComponent();
 6         }
 7
 8         private void FrmOrderWordText_Load(object sender, EventArgs e)
 9         {
10             DBHelper dd = new DBHelper();
11             string sql = string.Format("select song_name,singer_name,song_play_count from song_info,singer_info where song_info.singer_id=singer_info.singer_id order by song_play_count desc");
12             adapter.SelectCommand = new SqlCommand(sql, dd.Conection);
13             adapter.Fill(sb, "song_info");
14             DataTable table = sb.Tables["song_info"];
15
16             foreach (DataRow row in table.Rows)
17             {
18                 ListViewItem list = new ListViewItem(row[0].ToString());
19                 string [] item={row[1].ToString(),row[2].ToString()};
20                 list.SubItems.AddRange(item);
21                 listView1.Items.Add(list);
22             }
23         }
24
25         private void toolStripButton1_Click(object sender, EventArgs e)
26         {
27             this.Close();
28         }
29
30         private void toolStripButton5_Click(object sender, EventArgs e)
31         {
32             FrmSong song = new FrmSong();
33             song.Show();
34         }
35
36         private void toolStripButton6_Click(object sender, EventArgs e)
37         {
38             if (MessageBox.Show("确定要切歌吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
39             {
40                 PalyList.CutSong(-1);
41             }
42         }
43
44         private void toolStripButton7_Click(object sender, EventArgs e)
45         {
46             //PalyList.PlayAgain();
47
48             FormMain dd = new FormMain();
49             dd.palySong();
50         }
51
52         private void toolStripButton2_Click(object sender, EventArgs e)
53         {
54             FormMain dd = new FormMain();
55             dd.Show();
56             this.Close();
57         }

第八步:字数点歌

  1  DBHelper db = new DBHelper();
  2         SqlDataAdapter sda = new SqlDataAdapter();
  3         DataSet ds = new DataSet();
  4         public FrmOrderByWordCount()
  5         {
  6             InitializeComponent();
  7         }
  8         /// <summary>
  9         /// 打开主界面
 10         /// </summary>
 11         /// <param name="sender"></param>
 12         /// <param name="e"></param>
 13         private void toolStripButton2_Click(object sender, EventArgs e)
 14         {
 15             FormMain f = new FormMain();
 16             f.Show();
 17         }
 18         /// <summary>
 19         /// 重唱歌曲
 20         /// </summary>
 21         /// <param name="sender"></param>
 22         /// <param name="e"></param>
 23         private void toolStripButton7_Click(object sender, EventArgs e)
 24         {
 25
 26             FormMain dd = new FormMain();
 27             dd.palySong();
 28             //PalyList.PlayAgain();
 29         }
 30         /// <summary>
 31         /// 切歌
 32         /// </summary>
 33         /// <param name="sender"></param>
 34         /// <param name="e"></param>
 35         private void toolStripButton6_Click(object sender, EventArgs e)
 36         {
 37             if (MessageBox.Show("确定要切歌吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
 38             {
 39                 PalyList.CutSong(-1);
 40             }
 41         }
 42         /// <summary>
 43         /// 已点歌曲
 44         /// </summary>
 45         /// <param name="sender"></param>
 46         /// <param name="e"></param>
 47         private void toolStripButton5_Click(object sender, EventArgs e)
 48         {
 49             FrmSong frmList = new FrmSong();
 50             frmList.Show();
 51         }
 52         /// <summary>
 53         /// 返回
 54         /// </summary>
 55         /// <param name="sender"></param>
 56         /// <param name="e"></param>
 57         private void toolStripButton1_Click(object sender, EventArgs e)
 58         {
 59             this.Close();
 60
 61         }
 62
 63         public void FrmOrderByWordCount_Load(object sender, EventArgs e)
 64         {
 65             string sql2 = "select resource_path from resource_path where resource_id=2";
 66             SqlCommand cmd2 = new SqlCommand(sql2, db.Conection);
 67             db.OpenConnection();
 68             KtvUtil.SongPath = cmd2.ExecuteScalar().ToString();
 69             db.CloseConnection();
 70             for (int i = 1; i <= 4; i++)
 71             {
 72                 for (int j = 1; j<= 3; j++)
 73                 {
 74                     Label label = new Label();
 75                     label.Text = "" + i + "";
 76                     if (j==2)
 77                     {
 78                         label.Text = "" + (i + 4) + "";
 79                     }
 80                     else if (j==3)
 81                     {
 82                         label.Text = "" + (i + 8) + "";
 83                     }
 84                     label.Size = new Size(60, 30);
 85                     label.TextAlign = ContentAlignment.MiddleCenter;
 86                     label.Font = new System.Drawing.Font("华文彩云", 10);
 87                     label.BackColor = Color.Pink;
 88                     label.Click += label_Click;
 89                     label.Location = new Point(40 + 120 * j, 40 + 80 * i);
 90                     this.Controls.Add(label);
 91                 }
 92
 93             }
 94         }
 95         void label_Click(object sender, EventArgs e)
 96         {
 97             DBHelper dd = new DBHelper();
 98             DataSet ds = new DataSet();
 99             Label label = (Label)sender;
100             string sql = string.Format("select song_name,song_url,singer_name from song_info,singer_info" +
101                 " where song_info.singer_id=singer_info.singer_id and song_word_count={0}", Convert.ToInt32(label.Text));
102             SqlDataAdapter da = new SqlDataAdapter(sql, dd.Conection);
103             da.Fill(ds, "song_info");
104             dataGridView1.DataSource = ds.Tables["song_info"];
105             this.dataGridView1.Visible = true;
106
107
108         }
109
110         private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
111         {
112             string songname = this.dataGridView1.SelectedRows[0].Cells["clnSongName"].Value.ToString();
113             DBHelper db = new DBHelper();
114             db.OpenConnection();
115             string sql = string.Format("SELECT song_name,singer_name,song_url,song_photo_url FROM dbo.song_info,dbo.singer_info  where dbo.singer_info.singer_id=dbo.song_info.singer_id and song_name='{0}'", songname);
116             SqlCommand cmd = new SqlCommand(sql, db.Conection);
117
118             SqlDataReader read = cmd.ExecuteReader();
119             if (read.Read())
120             {
121                 SongList song = new SongList();
122                 song.SongName1 = read["song_name"].ToString();
123                 song.SongUl1 = read["song_url"].ToString();
124                 PalyList.AddSong(song);
125             }
126             read.Close();
127         }
128
129     }

第九步:类型点歌

  1  /// <summary>
  2         /// 切歌方法
  3         /// </summary>
  4         /// <param name="sender"></param>
  5         /// <param name="e"></param>
  6         private void toolStripButton6_Click(object sender, EventArgs e)
  7         {
  8             if (MessageBox.Show("确定要切歌吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
  9             {
 10                 PalyList.CutSong(-1);
 11             }
 12         }
 13
 14         private void FrmOrderBySongType_Load(object sender, EventArgs e)
 15         {
 16             LoadListView();
 17         }
 18
 19
 20         private void LoadListView()
 21         {
 22             DBHelper db = new DBHelper();
 23             string sql = "select songtype_id,songtype_name,songtype_URL from song_type";
 24             SqlCommand cmd = new SqlCommand(sql, db.Conection);
 25
 26             try
 27             {
 28                 db.OpenConnection();
 29                 SqlDataReader reader = cmd.ExecuteReader();
 30
 31                 if (reader.HasRows)
 32                 {
 33                     int index = 0;
 34                     while (reader.Read())
 35                     {
 36                         ListViewItem item = new ListViewItem();
 37                         item.Text = reader[1].ToString();
 38                         item.Tag = reader[0].ToString();
 39                         this.imageList1.Images.Add(Image.FromFile(@"E:\KTV前台管理\KTV前台管理\SingerTypeIamge\" + reader[2].ToString()));
 40                         item.ImageIndex = index;
 41                         this.listView1.Items.Add(item);
 42                         index++;
 43                     }
 44                 }
 45                 reader.Close();
 46             }
 47             catch (Exception ex)
 48             {
 49                 MessageBox.Show(ex.Message);
 50             }
 51             finally
 52             {
 53                 db.CloseConnection();
 54             }
 55         }
 56         /// <summary>
 57         /// 查找到该类型的歌手的歌曲
 58         /// </summary>
 59         private void DoubleClickSong()
 60         {
 61             if (this.listView1.SelectedItems[0] != null)
 62             {
 63                 string sql = string.Format("select song_id,song_name,song_url,singer_name from song_info,singer_info" +
 64                " where song_info.singer_id=singer_info.singer_id and song_info.songtype_id={0}", Convert.ToInt32(this.listView1.SelectedItems[0].Tag));
 65                 FrmSongList fs = new FrmSongList();
 66                 fs.Sql = sql;
 67                 fs.Show();
 68             }
 69         }
 70
 71         private void toolStripButton1_Click(object sender, EventArgs e)
 72         {
 73
 74             this.Close();
 75         }
 76
 77         private void toolStripButton5_Click(object sender, EventArgs e)
 78         {
 79             FrmSong song = new FrmSong();
 80             song.Show();
 81         }
 82
 83         private void listView1_Click(object sender, EventArgs e)
 84         {
 85             listView1.ToString();
 86         }
 87
 88         private void listView1_DoubleClick(object sender, EventArgs e)
 89         {
 90             DoubleClickSong();
 91         }
 92
 93         private void toolStripButton2_Click(object sender, EventArgs e)
 94         {
 95             FormMain dd = new FormMain();
 96             dd.Show();
 97             this.Close();
 98         }
 99
100         private void toolStripButton7_Click(object sender, EventArgs e)
101         {
102
103             FormMain dd = new FormMain();
104             dd.palySong();
105         }

2015-07-31

小学生之KTV项目文档(bdqn)的更多相关文章

  1. Atitit. 项目文档目录大纲 总集合  v2

    Atitit. 项目文档目录大纲 总集合  v2 -----Atitti.原有项目源码的架构,框架,配置与环境说明 v3 q511 -----Atitit.开发环境 与 工具 以及技术框架 以及 注意 ...

  2. 使用Mkdocs构建你的项目文档

    使用Mkdocs构建你的项目文档 环境搭建 安装必需软件 作者是在windows下安装的,如果是linux或mac用户,官网有更详细的安装说明. windows 10 x64 当然还有广大的windo ...

  3. MkDocs项目文档生成器

    简介 安装 我的配置 Chocolatey 简介 - Windows的包管理器 官方网址 安装 注意事项 Python 简介 安装 Pip 简介-Python的包管理器 升级 MkDocs的安装 使用 ...

  4. 通过VuePress管理项目文档(二)

    通过vue组件实现跟:Element相似的效果.需要在VuePress网站中将自己的项目中的Vue组件运行结果展示在页面中. 至于如何将组件在VuePress网站中展示请参考:https://segm ...

  5. 通过VuePress管理项目文档(一)

    VuePress 相关链接 完整的Vue组件代码以及完整的文档,仅适用于个人参考学习: 文档预览地址:预览链接 使用VuePress编辑文档的代码访问:组件文档 完整代码:组件代码 Vue组件开发 这 ...

  6. Atitit 项目文档规范化与必备文档与推荐文档列表

    Atitit 项目文档规范化与必备文档与推荐文档列表 ===========比较重要的必备文档========== 项目组名单通讯录( 包括项目组,客户沟通人等 需求文档 原型ui文档 开发计划表 项 ...

  7. Maven项目文档

    本教程学习如何一步到位地创建应用程序的文档.因此现在开始我们进入到  C:\MVN 创建 java 应用程序项目:consumerBanking. 进入到项目文件夹中执行以下命令 mvn 命令. C: ...

  8. 使用Docfx生成项目文档

    使用docfx.console生成本项目的文档 使用docfx.console生成其他项目的文档 直接使用docfx.exe生成项目文档 指定配置文档模板   文档地址:http://gitlab.l ...

  9. Java-Maven-Runoob:Maven 项目文档

    ylbtech-Java-Maven-Runoob:Maven 项目文档 1.返回顶部 1. Maven 项目文档 本章节我们主要学习如何创建 Maven 项目文档. 比如我们在 C:/MVN 目录下 ...

随机推荐

  1. WebBasic-表单

    用来提交数据 <form></form> 属性:action:提交的url  method:表单数据提交的方式  enctype:表单数据的编码方式 表单控件 --input元 ...

  2. JavaScript 显示弹出窗口

    window . showModalDialog ( sURL,vArguments , sFeatures )参数说明: sURL--必选参数,用来指定对话框要显示的文档的URL. //要显示页面的 ...

  3. linux vi 使用脑图

  4. JAVA-POI实现EXCEL的读写

    想要完成JAVA读写EXCEL,首先需要JAVA-POI包的支持,百度搜索即可找到资源,不再赘述: POI-新增EXCEL并输入内容 package com.gsh.test.poi; import ...

  5. oracle数据泵之解决方案(用户)导入导出。

    看到网上有这样的介绍而且很多,但觉得都是大神才能一下子看的懂.自己总结下菜鸟能看懂的. 1.导出. 首先第一步: 操作系统—开始—运行输入“cmd”进入dos界面输入“sqlplus/nolog”按回 ...

  6. Swagger 生成 ASP.NET Web API

    使用 Swagger 生成 ASP.NET Web API 在线帮助测试文档 原文:ASP.NET Web API Help Pages using Swagger作者:Shayne Boyer翻译: ...

  7. mysql优化 - mysql 的 hint

    FORCE INDEX 强制索引 只使用建立在field1上的索引,而不使用其它字段上的索引. SELECT * FROM table1 FORCE INDEX (field1) IGNORE IND ...

  8. 复杂事件处理引擎—Esper 处理模型

    1.esper的处理模型是持续性的——根据statement中事件流(event stream).视图(views).过滤器(filters)等的选择,esper引擎一旦处理事件数据,就会变更stat ...

  9. Entity Framework with MySQL 学习笔记一(关系整理版)

    1-1 设置 //DataAnnotation 1-1 | 1-0 table //SQLtable : member , columns : memberId, name //SQL basic l ...

  10. C++ wstring string char* wchar_t相互转换

    标签: stringwstringwchar_tcharc++2013-12-19 00:29 3721人阅读 评论(0) 收藏 举报本文章已收录于: C++知识库 分类: C/C++(50) 1. ...