Beispiel #1
0
  public void enregistrer_login() {
    String sql,
        nomI,
        prenomI,
        date_naissanceI,
        emailI,
        passwordI1,
        passwordI2,
        adresseI,
        villeI,
        code_postalI,
        telephoneI,
        mobileI,
        id_couleurI,
        type_utilisateurI;

    Connexion maBDD = new Connexion("localhost", "root", "", "autodrive");
    maBDD.seConnecter();
    try {
      nomI = this.nomI.getText();
      prenomI = this.prenomI.getText();
      date_naissanceI = this.date_naissanceI.getText();
      emailI = this.emailI.getText();
      passwordI1 = this.passwordI1.getText();
      passwordI2 = this.passwordI2.getText();
      adresseI = this.adresseI.getText();
      villeI = this.villeI.getText();
      code_postalI = this.code_postalI.getText();
      telephoneI = this.telephoneI.getText();
      mobileI = this.mobileI.getText();

      // moyPaiement=txtmoy.getSelectedText();
      System.out.println(
          nomI
              + " "
              + prenomI
              + " "
              + date_naissanceI
              + ""
              + emailI
              + " "
              + passwordI1
              + " "
              + adresseI
              + " "
              + villeI
              + ""
              + code_postalI
              + " "
              + telephoneI
              + " "
              + mobileI);

      // insertion
      Statement unStatement = maBDD.getConnection().createStatement();
      // ResultSet unResultat = unStatement.executeQuery(sql);
      sql =
          "INSERT INTO utilisateurs (nom,prenom,date_naissance,email,password,adresse,ville,code_postal,telephone,mobile) VALUES ('"
              + this.nomI.getText()
              + "','"
              + this.prenomI.getText()
              + "','"
              + this.date_naissanceI.getText()
              + "','"
              + this.emailI.getText()
              + "','"
              + this.passwordI1.getText()
              + "','"
              + this.adresseI.getText()
              + "','"
              + this.villeI.getText()
              + "','"
              + this.code_postalI.getText()
              + "','"
              + this.telephoneI.getText()
              + "','"
              + this.mobileI.getText()
              + ")";
      unStatement.executeUpdate(sql);
      // System.out.println(sql+" ligne insérée");
      JOptionPane.showMessageDialog(this, "Votre compte à bien été ajouter");
      unStatement.close();
      unStatement.close();

    } catch (SQLException exp) {
      JOptionPane.showMessageDialog(
          null, exp.getMessage(), "ERREUR SUR LA REQUETTE ! ", JOptionPane.ERROR_MESSAGE);
    }
    maBDD.seDeconnecter();
  }
Beispiel #2
0
  public void enregistrer_edit() {

    String sql,
        nom,
        prenom,
        date_naissance,
        email,
        password1,
        password2,
        adresse,
        ville,
        code_postal,
        telephone,
        mobile,
        id_couleur,
        type_utilisateur;

    Connexion maBDD = new Connexion("localhost", "root", "", "autodrive");
    maBDD.seConnecter();
    try {
      nom = this.nom.getText();
      prenom = this.prenom.getText();
      date_naissance = this.date_naissance.getText();
      email = this.email.getText();
      password1 = this.password1.getText();
      password2 = this.password2.getText();
      adresse = this.adresse.getText();
      ville = this.ville.getText();
      code_postal = this.code_postal.getText();
      telephone = this.telephone.getText();
      mobile = this.mobile.getText();

      /*		calendar_id=this.calendar_id.getToolTipText();
      utc_id=this.utc_id.getToolTipText();
      title=this.title.getToolTipText(); */

      // moyPaiement=txtmoy.getSelectedText();
      System.out.println(
          nom
              + " "
              + prenom
              + " "
              + date_naissance
              + ""
              + email
              + " "
              + password1
              + " "
              + adresse
              + " "
              + ville
              + ""
              + code_postal
              + " "
              + telephone
              + " "
              + mobile);

      // insertion
      Statement unStatement = maBDD.getConnection().createStatement();
      // ResultSet unResultat = unStatement.executeQuery(sql);
      sql =
          "UPDATE utilisateurs SET nom = nom, prenom = prenom, date_naissance = date_naissance, email = email, password1 = password, adresse = adresse, ville = ville, code_postal = code_postal, telephone = telephone, mobile = mobile where id_utilisateur = id_utilisateur";

      unStatement.executeUpdate(sql);
      // System.out.println(sql+" ligne insérée");
      JOptionPane.showMessageDialog(this, "Votre compte à bien été modifier");

      unStatement.close();
      unStatement.close();

    } catch (SQLException exp) {
      JOptionPane.showMessageDialog(
          null, exp.getMessage(), "ERREUR SUR LA REQUETTE ! ", JOptionPane.ERROR_MESSAGE);
    }
    maBDD.seDeconnecter();
  }