?? kingframe1.java
字號:
ss = con.createStatement();
strsql = "delete from kk where id = '" +
shanchuname +
"'";
gengai();
ss.close();
JOptionPane.showMessageDialog(JF, "刪除用戶成功", "消息",
JOptionPane.CANCEL_OPTION);
jTextField5.setText("");
jTextField4.setText("");
jPasswordField3.setText("");
} catch (SQLException ex) {
ex.printStackTrace();
}
} else {
JOptionPane.showMessageDialog(JF, "您刪除的帳號不存在", "錯誤",
JOptionPane.ERROR_MESSAGE);
jTextField5.setText("");
jTextField4.setText("");
jPasswordField3.setText("");
result.close();
ss.close();
}
} catch (SQLException ex) {
ex.printStackTrace();
}
}
} else {
JOptionPane.showMessageDialog(JF, "您不是超級管理員,不具有本權限", "錯誤",
JOptionPane.ERROR_MESSAGE);
jTextField5.setText("");
jTextField4.setText("");
jPasswordField3.setText("");
}
}
//記事本功能(完成)
public void jMenuItem11_actionPerformed(ActionEvent e) {
if (kingFrame1obj) {
JNotepad applet = JNotepad.newJNotepad();
applet.setSize(800, 500);
applet.setLocation(200, 200);
applet.setVisible(true);
applet.pack();
} else {
mm();
}
}
//添加學生信息(完成)
public void jMenuItem12_actionPerformed(ActionEvent e) {
if (kingFrame1obj) {
cardLayout1.show(contentPane, "jPanel8");
} else {
mm();
}
}
//添加學生信息中的退出(完成)
public void jButton16_actionPerformed(ActionEvent e) {
cardLayout1.show(contentPane, "jPanel2");
}
//添加學生信息中的重置(完成)
public void jButton17_actionPerformed(ActionEvent e) {
jTextField6.setText("");
jTextField7.setText("");
jTextField8.setText("");
jTextField9.setText("");
jTextField10.setText("");
jTextField11.setText("");
}
//添加中的確定按鈕(完成)
public void jButton15_actionPerformed(ActionEvent e) {
String name = jTextField6.getText();
String banji = jTextField7.getText();
if (name.equals("") || banji.equals("") ||
jTextField8.getText().equals("") ||
jTextField9.getText().equals("") ||
jTextField10.getText().equals("") ||
jTextField11.getText().equals("")) {
JOptionPane.showMessageDialog(JF, "您輸入的信息不齊全,如果沒有成績用0分代替", "消息",
JOptionPane.ERROR_MESSAGE);
} else {
float c = Float.parseFloat(jTextField8.getText());
float html = Float.parseFloat(jTextField9.getText());
float sql = Float.parseFloat(jTextField10.getText());
float java = Float.parseFloat(jTextField11.getText());
//判斷分數是否在0-100之間
if (c > 100 || c < 0) {
JOptionPane.showMessageDialog(JF, "您輸入的C語言成績錯誤", "消息",
JOptionPane.ERROR_MESSAGE);
jTextField8.setText("");
} else if (html > 100 || html < 0) {
JOptionPane.showMessageDialog(JF, "您輸入的html語言成績錯誤", "消息",
JOptionPane.ERROR_MESSAGE);
jTextField9.setText("");
} else if (sql > 100 || sql < 0) {
JOptionPane.showMessageDialog(JF, "您輸入的sql語言成績錯誤", "消息",
JOptionPane.ERROR_MESSAGE);
jTextField10.setText("");
} else if (java > 100 || java < 0) {
JOptionPane.showMessageDialog(JF, "您輸入的java語言成績錯誤", "消息",
JOptionPane.ERROR_MESSAGE);
jTextField11.setText("");
} else {
//查詢用戶是否已經存在
try {
ss = con.createStatement();
} catch (SQLException ex1) {
ex1.printStackTrace();
}
strsql = "select * from xuesheng where name =" +
"'" + name + "'";
select();
try {
if (result.next()) {
JOptionPane.showMessageDialog(JF, "您輸入的帳號已經存在", "錯誤",
JOptionPane.ERROR_MESSAGE);
jTextField3.setText("");
jPasswordField2.setText("");
result.close();
ss.close();
} else {
result.close();
ss.close();
ss = con.createStatement();
strsql = "insert into xuesheng values ('" + name +
"','" +
banji + "'," + c + "," + html + "," + sql +
"," +
java + ")";
gengai();
ss.close();
JOptionPane.showMessageDialog(JF, "添加成功", "消息",
JOptionPane.CANCEL_OPTION);
jTextField6.setText("");
jTextField7.setText("");
jTextField8.setText("");
jTextField9.setText("");
jTextField10.setText("");
jTextField11.setText("");
}
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
}
//修改密碼面板!(完成)
public void jMenuItem13_actionPerformed(ActionEvent e) {
cardLayout1.show(contentPane, "jPanel9");
}
//修改密碼中的取消(完成)
public void jButton19_actionPerformed(ActionEvent e) {
cardLayout1.show(contentPane, "jPanel2");
}
//修改密碼中的重置(完成)
public void jButton18_actionPerformed(ActionEvent e) {
jTextField12.setText("");
jPasswordField4.setText("");
jPasswordField5.setText("");
jPasswordField6.setText("");
}
//修改密碼中的確定(完成)
public void jButton20_actionPerformed(ActionEvent e) {
String strzh = jTextField12.getText();
String mima1 = jPasswordField4.getText();
String xinmima1 = jPasswordField5.getText();
String xinmima2 = jPasswordField6.getText();
if (strzh.equals("")) {
JOptionPane.showMessageDialog(JF, "帳號不能為空", "消息",
JOptionPane.ERROR_MESSAGE);
jTextField12.setText("");
} else if (mima1.equals("")) {
JOptionPane.showMessageDialog(JF, "原始密碼不能為空", "消息",
JOptionPane.ERROR_MESSAGE);
jPasswordField4.setText("");
} else if (xinmima1.equals("")) {
JOptionPane.showMessageDialog(JF, "新密碼不能為空", "消息",
JOptionPane.ERROR_MESSAGE);
jPasswordField5.setText("");
} else if (xinmima2.equals("")) {
JOptionPane.showMessageDialog(JF, "確認密碼不能為空", "消息",
JOptionPane.ERROR_MESSAGE);
jPasswordField6.setText("");
} else if (strzh.equals("eagle520")) {
JOptionPane.showMessageDialog(JF, "超級管理員密碼不可修改", "消息",
JOptionPane.ERROR_MESSAGE);
} else if (xinmima1.equals(xinmima2)) {
//查詢數據庫
try {
ss = con.createStatement();
strsql = "select * from kk where id =" +
"'" + strzh + "'";
select();
if (result.next()) {
if (mima1.equals(result.getObject(2))) {
result.close();
ss.close();
ss = con.createStatement();
strsql = "update kk set password = '" + xinmima1 +
"' where id = '" + strzh + "'";
gengai();
ss.close();
JOptionPane.showMessageDialog(JF, "修改成功",
"消息",
JOptionPane.CLOSED_OPTION);
jTextField12.setText("");
jPasswordField4.setText("");
jPasswordField5.setText("");
jPasswordField6.setText("");
} else {
JOptionPane.showMessageDialog(JF, "您輸入的密碼錯誤",
"錯誤",
JOptionPane.ERROR_MESSAGE);
jPasswordField4.setText("");
result.close();
ss.close();
}
} else {
JOptionPane.showMessageDialog(JF, "您輸入的帳號不存在", "錯誤",
JOptionPane.ERROR_MESSAGE);
jTextField1.setText("");
jPasswordField1.setText("");
result.close();
ss.close();
}
} catch (SQLException ex) {
ex.printStackTrace();
}
} else {
JOptionPane.showMessageDialog(JF, "您輸入的兩次密碼不相同", "消息",
JOptionPane.ERROR_MESSAGE);
jPasswordField5.setText("");
jPasswordField6.setText("");
}
}
}
class kingFrame1_jButton20_actionAdapter implements ActionListener {
private kingFrame1 adaptee;
kingFrame1_jButton20_actionAdapter(kingFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton20_actionPerformed(e);
}
}
class kingFrame1_jButton18_actionAdapter implements ActionListener {
private kingFrame1 adaptee;
kingFrame1_jButton18_actionAdapter(kingFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton18_actionPerformed(e);
}
}
class kingFrame1_jButton19_actionAdapter implements ActionListener {
private kingFrame1 adaptee;
kingFrame1_jButton19_actionAdapter(kingFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton19_actionPerformed(e);
}
}
class kingFrame1_jMenuItem13_actionAdapter implements ActionListener {
private kingFrame1 adaptee;
kingFrame1_jMenuItem13_actionAdapter(kingFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuItem13_actionPerformed(e);
}
}
class kingFrame1_jMenuItem3_actionAdapter implements ActionListener {
private kingFrame1 adaptee;
kingFrame1_jMenuItem3_actionAdapter(kingFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuItem3_actionPerformed(e);
}
}
class kingFrame1_jButton15_actionAdapter implements ActionListener {
private kingFrame1 adaptee;
kingFrame1_jButton15_actionAdapter(kingFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton15_actionPerformed(e);
}
}
class kingFrame1_jButton17_actionAdapter implements ActionListener {
private kingFrame1 adaptee;
kingFrame1_jButton17_actionAdapter(kingFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton17_actionPerformed(e);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -