private void btnRegistrarActionPerformed(java.awt.event.ActionEvent evt) {
Connection miConexion=(Connection) ConexionDB.GetConnection();
try
{
Statement statement=(Statement) miConexion.createStatement();
String codProducto=txtCodigo.getText();
String nombre=txtNombre.getText();
float precioCompra=Float.parseFloat(txtPrecioCompra.getText());
float precioVenta=Float.parseFloat(txtPrecioVenta.getText());
//Aquí se asigna a la fecha en un formato el cual puede ser cambiado
String fechaVencimiento=new SimpleDateFormat("yyyy/MM/dd").format(dateChooserFechaVencimiento.getDate());
int cantidad=Integer.parseInt(txtCantidad.getText());
statement.execute("insert into TProducto values('"+codProducto+"','"+nombre+"','"+precioCompra+"','"+precioVenta+"','"+fechaVencimiento+"','"+cantidad+"')");
JOptionPane.showMessageDialog(this, "Datos ingresados correctamente");
statement.close();
miConexion.close();
}
catch (Exception ex)
{
JOptionPane.showMessageDialog(this, "Error "+ex.getMessage());
}
--
Estructura de tabla para la tabla `TProducto`
--
CREATE TABLE IF NOT EXISTS `TProducto` (
`CodProducto` char(10) NOT NULL DEFAULT '',
`Nombre` varchar(700) NOT NULL,
`PrecioCompra` decimal(18,2) NOT NULL,
`PrecioVenta` decimal(18,2) NOT NULL,
`FechaVencimiento` datetime NOT NULL,
`Cantidad` int(11) DEFAULT NULL,
PRIMARY KEY (`CodProducto`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Mis Otros Blogger
http://manualesimportantesdeempresarios.blogspot.com/
http://trabajarporinternetenvenezuela.blogspot.com/
http://lomejordelaprogramacionjavayotros.blogspot.com/
http://fundacionformandoconcienciayvalores.blogspot.com/
No hay comentarios:
Publicar un comentario