parte visual envios

This commit is contained in:
carlos
2024-01-23 17:44:38 -06:00
parent da855a6c85
commit 2b2624fb41
11 changed files with 183 additions and 12 deletions
+27 -1
View File
@@ -1212,7 +1212,7 @@ namespace compabetov2.database
{
try
{
string sqlEnvio = "INSERT INTO envios (fecha, direccion, telefono) VALUES(@fecha,@direccion , @telefono);";
string sqlEnvio = "INSERT INTO envios (fecha, direccion, telefono,total) VALUES(@fecha,@direccion , @telefono,@total);";
string sqlDetalle = "INSERT INTO detalle_envios (fk_envios, fk_producto, cantidad) VALUES(@fk_envios, @fk_producto, @cantidad);";
string sqlIdCuenta = "SELECT idEnvios FROM envios ORDER BY idEnvios DESC LIMIT 1";
@@ -1220,6 +1220,7 @@ namespace compabetov2.database
commandCuenta.Parameters.AddWithValue("@fecha", envio.fecha);
commandCuenta.Parameters.AddWithValue("@direccion", "");
commandCuenta.Parameters.AddWithValue("@telefono", "");
commandCuenta.Parameters.AddWithValue("@total", envio.total);
commandCuenta.ExecuteNonQuery();
SQLiteCommand commandConsulta = new SQLiteCommand(sqlIdCuenta, conexion);
@@ -1283,6 +1284,31 @@ namespace compabetov2.database
}
}
public static SQLiteDataReader conseguirDetalleEnvioDAO(int idEnvio)
{
SQLiteDataReader reader = null;
var db_conexion = new Conexion();
try
{
SQLiteConnection conexion = db_conexion.get_connection();
conexion.Open();
string sql = "Select p.idproducto, p.nombre , de.cantidad from detalle_envios de, Producto p WHERE de.fk_producto = p.idproducto and de.fk_envios = @fk_envios;";
SQLiteCommand command = new SQLiteCommand(sql, conexion);
command.Parameters.AddWithValue("@fk_envios", idEnvio);
reader = command.ExecuteReader();
return reader;
}
catch (SQLiteException ex)
{
MessageBox.Show(ex.Message);
return reader;
}
}
private static void crearDB()
{
var db_conexion = new Conexion();
+7 -1
View File
@@ -13,13 +13,19 @@ namespace compabetov2.database.modelos
public string direccion;
public string telefono;
public string responsable;
public string estado;
public string cliente;
public decimal total;
public Envio(int id, string fecha, string direccion, string telefono, string responsable) {
public Envio(int id, string fecha, string direccion, string telefono, string responsable,string estado,string cliente, decimal total) {
this.id = id;
this.fecha = fecha;
this.direccion = direccion;
this.telefono = telefono;
this.responsable = responsable;
this.estado = estado;
this.cliente = cliente;
this.total = total;
}
}
}
+25 -2
View File
@@ -333,13 +333,36 @@ namespace compabetov2.database
reader.GetString(1),
reader.GetString(2),
reader.GetString(3),
reader.GetString(4)
);
reader.GetString(4),
reader.GetString(5),
reader.GetString(7),
reader.GetDecimal(6)
) ;
envios.Add(envio);
}
return envios;
}
public static List<DetalleEnvioModel> conseguirDetalleEnvio(int idEnvio)
{
List<DetalleEnvioModel> detallesEnvio = new List<DetalleEnvioModel>();
SQLiteDataReader reader = DAO.conseguirDetalleEnvioDAO(idEnvio);
while (reader.Read())
{
int idProducto = (int)reader.GetInt64(0);
DetalleEnvioModel detalleEnvio = new DetalleEnvioModel(
idEnvio,
new Producto(idProducto, reader["nombre"].ToString()),
(int)reader.GetInt64(2)
);
detallesEnvio.Add(detalleEnvio);
}
return detallesEnvio;
}
}
}