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

📄 persondutybean.java

📁 企业员工信息管理系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:

package oa.bean;

import java.text.*;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.sql.*;
import oa.main.*;
//import javax.swing.tree.DefaultMutableTreeNode;

public class PersonDutyBean extends ParentBean
{
	String PersonNo="";//职工编号
    String DutyOrgNo="";//职务部门编号
    String DutyNo="";//职务编号

	//构造函数
	public PersonDutyBean() 
	{
	}
	//设置部门编号
	public void setDutyOrgNo(String DutyOrgNo)
	{
		this.DutyOrgNo = DutyOrgNo;
	}
	//设置职工编号
	public void setPersonNo(String PersonNo)
	{
		this.PersonNo = PersonNo;
	}

	//通过部门编号得到部门名称
	public String getOrgName(String strOrgNo)
	{
		return toName("ZZ_BMB","BMBH","BMMC",strOrgNo);
	}

	public Vector getBMMC(String strPersonNo)//通过职工编号得到ZZ_ZGZWB的所有BMMC记录	
	{
		Vector vt = new Vector();
		String sql = "";
		String bmbh = "";
		String bmName = "";

		sql = "select BMBH from ZZ_ZGZWB where ZGBH='"+strPersonNo+"' order by BMBH";
		ResultSet rs = selectRecord(sql);
		ResultSet rst = null;
		Statement stmt = null;
		try{
		while(rs.next())
		{	
			String bmbh1 = ds.toString(rs.getString("BMBH"));
			if(bmbh1.equals(bmbh))
			{
				continue;
			}
			else
			{
				bmbh = bmbh1;
				sql = "select BMMC from ZZ_BMB where BMBH='"+bmbh+"'";
				rst = selectRecord(sql);
				try{
					if(rst.next()){
						bmName = ds.toString(rst.getString("BMMC"));
						Hashtable ht = new Hashtable();
						ht.put("BMBH",bmbh);
						ht.put("BMMC",bmName);
						vt.add(ht);	
					}
				}catch(Exception e){System.out.println("运行时出错:"+e);}
				finally{
					if(rst!=null)try{ stmt = rst.getStatement(); rst.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
					if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
				}
			}
		}
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
		return vt;
	}

	//通过职工编号得到职工姓名
	public String getPersonName(String strPersonNo)
	{
		return toName("ZZ_ZGB","ZGBH","XM",strPersonNo);
	}

	//通过职工编号得到ZZ_ZGZWB的BMMC_ZWMC记录
	public String getBMMC_ZWMC(String strPersonNo)
	{
		String sql = " select a.BMBH,b.zwmc,b.zwzt from ZZ_ZGZWB a,zz_zwb b where a.ZGBH='"+strPersonNo+"' and a.bmbh=b.bmbh and a.zwbh=b.zwbh ";
		ResultSet rs = selectRecord(sql);
		String bmName="",zwName="",mixName="",dutyzt="";
		Statement stmt = null;
		DutyBean dutybn = null;
		PersonBean psbn = null;
		try{
		while(rs.next())
		{	
			String bmbh = ds.toString(rs.getString("BMBH"));						
			bmName = getName(bmbh);
			zwName = ds.toString(rs.getString("ZWMC"));		
			dutyzt = ds.toString(rs.getString("ZWZT"));	
			if (dutyzt.equals("1"))
			{
				dutyzt = "(挂起)";
			}
			else
				dutyzt = "";

			if(!mixName.equals(""))
				mixName += "\n"+bmName+":"+zwName+dutyzt;
			if(mixName.equals(""))
				mixName = bmName+":"+zwName+dutyzt;
		}
		if(mixName.equals("")){
			dutybn = new DutyBean();
			psbn = new PersonBean();
			psbn.setPersonNO(strPersonNo);	 
			String BMBH = psbn.getBMBH();	
			String zwNo = dutybn.getOrdinaryZWBH(BMBH,"一般员工");
			if(zwNo.equals("")){
				Hashtable dutyhash = new Hashtable();
				dutyhash.put("BMBH",BMBH);
				dutyhash.put("ZWMC","一般员工");
				dutyhash.put("CZQX","");
				dutyhash.put("LCQX","");
				dutyhash.put("PZCS","");
				dutyhash.put("JBXH","");
				dutyhash.put("ZWZT","0");
				dutybn.addDuty(dutyhash);
				zwNo = dutybn.getOrdinaryZWBH(BMBH,"一般员工");
			}
			addRec(strPersonNo,BMBH,zwNo,"","");
			mixName = getBMMC_ZWMC(strPersonNo);
		}
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(psbn!=null) psbn.closeConn();
			if(dutybn!=null)dutybn.closeConn();
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
		return mixName;
		
	}
	public Vector getData(String strPersonNo)//通过职工编号得到ZZ_ZGZWB的所有记录
	{
		Vector vt = new Vector();
		String sql ="select BMBH,ZWBH from ZZ_ZGZWB where ZGBH='"+strPersonNo+"'";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		DutyBean dutybn = null;
		PersonBean psbn = null;
		try{
		while(rs.next())
		{	
			String bmbh = ds.toString(rs.getString("BMBH"));
			String zwbh = ds.toString(rs.getString("ZWBH"));
			Hashtable ht = new Hashtable();
			ht.put("BMBH",bmbh);
			ht.put("ZWBH",zwbh);
			vt.add(ht);
		}
		if(vt.size()==0){
			dutybn = new DutyBean();
			psbn = new PersonBean();
			psbn.setPersonNO(strPersonNo);
			String BMBH = psbn.getBMBH();
			String zwNo = dutybn.getOrdinaryZWBH(BMBH,"一般员工");
			if(zwNo.equals("")){
				Hashtable dutyhash = new Hashtable();
				dutyhash.put("BMBH",BMBH);
				dutyhash.put("ZWMC","一般员工");
				dutyhash.put("CZQX","");
				dutyhash.put("LCQX","");
				dutyhash.put("PZCS","");
				dutyhash.put("JBXH","");
				dutyhash.put("ZWZT","0");
				dutybn.addDuty(dutyhash);
				zwNo = dutybn.getOrdinaryZWBH(BMBH,"一般员工");
			}
			addRec(strPersonNo,BMBH,zwNo,"","");
			vt = getData(strPersonNo);
		}
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
			if(psbn!=null) psbn.closeConn();
			if(dutybn!=null)dutybn.closeConn();
		}
		return vt;
	}

	//通过职务名称得到职务编号
	public String getDutyNo(String strDutyName)
	{
		String dutyno = "";
		String sql = "select ZWBH from ZZ_ZWB where trim(ZWMC)='"+strDutyName+"' and BMBH='"+DutyOrgNo+"'";

		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try{
		while(rs.next())
			dutyno = ds.toString(rs.getString("ZWBH"));
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
		return dutyno;
	}

	//通过职务编号得到职务名称
	public String getDutyName(String strDutyNo)
	{
		String dutyname = "";
		String sql = "select ZWMC from ZZ_ZWB where ZWBH='"+strDutyNo+"' and BMBH='"+DutyOrgNo+"'";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try{
		while(rs.next())
			dutyname = ds.toString(rs.getString("ZWMC"));
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
		return dutyname;
	}

	
	//检查ZZ_ZGZWB中是否已经由此条记录
	public boolean hasRect(String personno,String dutyOrgno,String dutyno)
	{
		boolean b = false;
		String sql="select * from ZZ_ZGZWB where ZGBH='"+personno+"' and BMBH='"+dutyOrgno+"' and ZWBH='"+dutyno+"'";
		ResultSet rs=db.QuerySQL(sql);
		Statement stmt = null;
		try{
			if(rs.next()){
				b = true;
			}
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
		return b;
	}
	
	//判断ZZ_ZGB中是否有输入的部门名称、职工编号、职工姓名的对应纪录
	public int hasPerson(String orgName,String personno,String personname)
	{
		String sql="select * from ZZ_ZGB where BMBH='"+orgName+"' and ZGBH='"+personno+"' and XM='"+personname+"'";
		ResultSet rs=db.QuerySQL(sql);
		Statement stmt = null;
		try{
			if(rs.next())
				return 0;		    
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
		return 1;
	}

	//判断ZZ_ZWB是否有输入的部门名称、职务名称的对应纪录
	public int hasOrgDuty(String orgName,String dutyName)
	{
		String sql="select * from ZZ_ZWB where BMMC='"+orgName+"' and ZWMC='"+dutyName+"'";
		ResultSet rs=selectRecord(sql);
		Statement stmt = null;
		try{
			if(rs.next())
				return 0;		 
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
		return 1;
	}

	public void addRec(String personno,String dutyOrgno,String dutyno,String czqx,String lcqx,boolean rebuild)
	{
		ResultSet rs = selectRecord(" select * from zz_zgzwb where zgbh='"+personno+"' and bmbh='"+dutyOrgno+"' and zwbh="+dutyno+" ");
		//System.out.println("Enter Bean!!!!!!!			"+rs);
		Statement stmt = null;
		RightBean rb = null;
		MakeNews news = null;
		try{
			if(!rs.next())
			{
				Vector vect=new Vector();
				vect.add("ZZ_ZGZWB");
				vect.add(addVector("ZGBH",personno,"CHAR"));
				vect.add(addVector("BMBH",dutyOrgno,"CHAR"));
				vect.add(addVector("ZWBH",dutyno,"CHAR"));
				vect.add(addVector("CZQX",czqx,"CHAR"));
				vect.add(addVector("LCQX",lcqx,"CHAR"));
			
				insertRecord(vect);

				if(!rebuild)
					return;

				PublicData.rebuildFlowVector();
				PublicData.rebuildRightVector();

⌨️ 快捷键说明

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