📄 productsecbean.java
字号:
content="%"+content+"%";
switch(operation){
case id:
try{
prod_view_searchRemoteHome home = lookupPbview();
col=home.find_id(type,content);
// prod_pb_infoEntRemoteHome home2=lookupPbInfo();
//home2.
}
catch(Exception e){
System.out.println("err at product.productSecBean.find_prod_search(..):"+e);
}
break;
case name:
try{
prod_view_searchRemoteHome home = lookupPbview();
col=home.find_name(type,content);
}
catch(Exception e){
System.out.println("err at product.productSecBean.find_prod_search(..):"+e);
}
break;
case spec:
try{
prod_view_searchRemoteHome home = lookupPbview();
col=home.find_spec(type,content);
}
catch(Exception e){
System.out.println("err at product.productSecBean.find_prod_search(..):"+e);
}
break;
case model:
try{
prod_view_searchRemoteHome home = lookupPbview();
col=home.find_model(type,content);
}
catch(Exception e){
System.out.println("err at product.productSecBean.find_prod_search(..):"+e);
}
break;
}
try{
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()));
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.productSecBean.find_type_search(..)--2:"+e);
}
//System.out.println("return prod_view list");
return list;
}
public boolean del_prod_pk(String pk) {
/**@todo Complete this method*/
boolean res=true;
try{
productBasicInfoEntPK ppk=new productBasicInfoEntPK(pk);
productBasicInfoEntRemoteHome home = lookupBasicHome();
productBasicInfoEntRemote prod=home.findByPrimaryKey(ppk);
prod.remove();
}
catch(Exception e){
System.out.println("err at product.productSecBean.del_prod(..):"+e);
res=false;
}
return res;
}
public boolean mod_prod_pk(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) {
/**@todo Complete this method*/
boolean res=true;
try{
productBasicInfoEntPK ppk=new productBasicInfoEntPK(p_id);
productBasicInfoEntRemoteHome home = lookupBasicHome();
productBasicInfoEntRemote prod=home.findByPrimaryKey(ppk);
prod.setP_type_id(p_type_id);
prod.setP_name(p_name);
prod.setP_spec(p_spec);
prod.setP_model(p_model);
prod.setP_unit(p_unit);
prod.setP_image(p_image);
prod.setP_remark(p_remark);
}
catch(Exception e){
System.out.println("err at product.productSecBean.mod_prod_pk(..):"+e);
res=false;
}
return res;
}
public void in_prod_pb(String p_id, 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{
prod_pb_infoEntRemoteHome homedd=lookupPbInfo();
homedd.create( p_id, p_tax, p_amount, p_maxlow, p_bprice, p_sprice, p_state, p_depositary);
}
catch(Exception e){
System.out.println("err at product.productSecBean.in_prod_pb(..):"+e);
}
}
public boolean mod_prod_pb(String pid, float tax, int amount, int maxlow, float bprice, float sprice, String state, String depositary) {
/**@todo Complete this method*/
boolean res=true;
try{
prod_pb_infoEntPK pk=new prod_pb_infoEntPK(pid);
prod_pb_infoEntRemoteHome homedd=lookupPbInfo();
prod_pb_infoEntRemote pb=homedd.findByPrimaryKey(pk);
pb.setP_tax(tax);
pb.setP_amount(amount);
pb.setP_maxlow(maxlow);
pb.setP_bprice(bprice);
pb.setP_sprice(sprice);
pb.setP_state(state);
pb.setP_depositary(depositary);
}
catch(Exception e){
System.out.println("err at product.productSecBean.mod_prod_pb(..):"+e);
res=false;
}
return res;
}
public boolean del_prod_pb(String pid) {
/**@todo Complete this method*/
boolean res=true;
try{
prod_pb_infoEntPK pk=new prod_pb_infoEntPK(pid);
prod_pb_infoEntRemoteHome homedd=lookupPbInfo();
prod_pb_infoEntRemote pb=homedd.findByPrimaryKey(pk);
pb.remove();
}
catch(Exception e){
System.out.println("err at product.productSecBean.del_prod_pb(..):"+e);
res=false;
}
return res;
}
public java.util.Collection find_prod_pb_search(String type, String condition, String content) {
/**@todo Complete this method*/
//产品编号 1 ,入货日期 2 ,有效日期 3 ,大于 1 ,等于 0 ,小于 -1
Collection col=null;
try{
prod_in_stockRemoteHome home= lookupPbInStock();
if (type.equals("1")) {
//if (condition.equals("1")) {col=home.find_bid(content);}
//else if (condition.equals("0")) {col=home.find_id(content);}
//else if (condition.equals("-1")) {col=home.find_sid(content);}
}
/* else if (type.equals("2")) {
if (condition.equals("1")) {col=home.find_bbdate(DateFormat.getInstance().parse(content));}
else if (condition.equals("0")) {col=home.find_bdate(DateFormat.getInstance().parse(content));}
else if (condition.equals("-1")) {col=home.find_sbdate(DateFormat.getInstance().parse(content));}
}
else if (type.equals("3")) {
// if (condition.equals("1")) {col=home.find_bvali(DateFormat.getInstance().parse(content));}
//else if (condition.equals("0")) {col=home.find_vali(DateFormat.getInstance().parse(content));}
//else if (condition.equals("-1")) {col=home.find_svali(DateFormat.getInstance().parse(content));}
}*/
}
catch(Exception e){
System.out.println("err at product.productSecBean.find_prod_pb_search(..):"+e);
}
return col;
}
public boolean in_prod_in_stock(String pid, int num, float buyprice, String buydate, String batchno, String validity, String area, String state) {
/**@todo Complete this method*/
boolean re=true;
try{
prod_in_stockRemoteHome home =lookupPbInStock();
//找出最大的流水号
//prod_in_stockRemote pst=home.find_max_serno(pid);
//int serno=pst.getSerno()+1;
int serno=find_prod_in_stock_maxpk(pid)+1;
home.create( pid, serno, num, buyprice, buydate, batchno, validity, area, state);
//修改库存记录
prod_pb_infoEntRemoteHome phome=lookupPbInfo();
prod_pb_infoEntPK pk=new prod_pb_infoEntPK(pid);
prod_pb_infoEntRemote prod=phome.findByPrimaryKey(pk);
prod.setP_amount(prod.getP_amount()+num);
}
catch(Exception e){
re=false;
System.out.println("err at product.productSecBean.in_prod_in_stock(..):"+e);
}
return re;
}
public boolean mod_prod_in_stock(String pid, int serno, int num, float buyprice, String buydate, String batchno, String validity, String area, String state) {
/**@todo Complete this method*/
boolean re=true;
try{
prod_in_stockRemoteHome home =lookupPbInStock();
prod_in_stockPK pk=new prod_in_stockPK(pid,serno);
prod_in_stockRemote pin=home.findByPrimaryKey(pk);
int temp=pin.getNum();
pin.setNum(num);
pin.setBuyprice(buyprice);
pin.setBuydate(buydate);
pin.setBatchno(batchno);
pin.setValidity(validity);
pin.setArea(area);
//修改库存记录
prod_pb_infoEntRemoteHome phome=lookupPbInfo();
prod_pb_infoEntPK pkk=new prod_pb_infoEntPK(pid);
prod_pb_infoEntRemote prod=phome.findByPrimaryKey(pkk);
prod.setP_amount(prod.getP_amount()+num-temp);
}
catch(Exception e){
re=false;
System.out.println("err at product.productSecBean.mod_prod_in_stock(..):"+e);
}
return re;
}
public boolean del_prod_in_stock(String pid, int serno) {
/**@todo Complete this method*/
boolean re=true;
try{
prod_in_stockRemoteHome home =lookupPbInStock();
prod_in_stockPK pk=new prod_in_stockPK(pid,serno);
prod_in_stockRemote pin=home.findByPrimaryKey(pk);
int temp=pin.getNum();
pin.remove();
//修改库存记录
prod_pb_infoEntRemoteHome phome=lookupPbInfo();
prod_pb_infoEntPK pkk=new prod_pb_infoEntPK(pid);
prod_pb_infoEntRemote prod=phome.findByPrimaryKey(pkk);
prod.setP_amount(prod.getP_amount()-temp);
}
catch(Exception e){
re=false;
System.out.println("err at product.productSecBean.del_prod_in_stock(..):"+e);
}
return re;
}
public LinkedList find_prod_in_stock(int type, int condition, String content) {
/**@todo Complete this method*/
LinkedList list=new LinkedList();
Collection col=null;
try{
prod_in_stockRemoteHome home= lookupPbInStock();
switch (type) {
case 1: //id
switch (condition) {
case -1: // <
col=home.find_small_id(content);
break;
case 0: // =
col=home.find_equal_id(content);
break;
case 1: // >
col=home.find_big_id(content);
break;
}
break;
case 2: //buydate
java.util.Date dd=DateFormat.getDateInstance().parse(content);
//java.util.Date date=new java.util.Date(content);
//int day=date.getDay();
//int month=date.getMonth();
//int year=date.getYear();
//java.sql.Date dd=new java.sql.Date(2005,04,05);
switch (condition) {
case -1: // <
col=home.find_small_bdate(dd);
break;
case 0: // =
col=home.find_equal_bdate(dd);
break;
case 1: // >
col=home.find_big_bdate(dd);
break;
}
break;
case 3: //vdate
java.util.Date dd3=DateFormat.getDateInstance().parse(content);
//java.util.Date date3=new java.util.Date(content);
// int day3=date3.getDay();
// int month3=date3.getMonth();
//int year3=date3.getYear();
//java.sql.Date dd3=new java.sql.Date(2004,02,03);
switch (condition) {
case -1: // <
col=home.find_small_vdate(dd3);
break;
case 0: // =
col=home.find_equal_vdate(dd3);
break;
case 1: // >
col=home.find_big_vdate(dd3);
break;
}
break;
}
}
catch(Exception e){
System.out.println("err at product.productSecBean.find_prod_in_stock(..)--1:"+e);
}
try{
if(col!=null){
Iterator i = col.iterator();
while (i.hasNext()) {
prod_in_stockRemote pstock = (prod_in_stockRemote)
PortableRemoteObject.narrow(i.next(), prod_in_stockRemote.class);
//list.add(new type(prod.getP_type_id(), prod.getP_type_name(),prod.getP_type_remark()));
// p_id; p_serno; num; buy_price; buy_date; batchno; validity; area; sellout;
list.add(pstock.getPid());
list.add(pstock.getSerno() + "");
list.add(pstock.getNum() + "");
list.add(pstock.getBuyprice() + "");
list.add(pstock.getBuydate());
list.add(pstock.getBatchno());
list.add(pstock.getValidity());
list.add(pstock.getArea());
list.add(pstock.getState());
}
}
}
catch(Exception e){
System.out.println("err at product.productSecBean.find_type_search(..)--2:"+e);
}
return list;
}
public int find_prod_in_stock_maxpk(String id) {
/**@todo Complete this method*/
int re=0;
try{
prod_in_stockRemoteHome home =lookupPbInStock();
prod_in_stockRemote pstock=home.find_max_serno(id);
if(pstock!=null)
re=pstock.getSerno();
}
catch(Exception e){
}
return re;
}
public void ejbCreate() throws CreateException {
/**@todo Complete this method*/
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -