Advertisement
Guest User

Untitled

a guest
Aug 6th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.04 KB | None | 0 0
  1. package beans;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.SQLException;
  5. import java.sql.*;
  6. import database.Db_Connection;
  7. import java.util.logging.Level;
  8. import java.util.logging.Logger;
  9.  
  10. public class demande
  11.  
  12. {
  13. private String user_name,user_email,user_job,equipement,centre_cout,localisation,destinataire,priorite,observation;
  14.  
  15. int Id;
  16. private String date,dateSouhaite;
  17.  
  18. public demande(){
  19. user_name="";
  20. user_email="";
  21. user_job="";
  22. equipement="";
  23. centre_cout="";
  24. localisation="";
  25. destinataire="";
  26. priorite="";
  27. observation="";
  28. Id=1;
  29.  
  30. date=null;
  31.  
  32. dateSouhaite=null;
  33.  
  34.  
  35. }
  36.  
  37.  
  38. public demande(String user_name, String user_email, String user_job, String equipement, String centre_cout, String localisation, String destinataire, String priorite, String observation, int Id, String date, String dateSouhaite) {
  39. this.user_name = user_name;
  40. this.user_email = user_email;
  41. this.user_job = user_job;
  42. this.equipement = equipement;
  43. this.centre_cout = centre_cout;
  44. this.localisation = localisation;
  45. this.destinataire = destinataire;
  46. this.priorite = priorite;
  47. this.observation = observation;
  48. this.Id = Id;
  49. this.date = date;
  50. this.dateSouhaite = dateSouhaite;
  51. }
  52.  
  53.  
  54.  
  55.  
  56. //----------------------------------//
  57. public String getDate() {
  58. return date;
  59. }
  60.  
  61. public String getCentre_cout() {
  62. return centre_cout;
  63. }
  64.  
  65. public String getDateSouhaite() {
  66. return dateSouhaite;
  67. }
  68.  
  69. public String getDestinataire() {
  70. return destinataire;
  71. }
  72.  
  73. public int getId() {
  74. return Id;
  75. }
  76.  
  77. public void setId(int Id) {
  78. this.Id = Id;
  79. }
  80.  
  81.  
  82.  
  83. public String getEquipement() {
  84. return equipement;
  85. }
  86.  
  87. public String getLocalisation() {
  88. return localisation;
  89. }
  90.  
  91. public String getObservation() {
  92. return observation;
  93. }
  94.  
  95. public String getPriorite() {
  96. return priorite;
  97. }
  98.  
  99. public String getUser_job() {
  100. return user_job;
  101. }
  102.  
  103. public String getUser_email() {
  104. return user_email;
  105. }
  106.  
  107. public String getUser_name() {
  108. return user_name;
  109. }
  110.  
  111. public void setCentre_cout(String centre_cout) {
  112. this.centre_cout = centre_cout;
  113. }
  114.  
  115. public void setDate(String date) {
  116. this.date = date;
  117. }
  118.  
  119. public void setDateSouhaite(String dateSouhaite) {
  120. this.dateSouhaite = dateSouhaite;
  121. }
  122.  
  123. public void setDestinataire(String destinataire) {
  124. this.destinataire = destinataire;
  125. }
  126.  
  127. public void setEquipement(String equipement) {
  128. this.equipement = equipement;
  129. }
  130.  
  131. public void setLocalisation(String localisation) {
  132. this.localisation = localisation;
  133. }
  134.  
  135. public void setObservation(String observation) {
  136. this.observation = observation;
  137. }
  138.  
  139.  
  140.  
  141. public void setPriorite(String priorite) {
  142. this.priorite = priorite;
  143. }
  144.  
  145. public void setUser_email(String user_email) {
  146. this.user_email = user_email;
  147. }
  148.  
  149. public void setUser_job(String user_job) {
  150. this.user_job = user_job;
  151. }
  152.  
  153. public void setUser_name(String user_name) {
  154. this.user_name = user_name;
  155. }
  156.  
  157. //----------------------------------//
  158.  
  159. public void RegisterDemande()
  160. {
  161. try
  162. {
  163. Db_Connection dbconn=new Db_Connection();
  164. Connection myconnection= dbconn.Connection();
  165.  
  166. String sqlString="INSERT INTO demandes(user_name,user_email,user_job,equipement,centre_cout,localisation,destinataire,priorite,observation,date,dateSouhaite) VALUES ('"+user_name+","+user_email+","+user_job+","+equipement+","+centre_cout+","+localisation+","+destinataire+","+priorite+","+observation+","+date+","+dateSouhaite+"')";
  167.  
  168. Statement myStatement = myconnection.createStatement();
  169.  
  170. try
  171. {
  172. myStatement.executeUpdate(sqlString);
  173. myStatement.close();
  174. myconnection.close();
  175. } catch (SQLException ex) {Logger.getLogger(demande.class.getName()).log(Level.SEVERE, null, ex);}
  176. } catch (SQLException ex) {Logger.getLogger(demande.class.getName()).log(Level.SEVERE, null, ex);}
  177. }
  178.  
  179. //----------------------------------//
  180.  
  181. /* public static boolean LoginUser(String user,String pwd)
  182. {
  183. boolean check =false;
  184. try
  185. {
  186. Db_Connection dbconn=new Db_Connection();
  187. Connection myconnection= dbconn.Connection();
  188.  
  189. PreparedStatement ps1 =myconnection.prepareStatement("select * from users where username=? and password=?");
  190.  
  191. ps1.setString(1, user);
  192. ps1.setString(2, pwd);
  193. ResultSet rs1 =ps1.executeQuery();
  194. check = rs1.next();
  195.  
  196. myconnection.close();
  197. }catch(Exception e){e.printStackTrace();}
  198.  
  199. return check;
  200. }
  201. */
  202. //----------------------------------//
  203.  
  204. public void GetDemande()
  205. {
  206. try
  207. {
  208. Db_Connection dbconn=new Db_Connection();
  209. Connection myconnection= dbconn.Connection();
  210.  
  211. String sqlString = "SELECT * FROM demandes WHERE Id = '"+Id+"'";
  212. Statement myStatement = myconnection.createStatement();
  213. ResultSet rs=myStatement.executeQuery(sqlString);
  214.  
  215. while(rs.next())
  216. {
  217.  
  218. user_name=rs.getString("user_name");
  219. user_email=rs.getString("user_email");
  220. user_job=rs.getString("user_job");
  221. equipement=rs.getString("equipement");
  222. centre_cout=rs.getString("centre_cout");
  223. localisation=rs.getString("localisation");
  224. destinataire=rs.getString("destinataire");
  225. priorite=rs.getString("priorite");
  226. observation=rs.getString("observation");
  227.  
  228.  
  229. date=rs.getString("date");
  230.  
  231. date =rs.getString("dateSouhaite");
  232.  
  233. }
  234.  
  235. myStatement.close();
  236. myconnection.close();
  237.  
  238. } catch (SQLException ex) {Logger.getLogger(demande.class.getName()).log(Level.SEVERE, null, ex);}
  239.  
  240. }
  241.  
  242. //----------------------------------//
  243.  
  244. public void parseInt(String parameter) {
  245. throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  246. }
  247.  
  248. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement