📄 atm1.java
字号:
add(la6);
}
}
class myaction implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
CardLayout cc=new CardLayout();
contain.setLayout(cc);
contain.add(w1,"1");
contain.add(w2,"2");
contain.add(w3,"3");
contain.add(w4,"4");
contain.add(w5,"5");
contain.add(w6,"6");
contain.add(w7,"7");
contain.add(w8,"8");
contain.add(w9,"9");
contain.add(w10,"10");
contain.add(w11,"11");
contain.add(w12,"12");
contain.add(w13,"13");
contain.add(w14,"14");
contain.add(w15,"15");
contain.add(w16,"16");
contain.add(w17,"17");
contain.add(w18,"18");
contain=getContentPane();
if(e.getSource()==w1.b1)
{
cc.show(contain,"2");
}
else if(e.getSource()==w2.b1)
{
String pachar,oringid,oringpa=new String("");
int q=1,p=0;
char[]pas;
storeID=w2.t1.getText();
pas=w2.w2.getPassword();
pachar=new String(pas);
w2.w2.setText("");
w2.t1.setText("");
q=storeID.compareTo(oringpa);
try
{
oringpa=read();
}
catch(SQLException ee){ cc.show(contain,"10");}
finally
{
p=compe.compareTo(oringpa);
if(pachar.equals(oringpa)&&q!=0&&p!=0)
{
pachar="";
storemoney=changint(storemoneys);
cc.show(contain,"3");
}
else
{
pachar="";
cc.show(contain,"7");
}
}
}
else if(e.getSource()==w3.b1)
{ w5.la2.setText(""+storemoney);
cc.show(contain,"5");
}
else if(e.getSource()==w3.b2)
{ cc.show(contain,"4");}
else if(e.getSource()==w3.b3)
{ cc.show(contain,"15");}
else if(e.getSource()==w3.b4)
{ cc.show(contain,"6");}
else if(e.getSource()==w3.b5)
{
try
{
updatemoney();
cc.show(contain,"1");
}
catch( SQLException eee ){cc.show(contain,"3");}
}
else if(e.getSource()==w3.b6)
{ cc.show(contain,"2");}
else if(e.getSource()==w4.b1)
{
get=100;
cc.show(contain,"4");
}
else if(e.getSource()==w4.b2)
{
get=200;
cc.show(contain,"4");
}
else if(e.getSource()==w4.b3)
{
get=500;
cc.show(contain,"4");
}
else if(e.getSource()==w4.b4)
{ cc.show(contain,"10");}
else if(e.getSource()==w4.b5)
{
if(get>0)
{ if(storemoney-get>=0)
{
storemoney=storemoney-get;
get=0;
cc.show(contain,"11");
}
else
{get=0;cc.show(contain,"8");}
}
else
{get=0;cc.show(contain,"13");}
}
else if(e.getSource()==w4.b6)
{ cc.show(contain,"3");}
else if(e.getSource()==w5.b1)
{ cc.show(contain,"3");}
else if(e.getSource()==w6.b1)
{
int b=1,j=0;
String s1,s2;
s1=new String(w6.w1.getText());
s2=new String(w6.w2.getText());
b=s1.compareTo(compe);
j=w6.w1.getText().length();
j=j%6;
if(s1.equals(s2)&&b!=0&&j==0)
{
try
{
updatepassword();
w6.w1.setText("");
w6.w2.setText("");
cc.show(contain,"9");
}
catch(SQLException ee){w6.w1.setText("");w6.w2.setText("");cc.show(contain,"3");}
}
else
cc.show(contain,"12");
}
else if(e.getSource()==w6.b2)
{ w6.w1.setText("");
w6.w2.setText("");
cc.show(contain,"3");
}
else if(e.getSource()==w7.b1)
{
w2.w2.setText("");
w2.t1.setText("");
cc.show(contain,"2");
}
else if(e.getSource()==w8.b1)
{ cc.show(contain,"3");}
else if(e.getSource()==w9.b1)
{ cc.show(contain,"3");}
else if(e.getSource()==w10.b1)
{
int h=1,u=0;
get=0;
String s=w10.la1.getText();
u=w10.la1.getText().length();
u-=5;
get=changint(s);h=s.compareTo(compe);
w10.la1.setText("");
if(storemoney-get>=0&&h!=0&&u<=0&&get%50==0)
{
storemoney=storemoney-get;
get=0;
cc.show(contain,"11");
}
else if(h==0||u>0)
{
get=0;
cc.show(contain,"14");
}
else if(get%50!=0)
{ get=0;cc.show(contain,"17");}
else
{
get=0;
cc.show(contain,"8");
}
}
else if(e.getSource()==w11.b1)
{ cc.show(contain,"3");}
else if(e.getSource()==w12.b1)
{ w6.w1.setText(""); w6.w2.setText(""); cc.show(contain,"6");}
else if(e.getSource()==w13.b1)
{ cc.show(contain,"4");}
else if(e.getSource()==w14.b1)
{ cc.show(contain,"10");}
else if(e.getSource()==w15.b1)
{
int f=1,m1=0,m2=0,m3=0;
String k=new String("");
m1=k.compareTo(w15.t1.getText());
m2=k.compareTo(w15.t2.getText());
if(m1!=0&&m2!=0)
{
try
{
f=updatechang() ;
}
catch(SQLException eee){}
w15.t1.setText("");
w15.t2.setText("");
if(f==0)cc.show(contain,"18");else cc.show(contain,"16");
}
else
{w15.t1.setText("");w15.t2.setText("");cc.show(contain,"15");}
}
else if(e.getSource()==w15.b2)
{ w15.t1.setText("");w15.t2.setText("");cc.show(contain,"3");}
else if(e.getSource()==w16.b1)
{ cc.show(contain,"15");}
else if(e.getSource()==w17.b1)
{ w10.la1.setText(""); cc.show(contain,"10");}
else if(e.getSource()==w18.b1)
{ cc.show(contain,"3");}
invalidate();
validate();
}
public String read()throws SQLException
{
String result=new String("");
int control=0;
ResultSet rr;
temp();
try
{astate=acone.prepareStatement("select* from oder where 帐号=? ");
astate.setString(1,storeID);
}
catch(SQLException ee){ }
try
{ rr=astate.executeQuery();
if(rr.next())
{storemoneys=rr.getString("余额");
result=rr.getString("密码");
}
acone.close();
}
catch(SQLException e){}
finally
{return result;}
}
public void updatemoney()throws SQLException
{
storemoneys=new String(""+storemoney);
temp();
try
{
astate=acone.prepareStatement(" update oder set 余额=? where 帐号=? ");
astate.setString(1,storemoneys);
astate.setString(2,storeID);
astate.executeUpdate();
acone.close();
}
catch(SQLException e){ }
}
public void updatepassword()throws SQLException
{
temp();
try
{astate=acone.prepareStatement("update oder set 密码=? where 帐号=? ");
astate.setString(1,w6.w1.getText());
astate.setString(2,storeID);
astate.executeUpdate();
acone.close();
}
catch(SQLException ee){}
}
public int updatechang()throws SQLException
{
int a=0,flag=1,j=0,j0=0;
ResultSet rr;
String result=new String(""),update1=new String(""),com=new String("");
temp();
try
{astate=acone.prepareStatement("select* from oder where 帐号=? ");
astate.setString(1,w15.t1.getText());
rr=astate.executeQuery();
if(rr.next())
{result=rr.getString("余额");com=rr.getString("帐号");
get=changint(result)+changint(w15.t2.getText());
update1=new String(""+get);
a=changint(w15.t2.getText());
j=compe.compareTo(com);
j0=compe.compareTo(w15.t2.getText());
get=0;
}
}
catch(SQLException ee){}
if(storemoney-a>=0&&j!=0&&j0!=0)
{ try
{astate=acone.prepareStatement("update oder set 余额=? where 帐号=? ");
astate.setString(1,update1);
astate.setString(2,w15.t1.getText());
astate.executeUpdate();
}
catch(SQLException ee){System.out.println("02"); }
try
{
get=changint(w15.t2.getText());
storemoney-=get;
storemoneys=new String(""+storemoney);
astate=acone.prepareStatement("update oder set 余额=? where 帐号=? ");
astate.setString(1,storemoneys);
astate.setString(2,storeID);
astate.executeUpdate();
get=0;
acone.close();
}
catch(SQLException ee){}
flag=0;
}
return flag;
}
public int changint(String data)
{
int dollor=1,over=0;
over=data.length();
String ss1=new String("");
dollor=data.compareTo(ss1);
if(dollor!=0&&over<10)
{dollor=Integer.parseInt(data);}
return dollor;
}
public void temp()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){ }
try
{
acone=DriverManager.getConnection(url,"","");
}
catch(SQLException e){ }
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -