fix: arreglos en formCliente y eliminado un list obsoleto

This commit is contained in:
2024-04-26 20:46:21 +01:00
parent 675d86f38d
commit ae8dc07364
5 changed files with 71 additions and 69 deletions

View File

@@ -1,13 +1,5 @@
using Entidades;
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;
using Controladora;
namespace Vista
{
@@ -17,12 +9,30 @@ namespace Vista
public FrmCliente(Cliente? cliente = null)
{
InitializeComponent();
this.cliente = cliente;
if (cliente != null)
{
this.cliente = cliente;
this.Text = "Modificar Proveedor";
CargarDatos();
}
else
{
this.Text = "Agregar Proveedor";
this.Text = (cliente == null) ?
"Agregar Cliente" :
"Modificar Cliente";
}
}
private void CargarDatos()
{
txtNombre.Text = cliente.Nombre;
txtApellido.Text = cliente.Apellido;
txtDireccion.Text = cliente.Direccion;
txtCorreo.Text = cliente.Correo;
txtCuit.ReadOnly = true;
}
private bool ValidarDatos()
{
string devolucion = "";
@@ -50,12 +60,12 @@ namespace Vista
}
}
private void button2_Click(object sender, EventArgs e)
private void BtnCancelar_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
private void BtnAceptar_Click(object sender, EventArgs e)
{
string msg;
if (ValidarDatos())
@@ -68,22 +78,22 @@ namespace Vista
Cuit = txtCuit.Text,
Direccion = txtDireccion.Text,
Apellido = txtApellido.Text,
Correo = txtCorreo.Text,
Correo = txtCorreo.Text,
};
// msg = ControladoraCliente.Instance.AgregarCliente(Cliente);
msg = ControladoraClientes.Instance.Añadir(cliente);
}
else
{
//Cliente.Apellido = txtApellido.Text;
// Cliente.Nombre = txtNombre.Text;
// Cliente.Direccion = txtDireccion.Text;
// Cliente.Correo = txtCorreo.Text;
// Cliente.Cuit = txtCuit.Text;
// msg = ControladoraCliente.Instance.ModificarCliente(Cliente);
cliente.Apellido = txtApellido.Text;
cliente.Nombre = txtNombre.Text;
cliente.Direccion = txtDireccion.Text;
cliente.Correo = txtCorreo.Text;
cliente.Cuit = txtCuit.Text;
msg = ControladoraClientes.Instance.Modificar(cliente);
}
// MessageBox.Show(msg, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show(msg, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
Close();
}