diff --git a/GSBapplication/src/Metier/Observation.java b/GSBapplication/src/Metier/Observation.java
index 8ad7ccc..4fd5939 100644
--- a/GSBapplication/src/Metier/Observation.java
+++ b/GSBapplication/src/Metier/Observation.java
@@ -14,8 +14,15 @@ public class Observation {
* observation = l'observation d'un médicament
*/
private String observation;
+ private String idMedoc;
+ private int idPraticien;
-
+ //Constructeur
+ public Observation(String idMedoc,int idPraticien, String observ){
+ this.idMedoc = idMedoc;
+ this.idPraticien = idPraticien;
+ this.observation = observ;
+ }
//LES GUETTEUR
/**
@@ -25,6 +32,21 @@ public class Observation {
return observation;
}
+ /**
+ * @return l'identifiant du médicament
+ */
+ public String getIdMedoc(){
+ return this.idMedoc;
+ }
+
+ /**
+ *
+ * @return l'identifiant du praticien
+ */
+ public int getIdPraticien(){
+ return this.idPraticien;
+ }
+
diff --git a/GSBapplication/src/acces_aux_donnes/observationSQL.java b/GSBapplication/src/acces_aux_donnes/observationSQL.java
index 3bff386..2789b3b 100644
--- a/GSBapplication/src/acces_aux_donnes/observationSQL.java
+++ b/GSBapplication/src/acces_aux_donnes/observationSQL.java
@@ -4,10 +4,60 @@
*/
package acces_aux_donnes;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
/**
*
* @author emile.lalorcey
*/
public class observationSQL {
+ private Connection connexionTest;
+ private Statement stmt = null;
+ private ResultSet result = null;
+ public observationSQL() {
+ connexionTest = connexionSQL.getConnect("10.121.38.75","bdgsb","adminGSB","mdpGSB");
+ }
+
+ public int compterLignes(){
+ int nbLignes = 0;
+ try {
+ stmt = connexionTest.createStatement();
+ // Accès à la table
+ result = stmt.executeQuery("SELECT COUNT(idObservation) From OBSERVATION");
+ if (result.next()) {
+ nbLignes = Integer.parseInt(result.getString(1));
+ }
+ result.close();
+ stmt.close();
+ } catch (SQLException ex) {
+ System.out.println("SQLException : " + ex.getMessage());
+ System.out.println("SQLState : " + ex.getSQLState());
+ System.out.println("Code erreur : " + ex.getErrorCode());
+ }
+ return nbLignes;
+ }
+
+
+ public int ajouterObservation(String idMedoc, int idPraticien, String observation){
+ int passer = 1000;
+ int nbLignes = this.compterLignes();
+ try {
+ stmt = connexionTest.createStatement();
+ // Accès à la table
+ passer = stmt.executeUpdate("INSERT INTO OBSERVATION(idObservation, idMedoc, idPraticien, observation) "
+ + "VALUES ("+(nbLignes+1)+",'"+idMedoc+"',"+idPraticien+",\""+observation+"\");");
+
+ result.close();
+ stmt.close();
+ }catch (SQLException ex) {
+ System.out.println("SQLException : " + ex.getMessage());
+ System.out.println("SQLState : " + ex.getSQLState());
+ System.out.println("Code erreur : " + ex.getErrorCode());
+ }
+ return passer;
+ }
}
diff --git a/GSBapplication/src/presentation/jffAjoutObservation.form b/GSBapplication/src/presentation/jffAjoutObservation.form
index 769eecd..9b0db47 100644
--- a/GSBapplication/src/presentation/jffAjoutObservation.form
+++ b/GSBapplication/src/presentation/jffAjoutObservation.form
@@ -23,13 +23,84 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GSBapplication/src/presentation/jffAjoutObservation.java b/GSBapplication/src/presentation/jffAjoutObservation.java
index c5d9af7..52c9f73 100644
--- a/GSBapplication/src/presentation/jffAjoutObservation.java
+++ b/GSBapplication/src/presentation/jffAjoutObservation.java
@@ -4,17 +4,22 @@
*/
package presentation;
+import acces_aux_donnes.observationSQL;
+
/**
*
* @author emile.lalorcey
*/
public class jffAjoutObservation extends javax.swing.JFrame {
-
+ private String idMedoc;
+ private int idPraticien;
/**
* Creates new form jffAjoutObservation
*/
- public jffAjoutObservation() {
+ public jffAjoutObservation(String idMedoc,int idPraticien) {
initComponents();
+ this.idMedoc = idMedoc;
+ this.idPraticien = idPraticien;
}
/**
@@ -26,22 +31,73 @@ public class jffAjoutObservation extends javax.swing.JFrame {
// //GEN-BEGIN:initComponents
private void initComponents() {
+ jLabel1 = new javax.swing.JLabel();
+ jLTitre = new javax.swing.JLabel();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ jTAobservation = new javax.swing.JTextArea();
+ jBsoumettre = new javax.swing.JButton();
+
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+ jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/logodetoure.gif"))); // NOI18N
+
+ jLTitre.setText("Soumettez votre observation");
+
+ jTAobservation.setColumns(20);
+ jTAobservation.setRows(5);
+ jScrollPane1.setViewportView(jTAobservation);
+
+ jBsoumettre.setText("Soumettre");
+ jBsoumettre.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jBsoumettreActionPerformed(evt);
+ }
+ });
+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 400, Short.MAX_VALUE)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jLTitre)
+ .addGap(65, 65, 65)
+ .addComponent(jLabel1))
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGap(23, 23, 23)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 348, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(layout.createSequentialGroup()
+ .addGap(158, 158, 158)
+ .addComponent(jBsoumettre)))
+ .addGap(0, 23, Short.MAX_VALUE)))
+ .addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 300, Short.MAX_VALUE)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(jLabel1)
+ .addComponent(jLTitre))
+ .addGap(18, 18, 18)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(18, 18, 18)
+ .addComponent(jBsoumettre)
+ .addContainerGap(46, Short.MAX_VALUE))
);
pack();
}// //GEN-END:initComponents
+ private void jBsoumettreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBsoumettreActionPerformed
+ observationSQL observ = new observationSQL();
+ observ.ajouterObservation(this.idMedoc, this.idPraticien, jTAobservation.getText());
+ }//GEN-LAST:event_jBsoumettreActionPerformed
+
/**
* @param args the command line arguments
*/
@@ -72,11 +128,16 @@ public class jffAjoutObservation extends javax.swing.JFrame {
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
- new jffAjoutObservation().setVisible(true);
+ //new jffAjoutObservation().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton jBsoumettre;
+ private javax.swing.JLabel jLTitre;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JTextArea jTAobservation;
// End of variables declaration//GEN-END:variables
}