已阅读5页,还剩22页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
智能08 臧宝龙 40850238多媒体课程设计报告班级:智能08姓名:臧宝龙学号:40850238KTV点歌系统课程设计一 目标:使用VB.Net制作一个简易的多媒体点歌系统。二 功能需求:1. 实现歌曲文件的扫描并存储2. 歌星选择(字母)3. 歌名选择4. 点唱预约三设备及软件:PC机一台;Visual Studio2008;Microsoft Access2003三 源代码及相关功能演示:本设计基于学生信息管理系统并加以深度的改造与改进,基本实现了所需功能。1. DBoperation代码Public Class DBOperation Shared Function DBOperate(ByVal SQLString As String) As DataTable Dim CONN As String CONN = provider = microsoft.jet.oledb.4.0; & data source = K:课程设计课程设计KTVKTVbinDebugktv.mdb Dim oleconn As New OleDb.OleDbConnection(CONN) Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(SQLString, oleconn) cmd.CommandType = CommandType.Text Dim sTokens() As String sTokens = SQLString.Split( ) If Strings.InStr(INSERT,DELETE,UPDATE, sTokens(0).ToUpper) Then If oleconn.State ConnectionState.Open Then oleconn.Open() 打开数据库连接 End If cmd.ExecuteNonQuery() 执行SQL语句 If oleconn.State ConnectionState.Closed Then oleconn.Close() 关闭数据库连接 End If If sTokens(0).ToUpper = INSERT Then MsgBox(编辑记录成功) End If If sTokens(0).ToUpper = DELETE Then MsgBox(删除记录成功) End If If sTokens(0).ToUpper = UPDATE Then MsgBox(更新记录成功) End If Return Nothing Else Dim ObjectdsDataSet As New DataSet() Dim adapter As New OleDb.OleDbDataAdapter() adapter.TableMappings.Add(Table, TEMP) adapter.SelectCommand = cmd If oleconn.State ConnectionState.Open Then oleconn.Open() 打开数据库连接 End If cmd.ExecuteNonQuery() 执行SQL语句 If oleconn.State ConnectionState.Closed Then oleconn.Close() 关闭数据库连接 End If adapter.Fill(ObjectdsDataSet) 填充数据集 Return ObjectdsDataSet.Tables(TEMP) End If End FunctionEnd Class2. DBuser代码Public Class DBUser Private _UserName As String Private _Password As String Property username() As String Get Return _UserName End Get Set(ByVal value As String) _UserName = value End Set End Property Property password() As String Get Return _Password End Get Set(ByVal value As String) _Password = value End Set End Property Sub New(ByVal Name As String, ByVal PWD As String) _UserName = Name _Password = PWD End Sub Function LoginConfirm() As Boolean Dim SQLString As String SQLString = SELECT * FROM 用户信息表 WHERE 用户名= & _UserName & AND 密码= & _Password & Dim UserTable As DataTable = DBOperation.DBOperate(SQLString) 判断输入的信息在数据库中是否存在记录 If UserTable.Rows.Count = 0 Then MsgBox(你输入的用户名和密码不正确,请重新输入!, MsgBoxStyle.Exclamation, 消息框) Return False 没有信息则返回失败,说明输入的信息不正确. Else Return True End If End FunctionEnd Class3. Form1(播放界面)代码Imports System.IOImports System.Data.OleDbImports System.TextImports AxWMPLibImports SystemPublic Class form1 Dim da As OleDbDataAdapter Dim ds As DataSet Dim Comm As OleDbCommand Dim Comm1 As OleDbCommand Dim conn As OleDbConnection Dim songpath As String Dim songname As String Dim songshortname As String Dim songsinger As String Dim songzishu As String Dim songyuzhong As String Dim songgelei As String Dim songmovie As String Dim songstyle As String Dim songpop As String Dim songyinliang As String Dim songshengdao As String Dim songfmp As String Dim songyuyin As String Dim songjiezhi As String Dim songtime As String Dim songpinyin As String Dim filesname As String Dim x As String Dim ip As Int32 Dim y As String Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click播放按钮 AxWindowsMediaPlayer1.URL = songpath AxWindowsMediaPlayer1.Ctlcontrols.play() End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click全屏显示按钮 AxWindowsMediaPlayer1.fullScreen = True End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click伴唱按钮 AxWindowsMediaPlayer1.settings.balance = -1 表示媒体播放的声道设置,0表示均衡,-1和表示左右声道. End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click原唱按钮 AxWindowsMediaPlayer1.settings.balance = 0 表示媒体播放的声道设置,0表示均衡,-1和表示左右声道. End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load x = 0 ip = 0 Try conn = New OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;Password=;User ID=Admin;Data Source= + Application.StartupPath + ktv.mdb) Dim Comm1 As New OleDbCommand(select 歌名,全路径from myktv, conn) da = New OleDbDataAdapter() da.SelectCommand = Comm1 conn.Open() ds = New DataSet() da.Fill(ds, grade) DataGridView1.DataSource = ds.Tables(grade) Catch End Try AxWindowsMediaPlayer1.URL = DataGridView1.Rows(0).Cells(1).Value AxWindowsMediaPlayer1.Ctlcontrols.play() End Sub Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click返回按钮 AxWindowsMediaPlayer1.Ctlcontrols.stop() MessageBox.Show(回到主界面吗?) Dim frm As New Form2 frm.Show() Me.Finalize() End Sub Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick If e.RowIndex DataGridView1.Rows.Count - 1 Then AxWindowsMediaPlayer1.URL = DataGridView1.Rows(e.RowIndex).Cells(1).Value.ToString() x = e.RowIndex AxWindowsMediaPlayer1.Ctlcontrols.play() Label1.Text = AxWindowsMediaPlayer1.currentMedia.duration.ToString Label2.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentPositionString TextBox2.Text = x End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click暂停按钮 Select Case ip Case 0 AxWindowsMediaPlayer1.Ctlcontrols.pause() Button2.Text = 继续 ip = ip + 1 Case 1 Button2.Text = 暂停 AxWindowsMediaPlayer1.Ctlcontrols.play() ip = ip - 1 End Select End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click停止按钮 AxWindowsMediaPlayer1.Ctlcontrols.stop() End Sub Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) AxWindowsMediaPlayer1.Ctlcontrols.fastForward() AxWindowsMediaPlayer1.settings.rate = (AxWindowsMediaPlayer1.settings.rate) * 16 AxWindowsMediaPlayer1.Ctlcontrols.fastForward() End Sub Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll AxWindowsMediaPlayer1.Ctlcontrols.currentPosition = TrackBar1.Value TextBox1.Text = TrackBar1.Value End Sub Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click搜索按钮 Try conn = New OleDbConnection(provider = microsoft.jet.oledb.4.0; & data source = K:课程设计课程设计KTVKTVbinDebugktv.mdb) Dim Comm1 As New OleDbCommand(select 歌名,全路径from myktv where 歌名like % & TextBox1.Text & %, conn) da = New OleDbDataAdapter() da.SelectCommand = Comm1 conn.Open() ds = New DataSet() da.Fill(ds, grade) DataGridView1.DataSource = ds.Tables(grade) Catch End Try End Sub Private Sub AxWindowsMediaPlayer1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AxWindowsMediaPlayer1.Enter End Sub Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click切歌按钮 AxWindowsMediaPlayer1.URL = DataGridView1.Rows(x + 1).Cells(1).Value AxWindowsMediaPlayer1.Ctlcontrols.play() x = x + 1 End Sub Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter End Sub Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar2.Scroll AxWindowsMediaPlayer1.settings.volume = TrackBar2.Value TextBox1.Text = TrackBar2.Value End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim z As String Label1.Text = AxWindowsMediaPlayer1.currentMedia.durationString z = AxWindowsMediaPlayer1.currentMedia.duration TrackBar1.Maximum = z If z = 0 Then Exit Sub End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick Dim z As String Label2.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentPositionString z = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition If z = 0 Then Exit Sub 可能因为媒体文件的打开需要一定时间,这里等待媒体文件的打开 End Sub Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick Dim z1 As Int32 Dim z2 As Int32 z1 = AxWindowsMediaPlayer1.currentMedia.duration z2 = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition If (z1 = z2 And z1 0) Then AxWindowsMediaPlayer1.URL = DataGridView1.Rows(x + 1).Cells(1).Value TextBox2.Text = x AxWindowsMediaPlayer1.Ctlcontrols.play() x = x + 1 MessageBox.Show(下一首) Else End If TrackBar1.Value = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition End SubEnd Class界面如下:4. Form2(主界面)代码Imports System.IOImports System.Data.OleDbImports System.TextImports AxWMPLibImports SystemPublic Class Form2 Dim da As OleDbDataAdapter Dim ds As DataSet Dim Comm As OleDbCommand Dim Comm1 As OleDbCommand Dim conn As OleDbConnection Dim songpath As String Dim songname As String Dim songshortname As String Dim songsinger As String Dim songzishu As String Dim songyuzhong As String Dim songgelei As String Dim songmovie As String Dim songstyle As String Dim songpop As String Dim songyinliang As String Dim songshengdao As String Dim songfmp As String Dim songyuyin As String Dim songjiezhi As String Dim songtime As String Dim songpinyin As String Dim filesname As String Dim x As String Dim ip As Int32 Dim y As String Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click点播歌曲按钮 Dim frm1 As New Form3 frm1.Show() Me.Finalize() End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click 系统管理按钮 Dim frm2 As New Form7 frm2.Show() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click已唱歌曲按钮 Dim frm3 As New Form5 frm3.Show() Me.Finalize() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click歌星点歌按钮 Dim frm4 As New Form4 frm4.Show() Me.Finalize() End Sub Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim files As String() Dim music As String() Dim i As Int32 files = System.IO.Directory.GetFiles(K:课程设计课程设计KTVKTVbinDebug999, *.ksc) music = System.IO.Directory.GetFiles(K:课程设计课程设计KTVKTVbinDebug999, *.mkv) While i files.Length Dim sr As New StreamReader(DirectCast(File.OpenRead(files(i), System.IO.Stream), System.Text.Encoding.Default) Dim s As String s = sr.ReadToEnd() sr.Close() songpath = music(i) songname = s.Substring(s.IndexOf(歌名) + 6, s.IndexOf(缩写) - s.IndexOf(歌名) - 24) songshortname = s.Substring(s.IndexOf(缩写) + 6, s.IndexOf(歌手) - s.IndexOf(缩写) - 24) songsinger = s.Substring(s.IndexOf(歌手) + 6, s.IndexOf(字数) - s.IndexOf(歌手) - 24) songzishu = s.Substring(s.IndexOf(字数) + 6, s.IndexOf(语种) - s.IndexOf(字数) - 24) songyuzhong = s.Substring(s.IndexOf(语种) + 6, s.IndexOf(歌类) - s.IndexOf(语种) - 24) songgelei = s.Substring(s.IndexOf(歌类) + 6, s.IndexOf(电影) - s.IndexOf(歌类) - 24) songmovie = s.Substring(s.IndexOf(电影) + 6, s.IndexOf(风格) - s.IndexOf(电影) - 24) songstyle = s.Substring(s.IndexOf(风格) + 6, s.IndexOf(音量) - s.IndexOf(风格) - 52) songpop = s.Substring(s.IndexOf(风格) + 32, s.IndexOf(音量) - s.IndexOf(风格) - 50) songyinliang = s.Substring(s.IndexOf(音量) + 6, s.IndexOf(声道) - s.IndexOf(音量) - 24) songshengdao = s.Substring(s.IndexOf(声道) + 6, s.IndexOf(语音) - s.IndexOf(声道) - 24) songfmp = s.Substring(s.IndexOf(FMP声道) + 6, s.IndexOf(语音) - s.IndexOf(FMP声道) - 24) songyuyin = s.Substring(s.IndexOf(语音) + 6, s.IndexOf(介质) - s.IndexOf(语音) - 24) songjiezhi = s.Substring(s.IndexOf(介质) + 6, s.IndexOf(时间) - s.IndexOf(介质) - 24) songtime = s.Substring(s.IndexOf(时间) + 6, s.IndexOf(歌星拼音) - s.IndexOf(时间) - 24) filesname = s.Substring(s.IndexOf(videofilename) + 18, s.IndexOf(audiofilename) - s.IndexOf(videofilename) - 34) sr.Close() x = songpath Try conn = New OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;Password=;User ID=Admin;Data Source= + Application.StartupPath + ktv.mdb) conn.Open() Dim sql = insert into ktv values(0, & songpath & , & songname & , & songshortname & , & songsinger & , & songzishu & , & songyuzhong & , & songgelei & , & songmovie & , & songstyle & , & songyinliang & , & songyuyin & , & songjiezhi & , & songtime & , & filesname & ) Comm = New OleDbCommand(sql, conn) Comm.ExecuteNonQuery() conn.Close() Catch End Try i += 1 End While End SubEnd Class界面如下:5. Form3(点播歌曲)代码Imports System.IOImports System.Data.OleDbImports System.TextImports AxWMPLibImports SystemPublic Class Form3 Dim da As OleDbDataAdapter Dim ds As DataSet Dim Comm As OleDbCommand Dim Comm1 As OleDbCommand Dim conn As OleDbConnection Dim songpath As String Dim songname As String Dim songshortname As String Dim songsinger As String Dim songzishu As String Dim songyuzhong As String Dim songgelei As String Dim songmovie As String Dim songstyle As String Dim songpop As String Dim songyinliang As String Dim songshengdao As String Dim songfmp As String Dim songyuyin As String Dim songjiezhi As String Dim songtime As String Dim songpinyin As String Dim filesname As String Dim x As String Dim ip As Int32 Dim songnamenew As String Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try conn = New OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;Password=;User ID=Admin;Data Source= + Application.StartupPath + ktv.mdb) Dim Comm1 As New OleDbCommand(select * from ktv, conn) da = New OleDbDataAdapter() da.SelectCommand = Comm1 conn.Open() ds = New DataSet() da.Fill(ds, grade) DataGridView1.DataSource = ds.Tables(grade) conn.Close() Dim Comm2 As New OleDbCommand(select 歌名,缩写,歌手from myktv, conn) da = New OleDbDataAdapter() da.SelectCommand = Comm2 conn.Open() ds = New DataSet() da.Fill(ds, grade) DataGridView2.DataSource = ds.Tables(grade) Catch End Try End Sub Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick If e.RowIndex DataGridView1.Rows.Count - 1 Then 将选中行的数据写到文本框中 x = DataGridView1.Rows(e.RowIndex).Cells(0).Value.ToString() songpath = DataGridView1.Rows(e.RowIndex).Cells(1).Value.ToStrin
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年公司普通货物运输合同
- 港口高桩码头课程设计
- 企业人才储备计划协议书
- 定向培育就业协议书范例
- 股权购买协议书
- 员工和公司之间的汽车租赁协议
- 2024年购买二手房定金合同模板
- 工程建设年度借款合同书写作指导
- 幼儿园办园行为评估系统指标体系(复评用)
- 律师代写委托代理合同
- 人教版(PEP)小学六年级英语上册全册教案
- 海淀区高一年级第一学期期末数学试题含答案
- TSG ZF003-2011《爆破片装置安全技术监察规程》
- 大学美育学习通超星期末考试答案章节答案2024年
- 《春秋》导读学习通超星期末考试答案章节答案2024年
- 2022年黑龙江哈尔滨中考满分作文《这也是收获》5
- 2024-2025学年初中英语七年级上册(外研版)上课课件 Unit 5 Fantastic friends 2.Developing ideas
- 2024年纪检监察业务知识考试题库及答案
- 15 1 两种电荷 教学设计 人教版九年级物理全一册
- 2024年保密知识应知应会网络竞赛题库(含答案)
- 2024年人教版七年级上册地理期中测试试卷及答案
评论
0/150
提交评论