---恢复内容开始---

五道口 北大青鸟校区

KTV项目

指导老师: 袁玉明

 SQL数据库关系图

第一步:

  private void DoubleClicklvContry()
{
if (this.lvtype.SelectedItems[]!=null)
{
this.lvContry.Visible = true;
this.lvtype.Visible = false;
type = this.lvtype.SelectedItems[].Tag.ToString();
this.lvContry.Location = this.lvtype.Location;
lvContry.Dock = DockStyle.Fill;
}
string sql = "select singertype_id,singertype_name,singertype_imageURL from singer_type";
cmd = new SqlCommand(sql, con.Conntion);
try
{
con.OpenConntion();
SqlDataReader reader = cmd.ExecuteReader();
if (this.lvContry.Items != null)
{
lvSinger.Items.Clear();
}
if (reader.HasRows)
{
int index = ;
while (reader.Read())
{
ListViewItem item = new ListViewItem();
item.Text = reader[].ToString();
item.Tag = reader[].ToString();
this.imageList2.Images.Add(Image.FromFile(@"E:\KTV\SingerTypeIamge\" + reader[].ToString()));
item.ImageIndex =index;
this.lvContry.Items.Add(item);
index++;
}
}
reader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.CloseConntion();
}
} 第二部:
private void lvtype_DoubleClick_1(object sender, EventArgs e)
{
DoubleClicklvContry();
}
/// <summary>
/// 给lvSinger添加数据
/// </summary>
private void DoubleClicklvSinger()
{
if (this.lvContry.SelectedItems[]!=null)
{
this.lvSinger.Visible = true;
this.lvContry.Visible = false;
this.lvSinger.Location = this.lvContry.Location;
this.lvSinger.Dock = DockStyle.Fill; string sql = string.Format("select singer_id,singer_name,singer_photo_url from singer_info where singer_sex='{0}' and singertype_id={1}",
type,Convert.ToInt32(this.lvContry.SelectedItems[].Tag));
cmd=new SqlCommand(sql,con.Conntion);
try
{
con.OpenConntion();
//imageList3.Images.Clear();
SqlDataReader reader = cmd.ExecuteReader();
if (this.lvSinger.Items!=null)
{
lvSinger.Items.Clear();
}
if (reader.HasRows)
{
int index = ;
while (reader.Read())
{
ListViewItem item = new ListViewItem();
item.Text = reader[].ToString();
item.Tag = reader[].ToString();
this.imageList3.Images.Add(Image.FromFile(@"E:\KTV\singerPhoto\" + reader[].ToString()));
item.ImageIndex = index;
this.lvSinger.Items.Add(item);
index++;
}
}
reader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally {
con.CloseConntion();
}
}
}

104 第三部:  查找到该地区的歌手的歌曲

    private void lvContry_DoubleClick(object sender, EventArgs e)
{
DoubleClicklvSinger();
} private void DoubleClickSong()
{
if (this.lvSinger.SelectedItems[]!=null)
{
string sql = string.Format("select song_id,song_name,song_url,singer_name from song_info,singer_info"+
" where song_info.singer_id=singer_info.singer_id and singer_info.singer_id={0}",Convert.ToInt32(this.lvSinger.SelectedItems[].Tag));
FrmSong fs = new FrmSong();
fs.sql = sql; fs.Show();
this.Hide();
}

第四部:   选中歌手信息数据库连接↓

   private void FrmSong_Load(object sender, EventArgs e)
{ adapter = new SqlDataAdapter(sql, db.Conntion);
adapter.Fill(ds, "song_info"); this.dataGridView1.DataSource = ds.Tables["song_info"];
this.dataGridView1.AutoGenerateColumns = false;

以点歌曲传惨的列表

 public string Name { get; set; }
public string age { get; set; }
private void BOFANG_Load(object sender, EventArgs e)
{
this.listView1.Items.Clear();
foreach (Song item in ListSong.list)
{
ListViewItem lvitem = new ListViewItem(item.SongName);
lvitem.SubItems.Add(item.SongPath);
string sate = item.Sate == Sateze.unPaly ? "未播放" : "已播放";
lvitem.SubItems.Add(sate);
this.listView1.Items.Add(lvitem);

播放音乐原理图

第五部:  if 判定DATA 窗体传惨
传送到以点歌曲中
private void dataGridView1_DoubleClick(object sender, EventArgs e)
{
if (this.dataGridView1.SelectedRows[] != null)
{
BOFANG dd = new BOFANG();
Song song = new Song();
song.SongName = this.dataGridView1.SelectedRows[].Cells[].Value.ToString();
song.SongPath = this.dataGridView1.SelectedRows[].Cells[].Value.ToString();
dd.Name = song.SongName;
ListSong.AddSong(song); MessageBox.Show("添加成功,请在已点歌曲中查看!!!"); 第六步:拼音点歌 private void button1_Click(object sender, EventArgs e)
{
string en = textBox1.Text;
SqlConnection con = new SqlConnection(Sql.str);
string sql =string.Format( "select * from song_info where song_ab like '"+en+"%'");
SqlDataAdapter da = new SqlDataAdapter(sql,con);
DataSet ds = new DataSet(); da.Fill(ds, "song_info"); dataGridView1.DataSource = ds.Tables["song_info"];
SqlCommand cmd = new SqlCommand(sql,con);
try
{
con.Open();
int count = cmd.ExecuteNonQuery();
if (count > )
{
MessageBox.Show("查找成功");
} }
catch (Exception)
{ MessageBox.Show("网络异常请检查网络或者SQL 数据库!!!");
con.Close();

---恢复内容结束---

最新文章

  1. JS获取URL参数
  2. HTTP协议入门要点
  3. iOS 自定义的CodeSnippets添加按下tab键切换到指定输入位置
  4. webapi mvc session一直获取不到问题
  5. 剑指Offer:面试题34——丑数(java实现)
  6. WordPress 主题开发 - (二) 理解主题 待翻译
  7. 【转】终于解决了Apache乱码问题
  8. [C语言 - 14] 进制
  9. bzoj1015:[JSOI2008]星球大战starwar
  10. NIO设置SO_LINGER引发的异常
  11. POJ2828 Buy Tickets 【线段树】+【单点更新】+【逆序】
  12. C++程序设计与语言(特别版) -- 导论
  13. ios在Xcode里关于图片的权限设置
  14. gvim 技巧
  15. 【转】MySQL sql_mode 说明(及处理一起 sql_mode 引发的问题)
  16. 修改iptables后重启返回错误
  17. java设计模式三种工厂模式简单介绍
  18. pythonweb框架Flask学习笔记03-变量规则
  19. pushlet单播与多播
  20. css选择器与DOM&#39;匹配的关系

热门文章

  1. oracle触发器应用
  2. laravel观察者模式
  3. php面向对象编程--学习笔记
  4. python3可变与不可变数据类型
  5. Python学习笔记:04函数
  6. Aptana Studio 快捷键
  7. ExtJS 4 组件详解
  8. 转:So Easy!让开发人员更轻松的工具和资源
  9. UGUI穿透3D世界判断&amp;&amp;UGUI全事件监听
  10. 【Oracle】安装