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; }
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(); }