一个项目,一分收获;一个项目,一些资源。Ktv项目也是一样的,所以我想分享我的收获,让你们获得你需要的资源。

一. 那MyKTV点歌系统具体的功能有哪些呢?我们就来看看吧!

1.MyKTV前台功能:

01.歌星点歌 、拼音点歌 、数字点歌 、类型选择 、金榜排行

02.切歌 、点歌 、重唱和退出

2.MyKTV后台功能:

01.歌手管理 、歌曲管理 、设置资源路径

02.新增歌手、歌曲 ,查询歌手、歌曲信息,设置歌曲路径和退出

二. 功能已经概括的差不多了,就让我们一起来看看MyKTV的项目吧

  四个辅助类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace MyKTV
{
class KTVUtil
{
public static string picturePath = "";
public static string songPath = "";
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace MyKTV
{
class PlayList
{ public static Song[] SongList=new Song[];
//当前播放的歌曲在数组中的索引(已点列表)
public static int SongIndex = ; //点一首歌,相当于将歌曲放在数组中
public static bool AddSong(Song song)
{
bool result = false;//记录添加歌曲是否成功
for (int i = ; i < SongList.Length; i++)
{
if (SongList [i]==null)
{
SongList[i] = song;
result = true;
break;
}
}
return result;
}
//获取当前播放的歌曲 既然是获取当前播放的歌曲,返回值肯定是Song类型
public static Song GetPlaySong()
{
if (SongList [SongIndex]!=null)
{
return SongList[SongIndex];
}
else
{
return null;
}
}
//播放下一首
public static void Next()
{
if (SongList[SongIndex] != null && SongList[SongIndex].PlayStar== SongPlayState.again)
{
SongList[SongIndex].SongPlayed();
}
else
{
SongIndex++;
if (SongList[SongIndex]!=null)
{
SongList[SongIndex].SongPlayed();
} }
}
//当前播放的歌曲名称
public static string PlaySongName()
{
string songname = "";
if (SongList[SongIndex]!=null)
{
songname=SongList[SongIndex].SongName;
}
return songname;
}
//下一首要播放的歌曲名称
public static string NextSongName()
{
string songname = "";
//if (SongList[SongIndex+1] != null&&SongList[0]!=null)
//{
// songname = SongList[SongIndex+1].SongName; //}
//return songname; if (SongList[] != null && SongList[SongIndex + ] == null)
{
songname = "待添加....";
return songname;
}
else
{
if (SongList[] != null)
{
songname = SongList[SongIndex + ].SongName;
return songname;
}
else
{
return string.Empty;
} }
}
//重唱
public static void PalyAgain()
{
if (SongList[SongIndex]!=null)
{
SongList[SongIndex].SongAgain(); }
} //切歌
public static void Cutsong()
{
//获取到当前播放的歌曲改变播放状态
if (SongList [SongIndex] != null)
{
SongList [SongIndex].PlayStar = SongPlayState.cut;
SongIndex++; //改变歌曲索引,播放下一首
} }
////切歌
// public static void CutSong(int index)
// {
// //迭代变量,代表切歌位置
// int i;
// if (index==-1)//循环变量,代表切歌位置
// {
// i=SongIndex;
// }else
// {
// //从切歌的位置开始,将歌曲逐个向前移动一个位置
// i=index;
// }
// SongList[i].SongCut();
// while (SongList[i]!=null)
// {
// SongList[i]=SongList[i+1];
// i++; // } // }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace MyKTV
{
enum SongPlayState
{
//未播放,播放,重播,切歌
unplayer, played, again, cut
}
public class Song
{ private string songName; public string SongName
{
get { return songName; }
set { songName = value; }
}
private string songUrl; public string SongUrl
{
get { return songUrl; }
set { songUrl = value; }
}
//歌曲播放状态默认为未播放
private SongPlayState playStar = SongPlayState.unplayer; internal SongPlayState PlayStar
{
get { return playStar; }
set { playStar = value; }
} //将歌曲状态改为播放
public void SongPlayed()
{ this.PlayStar = SongPlayState.played;
}
//歌曲状态重播
public void SongAgain()
{
this.PlayStar = SongPlayState.again;
}
//歌曲状态切歌
public void SongCut()
{
this.PlayStar = SongPlayState.cut;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace MyKTV
{
class SqlUtil
{
public static string str = "data source=.;initial catalog=KTV;user id=sa;pwd=718191";
}
}

1.首先就是展现KTV的主界面,让我们先了解一下那些功能

01.实现各个共功能的主代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace MyKTV
{
public partial class frmMain : Form
{
public frmMain()
{
//InitializeComponent();
} private void btnGX_Click(object sender, EventArgs e)
{
frmGXDG1 fg = new frmGXDG1();
fg.form1 = this;
fg.Show();
this.Hide();
}
//获取歌曲路径
public void SongPath()
{
string sql = "select resourcepath from resourcepath where resourceid=1";
SqlConnection con = new SqlConnection(SqlUtil.str);
SqlCommand com = new SqlCommand(sql, con);
try
{
con.Open();
KTVUtil.songPath= com.ExecuteScalar().ToString();
}
catch (Exception)
{ throw;
}
finally
{
con.Close();
}
}
private void frmMain_Load(object sender, EventArgs e)
{ //读取歌曲路径
SongPath();
//读取resourcepath表中的歌手图片
string sql = "select resourcepath from resourcepath where resourceid=2";
SqlConnection con = new SqlConnection(SqlUtil.str);
SqlCommand com = new SqlCommand(sql,con);
try
{
con.Open();
KTVUtil.picturePath=com.ExecuteScalar().ToString();
}
catch (Exception)
{ throw;
}
finally
{
con.Close();
}
}
private Song song;//当前播放的歌曲
//播放歌曲
public void PlaySong()
{
//调用播放当前歌曲方法
this.song = PlayList.GetPlaySong();
if (song!=null)
{
//改变播放状态为播放
this.song.SongPlayed();
Player2.URL = KTVUtil.songPath + "\\" + this.song.SongUrl; txtIng.Text = PlayList.PlaySongName(); }
} private void btnPY_Click(object sender, EventArgs e)
{
frmPY fp = new frmPY();
fp.Show();
} private void btnSZ_Click(object sender, EventArgs e)
{
frmNum fn = new frmNum();
fn.Show();
} private void btnLX_Click(object sender, EventArgs e)
{
frmType ft = new frmType();
ft.getSong(song); ft.Show();
} private void btnJB_Click(object sender, EventArgs e)
{
frmPaiHang fp = new frmPaiHang();
fp.Show();
} private void toolStripButton3_Click(object sender, EventArgs e)
{ frmYiDian fy = frmYiDian.getFrm();
fy.Show(); } private void panel2_Paint(object sender, PaintEventArgs e)
{ }
public static int cutSong = 0;
private void timer1_Tick(object sender, EventArgs e)
{
String nextSongName = PlayList.NextSongName();
txtNext.Text = nextSongName;
if (song == null)
{
PlaySong();
}
if (Player2.playState == WMPLib.WMPPlayState.wmppsStopped)
{
song = null;
PlayList.Next();
}
if (song != null && this.song.PlayStar == SongPlayState.cut)
{
this.song = null;
}
if (song != null)
{
if (this.song.PlayStar == SongPlayState.again)
{
this.song = null;
}
}
}
private void toolStripButton5_Click(object sender, EventArgs e)
{
Application.Exit();
} private void Player2_Enter(object sender, EventArgs e)
{ } private void timNow_Tick(object sender, EventArgs e)
{ } private void toolStripButton2_Click(object sender, EventArgs e)
{ DialogResult result = MessageBox.Show("确定要切歌吗?", "", MessageBoxButtons.YesNo);
if (result==DialogResult.Yes)
{
PlayList.Cutsong(); } } private void toolStripButton1_Click(object sender, EventArgs e)
{ PlayList.PalyAgain(); } private void txtIng_TextChanged(object sender, EventArgs e)
{
//txtIng.Text = PlayList.PlaySongName();
} private void txtNext_TextChanged(object sender, EventArgs e)
{
// txtNext.Text = PlayList.NextSongName();
} private void timer2_Tick(object sender, EventArgs e)
{ }
//原唱伴唱(可惜没实现)
private void button1_Click(object sender, EventArgs e)
{
if (Player2.settings.balance==100)
{
Player2.settings.balance = -100;
}
else
{
Player2.settings.balance = 100;
}
} }
}

     2.歌星点歌(三个listview的集成窗体)

01.歌手类别

02.歌手地区

03.歌手姓名

04.代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace MyKTV
{
public partial class frmGXDG1 : Form
{
public frmGXDG1()
{
InitializeComponent();
}
public int a = ;//三个listview标示
public int typeid = ;
public string sex = "组合";
public frmMain form1 = null;
private void frmGXDG1_Load(object sender, EventArgs e)
{
this.listView2.Visible = false;
this.listView3.Visible = false;
}
//动态加载第二个listView五个图片
private void listView1_Click(object sender, EventArgs e)
{
a = ;
if (listView1.SelectedItems[]!=null)
{
listView2.Visible = true;
listView2.Location = listView1.Location;
//记录第一个listview所选类型
sex = listView1.SelectedItems[].Tag.ToString();
}
string sql = "select singercountryid,singercountryname from singercountry";
SqlConnection con = new SqlConnection(SqlUtil.str);
SqlCommand com = new SqlCommand(sql, con);
try
{
con.Open();
SqlDataReader reader = com.ExecuteReader(); listView2.Items.Clear();
if (reader.HasRows)
{
int num = ;
while (reader.Read())
{
ListViewItem lv = new ListViewItem();
lv.Text = reader["singercountryname"].ToString();
lv.Tag = Convert.ToInt32(reader["singercountryid"]); lv.ImageIndex = num;
listView2.Items.Add(lv);
num++;
}
reader.Close();
}
}
catch (Exception)
{ throw;
}
finally
{
con.Close();
}
} private void listView2_Click(object sender, EventArgs e)
{
a = ;
if (listView2.SelectedItems[]!=null)
{
listView2.Visible = false;
listView3.Visible = true;
listView3.Location = listView2.Location;
//保存所选择的地区编号
typeid = Convert.ToInt32(listView2.SelectedItems[].Tag);
string result=sex;
if (sex!="组合")
{
result=sex ;
}
string sql = "select singername,singerphotourl,singerid from singerinfo where singercountryid='"+typeid+"' and singersex='"+result+"'";
SqlConnection con = new SqlConnection(SqlUtil.str);
SqlCommand com = new SqlCommand(sql,con);
try
{
con.Open();
SqlDataReader reader = com.ExecuteReader();
listView3.Items.Clear();//清空listview列表集合
if (reader.HasRows)
{
int num = ;//添加的图片下标
imageList3.Images.Clear();//情况图片集合 while (reader.Read())
{
//读取图片地址
string path = KTVUtil.picturePath + "\\" + reader["singerphotourl"].ToString();
//把读取出来的图片添加到imagelist3上
imageList3.Images.Add(Image.FromFile(path));
ListViewItem lv = new ListViewItem();
lv.Text=reader["singername"].ToString();
lv.Tag = Convert.ToInt32(reader["singerid"]);
lv.ImageIndex = num;
listView3.Items.Add(lv);
num++;
}
}
}
catch (Exception)
{ throw;
}
finally
{
con.Close();
}
}
} private void listView3_Click(object sender, EventArgs e)
{
string sql = @"select singername,songname,songurl,songid from singerinfo as s,songinfo as f
where s.singerid=f.singerid and singername='"+listView3.SelectedItems[].Text+"'"; frmSongList fs = new frmSongList();
fs.sql = sql;
fs.Show(); } private void tsbYD_Click(object sender, EventArgs e)
{
frmYiDian fy = frmYiDian.getFrm();
fy.Show();
} private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{ } private void tsbFH_Click(object sender, EventArgs e)
{
if (a==)
{
a = ;
this.listView1.Visible = true;
this.listView2.Visible = false;
this.listView3.Visible = false;
}else
if (a==)
{
a = ;
listView2.Visible = true;
listView1.Visible = false;
listView3.Visible = false;
}else
if (a==)
{ form1.Show(); }
} private void tsbTC_Click(object sender, EventArgs e)
{
form1.Show(); this.Close();
} private void listView3_SelectedIndexChanged(object sender, EventArgs e)
{ } private void tsbCC_Click(object sender, EventArgs e)
{
PlayList.PalyAgain();
} private void tsbQG_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("确定要切歌吗?", "", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
PlayList.Cutsong();
}
} }
}

05.歌曲列表

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace MyKTV
{
public partial class frmSongList : Form
{
public string sql = "";
public int count = ;
public frmSongList()
{
InitializeComponent();
} private void frmSongList_Load(object sender, EventArgs e)
{
if (count != )
{
string numsql = "select singername,songname,songurl,songid from singerinfo as s,songinfo as f where s.singerid=f.singerid and songcount=" + count + "";
NewMethod(numsql);
}
else
{
NewMethod(sql);
}
}
//加载frmSongList控件里dgvList数据
private void NewMethod(string sql)
{
dgvList.AutoGenerateColumns = false;
SqlConnection con = new SqlConnection(SqlUtil.str);
SqlDataAdapter da = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
da.Fill(ds);
dgvList.DataSource = ds.Tables[];
} private void dgvList_CellClick(object sender, DataGridViewCellEventArgs e)
{
//点击某首歌曲,并将选中的歌曲名和路径赋给该对象()
Song song = new Song();
song.SongName = dgvList.SelectedRows[].Cells[].Value.ToString(); string a = dgvList.SelectedRows[].Cells[].Value.ToString();
song.SongUrl=a;
PlayList.AddSong(song);
string name = dgvList.SelectedRows[].Cells[].Value.ToString();
addCount(name); }
public void addCount(string name)
{
SqlConnection con = new SqlConnection(SqlUtil.str);
string sql = "update songinfo set songplaycount+=1 where songname='"+name+"'";
SqlCommand com = new SqlCommand(sql,con);
try
{
con.Open();
int num = com.ExecuteNonQuery();
}
catch (Exception)
{ throw;
}
finally
{
con.Close();
}
} private void dgvList_CellContentClick(object sender, DataGridViewCellEventArgs e)
{ }
}
}

字数点歌

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; namespace MyKTV
{
public partial class frmNum : Form
{
public frmNum()
{
InitializeComponent();
}
int count = ;
private void btn1_Click(object sender, EventArgs e)
{
count = Convert.ToInt32(btn1.Text);
frmSongList fs = new frmSongList();
fs.count = count;
fs.Show(); } private void btn2_Click(object sender, EventArgs e)
{
count = Convert.ToInt32(btn2.Text);
frmSongList fs = new frmSongList();
fs.count = count;
fs.Show();
} private void btn3_Click(object sender, EventArgs e)
{
count = Convert.ToInt32(btn3.Text);
frmSongList fs = new frmSongList();
fs.count = count;
fs.Show();
} private void btn4_Click(object sender, EventArgs e)
{
count = Convert.ToInt32(btn4.Text);
frmSongList fs = new frmSongList();
fs.count = count;
fs.Show();
} private void btn5_Click(object sender, EventArgs e)
{
count = Convert.ToInt32(btn5.Text);
frmSongList fs = new frmSongList();
fs.count = count;
fs.Show();
} private void btn6_Click(object sender, EventArgs e)
{
count = Convert.ToInt32(btn6.Text);
frmSongList fs = new frmSongList();
fs.count = count;
fs.Show();
} private void btn7_Click(object sender, EventArgs e)
{
count = Convert.ToInt32(btn7.Text);
frmSongList fs = new frmSongList();
fs.count = count;
fs.Show();
} private void btn8_Click(object sender, EventArgs e)
{
count = Convert.ToInt32(btn8.Text);
frmSongList fs = new frmSongList();
fs.count = count;
fs.Show();
} private void btn9_Click(object sender, EventArgs e)
{
count = Convert.ToInt32(btn9.Text);
frmSongList fs = new frmSongList();
fs.count = count;
fs.Show();
} private void toolStripButton2_Click(object sender, EventArgs e)
{
PlayList.PalyAgain();
} private void toolStripButton1_Click(object sender, EventArgs e)
{ } private void toolStripButton3_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("确定要切歌吗?", "", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
PlayList.Cutsong();
}
} private void toolStripButton4_Click(object sender, EventArgs e)
{
frmYiDian fy = frmYiDian.getFrm();
fy.Show();
} private void frmNum_Load(object sender, EventArgs e)
{ }
}
}

金榜排行

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace MyKTV
{
public partial class frmPaiHang : Form
{
public frmPaiHang()
{
InitializeComponent();
} private void frmPaiHang_Load(object sender, EventArgs e)
{
Initial();
}
public void Initial()
{
SqlConnection con = new SqlConnection(SqlUtil.str);
string sql = "select singername,songname,songplaycount,songurl from singerinfo as s,songinfo as f where s.singerid=f.singerid order by songplaycount desc";
SqlCommand com = new SqlCommand(sql, con);
try
{
con.Open();
SqlDataReader reader = com.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
string songname = Convert.ToString(reader["songname"]);
string singername = Convert.ToString(reader["singername"]);
int count = Convert.ToInt32(reader["songplaycount"]);
string songurl = Convert.ToString(reader["songurl"]);
ListViewItem lv = new ListViewItem(songname);
lv.SubItems.Add(singername);
lv.SubItems.Add(count.ToString());
lv.SubItems.Add(songurl);
lvPH1.Items.Add(lv);
}
}
}
catch (Exception)
{
throw;
}
finally
{
con.Close();
}
} private void toolStripButton4_Click(object sender, EventArgs e)
{
frmYiDian fy = frmYiDian.getFrm();
fy.Show();
} private void lvPH_SelectedIndexChanged(object sender, EventArgs e)
{ } private void lvPH_Click(object sender, EventArgs e)
{ } private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{ } private void listView1_Click(object sender, EventArgs e)
{
Song song = new Song();
song.SongName = lvPH1.SelectedItems[].SubItems[].Text;
song.SongUrl = lvPH1.SelectedItems[].SubItems[].Text;
PlayList.AddSong(song);
frmSongList fs = new frmSongList();
string name = lvPH1.SelectedItems[].SubItems[].Text;
fs.addCount(name);
this.lvPH1.Items.Clear();
Initial(); } private void toolStripButton2_Click(object sender, EventArgs e)
{
PlayList.PalyAgain();
} private void toolStripButton3_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("确定要切歌吗?", "", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
PlayList.Cutsong();
}
} private void timer1_Tick(object sender, EventArgs e)
{
this.lvPH1.Items.Clear(); ;
Initial();
}
}
}

类型点歌

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; namespace MyKTV
{
public partial class frmType : Form
{
public frmType()
{
InitializeComponent();
}
private Song song;//当前播放的歌曲
public void getSong(Song so){
this.song=so;
}
private void lvType_SelectedIndexChanged(object sender, EventArgs e)
{ }
//类型点歌
private void lvType_Click(object sender, EventArgs e)
{
string sql = "select singername,songname,songurl,songid from singerinfo as s,songinfo as f where s.singerid=f.singerid and songtype='" +lvType.SelectedItems[].Text+ "'";
frmSongList fs = new frmSongList();
fs.sql = sql;
fs.Show();
} private void toolStripButton4_Click(object sender, EventArgs e)
{
frmYiDian fy = frmYiDian.getFrm();
fy.Show();
} private void frmType_Load(object sender, EventArgs e)
{ } private void toolStripButton2_Click(object sender, EventArgs e)
{
PlayList.PalyAgain();
} private void toolStripButton3_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("确定要切歌吗?", "", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
PlayList.Cutsong();
}
}
}
}

拼音点歌

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace MyKTV
{
public partial class frmPY : Form
{
public frmPY()
{
InitializeComponent();
}
public string py = ""; private void butA_Click(object sender, EventArgs e)
{
py += btnA.Text;
txtPY.Text = py;
select();
} private void butB_Click(object sender, EventArgs e)
{
py += btnB.Text;
txtPY.Text = py;
select();
} private void butC_Click(object sender, EventArgs e)
{
py += btnC.Text;
txtPY.Text = py;
select();
} private void btnD_Click(object sender, EventArgs e)
{
py += btnD.Text;
txtPY.Text = py;
select();
} private void btnE_Click(object sender, EventArgs e)
{
py += btnE.Text;
txtPY.Text = py;
select();
} private void btnF_Click(object sender, EventArgs e)
{
py += btnF.Text;
txtPY.Text = py;
select();
} private void btnG_Click(object sender, EventArgs e)
{
py += btnG.Text;
txtPY.Text = py;
select();
} private void btnH_Click(object sender, EventArgs e)
{ } private void btnI_Click(object sender, EventArgs e)
{
py += btnI.Text;
txtPY.Text = py;
select();
}
private void btnK_Click(object sender, EventArgs e)
{
py += btnK.Text;
txtPY.Text = py;
select();
} private void btnL_Click(object sender, EventArgs e)
{
py += btnL.Text;
txtPY.Text = py;
select();
} private void btnM_Click(object sender, EventArgs e)
{
py += btnM.Text;
txtPY.Text = py;
select();
} private void btnN_Click(object sender, EventArgs e)
{
py += btnN.Text;
txtPY.Text = py;
select();
} private void btnO_Click(object sender, EventArgs e)
{
py += btnO.Text;
txtPY.Text = py;
select();
} private void btnP_Click(object sender, EventArgs e)
{
py += btnP.Text;
txtPY.Text = py;
select();
} private void btnQ_Click(object sender, EventArgs e)
{
py += btnQ.Text;
txtPY.Text = py;
select();
} private void btnR_Click(object sender, EventArgs e)
{
py += btnR.Text;
txtPY.Text = py;
select();
} private void btnS_Click(object sender, EventArgs e)
{
py += btnS.Text;
txtPY.Text = py;
select();
} private void btnT_Click(object sender, EventArgs e)
{
py += btnT.Text;
txtPY.Text = py;
select();
} private void btnU_Click(object sender, EventArgs e)
{
py += btnU.Text;
txtPY.Text = py;
select();
} private void btnV_Click(object sender, EventArgs e)
{
py += btnV.Text;
txtPY.Text = py;
select();
} private void btnW_Click(object sender, EventArgs e)
{
py += btnW.Text;
txtPY.Text = py;
select();
} private void btnX_Click(object sender, EventArgs e)
{
py += btnX.Text;
txtPY.Text = py;
select();
} private void btnY_Click(object sender, EventArgs e)
{
py += btnY.Text;
txtPY.Text = py;
select();
} private void btnZ_Click(object sender, EventArgs e)
{
py += btnZ.Text;
txtPY.Text = py;
select();
} private void btnJ_Click(object sender, EventArgs e)
{
py += btnJ.Text;
txtPY.Text = py;
select();
} private void btnPY_Click(object sender, EventArgs e)
{
int length = py.Length;
if (length>)
{
py = py.Substring(,length-);
txtPY.Text = py;
select();
} }
//拼音模糊查询
public void select() {
dgvPY.AutoGenerateColumns = false;
string sql = @"select singername,songname,songurl,songid from singerinfo as s,songinfo as f
where s.singerid=f.singerid and songab like '" + txtPY.Text + "%'";
SqlConnection con = new SqlConnection(SqlUtil.str);
SqlDataAdapter da = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
da.Fill(ds);
dgvPY.DataSource = ds.Tables[];
} private void txtPY_TextChanged(object sender, EventArgs e)
{
select();
} private void btnH_Click_1(object sender, EventArgs e)
{
py += btnH.Text;
txtPY.Text = py;
select();
} private void toolStripButton4_Click(object sender, EventArgs e)
{
frmYiDian fy = frmYiDian.getFrm();
fy.Show();
} private void dgvPY_CellClick(object sender, DataGridViewCellEventArgs e)
{
Song song = new Song();
song.SongName = dgvPY.SelectedRows[].Cells[].Value.ToString(); string a = dgvPY.SelectedRows[].Cells[].Value.ToString();
song.SongUrl = a; PlayList.AddSong(song);
} private void frmPY_Load(object sender, EventArgs e)
{ } private void panel1_Paint(object sender, PaintEventArgs e)
{ } private void toolStripButton2_Click(object sender, EventArgs e)
{
PlayList.PalyAgain();
} private void toolStripButton3_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("确定要切歌吗?", "", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
PlayList.Cutsong();
}
}
} }

已点列表

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; namespace MyKTV
{
public partial class frmYiDian : Form
{
private frmYiDian()
{
InitializeComponent();
}
public static frmYiDian frm;
public static frmYiDian getFrm()
{
if (frm==null)
{
frm = new frmYiDian();
}
return frm;
} public static int style = ;
private void lvYiDian_SelectedIndexChanged(object sender, EventArgs e)
{ }
public void RefreshSongList()
{
lvYiDian.Items.Clear();//清空原列表
for (int i = ; i < PlayList.SongList.Length; i++)
{
if (PlayList.SongList[i]!=null)
{
ListViewItem item = new ListViewItem(PlayList.SongList[i].SongName);
item.Tag = i;
//获取播放状态
string bofang = PlayList.SongList[i].PlayStar == SongPlayState.unplayer ? "未播放" : "已播放";
item.SubItems.Add(bofang);
lvYiDian.Items.Add(item);
}
}
} private void frmYiDian_Load(object sender, EventArgs e)
{
style = ;
RefreshSongList();
} private void timer1_Tick(object sender, EventArgs e)
{
RefreshSongList();
} private void frmYiDian_FormClosing(object sender, FormClosingEventArgs e)
{
style = ;
} private void 切歌ToolStripMenuItem_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("确定要切歌吗?", "", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
PlayList.Cutsong();
}
} private void 重唱ToolStripMenuItem_Click(object sender, EventArgs e)
{
PlayList.PalyAgain();
} }
}

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.Data.SqlClient;namespace MyKTV{    public partial class frmMain : Form    {        public frmMain()        {            //InitializeComponent();        }
        private void btnGX_Click(object sender, EventArgs e)        {            frmGXDG1 fg = new frmGXDG1();            fg.form1 = this;            fg.Show();            this.Hide();        }        //获取歌曲路径        public void SongPath()        {            string sql = "select resourcepath from resourcepath where resourceid=1";            SqlConnection con = new SqlConnection(SqlUtil.str);            SqlCommand com = new SqlCommand(sql, con);            try            {                con.Open();                KTVUtil.songPath= com.ExecuteScalar().ToString();            }            catch (Exception)            {
                throw;            }            finally            {                con.Close();            }        }        private void frmMain_Load(object sender, EventArgs e)        {                        //读取歌曲路径            SongPath();            //读取resourcepath表中的歌手图片            string sql = "select resourcepath from resourcepath where resourceid=2";            SqlConnection con = new SqlConnection(SqlUtil.str);            SqlCommand com = new SqlCommand(sql,con);            try            {                con.Open();                KTVUtil.picturePath=com.ExecuteScalar().ToString();            }            catch (Exception)            {
                throw;            }            finally            {                con.Close();            }        }        private Song song;//当前播放的歌曲        //播放歌曲        public void PlaySong()        {            //调用播放当前歌曲方法            this.song = PlayList.GetPlaySong();            if (song!=null)            {                //改变播放状态为播放                this.song.SongPlayed();                Player2.URL = KTVUtil.songPath + "\\" + this.song.SongUrl;                               txtIng.Text = PlayList.PlaySongName();                            }        }
        private void btnPY_Click(object sender, EventArgs e)        {            frmPY fp = new frmPY();            fp.Show();        }
        private void btnSZ_Click(object sender, EventArgs e)        {            frmNum fn = new frmNum();            fn.Show();        }
        private void btnLX_Click(object sender, EventArgs e)        {            frmType ft = new frmType();            ft.getSong(song);                        ft.Show();        }
        private void btnJB_Click(object sender, EventArgs e)        {            frmPaiHang fp = new frmPaiHang();            fp.Show();        }                 private void toolStripButton3_Click(object sender, EventArgs e)        {
                frmYiDian fy = frmYiDian.getFrm();                fy.Show();                                }
        private void panel2_Paint(object sender, PaintEventArgs e)        {
        }       public static int cutSong = 0;       private void timer1_Tick(object sender, EventArgs e)       {           String nextSongName = PlayList.NextSongName();           txtNext.Text = nextSongName;           if (song == null)           {               PlaySong();           }           if (Player2.playState == WMPLib.WMPPlayState.wmppsStopped)           {               song = null;               PlayList.Next();           }           if (song != null && this.song.PlayStar == SongPlayState.cut)           {               this.song = null;           }           if (song != null)           {               if (this.song.PlayStar == SongPlayState.again)               {                   this.song = null;               }           }       }        private void toolStripButton5_Click(object sender, EventArgs e)        {            Application.Exit();        }
        private void Player2_Enter(object sender, EventArgs e)        {
        }
        private void timNow_Tick(object sender, EventArgs e)        {                              }
        private void toolStripButton2_Click(object sender, EventArgs e)        {
            DialogResult result = MessageBox.Show("确定要切歌吗?", "", MessageBoxButtons.YesNo);            if (result==DialogResult.Yes)            {                PlayList.Cutsong();             }                   }
        private void toolStripButton1_Click(object sender, EventArgs e)        {                       PlayList.PalyAgain();                    }
        private void txtIng_TextChanged(object sender, EventArgs e)        {            //txtIng.Text = PlayList.PlaySongName();        }
        private void txtNext_TextChanged(object sender, EventArgs e)        {           // txtNext.Text = PlayList.NextSongName();        }                private void timer2_Tick(object sender, EventArgs e)        {                   }        //原唱伴唱(可惜没实现)        private void button1_Click(object sender, EventArgs e)        {            if (Player2.settings.balance==100)            {                Player2.settings.balance = -100;            }            else            {                Player2.settings.balance = 100;            }        }           }}

欢迎进入MyKTV点歌系统展示的更多相关文章

  1. 欢迎进入MyKTV前后台点歌系统展示

    一个项目,一分收获:一个项目,一些资源.Ktv项目也是一样的,所以我想分享我的收获,让你们获得你需要的资源. 一. 那MyKTV点歌系统具体的功能有哪些呢?我们就来看看吧! 1.MyKTV前台功能: ...

  2. KTV点歌系统

    经过十多天的艰苦奋战,MyKTV点歌系统终于成型,从刚开始接到项目的茫然,到完成项目时的喜悦,整个过程的艰辛和付出只有自己知道.虽然这个项目还有许多需要完善的地方,譬如添加歌词信息,实现窗体的美化等, ...

  3. KTV点歌系统播放原理

    北大青鸟KTV点歌系统播放原理 指导老师--原玉明 1.首先知道有两个类(PlayList   Song) PlayList类中有一方法 public static bool AddSong(Song ...

  4. java——集合、泛型、ArrayList、LinkedList、foreach循环、模拟ktv点歌系统

    集合:一系列特殊的类,这些类可以存储任意类型的对象,长度可变,集合类都在java.util包中. 但是集合记不住对象的类型,当把对象从集合中取出时这个对象的编译类型就变成了Object类型.这样在取元 ...

  5. 使用Egg改造订单系统展示效果,方便快速浏览

    素材准备: 1.Egg.js Born to build better enterprise frameworks and apps with Node.js & Koa 为企业级框架和应用而 ...

  6. Q:解决每天第一次打开MSCRM系统展示慢的问题

    问题:第天第一次打开系统时,需要加载很长时间,基本为1分多钟,而第二次打开只需5秒. 解决方案:利用IIS中的Session. 一.打开IIS,选择打开服务器功能中“Session State”. 二 ...

  7. CD租赁售卖系统javaweb系统展示SSM框架

    一.功能要点 1.管理员登录 2.用户注册登录 3.用户权限,可以查看可借或可买cd,并实现对cd的买租 4.管理员可以添加cd, 5.cd的类型,价格由管理员设置 二.运行环境 数据库mysql: ...

  8. 第1章 Linux系统简介

    第1节 UNIX发展历史和发行版本 1. UNIX与Linux发展史 1.1 UNIX发展历史 (1)1965年,美国麻省理工学院(MIT).通用电气公司(GE)及AT&T的贝尔实验室联合开发 ...

  9. 告别IT,出售多年自己研发的股票分析系统源码

    不知已过而立,发狠告别IT,回头看看以前自己的多个作品,耗时最多的就是这个股票分析系统了,留在自己的电脑里也体现不出多大价值了,故打算出售源码给需要的人,联系方式QQ:874724605 注明:股票源 ...

随机推荐

  1. Repository 返回 IQueryable?还是 IEnumerable?

    这是一个很有意思的问题,我们一步一步来探讨,首先需要明确两个概念(来自 MSDN): IQueryable:提供对未指定数据类型的特定数据源的查询进行计算的功能. IEnumerable:公开枚举数, ...

  2. Full Gc经历分析

    背景: 个别机器:内存突然上升,cpu利用率升高. 解决过程 1. jmap dump整个内存镜像 2. 整个文件700多M,使用Jhat打不开 3. 换heapanalyzer,能打开,但没有分析出 ...

  3. C# PPT 为形状设置三维效果

    在PPT中,形状是非常重要的元素.3-D形状,立体多元,给人耳目一新的感觉.在幻灯片中添加3-D效果形状,必然会为PPT的整体效果增色不少.为形状设置三维格式时,可设置棱台,轮廓线,表面效果等. 本篇 ...

  4. 附录E 安装Kafka

    E.1   安装Kafka E.1.1    下载Kafka Kafka是由LinkedIn设计的一个高吞吐量.分布式.基于发布订阅模式的消息系统,使用Scala编写,它以可水平扩展.可靠性.异步通信 ...

  5. CSS3的flex布局

    flex的一些属性 CSS3中引入了另一种框--flexbox,flexbox有一些block和inline不同的性质,比如: 自适应子元素(flex item,又称伸缩项目)的宽度 伸缩项目的flo ...

  6. 【Java心得总结五】Java容器上——容器初探

    在数学中我们有集合的概念,所谓的一个集合,就是将数个对象归类而分成为一个或数个形态各异的大小整体. 一般来讲,集合是具有某种特性的事物的整体,或是一些确认对象的汇集.构成集合的事物或对象称作元素或是成 ...

  7. cookie设置保存用户名,填入中文名之后出现的错误500问题

    对于问题发生的原因以后再来补充: 解决方法就是在dologin.jsp当中使用URLEncode工具类,这个工具类在java的net包当中 <一>用户浏览器-->jsp  的过程 1 ...

  8. 【原创】HDFS介绍

    一.            HDFS简介 1.    HDFS全称 Hadoop Distributed FileSystem,Hadoop分布式文件系统. Hadoop有一个抽象文件系统的概念,Ha ...

  9. 安装DotNetCore.1.0.1-VS2015Tools.Preview2.0.2出现0x80072f8a未指定的错误

    本文转载自: http://www.cnblogs.com/JiaoWoWeiZai/p/5892255.html 最近DotNetCore更新到了1.0.1,Azure tools也更新到了2.9. ...

  10. jquery制作论坛或社交网站的每天打卡签到特效

    效果:http://hovertree.com/texiao/jquery/50/ 现在许多社区,购物等网站都设置签到功能,打开可以收获经验.虚拟币等,提高用户粘性,增加浏览量,是一个不错的功能.本文 ...