merge gigante
This commit is contained in:
91
Vista/FrmProveedor.cs
Normal file
91
Vista/FrmProveedor.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
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;
|
||||
|
||||
public FrmProveedor(Proveedor? proveedor = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
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;
|
||||
};
|
||||
|
||||
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 numCuit_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user