merma completa
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -207,5 +207,20 @@ namespace compabetov2.database
|
||||
{
|
||||
return DAO.crearVentaDAO(venta, detalleVentas);
|
||||
}
|
||||
|
||||
public static bool insertarMerma(Merma merma)
|
||||
{
|
||||
return DAO.insertarMermaDAO(merma);
|
||||
}
|
||||
|
||||
public static bool eliminarMerma(Merma merma)
|
||||
{
|
||||
return DAO.eliminarMermaDAO(merma);
|
||||
}
|
||||
|
||||
public static bool actualizarMerma(Merma merma)
|
||||
{
|
||||
return DAO.actualizarMermaDAO(merma);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user