package com.tarisan.control; import com.tarisan.data.*; import com.tarisan.excepcion.*; import com.tarisan.log.*; import com.tarisan.util.Utilidades; import java.sql.*; import java.util.Calendar; import java.util.Vector; public class PersistenciaTamovextDental { public int obtenerUltimoValorNumSeq(int medico) throws ExcepcionTarisan { StringBuffer strSql = new StringBuffer(); Object aCondiciones[]=null; int intUltimoValorNumseq = 1; try { strSql.append("SELECT MAX(numseq) as max_numseq"); strSql.append(" FROM tamovext_dental"); strSql.append(" WHERE medico=?"); aCondiciones = new Object[1]; aCondiciones[0]=Integer.valueOf(medico); Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion(); ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, strSql.toString(), aCondiciones); //nos posicionamos en el registro if (rs.next()) //obtenemos el campo PARAM1 intUltimoValorNumseq = rs.getInt("MAX_NUMSEQ"); rs.close(); ParametrosConfiguracion.dataStore.liberarConexion(conexion); LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionado el valor " + intUltimoValorNumseq + " del campo NUMSEQ de la tabla TAMOVEXT_DENTAL (" + strSql.toString() + ")"); } catch (ExcepcionTarisan sqle) { LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMOVEXT_DENTAL: " + sqle + " (" + strSql.toString() + ")"); throw (ExcepcionTarisan)sqle; } catch(SQLException sqle) { LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMOVEXT_DENTAL: " + sqle + " (" + strSql.toString() + ")"); throw new ExcepcionTarisan(sqle.getMessage()); } catch(Exception sqle) { LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMOVEXT_DENTAL: " + sqle + " (" + strSql.toString() + ")"); throw new ExcepcionTarisan(sqle.getMessage()); } catch(Throwable sqle) { LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMOVEXT_DENTAL: " + sqle + " (" + strSql.toString() + ")"); throw new ExcepcionTarisan(sqle.getMessage()); } return intUltimoValorNumseq; } public boolean insertarTamovextDental(Object[] aValores, Connection conexion) { boolean resultado = false; StringBuffer strSql = new StringBuffer(); strSql.append("INSERT INTO TAMOVEXT_DENTAL"); strSql.append(" (MEDICO, ESPECIALIDAD, ACTO, NUMSEQ, COLECTIVO, POLIZA, ORDEN, FECHA, PRECIO, PRESCRIPTOR, ENTIDAD, TARJETA_CHIPCARD, AUTORIZACION, ESPECIALIDAD_CHIPCARD, ACTO_CHIPCARD)"); strSql.append(" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); try { ParametrosConfiguracion.dataStore.insertar(strSql.toString(), aValores, conexion); resultado = true; } catch (ExcepcionTarisan sqle) { LogTarisan.logger.log(NivelLog.ERROR, "Error en la insercion de TAMOVEXT_DENTAL: " + sqle + " (" + strSql + ")"); } catch(Exception sqle) { LogTarisan.logger.log(NivelLog.ERROR, "Error en la insercion de TAMOVEXT_DENTAL: " + sqle + " (" + strSql + ")"); } return resultado; } }