sesbean.java

来自「This project mainly deals with automatin」· Java 代码 · 共 281 行

JAVA
281
字号

package packIC;

import java.rmi.*;
import java.sql.*;
import javax.ejb.*;
import java.util.*;
import javax.naming.*;
import packIC.LoginHome;
import packIC.ImRawHome;
import packIC.RawRecHome;
import packIC.RawIssuedHome;
import packIC.ImFinHome;
import packIC.FinRecHome;
import packIC.FinIssuedHome;
import packIC.DealerHome;
import packIC.DeptHome;



public class SesBean implements SessionBean

{
public SessionContext sctxt;
public int ret;

public void ejbCreate()
	{
	System.out.println(" in create session");
        this.ret=0;
	}

public void setSessionContext(SessionContext sctxt)
	{
	System.out.println(" in set session");
	this.sctxt=sctxt;
	}

public void ejbActivate()
	{
	}
public void ejbPassivate()
	{
	}


public void ejbRemove()
	{
	}


//****************************** user functions ******************************


//****************************** login validations******************************
public int checkLogin(String userid,String password) throws RemoteException
	{
	try{
	Hashtable ht=new Hashtable();
	ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    	ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
	InitialContext Context = new InitialContext(ht);
	LoginHome home=(LoginHome)Context.lookup("java:comp/env/ejb/LoginEJB");
	LoginRemote remote=home.findByPrimaryKey(userid);
        String uid= remote.getUserid();
	String pass= remote.getPassword();
		if((password.equals(pass))&&(userid.equals(uid)))
			{
			return 1;
			}
			else 
                          {
			return 2;
       			 }
				
		     }
                       catch(FinderException e)
			{
				System.out.println("cannot find the user"+e);
				return 11;
			}
	 
		catch(RemoteException e)
			{
				System.out.println("Remote Exception in finding the user"+ e);
				return 13;
			}
		catch (Exception e)
			{
			System.out.println("Remote Exception in finding the user"+ e);
			return 15;
			}		
	 
	}

public int createImRawMaterial(int sno,int itemno,String itemname,double rate) throws RemoteException
	{
	System.out.println(" in create ImRawMaterial ");
	
		try{
	Hashtable ht=new Hashtable();
	ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    	ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
	InitialContext Context = new InitialContext(ht);
	ImRawHome home=null;
		    home = (ImRawHome)Context.lookup("java:comp/env/ejb/ImRawEJB");
																						   
 	ImRawRemote remote=home.create( sno, itemno, itemname, rate);
		    return remote.getSno();
		   }catch(CreateException e){System.out.println("Crreate Exception"+e);
					return 11;}
		   catch(RemoteException e){System.out.println("RemoteException"+e);
					return 13;}
		   catch(Exception e){System.out.println("Cannot look up");
					return 15;}

	}//end ImRawMaterial
public int createRawRecMaterial(int sno,int itemno,double qtyord,double qtyrec,java.sql.Date recdate,int recno,double amount) throws RemoteException
	{
	System.out.println(" in create RawRecMaterial ");
	
		try{
	Hashtable ht=new Hashtable();
	ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    	ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
	InitialContext Context = new InitialContext(ht);
	RawRecHome home=null;
		    home = (RawRecHome)Context.lookup("java:comp/env/ejb/RawRecEJB");
																						   
 	RawRecRemote remote=home.create( sno, itemno, qtyord, qtyrec, recdate, recno, amount);
		    return remote.getSno();
		   }catch(CreateException e){System.out.println("Crreate Exception"+e);
					return 11;}
		   catch(RemoteException e){System.out.println("RemoteException"+e);
					return 13;}
		   catch(Exception e){System.out.println("Cannot look up");
					return 15;}

	}//end RawRecMaterial

public int createRawissueMaterial(int sno,int itemno,double qtyissued,int challanno,String deptname,java.sql.Date issuedate) throws RemoteException
	{
	System.out.println(" in create RawIssueMaterial ");
	
		try{
	Hashtable ht=new Hashtable();
	ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    	ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
	InitialContext Context = new InitialContext(ht);
	RawIssuedHome home=null;
		    home = (RawIssuedHome)Context.lookup("java:comp/env/ejb/RawIssuedEJB");
																						   
 	RawIssuedRemote remote=home.create( sno, itemno, qtyissued, challanno,deptname,issuedate);
		    return remote.getSno();
		   }catch(CreateException e){System.out.println("Crreate Exception"+e);
					return 11;}
		   catch(RemoteException e){System.out.println("RemoteException"+e);
					return 13;}
		   catch(Exception e){System.out.println("Cannot look up");
					return 15;}

	}//end RawIssuedMaterial


public int createImFinMaterial(int sno,int itemno,String itemname,double rate) throws RemoteException
	{
	System.out.println(" in create ImFinMaterial ");
	
		try{
	Hashtable ht=new Hashtable();
	ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    	ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
	InitialContext Context = new InitialContext(ht);
	ImFinHome home=null;
		    home = (ImFinHome)Context.lookup("java:comp/env/ejb/ImFinEJB");
																						   
 	ImFinRemote remote=home.create( sno, itemno, itemname, rate);
		    return remote.getSno();
		   }catch(CreateException e){System.out.println("Crreate Exception"+e);
					return 11;}
		   catch(RemoteException e){System.out.println("RemoteException"+e);
					return 13;}
		   catch(Exception e){System.out.println("Cannot look up");
					return 15;}

	}//end ImFinMaterial

public int createFinRecMaterial(int sno,int itemnumber,double qtyrec,java.sql.Date recdate,String deptname,int recno) throws RemoteException

	{
	System.out.println(" in create FinRecMaterial ");
	
		try{
	Hashtable ht=new Hashtable();
	ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    	ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
	InitialContext Context = new InitialContext(ht);
	FinRecHome home=null;
		    home = (FinRecHome)Context.lookup("java:comp/env/ejb/FinRecEJB");
																						   
 	FinRecRemote remote=home.create( sno, itemnumber, qtyrec, recdate, deptname, recno);
		    return remote.getSno();
		   }catch(CreateException e){System.out.println("Crreate Exception"+e);
					return 11;}
		   catch(RemoteException e){System.out.println("RemoteException"+e);
					return 13;}
		   catch(Exception e){System.out.println("Cannot look up");
					return 15;}

	}//end FinRecGoods

public int createFinissueMaterial(int sno,int reqno,int itemnumber,double qtydes,java.sql.Date desdate,String dealername,double amount) throws RemoteException
	{
	System.out.println(" in create RawIssueMaterial ");
	
		try{
	Hashtable ht=new Hashtable();
	ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    	ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
	InitialContext Context = new InitialContext(ht);
	FinIssuedHome home=null;
		    home = (FinIssuedHome)Context.lookup("java:comp/env/ejb/FinIssuedEJB");
																						   
 	FinIssuedRemote remote=home.create( sno, reqno, itemnumber, qtydes,desdate, dealername, amount);
		    return remote.getSno();
		   }catch(CreateException e){System.out.println("Crreate Exception"+e);
					return 11;}
		   catch(RemoteException e){System.out.println("RemoteException"+e);
					return 13;}
		   catch(Exception e){System.out.println("Cannot look up");
					return 15;}

	}//end FinIssuedGoods

public int createDealer(int sno,int dealerno,String dealername,String address,int phone,String category,int creditlimit) throws RemoteException
	{
	System.out.println(" in create RawRecMaterial ");
	
		try{
	Hashtable ht=new Hashtable();
	ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    	ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
	InitialContext Context = new InitialContext(ht);
	DealerHome home=null;
		    home = (DealerHome)Context.lookup("java:comp/env/ejb/DealerEJB");
																						   
 	DealerRemote remote=home.create(  sno, dealerno,dealername, address, phone, category, creditlimit);
		    return remote.getSno();
		   }catch(CreateException e){System.out.println("Crreate Exception"+e);
					return 11;}
		   catch(RemoteException e){System.out.println("RemoteException"+e);
					return 13;}
		   catch(Exception e){System.out.println("Cannot look up");
					return 15;}

	}//end Dealer

public int createDepartments(int sno,int deptno,String deptname,String location,String depthead) throws RemoteException
	{
	System.out.println(" in create RawIssueMaterial ");
	
		try{
	Hashtable ht=new Hashtable();
	ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    	ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
	InitialContext Context = new InitialContext(ht);
	DeptHome home=null;
		    home = (DeptHome)Context.lookup("java:comp/env/ejb/DeptEJB");
																						   
 	DeptRemote remote=home.create( sno, deptno, deptname, location, depthead);
		    return remote.getSno();
		   }catch(CreateException e){System.out.println("Crreate Exception"+e);
					return 11;}
		   catch(RemoteException e){System.out.println("RemoteException"+e);
					return 13;}
		   catch(Exception e){System.out.println("Cannot look up");
					return 15;}

	}//end Departments

}//end class

⌨️ 快捷键说明

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