<%@page import="java.util.*,javax.sql.*,java.sql.*,javax.naming.*,m05bClasses.*" %>
<%@include file="/mantenimientosJSP/includes/m05b.inc"%>
<HTML>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<script language="javascript1.2" src="<%=m05bConstantesPaginas.PATH_SCRIPTS%>/formateador.js"></script>
<script language="javascript1.2" src="<%=m05bConstantesPaginas.PATH_SCRIPTS%>/m05Funciones.js"></script>
	<%@ include file="/m05bIdioma.inc"%>	
<%
  String sql="";
  String strMatricula="", kmAct="", fKmAct="", form="";
  java.sql.Connection conn=null;
  PreparedStatement pstmt = null;
  ResultSet rs = null;
  strMatricula=request.getParameter("Matricula")==null?"":request.getParameter("Matricula");
  form=request.getParameter("Form");
  	  
  	 if (!strMatricula.equals("")) {
	      try {
		      sql="select " + m05bConstantes.COL_34_KMACTUALES + 
		      	  	",TO_CHAR("+ m05bConstantes.COL_34_FKMACT + ",'"+formatoFecha+"')" +
		          	" FROM "+ m05bConstantes.TAB_VEHICULOS +
		          	" where "+ m05bConstantes.COL_34_MATRICULA + "='"+ strMatricula + "'" ;
		       //m05bbBeginSelect(sql);
			   //m05bRS = m05bPStmt.executeQuery();

		       m05bConexion miConex = new m05bConexion();
               conn = miConex.getConnection();
               conn.setAutoCommit(false);  // Al final si todo ha ido bien se hace commit	 
		       pstmt = conn.prepareStatement(sql);
		       rs = pstmt.executeQuery();			   
		       if (rs.next() == true){
		               kmAct=rs.getString(1); 		//Km Actuales
		               fKmAct=rs.getString(2); 		//Fecha Km Actuales
		       }
		  } catch (Exception SQLException){
			  m05bClasses.m05bFileLog miLog = new m05bClasses.m05bFileLog();
		   		miLog.addTraza(SQLException);
		  } finally {
			    //m05bEndSelect();
		       if (rs != null)
			   rs.close();
		       if (pstmt != null)
			   pstmt.close();
		       if (conn != null)
			   conn.close();

			    
		  }
  	 }
	if (form.equals("CuentaKm")) { %>
             <script>
                 top.formCambioCuentaKm.KmModif.value="";
                 top.formCambioCuentaKm.FCambio.value="";
                 top.formCambioCuentaKm.KmAct.value="<%=kmAct%>";
                 formatNumero(top.formCambioCuentaKm.KmAct);
                 top.formCambioCuentaKm.FKmAct.value="<%=fKmAct%>";
             </script>
	<% } else  {%>
             <script>
                 top.formModifKmAct.KmActuales.value="";
                 top.formModifKmAct.FCambio.value="";
                 top.formModifKmAct.KmAct.value="<%=kmAct%>";
                 formatNumero(top.formModifKmAct.KmAct);
                 top.formModifKmAct.FKmAct.value="<%=fKmAct%>";
             </script>
    <%  }  %>
<BODY style="cursor: wait" bgcolor="white" onkeydown="cancelaEnter();" onload="document.body.style.cursor='default';" onunload="document.body.style.cursor='wait';">
</BODY>
</HTML>