📄 update.java~78~
字号:
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "操作不正确");
}
}
public void jButton2_actionPerformed(ActionEvent e) {
try {
Connection con;
Statement stmt;
ResultSet rs1;
String a = jTextField1.getText();
int b = Integer.parseInt(a);
if (a.equals("")) {
JOptionPane.showMessageDialog(null, "沒有輸入用戶ID!", "輸入錯誤",
JOptionPane.ERROR_MESSAGE);
} else {
try {
Class.forName(
"com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://localhost:1433;databaseName=ATM",
"sa", "huang100");
Statement Stat = conn.createStatement();
rs1 = Stat.executeQuery(
"select * from userTable where userid='" + b + "'");
if (rs1.next()) {
Stat.executeUpdate("delete userTable where userid='" +
a + "'");
} else {
JOptionPane.showMessageDialog(null, "没有" + a + " 用户");
}
} catch (Exception ex) {
System.out.println("数据库连接失败");
}
}
} catch (Exception ex) {
}
}
public void jButton5_actionPerformed(ActionEvent e) {
jTextField2.setText("");
jTextField3.setText("");
jTextField4.setText("");
jTextField5.setText("");
jTextField11.setText("");
jTextField1.setText("");
}
public void jButton3_actionPerformed(ActionEvent e) {
Connection con;
Statement stmt;
ResultSet rs1,rs2;
String r1 = jTextField6.getText();
String w2 = jTextField7.getText();
String w3 = jTextField8.getText();
String w4 = jTextField9.getText();
String w5 = jTextField10.getText();
char w6[] = jPasswordField1.getPassword();
char w7[] = jPasswordField2.getPassword();
String r2 = new String(w6);
String w9 = new String(w7);
String q1 = (String) jComboBox1.getSelectedItem();
String q2 = (String) jComboBox2.getSelectedItem();
if (r1.equals("")) {
JOptionPane.showMessageDialog(null, "用户ID不能为空");
} else if (w2.equals("")) {
JOptionPane.showMessageDialog(null, "姓名不能为空");
} else if (w3.equals("")) {
JOptionPane.showMessageDialog(null, "住址不能为空");
} else if (q1.equals("请选择联系方式")) {
JOptionPane.showMessageDialog(null, "没有选择联系方式");
} else if (w4.equals("")) {
JOptionPane.showMessageDialog(null, "联系方式不能为空");
} else if (q2.equals("请选择证件")) {
JOptionPane.showMessageDialog(null, "没有选择证件种类");
} else if (w5.equals("")) {
JOptionPane.showMessageDialog(null, "没有输入证件号");
} else if (r2.equals("")) {
JOptionPane.showMessageDialog(null, "没有输入密码");
} else if (w9.equals("")) {
JOptionPane.showMessageDialog(null, "没有输入确认密码");
} else if (!r2.equals(w9)) {
JOptionPane.showMessageDialog(null, "两次输入的密码不相同");
jPasswordField1.setText("");
jPasswordField2.setText("");
} else {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://localhost:1433;databaseName=ATM",
"sa", "huang100");
Statement Stat = conn.createStatement();
rs1 = Stat.executeQuery(
"select userid from userTable where userid='" +
r1 + "'");
// rs2=Stat.executeQuery(
// "select userid from userTable where userpassword='" +
//r2 + "'");
if (rs1.next()) {
JOptionPane.showMessageDialog(null, "用户已经存在");
}//else if(rs2.next()){
//JOptionPane.showMessageDialog(null, "用户密碼已经存在"); }
else {
Stat.executeUpdate("insert into userTable values('" + r1 +
"','" +
r2+ "','" + w2 + "','" + 0 + "','"
+ w3 + "','" + w5 + "','" + w4 + "')");
JOptionPane.showMessageDialog(null, "用戶成功添加");
jTextField6.setText("");
jTextField7.setText("");
jTextField8.setText("");
jTextField9.setText("");
jTextField10.setText("");
jPasswordField1.setText("");
jPasswordField2.setText("");
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "數據庫聯繫失敗");
}
}
}
public void jButton4_actionPerformed(ActionEvent actionEvent) {
jTextField6.setText("");
jTextField7.setText("");
jTextField8.setText("");
jTextField9.setText("");
jTextField10.setText("");
jPasswordField1.setText("");
jPasswordField2.setText("");
}
public void jButton6_actionPerformed(ActionEvent actionEvent) {
this.dispose();
DengLu d = new DengLu();
d.setTitle("登录界面");
d.setBounds(200,200,400,400);
d.setVisible(true);
}
}
class Update_jButton6_actionAdapter implements ActionListener {
private Update adaptee;
Update_jButton6_actionAdapter(Update adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.jButton6_actionPerformed(actionEvent);
}
}
class Update_jButton4_actionAdapter implements ActionListener {
private Update adaptee;
Update_jButton4_actionAdapter(Update adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent) {
adaptee.jButton4_actionPerformed(actionEvent);
}
}
class Update_jButton3_actionAdapter implements ActionListener {
private Update adaptee;
Update_jButton3_actionAdapter(Update adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton3_actionPerformed(e);
}
}
class Update_jButton5_actionAdapter implements ActionListener {
private Update adaptee;
Update_jButton5_actionAdapter(Update adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton5_actionPerformed(e);
}
}
class Update_jButton2_actionAdapter implements ActionListener {
private Update adaptee;
Update_jButton2_actionAdapter(Update adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class Update_this_windowAdapter extends WindowAdapter {
private Update adaptee;
Update_this_windowAdapter(Update adaptee) {
this.adaptee = adaptee;
}
public void windowClosing(WindowEvent e) {
adaptee.this_windowClosing(e);
}
}
class Update_jButton1_actionAdapter implements ActionListener {
private Update adaptee;
Update_jButton1_actionAdapter(Update adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -