⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbaccess.java

📁 java实现银行ATM机器业务 直接可以运行 可以实现取款、存款、转账、修改密码等业务 java 银行ATM系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
 JPanel n4=new JPanel();


 JTextField text1=new JTextField(10);   //卡号输入
 JTextField text2=new JTextField(6);    //取款金额
 JTextField text3=new JTextField(10);   //转帐卡号输入
 JTextField text4=new JTextField(6);     //转帐金额输入
 JTextArea te=new JTextArea(3,24);

 JPasswordField pw1=new JPasswordField(6);    //卡密码输入
 JPasswordField pw2=new JPasswordField(6);     //输入新密码
 JPasswordField pw3=new JPasswordField(6);     //确认新密码

                                   

 Container c=this.getContentPane();
 CardLayout cl=new CardLayout();
 GridLayout gl=new GridLayout(5,1);
 int   fetchmoney=0;
 long opNum=1203101;
 int n=2;                               //密码错误次数控制
 public void showCardLayout()        //图形界面
 {    
    te.setLineWrap(true);
       te.setText("尊敬的用户: 欢迎使用ATM自动取款机!请插入您的 IC卡并输入密码! ");
       te.setEditable(false);
    c.setLayout(cl);
    p1.setLayout(gl);
    p2.setLayout(gl);
    p3.setLayout(gl);
    p4.setLayout(gl);
    p5.setLayout(gl);
    p6.setLayout(gl);
    p7.setLayout(gl);
    p8.setLayout(gl);
    p9.setLayout(gl);
    p10.setLayout(gl);
    p11.setLayout(gl);

    p1.add(a1);
    a1.add(t1); 
    p1.add(a2);
    a2.add(z1);
    a2.add(z2);
    p1.add(a3);
    a3.add(te);

    p2.add(b1); 
    b1.add(t2);
    p2.add(b2);
    b2.add(text1); 
    p2.add(b3); 
    b3.add(t3); 
    p2.add(b4);
    b4.add(z3); 
    b4.add(z4); 

    p3.add(c1); 
    c1.add(t4); 
    p3.add(c2); 
    c2.add(pw1);
    p3.add(c3); 
    c3.add(t5);  
    p3.add(c4); 
    c4.add(z5); 
    c4.add(z6); 

    p4.add(d1); 
    d1.add(t6); 
    p4.add(d2);
    d2.add(z7);
    d2.add(z8);
    p4.add(d3);
    d3.add(z9);
    d3.add(z10);
    p4.add(d4);
    d4.add(z11);

    p5.add(y1);
    y1.add(t7);
    p5.add(y2);
    y2.add(z23);
    y2.add(z24);
    p5.add(y3);
    y3.add(z25);
    y3.add(z26); 
    p5.add(y4);
    y4.add(z27);
    y4.add(z30);
    p5.add(y5);
    y5.add(t33);


    p6.add(e1);
    e1.add(t8);
    p6.add(e2);
    e2.add(text2);
    p6.add(e3);
    e3.add(t9);
    p6.add(e4);
    e4.add(z12);
    e4.add(z13);

    p7.add(f1);
    f1.add(t10);
    p7.add(f2);
    f2.add(t11); 
    f2.add(t12);
    p7.add(f3);
    f3.add(z14);
    f3.add(z15);
    f3.add(z16);


    p8.add(g1);
    g1.add(t13);
    g1.add(t14);
    p8.add(g2);
    g2.add(t15);
    g2.add(t16);
    p8.add(g3);
    g3.add(t17);
    g3.add(t18);
    p8.add(g4);
    g4.add(t19);
    g4.add(t20);
    p8.add(g5);
    g5.add(z17);
    g5.add(z18);

    p9.add(h1);
    h1.add(t21);
    h1.add(text3);
    p9.add(h2);
    h2.add(t22);
    h2.add(text4);
    p9.add(h3);
    h3.add(t23);
    p9.add(h4);
    h4.add(z19);
    h4.add(z20);

 

    p10.add(m1);
    m1.add(t24);
    m1.add(t29);
    p10.add(m2);
    m2.add(t25);
    m2.add(t30);
    p10.add(m3);
    m3.add(t31);
    m3.add(t32);
    p10.add(m4);
    m4.add(z21);
    m4.add(z22);


    p11.add(n1);
    n1.add(t26);
    n1.add(pw2);
    p11.add(n2);
    n2.add(t27);
    n2.add(pw3);
    p11.add(n3);
    n3.add(t28);
    p11.add(n4);
    n4.add(z28);
    n4.add(z29);
         
         
         
          c.add(p1,"1");
          c.add(p2,"2");
          c.add(p3,"3");
          c.add(p4,"4");
          c.add(p5,"5");
          c.add(p6,"6");
          c.add(p7,"7");
          c.add(p8,"8");
          c.add(p9,"9");
          c.add(p10,"10");
          c.add(p11,"11");

    z1.addActionListener(this);
    z2.addActionListener(this);
    z3.addActionListener(this);
    z4.addActionListener(this);
    z5.addActionListener(this);
    z6.addActionListener(this);
    z7.addActionListener(this);
    z8.addActionListener(this);
    z9.addActionListener(this);
    z10.addActionListener(this);
    z11.addActionListener(this);
    z12.addActionListener(this);
    z13.addActionListener(this);
    z14.addActionListener(this);
    z15.addActionListener(this);
    z16.addActionListener(this);
    z17.addActionListener(this);
    z18.addActionListener(this);
    z19.addActionListener(this);
    z20.addActionListener(this);
    z21.addActionListener(this);
    z22.addActionListener(this);
    z23.addActionListener(this);
    z24.addActionListener(this);
    z25.addActionListener(this);
    z26.addActionListener(this);
    z27.addActionListener(this);
    z28.addActionListener(this);
    z29.addActionListener(this);
    z30.addActionListener(this);
         int No_50=0,No_100=0;
         String strin="select NO_50,NO_100 from ATM where ATM_ID='123456789'";
         ResultSet rsSQLSelect=executeQuery(strin);
         try{
            if(rsSQLSelect.next())
            {  
             No_50=Integer.parseInt(rsSQLSelect.getString("NO_50"));
             No_100=Integer.parseInt(rsSQLSelect.getString("NO_100"));
             
            }
           }
           catch(Exception er){System.out.println("查询ATM机信息出错!");}
           if(No_50==0&&No_100==0)
           {
            z1.setVisible(false);
            t1.setText("对不起,本ATM自动取款机暂停服务!");
            cl.show(c,"1");
            return;
           }
         
             cl.show(c,"1");
 }

 public void actionPerformed(ActionEvent e)     //界面显示控制
 {    String IC_Number="";
   String password="";
   String  IC_No="";
  z30.setVisible(false);
       float   leftmoney=0;
       float   moneys=0;
       float mon=0;
       float money1=0;
       float money2=0;
       if(true)
       {int No_50=0,No_100=0;
        String strin="select NO_50,NO_100 from ATM where ATM_ID='123456789'";
        ResultSet rsSQLSelect=executeQuery(strin);
        try{
           if(rsSQLSelect.next())
           {  
            No_50=Integer.parseInt(rsSQLSelect.getString("NO_50"));
            No_100=Integer.parseInt(rsSQLSelect.getString("NO_100"));
            
           }
          }
          catch(Exception er){System.out.println("查询ATM机信息出错!");}
          if(No_50==0&&No_100==0)
          {
           z1.setVisible(false);
           t1.setText("对不起,本ATM自动取款机暂停服务!");
           cl.show(c,"1");
          }
       }
      
      cl.show(c,"1");
        
   if(e.getSource()==z1)
     {
      t3.setText("");
      text1.setText("");
         cl.show(c,"2");
      
        }
   if(e.getSource()==z4||e.getSource()==z6||e.getSource()==z11||e.getSource()==z16||e.getSource()==z18||e.getSource()==z22)
      {
        closeDBConnection();
        cl.show(c,"1");
        }
  
  
   if(e.getSource()==z2)
   {
    closeDBConnection();
    System.exit(0);
   }
  
   if(e.getSource()==z3)
      {  IC_Number=text1.getText().trim();
         if(getname(IC_Number))
            {z5.setVisible(true);
            pw1.setVisible(true);
            t4.setVisible(true);
             pw1.setText("");
             t5.setText("");
             cl.show(c,"3");
             }
         else
             {  
              t3.setText("您输入的卡号不存在,请重新输入!");
                 cl.show(c,"2");
                 }
        }
    if(e.getSource()==z5)
      {     password=pw1.getText().trim();
            IC_Number=text1.getText().trim();
            if(!login(IC_Number,password))
              {
                t5.setText("您输入的密码错误,请重新输入!");
                pw1.setText("");
                n--;
                cl.show(c,"3");
                }
            else
              {
                t5.setText("");
                cl.show(c,"4");
               }
          if(n<0)
           {
            n=2;
            t5.setText("您已经三次输入错误密码,谢谢您的使用,欢迎下次光临!");
            z5.setVisible(false);
            pw1.setVisible(false);
            t4.setVisible(false);
            cl.show(c,"3");
           }
     }
    
    if(e.getSource()==z7)
    {
      t33.setText("");
      cl.show(c,"5");
    }
    if(e.getSource()==z8)                          //余额查询
       {  DBAccess d=new DBAccess();
         String str3="";
          String stri="";
         IC_Number=text1.getText().trim();
          t29.setText(IC_Number);
          leftmoney=getmoney(IC_Number);
          t30.setText(Float.toString(leftmoney));
          stri="select bank_name from IC,bank where IC.bank_NO=bank.bank_NO and IC_ID='"+IC_Number+"'";
          ResultSet rsSQLSelect=d.executeQuery(stri);
      try{
         
     if(rsSQLSelect.next())
       {
         str3=rsSQLSelect.getString("bank_name");
      //d.commit();
        }
         }
      catch(Exception er){}
     
          t32.setText(str3);
          cl.show(c,"10");
        }
    if(e.getSource()==z9)
       {
        t23.setText("");
        cl.show(c,"9");
        }
    if(e.getSource()==z10)
     {
       t28.setText("");
       cl.show(c,"11");
       }
    if(e.getSource()==z12)
      {  DBAccess d=new DBAccess();
         IC_Number=text1.getText().trim();
         fetchmoney=Integer.parseInt(text2.getText());
         if(fetchmoney<=0)
         {
          t9.setText("取款金额非法!请重新输入!");
          text2.setText("");
          cl.show(c,"6");
          return;
         }
          if(fetchmoney>1000)
          {
             t9.setText("每次交易金额最大为1000元!");
             text2.setText("");
             cl.show(c,"6");
             return ;
             }
          if(fetchmoney%50!=0)
          {
            t9.setText("取款金额只能为50的倍数!");
            text2.setText("");
            cl.show(c,"6");
            return ;
            }
          leftmoney=getmoney(IC_Number);
          if(fetchmoney>leftmoney)
          {
            t9.setText("您的余额不足,请重新输入取款金额!");
            text2.setText("");
            cl.show(c,"6");
            return ;
            }
           
          int No_50=0,No_100=0,x_50=0,x_100=0,mo=0; 
          String str1="select NO_50,NO_100 from ATM where ATM_ID='123456789'";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -