//添加操作
public void btnInsert_actionPerformed(ActionEvent e) {
String name = this.txtName.getText().trim();
String sex = this.txtSex.getText().trim();
String grade = this.txtGrade.getText().trim();
String score = this.txtScore.getText().trim();
if (name.equals("") || sex.equals("") || grade.equals("") ||
score.equals("")) {
JOptionPane.showMessageDialog(this, "您输入的不合法!");
}
String sqlString = "insert into Score values('" + name + "','" + sex +
"','" + grade + "','" + score + "')";
int rows = db.exeUpdate(sqlString);
if (rows == 0) {
JOptionPane.showMessageDialog(this, "添加失败!");
} else {
JOptionPane.showMessageDialog(this, " 添加成功! ");
}
}
//删除操作
public void btnDelect_actionPerformed(ActionEvent e) {
String name = this.txtName.getText().trim();
if (name.equals("")) {
JOptionPane.showMessageDialog(this, "你输入的数据不完整");
return;
}
String sqlString = "delete from Score where Name='" + name + "'";
int rows = db.exeUpdate(sqlString);
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余2页未读,立即下载