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

📄 keep.java~19~

📁 ATM机具有存款、取款、查询结余、打印凭条、修改密码功能。
💻 JAVA~19~
字号:
package atm;
import javax.swing.*;
import java.awt.*;
import com.borland.jbcl.layout.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Font;
import java.awt.BorderLayout;
import java.sql.*;
/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2008</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class Keep extends JFrame{
    String strSql1="";
  String database_username="";
  String database_password="";
    int ab;
    int bb;
    String yy;



    public Keep() {
        super();
        try {
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Keep keep = new Keep();
    }

    private void jbInit() throws Exception {
        jPanel1.setLayout(xYLayout1);
        jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
        jLabel2.setForeground(Color.white);
        jLabel2.setText("请输入所要存入的钱数:");
        jPanel1.setBackground(new Color(49, 106, 183));
        jTextField1.addActionListener(new Keep_jTextField1_actionAdapter(this));
        jButton1.setText("确定");
        jButton1.addActionListener(new Keep_jButton1_actionAdapter(this));
        jButton2.setText("取消");
        jButton2.addActionListener(new Keep_jButton2_actionAdapter(this));
        jPanel1.add(jLabel2, new XYConstraints(85, 133, -1, -1));
        jPanel1.add(jTextField1, new XYConstraints(102, 197, 164, 26));
        jPanel1.add(jButton2, new XYConstraints(235, 326, -1, -1));
        jPanel1.add(jButton1, new XYConstraints(86, 326, -1, -1));
        this.getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
        setSize(450,550);
        setVisible(true);


    }

    JPanel jPanel1 = new JPanel();
    XYLayout xYLayout1 = new XYLayout();
    JLabel jLabel2 = new JLabel();
    JTextField jTextField1 = new JTextField();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();

    public void jTextField1_actionPerformed(ActionEvent e) {

    }

    public void jButton1_actionPerformed(ActionEvent e) {
               ResultSet rs = null;
              String url = "jdbc:odbc:atm";
               Tbalance tt=new Tbalance();
               String er=(new java.util.Date()).toLocaleString();
              try {
              String s = jTextField1.getText();
              if(s.equals("")){
         //System.out.println("卡号或密码错误!");
         JOptionPane.showMessageDialog(this,"输入为空,请重新输入!");
   }

              userlogin u=new userlogin();
              yy=u.s;

              int s1=Integer.parseInt(s);
              bb=tt.aa;
              ab=bb+s1;
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Connection dbConn = DriverManager.getConnection(url,database_username, database_password);
              Statement stmt = dbConn.createStatement();
              strSql1 = "insert into transinfo(transdate,cardid,transtype,transmoney)"+"values('"+er+"','"+yy+"','存款','"+s+"')";



                if(s1%100!=0){
              JOptionPane.showMessageDialog(this,"本机只可存入100元的整数倍!");
              jTextField1.setText("") ;
         }
                else{

                JOptionPane.showMessageDialog(this,"存款成功,交易金额为'"+s+"'元");
                int ee= stmt.executeUpdate(strSql1);
                jTextField1.setText("") ;
                balance2();
            }

            }catch(Exception ee){
                 System.out.println(ee.getMessage());
             }


          }
          public void balance2(){
           try{

            String url = "jdbc:odbc:atm";
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
             ResultSet rs = null;
             Connection dbConn = DriverManager.getConnection(url,database_username, database_password);
            Statement stmt = dbConn.createStatement();
            strSql1="update cardinfo set balance='"+ab+"' where cardid='"+yy+"'";
           int ee= stmt.executeUpdate(strSql1);
           if(ee!=0){
             System.out.println("存款更新成功!!");
         }
         rs.close();
        stmt.close();
        dbConn.close();

        }catch(Exception ex){
            ex.getMessage();
        }
}


    public void jButton2_actionPerformed(ActionEvent e) {

           Function f=new Function();
    }
}


class Keep_jButton2_actionAdapter implements ActionListener {
    private Keep adaptee;
    Keep_jButton2_actionAdapter(Keep adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton2_actionPerformed(e);
    }
}


class Keep_jButton1_actionAdapter implements ActionListener {
    private Keep adaptee;
    Keep_jButton1_actionAdapter(Keep adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }
}


class Keep_jTextField1_actionAdapter implements ActionListener {
    private Keep adaptee;
    Keep_jTextField1_actionAdapter(Keep adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jTextField1_actionPerformed(e);
    }
}

⌨️ 快捷键说明

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