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

📄 dl.java

📁 线程超市管理系统 采用线程管理的超市管系统
💻 JAVA
字号:
package zh;


import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;


public class DL implements ActionListener ,ItemListener{
	JFrame frame;

	JPanel panel_1, panel_2, panel_3,panel_4;

	JTextField text1,text;
	 String chs="";
//	JPasswordField text;

	JButton button1, button2;

	JLabel label, label1, label2;
	Choice choice;
	Container con;
     Quanxian quan;
	Mianban aaa;Mianban1 bbb;Mianban2 ccc;Mianban3 ddd;

	DL() {
		frame = new JFrame("登录窗口");
		button1 = new JButton("确定");
		button2 = new JButton("退出");
		choice=new Choice();
		choice.add("管理员");
		choice.add("经理");
		choice.add("销售员");
		choice.add("顾客");
		panel_1 = new JPanel();
		panel_2 = new JPanel();
		panel_3 = new JPanel();panel_4 = new JPanel();
		panel_4.add(choice);
		text = new JTextField();
		text.setPreferredSize(new Dimension(120, 25));
//		text.setEchoChar('*');
		text1 = new JTextField();
		text1.setPreferredSize(new Dimension(120, 25));
		aaa = new Mianban();bbb = new Mianban1();ccc=new Mianban2();ddd=new Mianban3();
		panel_3.add(button1);
		panel_3.add(Box.createRigidArea(new Dimension(40, 0)));
		panel_3.add(button2);
		con = frame.getContentPane();
		label2 = new JLabel("登录窗口", JLabel.CENTER);
		label1 = new JLabel("用户名:", JLabel.CENTER);
		label = new JLabel("密     码:", JLabel.CENTER);
		panel_1.add(label1);
		panel_1.add(text1);
		panel_2.add(label);
		panel_2.add(text);
		con.setLayout(new GridLayout(5, 1));
		con.add(label2);
		con.add(panel_1);
		con.add(panel_2);
		con.add(panel_4);
		con.add(panel_3);
		frame.setBounds(200, 150, 300, 300);
		frame.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e1) {
				System.exit(0);
			}
		});
		frame.setVisible(true);
		choice.addItemListener(this);
		button2.addActionListener(this);
		button1.addActionListener(this);
	}
	public void itemStateChanged(ItemEvent e){
		if(e.getItemSelectable()==choice){
			chs=choice.getSelectedItem();
		}
	}

	public void actionPerformed(ActionEvent e) {

		if (e.getSource() == button2) {
			System.exit(0);
		} else if (e.getSource() == button1) {
			Connection con;
			Statement st;
			int i=0;
			String syh = text1.getText().trim() ;
			String smm = text.getText().trim() ;
//			String name1,name2,name3;
			try {
				Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
				con = DriverManager.getConnection("jdbc:odbc:zz", "", "");
				st = con.createStatement();	int id = 0;System.out.print("555555");
//				if(text.getText().equals(""))
				if(chs.equals("管理员")){
				ResultSet rs = st.executeQuery("select * from password where leibie="+"'"+chs.trim()+"'");
				while (rs.next()) {
				if (rs.getString(2).equals(syh)
							&& rs.getString(3).equals(
									smm)) {
						id = 1;
       					frame.setVisible(false);
						aaa.myframe.setVisible(true);
						
						i++;}}}
				else if(chs.equals("经理")){
					ResultSet rs = st.executeQuery("select * from password where leibie="+"'"+chs.trim()+"'");
					while (rs.next()) {
					if (rs.getString(2).equals(syh)
								&& rs.getString(3).equals(
										smm)) {
							id = 1;
	       					frame.setVisible(false);
							bbb.myframe.setVisible(true);
							
							i++;}}}
				else if(chs.equals("销售员")){
					ResultSet rs = st.executeQuery("select * from password where leibie="+"'"+chs.trim()+"'");
					while (rs.next()) {
					if (rs.getString(2).equals(syh)
								&& rs.getString(3).equals(
										smm)) {
							id = 1;
	       					frame.setVisible(false);
							ccc.myframe.setVisible(true);
//							aaa.menu1.setEnabled(false);
//							aaa.menu2.setEnabled(false);
							i++;}}}
				else {
					ResultSet rs = st.executeQuery("select * from password where leibie="+"'"+chs.trim()+"'");
					while (rs.next()) {
//					if (rs.getString(2).equals(syh)
//								&& rs.getString(3).equals(
//										smm)) {
							id = 1;
	       					frame.setVisible(false);
							ddd.myframe.setVisible(true);
//							aaa.menu1.setEnabled(false);
//							aaa.menu2.setEnabled(false);
//							aaa.menu3.setEnabled(false);
							i++;}}

				con.close();
//				if (id == 0) {
//					JOptionPane.showMessageDialog(frame, "错误,请重试!");
//					text1.setText(null);
//					text.setText(null);
//				}

				
		} catch (java.lang.Exception ee) {}

	}

}

	public static void main(String[] args) {

		new DL();
		Jinhuo jinhuo=new Jinhuo();
		

	}
}

⌨️ 快捷键说明

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