📄 menubean.java
字号:
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 a,String b,String c)//取得菜单维护表中满足条件的所有记录
{
String sql = "",sqllr = "",sqlcz0 = "",sqlcz1 = "",sqlcz2 = "",sqlcz3 = "";
if(a.equals("")&&b.equals("")&&c.equals(""))
{
sql = "select * from menu where id2=0 and id3=0 order by id1";
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.id2=0 and menu.id3=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";
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.id2=0 and menu.id3=0 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.id2=0 and menu.id3=0 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.id2=0 and menu.id3=0 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.id2=0 and menu.id3=0 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";
if(!uid.equals("-1")){
String str = getbmqx(uid);
if(str.equals(""))
str="0";
sql = "select * from menu where id in ("+str+") and id2=0 and id3=0 order by id1,id2,id3";
}
}
else if(b.equals("")&&c.equals(""))
{
sql = "select * from menu where id1="+Integer.parseInt(a)+" and id3=0 and id2<>0 order by id2";
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="+Integer.parseInt(a)+" and menu.id3=0 and menu.id2<>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";
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="+Integer.parseInt(a)+" and menu.id3=0 and menu.id2<>0 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="+Integer.parseInt(a)+" and menu.id3=0 and menu.id2<>0 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="+Integer.parseInt(a)+" and menu.id3=0 and menu.id2<>0 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="+Integer.parseInt(a)+" and menu.id3=0 and menu.id2<>0 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";
if(!uid.equals("-1")){
String str = getbmqx(uid);
if(str.equals(""))
str="0";
sql = "select * from menu where id in ("+str+") and id1="+Integer.parseInt(a)+" and id3=0 and id2<>0 order by id1,id2,id3";
}
}
else if(c.equals(""))
{
sql = "select * from menu where id1="+Integer.parseInt(a)+" and id2="+Integer.parseInt(b)+" and id3<>0 order by 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="+Integer.parseInt(a)+" and menu.id2="+Integer.parseInt(b)+" and menu.id3<>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";
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="+Integer.parseInt(a)+" and menu.id2="+Integer.parseInt(b)+" and menu.id3<>0 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="+Integer.parseInt(a)+" and menu.id2="+Integer.parseInt(b)+" and menu.id3<>0 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="+Integer.parseInt(a)+" and menu.id2="+Integer.parseInt(b)+" and menu.id3<>0 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="+Integer.parseInt(a)+" and menu.id2="+Integer.parseInt(b)+" and menu.id3<>0 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";
if(!uid.equals("-1")){
String str = getbmqx(uid);
if(str.equals(""))
str="0";
sql = "select * from menu where id in ("+str+") and id1="+Integer.parseInt(a)+" and id2="+Integer.parseInt(b)+" and id3<>0 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);
Vector vect = new Vector();
Vector vlr = new Vector(),
vshow = new Vector(),
vgood = new Vector(),
vhead = new Vector(),
vimg = 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);
}
//取得列数和列名
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 = "";
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");
}
hash.put("LR",lr);
hash.put("IMG",img);
hash.put("GOOD",good);
hash.put("HEAD",head);
hash.put("SHOW",show);
}
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);}
}
return vect;
}
public Hashtable getOneData()//取得一条记录的信息
{
Hashtable ht = new Hashtable();
String sql = "";
sql = "select * from menu where ID="+strID+"";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try{
ResultSetMetaData rsmd = rs.getMetaData();
int cols = rsmd.getColumnCount();
while(rs.next())
{
for(int i=1;i<=cols;i++)
{
String field = ds.toString(rsmd.getColumnName(i));
String value = ds.toString(rs.getString(i));
ht.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 ht;
}
public boolean getOneData(String a,String b,String c) //判断是否有满足条件的记录
{
int intID1 = Integer.parseInt(a);
int intID2 = Integer.parseInt(b);
int intID3 = Integer.parseInt(c);
String sql = "select * from menu where id1="+intID1+" and id2="+intID2+" and id3="+intID3+" and id!="+strID;
ResultSet rs = selectRecord(sql);
Statement stmt = null;
boolean bo = false;
try{
if(rs.next()) {bo= 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 bo;
}
public int addMenu(Hashtable hash)//增加菜单维护表数据记录
{
String sql = "";
int intMax = db.makeID("MENU","ID","","",true);
String strID1 = ds.toString((String)hash.get("ID1"));
String strID2 = ds.toString((String)hash.get("ID2"));
String strID3 = ds.toString((String)hash.get("ID3"));
String strMenu1 = ds.toString((String)hash.get("MENU1"));
String strMenu2 = ds.toString((String)hash.get("MENU2"));
String strMenu3 = ds.toString((String)hash.get("MENU3"));
String strAdmin = ds.toString((String)hash.get("ADMIN"));
String strIntro = ds.toString((String)hash.get("INTRODUCE"));
String strAct = ds.toString((String)hash.get("ACT"));
String strzt = ds.toString((String)hash.get("ZT"));
if(strzt.equals(""))
strzt = "0";
String strstyle = ds.toString((String)hash.get("STYLE"));
Vector vect =new Vector();
vect.add("MENU");
vect.add(addVector("ID",String.valueOf(intMax),"NUM"));
if(strAct.equals("1"))
{
if(getOneData(strID1,"0","0"))
{
sql = "update menu set id1=id1+1 where id1>="+Integer.parseInt(strID1);
db.ExecuteSQL(sql);
}
else
strID1 = ""+makeID("MENU","ID1","","",true);
vect.add(addVector("ID1",strID1,"NUM"));
vect.add(addVector("MENU1",strMenu1,"CHAR"));
vect.add(addVector("ADMIN",strAdmin,"CHAR"));
vect.add(addVector("INTRODUCE",strIntro,"CHAR"));
vect.add(addVector("ZT",strzt,"CHAR"));
vect.add(addVector("STYLE",strstyle,"NUM"));
//给管理员新增版面权限
if(strzt.equals("0"))//正常
{
MakeNews mnbean = null;
try{
mnbean = new MakeNews();
Hashtable hash_t = new Hashtable();
hash_t.put("ZGBH","1");
hash_t.put("LB","1");
hash_t.put("DXBH",String.valueOf(intMax));
hash_t.put("SF","2");
hash_t.put("CZ","0");
hash_t.put("WHICHTALBE","1");
hash_t.put("BMBH","");
hash_t.put("SFGL","");
int ii = mnbean.addNews(hash_t);
hash_t.clear();
hash_t.put("ZGBH","1");
hash_t.put("LB","1");
hash_t.put("DXBH",String.valueOf(intMax));
hash_t.put("SF","2");
hash_t.put("CZ","1");
hash_t.put("WHICHTALBE","1");
hash_t.put("BMBH","");
hash_t.put("SFGL","");
ii = mnbean.addNews(hash_t);
hash_t.clear();
hash_t.put("ZGBH","1");
hash_t.put("LB","1");
hash_t.put("DXBH",String.valueOf(intMax));
hash_t.put("SF","2");
hash_t.put("CZ","2");
hash_t.put("WHICHTALBE","1");
hash_t.put("BMBH","");
hash_t.put("SFGL","");
ii = mnbean.addNews(hash_t);
hash_t.clear();
hash_t.put("ZGBH","1");
hash_t.put("LB","1");
hash_t.put("DXBH",String.valueOf(intMax));
hash_t.put("SF","2");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -