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

📄 userlogframe.java

📁 银行管理系统,根据实习的要求以及参考现实中的银行数据库系统
💻 JAVA
字号:
package bank;
import javax.swing.*;
import java.awt.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Connection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;

public class UserLogFrame extends JFrame implements ActionListener{

  public UserLogFrame()
  {
    try {
      jbInit();
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
    addWindowListener(new WindowAdapter(){
         public void windowClosing(WindowEvent e){
           System.exit(0);
         }

       }

        );
  }

  private void jbInit() throws Exception {
    jLabel1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
    jLabel1.setText("卡号类型:");
    this.getContentPane().setLayout(xYLayout1);
    jButton2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
    jButton2.setText("重置");
    jButton1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
    jButton1.setText("确定");

    this.getContentPane().setBackground(new Color(230, 200, 200));
    this.setSize(new Dimension(410,320));
    jLabel3.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
    jLabel3.setText("用户密码:");
    jComboBox1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
    this.getContentPane().add(jTextField1, new XYConstraints(121, 105, 184, 32));
    jLabel2.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));
    jLabel2.setText("卡号:");
    jButton1.addActionListener(this);
    jButton2.addActionListener(this);
    this.getContentPane().add(jLabel3, new XYConstraints(33, 162, 81, 29));
    this.getContentPane().add(jLabel2, new XYConstraints(33, 104, 89, 33));
    this.getContentPane().add(jLabel1, new XYConstraints(29, 40, 102, 36));
    this.getContentPane().add(jComboBox1, new XYConstraints(122, 44, 184, 37));
    this.getContentPane().add(jPasswordField1,
                              new XYConstraints(120, 159, 188, 31));
    this.getContentPane().add(jButton1, new XYConstraints(82, 213, 103, 30));

    this.getContentPane().add(jButton2, new XYConstraints(240, 211, 100, 29));

    try{

 con = bankconnect.getconn();
 Statement stmt = con.createStatement();
 ResultSet rs = stmt.executeQuery("select  branch_name from card");
 String a;
   while(rs.next())//一行行的移
  {
    a=rs.getString("branch_name");
    jComboBox1.addItem(a);
  }
    rs.close();
    con.close();
    this.hide();
    return;
}
catch(SQLException ex)
{
System.out.print("数据库连接出错!"+ex.toString());
}


  }

    private Statement stmt;
    private Connection con;
    private String branchname;
    private String accountID;
  JLabel jLabel1 = new JLabel();
  XYLayout xYLayout1 = new XYLayout();
  JLabel jLabel2 = new JLabel();
  JLabel jLabel3 = new JLabel();
  JButton jButton1 = new JButton(new ImageIcon("d.gif"));
  JButton jButton2 = new JButton(new ImageIcon("f.gif"));
  JTextField jTextField1 = new JTextField();
  JComboBox jComboBox1 = new JComboBox();
  JPasswordField jPasswordField1 = new JPasswordField();
  public void actionPerformed(ActionEvent e)
  {
    if(e.getSource()==jButton1)
   {
     try{
         con = bankconnect.getconn();
         if (jTextField1.getText().trim() != null) {
          stmt = con.createStatement();
          String loginQuery = "";
          String passwordtemp="";
          //取JCOMBOBOX的值
           branchname=jComboBox1.getSelectedItem().toString().trim();

         for (int i = 0; i < jPasswordField1.getPassword().length; i++) {
          passwordtemp += jPasswordField1.getPassword()[i];
         }
        loginQuery = "select * from account where account_num = " +
            Integer.parseInt(jTextField1.getText().trim()) +
            " and account_pswd = " + passwordtemp+" and branch_name like "+"'%"+branchname+"%'";
        accountID=jTextField1.getText();
        ResultSet rs = stmt.executeQuery(loginQuery);
        if (rs.next()) {
          rs.close();
          con.close();
          this.hide();
           MoneyDia mondia =new MoneyDia(accountID,branchname,passwordtemp);
          Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); //getDefaultToolkit()是获取默认工具包,获取该系统屏幕的大小
         Dimension frameSize = mondia.getSize(); //获取该窗体的大小

         mondia.setSize(731,463);
        mondia.setLocation( (screenSize.width - frameSize.width) / 2,
                          (screenSize.height - frameSize.height) / 2); //重设置该窗体的位置,放于系统中央
          mondia.show();
          return;
         }
        else {
          // Frame1.login_false();
          jTextField1.setText("卡号或者密码错误。");
        }

      }
    }
    catch(SQLException ex){
     System.out.println("数据库连接失败或者卡号和密码错误!"+ex.toString());

    }

   }
   else
   {
    jTextField1.setText("");
    jPasswordField1.setText("");
   }
  }
}

⌨️ 快捷键说明

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