por ahora todo menos orden de compra y remito
This commit is contained in:
@@ -18,6 +18,7 @@ namespace Vista
|
||||
public AddCategoria()
|
||||
{
|
||||
InitializeComponent();
|
||||
CargarDatos();
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
@@ -27,11 +28,8 @@ namespace Vista
|
||||
}
|
||||
private void CargarDatos()
|
||||
{
|
||||
if (categoria != null)
|
||||
{
|
||||
textBox1.Text = categoria.Descripcion;
|
||||
numericUpDown1.Value = categoria.Id;
|
||||
}
|
||||
numid.Value = ControladoraCategorias.Instance.Listar().Max(x => x.Id+1);
|
||||
numid.Enabled = false;
|
||||
}
|
||||
|
||||
private bool ValidarDatos()
|
||||
@@ -44,7 +42,7 @@ namespace Vista
|
||||
devolucion += "La descripción no puede superar los 100 caracteres\n";
|
||||
|
||||
// Validar unicidad del ID solo si es una nueva categoría
|
||||
if (categoria == null && ControladoraCategorias.Instance.Listar().Any(c => c.Id == (int)numericUpDown1.Value))
|
||||
if (categoria == null && ControladoraCategorias.Instance.Listar().Any(c => c.Id == (int)numid.Value))
|
||||
{
|
||||
devolucion += "Ya existe una categoría con el mismo ID\n";
|
||||
}
|
||||
@@ -71,7 +69,7 @@ namespace Vista
|
||||
{
|
||||
categoria = new Categoria
|
||||
{
|
||||
Id = (int)numericUpDown1.Value,
|
||||
Id = (int)numid.Value,
|
||||
Descripcion = textBox1.Text
|
||||
};
|
||||
|
||||
@@ -80,7 +78,7 @@ namespace Vista
|
||||
else
|
||||
{
|
||||
categoria.Descripcion = textBox1.Text;
|
||||
categoria.Id = (int)numericUpDown1.Value; // Solo si quieres permitir modificaciones del ID
|
||||
categoria.Id = (int)numid.Value; // Solo si quieres permitir modificaciones del ID
|
||||
|
||||
msg = ControladoraCategorias.Instance.Modificar(categoria);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user