Oracle课程设计报告(简易点歌台系统)

发布时间 : 星期一 文章Oracle课程设计报告(简易点歌台系统)更新完毕开始阅读

可从后台Oracle查看是否已添加:

同样可以删除该歌曲,不同的是删除歌曲的时候需要并且仅需要输入ID,若没有输入ID则提示错误:

否则删除相应的歌曲:

可从后台查看ID为1000的歌曲已被删除:

主要代码如下(注释说明了各部分代码的作用):

//添加歌曲

private void button_add_Click(object sender, EventArgs e) {

//若有其中一项未输入,则跳出提示

if (textBox_mid.Text == \ || textBox_mname.Text == \ || textBox_msinger.Text == \ || textBox_mtype.Text == \ || textBox_mlength.Text == \) {

MessageBox.Show(\请输入完整的歌曲信息\, \信息不完整\); return; }

string connstr = \; string judgestr = \;

string insertstr = \ + textBox_mid.Text + \ + textBox_mname.Text + \ + textBox_msinger.Text + \ + textBox_mtype.Text + \ + textBox_mlength.Text + \;

OracleConnection orclConn = new OracleConnection(connstr); OracleCommand oracmd = new OracleCommand(); oracmd.CommandText = judgestr;

oracmd.Connection = orclConn; orclConn.Open();

OracleDataReader ord = oracmd.ExecuteReader(); string[] ans = new string[1000]; int i = 0; bool ok = true;

//ans字符串数组存储已有的歌曲ID while (ord.Read()) {

ans[i++] = ord[0].ToString(); }

//若要添加的歌曲ID有重复,则不添加 for (int k = 0; k < i; k++) {

if (textBox_mid.Text.Equals(ans[k])) {

ok = false; break; } }

//判断是否添加歌曲 if (ok) {

oracmd.CommandText = insertstr; oracmd.ExecuteNonQuery();

MessageBox.Show(\添加歌曲成功\, \添加成功\); } else {

MessageBox.Show(\该歌曲ID已存在\, \已存在\); } }

//删除歌曲

private void button_cut_Click(object sender, EventArgs e) {

//若歌曲ID未输入,跳出提示 if (textBox_mid.Text == \) {

MessageBox.Show(\请输入歌曲ID\, \缺少歌曲ID\); return; }

string connstr = \;

//删除歌曲的SQL语句

string deletestr = \ + textBox_mid.Text + \; OracleConnection orclConn = new OracleConnection(connstr); OracleCommand oracmd = new OracleCommand(); oracmd.CommandText = deletestr; oracmd.Connection = orclConn; orclConn.Open();

oracmd.ExecuteNonQuery();

MessageBox.Show(\该歌曲已删除成功\, \删除成功\); orclConn.Close(); }

? 点歌界面

联系合同范文客服:xxxxx#qq.com(#替换为@)