⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gouwuchesessionbean.java~83~

📁 一个使用EJB开发的真实项目
💻 JAVA~83~
字号:
package ejb;

import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
import javax.naming.*;
import java.util.*;
import java.util.Date;
import java.util.GregorianCalendar;


public class GouWuCheSessionBean implements SessionBean {
    SessionContext sessionContext;
    public void ejbCreate() throws CreateException {
    }

    public void ejbRemove() {
    }

    public void ejbActivate() {
    }

    public void ejbPassivate() {
    }


    public void setSessionContext(SessionContext sessionContext) {
        this.sessionContext = sessionContext;
    }

    public boolean  inster(String userCode, String number, String name,
                          String model, float price, String count1) {
        boolean bool=false;

        try{

            Context ct = new InitialContext();
            GouWuCheInfoHome home = (GouWuCheInfoHome)ct.lookup("GouWuCheInfo");

            Date date;
            GregorianCalendar cal;
            String dinghao;
            date=new Date();
            cal=new GregorianCalendar();
            cal.setTime(date);
            dinghao=cal.get(cal.YEAR)+""+cal.get(cal.MONTH)+""+cal.get(cal.DATE)+""+cal.get(cal.HOUR+1)+""+cal.get(cal.MINUTE)+""+cal.get(cal.SECOND);

            GouWuCheInfo rm = home.create(String.valueOf(dinghao));
            rm.setCount1(count1);
            rm.setModel(model);
            rm.setName(name);
            rm.setNumber(number);
            rm.setPrice(price);
            rm.setUserCode(userCode);
            rm.setZhiFu("no");
            bool=true;
        }catch(java.lang.Exception e){e.printStackTrace();}
        return bool;
    }

    public boolean  delete(String dingDanHao) {
       boolean bool=false;
       try{
           Context ct = new InitialContext();
           GouWuCheInfoHome home = (GouWuCheInfoHome)ct.lookup("GouWuCheInfo");
           GouWuCheInfo rm = home.findByPrimaryKey(dingDanHao);
           rm.remove();
           bool=true;
       }catch(java.lang.Exception e){e.printStackTrace();}
       return bool;
    }

    public boolean xiugai(String dingDanHao, String userCode, String number,
                          String name, String model, float price, String count1,
                          String zhiFu) {
        boolean bool=false;
        try{
            Context ct = new InitialContext();
            GouWuCheInfoHome home = (GouWuCheInfoHome) ct.lookup("GouWuCheInfo");
            GouWuCheInfo rm = home.findByPrimaryKey(dingDanHao);
            rm.setCount1(count1);
            rm.setModel(model);
            rm.setName(name);
            rm.setNumber(number);
            rm.setPrice(price);
            rm.setUserCode(userCode);
            rm.setZhiFu(zhiFu);
            bool=true;
        }catch(java.lang.Exception e){e.printStackTrace();}
        return bool;
    }

    public boolean  querenzhifu(String dingDanHao) {
        boolean bool=false;
         try{
             Context ct = new InitialContext();
             GouWuCheInfoHome home = (GouWuCheInfoHome) ct.lookup(
                     "GouWuCheInfo");
             GouWuCheInfo rm = home.findByPrimaryKey(dingDanHao);
             rm.setZhiFu("yes");
             bool=true;

         }catch(java.lang.Exception e){e.printStackTrace();}
         return bool;
    }

    public List  selectAll() {
        List lt = new ArrayList();
        try{
            Context ct = new InitialContext();
            GouWuCheInfoHome home = (GouWuCheInfoHome) ct.lookup(
           "GouWuCheInfo");
           Iterator it = home.findAll().iterator();
           while(it.hasNext()){
             GouWuCheInfo gouWuCheInfo = (GouWuCheInfo)it.next();
             GouWuCheInfoVo vo = new GouWuCheInfoVo();
             vo.setCount1(gouWuCheInfo.getCount1());
             vo.setDingDanHao(gouWuCheInfo.getDingDanHao());
             vo.setModel(gouWuCheInfo.getModel());
             vo.setName(gouWuCheInfo.getName());
             vo.setNumber(gouWuCheInfo.getNumber());
             vo.setPrice(gouWuCheInfo.getPrice());
             vo.setUserCode(gouWuCheInfo.getUserCode());
             vo.setZhiFu(gouWuCheInfo.getZhiFu());
             lt.add(vo);
           }
        }catch(java.lang.Exception e){e.printStackTrace();}
        return lt;
    }

    public List selectForUserCode(String code) {
        List lt = new ArrayList();
        try{
            Context ct = new InitialContext();
            GouWuCheInfoHome home = (GouWuCheInfoHome) ct.lookup(
           "GouWuCheInfo");
            Iterator it = home.findForUserCode(code).iterator();
            while(it.hasNext()){
               GouWuCheInfo gouWuCheInfo = (GouWuCheInfo)it.next();
               GouWuCheInfoVo vo = new GouWuCheInfoVo();
               vo.setCount1(gouWuCheInfo.getCount1());
               vo.setDingDanHao(gouWuCheInfo.getDingDanHao());
               vo.setModel(gouWuCheInfo.getModel());
               vo.setName(gouWuCheInfo.getName());
               vo.setNumber(gouWuCheInfo.getNumber());
               vo.setPrice(gouWuCheInfo.getPrice());
               vo.setUserCode(gouWuCheInfo.getUserCode());
               vo.setZhiFu(gouWuCheInfo.getZhiFu());
               lt.add(vo);}
       }catch(java.lang.Exception e){e.printStackTrace();}
        return lt;
    }

    public List  selectForZhiFu() {
        List lt = new ArrayList();
        try{
            Context ct = new InitialContext();
            GouWuCheInfoHome home = (GouWuCheInfoHome) ct.lookup(
           "GouWuCheInfo");
            Iterator it = home.findForZhiFu().iterator();
           while(it.hasNext()){
             GouWuCheInfo gouWuCheInfo = (GouWuCheInfo)it.next();
             GouWuCheInfoVo vo = new GouWuCheInfoVo();
             vo.setCount1(gouWuCheInfo.getCount1());
             vo.setDingDanHao(gouWuCheInfo.getDingDanHao());
             vo.setModel(gouWuCheInfo.getModel());
             vo.setName(gouWuCheInfo.getName());
             vo.setNumber(gouWuCheInfo.getNumber());
             vo.setPrice(gouWuCheInfo.getPrice());
             vo.setUserCode(gouWuCheInfo.getUserCode());
             vo.setZhiFu(gouWuCheInfo.getZhiFu());
              lt.add(vo);}
        }catch(java.lang.Exception e){e.printStackTrace();}
        return lt;
    }

    public List selectForDingDanHao(String dingDanHao) {
        List lt = new ArrayList();

 try{
     Context ct = new InitialContext();
     GouWuCheInfoHome home = (GouWuCheInfoHome) ct.lookup(
    "GouWuCheInfo");
     Iterator it=home.findForDingDanHao(dingDanHao).iterator();
     while(it.hasNext())
     {GouWuCheInfo gouWuCheInfo=(GouWuCheInfo)it.next() ;
        GouWuCheInfoVo vo = new GouWuCheInfoVo();
        vo.setCount1(gouWuCheInfo.getCount1());
        vo.setDingDanHao(gouWuCheInfo.getDingDanHao());
        vo.setModel(gouWuCheInfo.getModel());
        vo.setName(gouWuCheInfo.getName());
        vo.setNumber(gouWuCheInfo.getNumber());
        vo.setPrice(gouWuCheInfo.getPrice());
        vo.setUserCode(gouWuCheInfo.getUserCode());
        vo.setZhiFu(gouWuCheInfo.getZhiFu());
        lt.add(vo);
    }
        ;}catch(java.lang.Exception e){e.printStackTrace();}
       return lt;

    }

    public List  selectForZhiFuORCode(String userCode) {
        return null;
    }

}

⌨️ 快捷键说明

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