diff --git a/Vista/FrmCliente.Designer.cs b/Vista/FrmCliente.Designer.cs index e13da86..d2a401d 100644 --- a/Vista/FrmCliente.Designer.cs +++ b/Vista/FrmCliente.Designer.cs @@ -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; } } diff --git a/Vista/FrmCliente.cs b/Vista/FrmCliente.cs index 4472952..8a940e1 100644 --- a/Vista/FrmCliente.cs +++ b/Vista/FrmCliente.cs @@ -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(); - this.cliente = cliente; + if (cliente != null) + { + this.cliente = cliente; + this.Text = "Modificar Proveedor"; + CargarDatos(); + } + else + { + this.Text = "Agregar Proveedor"; - this.Text = (cliente == null) ? - "Agregar Cliente" : - "Modificar Cliente"; + } } + + 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()) @@ -68,22 +78,22 @@ namespace Vista Cuit = txtCuit.Text, Direccion = txtDireccion.Text, Apellido = txtApellido.Text, - Correo = txtCorreo.Text, - + Correo = txtCorreo.Text, + }; - - // 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(); } diff --git a/Vista/FrmCliente.resx b/Vista/FrmCliente.resx index af32865..a395bff 100644 --- a/Vista/FrmCliente.resx +++ b/Vista/FrmCliente.resx @@ -18,7 +18,7 @@ System.Resources.ResXResourceReader, System.Windows.Forms, ... System.Resources.ResXResourceWriter, System.Windows.Forms, ... this is my long stringthis is a comment - Blue + Blue [base64 mime encoded serialized .NET Framework object] diff --git a/Vista/FrmClientes.cs b/Vista/FrmClientes.cs index 636b34f..0abf28c 100644 --- a/Vista/FrmClientes.cs +++ b/Vista/FrmClientes.cs @@ -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,9 +57,9 @@ 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); - ActualizarGrilla(); + string devolucion = ControladoraClientes.Instance.Eliminar(long.Parse(Fila.Cells["Cuit"].Value.ToString())); + MessageBox.Show(devolucion); + ActualizarGrilla(); } } } diff --git a/Vista/FrmProveedor.cs b/Vista/FrmProveedor.cs index 1fb65bc..69bf238 100644 --- a/Vista/FrmProveedor.cs +++ b/Vista/FrmProveedor.cs @@ -6,8 +6,6 @@ namespace Vista public partial class FrmProveedor : Form { Proveedor proveedor; - - List listaProveedores = new List(); 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