?? bank.java
字號:
text1.setText("");
text2.setText("");
mycard.show(p,"1");
}
else if(e.getSource()==button2)
{
try
{
con=DriverManager.getConnection("jdbc:odbc:superman","iceman","1986925");
sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
r=sql.executeQuery("SELECT * FROM user");
if(text3.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(this,"請輸入帳號!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
else
{
boolean b=false;
r.beforeFirst();
while((b=r.next())==true)
{
String s1=r.getString("counts");
long l=r.getLong("deposit");
if(s1.equals(text3.getText().trim()))
{
if(text4.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(this,"請輸入存款金額!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
else if(Float.valueOf(text4.getText().trim()).floatValue()<1.0)
{
JOptionPane.showMessageDialog(this,"存款金額必須大于1!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
else
{
l=l+Long.parseLong(text4.getText().trim());
s1="'"+s1+"'";
sql.executeUpdate("UPDATE user SET deposit = "+l+" WHERE counts="+s1);
JOptionPane.showMessageDialog(this,"交易成功,謝謝使用!","消息",JOptionPane.INFORMATION_MESSAGE);
text3.setText("");
text4.setText("");
con.close();
}
}
}
if(b==false)
{
JOptionPane.showMessageDialog(this,"對不起,帳號不正確!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
}
}
catch(SQLException e3)
{
}
}
else if(e.getSource()==button3)
{
text3.setText(null);
text4.setText(null);
mycard.show(p,"1");
}
else if(e.getSource()==button4)
{
try
{
con=DriverManager.getConnection("jdbc:odbc:superman","iceman","1986925");
sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
r=sql.executeQuery("SELECT * FROM user");
if(text5.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(this,"請輸入帳號!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
else
{
boolean b2=false;
r.beforeFirst();
while((b2=r.next())==true)
{
String s2=r.getString("counts");
if(s2.equals(text5.getText()))
{
text5.setText(null);
mycard.show(p,"8");
text13.setText(r.getString("name"));text13.setEditable(false);
text14.setText(s2);text14.setEditable(false);
text15.setText(r.getString("deposit"));text15.setEditable(false);
text16.setText(r.getString("number"));text16.setEditable(false);
con.close();
}
}
if(b2==false)
{
JOptionPane.showMessageDialog(this,"對不起,帳號不正確!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
}
}
catch(SQLException e4)
{
}
}
else if(e.getSource()==button5)
{
text5.setText(null);
mycard.show(p,"1");
}
else if(e.getSource()==button6)
{
try
{
con=DriverManager.getConnection("jdbc:odbc:superman","iceman","1986925");
sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
r=sql.executeQuery("SELECT * FROM user");
if(text6.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(this,"請輸入帳號!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
else
{
boolean b=false;
r.beforeFirst();
while((b=r.next())==true)
{
String s=r.getString("counts");
if(s.equals(text6.getText().trim()))
{
String s1=r.getString("password");
if(s1.equals(text7.getText().trim()))
{
if(text8.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(this,"請輸入取款金額!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
else if(Float.valueOf(text8.getText().trim()).floatValue()<1.0)
{
JOptionPane.showMessageDialog(this,"取款金額必須大于1!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
else if(r.getLong("deposit")<=Long.parseLong(text8.getText().trim()))
{
JOptionPane.showMessageDialog(this,"對不起,余額不足!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
else
{
long q=r.getLong("deposit")-Long.parseLong(text8.getText().trim());
s="'"+s+"'";
sql.executeUpdate("UPDATE user SET deposit="+q+" WHERE counts="+s);
JOptionPane.showMessageDialog(this,"交易成功,謝謝使用!","消息",JOptionPane.INFORMATION_MESSAGE);
text6.setText(null);
text7.setText(null);
text8.setText(null);
con.close();
}
}
else
{
JOptionPane.showMessageDialog(this,"對不起,密碼不正確!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
}
}
if(b==false)
{
JOptionPane.showMessageDialog(this,"對不起,帳號不正確!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
}
}
catch(SQLException e5)
{
}
}
else if(e.getSource()==button7)
{
text6.setText(null);
text7.setText(null);
text8.setText(null);
mycard.show(p,"1");
}
else if(e.getSource()==button8)
{
try
{
con=DriverManager.getConnection("jdbc:odbc:superman","iceman","1986925");
sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
r=sql.executeQuery("SELECT * FROM user");
if(text9.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(this,"請輸入帳號!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
else
{
boolean b=false;
r.beforeFirst();
while((b=r.next())==true)
{
String s=r.getString("counts");
if(s.equals(text9.getText().trim()))
{
String s1=r.getString("number");
if(text10.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(this,"請輸入身份證號!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
else if(s1.equals(text10.getText().trim()))
{
s="'"+s+"'";
sql.executeUpdate("UPDATE user SET report=0 WHERE counts="+s);
JOptionPane.showMessageDialog(this,"帳號已經(jīng)成功掛失!","消息",JOptionPane.INFORMATION_MESSAGE);
text9.setText(null);
text10.setText(null);
con.close();
}
else
{
JOptionPane.showMessageDialog(this,"身份證不正確!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
}
}
if(b==false)
{
JOptionPane.showMessageDialog(this,"對不起,帳號不正確!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
}
}
catch(SQLException e6)
{
}
}
else if(e.getSource()==button9)
{
try
{
con=DriverManager.getConnection("jdbc:odbc:superman","iceman","1986925");
sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
r=sql.executeQuery("SELECT * FROM user");
if(text9.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(this,"請輸入帳號!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
else
{
boolean b=false;
r.beforeFirst();
while((b=r.next())==true)
{
String s=r.getString("counts");
if(s.equals(text9.getText().trim()))
{
String s1=r.getString("number");
if(text10.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(this,"請輸入身份證號!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
else if(s1.equals(text10.getText().trim()))
{
s="'"+s+"'";
sql.executeUpdate("UPDATE user SET report=1 WHERE counts="+s);
JOptionPane.showMessageDialog(this,"帳號已經(jīng)成功解掛!","消息",JOptionPane.INFORMATION_MESSAGE);
text9.setText(null);
text10.setText(null);
con.close();
}
else
{
JOptionPane.showMessageDialog(this,"身份證不正確!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
}
}
if(b==false)
{
JOptionPane.showMessageDialog(this,"對不起,帳號不正確!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
}
}
catch(SQLException e7)
{
}
else if(e.getSource()==button10)
{
text9.setText(null);
text10.setText(null);
mycard.show(p,"1");
}
else if(e.getSource()==button11)
{
try
{
con=DriverManager.getConnection("jdbc:odbc:superman","iceman","1986925");
sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
r=sql.executeQuery("SELECT * FROM user");
if(text11.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(this,"請輸入帳號!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
else
{
boolean b=false;
r.beforeFirst();
while((b=r.next())==true)
{
String s=r.getString("counts");
if(s.equals(text11.getText().trim()))
{
String s1=r.getString("password");
if(text12.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(this,"請輸入密碼!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
else if(s1.equals(text12.getText().trim()))
{
s="'"+s+"'";
sql.executeUpdate("DELETE FROM user WHERE counts="+s);
JOptionPane.showMessageDialog(this,"此帳號已經(jīng)成功消除!","消息",JOptionPane.INFORMATION_MESSAGE);
text11.setText(null);
text12.setText(null);
con.close();
}
else
{
JOptionPane.showMessageDialog(this,"對不起,密碼不正確!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
}
}
if(b==false)
{
JOptionPane.showMessageDialog(this,"對不起,帳號不正確!","提示",JOptionPane.ERROR_MESSAGE);
con.close();
}
}
}
catch(SQLException e7)
{
}
}
else if(e.getSource()==button12)
{
text11.setText(null);
text12.setText(null);
mycard.show(p,"1");
}
}
}
public class Bank
{
public static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{
System.out.println(""+e);
}
denglu jiemian=new denglu();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -