aumenta el stock de los productos
This commit is contained in:
@@ -231,6 +231,47 @@ namespace compabetov2.database
|
||||
}
|
||||
}
|
||||
|
||||
public static bool aumentarStockDAO(List<Producto> stockNuevo)
|
||||
{
|
||||
var db_conexion = new Conexion();
|
||||
try
|
||||
{
|
||||
using (SQLiteConnection conexion = db_conexion.get_connection())
|
||||
{
|
||||
conexion.Open();
|
||||
|
||||
using(var transaccion = conexion.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var item in stockNuevo)
|
||||
{
|
||||
string sql = "UPDATE Producto SET stock = @stock WHERE idproducto = @idproducto;";
|
||||
SQLiteCommand command = new SQLiteCommand(sql, conexion);
|
||||
command.Parameters.AddWithValue("@idproducto", item.idProducto);
|
||||
command.Parameters.AddWithValue("@stock", item.stock);
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
transaccion.Commit();
|
||||
return true;
|
||||
}
|
||||
catch(SQLiteException ex)
|
||||
{
|
||||
transaccion.Rollback();
|
||||
MessageBox.Show(ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLiteException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool insertarCategoriaDAO(Categoria categoria)
|
||||
{
|
||||
var db_conexion = new Conexion();
|
||||
|
||||
Reference in New Issue
Block a user