hola amigos tengo un formulario de campos como
n°cuentas
fecha
saldo
tipo de movimiento (retiro, consignacion)
esta tabla se llama movimientos el cual tiene un ID_mov q es autoincrementable MYSQL
si no escribo el ID_mov en el formulario no me guarda el registro en tabla movimientos.
cuando escribo el ID_mov en el formulario con su caja de texto perfecto me escribe.
LA cosa es q yo no quieropasar el ID_mov porq ese es autoincrementable seria ilogico.
Este es el metodo INSERt Funcionando alli le escribo desde un formulario JSP el valor de ID_mov q es lo q no quiero hacer.
Código HTML:
public boolean save3(Movimiento move, Cuentas Cuu) throws SQLException{
boolean sav=false;
try
{
PreparedStatement ps=con.prepareStatement("insert into movimientos values(?,?,?,?,?)");
ps.setString(1, move.getIdmovimientos());
ps.setString(2, move.getIdcuentas());
ps.setFloat(3, Float.valueOf(move.getValor()));
ps.setString(4, move.getFecha());
ps.setString(5, move.getTipoperacion());
ps.executeUpdate();
retiro(Cuu);
sav=true;
}
Este es el JSP desde donde capturo el ID_mov
Código HTML:
[CODE]<form action="movimiento.jsp" method="post">
<table border="0" align="center">
<tr><td>id_movimiento</td><td><input type="text" name="idmovimiento"></td></tr>
<tr><td>N° de la cuenta</td><td><input type="text" name="idcuenta"></td></tr>
<tr><td>valor</td><td><input type="text" name="valor"></td></tr>
<tr><td>Fecha</td><td><input type="text" name="fecha"> </td></tr>
<tr><td> Tipo Operacion<td> <select name="tpo">
<option>Consignacion</option>
<option>Retiro</option>
</select> </td>
</tr>
<tr>
<td> </td></tr>
<tr><td><input align="rigth" type="submit" name="op" value="guardar"> </td>
<td><input align="rigth" type="submit" name="listar" value="Listar_Cuentas"> </td>
</tr>
</table>
</form>
<c:if test="${param.op=='guardar'}">
<c:if test="${param.tpo=='Consignacion'}">
<tx:Consignacion idmovimientos="${param.idmovimiento}" idcuentas="${param.idcuenta}" valor="${param.valor}" fecha="${param.fecha}" tipooperacion="${param.tpo}"/>
</c:if>
<c:if test="${param.tpo=='Retiro'}">
<tx:Retiros idmovimiento="${param.idmovimiento}" idcuenta="${param.idcuenta}" valores="${param.valor}" fecha1="${param.fecha}" tipoperaciones="${param.tpo}"/>
</c:if>
<c:set var="info" value="${msg}"/>
<c:set var="valor" value="${vr}"/>
${msg} ${vr}
</c:if>[/CODE]
Esta es la INSTANCIA DE LOS ANTERIORES PARA EL RETRO que es igual q la instancia de COnsignacion
Código HTML:
[CODE] public void doTag() throws JspException {
try {
Control cont =new Control();
Movimiento move= new Movimiento();
Cuentas cuu=new Cuentas();
move.setIdmovimientos(idmovimiento);
move.setIdcuentas(idcuenta);
move.setValor(valores);
move.setFecha(fecha1);
move.setTipoperacion(tipoperaciones);
cuu.setSaldo(Float.valueOf(valores));
cuu.setIdcuentas(idcuenta);
if(cont.save3(move, cuu)){
getJspContext().setAttribute("msg","Ud ha Retirado" );
getJspContext().setAttribute("vr","$"+ move.getValor()+" "+"<a href='consucuen.jsp'>Consultar su nuevo saldo</a>");
} else{
getJspContext().setAttribute("msg","El retiro que intenta hacer No es valido ");
}
} catch (Exception ex) {
throw new JspException(ex.getMessage());
}
}[/CODE]