84 lines
2.5 KiB
C#
84 lines
2.5 KiB
C#
using compabetov2.database;
|
|
using compabetov2.database.modelos;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace compabetov2
|
|
{
|
|
public partial class ActualizarMerma : Form
|
|
{
|
|
private Merma merma;
|
|
private mermas ventanaPadre;
|
|
public ActualizarMerma(Merma merma, mermas ventanaPadre)
|
|
{
|
|
InitializeComponent();
|
|
this.merma = merma;
|
|
this.ventanaPadre = ventanaPadre;
|
|
llenarCampos();
|
|
}
|
|
|
|
private void llenarCampos()
|
|
{
|
|
txtDescripcion.Text = merma.razon;
|
|
txtResponsable.Text = merma.responsable;
|
|
dtFecha.Text = merma.fecha;
|
|
}
|
|
|
|
private void btnAgregar_Click(object sender, EventArgs e)
|
|
{
|
|
Merma nuevaMerma = new Merma(merma.idMerma,dtFecha.Text,txtResponsable.Text,txtDescripcion.Text);
|
|
if (service.actualizarMerma(nuevaMerma))
|
|
{
|
|
MessageBox.Show("Merma actualizada");
|
|
ventanaPadre.llenarPanel();
|
|
Close();
|
|
}
|
|
|
|
}
|
|
|
|
private void txtDescripcion_TextChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void label2_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void pictureBox2_Click(object sender, EventArgs e)
|
|
{
|
|
// Mostrar mensaje de confirmación
|
|
DialogResult result = MessageBox.Show("¿En realidad quieres hacer esta modificación a esta merma?", "Confirmar Modificación", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
|
|
|
// Verificar la respuesta del usuario
|
|
if (result == DialogResult.Yes)
|
|
{
|
|
// Si el usuario hace clic en "Sí", proceder con la actualización
|
|
Merma nuevaMerma = new Merma(merma.idMerma, dtFecha.Text, txtResponsable.Text, txtDescripcion.Text);
|
|
|
|
if (service.actualizarMerma(nuevaMerma))
|
|
{
|
|
MessageBox.Show("Merma actualizada");
|
|
ventanaPadre.llenarPanel();
|
|
Close();
|
|
}
|
|
}
|
|
// Si el usuario hace clic en "No" o cierra la advertencia, no se realiza la actualización
|
|
}
|
|
|
|
|
|
private void pictureBox1_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
}
|
|
}
|