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

📄 empbean.java

📁 完整的JAVA工程
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package employee;

import java.util.*;
import java.sql.*;
import javax.swing.*;

/**
 * 有关职工信息数据库操作的类
 */
public class EmpBean {
	String sql;
	ResultSet rs = null;
	ImageIcon icon;
	
	String eEid1;
	String ePassword;
	String eName;
	String eSex;
	String eNation;
	String eRegion;
	String eEducation;
	String eSpecialty;
	String eBirthday;
	String eGstatus;
	String eMarriage;
	String eIdcard;
	String eHlocation;
	String eCityhk;
	String eCaddress;
	String ePostcode;
	String eMobilephone;
	String eHomephone;
	String eEmail;
	String eCategory;
	String eJobdate;
	String eContractdate;
	String eZzdate;
	String eXqdate;
	String eFilelocation;
	
	String id;
	String eEid2;
	String eDname;
	String eAname;
	String eBegtime;
	String eEndtime;
	String eTest;
	String eOfficephone;
	String eRemark;
	
	String eEid3;
	String tName;
	String tBegtime;
	String tEndtime;
	String tTest;
	String tRemark;

	String colName;//列名
	String colValue;//列值

	/**
	 * 添加职工基本信息
	 */	
	public void empAdd(String eid,String epassword,String ename, String sex, String nation, String region, String education, String specialty, String birthday, String gstatus,String marriage,String idcard, String hlocation, String cityhk, String caddress, String postcode, String mobilephone, String homephone, String email,String category,String jobdate,String contractdate,String zzdate,String xqdate,String filelocation){
		
		Database DB = new Database();
		
		this.eEid1 = eid;
		this.ePassword=epassword;
		this.eName = ename;
		this.eSex = sex;
		this.eNation = nation;
		this.eRegion = region;
		this.eEducation = education;
		this.eSpecialty = specialty;
		this.eBirthday = birthday;
		this.eGstatus = gstatus;
		this.eMarriage = marriage;
		this.eIdcard = idcard;
		this.eHlocation = hlocation;
		this.eCityhk = cityhk;
		this.eCaddress = caddress;
		this.ePostcode = postcode;
		this.eMobilephone = mobilephone;
		this.eHomephone = homephone;
		this.eEmail = email;
		this.eCategory = category;
		this.eJobdate = jobdate;
		this.eContractdate=contractdate;
		this.eZzdate=zzdate;
		this.eXqdate=xqdate;
		this.eFilelocation=filelocation;


		if(eEid1 == null||eEid1.equals("")){
			JOptionPane.showMessageDialog(null, "请输入职工编号!", "错误", JOptionPane.ERROR_MESSAGE);
			return;
		}
		else if(eName == null||eName.equals("")){
			JOptionPane.showMessageDialog(null, "请输入职工姓名!", "错误", JOptionPane.ERROR_MESSAGE);
			return;
		}
		else if(eSex == null||eSex.equals("")){
			JOptionPane.showMessageDialog(null, "请输入职工性别!", "错误", JOptionPane.ERROR_MESSAGE);
			return;
		}
		else{
			sql = "insert into employee (eid,epassword,ename,sex,nation,region,education,specialty,birthday,gstatus,marriage,idcard,hlocation,cityhk,caddress,postcode,mobilephone,homephone,email,category,jobdate,contractdate,zzdate,xqdate,filelocation) values ('"+eEid1+"','"+ePassword+"','"+eName+"','"+eSex+"','"+eNation+"','"+eRegion+"','"+eEducation+"','"+eSpecialty+"','"+eBirthday+"','"+eGstatus+"','"+eMarriage+"','"+eIdcard+"','"+eHlocation+"','"+eCityhk+"','"+eCaddress+"','"+ePostcode+"','"+eMobilephone+"','"+eHomephone+"','"+eEmail+"','"+eCategory+"','"+eJobdate+"','"+eContractdate+"','"+eZzdate+"','"+eXqdate+"','"+eFilelocation+"')";

			try{
				DB.OpenConn();
				DB.executeUpdate(sql);
				JOptionPane.showMessageDialog(null,"成功添加一条新的职工基本信息记录!");

			}
			catch(Exception e){
				System.out.println(e);
				JOptionPane.showMessageDialog(null, "保存失败!", "错误", JOptionPane.ERROR_MESSAGE); 
			}
			finally {
				DB.closeStmt();
				DB.closeConn();
			}
		}
	}
	
	/**
	 * 添加职工公司信息
	 */	
	public void empComAdd(String eid,String dname,String aname, String begtime, String endtime, String test, String officephone, String remark){
		
		Database DB = new Database();
		
		this.eEid2 = eid;
		this.eDname=dname;
		this.eAname = aname;
		this.eBegtime = begtime;
		this.eEndtime = endtime;
		this.eTest = test;
		this.eOfficephone = officephone;
		this.eRemark = remark;

		if(eEid2 == null||eEid2.equals("")){
			JOptionPane.showMessageDialog(null, "请输入职工编号!", "错误", JOptionPane.ERROR_MESSAGE);
			return;
		}
		else{
			sql = "insert into empcom (eid,dname,aname,begtime,endtime,test,officephone,remark) values ('"+eEid2+"','"+eDname+"','"+eAname+"','"+eBegtime+"','"+eEndtime+"','"+eTest+"','"+eOfficephone+"','"+eRemark+"')";

			try{
				DB.OpenConn();
				DB.executeUpdate(sql);
				JOptionPane.showMessageDialog(null,"成功添加一条新的职工公司信息记录!");

			}
			catch(Exception e){
				System.out.println(e);
				JOptionPane.showMessageDialog(null, "保存失败!", "错误", JOptionPane.ERROR_MESSAGE); 
			}
			finally {
				DB.closeStmt();
				DB.closeConn();
			}
		}
	}
	
	/**
	 * 添加职工培训信息
	 */	
	public void empTraAdd(String eid,String tname,String begtime, String endtime, String test,String remark){
		
		Database DB = new Database();
		
		this.eEid3 = eid;
		this.tName=tname;
		this.tBegtime = begtime;
		this.tEndtime = endtime;
		this.tTest = test;
		this.tRemark = remark;

		if(eEid3 == null||eEid3.equals("")){
			JOptionPane.showMessageDialog(null, "请输入职工编号!", "错误", JOptionPane.ERROR_MESSAGE);
			return;
		}
		else{
			sql = "insert into emptra (eid,tname,begtime,endtime,test,remark) values ('"+eEid3+"','"+tName+"','"+tBegtime+"','"+tEndtime+"','"+tTest+"','"+tRemark+"')";

			try{
				DB.OpenConn();
				DB.executeUpdate(sql);
				JOptionPane.showMessageDialog(null,"成功添加一条新的职工培训信息记录!");

			}
			catch(Exception e){
				System.out.println(e);
				JOptionPane.showMessageDialog(null, "保存失败!", "错误", JOptionPane.ERROR_MESSAGE); 
			}
			finally {
				DB.closeStmt();
				DB.closeConn();
			}
		}
	}
			
		
	/**
	 * 修改职工信息
	 */
	public void empModify(String eid,String epassword,String ename, String sex, String nation, String region, String education, String specialty, String birthday, String gstatus,String marriage,String idcard, String hlocation, String cityhk, String caddress, String postcode, String mobilephone, String homephone, String email,String category,String jobdate,String contractdate,String zzdate,String xqdate,String filelocation){
		
		Database DB = new Database();
		
		this.eEid1 = eid;
		this.ePassword=epassword;
		this.eName = ename;
		this.eSex = sex;
		this.eNation = nation;
		this.eRegion = region;
		this.eEducation = education;
		this.eSpecialty = specialty;
		this.eBirthday = birthday;
		this.eGstatus = gstatus;
		this.eMarriage = marriage;
		this.eIdcard = idcard;
		this.eHlocation = hlocation;
		this.eCityhk = cityhk;
		this.eCaddress = caddress;
		this.ePostcode = postcode;
		this.eMobilephone = mobilephone;
		this.eHomephone = homephone;
		this.eEmail = email;
		this.eCategory = category;
		this.eJobdate = jobdate;
		this.eContractdate=contractdate;
		this.eZzdate=zzdate;
		this.eXqdate=xqdate;
		this.eFilelocation=filelocation;

		if(eName == null||eName.equals("")){
			JOptionPane.showMessageDialog(null, "请输入职工姓名", "错误", JOptionPane.ERROR_MESSAGE);
			return;
		}
		else if(eSex == null||eSex.equals("")){
			JOptionPane.showMessageDialog(null, "请输入职工性别", "错误", JOptionPane.ERROR_MESSAGE);
			return;
		}
		else{
			sql = "update employee set epassword='"+ePassword+"',ename = '"+eName+"', sex = '"+eSex+"', nation = '"+eNation+"', region = '"+eRegion+"', education = '"+eEducation+"', specialty = '"+eSpecialty+"', birthday = '"+eBirthday+"',gstatus = '"+eGstatus+"', marriage = '"+eMarriage+"', idcard = '"+eIdcard+"', hlocation = '"+eHlocation+"', cityhk = '"+eCityhk+"', caddress = '"+eCaddress+"', postcode = '"+ePostcode+"', mobilephone = '"+eMobilephone+"',homephone = '"+eHomephone+"', email = '"+eEmail+"',category='"+eCategory+"',jobdate='"+eJobdate+"',contractdate='"+eContractdate+"',zzdate='"+eZzdate+"',xqdate='"+eXqdate+"',filelocation='"+eFilelocation+"' where eid = '"+eEid1+"'";
			try{
				DB.OpenConn();
				DB.executeUpdate(sql);
				JOptionPane.showMessageDialog(null,"成功修改一条新的纪录!");
			}
			catch(Exception e){
				System.out.println(e);
				JOptionPane.showMessageDialog(null, "更新失败", "错误", JOptionPane.ERROR_MESSAGE); 
			}
			finally {
				DB.closeStmt();
				DB.closeConn();
			}
		}
	}
	
	/**
	 * 删除职工信息
	 */
	public void empDel(String eid){
		
		Database DB = new Database();
		this.eEid1 = eid;
		
		sql = "delete from employee where eid = "+eEid1+"";
		try{
			DB.OpenConn();
			DB.executeUpdate(sql);
			JOptionPane.showMessageDialog(null,"成功删除一条新的纪录!");
		}
		catch(Exception e){
			System.out.println(e);
			JOptionPane.showMessageDialog(null, "删除失败", "错误", JOptionPane.ERROR_MESSAGE); 
		}
		finally {
			DB.closeStmt();
			DB.closeConn();
		}
	}

	/**
	 * 根据职工编号查询职工基本信息
	 */
	public String[] empSearch(String eid){
		
		Database DB = new Database();
		this.eEid1 = eid;
		String[] s = new String[24];
		sql = "select * from employee where eid = "+eEid1+"";

		try{
			DB.OpenConn();
			rs = DB.executeQuery(sql);
			if(rs.next()){
				s[0] = rs.getString("epassword");
				s[1] = rs.getString("ename");
				s[2] = rs.getString("sex");
				s[3] = rs.getString("nation");
				s[4] = rs.getString("region");
				s[5] = rs.getString("education");
				s[6] = rs.getString("specialty");
				s[7] = rs.getString("birthday");
				s[8] = rs.getString("gstatus");
				s[9] = rs.getString("marriage");
				s[10] = rs.getString("idcard");
				s[11] = rs.getString("hlocation");
				s[12] = rs.getString("cityhk");
				s[13] = rs.getString("caddress");
				s[14] = rs.getString("postcode");
				s[15] = rs.getString("mobilephone");
				s[16] = rs.getString("homephone");
				s[17] = rs.getString("email");
				s[18] = rs.getString("category");
				s[19] = rs.getString("jobdate");
				s[20] = rs.getString("contractdate");
				s[21] = rs.getString("zzdate");
				s[22] = rs.getString("xqdate");
				s[23] = rs.getString("filelocation");
			}
			else
				s = null;
		}
		catch(Exception e){
		}
		finally {
			DB.closeStmt();
			DB.closeConn();

⌨️ 快捷键说明

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