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

📄 qybb.java

📁 这是一个用JAVA做的人力资源系统
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import java.sql.*;

public class QYBB extends Frame implements ItemListener,ActionListener{
	String url="jdbc:odbc:test";
	Connection con;
	String sql;
	Statement stmt;
	Choice choice;
	Label label,label1;
	Button ok = new Button("马上给我结果~");
	Button cancel = new Button("取消");
	TextField Input = new TextField(15);
	TextArea ta=new TextArea(10,50);
	QYBB(){
		Label label1=new Label("请选择查询种类:");
		add(label1);
		choice=new Choice();
		choice.addItem("单个员工工资情况");
		choice.addItem("部门工资情况");
		choice.addItem("按月工资统计");
		choice.addItemListener(this);
		
		label=new Label();
		setLabelText(choice.getSelectedIndex(),choice.getSelectedItem());
		setLayout(new FlowLayout());
		add(choice);
		add(label);
		add(Input);
		addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent e){
				setVisible(false);
			}
		});
		Panel panel2 = new Panel();
		panel2.add(ta,BorderLayout.CENTER);
		add("Center",panel2);
		Panel panel3 = new Panel();
		panel3.add(ok);
		panel3.add(cancel);
		add("South",panel3);
		ok.addActionListener(this);
		cancel.addActionListener(this);
		Input.addActionListener(this);
		setSize(600,300);
		setTitle("企业报表");
		setVisible(true);
		setResizable(false);
		setLocationRelativeTo(null);
	}
	void setLabelText(int num,String text){
		if(text.equals("单个员工工资情况")){
		label.setText("请输入员工号                   ");
		}
		else{
			if(text.equals("部门工资情况")){
				label.setText("请输入部门名称                 ");
			}
			else{
				label.setText("请输入月份(如:07.12)");
			}
		}
	}
	public void actionPerformed(ActionEvent e){
		if (e.getActionCommand().equals("马上给我结果~")|e.getSource()==Input)
		{
			String I=Input.getText();
			try{
				Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			}catch(ClassNotFoundException e1){
				System.err.print("ClassNotFoundException:");
				System.err.print("e.getMessage()");
			}
			
			if(choice.getSelectedItem().equals("单个员工工资情况")){
				try{
					con = DriverManager.getConnection(url,"sa","sa");
					stmt = con.createStatement();
					String sql="select 基本工资 from salary where 员工号='"+I+"'";
		    		stmt=con.createStatement();
		    		ResultSet rs=stmt.executeQuery(sql);
		    	while(rs.next()){
		            String x="员工号:"+I+"  工资:"+rs.getString(1)+"\n";
		            ta.append(x);
				}
		    	stmt.close();
				con.close();
			}catch(SQLException ex){
				System.err.println("SQLException:"+ex.getMessage());
			}}
				else{
					if(choice.getSelectedItem().equals("部门工资情况")){
						try{
							con = DriverManager.getConnection(url,"sa","sa");
							stmt = con.createStatement();
						    String sql1="select * from salary where 员工号 In(select 员工号 from worker where 部门='"+I+"')";
						    stmt=con.createStatement();
			    		ResultSet rs1=stmt.executeQuery(sql1);
			    	while(rs1.next()){
			            String x2="员工号:"+rs1.getString(2)+"  工资:"+rs1.getString(5);
			            ta.append(x2);
					}
			    	stmt.close();
					con.close();
				}catch(SQLException ex){
					System.err.println("SQLException:"+ex.getMessage());
				}
					}
					else{
						try{
							con = DriverManager.getConnection(url,"sa","sa");
							stmt = con.createStatement();
						    String sql1="select * from salary where 年月='"+I+"'";
						    stmt=con.createStatement();
			    		ResultSet rs1=stmt.executeQuery(sql1);
			    	while(rs1.next()){			           
			    		ta.append("员工号:"+rs1.getString(2)+"   工资:"+rs1.getString(5)+"\n");
					}
			    	stmt.close();
					con.close();
				}catch(SQLException ex){
					System.err.println("SQLException:"+ex.getMessage());
				}
					}
					
				}
		    	
			
				Input.setText(null);
				
				
			}
		
		if (e.getActionCommand().equals("取消"))
		{
			setVisible(false);
		}
	}
	
	public void itemStateChanged(ItemEvent e){
		setLabelText(choice.getSelectedIndex(),choice.getSelectedItem());			
	}

}

⌨️ 快捷键说明

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