/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package beanControl;
import Business.business;
import EntityBean.Events;
import EntityBean.Users;
import SessionBean.EventsLocal;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
/**
*
* @author Huynh Kim Toan
*/
@ManagedBean(name = "VIEWEVENTS")
@RequestScoped
public class viewEvents {
@EJB
private EventsLocal eventsFacade;
private String title;
private String description;
private Users member = new Users();
private Events events = new Events();
public viewEvents() {
}
public List<Events> getList() {
List<Events> list = new ArrayList<Events>();
if(title.length() != 0)
{
list = this.eventsFacade.searchEvents(title);
}
return list;
}
public List<Users> getListFullName() {
List<Users> lst = new ArrayList<Users>();
int loop = new business().getInvolveFacade().count();
if(loop <= 10)
{
loop = new business().getInvolveFacade().count();
}else
{
loop = 10;
}
for (int i = 0; i < loop; i++) {
int[] memberID = new int[10];
memberID[i] = new business().getInvolveFacade().findAll().get(i).getUserID().getUserID();
String[] fullname = new String[10];
fullname[i] = new business().getLoginFacade().find(memberID[i]).getFullname();
lst.add(new Users(memberID[i],"member",new business().getLoginFacade().find(memberID[i]).getUsername(),new business().getLoginFacade().find(memberID[i]).getPassword(), fullname[i], new business().getLoginFacade().find(memberID[i]).getDayofbirth(),
new business().getLoginFacade().find(memberID[i]).getGender(), new business().getLoginFacade().find(memberID[i]).getCity(),
new business().getLoginFacade().find(memberID[i]).getAddress(), new business().getLoginFacade().find(memberID[i]).getCardnumber(),
new business().getLoginFacade().find(memberID[i]).getTelephone(), new business().getLoginFacade().find(memberID[i]).getEmail(),
new business().getLoginFacade().find(memberID[i]).getStatus()));
}
return lst;
}
public List<Events> ListEventByStatus(String status)
{
List<Events> lstEvents = new ArrayList<Events>();
int count = new business().getEventsFacade().count();
if(count <3)
{
count = new business().getEventsFacade().count();
}else
count = 3;
for(int i = 0 ; i < count ; i++)
{
int[] EventID = new int[10];
if(new business().getEventsFacade().findAll().get(i).getStatus().equals(status))
{
EventID[i] = new business().getEventsFacade().findAll().get(i).getEventID();
lstEvents.add(new Events(EventID[i],new business().getEventsFacade().find(EventID[i]).getTitle(),new business().getEventsFacade().find(EventID[i]).getSpeakers(),new business().getEventsFacade().find(EventID[i]).getPrize(), new business().getEventsFacade().find(EventID[i]).getDescription(), new business().getEventsFacade().find(EventID[i]).getConductDate(),new business().getEventsFacade().find(EventID[i]).getAddress(), new business().getEventsFacade().find(EventID[i]).getPeopleQuantity(), new business().getEventsFacade().find(EventID[i]).getFee(), new business().getEventsFacade().find(EventID[i]).getStatus()));
}
}
return lstEvents;
}
public List<Events> listEvent(String status){
List<Events> lstEvents = new ArrayList<Events>();
int count = new business().getEventsFacade().count();
if(status.equalsIgnoreCase("all")){
for(int i = 0 ; i < count ; i++)
{
int[] EventID = new int[50];
EventID[i] = new business().getEventsFacade().findAll().get(i).getEventID();
lstEvents.add(new Events(EventID[i],new business().getEventsFacade().find(EventID[i]).getTitle(),new business().getEventsFacade().find(EventID[i]).getSpeakers(),new business().getEventsFacade().find(EventID[i]).getPrize(), new business().getEventsFacade().find(EventID[i]).getDescription(), new business().getEventsFacade().find(EventID[i]).getConductDate(),new business().getEventsFacade().find(EventID[i]).getAddress(), new business().getEventsFacade().find(EventID[i]).getPeopleQuantity(), new business().getEventsFacade().find(EventID[i]).getFee(), new business().getEventsFacade().find(EventID[i]).getStatus()));
}
}else{
if(count <3)
{
count = new business().getEventsFacade().count();
}else{
count = 3;
}
for(int i = 0 ; i < count ; i++)
{
int[] EventID = new int[50];
if(new business().getEventsFacade().findAll().get(i).getStatus().equals(status))
{
EventID[i] = new business().getEventsFacade().findAll().get(i).getEventID();
lstEvents.add(new Events(EventID[i],new business().getEventsFacade().find(EventID[i]).getTitle(),new business().getEventsFacade().find(EventID[i]).getSpeakers(),new business().getEventsFacade().find(EventID[i]).getPrize(), new business().getEventsFacade().find(EventID[i]).getDescription(), new business().getEventsFacade().find(EventID[i]).getConductDate(),new business().getEventsFacade().find(EventID[i]).getAddress(), new business().getEventsFacade().find(EventID[i]).getPeopleQuantity(), new business().getEventsFacade().find(EventID[i]).getFee(), new business().getEventsFacade().find(EventID[i]).getStatus()));
}
}
}
return lstEvents;
// return eventsFacade.findAll();
}
public String description(Integer title1)
{
setEvents(new business().getEventsFacade().find(title1));
return "/EventDetail";
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
/** Creates a new instance of viewEvents */
public Events getEvents() {
return events;
}
public void setEvents(Events events) {
this.events = events;
}
public Users getMember() {
return member;
}
public void setMember(Users member) {
this.member = member;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}