用纯java代码写的简单粗糙的“人事管理系统”

源代码在线查看: delete.java

软件大小: 69 K
上传用户: chmqn
关键词: java 代码 管理系统
下载地址: 免注册下载 普通下载 VIP

相关代码

				import javax.lang.*;
				import javax.swing.*;
				import java.awt.*;
				import java.awt.event.*;
				import java.sql.*; 
				public class delete implements ActionListener{
					private Frame delete;
					private Choice condition;
					private TextField input;
					private TextArea output;
					private Button determined,display; 
					public delete()
					{
						init();
					}
					private void init(){
				        delete=new Frame("删除");
				        delete.setBounds(50, 50, 400, 310);
				        delete.setBackground(Color.gray);
				        delete.setLayout(null);
				        condition=new Choice();
				        condition.addItem("员工编号"); 
				        condition.addItem("姓名");
				        condition.setBounds(20, 50, 70, 20);
						delete.add(condition);
				        input=new TextField(10);
				        input.setBounds(100, 50, 80, 20);
						delete.add(input);
				        determined=new Button("删除");
				        determined.setBounds(300, 50, 80, 20);
						delete.add(determined);
				        determined.addActionListener(this);
				        display=new Button("显示");
				        display.setBounds(200, 50, 80, 20);
						delete.add(display);
				        display.addActionListener(this);
				        output=new TextArea();    
				        output.setBounds(10, 100, 380, 200);
				        delete.add(output);
				        delete.setVisible(true);
				        delete.addWindowListener(new WindowAdapter(){
							public void windowClosing(WindowEvent e){
								new 管理员查询();
								delete.setVisible(false);
							}			
						});
					}
					public void deleteunit()throws SQLException{
						String one;
						String sqly;
						int c;
						try{
							Class.forName("sun.jdbc.odbc.jdbcodbcDriver");
						}
						  catch(ClassNotFoundException e) { }
						  Connection con=DriverManager.getConnection("jdbc:odbc:wgzl");
						  Statement sql=con.createStatement(); //创建Statement对象
						  c=condition.getSelectedIndex();
							 sqly= "delete from xinxi where 员工编号= '"+input.getText().trim()+"'";
							  switch(c){
								  case 0:
									  sqly= "delete from xinxi where 员工编号= '"+input.getText().trim()+"'";
									  break;
								  case 1:
									  sqly= "delete from xinxi where 姓名= '"+input.getText().trim()+"'";
									  break;
							  }
							  sql.executeUpdate(sqly);
					}
					public void list()throws SQLException{
						output.setText("");
						String one;
						String sqly;
						String num,name,sex;
						float age;
						String birthday,data,local;
						float level;
						String character,beizhu,ads,tel,yonhu;
						int c;
						try{
							Class.forName("sun.jdbc.odbc.jdbcodbcDriver");
						}
						  catch(ClassNotFoundException e) { }
						  Connection con=DriverManager.getConnection("jdbc:odbc:wgzl");
						  Statement sql=con.createStatement(); //创建Statement对象
						  c=condition.getSelectedIndex();
						  sqly="select * from xinxi where 员工编号= '"+input.getText().trim()+"'";
						  switch(c){
						  case 0:
							  sqly="select * from xinxi where 员工编号= '"+input.getText().trim()+"'";
							  break;
						  case 1:
							  sqly="select * from xinxi where 姓名= '"+input.getText().trim()+"'";
							  break;
						  }		  
						  ResultSet rs=sql.executeQuery(sqly);
						  output.append("员工编号 "+"姓名 "+"性别 "+"年龄 "+"出生日期        "
								  +"何时进入分司   "+"职务 "+"薪水 "+"个人特点 "+"备注 "+"  用户名   "+"  地址"+"  联系方式"+'\n');
						  while(rs.next()){
							  num=rs.getString(1);
							  name=rs.getString(2);
							  sex=rs.getString(3);
							  age=rs.getFloat(4);
							  birthday=rs.getString(5);
							  data=rs.getString(6);
							  local=rs.getString(7);			  
							  level=rs.getFloat(8);
							  character=rs.getString(9);
							  beizhu=rs.getString(10);
							  yonhu=rs.getString(11);
							  ads=rs.getString(12);
							  tel=rs.getString(13);
							  output.append('\n'+num+"     "+name+"     "+sex+" "+age+" "+birthday+"     "+
									  data+"    "+local+" "+level+" "+character+"       "+beizhu+"    "+"  "+yonhu+"  "+ads+"   "+tel+'\n');			 
						  }	
						  con.close();
						  sql.close();
						
					}
					public static void main(String args[]){
						delete t=new delete();
					}
				
					public void actionPerformed(ActionEvent e) {
						if(e.getSource()==determined){
							try{
								 deleteunit();
								}catch(SQLException ee)
								{
									ee.printStackTrace();
								}
						}else if(e.getSource()==display){
							try{
								list();
								}catch(SQLException ee)
								{
									ee.printStackTrace();
								}
						}
						
					}
				
				}
							

相关资源