crud de variante sin lo relacionado a editar

This commit is contained in:
Carlos Sandoval
2024-06-21 16:04:33 -06:00
parent ff714ef848
commit 68bcb453d1
15 changed files with 82 additions and 26 deletions
+2 -1
View File
@@ -40,6 +40,7 @@
this.VariantePanel.Name = "VariantePanel";
this.VariantePanel.Size = new System.Drawing.Size(1146, 516);
this.VariantePanel.TabIndex = 16;
this.VariantePanel.Paint += new System.Windows.Forms.PaintEventHandler(this.VariantePanel_Paint);
//
// btnAgregar
//
@@ -59,7 +60,7 @@
this.ClientSize = new System.Drawing.Size(1171, 587);
this.Controls.Add(this.btnAgregar);
this.Controls.Add(this.VariantePanel);
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.Margin = new System.Windows.Forms.Padding(2);
this.Name = "Variantes";
this.Text = "Variantes";
this.Load += new System.EventHandler(this.Variantes_Load);
+6 -23
View File
@@ -113,31 +113,9 @@ namespace compabetov2.admin
"Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
if (service.eliminarProducto(producto))
if (service.eliminarVariante(variante.idVariante))
{
//eliminar imagen antigua
string destinationFolder = Path.Combine(Application.StartupPath, "Resources");
string imagenEliminada = 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();
}
}
});
@@ -167,5 +145,10 @@ namespace compabetov2.admin
ventana.Owner = this;
ventana.Show();
}
private void VariantePanel_Paint(object sender, PaintEventArgs e)
{
}
}
}
+8 -1
View File
@@ -1,4 +1,5 @@
using compabetov2.database.modelos;
using compabetov2.database;
using compabetov2.database.modelos;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -41,6 +42,12 @@ namespace compabetov2.admin
producto.idProducto,
Decimal.Parse(txtPrecioCompra.Text)
);
if (service.insertarVariante(NuevaVariante))
{
Close();
ventanaPadre.llenarLayout();
}
}
}
+1 -1
View File
@@ -16,7 +16,7 @@ namespace compabetov2.admin
public partial class agregarproducto : Form
{
private crud ventanaPadre;
private string imagePath;
private string imagePath = "";
public agregarproducto(crud ventanaPadre)
{
this.ventanaPadre = ventanaPadre;