crud de productos completado
This commit is contained in:
+33
-1
@@ -478,7 +478,39 @@ namespace compabetov2.database
|
||||
command.Parameters.AddWithValue("@precio", producto.precion);
|
||||
command.Parameters.AddWithValue("@img", producto.img);
|
||||
command.Parameters.AddWithValue("@stock", producto.stock);
|
||||
command.Parameters.AddWithValue("@idcategoria", producto.categoria.idCategoria);
|
||||
command.Parameters.AddWithValue("@idcategoria", 1);
|
||||
int filasAfectadas = command.ExecuteNonQuery();
|
||||
|
||||
if (filasAfectadas > 0) { return true; }
|
||||
else { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLiteException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool editarProductoDAO(Producto producto)
|
||||
{
|
||||
var db_conexion = new Conexion();
|
||||
try
|
||||
{
|
||||
using (SQLiteConnection conexion = db_conexion.get_connection())
|
||||
{
|
||||
conexion.Open();
|
||||
|
||||
string sql = "UPDATE Producto SET nombre = @nombre, precio = @precio, img = @img WHERE idproducto = @idproducto;";
|
||||
|
||||
|
||||
using (SQLiteCommand command = new SQLiteCommand(sql, conexion))
|
||||
{
|
||||
command.Parameters.AddWithValue("@nombre", producto.nombre);
|
||||
command.Parameters.AddWithValue("@precio", producto.precion);
|
||||
command.Parameters.AddWithValue("@img", producto.img);
|
||||
command.Parameters.AddWithValue("@idproducto", producto.idProducto);
|
||||
int filasAfectadas = command.ExecuteNonQuery();
|
||||
|
||||
if (filasAfectadas > 0) { return true; }
|
||||
|
||||
+11
-1
@@ -66,7 +66,17 @@ namespace compabetov2.database
|
||||
{
|
||||
return DAO.insertarProductoDAO(producto);
|
||||
}
|
||||
|
||||
|
||||
public static bool editarProducto(Producto producto)
|
||||
{
|
||||
return DAO.editarProductoDAO(producto);
|
||||
}
|
||||
|
||||
public static bool eliminarProducto(Producto producto)
|
||||
{
|
||||
return DAO.eliminarProductoDAO(producto);
|
||||
}
|
||||
|
||||
public static bool insertarCliente(Cliente cliente)
|
||||
{
|
||||
return DAO.insertarClienteDAO(cliente);
|
||||
|
||||
Reference in New Issue
Block a user