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

📄 orgmenubean.java

📁 企业员工信息管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		Hashtable hash = new Hashtable();
		String sql = "";

		sql = "select * from orgmenu  where BH  = "+id+"";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try{
			ResultSetMetaData rsmd = rs.getMetaData();
			int cols = rsmd.getColumnCount();
			if(rs.next())
			{
				for(int i=1;i<=cols;i++)
				{
					String field = ds.toString(rsmd.getColumnName(i));
					String value = ds.toString(rs.getString(i));
					hash.put(field,value);
				}
			}
		}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 hash;
	}

	
	//取得部门名称
	public String getOrgName(String id)
	{
		String sql = "";
		String name = "";
		sql = "select BMMC from zz_bmb where BMBH = '"+id+"'";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try{
			if(rs.next())
			{
				name = ds.toString(rs.getString("BMMC"));
			}
		}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 name;
	}

	//判断是否有子类
	public boolean isChild(String orgid,String pid)
	{
		String sql ="";
		boolean b = false;
		sql ="select * from orgmenu where BMBH = '"+orgid+"' and PBH = "+pid+"";
		ResultSet rs = selectRecord(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;
	}


	//取得当前子类位置
	public String getDetailPath(String orgid,String id)
	{
		String path = "";
		String sql = "";
		path = getOrgName(orgid);
		if(id.equals("")) return path;
		String spath = "";
		while(!id.equals("0"))
		{
			sql = "select * from orgmenu where bh = "+id+"";
			ResultSet rs = selectRecord(sql);
			Statement stmt = null;
			try{
				if(rs.next())
				{
					spath +=ds.toString(rs.getString("MC"))+",";
					id = ds.toString(rs.getString("PBH"));
				}
			}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);}		
			}
		}
		
		String strpath[] = spath.split(",");
		for(int i=strpath.length-1;i>=0;i--)
		{
			path+=">>"+strpath[i];
		}
		return path;
	}


	//初始化数据-----------------------------------------------------------------------------
	public void initialMenu()
	{
		String sql="";
		sql = "select BMBH from ZZ_BMB where BMBH like '%0000000000000000'";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try{
			String strName[] = new String[3];
			strName[0] ="综合信息";
			strName[1] ="公告通知";
			strName[2] ="规章制度";
			while(rs.next())
			{
				String strOrgid = "";
				strOrgid = ds.toString(rs.getString("BMBH"));
				for(int i=0;i<3;i++)
				{
					Hashtable hash =new Hashtable();
					hash.put("PBH","0");
					hash.put("BMBH",strOrgid);
					hash.put("MC",strName[i]);
					hash.put("JBXH","0");
					addMenu(hash);
				}
			}
		}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);}		
		}
	}
	public void initialMenu(String strBMBH)
	{
		String sql="";
		String strName[] = new String[3];
		strName[0] ="综合信息";
		strName[1] ="公告通知";
		strName[2] ="规章制度";

		String strOrgid = ds.toString(strBMBH);
		for(int i=0;i<3;i++)
		{
			Hashtable hash =new Hashtable();
			hash.put("PBH","0");
			hash.put("BMBH",strOrgid);
			hash.put("MC",strName[i]);
			hash.put("JBXH","0");
			addMenu(hash);
		}
	}

	//取得所有信息
	public Vector getClass(String id)
	{
		Vector vect =  new Vector();
		return vect;
	}


	//取得上一级父类信息
	public Hashtable getUpCs(String id)
	{
		Hashtable hash = new Hashtable();
		ResultSet rs = selectRecord("SELECT * FROM ORGMENU WHERE BH in (SELECT BH FROM ORGMENU WHERE BH ="+ id +")");
		Statement stmt = null;
		try{
			ResultSetMetaData rsmd = rs.getMetaData();
			int cols = rsmd.getColumnCount();
			if(rs.next()){
				for(int i=1;i<=cols;i++)
				{
					String field = ds.toString(rsmd.getColumnName(i));
					String value = ds.toString(rs.getString(i));
					hash.put(field,value);
				}
			}
		}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 hash;
	}


	//取得下一级类信息
	public Vector getDownCs(String id)
	{
		Vector vect =  new Vector();
		ResultSet rs = selectRecord("SELECT * FROM ORGMENU WHERE PBH=" + id + " order by JBXH");
		Statement stmt = null;
		try{
			ResultSetMetaData rsmd = rs.getMetaData();
			int cols = rsmd.getColumnCount();
			while(rs.next()){
				Hashtable hash = new Hashtable();
				for(int i=1;i<=cols;i++)
				{
					String field = ds.toString(rsmd.getColumnName(i));
					String value = ds.toString(rs.getString(i));
					hash.put(field,value);
				}
				vect.add(hash);
			}
		}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 vect;
	}
	public String getID1()//取得一级类别名称
	{
		String str = "";
		int pbh=strID;
		Statement stmt = null;
		while(pbh!=0){
			ResultSet rs = selectRecord("SELECT PBH,MC FROM ORGMENU WHERE BH=" + pbh);
			try{
				if(rs.next()){
					str = rs.getString("MC");
					pbh = rs.getInt("PBH");
				}
			}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 str;
	}
	public int getPBH()
	{
		int str=0;
		int pbh=strID;
		Statement stmt = null;
		ResultSet rs = null;
		while(pbh!=0){
			rs = selectRecord("SELECT PBH,BH FROM ORGMENU WHERE BH=" + pbh);
			try{
				if(rs.next()){
					str = rs.getInt("BH");
					pbh = rs.getInt("PBH");
				}
			}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 str;
	}
	public String getPathWithoutOrg()//取得当前子类位置(不含部门名称)
	{
		String path = "";
		String sql = "";
		if(strID==0) return path;
		ResultSet rs = null;
		Statement stmt = null;
		while(strID!=0)
		{
			sql = "select * from orgmenu where bh = "+strID+"";
			rs = selectRecord(sql);
			try{
				if(rs.next())
				{
					path +=ds.toString(rs.getString("MC"))+",";
					strID = rs.getInt("PBH");
				}
			}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);}		
			}
		}
		String strpath[] = path.split(",");
		path="";
		for(int i=strpath.length-1;i>=0;i--)
		{
			path+=strpath[i]+"\\";
		}
		path = path.substring(0,path.length()-1);
		return path;
	}

	public Vector getData(String orgid)//根据部门编号取得此部门下的所有子类的树形结构
	{
		Vector vect = new Vector();
		String sql = "select * from orgmenu where PBH=0 and BMBH='"+orgid+"' order by jbxh";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try{
			ResultSetMetaData rsmd = rs.getMetaData();
			int cols = rsmd.getColumnCount();
			while(rs.next())
			{
				Hashtable hash = new Hashtable();
				for(int i=1;i<=cols;i++)
				{
					String field = ds.toString(rsmd.getColumnName(i));
					String value = ds.toString(rs.getString(i));
					hash.put(field,value);
				}
				vect.add(hash);
				Vector v = new Vector();
				sql = "select * from orgmenu where PBH="+rs.getInt("BH") + " order by jbxh";
				ResultSet rs1 = selectRecord(sql);
				try{
					ResultSetMetaData rsmd1 = rs1.getMetaData();
					int cols1 = rsmd1.getColumnCount();
					while(rs1.next())
					{
						Hashtable hash1 = new Hashtable();
						for(int i=1;i<=cols1;i++)
						{
							String field = ds.toString(rsmd1.getColumnName(i));
							String value = ds.toString(rs1.getString(i));
							hash1.put(field,value);
						}
						v.add(hash1);
					}
					vect.add(v);
				}catch(Exception e){System.out.println("运行时出错:"+e);}
				finally{
					if(rs1!=null)try{ stmt = rs1.getStatement(); rs1.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
					if(stmt!=null)try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
				}
			}
			if(vect.size()==0 && !orgid.equals("")){
				initialMenu(orgid);
				vect=getData(orgid);
			}
		}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 vect;
	}

	public static void main(String args[]) 
	{
		
		OrgMenuBean omb = new OrgMenuBean();
		System.out.println("begin\r\n\r\n");
		Hashtable hash = new Hashtable();

		//hash.put("BH","5");
		hash.put("PBH","4");
		hash.put("BMBH","00020000000000000000");
		hash.put("MC","防毒杀毒");
		hash.put("JBXH","1");
		
		omb.setID(3);
		omb.setParentID(0);
		//omb.setOrgID("00020000000000000000");
		//omb.delMenu();
		//omb.addMenu(hash);
		//System.out.println(omb.buildTree("00010000000000000000").getDepth());
		//System.out.println(omb.getDetailPath("8"));

		System.out.println("\r\n\r\nend");
	}
}

⌨️ 快捷键说明

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