package com.xjf.ekms.sessionbean.manager;
import java.rmi.RemoteException;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import java.sql.*;
import javax.naming.NamingException;
import java.util.Collection;
import java.util.Iterator;
import java.util.Vector;
import com.xjf.ekms.cmp.recommend.RecommendHomeLocal;
import com.xjf.ekms.cmp.recommend.RecommendLocal;
import com.xjf.ekms.cmp.userinfo.UserInfoHomeLocal;
import com.xjf.ekms.cmp.copculture.CopCultureHomeLocal;
import com.xjf.ekms.cmp.copculture.CopCultureLocal;
import com.xjf.ekms.cmp.userinfo.UserInfoLocal;
import com.xjf.ekms.cmp.ecareerplan.ECareerPlanHomeLocal;
import com.xjf.ekms.cmp.ecareerplan.ECareerPlanLocal;
import com.xjf.ekms.cmp.statement.StatementHomeLocal;
import com.xjf.ekms.cmp.statement.StatementLocal;
import com.xjf.ekms.cmp.staffinfo.StaffInfoHomeLocal;
import com.xjf.ekms.cmp.staffinfo.StaffInfoLocal;
import com.xjf.ekms.cmp.newsnotice.NewsNoticeHomeLocal;
import com.xjf.ekms.cmp.newsnotice.NewsNoticeLocal;
import com.xjf.ekms.cmp.treenodes.*;
import com.xjf.ekms.cmp.recommendreply.*;
import com.xjf.ekms.data.*;
import com.xjf.ekms.data.Statement;
public class ManagerBean implements SessionBean {
/**
*
*/
private static final long serialVersionUID = 1L;
public boolean modifyPsword(String account,String newPsword,String dpart){
try{
Context jndiContext = new InitialContext();
UserInfoHomeLocal home = (UserInfoHomeLocal)jndiContext.lookup("java:comp/env/ejb/UserInfoHomeLocal");
UserInfoLocal local = home.findByAccountDpart(account, dpart);
UserInfo userInfo = local.getUserInfo();
userInfo.setPsword(newPsword);
local.setUserInfo(userInfo);
return true;
}catch(Exception e){
e.printStackTrace();
return false;
}
}
public UserInfo[] viewStaff(String dpart,int cpt){
try{
Context jndiContext = new InitialContext();
UserInfoHomeLocal home = (UserInfoHomeLocal)jndiContext.lookup("java:comp/env/ejb/UserInfoHomeLocal");
Collection localCln = home.findByDpartCpt(dpart, cpt);
Iterator itor = localCln.iterator();
Vector<UserInfo> vec = new Vector<UserInfo>();
while(itor.hasNext()){
UserInfoLocal local = (UserInfoLocal)itor.next();
vec.addElement(local.getUserInfo());
}
if(vec.size()>0){
return vec.toArray(new UserInfo[vec.size()]);
}else return null;
}catch(Exception e){
throw new EJBException(e);
}
}
public UserInfo[] viewCharge(String dpart,int cpt,String remarks){
try{
Context jndiContext = new InitialContext();
UserInfoHomeLocal home = (UserInfoHomeLocal)jndiContext.lookup("java:comp/env/ejb/UserInfoHomeLocal");
Collection localCln = home.findByDpartCptRemarks(dpart, cpt, remarks);
Iterator itor = localCln.iterator();
Vector<UserInfo> vec = new Vector<UserInfo>();
while(itor.hasNext()){
UserInfoLocal local = (UserInfoLocal)itor.next();
vec.addElement(local.getUserInfo());
}
if(vec.size()>0){
return vec.toArray(new UserInfo[vec.size()]);
}else return null;
}catch(Exception e){
throw new EJBException(e);
}
}
public UserInfo[] viewManager(){
try{
Context jndiContext = new InitialContext();
UserInfoHomeLocal home = (UserInfoHomeLocal)jndiContext.lookup("java:comp/env/ejb/UserInfoHomeLocal");
Collection localCln = home.findManager();
Iterator itor = localCln.iterator();
Vector<UserInfo> vec = new Vector<UserInfo>();
while(itor.hasNext()){
UserInfoLocal local = (UserInfoLocal)itor.next();
vec.addElement(local.getUserInfo());
}
if(vec.size()>0){
return vec.toArray(new UserInfo[vec.size()]);
}else return null;
}catch(Exception e){
throw new EJBException(e);
}
}
public String viewCopCulture(String type){
try{
Context jndiContext = new InitialContext();
CopCultureHomeLocal home = (CopCultureHomeLocal)jndiContext.lookup("java:comp/env/ejb/CopCultureHomeLocal");
CopCultureLocal local = home.findByType(type);
return (String)local.getCopCulture().getContent();
}catch(Exception e){
throw new EJBException(e);
}
}
public boolean addUserInfo(UserInfo userInfo){
try{
Context jndiContext = new InitialContext();
UserInfoHomeLocal home = (UserInfoHomeLocal)jndiContext.lookup("java:comp/env/ejb/UserInfoHomeLocal");
UserInfoLocal local = home.create(userInfo);
if(local!=null){
return true;
}
return false;
}catch(Exception e){
e.printStackTrace();
throw new EJBException(e);
}
}
public boolean modifyCopCulture(CopCulture copculture){
String type = copculture.getType();
try{
Context jndiContext = new InitialContext();
CopCultureHomeLocal home = (CopCultureHomeLocal)jndiContext.lookup("java:comp/env/ejb/CopCultureHomeLocal");
CopCultureLocal local = home.findByType(type);
local.setCopCulture(copculture);
return true;
}catch(Exception e){
e.printStackTrace();
return false;
}
}
public boolean modifyUserInfo(UserInfo userInfo){
String account = userInfo.getAccount();
String dpart = userInfo.getDpart();
try{
Context jndiContext = new InitialContext();
UserInfoHomeLocal home = (UserInfoHomeLocal)jndiContext.lookup("java:comp/env/ejb/UserInfoHomeLocal");
UserInfoLocal local = home.findByAccountDpart(account, dpart);
local.setUserInfo(userInfo);
return true;
}catch(Exception e){
e.printStackTrace();
return false;
}
}
public boolean deleteUserInfo(String account,String dpart){
try{
Context jndiContext = new InitialContext();
UserInfoHomeLocal home = (UserInfoHomeLocal)jndiContext.lookup("java:comp/env/ejb/UserInfoHomeLocal");
UserInfoLocal local = home.findByAccountDpart(account,dpart);
if(local.getUserInfo().getRemarks().equals("主管")){
Collection cln = home.findByDpartCpt(dpart, 3);
Iterator itor = cln.iterator();
while(itor.hasNext()){
UserInfoLocal local2 = (UserInfoLocal)itor.next();
local2.remove();
}
Collection cln2 = home.findByDpartCpt(dpart, 2);
Iterator itor2 = cln2.iterator();
local.remove();
while(itor.hasNext()){
UserInfoLocal local3 = (UserInfoLocal)itor2.next();
local3.remove();
}
}else{
local.remove();
}
return true;
}catch(Exception e){
return false;
}
}
public boolean addStaffInfo(StaffInfo staffInfo){
try{
Context jndiContext = new InitialContext();
StaffInfoHomeLocal home = (StaffInfoHomeLocal)jndiContext.lookup("java:comp/env/ejb/StaffInfoHomeLocal");
StaffInfoLocal local = home.create(staffInfo);
if(local!=null){
return true;
}
return false;
}catch(Exception e){
return false;
}
}
public boolean modifyStaffInfo(StaffInfo staffInfo){
String account = staffInfo.getAccont();
String dpart = staffInfo.getDpart();
try{
Context jndiContext = new InitialContext();
StaffInfoHomeLocal home = (StaffInfoHomeLocal)jndiContext.lookup("java:comp/env/ejb/StaffInfoHomeLocal");
StaffInfoLocal local = home.findByAccountDpart(account, dpart);
local.setStaffInfo(staffInfo);
return true;
}catch(Exception e){
e.printStackTrace();
return false;
}
}
public boolean deleteStaffInfo(String account,String dpart){
try{
Context jndiContext = new InitialContext();
StaffInfoHomeLocal home = (StaffInfoHomeLocal)jndiContext.lookup("java:comp/env/ejb/StaffInfoHomeLocal");
StaffInfoLocal local = home.findByAccountDpart(account,dpart);
local.remove();
return true;
}catch(Exception e){
return false;
}
}
public boolean addNewsNotice(NewsNotice newsnotice){
try{
Context jndiContext = new InitialContext();
NewsNoticeHomeLocal home = (NewsNoticeHomeLo
- 1
- 2
- 3
- 4
- 5
- 6
前往页