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

📄 adminframe.java~59~

📁 银行管理系统,根据实习的要求以及参考现实中的银行数据库系统
💻 JAVA~59~
字号:
package bank;

import javax.swing.JFrame;
import javax.swing.JLabel;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.Font;
import java.awt.Color;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Dimension;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Connection;
import javax.swing.JPasswordField;
import java.awt.Toolkit;

//管理员界面类
public class AdminFrame extends JFrame
{
  public AdminFrame() {
    try {
      jbInit();
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
  }

  private void jbInit() throws Exception {
    jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
    jLabel1.setBorder(null);
    jLabel1.setText("管理员号:");
    ///刷新屏幕////
    this.setTitle("登陆系统");
    this.setSize(new Dimension(410,320));
    this.getContentPane().setLayout(xYLayout1);
    jButton2.addActionListener(new AdminFrame_jButton2_actionAdapter(this));
    this.getContentPane().setBackground(new Color(234, 124, 139));
    this.setForeground(SystemColor.control);
    jButton2.setText("重置");
    jButton1.setText("确定");
    jButton1.addActionListener(new AdminFrame_jButton1_actionAdapter(this));
    this.getContentPane().add(jLabel1, new XYConstraints(37, 82, 81, 34));
    jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
    jLabel2.setText("密码:");
    jLabel2.setVisible(true);
    this.getContentPane().add(jLabel2, new XYConstraints(37, 142, 69, 29));
    this.getContentPane().add(jTextField1, new XYConstraints(140, 80, 119, 32));
    this.getContentPane().add(jPasswordField1,
    new XYConstraints(139, 143, 120, 34));
    this.getContentPane().add(jButton1, new XYConstraints(102, 218, 77, 27));
    this.getContentPane().add(jButton2, new XYConstraints(221, 219, 82, 28));

  }

  JLabel jLabel1 = new JLabel();
  XYLayout xYLayout1 = new XYLayout();
  JLabel jLabel2 = new JLabel();
  JTextField jTextField1 = new JTextField();
  JButton jButton1 = new JButton();
  JButton jButton2 = new JButton();
  void login_true()
  {
    login = true;
  }

  void login_false()
  {
   login = false;
  }

  void SetCardID(int ID)
  {
   admin_ID = ID;
  }

  private int admin_ID;
  private boolean login = false;
  private Connection con;
  private InterFrame Frame1;
  private Statement stmt;
  JPasswordField jPasswordField1 = new JPasswordField();

  public void jButton2_actionPerformed(ActionEvent e) {
    jTextField1.setText("");
    jPasswordField1.setText("");
  }

  public void jButton1_actionPerformed(ActionEvent e)
  {
    if(e.getSource()==jButton1)
   {
    try{
             con = bankconnect.getconn();
             if(jTextField1.getText().trim()!= null)
             {
               stmt = con.createStatement();
               String loginQuery ="";
               String passwordtemp ="";
               for(int i=0;i<jPasswordField1.getPassword().length;i++)
               {
                 passwordtemp += jPasswordField1.getPassword()[i];
               }
               loginQuery = "select * from admin where admin_ID = " +
                                         Integer.parseInt(jTextField1.getText().trim()) +
                                           " and admin_pswd = "+passwordtemp;
               ResultSet rs = stmt.executeQuery(loginQuery);
               if (rs.next())
               {
                 rs.close();
                 con.close();
                 this.hide();

                AdminChooseFrame adcf=new AdminChooseFrame();
                Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();//getDefaultToolkit()是获取默认工具包,获取该系统屏幕的大小
                Dimension frameSize = adcf.getSize(); //获取该窗体的大小
                adcf.setState(adcf.MAXIMIZED_BOTH);//设置窗体正常状态,不是最大化
                adcf.setSize(new Dimension(1024,768));
             //  adcf.setLocation( (screenSize.width - frameSize.width) / 2,(screenSize.height - frameSize.height) / 2);//重设置该窗体的位置,放于系统中央
                adcf.show();
                 return;
               }
               else
               {
                // Frame1.login_false();
                 jTextField1.setText("卡号或者密码错误。");
               }
             }
        }
        catch(SQLException ex)
        {
        System.out.println("数据库连接错误!"+ex.toString());
        }
  }
}
}
class AdminFrame_jButton1_actionAdapter
    implements ActionListener {
  private AdminFrame adaptee;
  AdminFrame_jButton1_actionAdapter(AdminFrame adaptee) {
    this.adaptee = adaptee;
  }

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

class AdminFrame_jButton2_actionAdapter
    implements ActionListener {
  private AdminFrame adaptee;
  AdminFrame_jButton2_actionAdapter(AdminFrame adaptee) {
    this.adaptee = adaptee;
  }

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

⌨️ 快捷键说明

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