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

📄 departmentbean.java

📁 “JSP数据库项目案例导航”一书从第一章到第十一章各章实例的源程序文件以及数据库文件。 注意: 1. 本书中的案例提供的数据库环境不同
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
			rs = selectRecord(sql);
			try{
				if (rs.next())
					zwmc = ds.toString(rs.getString("ZWMC"));
			}catch(Exception e){System.out.println("DepartmentBean.getAllInf()运行时出错:"+e);}
			finally{
				if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("DepartmentBean.getAllInf()关闭记录集rs时出错"+e);}
				if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("DepartmentBean.getAllInf()关闭声明时statement出错"+e);}		
			}
		}
		ht.put("ZWMC", zwmc);
// added by wangzhen
		if (!glyzwbh.equals("") && glyzwbh != null) {
			sql =
				"select XM from ZZ_ZGB where ZGBH= '"
					+ glyzwbh
					+ "' and BMBH='"
					+ depNo
					+ "'";
			rs = selectRecord(sql);
			try{
				if (rs.next())
					glyxm = ds.toString(rs.getString("XM"));
			}catch(Exception e){System.out.println("DepartmentBean.getAllInf()运行时出错:"+e);}
			finally{
				if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("DepartmentBean.getAllInf()关闭记录集rs时出错"+e);}
				if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("DepartmentBean.getAllInf()关闭声明时statement出错"+e);}		
			}
		}
		ht.put("GLYZWXM", glyxm);

		if (!wszwbh.equals("") && wszwbh != null) {
			sql =
				"select XM from ZZ_ZGB where ZGBH= '"
					+ wszwbh
					+ "' and BMBH='"
					+ depNo
					+ "'";
			rs = selectRecord(sql);
			try{
				if (rs.next())
					wsxm = ds.toString(rs.getString("XM"));
			}catch(Exception e){System.out.println("DepartmentBean.getAllInf()运行时出错:"+e);}
			finally{
				if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("DepartmentBean.getAllInf()关闭记录集rs时出错"+e);}
				if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("DepartmentBean.getAllInf()关闭声明时statement出错"+e);}		
			}
		}
//
		ht.put("WSZWXM", wsxm);

		String[] ckqxMax = null;
		String psName = "";
		String strMax = "";
		if (!ckqxbh.equals("") && ckqxbh != null) {
			ckqxMax = ckqxbh.split(",");
			for (int i = 0; i < ckqxMax.length; i++) {
				sql = "select XM from ZZ_ZGB where ZGBH='" + ckqxMax[i] + "'";
				rs = selectRecord(sql);
				try{
					if (rs.next())
						psName = ds.toString(rs.getString("XM"));
				}catch(Exception e){System.out.println("DepartmentBean.getAllInf()运行时出错:"+e);}
				finally{
					if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("DepartmentBean.getAllInf()关闭记录集rs时出错"+e);}
					if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("DepartmentBean.getAllInf()关闭声明时statement出错"+e);}		
				}
				if (!strMax.equals(""))
					strMax += "," + psName;
				if (strMax.equals(""))
					strMax = psName;
			}
		}
		ht.put("CKQX", strMax);		
		return ht;
	}
	public Hashtable getRootInf() //管理员和文书数据已经汉化
	{
		String sql =
			"select BMMC,TZWBH,GLYZWBH,WSZWBH,CKQX from ZZ_BMB where BMBH='"
				+ depNo
				+ "' and BMFBH is null";
		ResultSet rs = selectRecord(sql);
		ResultSet rs1 = null;
		Statement stmt = null;
		Hashtable ht = null;
		try{
		if (rs.next()) {
			ht = new Hashtable();
			ht.put("BMMC", ds.toString(rs.getString(1)));
			ht.put("GLYZWBH", ds.toString(rs.getString(3)));
			ht.put("WSZWBH", ds.toString(rs.getString(4)));
			ht.put("CKQXBH", ds.toString(rs.getString(5)));
			ht.put("BMFBH", "");
			ht.put("JBXH", "");
			String zwmc = "";
			String glyxm = "";
			String wsxm = "";
			String tzwbh = ds.toString(rs.getString(2));
			String ckqxbh = ds.toString(rs.getString(5));
//
			String glyzwbh = ds.toString(rs.getString(3));
			String wszwbh = ds.toString(rs.getString(4));

			if (!tzwbh.equals("") && tzwbh != null) {
				sql =
					"select ZWMC from ZZ_ZWB where ZWBH="
						+ tzwbh
						+ " and BMBH='"
						+ depNo
						+ "'";
				try{
				rs1 = selectRecord(sql);
				if (rs1.next())
					zwmc = ds.toString(rs1.getString("ZWMC"));
				}catch(Exception e){System.out.println("DepartmentBean.getRootInf()运行时出错:"+e);}
		finally{
			if(rs1!=null)try{ stmt = rs1.getStatement(); rs1.close();}catch(Exception e){System.out.println("DepartmentBean.getRootInf()关闭记录集rs时出错"+e);}
		    if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("DepartmentBean.getRootInf()关闭声明时statement出错"+e);}		
			}
			ht.put("ZWMC", zwmc);

			if (!glyzwbh.equals("") && glyzwbh != null) {
				sql =
					"select XM from ZZ_ZGB where ZGBH= '"
						+ glyzwbh
						+ "' and BMBH='"
						+ depNo
						+ "'";
				try{
				rs1 = selectRecord(sql);
				if (rs1.next())
					glyxm = ds.toString(rs.getString("XM"));
				}catch(Exception e){System.out.println("DepartmentBean.getRootInf()运行时出错:"+e);}
		finally{
			if(rs1!=null)try{ stmt = rs1.getStatement(); rs1.close();}catch(Exception e){System.out.println("DepartmentBean.getRootInf()关闭记录集rs时出错"+e);}
		    if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("DepartmentBean.getRootInf()关闭声明时statement出错"+e);}		
        }
			}
			ht.put("GLYZWXM", glyxm);

			if (!wszwbh.equals("") && wszwbh != null) {
				sql =
					"select XM from ZZ_ZGB where ZGBH="
						+ wszwbh
						+ " and BMBH='"
						+ depNo
						+ "'";
				try{
				rs1 = selectRecord(sql);
				if (rs1.next())
					wsxm = ds.toString(rs.getString("XM"));
				}catch(Exception e){System.out.println("DepartmentBean.getRootInf()运行时出错:"+e);}
		finally{
			if(rs1!=null)try{ stmt = rs1.getStatement(); rs1.close();}catch(Exception e){System.out.println("DepartmentBean.getRootInf()关闭记录集rs时出错"+e);}
		    if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("DepartmentBean.getRootInf()关闭声明时statement出错"+e);}		
        }
			}
			ht.put("WSZWXM", wsxm);

			String[] ckqxMax = null;
			String psName = "";
			String strMax = "";
			if (!ckqxbh.equals("") && ckqxbh != null) {
				ckqxMax = ckqxbh.split(",");
				for (int i = 0; i < ckqxMax.length; i++) {
					sql =
						"select XM from ZZ_ZGB where ZGBH='" + ckqxMax[i] + "'";
				try{
				rs1 = selectRecord(sql);
				if (rs1.next())
						psName = ds.toString(rs.getString("XM"));
				}catch(Exception e){System.out.println("DepartmentBean.getRootInf()运行时出错:"+e);}
		finally{
			if(rs1!=null)try{ stmt = rs1.getStatement(); rs1.close();}catch(Exception e){System.out.println("DepartmentBean.getRootInf()关闭记录集rs时出错"+e);}
		    if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("DepartmentBean.getRootInf()关闭声明时statement出错"+e);}		
        }
					if (!strMax.equals(""))
						strMax += "," + psName;
					if (strMax.equals(""))
						strMax = psName;
				}
			}
			ht.put("CKQX", strMax);
		} 
		}
		}catch(Exception e){System.out.println("DepartmentBean.getRootInf()运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("DepartmentBean.getRootInf()关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("DepartmentBean.getRootInf()关闭声明时statement出错"+e);}		
		}
		return ht;
	}

	public boolean nameExist(String bmname) //判断同一个部门下名称是否重
	{
		boolean bool = false;
		String sql =
			"select BMMC from zz_bmb where BMFBH='"
				+ depNo
				+ "' and BMMC='"
				+ bmname
				+ "'";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try{
			if (rs.next())
				bool = true;
			else
				bool = false;
		}catch(Exception e){System.out.println("DepartmentBean.nameExist(String)运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("DepartmentBean.nameExist(String)关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("DepartmentBean.nameExist(String)关闭声明时statement出错"+e);}		
		}

		return bool;
	}
	//分页时取得一页的数据量
	public Vector getOnePage(int page, int records) {
		String sql =
			"select * from ZZ_ZWB where BMBH='"
				+ depNo
				+ "' order by JBXH";
		return db.getOnePage(sql, page, records);
	}
	//返回某个部门的在职所有人员
	public Vector getOneBMPs(){
		String sql =
			"select XM from ZZ_ZGB where BMBH='" + depNo + "' and ZZZT=0 order by XM";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		Vector oneBmPerson = new Vector();
		try{
			String psName = "";
			while (rs.next()) {
				psName = ds.toString(rs.getString("XM"));
				oneBmPerson.add(psName);
			}
		}catch(Exception e){System.out.println("DepartmentBean.getOneBMPs()运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("DepartmentBean.getOneBMPs()关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("DepartmentBean.getOneBMPs()关闭声明时statement出错"+e);}		
		}
		return oneBmPerson;
	}
//	//返回某个部门的在职所有人员及职工编号  (added by wangzhen)
	public Vector getOneBMPsBH(){
		String sql =
			"select ZGBH,XM from ZZ_ZGB where BMBH='" + depNo + "' and ZZZT=0 order by XM";
		ResultSet rs = selectRecord(sql);
		Vector oneBmPerson = new Vector();
		String psName = "";
		Statement stmt = null;
		try{
		while (rs.next()) {
			psName = ds.toString(rs.getString("ZGBH"));
			oneBmPerson.add(psName);
		}
		}catch(Exception e){System.out.println("DepartmentBean.getOneBMPsBH()运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("DepartmentBean.getOneBMPsBH()关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("DepartmentBean.getOneBMPsBH()关闭声明时statement出错"+e);}		
		}
		return oneBmPerson;
	}
	public String getBMBH(String strPersonNO)//取得当前人员所在部门的部门编号new
	{
		String sql = "";
		String name = "";
		sql = " select BMBH from ZZ_ZGB where ZGBH = '"+strPersonNO+"'";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try{
			if(rs.next())
					name = ds.toString(rs.getString("BMBH"));
		}catch(Exception e){System.out.println("DepartmentBean.getBMBH(String)运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("DepartmentBean.getBMBH(String)关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("DepartmentBean.getBMBH(String)关闭声明时statement出错"+e);}		
		}
		return name;
	}
	public String isWho(String zgbh)
	{//判断当前人员的身份new
		String bmno = getBMBH(zgbh);
		String sql = "";
		String admin="",ws="";
		if(bmno!=null && !bmno.equals(""))
			sql = " select GLYZWBH,WSZWBH from ZZ_BMB where BMBH = '"+bmno+"'";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try{
			if(rs.next())
			{
				admin = ds.toString(rs.getString("GLYZWBH"));
				ws = ds.toString(rs.getString("WSZWBH"));
				if(admin.equals(zgbh) || (admin.equals(zgbh) && ws.equals(zgbh)))
				{
					return "bmadmin";
				}
				else if(ws.equals(zgbh))
				{
					return "bmws";
				}
			}
		}catch(Exception e){System.out.println("DepartmentBean.isWho(String)运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("DepartmentBean.isWho(String)关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("DepartmentBean.isWho(String)关闭声明时statement出错"+e);}		
		}
		return "person";
	}

	public String getOrgNo(String bmbh){ //取得二级部门编号
		String org = bmbh.substring(0,4);
		for(int i=0;i<16;i++)
			org = org+"0";
		return org;
	}

	public int unit(String strDepA,String strDepB)
	{
		try{
			String sql = "update ZZ_ZGB set BMBH='"+strDepB+"' where BMBH='"+strDepA+"'";
			executeUpdate(sql);

			if(!strDepA.substring(0,4).equals(strDepB.substring(0,4)))//当两个部门是不同的二级部门时删除职务
			{
				sql = "delete from ZZ_ZGZWB where BMBH='"+strDepA+"'";
				executeUpdate(sql);
			}
		}
		catch(Exception e){}
		finally{
		}
		return 0;
	}

	public static void main(String[] args) {
		System.out.println("Hello World!");
		try {
			Hashtable ht = new Hashtable();
			ht.put("BMFBH", "00020000000000000000");
			ht.put("BMMC", "财会室");
			ht.put("JBXH", "3");
			ht.put("TZWBH", "");
			ht.put("GLYZWBH", "");
			ht.put("WSZWBH", "");
			ht.put("BMBH", "00020200000000000000");
			DealString ds = new DealString();

			DepartmentBean dpartbn = new DepartmentBean();
			//System.out.println(dpartbn.addRec(ht));
			dpartbn.buildSelectedBMTree("1155");
		} catch (Exception e) {
		}

	}

}

⌨️ 快捷键说明

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