private void button1_Click(object sender, EventArgs e) { if (comboBox2.Text == "" || comboBox4.Text == "" || comboBox6.Text == "" || comboBox3.Text == "" || comboBox8.Text == "" || comboBox9.Text == "") { MessageBox.Show("请填写完整带“*”的数据", "提示"); return; } //________________________________________________________________________________________________ addacode = comboBox2.Text; addaname = comboBox4.Text.Replace("'", "''"); addtime = comboBox5.Text; addgcode = addacode.Substring(0, 4); addtrack = comboBox6.Text; addscode = addacode + addtrack; addgname = comboBox3.Text.Replace("'", "''"); addorigin = comboBox12.Text; addsname = comboBox8.Text.Replace("'", "''"); addarranger = comboBox9.Text.Replace("'", "''"); addlyric = comboBox7.Text.Replace("'", "''"); addvocal = comboBox11.Text.Replace("'", "''"); addstyle = comboBox10.Text.Replace("'", "''"); using (sqlAdapter sqladp = new sqlAdapter()) { string sql = "select oricode from [ori] where origin = '" + addorigin + "'"; addoricode = sqladp.ExecuteScalar(sql) as string; if (addoricode == null) { MessageBox.Show("没有找到原曲!", "消息提示"); Form9 Form9 = new Form9(); Form9.ShowDialog(); return; } sql = "select acode from [album] where acode = '" + addacode + "'"; object obj = sqladp.ExecuteScalar(sql); if (obj == null) { sql = "insert into [album] values ('" + addacode + "','" + addaname + "','" + addtime + "',@cover)"; sqladp.setCommand(sql); sqladp.Command.Parameters.Add("cover", SqlDbType.Image); sqladp.Command.Parameters["cover"].Value = imagebytes; sqladp.Command.ExecuteNonQuery(); } sql = "select gcode from [group] where gcode = '" + addgcode + "'"; obj = sqladp.ExecuteScalar(sql); //对数据库查询出的值进行判断 if (obj == null) { sql = "insert into [group] values ('" + addgname + "','" + addgcode + "')"; sqladp.ExecuteScalar(sql); } try { sql = "insert into [song] values ('" + addsname + "','" + addtrack + "','" + addarranger + "','" + addlyric + "','" + addvocal + "','" + addoricode + "','" + addstyle + "','" + addscode + "','" + DataPool.currentID + "')"; sqladp.ExecuteScalar(sql); sql = "insert into [gas] values ('" + addgcode + "','" + addacode + "','" + addscode + "')"; sqladp.ExecuteScalar(sql); MessageBox.Show("提交成功!", "提示信息"); } catch (Exception) { MessageBox.Show("错误", "提示信息"); return; } } }
private void 添加原曲ToolStripMenuItem_Click(object sender, EventArgs e) { Form9 Form9 = new Form9(); Form9.ShowDialog(); }
private void button3_Click(object sender, EventArgs e) { string autho; using (sqlAdapter sqladp = new sqlAdapter()) { string sql = "select autho from [user] where username = '******'"; autho = sqladp.ExecuteScalar(sql) as string; } if (autho == "1" || autho == "0") { Form9 Form9 = new Form9(); Form9.ShowDialog(); } else { MessageBox.Show("权限不足", "提示"); return; } }