当前位置:首页 > Oracle课程设计报告(简易点歌台系统)
该部分的主要代码如下(其中注释说明各部分代码的作用):
//删除已点歌曲
private void button_delete_Click(object sender, EventArgs e) {
if (listBox_Playingmusic.SelectedIndex == -1) return;
int num = listBox_Playingmusic.SelectedIndex; //删除播放列表信息
for (int i = num; i < cnt-1; i++) for (int j = 0; j < 6; j++)
singing[i, j] = singing[i + 1, j];
listBox_Playingmusic.Items.Remove(listBox_Playingmusic.SelectedItem); //更新状态栏
if (listBox_Playingmusic.Items.Count > 0) stastr = \正在播放:\ + singing[0, 1]; else {
toolStripStatusLabel1.Text = \; goto mark; }
if (listBox_Playingmusic.Items.Count > 1) stastr += \,下一曲:\ + singing[1, 1]; toolStripStatusLabel1.Text = stastr; mark: statusStrip1.Show();
//如果删除的歌曲是当前正在播放的歌曲,则更新倒计时 if (num == 0) {
if(listBox_Playingmusic.Items.Count == 0) for (int j = 0; j < 6; j++) singing[0, j] =\;
if (listBox_Playingmusic.Items.Count > 0) second = int.Parse(singing[0, 4]); else {
second = 0;
toolStripStatusLabel2.Text = \; } } cnt--;
textBox_count.Text = listBox_Playingmusic.Items.Count.ToString(); }
查看历史记录
点击右下方蓝色小字“查看点歌历史记录”可查看历史点歌记录,包括歌曲ID、歌曲名、点歌时间,按确定可关闭窗口,结果如图:
该部分的主要代码如下:
//查看历史播放记录
private void label9_Click(object sender, EventArgs e) {
Form3 form3=new Form3(); form3.Show(); }
//显示历史播放记录
private void Form3_Load(object sender, EventArgs e) {
string connStr; string queryString;
connStr = \;
queryString = \; OracleConnection conn = new OracleConnection(connStr); OracleCommand orclComd = conn.CreateCommand(); orclComd.CommandText = queryString; conn.Open();
OracleDataAdapter oraDA = new OracleDataAdapter(orclComd); DataSet ds = new DataSet(); oraDA.Fill(ds); conn.Close();
DataTable dtbl = ds.Tables[0]; this.dataGridView1.DataSource = dtbl; conn.Close(); }
//按确定键关闭窗口
private void button1_Click(object sender, EventArgs e) {
this.Close(); }
其余部分
另外还有一些重要的零散代码,如对文本框进行编辑时设置回车键的默认按钮、设置Timer事件等代码如下:
//以下三个函数分别改变按回车键时默认的Button
private void listBox_Selectedmusic_SelectedIndexChanged(object sender, EventArgs e) {
this.AcceptButton = button_play; }
private void listBox_Playingmusic_SelectedIndexChanged(object sender, EventArgs e) {
this.AcceptButton = button_delete; }
private void textBox_song_TextChanged(object sender, EventArgs e) {
this.AcceptButton = button_select; }
//设置每秒发生的事件
private void timer1_Tick(object sender, EventArgs e) {
if (second > 0) {
toolStripStatusLabel2.Text = \剩余时间:\; if (second / 60 > 0)
toolStripStatusLabel2.Text += ((second / 60).ToString() + \分\); if (second % 60 > 0)
toolStripStatusLabel2.Text += ((second % 60).ToString() + \秒\); }
if(listBox_Playingmusic.Items.Count>0) //如果播放列表不为空 if (second == 0) //如果当前播放歌曲结束 {
listBox_Playingmusic.Items.RemoveAt(0); for (int i = 0; i < cnt - 1; i++) for (int j = 0; j < 6; j++)
singing[i, j] = singing[i + 1, j]; //更新状态栏
if (listBox_Playingmusic.Items.Count > 0) {
stastr = \正在播放:\ + singing[0, 1]; second = int.Parse(singing[0, 4]); cnt--; } else {
toolStripStatusLabel1.Text = \; goto mark; }
if (listBox_Playingmusic.Items.Count > 1) stastr += \,下一曲:\ + singing[1, 1]; toolStripStatusLabel1.Text = stastr; mark: statusStrip1.Show();
textBox_count.Text = listBox_Playingmusic.Items.Count.ToString(); toolStripStatusLabel2.Text = \; }
if (second > 0) second--; }
共分享92篇相关文档