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

📄 enter.java

📁 一个关于图书馆管理系统的课程设计
💻 JAVA
字号:
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.sql.*;
public class enter extends JFrame implements ActionListener
{
	TextField a_name ;
	TextField a_password;
	Label a_name0=new Label("用户名  ");
	Label a_password0=new Label("  密码  ");
	String s1,s3;
	String s2,s4;
	JButton a_enter1;
	JButton a_enter2;
	int i=0;
	int j=0;
	public enter()
	{
    	super("enter_system");		
		a_name = new TextField(20); 
		a_password=new TextField(20);
		a_password.setEchoChar('*');
		a_enter1= new JButton("管理员登录");
		a_enter2= new JButton("学生登录");
		a_enter1.addActionListener(this);
		a_enter2.addActionListener(this);
		Panel pane=new Panel();//定义主面板
		//pane.setLayout(new FlowLayout());
		pane.setLayout(null);
		a_name0.setBounds(100,100,140,50);
		a_name.setBounds(100,150,140,30);
		a_password0.setBounds(100,200,140,50);
		a_password.setBounds(100,250,140,30);
		a_enter1.setBounds(40,300,100,50);
		a_enter2.setBounds(160,300,100,50);
		pane.add(a_name0); 
		pane.add(a_name); 
		pane.add(a_password0); 
		pane.add(a_password); 
		pane.add(a_enter1);
		pane.add(a_enter2);
		this.add(pane);
	}
	public void actionPerformed(ActionEvent e)
	{
	
		 if(e.getSource()==a_enter1)
		 {
		 
		 String url1="jdbc:odbc:agang";
		 String sql="select * FROM administrator";
			try{
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");  //驱动程序名称_JDBC/ODBC桥接驱动程序
			}catch(java.lang.ClassNotFoundException e1){}
			try{
			Connection con=DriverManager.getConnection(url1,"",null);//建立连接
			Statement stmt=con.createStatement();
		  	ResultSet rs=stmt.executeQuery(sql);  
		  	while(rs.next())
		  	{ 
			  s1=rs.getString("aname");
			  System.out.println(s1);
			  s2=rs.getString("apassword");
			  System.out.println(s2);
			  while(s1.trim().equals(a_name.getText())&&s2.trim().equals(a_password.getText()))
			  {
			  	i++;
			  	break;
			  }
			  
		  } 
		  if(i!=0)
			   {
			   	dispose();
				student_system t1=new student_system();//管理员进入界面
				t1.setVisible(true);
			    t1.setLocation(300,300);
			    t1.setSize(800,800);
			   //super("student_systen");
			  }
			 else  
			 {
			 	new myDialog();
			 }
		  stmt.close();
	      con.close();
	}catch(SQLException e2){}
	}
	else
	{
		String url1="jdbc:odbc:agang";
		 String sql="select * FROM password";
		try{
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");  //驱动程序名称_JDBC/ODBC桥接驱动程序
		}catch(java.lang.ClassNotFoundException e1){}
		try{
			Connection con=DriverManager.getConnection(url1,"",null);//建立连接
			Statement stmt=con.createStatement();
		  	ResultSet rs=stmt.executeQuery(sql);  
		  	while(rs.next())
		  	{ 
			  s1=rs.getString("pname");
			  System.out.println(s1);
			  s2=rs.getString("ppassword");
			  System.out.println(s2);
			  while(s1.trim().equals(a_name.getText())&&s2.trim().equals(a_password.getText()))
			  {
			  	j++;
			  	break;
			  }
			  
		  } 
		  if(j!=0)
			   {
			   	dispose();
				student_look x1=new student_look();//学生管理界面
				x1.setVisible(true);
				x1.setLocation(300,300);
				x1.setSize(600,600);
			   //super("student_systen");
			  }
			 else  
			 {
			 	new myDialog();
			 }
		  stmt.close();
	      con.close();
	}catch(SQLException e2){}	
	}
	}
	public static void main(String args[])
	{
		enter x=new enter();
		x.setVisible(true);
		x.setLocation(300,300);
		x.setSize(500,500);
	}
}


⌨️ 快捷键说明

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