你的位置:首页 > 软件开发 > ASP.net > 小学生之KTV项目文档(bdqn) 指导老师:yuanyuming

小学生之KTV项目文档(bdqn) 指导老师:yuanyuming

发布时间:2015-07-31 11:00:17
第一步:创建数据库连接方法和打开方法和关闭方法! 1 public class DBHelper 2 { 3 private string str = "server=.;database=MyKtv;uid=sa"; 4 private Sq ...

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

小学生之KTV项目文档(bdqn)     指导老师:yuanyuming
 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       get='_blank'>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     }
小学生之KTV项目文档(bdqn)     指导老师:yuanyuming

第三步:歌星点歌

小学生之KTV项目文档(bdqn)     指导老师:yuanyuming

小学生之KTV项目文档(bdqn)     指导老师:yuanyuming

小学生之KTV项目文档(bdqn)     指导老师:yuanyuming

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

小学生之KTV项目文档(bdqn)     指导老师:yuanyuming
 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     }
小学生之KTV项目文档(bdqn)     指导老师:yuanyuming

第五步:已点歌曲

小学生之KTV项目文档(bdqn)     指导老师:yuanyuming

 

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

小学生之KTV项目文档(bdqn)     指导老师:yuanyuming
 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     }
小学生之KTV项目文档(bdqn)     指导老师:yuanyuming

第七部:金榜排行

 小学生之KTV项目文档(bdqn)     指导老师:yuanyuming

小学生之KTV项目文档(bdqn)     指导老师:yuanyuming
 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   }
小学生之KTV项目文档(bdqn)     指导老师:yuanyuming

第九步:类型点歌

 

 小学生之KTV项目文档(bdqn)     指导老师:yuanyuming

小学生之KTV项目文档(bdqn)     指导老师:yuanyuming

原标题:小学生之KTV项目文档(bdqn) 指导老师:yuanyuming

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录