在好例子网,分享、交流、成长!
您当前所在位置:首页C# 开发实例C#语言基础 → KTV点歌系统源码(亲测可用)

KTV点歌系统源码(亲测可用)

C#语言基础

下载此实例
  • 开发语言:C#
  • 实例大小:30.37M
  • 下载次数:176
  • 浏览次数:4045
  • 发布时间:2018-04-26
  • 实例类别:C#语言基础
  • 发 布 人:mdzzbb
  • 文件格式:.zip
  • 所需积分:2
 相关标签: 系统 KTV

实例介绍

【实例简介】

附加数据库后修改 app.config中的连接串密码即可用,数据库在DB目录下,是 sql server 2012 , ide建议用vs2017

实现了添加歌手/歌曲,点播功能,具体如下图:



【实例截图】

from clipboard


from clipboard


后台管理界面相关:


from clipboard


from clipboard


from clipboard


from clipboard


需要启用 Windows Media Player 功能,否则会提示【System.Runtime.InteropServices.COMException:“没有注册类】

操作步骤:控制面板>>程序>>启用或者关闭windows 功能>>选中 媒体功能>>Windows Media Player,点击确定即可

from clipboard


【核心代码】


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace KTV
{
    public partial class FrmBoFang : Form
    {
        public FrmBoFang()
        {
            InitializeComponent();
        }

        private bool tag = false;
        public static DataSet ds = new DataSet();
        private void FrmBoFang_Load(object sender, EventArgs e)
        {
            listBox1.DisplayMember = "歌曲名称";
            listBox1.ValueMember = "存放位置";
            ds.Tables.Add();
            ds.Tables[0].Columns.Add("存放位置");
            ds.Tables[0].Columns.Add("歌曲名称");
            listBox1.DataSource = ds.Tables[0];   
            
        }

        public int i = 0;
        private int YouXianID = -1;
        private void button9_Click(object sender, EventArgs e)
        {
            tag = false;
            if (listBox1.Items.Count < 1)
            {
                MessageBox.Show("请选择您要播放的歌曲!", "温馨提示", MessageBoxButtons.OK,
                     MessageBoxIcon.Asterisk);
                return;
            }
            if (listBox1.SelectedValue.ToString() != "")
            {
                axWindowsMediaPlayer1.URL = listBox1.SelectedValue.ToString();
                i = listBox1.SelectedIndex;
                
            }
            else
            {
                MessageBox.Show("请选择您要播放的歌曲!", "温馨提示", MessageBoxButtons.OK,
                     MessageBoxIcon.Asterisk);
            }
        }

        private void btnBoFang_Click(object sender, EventArgs e)
        {
            if (listBox1.Items.Count < 1)
            {
                MessageBox.Show("请选择您要播放的歌曲!", "温馨提示", MessageBoxButtons.OK,
                     MessageBoxIcon.Asterisk);
                return;
            }
            axWindowsMediaPlayer1.Ctlcontrols.play();
            tag = false;
        }

        private void btnZanTing_Click(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.Ctlcontrols.pause();
        }

        private void btnTingZhi_Click(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.Ctlcontrols.stop();
            tag = true;
        }

        private void btnUp_Click(object sender, EventArgs e)
        {
            if (listBox1.Items.Count < 1)
            {
                MessageBox.Show("请选择您要播放的歌曲!", "温馨提示", MessageBoxButtons.OK,
                    MessageBoxIcon.Asterisk);
                return;
            }
            axWindowsMediaPlayer1.Ctlcontrols.previous();
            listBox1.ClearSelected();
            if (i == 0)
            {
                i = listBox1.Items.Count - 1;
            }
            else
            {
                i=i-1;
            }
            listBox1.SetSelected(i, true);
            axWindowsMediaPlayer1.URL = ds.Tables[0].Rows[i]["存放位置"].ToString();
        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            if (listBox1.Items.Count < 1)
            {
                MessageBox.Show("请选择您要播放的歌曲!", "温馨提示", MessageBoxButtons.OK,
                    MessageBoxIcon.Asterisk);
                return;
            }
            axWindowsMediaPlayer1.Ctlcontrols.next();
            listBox1.ClearSelected();
            if (i == listBox1.Items.Count - 1)
            {
                i = 0;
            }
            else
            {
                i = i   1;
            }
            listBox1.SetSelected(i, true);
            axWindowsMediaPlayer1.URL = ds.Tables[0].Rows[i]["存放位置"].ToString();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            ds.Tables[0].Rows.RemoveAt(listBox1.SelectedIndex);
        }

        private void button10_Click(object sender, EventArgs e)
        {
            ds.Tables[0].Rows.InsertAt(ds.Tables[0].Rows[0],listBox1.SelectedIndex - 1);
            
            ds.Tables[0].Rows.RemoveAt(listBox1.SelectedIndex 1);
        }

        private void button7_Click(object sender, EventArgs e)
        {
            FrmXuanZe FrmXuanZe1 = new FrmXuanZe();
            FrmXuanZe1.Show();
        }

        private void FrmBoFang_Shown(object sender, EventArgs e)
        {
            FrmXuanZe FrmXuanZe1 = new FrmXuanZe();
            FrmXuanZe1.Show();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsStopped && tag==false)
            {
                if (YouXianID == -1)
                {
                    listBox1.ClearSelected();
                    if (comboBox1.Text.Trim() == "顺序播放")
                    {
                        if (i <= listBox1.Items.Count - 1)
                        {
                            i = -1;
                        }
                        i = i   1;
                    }
                    else if (comboBox1.Text.Trim() == "倒叙播放")
                    {
                        if (i <=  0)
                        {
                            i = listBox1.Items.Count;
                        }
                        i = i - 1;
                    }
                    else if (comboBox1.Text.Trim() == "随机播放")
                    {
                        System.Random r = new Random();
                        i=r.Next(listBox1.Items.Count);
                    }

                    listBox1.SetSelected(i, true);

                    axWindowsMediaPlayer1.URL = ds.Tables[0].Rows[i]["存放位置"].ToString();
                }
                else
                {
                    axWindowsMediaPlayer1.URL = ds.Tables[0].Rows[YouXianID]["存放位置"].ToString();
                }
            }

        }

        private void btnQuanPing_Click(object sender, EventArgs e)
        {
            if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPlaying)
            {
                axWindowsMediaPlayer1.fullScreen = true;
            }
            else
            {
                MessageBox.Show("请先播放,再点全屏!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }

        private void btnYouXianBoFang_Click(object sender, EventArgs e)
        {
            YouXianID = listBox1.SelectedIndex;
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("需要硬件设备支持!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("这里退出将关闭KTV点歌系统,您真的要退出吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }
            Application.Exit();
        }

        private void FrmBoFang_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MessageBox.Show("这里退出将关闭KTV点歌系统,您真的要退出吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }
            Application.Exit();
        }
    }
}


标签: 系统 KTV

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警