fix: arreglos en formCliente y eliminado un list obsoleto

This commit is contained in:
2024-04-26 20:46:21 +01:00
committed by fede
parent 5673d60e4f
commit b5b59eb2fd
5 changed files with 71 additions and 69 deletions

View File

@@ -39,8 +39,8 @@ namespace Vista
txtApellido = new TextBox();
txtDireccion = new TextBox();
txtCorreo = new TextBox();
button1 = new Button();
button2 = new Button();
BtnAceptar = new Button();
BtnCancelar = new Button();
SuspendLayout();
//
// label1
@@ -123,33 +123,36 @@ namespace Vista
txtCorreo.Size = new Size(174, 23);
txtCorreo.TabIndex = 9;
//
// button1
// BtnAceptar
//
button1.Location = new Point(29, 190);
button1.Name = "button1";
button1.Size = new Size(75, 23);
button1.TabIndex = 10;
button1.Text = "Aceptar";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click;
BtnAceptar.Location = new Point(29, 190);
BtnAceptar.Name = "BtnAceptar";
BtnAceptar.Size = new Size(75, 23);
BtnAceptar.TabIndex = 10;
BtnAceptar.Text = "Aceptar";
BtnAceptar.UseVisualStyleBackColor = true;
BtnAceptar.Click += BtnAceptar_Click;
//
// button2
// BtnCancelar
//
button2.Location = new Point(158, 190);
button2.Name = "button2";
button2.Size = new Size(75, 23);
button2.TabIndex = 11;
button2.Text = "Cancelar";
button2.UseVisualStyleBackColor = true;
button2.Click += button2_Click;
BtnCancelar.Location = new Point(158, 190);
BtnCancelar.Name = "BtnCancelar";
BtnCancelar.Size = new Size(75, 23);
BtnCancelar.TabIndex = 11;
BtnCancelar.Text = "Cancelar";
BtnCancelar.UseVisualStyleBackColor = true;
BtnCancelar.Click += BtnCancelar_Click;
//
// FrmCliente
//
AcceptButton = BtnAceptar;
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
CancelButton = BtnCancelar;
ClientSize = new Size(420, 245);
Controls.Add(button2);
Controls.Add(button1);
ControlBox = false;
Controls.Add(BtnCancelar);
Controls.Add(BtnAceptar);
Controls.Add(txtCorreo);
Controls.Add(txtDireccion);
Controls.Add(txtApellido);
@@ -179,8 +182,8 @@ namespace Vista
private TextBox txtApellido;
private TextBox txtDireccion;
private TextBox txtCorreo;
private Button button1;
private Button button2;
private Button BtnAceptar;
private Button BtnCancelar;
public EventHandler button1_Click_1 { get; private set; }
}

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();
if (cliente != null)
{
this.cliente = cliente;
this.Text = (cliente == null) ?
"Agregar Cliente" :
"Modificar Cliente";
this.Text = "Modificar Proveedor";
CargarDatos();
}
else
{
this.Text = "Agregar Proveedor";
}
}
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())
@@ -72,18 +82,18 @@ namespace Vista
};
// 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();
}

View File

@@ -18,7 +18,7 @@
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>

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,13 +9,13 @@ namespace Vista
public FrmClientes()
{
InitializeComponent();
ActualizarGrilla();
}
private void ActualizarGrilla()
{
dataGridView1.DataSource = null;
// dataGridView1.DataSource = listaProveedores;
//revisar dataGridView1.DataSource = ControladoraClientes.Instance.RecuperarProveedores();
dataGridView1.DataSource = ControladoraClientes.Instance.Listar();
}
private void button1_Click(object sender, EventArgs e)
@@ -45,7 +37,7 @@ namespace Vista
{
Nombre = dataGridView1.SelectedRows[0].Cells["Nombre"].Value.ToString(),
Cuit = dataGridView1.SelectedRows[0].Cells["Cuit"].Value.ToString(),
Apellido = dataGridView1.SelectedRows[0].Cells["RazonSocial"].Value.ToString(),
Apellido = dataGridView1.SelectedRows[0].Cells["Apellido"].Value.ToString(),
Direccion = dataGridView1.SelectedRows[0].Cells["Direccion"].Value.ToString(),
Correo = dataGridView1.SelectedRows[0].Cells["Correo"].Value.ToString(),
};
@@ -65,8 +57,8 @@ namespace Vista
foreach (DataGridViewRow Fila in dataGridView1.SelectedRows)
{ // itera por un loop y elimina las lineas seleccionadas 1 a la vez.
//string devolucion = ControladoraClientes.Instance.EliminarCliente(Fila.Cells["Codigo"].Value.ToString());
// MessageBox.Show(devolucion);
string devolucion = ControladoraClientes.Instance.Eliminar(long.Parse(Fila.Cells["Cuit"].Value.ToString()));
MessageBox.Show(devolucion);
ActualizarGrilla();
}
}

View File

@@ -6,8 +6,6 @@ namespace Vista
public partial class FrmProveedor : Form
{
Proveedor proveedor;
List<Proveedor> listaProveedores = new List<Proveedor>();
public FrmProveedor(Proveedor? proveedor = null)
{
@@ -17,7 +15,7 @@ namespace Vista
{
this.proveedor = proveedor;
this.Text = "Modificar Proveedor";
CargarDatos(proveedor);
CargarDatos();
}
else
{
@@ -27,7 +25,7 @@ namespace Vista
}
private void CargarDatos(Proveedor proveedor)
private void CargarDatos()
{
txtDireccion.Text = proveedor.Direccion;
txtNombre.Text = proveedor.Nombre;
@@ -78,7 +76,6 @@ namespace Vista
RazonSocial = txtSocial.Text,
Habilitado = checkBoxHabilitado.Checked,
};
listaProveedores.Add(proveedor);
msg = ControladoraProveedores.Instance.Añadir(proveedor);
}
else