arreglado tema clientes y otras cosas

This commit is contained in:
fedpo
2024-08-06 01:06:37 +01:00
parent a323a5cca1
commit 5b7ee8c6bc
28 changed files with 153 additions and 99 deletions

View File

@@ -8,10 +8,7 @@ namespace Controladora
{
public string Añadir(Cliente t)
{
if (t == null)
{
return "El Cliente es nulo, fallo la carga";
}
if (t == null) return "El Cliente es nulo, fallo la carga";
// Verificar si el CUIT ya existe en el repositorio
if (RepositorioClientes.Instance.ExistePorCuit(t.Cuit))

View File

@@ -14,29 +14,31 @@ namespace Controladora
public string Añadir(Remito t)
{
if (t == null) return "El Remito es nulo fallo la carga";
if (t.Id < 0) return "El id Esta Mal Cargado";
return (RepositorioRemito.Instance.Add(t)) ?
var retRemito = RepositorioRemito.Instance.Add(t);
var retLotes = RepositorioLote.Instance.Add(t);
return (!retLotes) ?
$"El remito {t.Id} se cargo correctamente":
$"Fallo la carga del remito {t.Id}";
}
public string Modificar(Remito t)
{
if (t == null) return "El Remito es nulo fallo la carga";
return (RepositorioRemito.Instance.Add(t)) ?
$"El remito {t.Id} se cargo correctamente":
$"Fallo la carga del remito {t.Id}";
return "No se puede modificar un Remito";
}
public string Eliminar(Remito t)
private string Eliminar(Remito t)
{
return "No se puede Eliminar un remito";
/*
if (t == null) return "El Remito es nulo fallo la carga";
return (RepositorioRemito.Instance.Add(t)) ?
$"El remito {t.Id} se cargo correctamente":
$"Fallo la carga del remito {t.Id}";
return (RepositorioRemito.Instance.Del(t)) ?
$"El remito {t.Id} se elimino correctamente":
$"Fallo la Eliminacion del remito {t.Id}";
*/
}
}
}

View File

@@ -49,6 +49,8 @@
<Path>
<Point X="11" Y="1.988" />
<Point X="11" Y="2.155" />
<Point X="9.958" Y="2.155" Type="JumpStart" />
<Point X="9.792" Y="2.155" Type="JumpEnd" />
<Point X="8" Y="2.155" />
</Path>
</InheritanceLine>
@@ -73,12 +75,9 @@
<Class Name="Entidades.Lote">
<Position X="0.75" Y="1.75" Width="2" />
<TypeIdentifier>
<HashCode>AAACAAAAAAAAAAEAQABAAAAAAAAAABAAAAAAAAAAAAA=</HashCode>
<HashCode>AAAAAAAAAAAAAAEAAAAAAAAAAAAAABAAAAAAAAAAAAA=</HashCode>
<FileName>Lote.cs</FileName>
</TypeIdentifier>
<ShowAsAssociation>
<Property Name="Producto" />
</ShowAsAssociation>
</Class>
<Class Name="Entidades.OrdenDeCompra">
<Position X="10" Y="5.25" Width="1.5" />

17
Entidades/EnvaseTipo.cs Normal file
View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entidades
{
public enum EnvaseTipo
{
Plastico,
Enlatado,
Carton,
NoTiene
}
}

View File

@@ -1,12 +1,9 @@

namespace Entidades
{
public class Lote
public class Lote: Detalle<Producto>
{
public int Id { get; set; }
public DateTime Fecha { get; set; }
public Producto Producto { get; set; }
public long CantidadDeProductos { get; set; }
public bool Habilitado { get; set; }
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entidades
{
public class ProductoNoPercedero : Producto
{
public EnvaseTipo TipoDeEnvase { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entidades
{
public class ProductoPercedero : Producto
{
public int MesesHastaConsumoPreferente { get; set; }
public int MesesHastaVencimiento { get; set; }
}
}

View File

@@ -6,11 +6,6 @@ namespace Modelo
{
public override bool Add(Cliente t)
{
if (ExistePorCuit(t.Cuit))
{
throw new InvalidOperationException($"El Cliente con el CUIT {t.Cuit} ya existe.");
}
bool ret = false;
try
{
@@ -33,8 +28,6 @@ namespace Modelo
override public bool Mod(Cliente t)
{
bool ret = false;
try
{
var clienteAModificar = almacen.FindIndex(x => x.Cuit == t.Cuit);

View File

@@ -4,6 +4,7 @@ namespace Modelo
{
public sealed class RepositorioLote : RepositorioBase<Lote, RepositorioLote>
{
override public bool Add(Lote t)
{
bool ret = false;
@@ -21,6 +22,23 @@ namespace Modelo
return ret;
}
public bool Add(Remito rem)
{
if (rem.MostrarLotes().Count <= 0) return true;
var ret = false;
try
{
foreach (var detalle in rem.MostrarLotes())
{
ret = Add(detalle);
}
}catch (Exception)
{
throw;
}
return ret;
}
override public bool Mod(Lote t)
{
bool ret = false;

View File

@@ -85,6 +85,7 @@ namespace Vista
Direccion = txtDireccion.Text,
Apellido = txtApellido.Text,
Correo = txtCorreo.Text,
Habilitado = true
};

View File

@@ -32,9 +32,9 @@
BtnEliminar = new Button();
groupBox1 = new GroupBox();
BtnAceptar = new Button();
dataGridView1 = new DataGridView();
dgvCliente = new DataGridView();
groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
((System.ComponentModel.ISupportInitialize)dgvCliente).BeginInit();
SuspendLayout();
//
// BtnModificar
@@ -60,7 +60,7 @@
// groupBox1
//
groupBox1.Controls.Add(BtnAceptar);
groupBox1.Controls.Add(dataGridView1);
groupBox1.Controls.Add(dgvCliente);
groupBox1.Controls.Add(BtnEliminar);
groupBox1.Controls.Add(BtnModificar);
groupBox1.Location = new Point(12, 2);
@@ -79,20 +79,20 @@
BtnAceptar.UseVisualStyleBackColor = true;
BtnAceptar.Click += BtnAceptar_Click;
//
// dataGridView1
// dgvCliente
//
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Location = new Point(6, 22);
dataGridView1.MultiSelect = false;
dataGridView1.Name = "dataGridView1";
dataGridView1.ReadOnly = true;
dataGridView1.RowTemplate.Height = 25;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.Size = new Size(737, 235);
dataGridView1.TabIndex = 3;
dgvCliente.AllowUserToAddRows = false;
dgvCliente.AllowUserToDeleteRows = false;
dgvCliente.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dgvCliente.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dgvCliente.Location = new Point(6, 22);
dgvCliente.MultiSelect = false;
dgvCliente.Name = "dgvCliente";
dgvCliente.ReadOnly = true;
dgvCliente.RowTemplate.Height = 25;
dgvCliente.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvCliente.Size = new Size(737, 235);
dgvCliente.TabIndex = 3;
//
// FrmClientes
//
@@ -104,7 +104,7 @@
Text = "Clientes";
WindowState = FormWindowState.Maximized;
groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
((System.ComponentModel.ISupportInitialize)dgvCliente).EndInit();
ResumeLayout(false);
}
@@ -112,7 +112,7 @@
private Button BtnModificar;
private Button BtnEliminar;
private GroupBox groupBox1;
private DataGridView dataGridView1;
private DataGridView dgvCliente;
private Button BtnAceptar;
}
}

View File

@@ -14,8 +14,8 @@ namespace Vista
private void ActualizarGrilla()
{
dataGridView1.DataSource = null;
dataGridView1.DataSource = ControladoraClientes.Instance.Listar();
dgvCliente.DataSource = null;
dgvCliente.DataSource = ControladoraClientes.Instance.Listar();
}
private void BtnAceptar_Click(object sender, EventArgs e)
@@ -27,7 +27,7 @@ namespace Vista
private void BtnModificar_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count < 1)
if (dgvCliente.SelectedRows.Count < 1)
{
MessageBox.Show("Seleccione una linea para modificar");
return;
@@ -35,11 +35,11 @@ namespace Vista
Cliente cliente = new Cliente()
{
Nombre = dataGridView1.SelectedRows[0].Cells["Nombre"].Value.ToString(),
Cuit = (Int64)dataGridView1.SelectedRows[0].Cells["Cuit"].Value,
Apellido = dataGridView1.SelectedRows[0].Cells["Apellido"].Value.ToString(),
Direccion = dataGridView1.SelectedRows[0].Cells["Direccion"].Value.ToString(),
Correo = dataGridView1.SelectedRows[0].Cells["Correo"].Value.ToString(),
Nombre = dgvCliente.SelectedRows[0].Cells["Nombre"].Value.ToString(),
Cuit = (Int64)dgvCliente.SelectedRows[0].Cells["Cuit"].Value,
Apellido = dgvCliente.SelectedRows[0].Cells["Apellido"].Value.ToString(),
Direccion = dgvCliente.SelectedRows[0].Cells["Direccion"].Value.ToString(),
Correo = dgvCliente.SelectedRows[0].Cells["Correo"].Value.ToString(),
};
var formModificar = new FrmCliente(cliente);
@@ -49,13 +49,13 @@ namespace Vista
private void BtnEliminar_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count < 0)
if (dgvCliente.SelectedRows.Count < 0)
{
MessageBox.Show("Seleccione una linea para eliminar");
return;
}
foreach (DataGridViewRow Fila in dataGridView1.SelectedRows)
foreach (DataGridViewRow Fila in dgvCliente.SelectedRows)
{ // itera por un loop y elimina las lineas seleccionadas 1 a la vez.
string devolucion = ControladoraClientes.Instance.Eliminar(long.Parse(Fila.Cells["Cuit"].Value.ToString()));
MessageBox.Show(devolucion);
@@ -64,5 +64,5 @@ namespace Vista
}
}
}
}

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

@@ -29,15 +29,15 @@
private void InitializeComponent()
{
groupBox1 = new GroupBox();
label2 = new Label();
label1 = new Label();
dgvDetalles = new DataGridView();
dgvOrdenDeCompra = new DataGridView();
BtnAdd = new Button();
BtnEliminar = new Button();
dgvDetalles = new DataGridView();
label1 = new Label();
label2 = new Label();
groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dgvOrdenDeCompra).BeginInit();
((System.ComponentModel.ISupportInitialize)dgvDetalles).BeginInit();
((System.ComponentModel.ISupportInitialize)dgvOrdenDeCompra).BeginInit();
SuspendLayout();
//
// groupBox1
@@ -54,6 +54,37 @@
groupBox1.TabIndex = 4;
groupBox1.TabStop = false;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(6, 4);
label2.Name = "label2";
label2.Size = new Size(102, 15);
label2.TabIndex = 6;
label2.Text = "Orden de Compra";
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(404, 4);
label1.Name = "label1";
label1.Size = new Size(48, 15);
label1.TabIndex = 5;
label1.Text = "Detalles";
//
// dgvDetalles
//
dgvDetalles.AllowUserToAddRows = false;
dgvDetalles.AllowUserToDeleteRows = false;
dgvDetalles.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dgvDetalles.EditMode = DataGridViewEditMode.EditProgrammatically;
dgvDetalles.Location = new Point(404, 22);
dgvDetalles.Name = "dgvDetalles";
dgvDetalles.RowTemplate.Height = 25;
dgvDetalles.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvDetalles.Size = new Size(471, 235);
dgvDetalles.TabIndex = 4;
//
// dgvOrdenDeCompra
//
dgvOrdenDeCompra.AllowUserToAddRows = false;
@@ -88,37 +119,6 @@
BtnEliminar.UseVisualStyleBackColor = true;
BtnEliminar.Click += BtnEliminar_Click;
//
// dgvDetalles
//
dgvDetalles.AllowUserToAddRows = false;
dgvDetalles.AllowUserToDeleteRows = false;
dgvDetalles.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dgvDetalles.EditMode = DataGridViewEditMode.EditProgrammatically;
dgvDetalles.Location = new Point(404, 22);
dgvDetalles.Name = "dgvDetalles";
dgvDetalles.RowTemplate.Height = 25;
dgvDetalles.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvDetalles.Size = new Size(471, 235);
dgvDetalles.TabIndex = 4;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(404, 4);
label1.Name = "label1";
label1.Size = new Size(48, 15);
label1.TabIndex = 5;
label1.Text = "Detalles";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(6, 4);
label2.Name = "label2";
label2.Size = new Size(102, 15);
label2.TabIndex = 6;
label2.Text = "Orden de Compra";
//
// FrmOrdenesDeCompras
//
AutoScaleDimensions = new SizeF(7F, 15F);
@@ -130,8 +130,8 @@
WindowState = FormWindowState.Maximized;
groupBox1.ResumeLayout(false);
groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)dgvOrdenDeCompra).EndInit();
((System.ComponentModel.ISupportInitialize)dgvDetalles).EndInit();
((System.ComponentModel.ISupportInitialize)dgvOrdenDeCompra).EndInit();
ResumeLayout(false);
}

View File

@@ -68,13 +68,14 @@ namespace Vista
Id = 2,
Descripcion = "Perfumeria"
});
Producto producto = new Producto
ProductoNoPercedero producto = new ProductoNoPercedero
{
Id = 1,
Categoria = ControladoraCategorias.Instance.Listar()[0],
Habilitado = true,
Nombre = "Pantalones Vaqueros",
Precio = 2000.2
Precio = 2000.2,
TipoDeEnvase = EnvaseTipo.NoTiene
};
producto.A<EFBFBD>adirProveedor(proveedor);
ControladoraProductos.Instance.A<EFBFBD>adir(producto);