Пример #1
0
  private void jButton1ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed
    conexioninicio ci = new conexioninicio();
    Connection con = null;

    try {
      Class.forName("org.gjt.mm.mysql.Driver");
      con = DriverManager.getConnection(ci.getURl(), ci.getLogin(), ci.getPassword());
      Statement stmt = con.createStatement();
      String cadenasql =
          "select nombre,apPat,apMat,calle,numExt,colonia,municipio,cp,email,numTel,curp,idadmon,contraseña,nombreest from persona natural join admin natural join estado where idadmon="
              + "'"
              + User
              + "'";
      ResultSet rs = stmt.executeQuery(cadenasql);
      while (rs.next()) {
        nombre.setText(rs.getString("nombre"));
        apPat.setText(rs.getString("apPat"));
        apMat.setText(rs.getString("apMat"));
        calle.setText(rs.getString("calle"));
        num.setText(rs.getString("numExt"));
        colonia.setText(rs.getString("colonia"));
        municipio.setText(rs.getString("municipio"));
        cp.setText(rs.getString("cp"));
        email.setText(rs.getString("email"));
        telefono.setText(rs.getString("numTel"));
        curp.setText(rs.getString("curp"));
        idamin.setText(rs.getString("idadmon"));
        contraseñaactual.setText(rs.getString("contraseña"));
        this.jComboBox1.setSelectedItem(rs.getString("nombreest"));
      }
    } catch (Exception e) {
      System.out.println(e.getMessage());
    } // TODO add your handling code here:
  } // GEN-LAST:event_jButton1ActionPerformed
Пример #2
0
  /** Creates new form PrincipalCliente */
  public ModificarAdmin() {
    initComponents();
    conexioninicio ci = new conexioninicio();
    ci.conectar();
    this.setSize(470, 650);
    this.setLocationRelativeTo(null); // Centra la ventana Splash
    try {
      Connection con = DriverManager.getConnection(ci.getURl(), ci.getLogin(), ci.getPassword());
      //  System.out.println("Conexion a la base de datos cliente realizada con exito! ");
      Statement stmt = con.createStatement();

      ResultSet rs = stmt.executeQuery("SELECT * FROM tienda.estado ;");
      // obteniendo la informacion de las columnas que estan siendo consultadas
      ResultSetMetaData rsMd = rs.getMetaData();
      // La cantidad de columnas que tiene la consulta
      int cantidadColumnas = rsMd.getColumnCount();
      // Establecer como cabezeras el nombre de las columnas

      // Creando las filas para el Jtable
      while (rs.next()) {
        Object[] fila = new Object[cantidadColumnas];
        for (int i = 1; i < cantidadColumnas; i++) {
          jComboBox1.addItem(rs.getObject(i + 1));
        }
      }
      rs.close();
      con.close();

    } catch (Exception e) {

      JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    }
  }
Пример #3
0
  private void jButton3ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton3ActionPerformed
    conexioninicio ci = new conexioninicio();
    Connection con = null;
    Connection con1 = null;

    try {
      Class.forName("org.gjt.mm.mysql.Driver");
      con = DriverManager.getConnection(ci.getURl(), ci.getLogin(), ci.getPassword());
      con1 = DriverManager.getConnection(ci.getURl(), ci.getLogin(), ci.getPassword());
      Statement stmt = con.createStatement();
      Statement stmts = con1.createStatement();
      String cadenasql =
          "UPDATE persona  SET nombre="
              + "'"
              + nombre.getText().toUpperCase()
              + "'"
              + ","
              + "apPat="
              + "'"
              + apPat.getText().toUpperCase()
              + "'"
              + ","
              + "apMat="
              + "'"
              + apMat.getText().toUpperCase()
              + "'"
              + ","
              + "calle="
              + "'"
              + calle.getText().toUpperCase()
              + "'"
              + ","
              + "colonia="
              + "'"
              + colonia.getText().toUpperCase()
              + "'"
              + ","
              + "numExt="
              + num.getText()
              + ","
              + "municipio="
              + "'"
              + municipio.getText().toUpperCase()
              + "'"
              + ","
              + "numTel="
              + "'"
              + telefono.getText()
              + "'"
              + ","
              + "cp="
              + "'"
              + cp.getText()
              + "',"
              + "curp="
              + "'"
              + curp.getText().toUpperCase()
              + "',"
              + "idestado="
              + "'"
              + jComboBox1.getSelectedIndex()
              + "',"
              + "email="
              + "'"
              + email.getText()
              + "' where curp = '"
              + curp.getText()
              + "'";

      String cadenasql2 =
          "UPDATE admin  SET idadmon="
              + "'"
              + idamin.getText()
              + "',curp="
              + "'"
              + curp.getText().toUpperCase()
              + "' where curp = '"
              + curp.getText()
              + "'";

      stmt.executeUpdate(cadenasql);
      stmts.executeUpdate(cadenasql2);
      //   System.out.print("Se han borrado todos los datos");

      JOptionPane.showMessageDialog(this, "ActualizaCION Exitosa");
    } catch (Exception e) {
      System.out.println(e.getMessage());
    } // TODO add your handling code here:
  } // GEN-LAST:event_jButton3ActionPerformed