Package beanStaff

Source Code of beanStaff.RegisteInvolve

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

import Business.business;
import EntityBean.Enroll;
import EntityBean.Events;
import EntityBean.Users;
import SessionBean.EnrollSSBLocal;
import SessionBean.EventsLocal;
import SessionBean.UsersSSBLocal;
import helper.operationSession;
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 = "STAFFINVOVLE")
@RequestScoped
public class RegisteInvolve {

    @EJB
    private EventsLocal eventsFacade;
    @EJB
    private EnrollSSBLocal involveFacade;
    @EJB
    private UsersSSBLocal loginFacade;
    private String user;
    private int quantityRegiste = 0;

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

    public void RegisteEvent() {
        try {
            if (user == null) {
                messages.taoTB(FacesMessage.SEVERITY_ERROR, "User null !", "");
            } else {
                Users login = this.loginFacade.getUserID(user);
                String title = (String) operationSession.layGTSession("title");
                int userID = login.getUserID();
                Enroll involve = this.involveFacade.getAllEnroll(userID, title);
                //involve.setMember1(this.member1Facade.find(memberID));
                involve.setPaymentStatus(true);
                if (involve != null) {
                    if (getQuantity() > 0) {
                        this.involveFacade.edit(involve);
                        messages.taoTB(FacesMessage.SEVERITY_INFO, "activate Succesfull !", "");
                    } else {
                        messages.taoTB(FacesMessage.SEVERITY_ERROR, "Quantity has full !", "");
                    }
                }
            }
        } catch (Exception ex) {
            messages.taoTB(FacesMessage.SEVERITY_ERROR, "activate Error !", "");
        }
    }

    public void deleteRegister() {
        if (user == null) {
            messages.taoTB(FacesMessage.SEVERITY_ERROR, "User null !", "");
        } else {
            Users login = this.loginFacade.getUserID(user);
            String title = (String) operationSession.layGTSession("title");
            int userID = login.getUserID();
            Enroll involve = this.involveFacade.getAllEnroll(userID, title);

            if (involve != null) {
                this.involveFacade.remove(involve);
                messages.taoTB(FacesMessage.SEVERITY_INFO, "Remove Succesfull !", "");
            } else {
                messages.taoTB(FacesMessage.SEVERITY_ERROR, " Error !", "");
            }
        }
    }

    public int getQuantity() {
        Events events = this.eventsFacade.find(operationSession.layGTSession("title"));
        String title = events.getTitle();
        int Quantity = events.getPeopleQuantity();
        for (int i = 0; i < this.involveFacade.count(); i++) {
            if (this.involveFacade.findAll().get(i).getPaymentStatus().equals(true) && this.involveFacade.findAll().get(i).getEventID().getTitle().equals(title)) {
                quantityRegiste++;
            }
        }
        int total = Quantity - quantityRegiste;
        return total;
    }

    public List<Users> getListUser() {
        List<Users> lstUser = new ArrayList<Users>();
        String title = (String) operationSession.layGTSession("title");
        for (int i = 0; i < new business().getInvolveFacade().count(); i++) {
            if (new business().getInvolveFacade().findAll().get(i).getEventID().getTitle().equals(title) && new business().getInvolveFacade().findAll().get(i).getPaymentStatus().equals("pending")) {
                int userID = new business().getInvolveFacade().findAll().get(i).getUserID().getUserID();
                String userName1 = new business().getLoginFacade().find(userID).getUsername();
                lstUser.add(new Users(userID));
            }
        }
        return lstUser;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }
}
TOP

Related Classes of beanStaff.RegisteInvolve

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.