crud de variante terminado, tal vez con detalles

This commit is contained in:
Carlos Sandoval
2024-06-24 23:15:03 -06:00
parent a9c9bd2c05
commit a610343abe
24 changed files with 288 additions and 227 deletions
+8 -21
View File
@@ -29,7 +29,7 @@ namespace compabetov2.admin
AdminPanel.Controls.Clear();
productos.Clear();
productos = service.conseguirProductos();
foreach (Producto producto in productos)
{
@@ -41,7 +41,7 @@ namespace compabetov2.admin
filaLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
filaLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
filaLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
TableLayoutPanel informacionProducto = new TableLayoutPanel();
informacionProducto.RowCount = 1;
@@ -133,27 +133,10 @@ namespace compabetov2.admin
{
//eliminar imagen antigua
string destinationFolder = Path.Combine(Application.StartupPath, "Resources");
string imagenEliminada = Path.Combine(destinationFolder, producto.img);
string imagenEliminar = Path.Combine(destinationFolder, producto.img);
llenarLayout();
//se pone a esperar 1 segundo antes de eliminar la imagen
//esto para que al programa le de tiempo de dejar de utilizar la imagen y no lance una excepcion
Timer timer = new Timer();
timer.Interval = 1000; // 1 segundos
timer.Tick += delegate (object sender2, EventArgs e2)
{
try
{
File.Delete(imagenEliminada);
timer.Stop();
}
catch (Exception ex)
{
// Manejar la excepción de eliminación de archivo temporal
Console.WriteLine("Error al eliminar archivo temporal: " + ex.Message);
}
};
timer.Start();
}
}
});
@@ -172,7 +155,7 @@ namespace compabetov2.admin
AdminPanel.Controls.Add(filaLayout);
}
}
private void crud_Load(object sender, EventArgs e)
{
@@ -211,5 +194,9 @@ namespace compabetov2.admin
agregarproducto.Owner = this;
agregarproducto.Show();
}
}
}