📄 userlogin.java~116~
字号:
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
*/
class userlogin extends JFrame{
String strSql="";
String database_username="";
String database_password="";
int p;
public static String s;
public static String ss;
JPanel jPanel1 = new JPanel();
JLabel jLabel1 = new JLabel();
XYLayout xYLayout2 = new XYLayout();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JTextField jTextField1 = new JTextField();
JPasswordField jPasswordField1 = new JPasswordField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
public userlogin() {
super();
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
jPanel1.setBackground(new Color(49, 106, 183));
jPanel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 25));
jPanel1.setLayout(xYLayout2);
jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
jLabel1.setForeground(Color.white);
jLabel1.setText("卡号:");
jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
jLabel2.setForeground(Color.white);
jLabel2.setText("密码:");
jLabel3.setBackground(Color.black);
jLabel3.setFont(new java.awt.Font("宋体", Font.PLAIN, 30));
jLabel3.setForeground(Color.white);
jLabel3.setText("中国银行欢迎您!");
jButton1.setText("确定");
jButton1.addActionListener(new userlogin_jButton1_actionAdapter(this));
jButton2.setText("取消");
jButton2.addActionListener(new userlogin_jButton2_actionAdapter(this));
jPanel1.add(jTextField1, new XYConstraints(128, 219, 205, -1));
jPanel1.add(jPasswordField1, new XYConstraints(128, 280, 204, -1));
jPanel1.add(jLabel2, new XYConstraints(61, 280, -1, -1));
jPanel1.add(jLabel1, new XYConstraints(64, 215, -1, -1));
jPanel1.add(jButton1, new XYConstraints(117, 380, -1, -1));
jPanel1.add(jButton2, new XYConstraints(233, 380, -1, -1));
jPanel1.add(jLabel3, new XYConstraints(82, 49, -1, -1));
this.getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
setSize(450,550);
setVisible(true);
}
public void jButton1_actionPerformed(ActionEvent e) {
s = jTextField1.getText().trim();
ss = jPasswordField1.getText().trim();
//System.out.println(s);
// System.out.println(ss);
ResultSet rs = null;
String url = "jdbc:odbc:atm";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection dbConn = DriverManager.getConnection(url,database_username, database_password);
Statement stmt = dbConn.createStatement();
strSql = "select * from cardinfo where cardid='"+s+"' and password= '"+ss+"' ";
rs= stmt.executeQuery(strSql);
if(rs.next()){
p=rs.getInt(5);
if(p==2){
setVisible(false);
Manager manager=new Manager();
}
else{
setVisible(false);
Function function = new Function();
}
}
else{
// System.out.println("卡号或密码错误!");
JOptionPane.showMessageDialog(this,"卡号或密码错误!");
}
rs.close();
stmt.close();
dbConn.close();
}catch(Exception ee){
System.out.println(ee.getMessage());
}
}
class userlogin_jButton1_actionAdapter implements ActionListener {
private userlogin adaptee;
userlogin_jButton1_actionAdapter(userlogin adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
public static void main(String[] args) {
userlogin userlogin = new userlogin();
}
public void jButton2_actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(this,"交易结束,感谢您的使用!");
}
}
class userlogin_jButton2_actionAdapter implements ActionListener {
private userlogin adaptee;
userlogin_jButton2_actionAdapter(userlogin adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -