C# KTV 系统 SQL数据库连接 C# 应用窗体
---恢复内容开始---
五道口 北大青鸟校区
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();
---恢复内容结束---
C# KTV 系统 SQL数据库连接 C# 应用窗体的更多相关文章
- SQL数据库连接到服务器出错——无法连接到XXX
问题:Windows或者SQL Server身份验证下,出现连接到服务器出错 解决方式: 1.检查实例名称是否正确,如下 根据自己电脑的实际名称修改修改如下: 1)Microsoft SQL Serv ...
- Window系统、主函数和窗体函数这三者之间的关系
理解Window系统.主窗体.窗体函数这三者之间的关系,对于编写Windows程序十分重要. 主函数和窗体函数都是由Windows系统来调用的函数.仅仅只是主函数是程序启动之后.系统首先调用的函数: ...
- SQL数据库连接池与C#关键字return
SQL数据库连接池: 先前做的一个Sharepoint项目,在上线后的不久,最近一直出现间歇性访问缓慢问题Sharepoint特性问题,并分析了其数据库服务器,发现所耗内存已经达到了97%. 所以断定 ...
- KTV项目 SQL数据库的应用 结合C#应用窗体
五道口北大青鸟校区 KTV项目 指导老师:袁玉明 歌曲播放原理 SQL数据库关系图 C#解决方案类图 第一步:创建数据库连接方法和打开方法和关闭方法! public class DBHelper { ...
- 仿5173游戏交易平台系统SQL注入(可直接脱裤)+Getshell
最近没事登登好几年前玩过的游戏看看,发现有人喊高价收号,这一看就是骗子,这等骗子还想骗我?我就来看看这逗逼是怎么骗人的,结果发现这人给了一个说是 5173平台交易的网站,叫我直接把号的信息填上去然后填 ...
- web第一节课 sql 数据库连接 查询
1.数据库连接语句 <connectionStrings> <add name="yhotel" connectionString="Database= ...
- SQL Server Window Function 窗体函数读书笔记二 - A Detailed Look at Window Functions
这一章主要是介绍 窗体中的 Aggregate 函数, Rank 函数, Distribution 函数以及 Offset 函数. Window Aggregate 函数 Window Aggrega ...
- Java之MS SQL数据库连接
一 1.首先,到微软官方下载jdbc驱动包 Microsoft JDBC Driver 4.0 for SQL Server 2.运行sqljdbc_4.0.2206.100_chs.exe,把文件 ...
- SQL Server Window Function 窗体函数读书笔记一 - SQL Windowing
SQL Server 窗体函数主要用来处理由 OVER 子句定义的行集, 主要用来分析和处理 Running totals Moving averages Gaps and islands 先看一个简 ...
随机推荐
- Navicat 选择语句
1.进入数据库后,点击Query 2.点击new query 3.左边提供界面的筛选条件,如果不清楚sql语句,可直接在上面操作 4.右边可自己编写sql语句 5.写完语句后,点击Run,在resul ...
- canvas新属性
lineCap默认值是butt,还有aquare,round 使用:context.lineCap="butt" lineJoin miter是默认 还可以是round,bevel ...
- phpMemcache消息队列类
<?php /** * Memcache 消息队列类 */ class QMC { const PREFIX = 'ASDFASDFFWQKE'; /** * 初始化 mc * @staticv ...
- iOS8之后CoreLocation定位的使用
在Info.plist文件中添加如下配置: //始终允许访问位置信息 (1)NSLocationAlwaysUsageDescription //使用应用程序期间允许访问位置数据 (2)NSLocat ...
- 关于32位程序在Win7&64位系统中连接Microsoft Excel数据源的问题
最近在新公司电脑上跑以前的selenium测试框架的时候,抛出了如下的错误 出现的是ODBC Driver问题:[Microsoft][ODBC Driver Manager] Data source ...
- Web Service相关工具的配置
近期在学习Web Service Testing,使用到了soapUI这个工具,但是在学习之前,需要搭建Web Service环境,其中有关数据库的连接问题花费了我好多时间,主要还是自己对于很多配置不 ...
- java.util.concurrent并发包诸类概览
java.util.concurrent包的类都来自于JSR-166:Concurrent Utilities,官方的描述叫做“The JSR proposes a set of medium-lev ...
- LA 小、杂、乱题合辑
${\Large 1.}$(来自丘维声『高等代数』(上)$P_{189,194}$) $(1).$ 设$A,B$分别是数域${\mathbb F}$上$n\times n,m\times n$矩阵. ...
- Children of the Candy Corn (bfs+dfs)
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8120 Accepted: 3547 Description The c ...
- BZOJ2749: [HAOI2012]外星人
2749: [HAOI2012]外星人 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 377 Solved: 199[Submit][Status] ...