Package beanAdmin

Source Code of beanAdmin.beanCategory

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

import Business.business;
import EntityBean.EventCategory;
import SessionBean.EventCategorySSBLocal;
import SessionBean.EventsLocal;
import helper.messages;
import helper.operationSession;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
*
* @author ADMIN
*/
@ManagedBean(name = "STAFFCategory")
@RequestScoped
public class beanCategory {

    /**
     * Creates a new instance of beanCategory
     */
    public beanCategory() {
    }
    @EJB
    private EventsLocal eventsFacade;
    @EJB
    private EventCategorySSBLocal cateFacade;
    private EventCategory Category = new EventCategory();
    private String Description;
    private int eventID;
    private String CateName;

 
    private String prize;
   

    /** Creates a new instance of beanCategory */

   
     public String viewDetails(int cateid) {
        operationSession.ganGiaTriChoSession("cateid", String.valueOf(cateid));
        setCategory(new business().getEventCategoryFacade().find(cateid));
        String des = this.Category.getDescription();
        operationSession.ganGiaTriChoSession("des", des);
        Description = this.Category.getDescription();
        CateName = this.Category.getCateName();
       
            return "/admin/ViewDetailCategory";
      
    }
     public void insertCategory() {
           try {
         Category.setCateName(CateName);
         Category.setDescription(Description);
         this.cateFacade.create(Category);
         messages.taoTB(FacesMessage.SEVERITY_INFO, "Successful", "Successful");
           
        } catch (Exception ex) {
           messages.taoTB(FacesMessage.SEVERITY_ERROR, "Error", "Error");
        }

    }
     public void updateCategory() {
                  if (CateName.length() == 0) {
            messages.taoTB(FacesMessage.SEVERITY_ERROR, "Category Name Not null .", "Error");
        } else if (Description.length() == 0) {
            messages.taoTB(FacesMessage.SEVERITY_ERROR, "Description Not null .", "Error");
        } else {
            this.Category = this.cateFacade.find(Integer.parseInt((String)operationSession.layGTSession("cateid")));
           
                Category.setCateName(CateName);
                Category.setDescription(Description);
               
                this.cateFacade.edit(Category);

                messages.taoTB(FacesMessage.SEVERITY_INFO, "update Category Successfull", "Successfull");
           
        }
    }
      public void deleteCategory() {
        this.Category = this.cateFacade.find(operationSession.layGTSession("cateid"));
            this.cateFacade.remove(Category);
            messages.taoTB(FacesMessage.SEVERITY_INFO, "Delete Category Successfull", "Successfull");
      
    }
    public List<EventCategory> getlistsCategory()
    {
        List<EventCategory> lst1 = new ArrayList<EventCategory>();
           int count = new business().getEventCategoryFacade().count() ;
           if(count <= 3)
           {
              count = new business().getEventCategoryFacade().count();
           }else
           {
              count = 3;
           }
        for(int i=0; i < count ; i++)
        {       
              Integer[] CateID = new Integer[3];
              CateID[i] = new business().getEventCategoryFacade().findAll().get(i).getCateID();
              lst1.add(new EventCategory(CateID[i], new business().getEventCategoryFacade().find(CateID[i]).getCateName(),new business().getEventCategoryFacade().find(CateID[i]).getDescription()));       
        }
           return lst1;
    }

    public int getEventID() {
        return eventID;
    }

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

    public String getPrize() {
        return prize;
    }

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

    public String getDescription() {
        return Description;
    }

    public void setDescription(String Description) {
        this.Description = Description;
    }

    public String getCateName() {
        return CateName;
    }

    public void setCateName(String CateName) {
        this.CateName = CateName;
    }

    public EventCategory getPrizes() {
        return Category;
    }

    public EventCategory getCategory() {
        return Category;
    }

    public void setCategory(EventCategory Category) {
        this.Category = Category;
    }
   

    public void setPrizes(EventCategory cate) {
        this.Category = cate;
    }
}
TOP

Related Classes of beanAdmin.beanCategory

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.