no pude usar controladoras, no carga los datos ,interface de cliente y provedor
This commit is contained in:
93
Vista/FrmCliente.cs
Normal file
93
Vista/FrmCliente.cs
Normal 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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user