crud de productos completado

This commit is contained in:
carlos
2024-06-19 20:51:46 -06:00
parent 3c34b7fd78
commit 3671014cdc
24 changed files with 425 additions and 24 deletions
+33 -1
View File
@@ -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; }