1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
|
package com.sungard.beans;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import javax.faces.model.SelectItem;
import antlr.collections.List;
import com.sungard.persistence.Employe;
import com.sungard.service.IEmployeService;
public class EmployeBean {
//private String empId;
Employe employe;
private int id;
private String nom;
private String prenom;
private Date date_embauche;
private float salaire;
private String fonction;
private IEmployeService empServ;
public ArrayList<Employe> employes;
public ArrayList<SelectItem> listIds;
public EmployeBean() {
employe=new Employe();
/*listIds=new ArrayList<SelectItem>();
employes = new ArrayList<Employe>();
employes= empServ.findEmployes();*/
}
public ArrayList<SelectItem> getListIds() {
System.out.println("employes list size: "+getEmployes().size());
if(listIds==null)
listIds=new ArrayList<SelectItem>();
for (Employe emp : getEmployes()) {
SelectItem selectItem=new SelectItem();
selectItem.setLabel(String.valueOf(emp.getId()));
selectItem.setValue(String.valueOf(emp.getId()));
listIds.add(selectItem);
}
System.out.println(listIds);
return listIds;
}
public void setListIds(ArrayList<SelectItem> listIds) {
this.listIds = listIds;
}
public ArrayList<Employe> getEmployes() {
if(employes==null)
employes = empServ.findEmployes();
return employes;
}
public void setEmployes(ArrayList<Employe> employes) {
this.employes = employes;
}
public String addEmployeAction(){
try{
employe.setNom(nom);
System.out.println(nom);
employe.setPrenom(prenom);
System.out.println(prenom);
employe.setDate_embauche(date_embauche);
System.out.println(date_embauche);
employe.setSalaire(salaire);
System.out.println(salaire);
employe.setFonction(fonction);
System.out.println(fonction);
this.empServ.addEmploye(employe);
return "success";
}catch(Exception e){
e.printStackTrace();
return "failure";
}
}
public String deleteEmployeAction(){
try{
this.empServ.deleteEmploye(this.employe);
return "success";
}catch(Exception e){
e.printStackTrace();
return "failure";
}
}
public String updateEmployeAction(){
try{
employe.setNom(nom);
System.out.println(nom);
employe.setPrenom(prenom);
System.out.println(prenom);
employe.setDate_embauche(date_embauche);
System.out.println(date_embauche);
employe.setSalaire(salaire);
System.out.println(salaire);
employe.setFonction(fonction);
System.out.println(fonction);
this.empServ.deleteEmploye(this.employe);
return "success";
}catch(Exception e){
e.printStackTrace();
return "failure";
}
}
public void findAction(int id){
employe=this.empServ.getEmployeById(id);
this.nom=employe.getNom();
this.prenom=employe.getPrenom();
this.date_embauche=employe.getDate_embauche();
this.salaire=employe.getSalaire();
this.fonction=employe.getFonction();
}
public void setEmpServ(IEmployeService empServ) {
this.empServ = empServ;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getPrenom() {
return prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
public Date getDate_embauche() {
return date_embauche;
}
public void setDate_embauche(Date date_embauche) {
this.date_embauche = date_embauche;
}
public float getSalaire() {
return salaire;
}
public void setSalaire(float salaire) {
this.salaire = salaire;
}
public String getFonction() {
return fonction;
}
public void setFonction(String fonction) {
this.fonction = fonction;
}
public IEmployeService getEmpServ() {
return empServ;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
/*public void setEmpId(String empId) {
this.empId = empId;
if(empId!=null && !empId.equals("")){
Integer id=new Integer(empId);
try{
if(empServ!=null){
empServ.getEmployeById(id);
}
}
catch(Exception e){
e.printStackTrace();
}
}
}*/ |
Partager