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

📄 makenews.java

📁 企业员工信息管理系统
💻 JAVA
字号:

package oa.bean;

import java.text.*;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.sql.*;
import oa.main.*;
import javax.swing.tree.DefaultMutableTreeNode;

public class MakeNews extends ParentBean
{
	int strID=-1;//新闻发表唯一编号


	public void setID(int o)//设置新闻发表唯一编号
	{
		strID = o;
	}

	public int addNews(Hashtable hash)//增加新闻发表维护表数据记录
	{
		int intMax = db.makeID("ZZ_FBXWB","ID","","",true);
		String zgbh = ds.toString((String)hash.get("ZGBH"));
		String lb   = ds.toString((String)hash.get("LB"));
		String dxbh = ds.toString((String)hash.get("DXBH"));
		String sf   = ds.toString((String)hash.get("SF"));
		String cz   = ds.toString((String)hash.get("CZ"));
		String whichtable = ds.toString((String)hash.get("WHICHTALBE"));
		String bmbh = ds.toString((String)hash.get("BMBH"));
		String sfgl = ds.toString((String)hash.get("SFGL"));

		Vector vect =new Vector();
		vect.add("ZZ_FBXWB");
		vect.add(addVector("ID",String.valueOf(intMax),"NUM"));
		vect.add(addVector("ZGBH",zgbh,"CHAR"));
		vect.add(addVector("LB",lb,"CHAR"));
		vect.add(addVector("DXBH",dxbh,"NUM"));
		vect.add(addVector("SF",sf,"CHAR"));
		vect.add(addVector("CZ",cz,"CHAR"));
		vect.add(addVector("WHICHTABLE",whichtable,"CHAR"));
		vect.add(addVector("BMBH",bmbh,"CHAR"));
		vect.add(addVector("SFGL",sfgl,"CHAR"));

		return insertRecord(vect);
	}



	
	public int modNews(Hashtable hash)//修改新闻发表维护表数据记录
	{
		String zgbh = ds.toString((String)hash.get("ZGBH"));
		String lb   = ds.toString((String)hash.get("LB"));
		String dxbh = ds.toString((String)hash.get("DXBH"));
		String sf   = ds.toString((String)hash.get("SF"));
		String cz   = ds.toString((String)hash.get("CZ"));
		String whichtable = ds.toString((String)hash.get("WHICHTALBE"));
		String bmbh = ds.toString((String)hash.get("BMBH"));
		String sfgl = ds.toString((String)hash.get("SFGL"));

		Vector vect =new Vector();
		vect.add("ZZ_FBXWB");
		vect.add(addVector("ZGBH",zgbh,"CHAR"));
		vect.add(addVector("LB",lb,"CHAR"));
		vect.add(addVector("DXBH",dxbh,"NUM"));
		vect.add(addVector("SF",sf,"CHAR"));
		vect.add(addVector("CZ",cz,"CHAR"));
		vect.add(addVector("WHICHTABLE",whichtable,"CHAR"));
		vect.add(addVector("BMBH",bmbh,"CHAR"));
		vect.add(addVector("SFGL",sfgl,"CHAR"));		

		vect.add("ID="+strID+"");		
		return updateRecord(vect);
	}

	public int delNews() //删除新闻发表维护表数据记录
	{
		String sql="";		
		sql = "delete from ZZ_FBXWB where ID = "+strID+"";
		
		return deleteRecord(sql);
	}

	public Hashtable getbmqx(String uid)//获得个人有管理员权限的所有版面 
	{
		String showqx1 = "";//所有可审批的位于menu表中的版面
		String showqx2 = "";//所有可审批的位于menuchild表中的版面
		String imgqx1 = "";//所有可审批图片的位于menu表中的版面
		String imgqx2 = "";//所有可审批图片的位于menuchild表中的版面
		String headqx1 = "";//所有可审批首页的位于menu表中的版面
		String headqx2 = "";//所有可审批首页的位于menuchild表中的版面
		String goodqx1 = "";//所有可审批焦点的位于menu表中的版面
		String goodqx2 = "";//所有可审批焦点的位于menuchild表中的版面

		Hashtable ht = new Hashtable();
		MenuBean mb = null;

		String sql = "select dxbh,cz,whichtable from zz_fbxwb where zgbh='"+uid+"' and lb='1' and sf='2' ";

		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try{
			mb = new MenuBean();
		while(rs.next())
		{
			String dxbh = ds.toString(rs.getString(1));
			String cz = ds.toString(rs.getString(2));
			String whichtable = ds.toString(rs.getString(3));
			String str1 = "";//保存中间结果
			String str2 = "";//保存中间结果
			String sql_1 = "";
			ResultSet rs_1 = null;
			if(whichtable.equals("1"))//在menu表中
			{
				sql_1 = "select id,id1,id2,id3 from menu where id = "+dxbh;
				rs_1 = selectRecord(sql_1);
				String id1="",id2="",id3 = "";
				try{
					if(rs_1.next()){
						id1 = ds.toString(rs_1.getString(2));
						id2 = ds.toString(rs_1.getString(3));
						id3 = ds.toString(rs_1.getString(4));
					}
				}catch(Exception e){System.out.println("运行时出错:"+e);}
				finally{
					if(rs_1!=null)try{ stmt = rs_1.getStatement(); rs_1.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
					if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
				}
				if(id2.equals("0"))//一级菜单
				{
					sql_1 = "select id from menu where id1='"+id1+"'";
					rs_1 = selectRecord(sql_1);
					try{
						while(rs_1.next())
						{
							if(!str1.equals(""))
							{
								str1 = str1 + ",";
							}
							str1 = str1 + ds.toString(rs_1.getString(1));
						}
					}catch(Exception e){System.out.println("运行时出错:"+e);}
					finally{
						if(rs_1!=null)try{ stmt = rs_1.getStatement(); rs_1.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
						if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
					}
					
					sql_1 = "select id from menuchild where idparent in ("+str1+") and isthis='0'";
					rs_1 = selectRecord(sql_1);
					try{
						while(rs_1.next())
						{
							if(!str2.equals(""))
							{
								str2 = str2 + ",";
							}
							str2 = str2 + ds.toString(rs_1.getString(1));
						}
					}catch(Exception e){System.out.println("运行时出错:"+e);}
					finally{
						if(rs_1!=null)try{ stmt = rs_1.getStatement(); rs_1.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
						if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
					}
				}
				if(id3.equals("0")&&!id2.equals("0"))//二级菜单
				{
					sql_1 = "select id from menu where id1='"+id1+"' and id2='"+id2+"'";
					rs_1 = selectRecord(sql_1);
					try{
						while(rs_1.next())
						{
							if(!str1.equals(""))
							{
								str1 = str1 + ",";
							}
							str1 = str1 + ds.toString(rs_1.getString(1));
						}
					}catch(Exception e){System.out.println("运行时出错:"+e);}
					finally{
						if(rs_1!=null)try{ stmt = rs_1.getStatement(); rs_1.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
						if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
					}
					
					sql_1 = "select id from menuchild where idparent in ("+str1+") and isthis='0'";
					rs_1 = selectRecord(sql_1);
					try{
						while(rs_1.next())
						{
							if(!str2.equals(""))
							{
								str2 = str2 + ",";
							}
							str2 = str2 + ds.toString(rs_1.getString(1));
						}
					}catch(Exception e){System.out.println("运行时出错:"+e);}
					finally{
						if(rs_1!=null)try{ stmt = rs_1.getStatement(); rs_1.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
						if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
					}
				}
				if(!id3.equals("0"))//三级菜单
				{				
					if(!str1.equals(""))
					{
						str1 = str1 + ",";
					}
					str1 = str1 + dxbh;					
					
					sql_1 = "select id from menuchild where idparent in ("+str1+") and isthis='0'";
					rs_1 = selectRecord(sql_1);
					try{
						while(rs_1.next())
						{
							if(!str2.equals(""))
							{
								str2 = str2 + ",";
							}
							str2 = str2 + ds.toString(rs_1.getString(1));
						}
					}catch(Exception e){System.out.println("运行时出错:"+e);}
					finally{
						if(rs_1!=null)try{ stmt = rs_1.getStatement(); rs_1.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
						if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
					}
				}
				if(!showqx1.equals(""))
				{
					showqx1 = showqx1 + ",";
				}
				showqx1 = showqx1 + str1;

				if(!showqx2.equals(""))
				{
					showqx2 = showqx2 + ",";
				}
				showqx2 = showqx2 + str2;


				if(cz.equals("1"))//审焦点
				{
					if(!goodqx1.equals(""))
					{
						goodqx1 = goodqx1 + ",";
					}
					goodqx1 = goodqx1 + str1;

					if(!goodqx2.equals(""))
					{
						goodqx2 = goodqx2 + ",";
					}
					goodqx2 = goodqx2 + str2;
				}
				if(cz.equals("2"))//审首页
				{
					if(!headqx1.equals(""))
					{
						headqx1 = headqx1 + ",";
					}
					headqx1 = headqx1 + str1;

					if(!headqx2.equals(""))
					{
						headqx2 = headqx2 + ",";
					}
					headqx2 = headqx2 + str2;
				}
				if(cz.equals("3"))//审图片
				{
					if(!imgqx1.equals(""))
					{
						imgqx1 = imgqx1 + ",";
					}
					imgqx1 = imgqx1 + str1;

					if(!imgqx2.equals(""))
					{
						imgqx2 = imgqx2 + ",";
					}
					imgqx2 = imgqx2 + str2;
				}
			}
			if(whichtable.equals("2"))//menuchild表中
			{
				str2 = dxbh;

				if(!showqx2.equals(""))
				{
					showqx2 = showqx2 + ",";
				}
				showqx2 = showqx2 + str2;

				if(cz.equals("1"))//审焦点
				{
					if(!goodqx2.equals(""))
					{
						goodqx2 = goodqx2 + ",";
					}
					goodqx2 = goodqx2 + str2;
				}
				if(cz.equals("2"))//审首页
				{
					if(!headqx2.equals(""))
					{
						headqx2 = headqx2 + ",";
					}
					headqx2 = headqx2 + str2;
				}
				if(cz.equals("3"))//审图片
				{
					if(!imgqx2.equals(""))
					{
						imgqx2 = imgqx2 + ",";
					}
					imgqx2 = imgqx2 + str2;
				}
			}			
		}
		}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(mb!=null)mb.closeConn();
		}
		ht.put("SHOW1",showqx1);
		ht.put("SHOW2",showqx2);
		ht.put("IMG1",imgqx1);
		ht.put("IMG2",imgqx2);
		ht.put("HEAD1",headqx1);
		ht.put("HEAD2",headqx2);
		ht.put("GOOD1",goodqx1);
		ht.put("GOOD2",goodqx2);
		return ht;
	}

	//取得某人所有版面权限的ID号
	public Vector getData(String zgbh)
	{
		Vector vect = new Vector();
		String sql = "select ID from ZZ_FBXWB where ZGBH='"+zgbh+"'";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try{
		while(rs.next())
		{
			String id = ds.toString(rs.getString(1));
			vect.add(id);
		}
		}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 Hashtable getOneData()
	{
		Hashtable hash = new Hashtable();
		String sql = "select * from ZZ_FBXWB where ID="+strID+"";
		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;
	}

	//判断是否有满足条件的记录 -1:无, id:有,并且删除这条纪录
	public int hasSuchData(String zgbh,String bmbh,String sf,String cz,String wt)
	{
		int id = -1;
		String sql = "";
		String strcz = ds.toString(cz);  //(CZ is null or CZ='"+cz+"')
		if(strcz.equals(""))
			sql = "select ID from ZZ_FBXWB where ZGBH='"+zgbh+"' and LB='1' and DXBH="+bmbh+" and SF='"+sf+"' and CZ is null and WHICHTABLE='"+wt+"'";
		else
			sql = "select ID from ZZ_FBXWB where ZGBH='"+zgbh+"' and LB='1' and DXBH="+bmbh+" and SF='"+sf+"' and CZ='"+strcz+"' and WHICHTABLE='"+wt+"'";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try{
		if(rs.next())
		{
			id = rs.getInt(1);
			//setID(rs.getInt(1));
			//int ii = delNews();			
		}
		}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 id;
	}
	
	public static void main(String args[]) 
	{
		MakeNews mb = new MakeNews();
		System.out.println("begin\r\n\r\n");
		//mb.setID(1);
		
		System.out.println("\r\n\r\nend");
	}
}

⌨️ 快捷键说明

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