crud de variante sin lo relacionado a editar
This commit is contained in:
@@ -10,6 +10,7 @@ using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using compabetov2.admin;
|
||||
using compabetov2.database;
|
||||
using compabetov2.database.modelos;
|
||||
|
||||
@@ -1807,6 +1808,60 @@ namespace compabetov2.database
|
||||
}
|
||||
}
|
||||
|
||||
public static bool insertarVarianteDAO(Variante variante)
|
||||
{
|
||||
var db_conexion = new Conexion();
|
||||
try
|
||||
{
|
||||
SQLiteConnection conexion = db_conexion.get_connection();
|
||||
conexion.Open();
|
||||
|
||||
string sql = "INSERT INTO variantes (nombre, precio, cantidad, img, fk_producto, precioCompra) " +
|
||||
"VALUES(@nombre, @precio, @cantidad, @img, @fk_producto, @precioCompra);";
|
||||
|
||||
|
||||
SQLiteCommand command = new SQLiteCommand(sql, conexion);
|
||||
command.Parameters.AddWithValue("@nombre", variante.nombre);
|
||||
command.Parameters.AddWithValue("@precio", variante.precio);
|
||||
command.Parameters.AddWithValue("@cantidad", variante.cantidad);
|
||||
command.Parameters.AddWithValue("@img", variante.img);
|
||||
command.Parameters.AddWithValue("@fk_producto", variante.fkProducto);
|
||||
command.Parameters.AddWithValue("@precioCompra", variante.precioCompra);
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (SQLiteException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool eliminarVarianteDAO(int idVariante)
|
||||
{
|
||||
var db_conexion = new Conexion();
|
||||
try
|
||||
{
|
||||
SQLiteConnection conexion = db_conexion.get_connection();
|
||||
conexion.Open();
|
||||
|
||||
string sql = "DELETE FROM variantes WHERE idVariante = @idVariante;";
|
||||
|
||||
|
||||
SQLiteCommand command = new SQLiteCommand(sql, conexion);
|
||||
command.Parameters.AddWithValue("@idVariante", idVariante);
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (SQLiteException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static SQLiteDataReader conseguirImportesDAO()
|
||||
{
|
||||
SQLiteDataReader reader = null;
|
||||
|
||||
@@ -603,6 +603,16 @@ namespace compabetov2.database
|
||||
return variantes;
|
||||
}
|
||||
|
||||
public static bool insertarVariante(Variante variante)
|
||||
{
|
||||
return DAO.insertarVarianteDAO(variante);
|
||||
}
|
||||
|
||||
public static bool eliminarVariante(int idVariante)
|
||||
{
|
||||
return DAO.eliminarVarianteDAO(idVariante);
|
||||
}
|
||||
|
||||
public static List<ImporteModel> conseguirImportes()
|
||||
{
|
||||
List<ImporteModel> importes = new List<ImporteModel>();
|
||||
|
||||
Reference in New Issue
Block a user