merma completa

This commit is contained in:
carlos
2024-01-18 23:17:35 -06:00
parent a438eb1914
commit f084bb8e20
24 changed files with 895 additions and 33 deletions
+91
View File
@@ -721,6 +721,36 @@ namespace compabetov2.database
}
}
public static bool insertarMermaDAO(Merma merma)
{
var db_conexion = new Conexion();
try
{
using (SQLiteConnection conexion = db_conexion.get_connection())
{
conexion.Open();
string sql = "INSERT INTO Merma (fecha, responsable, razon) VALUES(@fecha, @responsable, @razon);";
using (SQLiteCommand command = new SQLiteCommand(sql, conexion))
{
command.Parameters.AddWithValue("@fecha", merma.fecha);
command.Parameters.AddWithValue("@responsable", merma.responsable);
command.Parameters.AddWithValue("@razon", merma.razon);
int filasAfectadas = command.ExecuteNonQuery();
if (filasAfectadas > 0) { return true; }
else { return false; }
}
}
}
catch (SQLiteException ex)
{
MessageBox.Show(ex.Message);
return false;
}
}
public static bool crearVentaDAO(VentaModel venta, List<DetalleVentaModel> detalleVentas)
{
var db_conexion = new Conexion();
@@ -781,6 +811,67 @@ namespace compabetov2.database
}
}
public static bool eliminarMermaDAO(Merma merma)
{
var db_conexion = new Conexion();
try
{
using (SQLiteConnection conexion = db_conexion.get_connection())
{
conexion.Open();
string sql = "DELETE FROM Merma WHERE idmerma = @idmerma;";
using (SQLiteCommand command = new SQLiteCommand(sql, conexion))
{
command.Parameters.AddWithValue("@idmerma", merma.idMerma);
int filasAfectadas = command.ExecuteNonQuery();
if (filasAfectadas > 0) { return true; }
else { return false; }
}
}
}
catch (SQLiteException ex)
{
MessageBox.Show(ex.Message);
return false;
}
}
public static bool actualizarMermaDAO(Merma merma)
{
var db_conexion = new Conexion();
try
{
using (SQLiteConnection conexion = db_conexion.get_connection())
{
conexion.Open();
string sql = "UPDATE Merma SET fecha = @fecha, responsable = @responsable, razon = @razon WHERE idmerma = @idmerma; ";
using (SQLiteCommand command = new SQLiteCommand(sql, conexion))
{
command.Parameters.AddWithValue("@fecha", merma.fecha);
command.Parameters.AddWithValue("@responsable", merma.responsable);
command.Parameters.AddWithValue("@razon", merma.razon);
command.Parameters.AddWithValue("@idmerma", merma.idMerma);
int filasAfectadas = command.ExecuteNonQuery();
if (filasAfectadas > 0) { return true; }
else { return false; }
}
}
}
catch (SQLiteException ex)
{
MessageBox.Show(ex.Message);
return false;
}
}
private static void crearDB()
{
var db_conexion = new Conexion();