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

📄 menubean.java

📁 运用java+jsp写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
						hash.put("SHOW",show);
						hash.put("COUNT",num);
					}
					else
						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);}
			if(rslr!=null)try{ stmt = rslr.getStatement(); rslr.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}
			if(rscz0!=null)try{ stmt = rscz0.getStatement(); rscz0.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}
			if(rscz1!=null)try{ stmt = rscz1.getStatement(); rscz1.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}
			if(rscz2!=null)try{ stmt = rscz2.getStatement(); rscz2.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}
			if(rscz3!=null)try{ stmt = rscz3.getStatement(); rscz3.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}
			if(rsnum!=null)try{ stmt = rsnum.getStatement(); rsnum.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 Vector getData(String id1)//取得菜单维护表所有记录
	{
		Vector vect = new Vector();
		String
		sql = "select * from menu where id1="+id1+" order by id1,id2,id3",
		sqllr = "select xm,dxbh,menu.id1,menu.id2,menu.id3,menu.zt from zz_fbxwb,zz_zgb,menu where sf='1' and zz_zgb.zgbh<>'1' and menu.id1="+id1+" and zz_fbxwb.zgbh=zz_zgb.zgbh and zz_fbxwb.dxbh=menu.id order by id1,id2,id3,zz_zgb.bmbh,zz_zgb.jbxh",
		sqlcz1 = "select xm,dxbh,menu.id1,menu.id2,menu.id3,menu.zt from zz_fbxwb,zz_zgb,menu where sf='2' and zz_zgb.zgbh<>'1' and menu.id1="+id1+" and cz='1' and zz_fbxwb.zgbh=zz_zgb.zgbh and zz_fbxwb.dxbh=menu.id order by id1,id2,id3,zz_zgb.bmbh,zz_zgb.jbxh",
		sqlcz2 = "select xm,dxbh,menu.id1,menu.id2,menu.id3,menu.zt from zz_fbxwb,zz_zgb,menu where sf='2' and zz_zgb.zgbh<>'1' and menu.id1="+id1+" and cz='2' and zz_fbxwb.zgbh=zz_zgb.zgbh and zz_fbxwb.dxbh=menu.id order by id1,id2,id3,zz_zgb.bmbh,zz_zgb.jbxh",
		sqlcz3 = "select xm,dxbh,menu.id1,menu.id2,menu.id3,menu.zt from zz_fbxwb,zz_zgb,menu where sf='2' and zz_zgb.zgbh<>'1' and menu.id1="+id1+" and cz='3' and zz_fbxwb.zgbh=zz_zgb.zgbh and zz_fbxwb.dxbh=menu.id order by id1,id2,id3,zz_zgb.bmbh,zz_zgb.jbxh",
		sqlcz0 = "select xm,dxbh,menu.id1,menu.id2,menu.id3,menu.zt from zz_fbxwb,zz_zgb,menu where sf='2' and zz_zgb.zgbh<>'1' and menu.id1="+id1+" and cz='0' and zz_fbxwb.zgbh=zz_zgb.zgbh and zz_fbxwb.dxbh=menu.id order by id1,id2,id3,zz_zgb.bmbh,zz_zgb.jbxh",
		sqlnum = "select c.id,count(article.id) from article,menu c where menuid in(select distinct B.id from menu a,menu b where a.id=c.id and b.id1=a.id1 and (b.id2=a.id2 and a.id2<>0 or a.id2=0) and (b.id3=a.id3 and a.id3<>0 or a.id3=0) and b.zt=0 and a.zt=0) and article.ifshow='1' and c.id1="+id1+" group by c.id";//"select menuid,count(article.id) from article,menu where menu.id1="+id1+" and menu.id=article.menuid group by menuid";

		if(!uid.equals("-1")){
			String str = getbmqx(uid);
			if(str.equals(""))
				str="0";
			sql = "select * from menu where id in ("+str+") and id1="+id1+" order by id1,id2,id3";
		}
		ResultSet rs = selectRecord(sql);
		ResultSet rslr = selectRecord(sqllr);
		ResultSet rscz0 = selectRecord(sqlcz0);
		ResultSet rscz1 = selectRecord(sqlcz1);
		ResultSet rscz2 = selectRecord(sqlcz2);
		ResultSet rscz3 = selectRecord(sqlcz3);
		ResultSet rsnum = selectRecord(sqlnum);
		Vector vlr = new Vector(),
				vshow = new Vector(),
				vgood = new Vector(),
				vhead = new Vector(),
				vimg = new Vector(),
				vnum = new Vector();
		Statement stmt = null;
		try{
		while(rslr.next()){
			Hashtable hash = new Hashtable();
			hash.put("XM",rslr.getString("XM"));
			hash.put("ID",rslr.getString("DXBH"));
			vlr.add(hash);
		}
		while(rscz0.next()){
			Hashtable hash = new Hashtable();
			hash.put("XM",rscz0.getString("XM"));
			hash.put("ID",rscz0.getString("DXBH"));
			vshow.add(hash);
		}
		while(rscz1.next()){
			Hashtable hash = new Hashtable();
			hash.put("XM",rscz1.getString("XM"));
			hash.put("ID",rscz1.getString("DXBH"));
			vgood.add(hash);
		}
		while(rscz2.next()){
			Hashtable hash = new Hashtable();
			hash.put("XM",rscz2.getString("XM"));
			hash.put("ID",rscz2.getString("DXBH"));
			vhead.add(hash);
		}
		while(rscz3.next()){
			Hashtable hash = new Hashtable();
			hash.put("XM",rscz3.getString("XM"));
			hash.put("ID",rscz3.getString("DXBH"));
			vimg.add(hash);
		}
		while(rsnum.next()){
			Hashtable hash = new Hashtable();
			hash.put("ID",rsnum.getString(1));
			hash.put("COUNT",rsnum.getString(2));
			vnum.add(hash);
		}
		//取得列数和列名
		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));
				if(field.equals("ADMIN")){
					String lr = "",img = "",good ="",head = "",show = "",num = "";
					String id = (String)hash.get("ID");
					for(int j=0;j<vlr.size();j++){
						if(((Hashtable)vlr.get(j)).get("ID").equals(id))
							if(lr.equals(""))
								lr = (String)((Hashtable)vlr.get(j)).get("XM");
							else lr += ","+(String)((Hashtable)vlr.get(j)).get("XM");
					}
					for(int j=0;j<vshow.size();j++){
						if(((Hashtable)vshow.get(j)).get("ID").equals(id))
							if(show.equals(""))
								show = (String)((Hashtable)vshow.get(j)).get("XM");
							else show += ","+(String)((Hashtable)vshow.get(j)).get("XM");
					}
					for(int j=0;j<vgood.size();j++){
						if(((Hashtable)vgood.get(j)).get("ID").equals(id))
							if(good.equals(""))
								good = (String)((Hashtable)vgood.get(j)).get("XM");
							else good += ","+(String)((Hashtable)vgood.get(j)).get("XM");
					}
					for(int j=0;j<vhead.size();j++){
						if(((Hashtable)vhead.get(j)).get("ID").equals(id))
							if(head.equals(""))
								head = (String)((Hashtable)vhead.get(j)).get("XM");
							else head += ","+(String)((Hashtable)vhead.get(j)).get("XM");
					}
					for(int j=0;j<vimg.size();j++){
						if(((Hashtable)vimg.get(j)).get("ID").equals(id))
							if(img.equals(""))
								img = (String)((Hashtable)vimg.get(j)).get("XM");
							else img += ","+(String)((Hashtable)vimg.get(j)).get("XM");
					}
					for(int j=0;j<vnum.size();j++){
						if(((Hashtable)vnum.get(j)).get("ID").equals(id))
							num = (String)((Hashtable)vnum.get(j)).get("COUNT");
					}
					hash.put("LR",lr);
					hash.put("IMG",img);
					hash.put("GOOD",good);
					hash.put("HEAD",head);
					hash.put("SHOW",show);
					hash.put("COUNT",num);
				}
				else
					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);}
			if(rslr!=null)try{ stmt = rslr.getStatement(); rslr.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}
			if(rscz0!=null)try{ stmt = rscz0.getStatement(); rscz0.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}
			if(rscz1!=null)try{ stmt = rscz1.getStatement(); rscz1.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}
			if(rscz2!=null)try{ stmt = rscz2.getStatement(); rscz2.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}
			if(rscz3!=null)try{ stmt = rscz3.getStatement(); rscz3.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}
			if(rsnum!=null)try{ stmt = rsnum.getStatement(); rsnum.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 Vector getData(String id1,String id2)//取得菜单维护表所有记录
	{
		Vector vect = new Vector();
		String
		sql = "select * from menu where id1="+id1+" and id2="+id2+" order by id1,id2,id3",
		sqllr = "select xm,dxbh,menu.id1,menu.id2,menu.id3,menu.zt from zz_fbxwb,zz_zgb,menu where sf='1' and zz_zgb.zgbh<>'1' and menu.id1="+id1+" and menu.id2="+id2+" and zz_fbxwb.zgbh=zz_zgb.zgbh and zz_fbxwb.dxbh=menu.id order by id1,id2,id3,zz_zgb.bmbh,zz_zgb.jbxh",
		sqlcz1 = "select xm,dxbh,menu.id1,menu.id2,menu.id3,menu.zt from zz_fbxwb,zz_zgb,menu where sf='2' and zz_zgb.zgbh<>'1' and menu.id1="+id1+" and menu.id2="+id2+" and cz='1' and zz_fbxwb.zgbh=zz_zgb.zgbh and zz_fbxwb.dxbh=menu.id order by id1,id2,id3,zz_zgb.bmbh,zz_zgb.jbxh",
		sqlcz2 = "select xm,dxbh,menu.id1,menu.id2,menu.id3,menu.zt from zz_fbxwb,zz_zgb,menu where sf='2' and zz_zgb.zgbh<>'1' and menu.id1="+id1+" and menu.id2="+id2+" and cz='2' and zz_fbxwb.zgbh=zz_zgb.zgbh and zz_fbxwb.dxbh=menu.id order by id1,id2,id3,zz_zgb.bmbh,zz_zgb.jbxh",
		sqlcz3 = "select xm,dxbh,menu.id1,menu.id2,menu.id3,menu.zt from zz_fbxwb,zz_zgb,menu where sf='2' and zz_zgb.zgbh<>'1' and menu.id1="+id1+" and menu.id2="+id2+" and cz='3' and zz_fbxwb.zgbh=zz_zgb.zgbh and zz_fbxwb.dxbh=menu.id order by id1,id2,id3,zz_zgb.bmbh,zz_zgb.jbxh",
		sqlcz0 = "select xm,dxbh,menu.id1,menu.id2,menu.id3,menu.zt from zz_fbxwb,zz_zgb,menu where sf='2' and zz_zgb.zgbh<>'1' and menu.id1="+id1+" and menu.id2="+id2+" and cz='0' and zz_fbxwb.zgbh=zz_zgb.zgbh and zz_fbxwb.dxbh=menu.id order by id1,id2,id3,zz_zgb.bmbh,zz_zgb.jbxh",
		sqlnum = "select c.id,count(article.id) from article,menu c where menuid in(select distinct B.id from menu a,menu b where a.id=c.id and b.id1=a.id1 and (b.id2=a.id2 and a.id2<>0 or a.id2=0) and (b.id3=a.id3 and a.id3<>0 or a.id3=0) and b.zt=0 and a.zt=0) and article.ifshow='1' and c.id1="+id1+" and c.id2="+id2+" group by c.id";//"select menuid,count(article.id) from article,menu where menu.id1="+id1+" and menu.id2="+id2+" and menu.id=article.menuid group by menuid";
		if(!uid.equals("-1")){
			String str = getbmqx(uid);
			if(str.equals(""))
				str="0";
			sql = "select * from menu where id in ("+str+") and id1="+id1+" and id2="+id2+" order by id1,id2,id3";
		}
		ResultSet rs = selectRecord(sql);
		ResultSet rslr = selectRecord(sqllr);
		ResultSet rscz0 = selectRecord(sqlcz0);
		ResultSet rscz1 = selectRecord(sqlcz1);
		ResultSet rscz2 = selectRecord(sqlcz2);
		ResultSet rscz3 = selectRecord(sqlcz3);
		ResultSet rsnum = selectRecord(sqlnum);
		Vector vlr = new Vector(),
				vshow = new Vector(),
				vgood = new Vector(),
				vhead = new Vector(),
				vimg = new Vector(),
				vnum = new Vector();
		Statement stmt = null;
		try{
		while(rslr.next()){
			Hashtable hash = new Hashtable();
			hash.put("XM",rslr.getString("XM"));
			hash.put("ID",rslr.getString("DXBH"));
			vlr.add(hash);
		}
		while(rscz0.next()){
			Hashtable hash = new Hashtable();
			hash.put("XM",rscz0.getString("XM"));
			hash.put("ID",rscz0.getString("DXBH"));
			vshow.add(hash);
		}
		while(rscz1.next()){
			Hashtable hash = new Hashtable();
			hash.put("XM",rscz1.getString("XM"));
			hash.put("ID",rscz1.getString("DXBH"));
			vgood.add(hash);
		}
		while(rscz2.next()){
			Hashtable hash = new Hashtable();
			hash.put("XM",rscz2.getString("XM"));
			hash.put("ID",rscz2.getString("DXBH"));
			vhead.add(hash);
		}
		while(rscz3.next()){
			Hashtable hash = new Hashtable();
			hash.put("XM",rscz3.getString("XM"));
			hash.put("ID",rscz3.getString("DXBH"));
			vimg.add(hash);
		}
		while(rsnum.next()){
			Hashtable hash = new Hashtable();
			hash.put("ID",rsnum.getString(1));
			hash.put("COUNT",rsnum.getString(2));
			vnum.add(hash);
		}
		rsnum.close();
		//取得列数和列名
		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));
				if(field.equals("ADMIN")){
					String lr = "",img = "",good ="",head = "",show = "",num = "";
					String id = (String)hash.get("ID");
					for(int j=0;j<vlr.size();j++){
						if(((Hashtable)vlr.get(j)).get("ID").equals(id))
							if(lr.equals(""))
								lr = (String)((Hashtable)vlr.get(j)).get("XM");
							else lr += ","+(String)((Hashtable)vlr.get(j)).get("XM");
					}
					for(int j=0;j<vshow.size();j++){
						if(((Hashtable)vshow.get(j)).get("ID").equals(id))
							if(show.equals(""))
								show = (String)((Hashtable)vshow.get(j)).get("XM");
							else show += ","+(String)((Hashtable)vshow.get(j)).get("XM");
					}
					for(int j=0;j<vgood.size();j++){
						if(((Hashtable)vgood.get(j)).get("ID").equals(id))
							if(good.equals(""))
								good = (String)((Hashtable)vgood.get(j)).get("XM");
							else good += ","+(String)((Hashtable)vgood.get(j)).get("XM");
					}
					for(int j=0;j<vhead.size();j++){
						if(((Hashtable)vhead.get(j)).get("ID").equals(id))
							if(head.equals(""))
								head = (String)((Hashtable)vhead.get(j)).get("XM");
							else head += ","+(String)((Hashtable)vhead.get(j)).get("XM");
					}
					for(int j=0;j<vimg.size();j++){
						if(((Hashtable)vimg.get(j)).get("ID").equals(id))
							if(img.equals(""))
								img = (String)((Hashtable)vimg.get(j)).get("XM");
							else img += ","+(String)((Hashtable)vimg.get(j)).get("XM");
					}
					for(int j=0;j<vnum.size();j++){
						if(((Hashtable)vnum.get(j)).get("ID").equals(id))
							num = (String)((Hashtable)vnum.get(j)).get("COUNT");
					}
					hash.put("LR",lr);
					hash.put("IMG",img);
					hash.put("GOOD",good);
					hash.put("HEAD",head);
					hash.put("SHOW",show);
					hash.put("COUNT",num);
				}
				else
					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);}
			if(rslr!=null)try{ stmt = rslr.getStatement(); rslr.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}
			if(rscz0!=null)try{ stmt = rscz0.getStatement(); rscz0.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}

⌨️ 快捷键说明

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