📄 mainbean.java
字号:
{
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("MainBean.getPicNew()运行时出错:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("MainBean.getPicNew()关闭记录集rs时出错"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("MainBean.getPicNew()关闭声明时statement出错"+e);}
}
return vect;
}
//取得某一版面的首页图片新闻----------------------------------------------------------
public Vector getPicNew(String id)
{
//检索菜单表编号
String sql = "select num from nb_zyszb where id="+id;
ResultSet rs = selectRecord(sql);
Statement stmt = null;
Vector v_article = new Vector();
try{
int num = 0;
if(rs.next())
num = rs.getInt(1);
//if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("MainBean.getPicNew(String id)关闭记录集rs时出错"+e);}
//if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("MainBean.getPicNew(String id)关闭声明时statement出错"+e);}
sql = "select ID from Menu where id3<>0 and Id1="+id;
rs = selectRecord(sql);
Vector v_menu = new Vector();
while(rs.next())
{
v_menu.add(rs.getString("ID"));
}
//if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("MainBean.getPicNew(String id)关闭记录集rs时出错"+e);}
//if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("MainBean.getPicNew(String id)关闭声明时statement出错"+e);}
if(v_menu.isEmpty()) return v_menu;
//检索子菜单表编号
sql = "select ID from menuchild where isthis=0 and IDPARENT in (select ID from Menu where id3<>0 and Id1="+id+")";
stmt = rs.getStatement(); rs.close();stmt.close();
rs = selectRecord(sql);
Vector v_child = new Vector();
while(rs.next())
{
String id4 = rs.getString("ID");
v_child.add(id4);
Stack s4 = new Stack();
s4.push(id4);
while(!s4.empty())//当有孩子节点时继续搜索
{
id4 = (String)s4.pop();
sql = "select count(id) from menuchild where isthis=1 and IDPARENT="+id4;
ResultSet rs4 = selectRecord(sql);
try{
int count = 0;
if(rs4.next())
count = rs4.getInt(1);
if(count>0)
{
sql = "select id from menuchild where isthis=1 and IDPARENT="+id4;
ResultSet rs_t = selectRecord(sql);
try{
while(rs_t.next())
{
String id_t = rs_t.getString("id");
s4.push(id_t);
v_child.add(id_t);
}
}catch(Exception e){System.out.println("MainBean.getPicNew(String id)运行时出错:"+e);}
finally{
//if(rs_t!=null)try{ stmt = rs_t.getStatement(); rs_t.close();}catch(Exception e){System.out.println("MainBean.getPicNew(String id)关闭记录集rs时出错"+e);}
//if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("MainBean.getPicNew(String id)关闭声明时statement出错"+e);}
}
}
}catch(Exception e){System.out.println("MainBean.getPicNew(String id)运行时出错:"+e);}
finally{
if(rs4!=null)try{ stmt = rs4.getStatement(); rs4.close();}catch(Exception e){System.out.println("MainBean.getPicNew(String id)关闭记录集rs时出错"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("MainBean.getPicNew(String id)关闭声明时statement出错"+e);}
}
}
}
//if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("MainBean.getPicNew(String id)关闭记录集rs时出错"+e);}
//if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("MainBean.getPicNew(String id)关闭声明时statement出错"+e);}
//检索文章编号
sql = "";
for(int i=0;i<v_menu.size();i++)
{
//if(!sql.equals(""))sql += " union ";
//sql += "select id from article where whichtable='1' and ifshow='1' and IFIMG='1' and ifhead ='1' and ORGANID='00000000000000000000' and menuid="+(String)v_menu.get(i);
if(!sql.equals(""))sql += ",";
sql += (String)v_menu.get(i);
}
for(int i=0;i<v_child.size();i++)
{
//if(!sql.equals(""))sql += " union ";
//sql += "select id from article where whichtable='0' and ifshow='1' and IFIMG='1' and ifhead ='1' and ORGANID='00000000000000000000' and menuid="+(String)v_child.get(i);
if(!sql.equals(""))sql += ",";
sql += (String)v_menu.get(i);
}
sql = "select id from article where whichtable='1' and ifshow='1' and IFIMG='1' and ifhead ='1' and ORGANID='00000000000000000000' and menuid in ("+sql+")";
sql = "select id,title,addtime,hits,img from article where id in ("+sql+") order by edittime desc";
rs = selectRecord(sql);
int i = 0;
ResultSetMetaData rsmd = rs.getMetaData();
int cols = 0;
cols = rsmd.getColumnCount();
while(rs.next())
{
Hashtable hash = new Hashtable();
for(i=1;i<=cols;i++)
{
String field = ds.toString(rsmd.getColumnName(i));
String value = ds.toString(rs.getString(i));
hash.put(field,value);
}
v_article.add(hash);//把焦点文章信息存入
}
}catch(Exception e){System.out.println("MainBean.getPicNew(String id)运行时出错:"+e);}
finally{
//if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("MainBean.getPicNew(String id)关闭记录集rs时出错"+e);}
//if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("MainBean.getPicNew(String id)关闭声明时statement出错"+e);}
}
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("MainBean.getPicNew(String id)关闭记录集rs时出错"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("MainBean.getPicNew(String id)关闭声明时statement出错"+e);}
return v_article;
}
//设置默认Css格式时,修改数据表
public void setMrCss(String cssstyle)
{
String sql = "";
sql = "update NB_YSB set ISNOW=0 where STYLE!='"+cssstyle+"'";
deleteRecord(sql);
sql = "update NB_YSB set ISNOW=1 where STYLE='"+cssstyle+"'";
deleteRecord(sql);
}
//取得显示图片新闻的数目-----------------------------------------------------------------
public int getPicNum()
{
String sql = "";
String s = "0";
sql = "select NUM from NB_TPSZB";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try{
if(rs.next())
{
s= ds.toString(rs.getString("NUM"));
}
}catch(Exception e){System.out.println("MainBean.getPicNum()运行时出错:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("MainBean.getPicNum()关闭记录集rs时出错"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("MainBean.getPicNum()关闭声明时statement出错"+e);}
}
return Integer.parseInt(s);
}
//取得显示图片新闻的高度-----------------------------------------------------------------
public int getPicHeight()
{
String sql = "";
String s ="0";
sql = "select HEIGHT from NB_TPSZB";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try{
if(rs.next())
{
s= ds.toString(rs.getString("HEIGHT"));
}
}catch(Exception e){System.out.println("MainBean.getPicHeight()运行时出错:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("MainBean.getPicHeight()关闭记录集rs时出错"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("MainBean.getPicHeight()关闭声明时statement出错"+e);}
}
return Integer.parseInt(s);
}
//取得显示图片新闻的宽度----------------------------------------------------------------
public int getPicWidth()
{
String sql = "";
String s = "0";
sql = "select WIDTH from NB_TPSZB";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try{
if(rs.next())
{
s = ds.toString(rs.getString("WIDTH"));
}
}catch(Exception e){System.out.println("MainBean.getPicWidth()运行时出错:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("MainBean.getPicWidth()关闭记录集rs时出错"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("MainBean.getPicWidth()关闭声明时statement出错"+e);}
}
return Integer.parseInt(s);
}
//取得所有公开的专题
public Vector getTopic()
{
Vector vect = new Vector();
String sql = "";
sql = "select * from NB_TOPIC where STATUS = 0 order by edittime desc";
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);
}
}catch(Exception e){System.out.println("MainBean.getTopic()运行时出错:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("MainBean.getTopic()关闭记录集rs时出错"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("MainBean.getTopic()关闭声明时statement出错"+e);}
}
return vect;
}
//取得某一版面下的公开的专题
public Vector getTopic(String muname)
{
Vector vect = new Vector();
String sql = "";
int menuid1 = toID("MENU","MENU1","ID1",muname);
sql = "select * from NB_TOPIC where STATUS = 0 and MENUID1="+menuid1+" 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);
}
}catch(Exception e){System.out.println("MainBean.getTopic(String muname)运行时出错:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("MainBean.getTopic(String muname)关闭记录集rs时出错"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("MainBean.getTopic(String muname)关闭声明时statement出错"+e);}
}
return vect;
}
//取得一级版面下的设置显示的新闻条数-----------------------------------------------------------------
public int getNewsNum(String i)
{
String sql = "";
int num = 0;
sql = "select NUM from NB_ZYSZB where ID = "+i+"";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try{
if(rs.next())
{
String str = ds.toString(rs.getString("NUM"));
num = Integer.parseInt(str);
}
}catch(Exception e){System.out.println("MainBean.getNewsNum(String i)运行时出错:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("MainBean.getNewsNum(String i)关闭记录集rs时出错"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("MainBean.getNewsNum(String i)关闭声明时statement出错"+e);}
}
return num;
}
//取得一级版面的新闻后面是否显示时间----------------------------------------------------------------
public boolean isShowTime(String i)
{
String sql = "";
String str = "";
sql = "select ISSHOWTIME from NB_ZYSZB where ID = "+i+"";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try{
if(rs.next())
{
str = ds.toString(rs.getString("ISSHOWTIME"));
}
}catch(Exception e){System.out.println("MainBean.isShowTime(String i)运行时出错:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("MainBean.isShowTime(String i)关闭记录集rs时出错"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("MainBean.isShowTime(String i)关闭声明时statement出错"+e);}
}
if(str.equals("1"))
return true;
else
return false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -