?? persondutybean.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 PersonDutyBean extends ParentBean
{
String PersonNo="";//職工編號
String DutyOrgNo="";//職務(wù)部門編號
String DutyNo="";//職務(wù)編號
//構(gòu)造函數(shù)
public PersonDutyBean()
{
}
//設(shè)置部門編號
public void setDutyOrgNo(String DutyOrgNo)
{
this.DutyOrgNo = DutyOrgNo;
}
//設(shè)置職工編號
public void setPersonNo(String PersonNo)
{
this.PersonNo = PersonNo;
}
//通過部門編號得到部門名稱
public String getOrgName(String strOrgNo)
{
return toName("ZZ_BMB","BMBH","BMMC",strOrgNo);
}
public Vector getBMMC(String strPersonNo)//通過職工編號得到ZZ_ZGZWB的所有BMMC記錄
{
Vector vt = new Vector();
String sql = "";
String bmbh = "";
String bmName = "";
sql = "select BMBH from ZZ_ZGZWB where ZGBH='"+strPersonNo+"' order by BMBH";
ResultSet rs = selectRecord(sql);
ResultSet rst = null;
Statement stmt = null;
try{
while(rs.next())
{
String bmbh1 = ds.toString(rs.getString("BMBH"));
if(bmbh1.equals(bmbh))
{
continue;
}
else
{
bmbh = bmbh1;
sql = "select BMMC from ZZ_BMB where BMBH='"+bmbh+"'";
rst = selectRecord(sql);
try{
if(rst.next()){
bmName = ds.toString(rst.getString("BMMC"));
Hashtable ht = new Hashtable();
ht.put("BMBH",bmbh);
ht.put("BMMC",bmName);
vt.add(ht);
}
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rst!=null)try{ stmt = rst.getStatement(); rst.close();}catch(Exception e){System.out.println("關(guān)閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關(guān)閉聲明時statement出錯"+e);}
}
}
}
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("關(guān)閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關(guān)閉聲明時statement出錯"+e);}
}
return vt;
}
//通過職工編號得到職工姓名
public String getPersonName(String strPersonNo)
{
return toName("ZZ_ZGB","ZGBH","XM",strPersonNo);
}
//通過職工編號得到ZZ_ZGZWB的BMMC_ZWMC記錄
public String getBMMC_ZWMC(String strPersonNo)
{
String sql = " select a.BMBH,b.zwmc,b.zwzt from ZZ_ZGZWB a,zz_zwb b where a.ZGBH='"+strPersonNo+"' and a.bmbh=b.bmbh and a.zwbh=b.zwbh ";
ResultSet rs = selectRecord(sql);
String bmName="",zwName="",mixName="",dutyzt="";
Statement stmt = null;
DutyBean dutybn = null;
PersonBean psbn = null;
try{
while(rs.next())
{
String bmbh = ds.toString(rs.getString("BMBH"));
bmName = getName(bmbh);
zwName = ds.toString(rs.getString("ZWMC"));
dutyzt = ds.toString(rs.getString("ZWZT"));
if (dutyzt.equals("1"))
{
dutyzt = "(掛起)";
}
else
dutyzt = "";
if(!mixName.equals(""))
mixName += "\n"+bmName+":"+zwName+dutyzt;
if(mixName.equals(""))
mixName = bmName+":"+zwName+dutyzt;
}
if(mixName.equals("")){
dutybn = new DutyBean();
psbn = new PersonBean();
psbn.setPersonNO(strPersonNo);
String BMBH = psbn.getBMBH();
String zwNo = dutybn.getOrdinaryZWBH(BMBH,"一般員工");
if(zwNo.equals("")){
Hashtable dutyhash = new Hashtable();
dutyhash.put("BMBH",BMBH);
dutyhash.put("ZWMC","一般員工");
dutyhash.put("CZQX","");
dutyhash.put("LCQX","");
dutyhash.put("PZCS","");
dutyhash.put("JBXH","");
dutyhash.put("ZWZT","0");
dutybn.addDuty(dutyhash);
zwNo = dutybn.getOrdinaryZWBH(BMBH,"一般員工");
}
addRec(strPersonNo,BMBH,zwNo,"","");
mixName = getBMMC_ZWMC(strPersonNo);
}
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(psbn!=null) psbn.closeConn();
if(dutybn!=null)dutybn.closeConn();
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("關(guān)閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關(guān)閉聲明時statement出錯"+e);}
}
return mixName;
}
public Vector getData(String strPersonNo)//通過職工編號得到ZZ_ZGZWB的所有記錄
{
Vector vt = new Vector();
String sql ="select BMBH,ZWBH from ZZ_ZGZWB where ZGBH='"+strPersonNo+"'";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
DutyBean dutybn = null;
PersonBean psbn = null;
try{
while(rs.next())
{
String bmbh = ds.toString(rs.getString("BMBH"));
String zwbh = ds.toString(rs.getString("ZWBH"));
Hashtable ht = new Hashtable();
ht.put("BMBH",bmbh);
ht.put("ZWBH",zwbh);
vt.add(ht);
}
if(vt.size()==0){
dutybn = new DutyBean();
psbn = new PersonBean();
psbn.setPersonNO(strPersonNo);
String BMBH = psbn.getBMBH();
String zwNo = dutybn.getOrdinaryZWBH(BMBH,"一般員工");
if(zwNo.equals("")){
Hashtable dutyhash = new Hashtable();
dutyhash.put("BMBH",BMBH);
dutyhash.put("ZWMC","一般員工");
dutyhash.put("CZQX","");
dutyhash.put("LCQX","");
dutyhash.put("PZCS","");
dutyhash.put("JBXH","");
dutyhash.put("ZWZT","0");
dutybn.addDuty(dutyhash);
zwNo = dutybn.getOrdinaryZWBH(BMBH,"一般員工");
}
addRec(strPersonNo,BMBH,zwNo,"","");
vt = getData(strPersonNo);
}
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("關(guān)閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關(guān)閉聲明時statement出錯"+e);}
if(psbn!=null) psbn.closeConn();
if(dutybn!=null)dutybn.closeConn();
}
return vt;
}
//通過職務(wù)名稱得到職務(wù)編號
public String getDutyNo(String strDutyName)
{
String dutyno = "";
String sql = "select ZWBH from ZZ_ZWB where trim(ZWMC)='"+strDutyName+"' and BMBH='"+DutyOrgNo+"'";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try{
while(rs.next())
dutyno = ds.toString(rs.getString("ZWBH"));
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("關(guān)閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關(guān)閉聲明時statement出錯"+e);}
}
return dutyno;
}
//通過職務(wù)編號得到職務(wù)名稱
public String getDutyName(String strDutyNo)
{
String dutyname = "";
String sql = "select ZWMC from ZZ_ZWB where ZWBH='"+strDutyNo+"' and BMBH='"+DutyOrgNo+"'";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try{
while(rs.next())
dutyname = ds.toString(rs.getString("ZWMC"));
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("關(guān)閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關(guān)閉聲明時statement出錯"+e);}
}
return dutyname;
}
//檢查ZZ_ZGZWB中是否已經(jīng)由此條記錄
public boolean hasRect(String personno,String dutyOrgno,String dutyno)
{
boolean b = false;
String sql="select * from ZZ_ZGZWB where ZGBH='"+personno+"' and BMBH='"+dutyOrgno+"' and ZWBH='"+dutyno+"'";
ResultSet rs=db.QuerySQL(sql);
Statement stmt = null;
try{
if(rs.next()){
b = true;
}
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("關(guān)閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關(guān)閉聲明時statement出錯"+e);}
}
return b;
}
//判斷ZZ_ZGB中是否有輸入的部門名稱、職工編號、職工姓名的對應(yīng)紀錄
public int hasPerson(String orgName,String personno,String personname)
{
String sql="select * from ZZ_ZGB where BMBH='"+orgName+"' and ZGBH='"+personno+"' and XM='"+personname+"'";
ResultSet rs=db.QuerySQL(sql);
Statement stmt = null;
try{
if(rs.next())
return 0;
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("關(guān)閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關(guān)閉聲明時statement出錯"+e);}
}
return 1;
}
//判斷ZZ_ZWB是否有輸入的部門名稱、職務(wù)名稱的對應(yīng)紀錄
public int hasOrgDuty(String orgName,String dutyName)
{
String sql="select * from ZZ_ZWB where BMMC='"+orgName+"' and ZWMC='"+dutyName+"'";
ResultSet rs=selectRecord(sql);
Statement stmt = null;
try{
if(rs.next())
return 0;
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("關(guān)閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關(guān)閉聲明時statement出錯"+e);}
}
return 1;
}
public void addRec(String personno,String dutyOrgno,String dutyno,String czqx,String lcqx,boolean rebuild)
{
ResultSet rs = selectRecord(" select * from zz_zgzwb where zgbh='"+personno+"' and bmbh='"+dutyOrgno+"' and zwbh="+dutyno+" ");
//System.out.println("Enter Bean!!!!!!! "+rs);
Statement stmt = null;
RightBean rb = null;
MakeNews news = null;
try{
if(!rs.next())
{
Vector vect=new Vector();
vect.add("ZZ_ZGZWB");
vect.add(addVector("ZGBH",personno,"CHAR"));
vect.add(addVector("BMBH",dutyOrgno,"CHAR"));
vect.add(addVector("ZWBH",dutyno,"CHAR"));
vect.add(addVector("CZQX",czqx,"CHAR"));
vect.add(addVector("LCQX",lcqx,"CHAR"));
insertRecord(vect);
if(!rebuild)
return;
PublicData.rebuildFlowVector();
PublicData.rebuildRightVector();
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -