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

📄 smartticketfacadebean.java

📁 这个范例程序演示了利用j2me技术开发无线服务器支持的应用。这是一个电影票订购程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        }         return;    }     public void login(String userName,                       String password) throws SmartTicketFacadeException {        if (account == null ||!account.getUserName().equals(userName)                 ||!account.getPassword().equals(password)) {            try {                AccountLocal account =                     (AccountLocal) accountHome.findByPrimaryKey(userName);                if (account.getPassword().equals(password)) {                    this.account = account;                    try {                        ticketing = ticketingHome.create(account);                        synchronizing = synchronizingHome.create(account);                        return;                    } catch (CreateException ce) {                        this.account = null;                        ticketing = null;                        synchronizing = null;                        throw new EJBException("SmartTicketFacadeBean.login: "                                                + ce.getMessage());                    }                 }                 throw new SmartTicketFacadeException("Incorrect password.");            } catch (FinderException fe) {                throw new SmartTicketFacadeException("No such user.");            }         }     }     public void createAccount(String userName, String password,                               String firstName, String lastName,                               String zipCode, String eMail,                               String creditCardHolderName,                               String CreditCardNumber,                               String creditCardExpirationDate,                               String creditCardType) throws SmartTicketFacadeException {        try {            account = accountHome.create(userName, password);            account.setFirstName(firstName);            account.setLastName(lastName);            account.setZipCode(zipCode);            account.setEMail(eMail);            account.setCreditCardNumber(CreditCardNumber);            account.setCreditCardHolderName(creditCardHolderName);            account.setCreditCardExpirationDate(creditCardExpirationDate);            account.setCreditCardType(creditCardType);            ticketing = ticketingHome.create(account);            synchronizing = synchronizingHome.create(account);            return;        } catch (CreateException ce) {            ticketing = null;            synchronizing = null;            throw new SmartTicketFacadeException("Account creation error.");        }     }     public void updateAccount(String userName, String password,                               String firstName, String lastName,                               String zipCode, String eMail,                               String creditCardHolderName,                               String CreditCardNumber,                               String creditCardExpirationDate,                               String creditCardType) throws SmartTicketFacadeException {        if (account != null && account.getUserName().equals(userName)) {            account.setPassword(password);            account.setFirstName(firstName);            account.setLastName(lastName);            account.setZipCode(zipCode);            account.setEMail(eMail);            account.setCreditCardNumber(CreditCardNumber);            account.setCreditCardHolderName(creditCardHolderName);            account.setCreditCardExpirationDate(creditCardExpirationDate);            account.setCreditCardType(creditCardType);            return;        }         throw new SmartTicketFacadeException("User not logged in.");    }     public TheaterLocal[] getTheaters(String zipCode)             throws SmartTicketFacadeException {        try {            return (TheaterLocal[]) new ArrayList(theaterHome.findByZipCode(zipCode)).toArray(new TheaterLocal[0]);        } catch (FinderException fe) {            throw new SmartTicketFacadeException("No matching theaters.");        }     }     public MovieScheduleLocal[] getMovieSchedules(String theaterId)             throws SmartTicketFacadeException {        try {            return (MovieScheduleLocal[]) new ArrayList(theaterHome.findByPrimaryKey(theaterId).getSchedule().getMovieSchedules()).toArray(new MovieScheduleLocal[0]);        } catch (FinderException fe) {            throw new SmartTicketFacadeException("No matching movie schedules.");        }     }     public MovieLocal getMovie(String movieId)             throws SmartTicketFacadeException {        try {            return movieHome.findByPrimaryKey(movieId);        } catch (FinderException fe) {            throw new SmartTicketFacadeException("No matching movie.");        }     }     public ShowTimePattern[] getMovieShowTimes(String theaterId, String movieId)             throws SmartTicketFacadeException {        try {            return movieScheduleHome.findByPrimaryKey(new MovieSchedulePK(theaterId,                     movieId)).getShowTimePatterns();        } catch (FinderException fe) {            throw new SmartTicketFacadeException("No matching movie schedule.");        }     }     public Seating getSeating(String theaterId, String movieId, ShowTime showTime)             throws SmartTicketFacadeException {        try {            return movieScheduleHome.findByPrimaryKey(new MovieSchedulePK(theaterId,                     movieId)).getShow(showTime).getSeating();        } catch (FinderException fe) {            throw new SmartTicketFacadeException("No matching movie show.");        }     }     public ReservationData reserveSeats(String theaterId, String movieId,                                         ShowTime showTime,                                         Seat[] seats) throws SmartTicketFacadeException {        if (ticketing != null) {            return ticketing.reserveSeats(theaterId, movieId, showTime,                                           seats);        }         throw new SmartTicketFacadeException("User not logged in.");    }     public void purchaseTickets(String reservationId)             throws SmartTicketFacadeException {        if (ticketing != null) {            ticketing.purchaseTickets(reservationId);            return;        }         throw new SmartTicketFacadeException("User not logged in.");    }     public void cancelSeatReservation(String reservationId)             throws SmartTicketFacadeException {        if (ticketing != null) {            ticketing.cancelSeatReservation(reservationId);            return;        }         throw new SmartTicketFacadeException("User not logged in.");    }     public SyncClientAnchor initiateSynchronization(SyncClientAnchor syncClientAnchor,             long clientTime) throws SmartTicketFacadeException {        if (synchronizing != null) {            return synchronizing.initiateSynchronization(syncClientAnchor,                     clientTime);        }         throw new SmartTicketFacadeException("User not logged in.");    }     public MovieRatingData[] synchronizeMovieRatings(MovieRatingData[] movieRatings,             int conflictResolutionStrategyId) throws SmartTicketFacadeException {        if (synchronizing != null) {            return synchronizing.synchronizeMovieRatings(movieRatings,                     conflictResolutionStrategyId);        }         throw new SmartTicketFacadeException("User not logged in.");    }     public MovieRatingData[] commitMovieRatings(MovieRatingData[] movieRatings)             throws SmartTicketFacadeException {        if (synchronizing != null) {            return synchronizing.commitMovieRatings(movieRatings);        }         throw new SmartTicketFacadeException("User not logged in.");    }     public MovieRatingLocal[] getMovieRatings()             throws SmartTicketFacadeException {        if (account != null) {            return (MovieRatingLocal[]) new ArrayList(account.getMovieRatings()).toArray(new MovieRatingLocal[0]);        }         throw new SmartTicketFacadeException("User not logged in.");    }     public MovieRatingLocal getMovieRating(String movieId)             throws SmartTicketFacadeException {        if (account != null) {            return account.getMovieRating(movieId);        }         throw new SmartTicketFacadeException("User not logged in.");    } }

⌨️ 快捷键说明

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