Package beanStaff

Source Code of beanStaff.beanPrize

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package beanStaff;

import Business.business;
import EntityBean.Prize;
import SessionBean.EventsLocal;
import SessionBean.PrizeSSBLocal;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import helper.messages;
import java.util.ArrayList;
import java.util.List;
import javax.faces.application.FacesMessage;
/**
*
* @author Huynh Kim Toan
*/
@ManagedBean(name = "STAFFPRIZE")
@RequestScoped
public class beanPrize {

    @EJB
    private EventsLocal eventsFacade;
    @EJB
    private PrizeSSBLocal prizeFacade;
    private Prize prizes = new Prize();
    private String title;
    private int eventID;
    private String fullname;

 
    private String prize;
   

    /** Creates a new instance of beanPrize */
    public beanPrize() {
    }

    public void CreatePrize() {
//        prizes.setPrize(prize);
          try {
        if(fullname.length()==0)
        {
          messages.taoTB(FacesMessage.SEVERITY_ERROR, "UserName Not Null ", "Error");
        }else{
         prizes.setFullname(fullname);
         prizes.setEventID(this.eventsFacade.find(eventID));
         this.prizeFacade.create(prizes);
         messages.taoTB(FacesMessage.SEVERITY_INFO, "Successful", "Successful");
        }
     
                  
        } catch (Exception ex) {
           messages.taoTB(FacesMessage.SEVERITY_ERROR, "Error", "Error");
        }
    }

    public List<Prize> getlistsPrize()
    {
        List<Prize> lst1 = new ArrayList<Prize>();
           int count = new business().getPrizeFacade().count() ;
           if(count <= 3)
           {
              count = new business().getPrizeFacade().count();
           }else
           {
              count = 3;
           }
        for(int i=0; i < count ; i++)
        {       
              Integer[] prizeID = new Integer[3];
              prizeID[i] = new business().getPrizeFacade().findAll().get(i).getPrizeID();
              String[] fullname1 = new String[3];
              fullname1[i= new business().getPrizeFacade().find(prizeID[i]).getFullname();
              lst1.add(new Prize(prizeID[i], new business().getPrizeFacade().find(prizeID[i]).getPrize(), fullname1[i]));       
        }
           return lst1;
    }

    public int getEventID() {
        return eventID;
    }

    public void setEventID(int eventID) {
        this.eventID = eventID;
    }

      public String getFullname() {
        return fullname;
    }

    public void setFullname(String fullname) {
        this.fullname = fullname;
    }
    public String getPrize() {
        return prize;
    }

    public void setPrize(String prize) {
        this.prize = prize;
    }
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Prize getPrizes() {
        return prizes;
    }

    public void setPrizes(Prize prizes) {
        this.prizes = prizes;
    }
}
TOP

Related Classes of beanStaff.beanPrize

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.