This repository has been archived on 2024-08-10. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Final_OOP/Vista/FrmProveedor.cs

96 lines
3.0 KiB
C#

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 FrmProveedor : Form
{
Proveedor proveedor;
List<Proveedor> listaProveedores = new List<Proveedor>();
public FrmProveedor(Proveedor? proveedor = null)
{
InitializeComponent();
this.proveedor = proveedor;
this.Text = (proveedor == null) ?
"Agregar Proveedor" :
"Modificar Proveedor";
}
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(txtSocial.Text)) devolucion += "La razon social no puede ser nulo o vacio\n";
if (txtSocial.Text.Length > 50) devolucion += "La razon social no puede superar los 50 chars\n";
if (string.IsNullOrEmpty(txtNombre.Text)) devolucion += "El Nombre no puede ser nulo o vacio\n";
if (devolucion == "")
{
return true;
}
else
{
MessageBox.Show(devolucion);
return false;
}
}
private void BtnAceptarr_Click(object sender, EventArgs e)
{
string msg;
if (ValidarDatos())
{
if (proveedor == null)
{
proveedor = new Proveedor
{
Nombre = txtNombre.Text,
Cuit = (Int64)numCuit.Value,
Direccion = txtDireccion.Text,
RazonSocial = txtSocial.Text,
Habilitado = checkBoxHabilitado.Checked,
};
listaProveedores.Add(proveedor);
// msg = ControladoraProveedores.Instance.AgregarProveedor(proveedor);
}
else
{
proveedor.Nombre = txtNombre.Text;
proveedor.Direccion = txtDireccion.Text;
proveedor.RazonSocial = txtSocial.Text;
proveedor.Cuit = (Int64)numCuit.Value;
// msg = ControladoraProveedores.Instance.ModificarProveedor(proveedor);
}
// MessageBox.Show(msg, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}