📄 productsecbean.java
字号:
package product;
import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import javax.rmi.PortableRemoteObject;
import java.util.*;
import java.awt.Image;
import java.text.DateFormat;
//import java.sql.Date;
import object.*;
import java.io.*;
public class productSecBean implements SessionBean,Serializable{
SessionContext sessionContext;
//private productBasicInfoEntRemoteHome pb_home=null;
//private productTypeInfoEntRemoteHome pt_home=null;
public void ejbRemove() {
/**@todo Complete this method*/
}
public void ejbActivate() {
/**@todo Complete this method*/
}
public void ejbPassivate() {
/**@todo Complete this method*/
}
public void setSessionContext(SessionContext sessionContext) {
this.sessionContext = sessionContext;
}
//用于返回一个productBasicInfo远程引用
private productBasicInfoEntRemoteHome lookupBasicHome(){
productBasicInfoEntRemoteHome home=null;
try{
Context ctx = new InitialContext(System.getProperties());
home = (productBasicInfoEntRemoteHome) PortableRemoteObject.narrow(
ctx.lookup("productBasicInfoEntRemote"), productBasicInfoEntRemoteHome.class);
}
catch(Exception e){
System.out.println("查找 productBasicInfoEntRemoteHome bean 时有异常: "+e);
System.out.println("err at product.productSecBean.lookupBasicHome():"+e);
}
return home;
}
//用于返回一个productBasicInfo远程引用
private productTypeInfoEntRemoteHome lookupTypeHome(){
productTypeInfoEntRemoteHome home=null;
try{
Context ctx = new InitialContext(System.getProperties());
home = (productTypeInfoEntRemoteHome) PortableRemoteObject.narrow(
ctx.lookup("productTypeInfoEntRemote"), productTypeInfoEntRemoteHome.class);
}
catch(Exception e){
System.out.println("err at product.productSecBean.lookupTypeHome():"+e);
}
return home;
}
private prod_pb_infoEntRemoteHome lookupPbInfo(){
prod_pb_infoEntRemoteHome home=null;
try{
Context ctx = new InitialContext(System.getProperties());
home = (prod_pb_infoEntRemoteHome) PortableRemoteObject.narrow(
ctx.lookup("prod_pb_infoEntRemote"), prod_pb_infoEntRemoteHome.class);
}
catch(Exception e){
System.out.println("err at product.productSecBean.lookupPbInfo():"+e);
}
return home;
}
private prod_in_stockRemoteHome lookupPbInStock(){
prod_in_stockRemoteHome home=null;
try{
Context ctx = new InitialContext(System.getProperties());
home = (prod_in_stockRemoteHome) PortableRemoteObject.narrow(
ctx.lookup("prod_in_stockRemote"), prod_in_stockRemoteHome.class);
}
catch(Exception e){
System.out.println("err at product.productSecBean.lookupPbInStock():"+e);
}
return home;
}
private prod_view_searchRemoteHome lookupPbview(){
prod_view_searchRemoteHome home=null;
try{
Context ctx = new InitialContext(System.getProperties());
home = (prod_view_searchRemoteHome) PortableRemoteObject.narrow(
ctx.lookup("prod_view_searchRemote"), prod_view_searchRemoteHome.class);
}
catch(Exception e){
System.out.println("err at product.productSecBean.lookupPbview():"+e);
}
return home;
}
public String find_prod_basic_pk(String p_id) {
/**@todo Complete this method*/
return null;
}
public LinkedList find_prod_type(String type) {
/**@todo Complete this method*/
LinkedList list=new LinkedList();
Collection col=null;
try{
prod_view_searchRemoteHome home = lookupPbview();
col=home.find_type(type);
if(col!=null){
Iterator i = col.iterator();
while (i.hasNext()) {
prod_view_searchRemote prod = (prod_view_searchRemote)
PortableRemoteObject.narrow(i.next(), prod_view_searchRemote.class);
//list.add(new type(prod.getP_type_id(), prod.getP_type_name(),prod.getP_type_remark()));
/*String id;
String name;
String spec;
String model;
String unit;
String price=null;
*/
//list.add(prod.getTid());
list.add(prod.getId());
list.add(prod.getName());
list.add(prod.getSpec());
list.add(prod.getModel());
list.add(prod.getUnit());
//list.add(prod.getRemark());
//list.add((""+prod.getTax()).substring(0,(""+prod.getTax()).indexOf(".")+2));
//list.add(prod.getTax() + "");
//list.add(prod.getAmount() + "");
//list.add(prod.getMaxlow() + "");
//list.add(prod.getBprice() + "");
list.add(prod.getSprice() + "");
//list.add(prod.getState() + "");
//list.add(prod.getDepositary());
}
}
}
catch(Exception e){
System.out.println("err at product.find_prod_type(..)");
}
return list;
}
public void in_type(String type_id, String name, String remark) {
/**@todo Complete this method*/
try{
productTypeInfoEntRemoteHome home=lookupTypeHome();
home.create(type_id,name,remark);
}
catch(Exception e){
System.out.println("err at product.productSecBean.in_type():"+e);
}
}
public void in_Prod_basic(String p_id, String p_type_id, String p_name, String p_spec, String p_model, String p_unit, Image p_image, String p_remark){
//float p_tax, int p_amount, int p_maxlow, float p_bprice, float p_sprice, String p_state, String p_depositary
/**@todo Complete this method*/
try{
productBasicInfoEntRemoteHome home = lookupBasicHome();
home.create(p_id, p_type_id, p_name, p_spec, p_model, p_unit, p_image,
p_remark);
//prod_pb_infoEntRemoteHome home2=lookupPbInfo();
// home2.create(p_id, p_tax, p_amount, p_maxlow, p_bprice, p_sprice, p_state, p_depositary);
}
catch(Exception e){
System.out.println("插入 new product 时有异常: "+e);
System.out.println("err at product.productSecBean.in_Prod_basic(..):"+e);
}
}
public String find_prod_basic_maxpk() {
/**@todo Complete this method*/
String result="0000000001";
try{
productBasicInfoEntRemoteHome home= lookupBasicHome();
productBasicInfoEntRemote prod=home.find_basic_mpk();
if(prod!=null)
result=prod.getP_id();
}
catch(Exception e){
System.out.println("err at product.find_prod_basic_maxpk():"+e);
}
return result;
}
public boolean mod_type_pk(String pk, String name, String remark) {
/**@todo Complete this method*/
boolean result=true;
try{
productTypeInfoEntPK tpk = new productTypeInfoEntPK(pk);
productTypeInfoEntRemoteHome home = lookupTypeHome();
productTypeInfoEntRemote type=home.findByPrimaryKey(tpk);
type.setP_type_name(name);
type.setP_type_remark(remark);
}
catch(Exception e){
System.out.println("err at product.productSecBean.mod_type_pk():"+e);
result=false;
}
return result;
}
public boolean del_type_pk(String pk) {
/**@todo Complete this method*/
boolean result=true;
try{
productTypeInfoEntPK tpk = new productTypeInfoEntPK(pk);
productTypeInfoEntRemoteHome home = lookupTypeHome();
productTypeInfoEntRemote type=home.findByPrimaryKey(tpk);
type.remove();
}
catch(Exception e){
result=false;
System.out.println("err at product.productSecBean.del_type_pk():"+e);
}
return result;
}
public String find_type_maxpk() {
/**@todo Complete this method*/
String result="0001";
try{
productTypeInfoEntRemoteHome home=lookupTypeHome();
Collection col=home.find_maxpk();
if(col!=null){
Iterator i = col.iterator();
while (i.hasNext()) {
productTypeInfoEntRemote prod_basic = (productTypeInfoEntRemote)
PortableRemoteObject.narrow(i.next(), productTypeInfoEntRemote.class);
result = prod_basic.getP_type_id();
}
}
}
catch(Exception e){
System.out.println("err at product.productSecBean.find_type_maxpk():"+e);
}
return result;
}
public String find_type_pk(String name) {
/**@todo Complete this method*/
return null;
}
public java.util.Collection find_type_name(String name) {
/**@todo Complete this method*/
return null;
}
public LinkedList find_alltype() {
/**@todo Complete this method*/
LinkedList list=new LinkedList();
Collection col=null;
try{
productTypeInfoEntRemoteHome home= lookupTypeHome();
col=home.find_alltype();
}
catch(Exception e){
System.out.println("err at product.productSecBean.find_alltype()--1:"+e);
}
try{
if(col!=null){
Iterator i = col.iterator();
while (i.hasNext()) {
productTypeInfoEntRemote prod = (productTypeInfoEntRemote)
PortableRemoteObject.narrow(i.next(), productTypeInfoEntRemote.class);
//list.add(new type(prod.getP_type_id(), prod.getP_type_name(),prod.getP_type_remark()));
list.add(prod.getP_type_id());
list.add(prod.getP_type_name());
}
}
}
catch(Exception e){
System.out.println("err at product.productSecBean.find_alltype()--2:"+e);
}
return list;
}
public LinkedList find_type_search(int type, String content) {
/**@todo Complete this method*/
final int id_all=10,id_small=11,id_big=12,id_equal=13; //标记 类型和条件的常量标记
final int name=20;
Collection col=null;//=new Collection();
LinkedList list=new LinkedList();
switch(type){
case id_all:
try{
productTypeInfoEntRemoteHome home=lookupTypeHome();
col=home.find_bigpk("0");
}
catch(Exception e){
System.out.println("err at product.productSecBean.find_type_search(..):"+e);
}
break;
case id_small:
try{
productTypeInfoEntRemoteHome home=lookupTypeHome();
col=home.find_smallpk(content);
}
catch(Exception e){
System.out.println("err at product.productSecBean.find_type_search(..):"+e);
}
break;
case id_big:
try{
productTypeInfoEntRemoteHome home=lookupTypeHome();
col=home.find_bigpk(content);
}
catch(Exception e){
System.out.println("err at product.productSecBean.find_type_search(..):"+e);
}
break;
case id_equal:
try{
productTypeInfoEntRemoteHome home=lookupTypeHome();
col=home.find_equal(content);
}
catch(Exception e){
System.out.println("err at product.productSecBean.find_type_search(..):"+e);
}
break;
case name:
try{
productTypeInfoEntRemoteHome home=lookupTypeHome();
content="%"+content+"%";
col=home.find_likename(content);
}
catch(Exception e){
System.out.println("err at product.productSecBean.find_type_search(..)--1:"+e);
}
break;
}
try{
if(col!=null){
Iterator i = col.iterator();
while (i.hasNext()) {
productTypeInfoEntRemote prod = (productTypeInfoEntRemote)
PortableRemoteObject.narrow(i.next(), productTypeInfoEntRemote.class);
//list.add(new type(prod.getP_type_id(), prod.getP_type_name(),prod.getP_type_remark()));
list.add(prod.getP_type_id());
list.add(prod.getP_type_name());
list.add(prod.getP_type_remark());
}
}
}
catch(Exception e){
System.out.println("err at product.productSecBean.find_type_search(..)--2:"+e);
}
return list;
}
public java.util.Collection find_prod_basic_name(String name) {
/**@todo Complete this method*/
return null;
}
public LinkedList find_prod_search(int operation, String type, String content) {
/**@todo Complete this method*/
final int name=1,spec=2,id=3,model=4;
Collection col=null;
LinkedList list=new LinkedList();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -