本文共 3399 字,大约阅读时间需要 11 分钟。
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
package 界面类;
import javax.jws.soap.SOAPBinding.Use;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.event.AncestorListener;
import 数据库具体查询.clientresult1;
import 数据库具体查询.clientresult2;
import 数据库具体查询.credi_result;
import 数据库具体查询.userresult;
import 数据库类.getconnect;
import 数据库类.result;
import 界面类.mainframe;
import 管理员具体功能实现.showleavemessage;
import 管理员具体功能实现.telluser;
import 读者信息管理.newuser;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.*;
import java.io.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class client extends JFrame implements ActionListener{
JLabel jl1;
JLabel jl2;
JLabel jl3;
JLabel jl4;
JButton **1;
JButton **2;
public static String b6;
JTextField jtf;
JPasswordField jpf;
JPanel jp1;
JPanel jp2;
ResultSet rs=null;
Connection con = null;
Statement sm = null;
public static void main(String[] args) throws ClassNotFoundException, SQLException {
client c= new client();
}
// TODO 自动生成的方法存根
public client () throws ClassNotFoundException, SQLException{
String UserName = "sa";
String Password = "sa";
String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String Url = "jdbc:sqlserver://127.0.0.1;database=book3";
try {
Class.forName(driverName);
System.out.println("数据库驱动加载成功");
con=DriverManager.getConnection(Url,UserName,Password);
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
try {
if(!con.isClosed()){
System.out.println("数据库连接成功");
}
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
Statement sm= con.createStatement();
rs = sm.executeQuery("select User2_password,User2_name from User2");
while(rs.next()){
String b=rs.getString("User2_password");
String b1=rs.getString("User2_name");
System.out.println(b+" "+b1);
}
//先处理上面
JPanel jp1=new JPanel ();
jp1.setLayout(new GridLayout(2,2));
JLabel jl1 = new JLabel("用户名",JLabel.CENTER);
JLabel jl2= new JLabel("密码",JLabel.CENTER);
JTextField jtf = new JTextField();
jtf.setText("56");
JPasswordField jpf= new JPasswordField();
jpf.addActionListener(this);
//jpf.setEchoChar('*');
jp1.add(jl1);
jp1.add(jtf);
jp1.add(jl2);
jp1.add(jpf);
//处理下面
JButton **1=new JButton("注册");
**1.addActionListener(this);
JButton **2=new JButton("登陆");
**2.addActionListener(this);
JPanel jp2=new JPanel();
jp2.add(**1);
jp2.add(**2);
this.add(jp1);
this.add(jp2,BorderLayout.SOUTH);
this.setTitle("图书管理系统-登陆"); //设置标题
this.setSize(525,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public void actionPerformed(ActionEvent arg0) {
if(arg0.getActionCommand().equals("注册")){
//进入注册读者界面
new newuser();
}
if(arg0.getActionCommand().equals("登陆")){
String[] c1={"lisi,maliu,nannan,qiqi,wangwu,zhangsan"};
String[] c2={"李四,马六,南南,七七,王五,张三"};
JTextField jtf = new JTextField();
JPasswordField jpf= new JPasswordField();
System.out.println(0);
if(jtf.getText().equals(c2)||jpf.getPassword().equals(c1)){
System.out.println(1);
new mainframe();
}
}
}
}
转载地址:http://gytnx.baihongyu.com/