为了我不至于被那帮人女的那么惨,决定把我最认为最需要而且掌握不咋地好的东西拿出来给大家分享分享,大家都是到KTV对吧,就算不知道,你没吃过过猪肉还没见过猪跑吗,是吧,所以,小博就为大家屡屡这KTV
搭建好KTV点歌界面,然后要实现的是歌星点歌,点击窗体的Load事件写如下代码:
private void FrmZhu_Load(object sender, EventArgs e) { //读取MyResource表中的图片路径,放入到imagePath变量中 string sql = "select resource_path from resource_path where resource_id=1"; SqlConnection con = new SqlConnection(SqlHelper.str); SqlCommand com = new SqlCommand(sql,con); con.Open(); KTVUtil.singerPhoto = com.ExecuteScalar().ToString(); con.Close(); //读取歌手路径 sql = "select resource_path from resource_path where resource_id=2"; com.CommandText = sql; try { con.Open(); KTVUtil.SongLu = com.ExecuteScalar().ToString(); } catch (Exception ex) { MessageBox.Show("系统资源错误!"+ex.Message); } finally { con.Close(); } }
进入了地区查询是不是该下一步查询你,以便缩小查询范围,对吧,所以要用到下面的东东
if (lvTwo.SelectedItems[0] != null) { lvTwo.Visible = false; lvThree.Location = lvTwo.Location; lvlB.Dock = DockStyle.Fill; lvThree.Size = lvlB.Size; lvThree.Visible = true; singid = Convert.ToInt32(lvTwo.SelectedItems[0].Tag); while (dr.Read()) { //将歌手头像放到IamgeList控件中 string photoURL = KTVUtil.singerPhoto + "\\" + Convert.ToString(dr["singer_poto_url"]); imasingerName.Images.Add(Image.FromFile(photoURL)); //将歌手添加到ListView中 ListViewItem list = new ListViewItem(); list.Text = Convert.ToString(dr["singer_name"]); list.Tag = Convert.ToString(dr["singer_id"]); list.ImageIndex = imageIndex; lvThree.Items.Add(list); imageIndex++; } dr.Close(); }
第1步
private void lvThree_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(SqlHelper.str); StringBuilder sb = new StringBuilder(); sb.AppendFormat("select song_id,song_name,singer_name=‘"+lvThree.SelectedItems[0].Text+"‘,song_url from song_info where singer_id="+Convert.ToInt32(lvThree.SelectedItems[0].Tag)+""); fslGEyu eyu = new fslGEyu(); eyu.name = sb.ToString(); eyu.Previous = Execute.Singer;//指定返回的窗体是按歌手点歌 eyu.Show(); // this.Close(); }
第2个动态喽
小博认为这是忽然那男的,,,
就到这吧,期待下次相遇
时间: 2024-10-21 01:29:08