Ejemplo n.º 1
0
  public void llenarMovimientos() {
    String mQuery = "";
    try {
      catmovimientos = new CatMovimientos();
      movimientos = new ArrayList<>();

      mQuery =
          "select id_mov, nom_mov, "
              + "case flg_tip when '0' then 'Entrada' when '1' then 'Salida' end as flg_tip "
              + "from cat_mov order by flg_tip;";
      ResultSet resVariable;
      Accesos mAccesos = new Accesos();
      mAccesos.Conectar();
      resVariable = mAccesos.querySQLvariable(mQuery);
      while (resVariable.next()) {
        movimientos.add(
            new CatMovimientos(
                resVariable.getString(1), resVariable.getString(2), resVariable.getString(3)));
      }
      mAccesos.Desconectar();

    } catch (Exception e) {
      System.out.println(
          "Error en el llenado de Catálogo Movimientos. " + e.getMessage() + " Query: " + mQuery);
    }
  }
Ejemplo n.º 2
0
 public boolean validardatos() {
   boolean mValidar = true;
   if ("false".equals(flg_tip)) {
     flg_tip = "0";
   } else {
     flg_tip = "1";
   }
   if ("".equals(nom_mov) == true) {
     mValidar = false;
     addMessage("Validar Datos", "Debe Ingresar un Nombre para el Tipo de Movimiento.", 2);
   }
   Accesos maccesos = new Accesos();
   maccesos.Conectar();
   if ("0"
               .equals(
                   maccesos.strQuerySQLvariable(
                       "select count(id_mov) from cat_mov "
                           + "where upper(nom_mov)='"
                           + nom_mov.toUpperCase()
                           + "';"))
           == false
       && "".equals(id_mov)) {
     mValidar = false;
     addMessage("Validar Datos", "El Nombre del tipo de Movimiento ya existe.", 2);
   }
   maccesos.Desconectar();
   return mValidar;
 }
Ejemplo n.º 3
0
 public void guardar() {
   String mQuery = "";
   if (validardatos()) {
     try {
       Accesos mAccesos = new Accesos();
       mAccesos.Conectar();
       if ("".equals(id_mov)) {
         mQuery = "select ifnull(max(id_mov),0)+1 as codigo from cat_mov;";
         id_mov = mAccesos.strQuerySQLvariable(mQuery);
         mQuery =
             "insert into cat_mov (id_mov,nom_mov,flg_tip) "
                 + "values ("
                 + id_mov
                 + ",'"
                 + nom_mov
                 + "', "
                 + flg_tip
                 + ");";
       } else {
         mQuery =
             "update cat_mov SET "
                 + " nom_mov = '"
                 + nom_mov
                 + "', "
                 + " flg_tip = "
                 + flg_tip
                 + " "
                 + "WHERE id_mov = "
                 + id_mov
                 + ";";
       }
       mAccesos.dmlSQLvariable(mQuery);
       mAccesos.Desconectar();
       addMessage("Guardar Movimientos", "Información Almacenada con éxito.", 1);
     } catch (Exception e) {
       addMessage(
           "Guardar Movimientos",
           "Error al momento de guardar la información. " + e.getMessage(),
           2);
       System.out.println("Error al Guardar Movimientos. " + e.getMessage() + " Query: " + mQuery);
     }
     llenarMovimientos();
   }
   nuevo();
 }
Ejemplo n.º 4
0
  @Override
  public void run() {
    synchronized (ac) {
      int actual = ac.getValor();
      actual++;

      try {
        ac.wait(1000);
        ac.notify();
        Thread.sleep(100);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

      ac.setValor(actual);
      System.out.println("Total de accesos " + ac.getValor());
    }
  }
Ejemplo n.º 5
0
 public void eliminar() {
   String mQuery = "";
   Accesos mAccesos = new Accesos();
   mAccesos.Conectar();
   if ("".equals(id_mov) == false) {
     try {
       mQuery = "delete from cat_mov where id_mov=" + id_mov + ";";
       mAccesos.dmlSQLvariable(mQuery);
       addMessage("Eliminar Movimiento", "Información Eliminada con éxito.", 1);
     } catch (Exception e) {
       addMessage(
           "Eliminar Movimiento",
           "Error al momento de Eliminar la información. " + e.getMessage(),
           2);
       System.out.println("Error al Eliminar Movimiento. " + e.getMessage() + " Query: " + mQuery);
     }
     llenarMovimientos();
     nuevo();
   } else {
     addMessage("Eliminar Familia", "Debe elegir un Registro.", 2);
   }
   mAccesos.Desconectar();
 }