no pude usar controladoras, no carga los datos ,interface de cliente y provedor

This commit is contained in:
2024-08-11 18:20:24 -03:00
parent 1aded875ab
commit e82c5a70b8
46 changed files with 6435 additions and 82 deletions

93
Vista/FrmCliente.cs Normal file
View File

@@ -0,0 +1,93 @@
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;
namespace Vista
{
public partial class FrmCliente : Form
{
Cliente cliente;
public FrmCliente(Cliente? cliente = null)
{
InitializeComponent();
this.cliente = cliente;
this.Text = (cliente == null) ?
"Agregar Cliente" :
"Modificar Cliente";
}
private bool ValidarDatos()
{
string devolucion = "";
/*
* complicado de leer pero en estas lineas estan todas las comprobaciones
* que pude pensar en el momento.
*/
if (string.IsNullOrEmpty(txtDireccion.Text)) devolucion += "La direccion no deberia ser nulo o vacio\n";
if (txtDireccion.Text.Length > 200) devolucion += "La direccion no puede superar los 200 chars\n";
if (string.IsNullOrEmpty(txtNombre.Text)) devolucion += "el nombre no puede ser nulo o vacio\n";
if (txtNombre.Text.Length > 50) devolucion += "El nombre no puede superar los 50 chars\n";
if (string.IsNullOrEmpty(txtApellido.Text)) devolucion += "El Apellido no puede ser nulo o vacio\n";
if (string.IsNullOrEmpty(txtCorreo.Text)) devolucion += "El Correo no puede ser nulo o vacio\n";
if (devolucion == "")
{
return true;
}
else
{
MessageBox.Show(devolucion);
return false;
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
string msg;
if (ValidarDatos())
{
if (cliente == null)
{
cliente = new Cliente
{
Nombre = txtNombre.Text,
Cuit = txtCuit.Text,
Direccion = txtDireccion.Text,
Apellido = txtApellido.Text,
Correo = txtCorreo.Text,
};
// msg = ControladoraCliente.Instance.AgregarCliente(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);
}
// MessageBox.Show(msg, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
Close();
}
}
}
}