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 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.bean;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import java.util.logging.*;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
//import javax.persistence.Entity;
/**
*
* @author Haythem
*/
@ManagedBean
@SessionScoped
public class NouvelleCompagne implements Serializable{
static Logger log = Logger.getLogger(NouvelleCompagne.class.getName());
// paramètres générals
private String societe;
private String compagne;
private String description;
// paramètres budget & investissement
private String type_compagne;
private double prix_unitaire;
private String type_invest;
private String texte;
private String header;
private List<String> critere_envoi;
// cibles et critères
private String public_vise;
private String tranche_age;
private List<String> consommation;
private String critere_ville;
//somme total
private double budget_estime;
private int nbre_clients;
/*---------------------------------------------------------------
* DIVERS METHODES
*---------------------------------------------------------------
*/
public double calculeSomme(double prix_unitaire, int nb){
budget_estime= prix_unitaire* nb;
return budget_estime;
}
public static Boolean AddCompagne(String name, String description, String texte, String header, Double budget, int nb)
{
Statement stmt = null;
Boolean res=false;
Connection conn=null;
String sqlInsert= "insert into compagne (name , description, texte, header, budget, nb ) values ('"+ name + "' , '"+ description + "', '"+ texte + "', '"+ header + "', '"+ budget + "', '"+ nb+ "')";
try
{
System.out.println("1");
conn=com.util.ConnectionPool.getConnection();
System.out.println("2");
stmt = conn.createStatement();
System.out.println("3");
stmt.execute(sqlInsert);
System.out.println("success");
conn.commit();
res = true;
}
catch (SQLException e)
{
try
{
System.out.println("erreur");
conn.rollback();
}
catch (SQLException e1)
{
//log.error(e1.getMessage());
System.out.println("erreur2");
e1.printStackTrace();
}
//log.error(e.getMessage());
e.printStackTrace();
}
finally
{
try
{
stmt.close();
}
catch (SQLException e)
{
//log.error(e.getMessage());
e.printStackTrace();
}
}
//log.debug("New Client Inserted:"+res+"\n");
return res;
}
/*------------------------------------------------------------------------------------------------
----------------------------------- GETTER AND SETTER --------------------------------------------
* -----------------------------------------------------------------------------------------------
*/
public double getBudget_estime() {
return budget_estime;
}
public void setBudget_estime(double budget_estime) {
this.budget_estime = budget_estime;
}
public String getCompagne() {
return compagne;
}
public void setCompagne(String compagne) {
this.compagne = compagne;
}
public List<String> getCritere_envoi() {
return critere_envoi;
}
public List<String> getConsommation() {
return consommation;
}
public void setConsommation(List<String> consommation) {
this.consommation = consommation;
}
public void setCritere_envoi(List<String> critere_envoi) {
this.critere_envoi = critere_envoi;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getNbre_clients() {
return nbre_clients;
}
public void setNbre_clients(int nbre_clients) {
this.nbre_clients = nbre_clients;
}
public double getPrix_unitaire() {
return prix_unitaire;
}
public void setPrix_unitaire(double prix_unitaire) {
this.prix_unitaire = prix_unitaire;
}
public String getPublic_vise() {
return public_vise;
}
public void setPublic_vise(String public_vise) {
this.public_vise = public_vise;
}
public String getSociete() {
return societe;
}
public void setSociete(String societe) {
this.societe = societe;
}
public String getTranche_age() {
return tranche_age;
}
public void setTranche_age(String tranche_age) {
this.tranche_age = tranche_age;
}
public String getType_compagne() {
return type_compagne;
}
public void setType_compagne(String type_compagne) {
this.type_compagne = type_compagne;
}
public String getType_invest() {
return type_invest;
}
public void setType_invest(String type_invest) {
this.type_invest = type_invest;
}
public String getCritere_ville() {
return critere_ville;
}
public void setCritere_ville(String critere_ville) {
this.critere_ville = critere_ville;
}
public String getHeader() {
return header;
}
public void setHeader(String header) {
this.header = header;
}
public String getTexte() {
return texte;
}
public void setTexte(String texte) {
this.texte = texte;
}
} |
Partager