package m05bClasses;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.StringTokenizer;


public class m05bCombo {
    m05bFileLog miLog = new m05bFileLog();
	String persona = "persona";
	
	public String populateCombo(String campoCod, String campoDesc, String tabla, String campoWhere, String codigo, String defecto) 
		throws javax.servlet.ServletException, java.io.IOException { 

		String sql="",cadena="";
		java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;

		try{
		// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();
		// Cargar el combo
				if (!(campoCod.equals("")))  {
						sql = "select " + campoCod + ", " + campoDesc + " from " + tabla ;
						if (!(codigo.equals("")))
							sql += " where " + campoWhere + " = " + codigo;
				}  else   {
						sql = "select " + campoDesc + " from " + tabla ;
				}
				sql += " order by " + campoDesc;
				
				//miLog.addTraza(persona, "Populate Combo", "SQL: " + sql, m05bConstantes.LOG_NIVEL_BAJO);
				m05bPstmt = m05bConn.prepareStatement(sql);
				m05bRS = m05bPstmt.executeQuery();
				while (m05bRS.next() == true){
					if (!(campoCod.equals("")))  {
						if (defecto.equals(m05bRS.getString(campoCod)))
							cadena=cadena+"<option selected value='" + m05bRS.getString(campoCod) + "'>" + m05bRS.getString(campoDesc)+"</option>"; 
			            else
			                cadena=cadena+"<option value='" + m05bRS.getString(campoCod) + "'>" + m05bRS.getString(campoDesc)+"</option>";
					}
					else  {
			                cadena=cadena+"<option value='" + m05bRS.getString(campoDesc)+"'>" + m05bRS.getString(campoDesc)+"</option>";
					}
				}
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);
		} finally {
				// Cerrar la conexion
				try{
					if (m05bRS != null)
						m05bRS.close();
					if (m05bPstmt != null)
						m05bPstmt.close();
					if (m05bConn != null)
						m05bConn.close();
		 		} catch (Exception ex2) {
					miLog.addTraza(ex2);
				}
		}
		return cadena;
	}  // Fin funcion populateCombo
		
	public String popCombo(String campoCod, String campoDesc, String tabla, String campoWhere, String codigo, String defecto) 
		throws javax.servlet.ServletException, java.io.IOException { 

		String sql="",cadena="";
		java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;

		try{
		// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
		// Cargar el combo
				if (!(campoCod.equals("")))  {
						sql = "select " + campoCod + ", " + campoDesc + " from " + tabla ;
						if (!(codigo.equals("")))
							sql += " where " + campoWhere + " = " + codigo;
						sql += " order by 2" ;
				}  else   {
						sql = "select " + campoDesc + " from " + tabla ;
						sql += " order by 1" ;
				}
      			//miLog.addTraza(persona , "popCombo" , "SQL: " + sql, m05bConstantes.LOG_NIVEL_BAJO);
				m05bPstmt = m05bConn.prepareStatement(sql);
			
				m05bRS = m05bPstmt.executeQuery();
				while (m05bRS.next() == true){
					if (!(campoCod.equals("")))  {
						if (defecto.equals(m05bRS.getString(campoCod))){
							cadena=cadena+"<option selected value='" + m05bRS.getString(campoCod) + "'>" + m05bRS.getString(campoDesc)+"</option>"; }
			            else{
			                cadena=cadena+"<option value='" + m05bRS.getString(campoCod) + "'>" +m05bRS.getString(campoDesc)+"</option>";}
			            	
					}
					else  {
			                cadena=cadena+"<option value='" + m05bRS.getString(campoDesc)+"'>" + m05bRS.getString(campoDesc)+"</option>";
					}
				}
 		} catch (Exception ex1) {
 		//	System.out.println(sql);
			miLog.addTraza(ex1);		
		} finally {
			// Cerrar la conexion
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);		
			}
		}
		
		return cadena;
	} // Fin funcion popCombo

	public String popComboLikeDefecto(String campoCod, String campoDesc, String tabla, String campoWhere, String codigo, String defecto) 
	throws javax.servlet.ServletException, java.io.IOException { 

	String sql="",cadena="";
	java.sql.Connection m05bConn = null;
	PreparedStatement m05bPstmt = null;
	ResultSet m05bRS = null;

	try{
	// Abrir la conexion
			m05bConexion miConex = new m05bConexion();
			m05bConn = miConex.getConnection();			
	// Cargar el combo
			if (!(campoCod.equals("")))  {
					sql = "select " + campoCod + ", " + campoDesc + " from " + tabla ;
					if (!(codigo.equals("")))
						sql += " where " + campoWhere + " = " + codigo;
					sql += " order by " + campoDesc;
			}  else   {
					sql = "select " + campoDesc + " from " + tabla ;
					sql += " order by " + campoDesc;
			}
  			//miLog.addTraza(persona , "popCombo" , "SQL: " + sql, m05bConstantes.LOG_NIVEL_BAJO);
  			//miLog.addTraza(persona , "popCombo" , "defecto: " + defecto, m05bConstantes.LOG_NIVEL_BAJO);
			m05bPstmt = m05bConn.prepareStatement(sql);
			m05bRS = m05bPstmt.executeQuery();
			while (m05bRS.next() == true){
				if (!(campoCod.equals("")))  {
					//miLog.addTraza(persona , "popCombo" , "(m05bRS.getString(campoCod).startsWith(defecto)) " + (m05bRS.getString(campoCod).startsWith(defecto)) + m05bRS.getString(campoCod)+"defecto:"+defecto, m05bConstantes.LOG_NIVEL_BAJO);
					if ((!(defecto.equals(""))) && (m05bRS.getString(campoCod).startsWith(defecto))){
						cadena=cadena+"<option selected value='" + m05bRS.getString(campoCod) + "'>" + m05bRS.getString(campoDesc)+"</option>"; }
		            else{
		                cadena=cadena+"<option value='" + m05bRS.getString(campoCod) + "'>" +m05bRS.getString(campoDesc)+"</option>";}
				}
				else  {
		                cadena=cadena+"<option value='" + m05bRS.getString(campoDesc)+"'>" + m05bRS.getString(campoDesc)+"</option>";
				}
			}
		} catch (Exception ex1) {
		miLog.addTraza(ex1);		
	} finally {
		// Cerrar la conexion
		try{
			if (m05bRS != null)
				m05bRS.close();
			if (m05bPstmt != null)
				m05bPstmt.close();
			if (m05bConn != null)
				m05bConn.close();
 		} catch (Exception ex2) {
			miLog.addTraza(ex2);		
		}
	}
	
	return cadena;
} // Fin funcion popCombo	
	
	public String popComboGastos(String campoCod, String campoDesc, String tabla, String campoWhere, String codigo, String defecto) 
	throws javax.servlet.ServletException, java.io.IOException { 

	String sql="",cadena="";
	java.sql.Connection m05bConn = null;
	PreparedStatement m05bPstmt = null;
	ResultSet m05bRS = null;

	try{
	// Abrir la conexion
			m05bConexion miConex = new m05bConexion();
			m05bConn = miConex.getConnection();			
	// Cargar el combo
			if (!(campoCod.equals("")))  {
					sql = "select " + campoCod + ", " + campoDesc + " from " + tabla ;
					if (!(codigo.equals("")))
						sql += " where " + campoWhere + " = " + codigo;
					sql += " order by " + campoDesc;
			}  else   {
					sql = "select " + campoDesc + " from " + tabla ;
					sql += " order by " + campoDesc;
			}
  			//miLog.addTraza(persona , "popCombo" , "SQL: " + sql, m05bConstantes.LOG_NIVEL_BAJO);
			
			m05bPstmt = m05bConn.prepareStatement(sql);
			m05bRS = m05bPstmt.executeQuery();
			while (m05bRS.next() == true){
				if (!(campoCod.equals("")))  {
					if (defecto.equals(m05bRS.getString(1))){
						cadena=cadena+"<option selected value='" + m05bRS.getString(1) + "'>" + m05bRS.getString(2)+"</option>"; }
		            else{
		                cadena=cadena+"<option value='" + m05bRS.getString(1) + "'>" +m05bRS.getString(2)+"</option>";}
				}
				else  {
		                cadena=cadena+"<option value='" + m05bRS.getString(2)+"'>" + m05bRS.getString(2)+"</option>";
				}
			}
		} catch (Exception ex1) {
		miLog.addTraza(ex1);		
	} finally {
		// Cerrar la conexion
		try{
			if (m05bRS != null)
				m05bRS.close();
			if (m05bPstmt != null)
				m05bPstmt.close();
			if (m05bConn != null)
				m05bConn.close();
 		} catch (Exception ex2) {
			miLog.addTraza(ex2);		
		}
	}
	
	return cadena;
} // Fin funcion popCombo
	
	
	public String popComboExclu(String campoCod, String campoDesc, String tabla, String campoWhere, String codigo,String campoWhere2,String codigo2, String defecto) 
	throws javax.servlet.ServletException, java.io.IOException { 

	String sql="",cadena="";
	java.sql.Connection m05bConn = null;
	PreparedStatement m05bPstmt = null;
	ResultSet m05bRS = null;

	try{
	// Abrir la conexion
			m05bConexion miConex = new m05bConexion();
			m05bConn = miConex.getConnection();			
	// Cargar el combo
			if (!(campoCod.equals("")))  {
					sql = "select " + campoCod + ", " + campoDesc + " from " + tabla ;
					if (!(codigo.equals("")))
						sql += " where " + campoWhere + " != " + codigo;
					if (!(codigo2.equals("")))
						sql += " and " + campoWhere2 + " = " + codigo2;
					sql += " order by " + campoDesc;
			}  else   {
					sql = "select " + campoDesc + " from " + tabla ;
					sql += " order by " + campoDesc;
			}
  			//miLog.addTraza(persona , "popCombo" , "SQL: " + sql, m05bConstantes.LOG_NIVEL_BAJO);
			
			m05bPstmt = m05bConn.prepareStatement(sql);
			m05bRS = m05bPstmt.executeQuery();
			while (m05bRS.next() == true){
				if (!(campoCod.equals("")))  {
					if (defecto.equals(m05bRS.getString(campoCod))){
						cadena=cadena+"<option selected value='" + m05bRS.getString(campoCod) + "'>" + m05bRS.getString(campoDesc)+"</option>"; }
		            else{
		                cadena=cadena+"<option value='" + m05bRS.getString(campoCod) + "'>" +m05bRS.getString(campoDesc)+"</option>";}
				}
				else  {
		                cadena=cadena+"<option value='" + m05bRS.getString(campoDesc)+"'>" + m05bRS.getString(campoDesc)+"</option>";
				}
			}
		} catch (Exception ex1) {
		miLog.addTraza(ex1);		
	} finally {
		// Cerrar la conexion
		try{
			if (m05bRS != null)
				m05bRS.close();
			if (m05bPstmt != null)
				m05bPstmt.close();
			if (m05bConn != null)
				m05bConn.close();
 		} catch (Exception ex2) {
			miLog.addTraza(ex2);		
		}
	}
	
	return cadena;
} // Fin funcion popCombo
	
	public String popComboConCod(String campoCod, String campoDesc, String tabla, String campoWhere, String codigo, String defecto) 
	throws javax.servlet.ServletException, java.io.IOException { 

	String sql="",cadena="";
	java.sql.Connection m05bConn = null;
	PreparedStatement m05bPstmt = null;
	ResultSet m05bRS = null;

	try{
	// Abrir la conexion
			m05bConexion miConex = new m05bConexion();
			m05bConn = miConex.getConnection();			
	// Cargar el combo
			if (!(campoCod.equals("")))  {
					sql = "select " + campoCod + ", " + campoDesc + " from " + tabla ;
					if (!(codigo.equals("")))
						sql += " where " + campoWhere + " = " + codigo;
					sql += " order by " + campoDesc;
			}  else   {
					sql = "select " + campoDesc + " from " + tabla ;
					sql += " order by " + campoDesc;
			}
  			//miLog.addTraza(persona , "popCombo" , "SQL: " + sql, m05bConstantes.LOG_NIVEL_BAJO);
			
			m05bPstmt = m05bConn.prepareStatement(sql);
			m05bRS = m05bPstmt.executeQuery();
			while (m05bRS.next() == true){
				if (!(campoCod.equals(""))) {
					if (defecto.equals(m05bRS.getString(campoCod))) {
						cadena=cadena+"<option selected value='" + m05bRS.getString(campoCod) + "'>" + (m05bRS.getString(campoCod)+"-"+m05bRS.getString(campoDesc))+"</option>"; }
		            else{
		                cadena=cadena+"<option value='" + m05bRS.getString(campoCod) + "'>" +(m05bRS.getString(campoCod)+"-"+m05bRS.getString(campoDesc))+"</option>";}
				}
				else  {
		                cadena=cadena+"<option value='" + m05bRS.getString(campoDesc)+"'>" + (m05bRS.getString(campoCod)+"-"+m05bRS.getString(campoDesc)) +"</option>";
				}
			}
		} catch (Exception ex1) {
		miLog.addTraza(ex1);		
	} finally {
		// Cerrar la conexion
		try{
			if (m05bRS != null)
				m05bRS.close();
			if (m05bPstmt != null)
				m05bPstmt.close();
			if (m05bConn != null)
				m05bConn.close();
 		} catch (Exception ex2) {
			miLog.addTraza(ex2);		
		}
	}
	
	return cadena;
} // Fin funcion popCombo
	
	public String popComboOrderCod(String campoCod, String campoDesc, String tabla, String campoWhere, String codigo, String defecto) 
		throws javax.servlet.ServletException, java.io.IOException { 

		String sql="",cadena="";
		java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;

		try{
		// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
		// Cargar el combo
				if (!(campoCod.equals("")))  {
						sql = "select " + campoCod + ", " + campoDesc + " from " + tabla ;
						if (!(codigo.equals("")))
							sql += " where " + campoWhere + " = " + codigo;
						sql += " order by " + campoCod;
				}  else   {
						sql = "select " + campoDesc + " from " + tabla ;
						sql += " order by " + campoCod;
				}
				
				m05bPstmt = m05bConn.prepareStatement(sql);
				m05bRS = m05bPstmt.executeQuery();
				while (m05bRS.next() == true){
					if (!(campoCod.equals("")))  {
						if (defecto.equals(m05bRS.getString(campoCod))){
							cadena=cadena+"<option selected value='" + m05bRS.getString(campoCod) + "'>" + m05bRS.getString(campoDesc)+"</option>"; }
			            else{
			                cadena=cadena+"<option value='" + m05bRS.getString(campoCod) + "'>" +m05bRS.getString(campoDesc)+"</option>";}
					}
					else  {
			                cadena=cadena+"<option value='" + m05bRS.getString(campoDesc)+"'>" + m05bRS.getString(campoDesc)+"</option>";
					}
				}
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);		
		} finally {
			// Cerrar la conexion
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);		
			}
		}
		
		return cadena;
	} // Fin funcion popCombo
	
	
	public String popComboMultiple(String campoCod, String campoDesc, String tabla, String campoWhere, String codigo, String defecto) 
		throws javax.servlet.ServletException, java.io.IOException { 

		String sql="",cadena="";
		java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;
		boolean Encontrado=false;
		String delimReg= ",";
		StringTokenizer stReg=null; 
		String sNextToken="";
		String campo="";
		

		try{
		// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();
		// Cargar el combo
				if (!(campoCod.equals("")))  {
						sql = "select " + campoCod + ", " + campoDesc + " from " + tabla ;
						if (!(codigo.equals("")))
							sql += " where " + campoWhere + " = " + codigo;
						sql += " order by " + campoDesc;
				}  else   {
						sql = "select " + campoDesc + " from " + tabla ;
						sql += " order by " + campoDesc;
				}
				m05bPstmt = m05bConn.prepareStatement(sql);
				m05bRS = m05bPstmt.executeQuery();
				while (m05bRS.next() == true){
					if (!(campoCod.equals("")))  {
      //miLog.addTraza(persona , "m05bpopComboMultiple" , "campoCod: " + campoCod, m05bConstantes.LOG_NIVEL_BAJO);
                        stReg = new StringTokenizer(defecto,delimReg);
						while (stReg.hasMoreTokens() && (!Encontrado)) {	
							   sNextToken=stReg.nextToken();
      //miLog.addTraza(m05bConstantes.LOG_NO_USER , "m05bpopComboMultiple", "sNextToken: " + sNextToken, m05bConstantes.LOG_NIVEL_BAJO);
							   campo="'"+m05bRS.getString(campoCod)+"'";
						       if (sNextToken.equals(campo)){
      //miLog.addTraza(m05bConstantes.LOG_NO_USER , "m05bpopComboMultiple", "Encontrado: " + Encontrado, m05bConstantes.LOG_NIVEL_BAJO);
						       	   
							        Encontrado=true;}
					    }
					    if (Encontrado){
							cadena=cadena+"<option selected value='" + m05bRS.getString(campoCod) + "'>" + m05bRS.getString(campoDesc)+"</option>"; }
			            else{
			                cadena=cadena+"<option value='" + m05bRS.getString(campoCod) + "'>" +m05bRS.getString(campoDesc)+"</option>";}
					}
					else  {
			                cadena=cadena+"<option value='" + m05bRS.getString(campoDesc)+"'>" + m05bRS.getString(campoDesc)+"</option>";
					}
				Encontrado=false;
				}
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);		
		} finally {
			// Cerrar la conexion
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);		
			}
		}
		
		return cadena;
	} // Fin funcion popCombo
	
	
	public String ComDni(String campoCod, String campoDesc, String tabla, String defecto) 
		throws javax.servlet.ServletException, java.io.IOException { 

		String sql="",cadena="";
		java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;

		try{
		// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();
		// Cargar el combo
				if (!(campoCod.equals("")))  {
						sql = "select " + campoCod + ", " + campoDesc + " from " + tabla ;
						sql += " order by " + campoCod;}
				
				m05bPstmt = m05bConn.prepareStatement(sql);
				m05bRS = m05bPstmt.executeQuery();
				while (m05bRS.next() == true){
					
						if (defecto.equals(m05bRS.getString(campoCod))){
							cadena=cadena+"<option selected value='" + m05bRS.getString(campoCod) + "'>" + m05bRS.getString(campoCod)+"</option>"; }
			            else{
			                cadena=cadena+"<option value='" + m05bRS.getString(campoCod) + "'>" + m05bRS.getString(campoCod)+"</option>";}
				}
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);		
		} finally {
			// Cerrar la conexion
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);		
			}
		}
		
		return cadena;
	} // Fin funcion popCombo
	public String ComDniNombre(String campoCod, String campoDesc, String tabla, String defecto) 
		throws javax.servlet.ServletException, java.io.IOException { 

		String sql="",cadena="";
		java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;

		try{
		// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
		// Cargar el combo
				if (!(campoCod.equals("")))  {
						sql = "select " + campoCod + ", " + campoDesc + " from " + tabla ;
						sql += " order by " + campoCod;}
				
				m05bPstmt = m05bConn.prepareStatement(sql);
				m05bRS = m05bPstmt.executeQuery();
				while (m05bRS.next() == true){
					
						if (defecto.equals(m05bRS.getString(campoCod))){
							cadena=cadena+"<option selected value='" + m05bRS.getString(1) + "'>" + m05bRS.getString(1)+"|"+ m05bRS.getString(2)+"</option>"; }
			            else{
			                cadena=cadena+"<option value='" + m05bRS.getString(1) + "'>" + m05bRS.getString(1)+"|"+ m05bRS.getString(2)+"</option>";}
				}
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);		
		} finally {
			// Cerrar la conexion
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);		
			}
		}
		
		return cadena;
	} // Fin funcion popCombo
	public String ComArrayDni(String campoCod, String campoDesc, String tabla) 
		throws javax.servlet.ServletException, java.io.IOException { 
        String contador="";
		String sql="",cadena="";
		java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;
		int i=0;

		try{
		// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
		// Cargar el combo
				if (!(campoCod.equals("")))  {
						sql = "select " + campoCod + ", " + campoDesc + " from " + tabla ;
						sql += " order by " + campoCod;}
				m05bPstmt = m05bConn.prepareStatement(sql);
				m05bRS = m05bPstmt.executeQuery();
				while (m05bRS.next() == true){
				        contador = "" + i;
                        cadena=cadena + "DniNombre[" + contador + "]=new Array('" + m05bRS.getString(1)+ "','"+m05bRS.getString(2) +"');"; 
			     i=i+1;          
				}
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);		
		} finally {
			// Cerrar la conexion
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);		
			}
		}
		
		return cadena;
	} // Fin funcion popCombo
	
	public String popComboDistinct(String campoCod, String campoDesc, String tabla, String campoWhere, String codigo, String defecto) 
		throws javax.servlet.ServletException, java.io.IOException { 

		String sql="",cadena="";
		java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;

		try{
		// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
		// Cargar el combo
	          if (!codigo.equals("")){
						sql = "select " + campoDesc + ", " + campoCod + ", " +codigo + " from " + tabla ;
			  } else {
						sql = "select  " + campoDesc + ", " + campoCod  + " from " + tabla ;
			  }
					    sql += " where " + campoWhere ;
						sql += " order by " + campoDesc;
						//miLog.addTraza(persona, "Populate Combo", "SQL: " + sql, m05bConstantes.LOG_NIVEL_BAJO);				
				m05bPstmt = m05bConn.prepareStatement(sql);
				m05bRS = m05bPstmt.executeQuery();
				while (m05bRS.next() == true){
					if (!(campoCod.equals("")))  {
						if (defecto.equals(m05bRS.getString(campoCod))){
	                       if (!codigo.equals("")){
							cadena=cadena+"<option selected value='" + m05bRS.getString(campoCod)+m05bRS.getString(codigo) + "'>" + m05bRS.getString(campoDesc)+"</option>"; }	                       	   
							else{
							cadena=cadena+"<option selected value='" + m05bRS.getString(campoCod)+ "'>" + m05bRS.getString(campoDesc)+"</option>"; }
			            }else{
                          if (!codigo.equals("")){
			                   cadena=cadena+"<option value='" + m05bRS.getString(campoCod)+m05bRS.getString(codigo) + "'>" + m05bRS.getString(campoDesc)+"</option>";}
                          else{			            	
			                cadena=cadena+"<option value='" + m05bRS.getString(campoCod)+ "'>" + m05bRS.getString(campoDesc)+"</option>";}
					    }
				     } else  {
			                cadena=cadena+"<option value='" + m05bRS.getString(campoDesc)+"'>" + m05bRS.getString(campoDesc)+"</option>";
					}
				}
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);		
		} finally {
			// Cerrar la conexion
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);		
			}
		}
		
		return cadena;
	} // Fin funcion popCombo

	public String popComboDistinctCodPostal(String campoCod, String campoDesc, String tabla, String campoWhere, String codigo, String defecto) 
	throws javax.servlet.ServletException, java.io.IOException { 

	String sql="",cadena="";
	java.sql.Connection m05bConn = null;
	PreparedStatement m05bPstmt = null;
	ResultSet m05bRS = null;

	try{
	// Abrir la conexion
			m05bConexion miConex = new m05bConexion();
			m05bConn = miConex.getConnection();			
	// Cargar el combo
          if (!codigo.equals("")){
					sql = "select distinct " + campoDesc + ", " + campoCod + ", " +codigo + " from " + tabla ;
		  } else {
					sql = "select distinct " + campoDesc + ", " + campoCod  + " from " + tabla ;
		  }
				    sql += " where " + campoWhere ;
					sql += " order by 1"  ;
					//miLog.addTraza(persona, "Populate Combo", "SQL: " + sql, m05bConstantes.LOG_NIVEL_BAJO);				
			m05bPstmt = m05bConn.prepareStatement(sql);
			m05bRS = m05bPstmt.executeQuery();
		
			while (m05bRS.next() == true){
				if (!(campoCod.equals("")))  {
					if (defecto.equals(m05bRS.getString(campoCod))){
                       if (!codigo.equals("")){
						cadena=cadena+"<option selected value='" + m05bRS.getString(campoCod)+m05bRS.getString(codigo) + "'>" + m05bRS.getString(campoDesc)+"</option>"; }	                       	   
						else{
						cadena=cadena+"<option selected value='" + m05bRS.getString(campoCod)+ "'>" + m05bRS.getString(campoDesc)+"</option>"; }
		            }else{
                      if (!codigo.equals("")){
		                   cadena=cadena+"<option value='" + m05bRS.getString(campoCod)+m05bRS.getString(codigo) + "'>" + m05bRS.getString(campoDesc)+"</option>";}
                      else{			            	
		                cadena=cadena+"<option value='" + m05bRS.getString(campoCod)+ "'>" + m05bRS.getString(campoDesc)+"</option>";}
				    }
			     } else  {
		                cadena=cadena+"<option value='" + m05bRS.getString(campoDesc)+"'>" + m05bRS.getString(campoDesc)+"</option>";
				}
			}
		} catch (Exception ex1) {
		miLog.addTraza(ex1);		
	} finally {
		// Cerrar la conexion
		try{
			if (m05bRS != null)
				m05bRS.close();
			if (m05bPstmt != null)
				m05bPstmt.close();
			if (m05bConn != null)
				m05bConn.close();
 		} catch (Exception ex2) {
			miLog.addTraza(ex2);		
		}
	}
	
	return cadena;
} // Fin funcion popCombo	
	
    public String Combo(String campoCod,  String tabla,  String defecto) throws javax.servlet.ServletException, java.io.IOException {

		String sql="", cadena="";
		java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;

		try{
			// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
			// Cargar el combo
				if (!(campoCod.equals("")))  {
						sql = "select " + campoCod + " from " + tabla ;
						sql = sql + " order by " + campoCod;
				}
				m05bPstmt = m05bConn.prepareStatement(sql);
				m05bRS = m05bPstmt.executeQuery();
				while (m05bRS.next() == true){
					if (!(campoCod.equals("")))  {
						if (defecto.equals(m05bRS.getString(campoCod)))
							cadena=cadena+"<option selected value='" + m05bRS.getString(campoCod) + "'>" + m05bRS.getString(campoCod)+"</option>";
			            else
			                cadena=cadena+"<option value='" + m05bRS.getString(campoCod) + "'>" + m05bRS.getString(campoCod)+"</option>";
					}
				}
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);
		} finally {
			// Cerrar la conexion
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);
			}
		}
		return cadena;
	}  // Fin funcion Combo

    public String ComMatricula ( String situacion, String defecto ) throws javax.servlet.ServletException, java.io.IOException {
        String sql="", matricula="", Matriculas="";
        java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;
		
		try{
			// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
			// Cargar el combo
				sql = "select " + m05bConstantes.COL_34_MATRICULA + " from " + m05bConstantes.TAB_VEHICULOS;
				if (situacion.equals(m05bConstantes.VEH_BAJA)) 
					sql = sql + " where "+ m05bConstantes.COL_34_SITUACION + " = '" + m05bConstantes.VEH_BAJA + "'";
				else if (situacion.equals(m05bConstantes.VEH_ALTA)) 
					sql = sql + " where "+ m05bConstantes.COL_34_SITUACION + " = '" + m05bConstantes.VEH_ALTA + "'";
	            sql = sql + " order by "+ m05bConstantes.COL_34_MATRICULA + " desc ";
	            m05bPstmt = m05bConn.prepareStatement(sql);
				m05bRS = m05bPstmt.executeQuery();
				while (m05bRS.next() == true){
					matricula=m05bRS.getString(m05bConstantes.COL_34_MATRICULA);
					if (matricula.equals(defecto))
				        Matriculas=Matriculas+"<option selected value='" + matricula + "'>" + matricula+"</option>";
					else
				        Matriculas=Matriculas+"<option value='" + matricula + "'>" + matricula+"</option>";
			    }
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);
		} finally {
				try{
				// Cerrar la conexion
					if (m05bRS != null)
						m05bRS.close();
					if (m05bPstmt != null)
						m05bPstmt.close();
					if (m05bConn != null)
						m05bConn.close();
		 		} catch (Exception ex2) {
					miLog.addTraza(ex2);
				}
		}
        return Matriculas;

}  // Fin funcion ComMatricula
	
  	public String populaCombo(String campoCod, String campoDesc, String tabla, String campoWhere, String codigo, String defecto)
		throws javax.servlet.ServletException, java.io.IOException {

		String sql="", cadena="";
		java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;


		try{
				// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
				// Cargar el combo
				if (!(campoCod.equals("")))  {
						sql = "select " + campoCod + ", " + campoDesc + " from " + tabla ;
						if (!(codigo.equals("")))
							sql += " where " + campoWhere + " = " + codigo;
						sql += " order by " + campoCod;
				}  else   {
						sql = "select " + campoDesc + " from " + tabla ;
						sql += " order by " + campoDesc;
				}
				m05bPstmt = m05bConn.prepareStatement(sql);
				m05bRS = m05bPstmt.executeQuery();
				while (m05bRS.next() == true){
					if (!(campoCod.equals("")))  {
						if (defecto.equals(m05bRS.getString(campoDesc)))
							cadena=cadena+"<option selected value='"+ m05bRS.getString(campoDesc) + "'>" + m05bRS.getString(campoDesc)+"</option>";
			            else
			                cadena=cadena+"<option value='"  + m05bRS.getString(campoDesc)+"'>" + m05bRS.getString(campoDesc)+"</option>";
					}
					else  {
			                cadena=cadena+"<option value='" + m05bRS.getString(campoDesc)+"'>" + m05bRS.getString(campoDesc)+"</option>";
					}
				}
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);
		} finally {
				// Cerrar la conexion
				try{
					if (m05bRS != null)
						m05bRS.close();
					if (m05bPstmt != null)
						m05bPstmt.close();
					if (m05bConn != null)
						m05bConn.close();
		 		} catch (Exception ex2) {
					miLog.addTraza(ex2);
				}
		}

		return cadena;
	}  // Fin funcion populaCombo
  	public String GrupoRango (String defecto) throws javax.servlet.ServletException, java.io.IOException {
  		return GrupoRango(defecto,m05bConstantesInformes.IDIOMA_C);
  	}
     public String GrupoRango (String defecto,String idioma) throws javax.servlet.ServletException, java.io.IOException {

		  String sql="", cadena="";
		  java.sql.Connection m05bConn = null;
		  PreparedStatement m05bPstmt = null;
		  ResultSet m05bRS = null;
			String campoTexto="";
			if (!idioma.equals(m05bConstantesInformes.IDIOMA_C))
				campoTexto="E";
		try{
				// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
				// Cargar el combo
	            sql="select NVL(" +campoTexto+ m05bConstantes.COL_36_NOMBRE + ","+ m05bConstantes.COL_36_NOMBRE + "), " + m05bConstantes.COL_36_CODIGO + 
	            		" , " + m05bConstantes.COL_36_RANGOS + 
	            			" from " + m05bConstantes.TAB_GRUPOS;
	            sql+=" where " + m05bConstantes.COL_36_CODIGO  + " not in ('"+m05bConstantes.GRUPO_CTK_A+"','"+m05bConstantes.GRUPO_CTK_B+
	            		"','"+m05bConstantes.GRUPO_CTK_C+"','"+m05bConstantes.GRUPO_CTK_D+"','"+m05bConstantes.GRUPO_CTK_RA+"','"+m05bConstantes.GRUPO_CTK_RB+"')";
	            sql+=" order by " + m05bConstantes.COL_36_NOMBRE;
				m05bPstmt = m05bConn.prepareStatement(sql);
				m05bRS = m05bPstmt.executeQuery();
				while (m05bRS.next() == true){
						if (defecto.equals(m05bRS.getString(2)))
							cadena=cadena+"<option selected value='" + m05bRS.getString(2) + ".." + m05bRS.getString(3) + "'>" + m05bRS.getString(1)+"</option>";
			            else
			                cadena=cadena+"<option value='" + m05bRS.getString(2) + ".." + m05bRS.getString(3)+"'>" + m05bRS.getString(1)+"</option>";
				}
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);
		} finally {
				// Cerrar la conexion
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);
			}
		}
		return cadena;

     }   // Fin funcion GrupoRango
     
     public String distinctEjercicio( String tabla, String columna ) throws SQLException, javax.servlet.ServletException, java.io.IOException {

		String sql="", cadena="";
		java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;

		try{
			// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
			// Cargar el combo
			sql = "select distinct(to_char(" + columna + ",'YYYY')) from " + tabla ;
			sql += " where " + columna + " is not null ";
			sql += " order by " + " to_char(" + columna + ",'YYYY') desc";

			m05bPstmt = m05bConn.prepareStatement(sql);
			m05bRS = m05bPstmt.executeQuery();

			while (m05bRS.next() == true){
		                cadena=cadena+"<option value='" + m05bRS.getString(1) + "'>" + m05bRS.getString(1)+"</option>";
			}
 		} catch (Exception e) {
 			miLog.addTraza(e);
		} finally {
				// Cerrar la conexion
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);
			}
		}
		return cadena;
	}  // Fin funcion distinctEjercicio
	
public String popMatricTarjetaBaja () throws javax.servlet.ServletException, java.io.IOException {
	
        String Matriculas="", sql="";
        java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;

 		try{
			// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
			// Cargar el combo
			sql = "select " + m05bConstantes.COL_34_MATRICULA + " from " + m05bConstantes.TAB_TARJETAS + ", " + m05bConstantes.TAB_VEHICULOS;
           	sql = sql + " where " + m05bConstantes.COL_31_MATRICULA + " = " + m05bConstantes.COL_34_MATRICULA;
           	sql = sql + " and " + m05bConstantes.COL_31_SITUACION + " = '" + m05bConstantes.TAR_CANCELADA + "'";
            sql = sql + " order by " + m05bConstantes.COL_34_MATRICULA +" desc ";

			
			m05bPstmt = m05bConn.prepareStatement(sql);
			m05bRS = m05bPstmt.executeQuery();
			while (m05bRS.next() == true){
		        Matriculas=Matriculas+"<option value='" + m05bRS.getString(m05bConstantes.COL_34_MATRICULA) + "'>" + m05bRS.getString(m05bConstantes.COL_34_MATRICULA)+"</option>";
			}
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);
		}
		try{
				// Cerrar la conexion
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);
			}
 		} catch (Exception ex2) {
			miLog.addTraza(ex2);
		}
        return Matriculas;

}  // Fin funcion popMatricTarjetaBaja

	public String joinComboArray(String campoCod, String campoDesc, String tabla,String campoCod2) 
		throws javax.servlet.ServletException, java.io.IOException { 

		String sql="", cadena="", contador="", aux="";
		int i= 0; 
		java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;

		try{
			// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
			// Cargar el combo
			if (campoCod2==""){
				sql = "select distinct REPLACE(" +  campoDesc +",'''',''),"+campoCod + " from " + tabla   ;
				sql += " order by "  + 1;
			}else{
					sql = "select " + campoCod2 + ", " + campoCod + ", REPLACE(" + campoDesc + ",'''','') from " + tabla   ;
					sql += " order by " + campoCod2 + "," + campoCod;}
			//miLog.addTraza(persona, "Populate Combo", "SQL: " + sql, m05bConstantes.LOG_NIVEL_BAJO);
			m05bPstmt = m05bConn.prepareStatement(sql);
			m05bRS = m05bPstmt.executeQuery();
			while (m05bRS.next() == true){
				contador = "" + i;
				aux=m05bRS.getString(1)==null?"":m05bRS.getString(1);
			    if (campoCod2==""){
			    	if (m05bRS.getString(3).equals(m05bConstantes.PARAM_NOUSADO))  {
                		cadena=cadena + "CmbDesc[" + contador + "]=new Array('" + m05bRS.getString(2) + "','" +  aux +"');"; 
			    	} else {
                		cadena=cadena + "CmbDesc[" + contador + "]=new Array('" + m05bRS.getString(2)+ "','"+m05bRS.getString(3) + "','" +  m05bRS.getString(1)+"');"; 
                	}
                } else {
                	
				   cadena=cadena + "CmbDesc[" + contador + "]=new Array('" + m05bRS.getString(1) + 
				   "','" + m05bRS.getString(2) + "','" +  m05bRS.getString(3)+"');"; 
				}
                i=i+1;
		  	}
			//miLog.addTraza(persona, "Populate Combo", "cadena: " + cadena, m05bConstantes.LOG_NIVEL_BAJO);
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);
		} finally {
			// Cerrar la conexion
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);		
			}
		}
		return cadena;
	}  // Fin funcion joinComboArray
	public String joinComboArrayGrupos( ) 
	throws javax.servlet.ServletException, java.io.IOException { 
		return joinComboArrayGrupos(m05bConstantesInformes.IDIOMA_C);
	}
		
	public String joinComboArrayGrupos( String idioma) 
		throws javax.servlet.ServletException, java.io.IOException { 
		String campoTexto="";
		if (!idioma.equals(m05bConstantesInformes.IDIOMA_C))
			campoTexto="E";
		String sql="", cadena="", contador="", grupo="";
		int i= 0; 
		java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null, m05bPstmt2=null;
		ResultSet m05bRS = null, m05bRS2=null;

		try{
			// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
			// Cargar el combo
						sql = "select " + m05bConstantes.COL_36_RANGOS + ", " + m05bConstantes.COL_36_CODIGO +
								" from " + m05bConstantes.TAB_GRUPOS   ;
				m05bPstmt = m05bConn.prepareStatement(sql);
				m05bRS = m05bPstmt.executeQuery();
				String sCamposIn="";
		        String sNextToken="";
				while (m05bRS.next() == true){
					    grupo=m05bRS.getString(2);
						String delimReg= ",";
						StringTokenizer stReg = new StringTokenizer(m05bRS.getString(1),delimReg);
						while (stReg.hasMoreTokens()) {
							    sNextToken=stReg.nextToken();
							    sCamposIn=sCamposIn + "'"+sNextToken+"',";
								sql = "select " + m05bConstantes.COL_99_CODDESC + ", NVL(" +campoTexto+ m05bConstantes.COL_99_DESCRIPCION + ","+ m05bConstantes.COL_99_DESCRIPCION + ") from " + m05bConstantes.TAB_DESCRIPCIONES   ;
								sql += " where " + m05bConstantes.COL_99_CODTABLA + "=11";
								sql += " and " + m05bConstantes.COL_99_CODDESC + "='" + sNextToken + "'";
								sql += " order by 2,1";
								
								m05bPstmt2 = m05bConn.prepareStatement(sql);
								m05bRS2 = m05bPstmt2.executeQuery();							
								if (m05bRS2.next() == true) {
									contador = "" + i;
									cadena=cadena + "comboDesc[" + contador + "]=new Array('" + grupo + 
															"','" + m05bRS2.getString(1) + "','" +  m05bRS2.getString(2)+"');"; 
					                i=i+1;
					            }
					    }
				}
			    if (!(sCamposIn.equals(""))){
                                sCamposIn=sCamposIn.substring(0,sCamposIn.length()-1);
								sql = "select " + m05bConstantes.COL_99_CODDESC + ", NVL(" +campoTexto+ m05bConstantes.COL_99_DESCRIPCION + ","+ m05bConstantes.COL_99_DESCRIPCION + ") from " + m05bConstantes.TAB_DESCRIPCIONES   ;
								sql += " where " + m05bConstantes.COL_99_CODTABLA + "=11";
								sql += " and " + m05bConstantes.COL_99_CODDESC + " not in (" + sCamposIn + ")";
								sql += " order by 2,1";
								
								m05bPstmt2 = m05bConn.prepareStatement(sql);
								m05bRS2 = m05bPstmt2.executeQuery();
								while (m05bRS2.next() == true) {
								    contador = "" + i;						
									cadena=cadena + "comboDesc[" + contador + "]=new Array('" + "***" + 
															"','" + m05bRS2.getString(1) + "','" +  m05bRS2.getString(2)+"');";
									i=i+1; }
				}	
					
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);		
		} finally {
		// Cerrar la conexion
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bRS2 != null)
					m05bRS2.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bPstmt2 != null)
					m05bPstmt2.close();			
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);		
			}
		}
		return cadena;
	}  // Fin funcion joinComboArrayGrupos		

public String popCompaPolizaModal() throws javax.servlet.ServletException, java.io.IOException {
		String sql="", Polizas="";
        java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;

		try{
			// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
			// Cargar el combo
			sql = "select " + m05bConstantes.COL_28_CODSEG + "," + m05bConstantes.COL_28_POLIZA ;
			sql = sql + " ||'..'|| " + m05bConstantes.COL_28_CIA + " ||'___'|| " + m05bConstantes.COL_99_DESCRIPCION;
			sql = sql + " AS DESCRIPCION FROM " + m05bConstantes.TAB_SEGUROS;
			sql = sql + " , " + m05bConstantes.TAB_DESCRIPCIONES;
           	sql = sql + " where " + m05bConstantes.COL_99_CODTABLA + "(+) = '8' " ;
           	sql = sql + " and " + m05bConstantes.COL_99_CODDESC + "(+) = " + m05bConstantes.COL_28_MODAL ;
            sql = sql + " order by " + m05bConstantes.COL_28_CODSEG;

			
			m05bPstmt = m05bConn.prepareStatement(sql);
			m05bRS = m05bPstmt.executeQuery();
			while (m05bRS.next() == true){
		        Polizas=Polizas+"<option value='" + m05bRS.getString(m05bConstantes.COL_28_CODSEG) + "'>" + m05bRS.getString(2)+"</option>";
			}
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);
		}
		finally {
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);
			}
		}
        return Polizas;

}   // Fin funcion popCompaPolizaModal

public String popCompaPoliza() throws javax.servlet.ServletException, java.io.IOException {
        String sql="", Polizas="";
        java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;

		try{
			// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
			// Cargar el combo
			sql = "select distinct " + m05bConstantes.COL_28_POLIZA + "," +  m05bConstantes.COL_28_POLIZA ;
			sql = sql + " ||'|'|| " + m05bConstantes.COL_28_CIA ;
			sql = sql + " AS DESCRIPCION FROM " + m05bConstantes.TAB_SEGUROS;
            sql = sql + " order by 1 desc" ;

			
			m05bPstmt = m05bConn.prepareStatement(sql);
			m05bRS = m05bPstmt.executeQuery();
			while (m05bRS.next() == true){
		        Polizas=Polizas+"<option value='" + m05bRS.getString(m05bConstantes.COL_28_POLIZA) + "'>" + m05bRS.getString(2)+"</option>";

			}
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);
		} finally {
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);
			}
		}
        return Polizas;
} // Fin funcion popCompaPoliza


public String popCuentaBanco() throws javax.servlet.ServletException, java.io.IOException {
        String sql="", Cuentas="";
        java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;

		try{
			// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
			// Cargar el combo
			sql = "select distinct " + m05bConstantes.COL_03_NCUENTA + "," +  m05bConstantes.COL_03_NCUENTA ;
			sql = sql + " ||'|'|| " + m05bConstantes.COL_03_NOMBRE ;
			sql = sql + " AS DESCRIPCION FROM " + m05bConstantes.TAB_BANCOS;
            sql = sql + " order by 1 desc" ;

			
			m05bPstmt = m05bConn.prepareStatement(sql);
			m05bRS = m05bPstmt.executeQuery();
			while (m05bRS.next() == true){
		        Cuentas=Cuentas+"<option value='" + m05bRS.getString(m05bConstantes.COL_03_NCUENTA) + "'>" + m05bRS.getString(2)+"</option>";
			}
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);
		} finally {
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);
			}
		}
        return Cuentas;

}  // Fin funcion popCuentaBanco
public String popComboCargarDistinct(String campoCod, String campoDesc, String tabla) throws javax.servlet.ServletException, java.io.IOException {
        String sql="", Codigos="";
        java.sql.Connection m05bConn = null;
		PreparedStatement m05bPstmt = null;
		ResultSet m05bRS = null;

		try{
			// Abrir la conexion
				m05bConexion miConex = new m05bConexion();
				m05bConn = miConex.getConnection();			
			// Cargar el combo
			sql = "select distinct " + campoCod + "," + campoDesc ;
			sql = sql + " FROM " + tabla;
            sql = sql + " order by 1 asc" ;
			
			m05bPstmt = m05bConn.prepareStatement(sql);
			m05bRS = m05bPstmt.executeQuery();
			while (m05bRS.next() == true){
		        Codigos=Codigos+"<option value='" + m05bRS.getString(1) + "'>" + m05bRS.getString(2)+"</option>";
			}
 		} catch (Exception ex1) {
			miLog.addTraza(ex1);
		} finally {
			try{
				if (m05bRS != null)
					m05bRS.close();
				if (m05bPstmt != null)
					m05bPstmt.close();
				if (m05bConn != null)
					m05bConn.close();
	 		} catch (Exception ex2) {
				miLog.addTraza(ex2);
			}
		}
        return Codigos;
} // Fin funcion popCompaPoliza
public String popComboCargarDistinctNoNull(String campoCod, String campoDesc, String tabla) throws javax.servlet.ServletException, java.io.IOException {
    String sql="", Codigos="";
    java.sql.Connection m05bConn = null;
	PreparedStatement m05bPstmt = null;
	ResultSet m05bRS = null;

	try{
		// Abrir la conexion
			m05bConexion miConex = new m05bConexion();
			m05bConn = miConex.getConnection();			
		// Cargar el combo
		sql = "select distinct " + campoCod + "," + campoDesc ;
		sql = sql + " FROM " + tabla + " WHERE " + campoDesc +" IS NOT NULL ";
        sql = sql + " order by 1 asc" ;
		
		m05bPstmt = m05bConn.prepareStatement(sql);
		m05bRS = m05bPstmt.executeQuery();
		while (m05bRS.next() == true){
	        Codigos=Codigos+"<option value='" + m05bRS.getString(1) + "'>" + m05bRS.getString(2)+"</option>";
		}
		} catch (Exception ex1) {
		miLog.addTraza(ex1);
	} finally {
		try{
			if (m05bRS != null)
				m05bRS.close();
			if (m05bPstmt != null)
				m05bPstmt.close();
			if (m05bConn != null)
				m05bConn.close();
 		} catch (Exception ex2) {
			miLog.addTraza(ex2);
		}
	}
    return Codigos;
} // Fin funcion popCompaPoliza
}