diff --git a/.vs/Final_OOP/v17/.suo b/.vs/Final_OOP/v17/.suo index 50e89fb..62636ab 100644 Binary files a/.vs/Final_OOP/v17/.suo and b/.vs/Final_OOP/v17/.suo differ diff --git a/Controladora/ControladoraCategorias.cs b/Controladora/ControladoraCategorias.cs index a9f112b..2db1614 100644 --- a/Controladora/ControladoraCategorias.cs +++ b/Controladora/ControladoraCategorias.cs @@ -12,22 +12,11 @@ namespace Controladora { repositorioCategoria = new(new Context()); } - // Método para verificar si una categoría con un ID ya existe - private bool CategoriaExiste(int id) - { - var cat = repositorioCategoria.ObtenerPorId(id); - return (cat.Id == id); - } public string Añadir(Categoria t) { if (t == null) return "La categoría es nula, fallo la carga"; - if (CategoriaExiste(t.Id)) - { - return $"Ya existe una categoría con el ID {t.Id}"; - } - repositorioCategoria.Add(t); repositorioCategoria.Guardar(); return $"La categoría {t.Descripcion} se cargó correctamente"; @@ -46,11 +35,6 @@ namespace Controladora { if (t == null) return "La categoría es nula, fallo la carga"; - if (!CategoriaExiste(t.Id)) - { - return $"No se encontró una categoría con el ID {t.Id}"; - } - repositorioCategoria.Mod(t); repositorioCategoria.Guardar(); return $"La categoría {t.Descripcion} se modificó correctamente"; diff --git a/Controladora/ControladoraClientes.cs b/Controladora/ControladoraClientes.cs index f48cc88..06e2835 100644 --- a/Controladora/ControladoraClientes.cs +++ b/Controladora/ControladoraClientes.cs @@ -11,22 +11,11 @@ namespace Controladora { repositorioClientes = new(new Context()); } - private bool ClienteExiste(long cuit) - { - var cat = repositorioClientes.ObtenerPorId(cuit); - return (cat.Cuit == cuit); - } public string Añadir(Cliente t) { if (t == null) return "El Cliente es nulo, fallo la carga"; - // Verificar si el CUIT ya existe en el repositorio - if (ClienteExiste(t.Cuit)) - { - return $"El Cliente con el CUIT {t.Cuit} ya existe"; - } - try { repositorioClientes.Add(t); diff --git a/Controladora/ControladoraPresupuestos.cs b/Controladora/ControladoraPresupuestos.cs index 8c8ea0a..f6579ca 100644 --- a/Controladora/ControladoraPresupuestos.cs +++ b/Controladora/ControladoraPresupuestos.cs @@ -75,7 +75,7 @@ namespace Controladora if (proveedor.Cuit < 0) return new List().AsReadOnly(); var productos = ControladoraProductos.Instance .Listar() - .Where(x => x.ListarProveedores() + .Where(x => x.proveedores .Any(x => x.Cuit == proveedor.Cuit)) .ToList() .AsReadOnly(); diff --git a/Controladora/ControladoraProductoNoPercedero.cs b/Controladora/ControladoraProductoNoPercedero.cs index 3b89b0c..f5d6e9f 100644 --- a/Controladora/ControladoraProductoNoPercedero.cs +++ b/Controladora/ControladoraProductoNoPercedero.cs @@ -1,12 +1,55 @@ -using System; +using Entidades; +using Modelo; +using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Controladora { - public class ControladoraProductoNoPercedero + public class ControladoraProductoNoPercedero : Singleton { + RepositorioProductosNoPercedero noPercedero; + public ControladoraProductoNoPercedero() + { + noPercedero = new RepositorioProductosNoPercedero(new Context()); + } + + public string Añadir(ProductoNoPercedero t) + { + if (t == null) return "El Producto es nulo fallo la carga"; + + noPercedero.Add(t); + return (noPercedero.Guardar()) ? + $"El Producto {t.Nombre} se cargo correctamente" : + $"Fallo la carga del Producto {t.Nombre}"; + } + + public string Eliminar(ProductoNoPercedero t) + { + if (t == null) return "El Producto es nulo fallo la carga"; + + noPercedero.Del(t); + return (noPercedero.Guardar()) ? + $"El Producto {t.Nombre} se Elimino correctamente" : + $"Fallo la Eliminacion del Producto {t.Nombre}"; + } + + public string Modificar(ProductoNoPercedero t) + { + if (t == null) return "El Producto es nulo fallo la carga"; + + noPercedero.Mod(t); + return (noPercedero.Guardar()) ? + $"El Producto {t.Nombre} se Modifico correctamente" : + $"Fallo la Modificacion del Producto {t.Nombre}"; + } + + public ReadOnlyCollection Listar() + { + return noPercedero.Listar().AsReadOnly(); + } } } diff --git a/Controladora/ControladoraProductoPercedero.cs b/Controladora/ControladoraProductoPercedero.cs index 2052bd9..195ec98 100644 --- a/Controladora/ControladoraProductoPercedero.cs +++ b/Controladora/ControladoraProductoPercedero.cs @@ -1,4 +1,6 @@ -using System; +using Entidades; +using Modelo; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,7 +8,41 @@ using System.Threading.Tasks; namespace Controladora { - public class ControladoraProductoPercedero + public class ControladoraProductoPercedero : Singleton { + RepositorioProductosPercedero Percedero; + public ControladoraProductoPercedero() + { + Percedero = new RepositorioProductosPercedero(new Context()); + } + public string Añadir(ProductoPercedero t) + { + if (t == null) return "El Producto es nulo fallo la carga"; + + Percedero.Add(t); + return (Percedero.Guardar()) ? + $"El Producto {t.Nombre} se cargo correctamente" : + $"Fallo la carga del Producto {t.Nombre}"; + } + + public string Eliminar(ProductoPercedero t) + { + if (t == null) return "El Producto es nulo fallo la carga"; + + Percedero.Del(t); + return (Percedero.Guardar()) ? + $"El Producto {t.Nombre} se Elimino correctamente" : + $"Fallo la eliminacion del Producto {t.Nombre}"; + } + + public string Modificar(ProductoPercedero t) + { + if (t == null) return "El Producto es nulo fallo la carga"; + + Percedero.Mod(t); + return (Percedero.Guardar()) ? + $"El Producto {t.Nombre} se Modifico correctamente" : + $"Fallo la Modificacion del Producto {t.Nombre}"; + } } } diff --git a/Controladora/ControladoraProductos.cs b/Controladora/ControladoraProductos.cs index a6a2883..839e453 100644 --- a/Controladora/ControladoraProductos.cs +++ b/Controladora/ControladoraProductos.cs @@ -18,7 +18,7 @@ namespace Controladora { Producto productoalistar = new RepositorioProductos(new Context()).Listar().First(x => x.Id == producto.Id); if (productoalistar == null) return new ReadOnlyCollection(new List()); - return productoalistar.ListarProveedores(); + return productoalistar.proveedores.AsReadOnly(); } diff --git a/Entidades/Categoria.cs b/Entidades/Categoria.cs index 8a6bd26..ef6f258 100644 --- a/Entidades/Categoria.cs +++ b/Entidades/Categoria.cs @@ -1,9 +1,12 @@  +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + namespace Entidades { public class Categoria { - public int Id { get; set; } + public Int32 Id { get; set; } public string Descripcion { get; set; } } } diff --git a/Entidades/Detalle.cs b/Entidades/Detalle.cs index 640d6b4..cafef6f 100644 --- a/Entidades/Detalle.cs +++ b/Entidades/Detalle.cs @@ -9,7 +9,7 @@ namespace Entidades public int Cantidad { get; set; } public T Producto { get; set; } - public int IdProducto { get; set; } + } } \ No newline at end of file diff --git a/Entidades/DetalleOrdenDeCompra.cs b/Entidades/DetalleOrdenDeCompra.cs index a9dc9e7..2320f04 100644 --- a/Entidades/DetalleOrdenDeCompra.cs +++ b/Entidades/DetalleOrdenDeCompra.cs @@ -8,7 +8,6 @@ namespace Entidades public int IdOrdenDeCompra { get; set; } public double MontoCU { get; set; } public int IdPresupuesto { get; set; } - public Presupuesto presupuesto { get; set; } [NotMapped] public string NombreProducto diff --git a/Entidades/Factura.cs b/Entidades/Factura.cs index c19b8ea..edb2789 100644 --- a/Entidades/Factura.cs +++ b/Entidades/Factura.cs @@ -11,7 +11,8 @@ namespace Entidades public long IdCliente { get; set; } public Cliente Cliente { get; set; } - public List detalles = new List(); + private List detalles = new List(); + public ReadOnlyCollection Detalles => detalles.AsReadOnly(); public void AñadirDetalle(DetalleFactura detalle) diff --git a/Entidades/OrdenDeCompra.cs b/Entidades/OrdenDeCompra.cs index 35c1763..0748ff7 100644 --- a/Entidades/OrdenDeCompra.cs +++ b/Entidades/OrdenDeCompra.cs @@ -11,8 +11,8 @@ namespace Entidades public long IdProveedor { get; set; } public bool Entregado { get; set; } - public List detalles = new List(); - + private List detalles = new List(); + public ReadOnlyCollection Detalles => detalles.AsReadOnly(); public void AñadirDetalle(DetalleOrdenDeCompra detalle) { detalles.Add(detalle); diff --git a/Entidades/Presupuesto.cs b/Entidades/Presupuesto.cs index 5772576..8e05391 100644 --- a/Entidades/Presupuesto.cs +++ b/Entidades/Presupuesto.cs @@ -22,7 +22,7 @@ } public List detalles = new List(); - + public void AñadirDetalle(DetallePresupuesto det) { detalles.Add(det); } diff --git a/Entidades/Producto.cs b/Entidades/Producto.cs index 047186a..174bb31 100644 --- a/Entidades/Producto.cs +++ b/Entidades/Producto.cs @@ -12,7 +12,7 @@ namespace Entidades public bool Habilitado { get; set; } public bool EsPerecedero { get; set; } - private List proveedores = new List(); + public List proveedores = new List(); public void AñadirProveedor(Proveedor proveedor) { @@ -25,10 +25,6 @@ namespace Entidades if (pAEliminar == null) return false; return proveedores.Remove(pAEliminar); } - public ReadOnlyCollection ListarProveedores() - { - return proveedores.AsReadOnly(); - } public List categorias = new List(); @@ -42,8 +38,5 @@ namespace Entidades return categorias.Remove(cAEliminar); } - public ReadOnlyCollection MostrarCategorias(){ - return categorias.AsReadOnly(); - } } } diff --git a/Entidades/Remito.cs b/Entidades/Remito.cs index 2f008b5..9b799d6 100644 --- a/Entidades/Remito.cs +++ b/Entidades/Remito.cs @@ -6,10 +6,12 @@ public class Remito { public int Id { get; set; } - public List lotesDeProductosEntregados = new List(); + public Proveedor Proveedor { get; set; } public int IdProveedor { get; set; } + private List lotesDeProductosEntregados = new List(); + public ReadOnlyCollection Lotes => lotesDeProductosEntregados.AsReadOnly(); public ReadOnlyCollection MostrarLotes() { return lotesDeProductosEntregados.AsReadOnly(); diff --git a/Informes/bin/Debug/net8.0/Entidades.dll b/Informes/bin/Debug/net8.0/Entidades.dll index 8bb7047..66a1039 100644 Binary files a/Informes/bin/Debug/net8.0/Entidades.dll and b/Informes/bin/Debug/net8.0/Entidades.dll differ diff --git a/Informes/bin/Debug/net8.0/Entidades.pdb b/Informes/bin/Debug/net8.0/Entidades.pdb index 209e410..b28042f 100644 Binary files a/Informes/bin/Debug/net8.0/Entidades.pdb and b/Informes/bin/Debug/net8.0/Entidades.pdb differ diff --git a/Informes/bin/Debug/net8.0/Informes.dll b/Informes/bin/Debug/net8.0/Informes.dll index 6b10698..284ba5e 100644 Binary files a/Informes/bin/Debug/net8.0/Informes.dll and b/Informes/bin/Debug/net8.0/Informes.dll differ diff --git a/Informes/bin/Debug/net8.0/Informes.pdb b/Informes/bin/Debug/net8.0/Informes.pdb index a2b3615..57f102f 100644 Binary files a/Informes/bin/Debug/net8.0/Informes.pdb and b/Informes/bin/Debug/net8.0/Informes.pdb differ diff --git a/Informes/obj/Debug/net8.0/Informes.AssemblyInfo.cs b/Informes/obj/Debug/net8.0/Informes.AssemblyInfo.cs index 913a37e..61b0ed6 100644 --- a/Informes/obj/Debug/net8.0/Informes.AssemblyInfo.cs +++ b/Informes/obj/Debug/net8.0/Informes.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("Informes")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+566bfe57c004ac77e4c9433bbd20ee10a1a09a57")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+670190c44b669009d2d84e1f849117de0d18586f")] [assembly: System.Reflection.AssemblyProductAttribute("Informes")] [assembly: System.Reflection.AssemblyTitleAttribute("Informes")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/Informes/obj/Debug/net8.0/Informes.AssemblyInfoInputs.cache b/Informes/obj/Debug/net8.0/Informes.AssemblyInfoInputs.cache index cd271ae..6dec131 100644 --- a/Informes/obj/Debug/net8.0/Informes.AssemblyInfoInputs.cache +++ b/Informes/obj/Debug/net8.0/Informes.AssemblyInfoInputs.cache @@ -1 +1 @@ -ae00625e110761358d22d1280d507fcadf870bc5f0bd5603a24f1f10ad9015b0 +3686af964ab837044e10a22154c7a4ac73f28162a711d7a0fa37d00d14ff75af diff --git a/Informes/obj/Debug/net8.0/Informes.csproj.AssemblyReference.cache b/Informes/obj/Debug/net8.0/Informes.csproj.AssemblyReference.cache index 20024e7..6393416 100644 Binary files a/Informes/obj/Debug/net8.0/Informes.csproj.AssemblyReference.cache and b/Informes/obj/Debug/net8.0/Informes.csproj.AssemblyReference.cache differ diff --git a/Informes/obj/Debug/net8.0/Informes.dll b/Informes/obj/Debug/net8.0/Informes.dll index 6b10698..284ba5e 100644 Binary files a/Informes/obj/Debug/net8.0/Informes.dll and b/Informes/obj/Debug/net8.0/Informes.dll differ diff --git a/Informes/obj/Debug/net8.0/Informes.pdb b/Informes/obj/Debug/net8.0/Informes.pdb index a2b3615..57f102f 100644 Binary files a/Informes/obj/Debug/net8.0/Informes.pdb and b/Informes/obj/Debug/net8.0/Informes.pdb differ diff --git a/Informes/obj/Debug/net8.0/ref/Informes.dll b/Informes/obj/Debug/net8.0/ref/Informes.dll index ca549f8..cf8b199 100644 Binary files a/Informes/obj/Debug/net8.0/ref/Informes.dll and b/Informes/obj/Debug/net8.0/ref/Informes.dll differ diff --git a/Informes/obj/Debug/net8.0/refint/Informes.dll b/Informes/obj/Debug/net8.0/refint/Informes.dll index ca549f8..cf8b199 100644 Binary files a/Informes/obj/Debug/net8.0/refint/Informes.dll and b/Informes/obj/Debug/net8.0/refint/Informes.dll differ diff --git a/Modelo/Context.cs b/Modelo/Context.cs index 791c9a5..1b7aad6 100644 --- a/Modelo/Context.cs +++ b/Modelo/Context.cs @@ -32,60 +32,168 @@ public class Context : Microsoft.EntityFrameworkCore.DbContext modelBuilder.Entity() .ToTable("Categoria") .HasKey(x => x.Id); + modelBuilder.Entity() - .Property(c=>c.Descripcion) + .Property(c => c.Descripcion) .IsRequired() - .HasMaxLength(100); + .HasMaxLength(50); /// Cliente modelBuilder.Entity() .ToTable("Clientes") // Nombre de la tabla .HasKey(c => c.Cuit); // Configura la clave primaria + + modelBuilder.Entity() + .Property(x => x.Cuit) + .ValueGeneratedNever(); + modelBuilder.Entity() .Property(c => c.Nombre) .IsRequired() - .HasMaxLength(100); + .HasMaxLength(30); modelBuilder.Entity() .Property(c => c.Apellido) .IsRequired() - .HasMaxLength(100); + .HasMaxLength(30); modelBuilder.Entity() .Property(c => c.Direccion) - .HasMaxLength(200); + .IsRequired() + .HasMaxLength(50); modelBuilder.Entity() .Property(c => c.Correo) + .IsRequired() .HasMaxLength(150); - + modelBuilder.Entity() .Property(c => c.Habilitado) + .IsRequired() .HasDefaultValue(true); - - /// Factura Y DetalleFactura WIP + + /// Factura Y DetalleFactura modelBuilder.Entity() .ToTable("Facturas") .HasKey(f => f.Id); - + modelBuilder.Entity() - .HasMany(f => f.detalles) + .HasMany(f => f.Detalles) .WithOne() .HasForeignKey(df => df.IdFactura); - + modelBuilder.Entity() .ToTable("DetallesFacturas") - .HasKey(df => df.Id); - + .HasKey(df => new { df.Id, df.IdFactura }); + + modelBuilder.Entity() .Property(df => df.IdFactura) .IsRequired(); + + + //Producto + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id); + + entity.Property(e => e.Nombre) + .IsRequired() + .HasMaxLength(30); + + entity.Property(e => e.Precio) + .HasColumnType("float"); + + entity.Property(e => e.Habilitado) + .IsRequired() + .HasDefaultValue(true); + + entity.Property(e => e.EsPerecedero) + .IsRequired(); + + entity.HasMany(e => e.proveedores) + .WithMany() + .UsingEntity>( + "ProductoProveedor", + j => j.HasOne().WithMany().HasForeignKey("ProveedorId"), + j => j.HasOne().WithMany().HasForeignKey("ProductoId"), + j => j.HasKey("ProveedorId", "ProductoId")); + + + entity.HasMany(e => e.categorias) + .WithMany() + .UsingEntity>( + "ProductoCategoria", + j => j.HasOne().WithMany().HasForeignKey("CategoriaId"), + j => j.HasOne().WithMany().HasForeignKey("ProductoId"), + j => j.HasKey("CategoriaId", "ProductoId")); + }); + + // Mapeo para ProductoNoPercedero + modelBuilder.Entity(entity => + { + entity.Property(e => e.TipoDeEnvase) + .HasConversion(); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(x => x.Cuit); + + entity.Property(x => x.Cuit).ValueGeneratedNever(); + + entity.Property(x => x.Nombre) + .IsRequired() + .HasMaxLength(30); + + entity.Property(x => x.Habilitado) + .IsRequired() + .HasDefaultValue(true); + + entity.Property(x => x.RazonSocial) + .IsRequired() + .HasMaxLength(60); + + entity.Property(x => x.Direccion) + .IsRequired() + .HasMaxLength(60); + }); + + modelBuilder.Entity() + .HasKey(df => new { df.Id, df.IdOrdenDeCompra }); + + modelBuilder.Entity() + .HasKey(x => x.Id); + + modelBuilder.Entity() + .HasMany(x => x.Detalles) + .WithOne() + .HasForeignKey(x => x.IdOrdenDeCompra); + + modelBuilder.Entity() + .HasKey(df => new { df.Id, df.IdPresupuesto }); + + modelBuilder.Entity() + .HasKey(x => x.Id); + + modelBuilder.Entity() + .HasMany(x => x.detalles) + .WithOne() + .HasForeignKey(x => x.IdPresupuesto); + + modelBuilder.Entity() + .HasKey(df => new { df.Id, df.IdRemito }); + + modelBuilder.Entity() + .HasKey(x => x.Id); + + modelBuilder.Entity() + .HasMany(x => x.Lotes) + .WithOne() + .HasForeignKey(x => x.IdRemito); + - modelBuilder.Entity() - .HasOne(df => df.Producto) - .WithMany() - .HasForeignKey(df => df.Producto.Id); } } diff --git a/Modelo/Migrations/20240826212726_nuevasrelaciones.Designer.cs b/Modelo/Migrations/20240826212726_nuevasrelaciones.Designer.cs new file mode 100644 index 0000000..b55a205 --- /dev/null +++ b/Modelo/Migrations/20240826212726_nuevasrelaciones.Designer.cs @@ -0,0 +1,591 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Modelo; + +#nullable disable + +namespace Modelo.Migrations +{ + [DbContext(typeof(Context))] + [Migration("20240826212726_nuevasrelaciones")] + partial class nuevasrelaciones + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Entidades.Categoria", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Descripcion") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Categoria", (string)null); + }); + + modelBuilder.Entity("Entidades.Cliente", b => + { + b.Property("Cuit") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Cuit")); + + b.Property("Apellido") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Correo") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Direccion") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Cuit"); + + b.ToTable("Clientes", (string)null); + }); + + modelBuilder.Entity("Entidades.DetalleFactura", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdFactura") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.HasKey("Id", "IdFactura"); + + b.HasIndex("IdFactura"); + + b.HasIndex("IdProducto"); + + b.ToTable("DetallesFacturas", (string)null); + }); + + modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdOrdenDeCompra") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("IdPresupuesto") + .HasColumnType("int"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.Property("MontoCU") + .HasColumnType("float"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("Id", "IdOrdenDeCompra"); + + b.HasIndex("IdOrdenDeCompra"); + + b.HasIndex("ProductoId"); + + b.ToTable("DetalleOrdenDeCompras"); + }); + + modelBuilder.Entity("Entidades.DetallePresupuesto", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdPresupuesto") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.Property("MontoCUPropuesto") + .HasColumnType("float"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("Id", "IdPresupuesto"); + + b.HasIndex("IdPresupuesto"); + + b.HasIndex("ProductoId"); + + b.ToTable("DetallePresupuestos"); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClienteCuit") + .HasColumnType("bigint"); + + b.Property("Fecha") + .HasColumnType("datetime2"); + + b.Property("IdCliente") + .HasColumnType("bigint"); + + b.Property("Total") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClienteCuit"); + + b.ToTable("Facturas", (string)null); + }); + + modelBuilder.Entity("Entidades.Lote", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdRemito") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("Fecha") + .HasColumnType("datetime2"); + + b.Property("Habilitado") + .HasColumnType("bit"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("Id", "IdRemito"); + + b.HasIndex("IdRemito"); + + b.HasIndex("ProductoId"); + + b.ToTable("Lotes"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Entregado") + .HasColumnType("bit"); + + b.Property("IdProveedor") + .HasColumnType("bigint"); + + b.Property("ProveedorCuit") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("OrdenDeCompras"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Aceptado") + .HasColumnType("bit"); + + b.Property("Fecha") + .HasColumnType("datetime2"); + + b.Property("Habilitado") + .HasColumnType("bit"); + + b.Property("IdProveedor") + .HasColumnType("bigint"); + + b.Property("ProveedorCuit") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("Presupuestos"); + }); + + modelBuilder.Entity("Entidades.Producto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("nvarchar(21)"); + + b.Property("EsPerecedero") + .HasColumnType("bit"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Precio") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Producto"); + + b.HasDiscriminator().HasValue("Producto"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Entidades.Proveedor", b => + { + b.Property("Cuit") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Cuit")); + + b.Property("Direccion") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("RazonSocial") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.HasKey("Cuit"); + + b.ToTable("Proveedores"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IdProveedor") + .HasColumnType("int"); + + b.Property("ProveedorCuit") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("Remitos"); + }); + + modelBuilder.Entity("ProductoCategoria", b => + { + b.Property("CategoriaId") + .HasColumnType("int"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("CategoriaId", "ProductoId"); + + b.HasIndex("ProductoId"); + + b.ToTable("ProductoCategoria"); + }); + + modelBuilder.Entity("ProductoProveedor", b => + { + b.Property("ProductoId") + .HasColumnType("int"); + + b.Property("ProveedorId") + .HasColumnType("bigint"); + + b.HasKey("ProductoId", "ProveedorId"); + + b.HasIndex("ProveedorId"); + + b.ToTable("ProductoProveedor"); + }); + + modelBuilder.Entity("Entidades.ProductoNoPercedero", b => + { + b.HasBaseType("Entidades.Producto"); + + b.Property("TipoDeEnvase") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasDiscriminator().HasValue("ProductoNoPercedero"); + }); + + modelBuilder.Entity("Entidades.ProductoPercedero", b => + { + b.HasBaseType("Entidades.Producto"); + + b.Property("MesesHastaConsumoPreferente") + .HasColumnType("int"); + + b.Property("MesesHastaVencimiento") + .HasColumnType("int"); + + b.HasDiscriminator().HasValue("ProductoPercedero"); + }); + + modelBuilder.Entity("Entidades.DetalleFactura", b => + { + b.HasOne("Entidades.Factura", null) + .WithMany("Detalles") + .HasForeignKey("IdFactura") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("IdProducto") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b => + { + b.HasOne("Entidades.OrdenDeCompra", null) + .WithMany("Detalles") + .HasForeignKey("IdOrdenDeCompra") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.DetallePresupuesto", b => + { + b.HasOne("Entidades.Presupuesto", null) + .WithMany("Detalles") + .HasForeignKey("IdPresupuesto") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.HasOne("Entidades.Cliente", "Cliente") + .WithMany() + .HasForeignKey("ClienteCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cliente"); + }); + + modelBuilder.Entity("Entidades.Lote", b => + { + b.HasOne("Entidades.Remito", null) + .WithMany("Lotes") + .HasForeignKey("IdRemito") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("ProductoCategoria", b => + { + b.HasOne("Entidades.Categoria", null) + .WithMany() + .HasForeignKey("CategoriaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", null) + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ProductoProveedor", b => + { + b.HasOne("Entidades.Producto", null) + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Proveedor", null) + .WithMany() + .HasForeignKey("ProveedorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.Navigation("Detalles"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.Navigation("Detalles"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.Navigation("Detalles"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.Navigation("Lotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modelo/Migrations/20240826212726_nuevasrelaciones.cs b/Modelo/Migrations/20240826212726_nuevasrelaciones.cs new file mode 100644 index 0000000..aeb35cd --- /dev/null +++ b/Modelo/Migrations/20240826212726_nuevasrelaciones.cs @@ -0,0 +1,443 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Modelo.Migrations +{ + /// + public partial class nuevasrelaciones : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Categoria", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Descripcion = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Categoria", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Clientes", + columns: table => new + { + Cuit = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Nombre = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false), + Apellido = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false), + Direccion = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Correo = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false), + Habilitado = table.Column(type: "bit", nullable: false, defaultValue: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Clientes", x => x.Cuit); + }); + + migrationBuilder.CreateTable( + name: "Producto", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Nombre = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false), + Precio = table.Column(type: "float", nullable: false), + Habilitado = table.Column(type: "bit", nullable: false, defaultValue: true), + EsPerecedero = table.Column(type: "bit", nullable: false), + Discriminator = table.Column(type: "nvarchar(21)", maxLength: 21, nullable: false), + TipoDeEnvase = table.Column(type: "nvarchar(max)", nullable: true), + MesesHastaConsumoPreferente = table.Column(type: "int", nullable: true), + MesesHastaVencimiento = table.Column(type: "int", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Producto", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Proveedores", + columns: table => new + { + Cuit = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Nombre = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false), + RazonSocial = table.Column(type: "nvarchar(60)", maxLength: 60, nullable: false), + Direccion = table.Column(type: "nvarchar(60)", maxLength: 60, nullable: false), + Habilitado = table.Column(type: "bit", nullable: false, defaultValue: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Proveedores", x => x.Cuit); + }); + + migrationBuilder.CreateTable( + name: "Facturas", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Total = table.Column(type: "float", nullable: false), + Fecha = table.Column(type: "datetime2", nullable: false), + IdCliente = table.Column(type: "bigint", nullable: false), + ClienteCuit = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Facturas", x => x.Id); + table.ForeignKey( + name: "FK_Facturas_Clientes_ClienteCuit", + column: x => x.ClienteCuit, + principalTable: "Clientes", + principalColumn: "Cuit", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ProductoCategoria", + columns: table => new + { + CategoriaId = table.Column(type: "int", nullable: false), + ProductoId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductoCategoria", x => new { x.CategoriaId, x.ProductoId }); + table.ForeignKey( + name: "FK_ProductoCategoria_Categoria_CategoriaId", + column: x => x.CategoriaId, + principalTable: "Categoria", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ProductoCategoria_Producto_ProductoId", + column: x => x.ProductoId, + principalTable: "Producto", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "OrdenDeCompras", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProveedorCuit = table.Column(type: "bigint", nullable: false), + IdProveedor = table.Column(type: "bigint", nullable: false), + Entregado = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_OrdenDeCompras", x => x.Id); + table.ForeignKey( + name: "FK_OrdenDeCompras_Proveedores_ProveedorCuit", + column: x => x.ProveedorCuit, + principalTable: "Proveedores", + principalColumn: "Cuit", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Presupuestos", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Fecha = table.Column(type: "datetime2", nullable: false), + Habilitado = table.Column(type: "bit", nullable: false), + Aceptado = table.Column(type: "bit", nullable: false), + ProveedorCuit = table.Column(type: "bigint", nullable: false), + IdProveedor = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Presupuestos", x => x.Id); + table.ForeignKey( + name: "FK_Presupuestos_Proveedores_ProveedorCuit", + column: x => x.ProveedorCuit, + principalTable: "Proveedores", + principalColumn: "Cuit", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ProductoProveedor", + columns: table => new + { + ProductoId = table.Column(type: "int", nullable: false), + ProveedorId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductoProveedor", x => new { x.ProductoId, x.ProveedorId }); + table.ForeignKey( + name: "FK_ProductoProveedor_Producto_ProductoId", + column: x => x.ProductoId, + principalTable: "Producto", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ProductoProveedor_Proveedores_ProveedorId", + column: x => x.ProveedorId, + principalTable: "Proveedores", + principalColumn: "Cuit", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Remitos", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProveedorCuit = table.Column(type: "bigint", nullable: false), + IdProveedor = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Remitos", x => x.Id); + table.ForeignKey( + name: "FK_Remitos_Proveedores_ProveedorCuit", + column: x => x.ProveedorCuit, + principalTable: "Proveedores", + principalColumn: "Cuit", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "DetallesFacturas", + columns: table => new + { + Id = table.Column(type: "int", nullable: false), + IdFactura = table.Column(type: "int", nullable: false), + Cantidad = table.Column(type: "int", nullable: false), + IdProducto = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DetallesFacturas", x => new { x.Id, x.IdFactura }); + table.ForeignKey( + name: "FK_DetallesFacturas_Facturas_IdFactura", + column: x => x.IdFactura, + principalTable: "Facturas", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_DetallesFacturas_Producto_IdProducto", + column: x => x.IdProducto, + principalTable: "Producto", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "DetalleOrdenDeCompras", + columns: table => new + { + Id = table.Column(type: "int", nullable: false), + IdOrdenDeCompra = table.Column(type: "int", nullable: false), + MontoCU = table.Column(type: "float", nullable: false), + IdPresupuesto = table.Column(type: "int", nullable: false), + Cantidad = table.Column(type: "int", nullable: false), + ProductoId = table.Column(type: "int", nullable: false), + IdProducto = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DetalleOrdenDeCompras", x => new { x.Id, x.IdOrdenDeCompra }); + table.ForeignKey( + name: "FK_DetalleOrdenDeCompras_OrdenDeCompras_IdOrdenDeCompra", + column: x => x.IdOrdenDeCompra, + principalTable: "OrdenDeCompras", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_DetalleOrdenDeCompras_Producto_ProductoId", + column: x => x.ProductoId, + principalTable: "Producto", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "DetallePresupuestos", + columns: table => new + { + Id = table.Column(type: "int", nullable: false), + IdPresupuesto = table.Column(type: "int", nullable: false), + MontoCUPropuesto = table.Column(type: "float", nullable: false), + Cantidad = table.Column(type: "int", nullable: false), + ProductoId = table.Column(type: "int", nullable: false), + IdProducto = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DetallePresupuestos", x => new { x.Id, x.IdPresupuesto }); + table.ForeignKey( + name: "FK_DetallePresupuestos_Presupuestos_IdPresupuesto", + column: x => x.IdPresupuesto, + principalTable: "Presupuestos", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_DetallePresupuestos_Producto_ProductoId", + column: x => x.ProductoId, + principalTable: "Producto", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Lotes", + columns: table => new + { + Id = table.Column(type: "int", nullable: false), + IdRemito = table.Column(type: "int", nullable: false), + Fecha = table.Column(type: "datetime2", nullable: false), + Habilitado = table.Column(type: "bit", nullable: false), + Cantidad = table.Column(type: "int", nullable: false), + ProductoId = table.Column(type: "int", nullable: false), + IdProducto = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Lotes", x => new { x.Id, x.IdRemito }); + table.ForeignKey( + name: "FK_Lotes_Producto_ProductoId", + column: x => x.ProductoId, + principalTable: "Producto", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Lotes_Remitos_IdRemito", + column: x => x.IdRemito, + principalTable: "Remitos", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_DetalleOrdenDeCompras_IdOrdenDeCompra", + table: "DetalleOrdenDeCompras", + column: "IdOrdenDeCompra"); + + migrationBuilder.CreateIndex( + name: "IX_DetalleOrdenDeCompras_ProductoId", + table: "DetalleOrdenDeCompras", + column: "ProductoId"); + + migrationBuilder.CreateIndex( + name: "IX_DetallePresupuestos_IdPresupuesto", + table: "DetallePresupuestos", + column: "IdPresupuesto"); + + migrationBuilder.CreateIndex( + name: "IX_DetallePresupuestos_ProductoId", + table: "DetallePresupuestos", + column: "ProductoId"); + + migrationBuilder.CreateIndex( + name: "IX_DetallesFacturas_IdFactura", + table: "DetallesFacturas", + column: "IdFactura"); + + migrationBuilder.CreateIndex( + name: "IX_DetallesFacturas_IdProducto", + table: "DetallesFacturas", + column: "IdProducto"); + + migrationBuilder.CreateIndex( + name: "IX_Facturas_ClienteCuit", + table: "Facturas", + column: "ClienteCuit"); + + migrationBuilder.CreateIndex( + name: "IX_Lotes_IdRemito", + table: "Lotes", + column: "IdRemito"); + + migrationBuilder.CreateIndex( + name: "IX_Lotes_ProductoId", + table: "Lotes", + column: "ProductoId"); + + migrationBuilder.CreateIndex( + name: "IX_OrdenDeCompras_ProveedorCuit", + table: "OrdenDeCompras", + column: "ProveedorCuit"); + + migrationBuilder.CreateIndex( + name: "IX_Presupuestos_ProveedorCuit", + table: "Presupuestos", + column: "ProveedorCuit"); + + migrationBuilder.CreateIndex( + name: "IX_ProductoCategoria_ProductoId", + table: "ProductoCategoria", + column: "ProductoId"); + + migrationBuilder.CreateIndex( + name: "IX_ProductoProveedor_ProveedorId", + table: "ProductoProveedor", + column: "ProveedorId"); + + migrationBuilder.CreateIndex( + name: "IX_Remitos_ProveedorCuit", + table: "Remitos", + column: "ProveedorCuit"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "DetalleOrdenDeCompras"); + + migrationBuilder.DropTable( + name: "DetallePresupuestos"); + + migrationBuilder.DropTable( + name: "DetallesFacturas"); + + migrationBuilder.DropTable( + name: "Lotes"); + + migrationBuilder.DropTable( + name: "ProductoCategoria"); + + migrationBuilder.DropTable( + name: "ProductoProveedor"); + + migrationBuilder.DropTable( + name: "OrdenDeCompras"); + + migrationBuilder.DropTable( + name: "Presupuestos"); + + migrationBuilder.DropTable( + name: "Facturas"); + + migrationBuilder.DropTable( + name: "Remitos"); + + migrationBuilder.DropTable( + name: "Categoria"); + + migrationBuilder.DropTable( + name: "Producto"); + + migrationBuilder.DropTable( + name: "Clientes"); + + migrationBuilder.DropTable( + name: "Proveedores"); + } + } +} diff --git a/Modelo/Migrations/20240826213353_fixrelacionproductocategoria.Designer.cs b/Modelo/Migrations/20240826213353_fixrelacionproductocategoria.Designer.cs new file mode 100644 index 0000000..0373f40 --- /dev/null +++ b/Modelo/Migrations/20240826213353_fixrelacionproductocategoria.Designer.cs @@ -0,0 +1,591 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Modelo; + +#nullable disable + +namespace Modelo.Migrations +{ + [DbContext(typeof(Context))] + [Migration("20240826213353_fixrelacionproductocategoria")] + partial class fixrelacionproductocategoria + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Entidades.Categoria", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Descripcion") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Categoria", (string)null); + }); + + modelBuilder.Entity("Entidades.Cliente", b => + { + b.Property("Cuit") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Cuit")); + + b.Property("Apellido") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Correo") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Direccion") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Cuit"); + + b.ToTable("Clientes", (string)null); + }); + + modelBuilder.Entity("Entidades.DetalleFactura", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdFactura") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.HasKey("Id", "IdFactura"); + + b.HasIndex("IdFactura"); + + b.HasIndex("IdProducto"); + + b.ToTable("DetallesFacturas", (string)null); + }); + + modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdOrdenDeCompra") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("IdPresupuesto") + .HasColumnType("int"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.Property("MontoCU") + .HasColumnType("float"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("Id", "IdOrdenDeCompra"); + + b.HasIndex("IdOrdenDeCompra"); + + b.HasIndex("ProductoId"); + + b.ToTable("DetalleOrdenDeCompras"); + }); + + modelBuilder.Entity("Entidades.DetallePresupuesto", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdPresupuesto") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.Property("MontoCUPropuesto") + .HasColumnType("float"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("Id", "IdPresupuesto"); + + b.HasIndex("IdPresupuesto"); + + b.HasIndex("ProductoId"); + + b.ToTable("DetallePresupuestos"); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClienteCuit") + .HasColumnType("bigint"); + + b.Property("Fecha") + .HasColumnType("datetime2"); + + b.Property("IdCliente") + .HasColumnType("bigint"); + + b.Property("Total") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClienteCuit"); + + b.ToTable("Facturas", (string)null); + }); + + modelBuilder.Entity("Entidades.Lote", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdRemito") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("Fecha") + .HasColumnType("datetime2"); + + b.Property("Habilitado") + .HasColumnType("bit"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("Id", "IdRemito"); + + b.HasIndex("IdRemito"); + + b.HasIndex("ProductoId"); + + b.ToTable("Lotes"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Entregado") + .HasColumnType("bit"); + + b.Property("IdProveedor") + .HasColumnType("bigint"); + + b.Property("ProveedorCuit") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("OrdenDeCompras"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Aceptado") + .HasColumnType("bit"); + + b.Property("Fecha") + .HasColumnType("datetime2"); + + b.Property("Habilitado") + .HasColumnType("bit"); + + b.Property("IdProveedor") + .HasColumnType("bigint"); + + b.Property("ProveedorCuit") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("Presupuestos"); + }); + + modelBuilder.Entity("Entidades.Producto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("nvarchar(21)"); + + b.Property("EsPerecedero") + .HasColumnType("bit"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Precio") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Producto"); + + b.HasDiscriminator().HasValue("Producto"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Entidades.Proveedor", b => + { + b.Property("Cuit") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Cuit")); + + b.Property("Direccion") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("RazonSocial") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.HasKey("Cuit"); + + b.ToTable("Proveedores"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IdProveedor") + .HasColumnType("int"); + + b.Property("ProveedorCuit") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("Remitos"); + }); + + modelBuilder.Entity("ProductoCategoria", b => + { + b.Property("CategoriaId") + .HasColumnType("int"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("CategoriaId", "ProductoId"); + + b.HasIndex("ProductoId"); + + b.ToTable("ProductoCategoria"); + }); + + modelBuilder.Entity("ProductoProveedor", b => + { + b.Property("ProductoId") + .HasColumnType("int"); + + b.Property("ProveedorId") + .HasColumnType("bigint"); + + b.HasKey("ProductoId", "ProveedorId"); + + b.HasIndex("ProveedorId"); + + b.ToTable("ProductoProveedor"); + }); + + modelBuilder.Entity("Entidades.ProductoNoPercedero", b => + { + b.HasBaseType("Entidades.Producto"); + + b.Property("TipoDeEnvase") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasDiscriminator().HasValue("ProductoNoPercedero"); + }); + + modelBuilder.Entity("Entidades.ProductoPercedero", b => + { + b.HasBaseType("Entidades.Producto"); + + b.Property("MesesHastaConsumoPreferente") + .HasColumnType("int"); + + b.Property("MesesHastaVencimiento") + .HasColumnType("int"); + + b.HasDiscriminator().HasValue("ProductoPercedero"); + }); + + modelBuilder.Entity("Entidades.DetalleFactura", b => + { + b.HasOne("Entidades.Factura", null) + .WithMany("Detalles") + .HasForeignKey("IdFactura") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("IdProducto") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b => + { + b.HasOne("Entidades.OrdenDeCompra", null) + .WithMany("Detalles") + .HasForeignKey("IdOrdenDeCompra") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.DetallePresupuesto", b => + { + b.HasOne("Entidades.Presupuesto", null) + .WithMany("Detalles") + .HasForeignKey("IdPresupuesto") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.HasOne("Entidades.Cliente", "Cliente") + .WithMany() + .HasForeignKey("ClienteCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cliente"); + }); + + modelBuilder.Entity("Entidades.Lote", b => + { + b.HasOne("Entidades.Remito", null) + .WithMany("Lotes") + .HasForeignKey("IdRemito") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("ProductoCategoria", b => + { + b.HasOne("Entidades.Categoria", null) + .WithMany() + .HasForeignKey("CategoriaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", null) + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ProductoProveedor", b => + { + b.HasOne("Entidades.Producto", null) + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Proveedor", null) + .WithMany() + .HasForeignKey("ProveedorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.Navigation("Detalles"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.Navigation("Detalles"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.Navigation("Detalles"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.Navigation("Lotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modelo/Migrations/20240826213353_fixrelacionproductocategoria.cs b/Modelo/Migrations/20240826213353_fixrelacionproductocategoria.cs new file mode 100644 index 0000000..f4b64de --- /dev/null +++ b/Modelo/Migrations/20240826213353_fixrelacionproductocategoria.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Modelo.Migrations +{ + /// + public partial class fixrelacionproductocategoria : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/Modelo/Migrations/20240826222040_cambiadapkcompuesta.Designer.cs b/Modelo/Migrations/20240826222040_cambiadapkcompuesta.Designer.cs new file mode 100644 index 0000000..5843692 --- /dev/null +++ b/Modelo/Migrations/20240826222040_cambiadapkcompuesta.Designer.cs @@ -0,0 +1,591 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Modelo; + +#nullable disable + +namespace Modelo.Migrations +{ + [DbContext(typeof(Context))] + [Migration("20240826222040_cambiadapkcompuesta")] + partial class cambiadapkcompuesta + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Entidades.Categoria", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Descripcion") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Categoria", (string)null); + }); + + modelBuilder.Entity("Entidades.Cliente", b => + { + b.Property("Cuit") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Cuit")); + + b.Property("Apellido") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Correo") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Direccion") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Cuit"); + + b.ToTable("Clientes", (string)null); + }); + + modelBuilder.Entity("Entidades.DetalleFactura", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdFactura") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.HasKey("Id", "IdFactura"); + + b.HasIndex("IdFactura"); + + b.HasIndex("IdProducto"); + + b.ToTable("DetallesFacturas", (string)null); + }); + + modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdOrdenDeCompra") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("IdPresupuesto") + .HasColumnType("int"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.Property("MontoCU") + .HasColumnType("float"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("Id", "IdOrdenDeCompra"); + + b.HasIndex("IdOrdenDeCompra"); + + b.HasIndex("ProductoId"); + + b.ToTable("DetalleOrdenDeCompras"); + }); + + modelBuilder.Entity("Entidades.DetallePresupuesto", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdPresupuesto") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.Property("MontoCUPropuesto") + .HasColumnType("float"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("Id", "IdPresupuesto"); + + b.HasIndex("IdPresupuesto"); + + b.HasIndex("ProductoId"); + + b.ToTable("DetallePresupuestos"); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClienteCuit") + .HasColumnType("bigint"); + + b.Property("Fecha") + .HasColumnType("datetime2"); + + b.Property("IdCliente") + .HasColumnType("bigint"); + + b.Property("Total") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClienteCuit"); + + b.ToTable("Facturas", (string)null); + }); + + modelBuilder.Entity("Entidades.Lote", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdRemito") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("Fecha") + .HasColumnType("datetime2"); + + b.Property("Habilitado") + .HasColumnType("bit"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("Id", "IdRemito"); + + b.HasIndex("IdRemito"); + + b.HasIndex("ProductoId"); + + b.ToTable("Lotes"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Entregado") + .HasColumnType("bit"); + + b.Property("IdProveedor") + .HasColumnType("bigint"); + + b.Property("ProveedorCuit") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("OrdenDeCompras"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Aceptado") + .HasColumnType("bit"); + + b.Property("Fecha") + .HasColumnType("datetime2"); + + b.Property("Habilitado") + .HasColumnType("bit"); + + b.Property("IdProveedor") + .HasColumnType("bigint"); + + b.Property("ProveedorCuit") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("Presupuestos"); + }); + + modelBuilder.Entity("Entidades.Producto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("nvarchar(21)"); + + b.Property("EsPerecedero") + .HasColumnType("bit"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Precio") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Producto"); + + b.HasDiscriminator().HasValue("Producto"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Entidades.Proveedor", b => + { + b.Property("Cuit") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Cuit")); + + b.Property("Direccion") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("RazonSocial") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.HasKey("Cuit"); + + b.ToTable("Proveedores"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IdProveedor") + .HasColumnType("int"); + + b.Property("ProveedorCuit") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("Remitos"); + }); + + modelBuilder.Entity("ProductoCategoria", b => + { + b.Property("CategoriaId") + .HasColumnType("int"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("CategoriaId", "ProductoId"); + + b.HasIndex("ProductoId"); + + b.ToTable("ProductoCategoria"); + }); + + modelBuilder.Entity("ProductoProveedor", b => + { + b.Property("ProveedorId") + .HasColumnType("bigint"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("ProveedorId", "ProductoId"); + + b.HasIndex("ProductoId"); + + b.ToTable("ProductoProveedor"); + }); + + modelBuilder.Entity("Entidades.ProductoNoPercedero", b => + { + b.HasBaseType("Entidades.Producto"); + + b.Property("TipoDeEnvase") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasDiscriminator().HasValue("ProductoNoPercedero"); + }); + + modelBuilder.Entity("Entidades.ProductoPercedero", b => + { + b.HasBaseType("Entidades.Producto"); + + b.Property("MesesHastaConsumoPreferente") + .HasColumnType("int"); + + b.Property("MesesHastaVencimiento") + .HasColumnType("int"); + + b.HasDiscriminator().HasValue("ProductoPercedero"); + }); + + modelBuilder.Entity("Entidades.DetalleFactura", b => + { + b.HasOne("Entidades.Factura", null) + .WithMany("Detalles") + .HasForeignKey("IdFactura") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("IdProducto") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b => + { + b.HasOne("Entidades.OrdenDeCompra", null) + .WithMany("Detalles") + .HasForeignKey("IdOrdenDeCompra") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.DetallePresupuesto", b => + { + b.HasOne("Entidades.Presupuesto", null) + .WithMany("Detalles") + .HasForeignKey("IdPresupuesto") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.HasOne("Entidades.Cliente", "Cliente") + .WithMany() + .HasForeignKey("ClienteCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cliente"); + }); + + modelBuilder.Entity("Entidades.Lote", b => + { + b.HasOne("Entidades.Remito", null) + .WithMany("Lotes") + .HasForeignKey("IdRemito") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("ProductoCategoria", b => + { + b.HasOne("Entidades.Categoria", null) + .WithMany() + .HasForeignKey("CategoriaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", null) + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ProductoProveedor", b => + { + b.HasOne("Entidades.Producto", null) + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Proveedor", null) + .WithMany() + .HasForeignKey("ProveedorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.Navigation("Detalles"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.Navigation("Detalles"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.Navigation("Detalles"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.Navigation("Lotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modelo/Migrations/20240826222040_cambiadapkcompuesta.cs b/Modelo/Migrations/20240826222040_cambiadapkcompuesta.cs new file mode 100644 index 0000000..fa1dcbe --- /dev/null +++ b/Modelo/Migrations/20240826222040_cambiadapkcompuesta.cs @@ -0,0 +1,54 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Modelo.Migrations +{ + /// + public partial class cambiadapkcompuesta : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_ProductoProveedor", + table: "ProductoProveedor"); + + migrationBuilder.DropIndex( + name: "IX_ProductoProveedor_ProveedorId", + table: "ProductoProveedor"); + + migrationBuilder.AddPrimaryKey( + name: "PK_ProductoProveedor", + table: "ProductoProveedor", + columns: new[] { "ProveedorId", "ProductoId" }); + + migrationBuilder.CreateIndex( + name: "IX_ProductoProveedor_ProductoId", + table: "ProductoProveedor", + column: "ProductoId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_ProductoProveedor", + table: "ProductoProveedor"); + + migrationBuilder.DropIndex( + name: "IX_ProductoProveedor_ProductoId", + table: "ProductoProveedor"); + + migrationBuilder.AddPrimaryKey( + name: "PK_ProductoProveedor", + table: "ProductoProveedor", + columns: new[] { "ProductoId", "ProveedorId" }); + + migrationBuilder.CreateIndex( + name: "IX_ProductoProveedor_ProveedorId", + table: "ProductoProveedor", + column: "ProveedorId"); + } + } +} diff --git a/Modelo/Migrations/20240827025739_CuitNotGenerateValue.Designer.cs b/Modelo/Migrations/20240827025739_CuitNotGenerateValue.Designer.cs new file mode 100644 index 0000000..7e8ffbd --- /dev/null +++ b/Modelo/Migrations/20240827025739_CuitNotGenerateValue.Designer.cs @@ -0,0 +1,585 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Modelo; + +#nullable disable + +namespace Modelo.Migrations +{ + [DbContext(typeof(Context))] + [Migration("20240827025739_CuitNotGenerateValue")] + partial class CuitNotGenerateValue + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Entidades.Categoria", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Descripcion") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Categoria", (string)null); + }); + + modelBuilder.Entity("Entidades.Cliente", b => + { + b.Property("Cuit") + .HasColumnType("bigint"); + + b.Property("Apellido") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Correo") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Direccion") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Cuit"); + + b.ToTable("Clientes", (string)null); + }); + + modelBuilder.Entity("Entidades.DetalleFactura", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdFactura") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.HasKey("Id", "IdFactura"); + + b.HasIndex("IdFactura"); + + b.HasIndex("IdProducto"); + + b.ToTable("DetallesFacturas", (string)null); + }); + + modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdOrdenDeCompra") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("IdPresupuesto") + .HasColumnType("int"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.Property("MontoCU") + .HasColumnType("float"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("Id", "IdOrdenDeCompra"); + + b.HasIndex("IdOrdenDeCompra"); + + b.HasIndex("ProductoId"); + + b.ToTable("DetalleOrdenDeCompras"); + }); + + modelBuilder.Entity("Entidades.DetallePresupuesto", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdPresupuesto") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.Property("MontoCUPropuesto") + .HasColumnType("float"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("Id", "IdPresupuesto"); + + b.HasIndex("IdPresupuesto"); + + b.HasIndex("ProductoId"); + + b.ToTable("DetallePresupuestos"); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClienteCuit") + .HasColumnType("bigint"); + + b.Property("Fecha") + .HasColumnType("datetime2"); + + b.Property("IdCliente") + .HasColumnType("bigint"); + + b.Property("Total") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClienteCuit"); + + b.ToTable("Facturas", (string)null); + }); + + modelBuilder.Entity("Entidades.Lote", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdRemito") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("Fecha") + .HasColumnType("datetime2"); + + b.Property("Habilitado") + .HasColumnType("bit"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("Id", "IdRemito"); + + b.HasIndex("IdRemito"); + + b.HasIndex("ProductoId"); + + b.ToTable("Lotes"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Entregado") + .HasColumnType("bit"); + + b.Property("IdProveedor") + .HasColumnType("bigint"); + + b.Property("ProveedorCuit") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("OrdenDeCompras"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Aceptado") + .HasColumnType("bit"); + + b.Property("Fecha") + .HasColumnType("datetime2"); + + b.Property("Habilitado") + .HasColumnType("bit"); + + b.Property("IdProveedor") + .HasColumnType("bigint"); + + b.Property("ProveedorCuit") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("Presupuestos"); + }); + + modelBuilder.Entity("Entidades.Producto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("nvarchar(21)"); + + b.Property("EsPerecedero") + .HasColumnType("bit"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Precio") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Producto"); + + b.HasDiscriminator().HasValue("Producto"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Entidades.Proveedor", b => + { + b.Property("Cuit") + .HasColumnType("bigint"); + + b.Property("Direccion") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("RazonSocial") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.HasKey("Cuit"); + + b.ToTable("Proveedores"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IdProveedor") + .HasColumnType("int"); + + b.Property("ProveedorCuit") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("Remitos"); + }); + + modelBuilder.Entity("ProductoCategoria", b => + { + b.Property("CategoriaId") + .HasColumnType("int"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("CategoriaId", "ProductoId"); + + b.HasIndex("ProductoId"); + + b.ToTable("ProductoCategoria"); + }); + + modelBuilder.Entity("ProductoProveedor", b => + { + b.Property("ProveedorId") + .HasColumnType("bigint"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("ProveedorId", "ProductoId"); + + b.HasIndex("ProductoId"); + + b.ToTable("ProductoProveedor"); + }); + + modelBuilder.Entity("Entidades.ProductoNoPercedero", b => + { + b.HasBaseType("Entidades.Producto"); + + b.Property("TipoDeEnvase") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasDiscriminator().HasValue("ProductoNoPercedero"); + }); + + modelBuilder.Entity("Entidades.ProductoPercedero", b => + { + b.HasBaseType("Entidades.Producto"); + + b.Property("MesesHastaConsumoPreferente") + .HasColumnType("int"); + + b.Property("MesesHastaVencimiento") + .HasColumnType("int"); + + b.HasDiscriminator().HasValue("ProductoPercedero"); + }); + + modelBuilder.Entity("Entidades.DetalleFactura", b => + { + b.HasOne("Entidades.Factura", null) + .WithMany("Detalles") + .HasForeignKey("IdFactura") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("IdProducto") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b => + { + b.HasOne("Entidades.OrdenDeCompra", null) + .WithMany("Detalles") + .HasForeignKey("IdOrdenDeCompra") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.DetallePresupuesto", b => + { + b.HasOne("Entidades.Presupuesto", null) + .WithMany("detalles") + .HasForeignKey("IdPresupuesto") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.HasOne("Entidades.Cliente", "Cliente") + .WithMany() + .HasForeignKey("ClienteCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cliente"); + }); + + modelBuilder.Entity("Entidades.Lote", b => + { + b.HasOne("Entidades.Remito", null) + .WithMany("Lotes") + .HasForeignKey("IdRemito") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("ProductoCategoria", b => + { + b.HasOne("Entidades.Categoria", null) + .WithMany() + .HasForeignKey("CategoriaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", null) + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ProductoProveedor", b => + { + b.HasOne("Entidades.Producto", null) + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Proveedor", null) + .WithMany() + .HasForeignKey("ProveedorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.Navigation("Detalles"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.Navigation("Detalles"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.Navigation("detalles"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.Navigation("Lotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modelo/Migrations/20240827025739_CuitNotGenerateValue.cs b/Modelo/Migrations/20240827025739_CuitNotGenerateValue.cs new file mode 100644 index 0000000..a9e2f14 --- /dev/null +++ b/Modelo/Migrations/20240827025739_CuitNotGenerateValue.cs @@ -0,0 +1,163 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Modelo.Migrations +{ + /// + public partial class CuitNotGenerateValue : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Facturas_Clientes_ClienteCuit", + table: "Facturas"); + + migrationBuilder.DropForeignKey( + name: "FK_Remitos_Proveedores_ProveedorCuit", + table: "Remitos"); + + migrationBuilder.DropForeignKey( + name: "FK_ProductoProveedor_Proveedores_ProveedorId", + table: "ProductoProveedor"); + + migrationBuilder.DropForeignKey( + name: "FK_Presupuestos_Proveedores_ProveedorCuit", + table: "Presupuestos"); + + migrationBuilder.DropForeignKey( + name: "FK_OrdenDeCompras_Proveedores_ProveedorCuit", + table: "OrdenDeCompras"); + + + migrationBuilder.DropPrimaryKey( + name:"PK_Clientes", + table: "Clientes"); + + migrationBuilder.DropColumn( + name:"Cuit", + table: "Clientes"); + + + migrationBuilder.DropPrimaryKey( + name: "PK_Proveedores", + table: "Proveedores"); + + migrationBuilder.DropColumn( + name:"Cuit", + table: "Proveedores"); + + migrationBuilder.AddColumn( + name: "Cuit", + table: "Clientes", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddPrimaryKey( + name: "PK_Clientes", + table: "Clientes", + column: "Cuit"); + + migrationBuilder.AddColumn( + name: "Cuit", + table: "Proveedores", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddPrimaryKey( + name: "PK_Proveedores", + table: "Proveedores", + column: "Cuit"); + + migrationBuilder.AddForeignKey( + name: "FK_Facturas_Clientes_ClienteCuit", + table: "Facturas", + column: "ClienteCuit", + principalTable: "Clientes", + principalColumn: "Cuit", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Remitos_Proveedores_ProveedorCuit", + table: "Remitos", + column: "ProveedorCuit", + principalTable: "Proveedores", + principalColumn: "Cuit", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_ProductoProveedor_Proveedores_ProveedorId", + table: "ProductoProveedor", + column: "ProveedorId", + principalTable: "Proveedores", + principalColumn: "Cuit", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Presupuestos_Proveedores_ProveedorCuit", + table: "Presupuestos", + column: "ProveedorCuit", + principalTable: "Proveedores", + principalColumn: "Cuit", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_OrdenDeCompras_Proveedores_ProveedorCuit", + table: "OrdenDeCompras", + column: "ProveedorCuit", + principalTable: "Proveedores", + principalColumn: "Cuit", + onDelete: ReferentialAction.Cascade); + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "Cuit", + table: "Clientes"); + + migrationBuilder.DropColumn( + name: "Cuit", + table: "Clientes"); + + + migrationBuilder.DropPrimaryKey( + name: "Cuit", + table: "Proveedores"); + + migrationBuilder.DropColumn( + name: "Cuit", + table: "Proveedores"); + + migrationBuilder.AddColumn( + name: "Cuit", + table: "Proveedores", + type: "bigint", + nullable: false, + defaultValue: 0L) + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AddColumn( + name: "Cuit", + table: "Clientes", + type: "bigint", + nullable: false, + defaultValue: 0L) + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AddPrimaryKey( + name: "Cuit", + table: "Proveedores", + column: "Cuit"); + + migrationBuilder.AddPrimaryKey( + name: "Cuit", + table: "Clientes", + column: "Cuit"); + + } + } +} diff --git a/Modelo/Migrations/ContextModelSnapshot.cs b/Modelo/Migrations/ContextModelSnapshot.cs index 522241d..3b25ab6 100644 --- a/Modelo/Migrations/ContextModelSnapshot.cs +++ b/Modelo/Migrations/ContextModelSnapshot.cs @@ -1,4 +1,5 @@ // +using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; @@ -16,10 +17,565 @@ namespace Modelo.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.7") + .HasAnnotation("ProductVersion", "8.0.8") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Entidades.Categoria", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Descripcion") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Categoria", (string)null); + }); + + modelBuilder.Entity("Entidades.Cliente", b => + { + b.Property("Cuit") + .HasColumnType("bigint"); + + b.Property("Apellido") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Correo") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Direccion") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Cuit"); + + b.ToTable("Clientes", (string)null); + }); + + modelBuilder.Entity("Entidades.DetalleFactura", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdFactura") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.HasKey("Id", "IdFactura"); + + b.HasIndex("IdFactura"); + + b.HasIndex("IdProducto"); + + b.ToTable("DetallesFacturas", (string)null); + }); + + modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdOrdenDeCompra") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("IdPresupuesto") + .HasColumnType("int"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.Property("MontoCU") + .HasColumnType("float"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("Id", "IdOrdenDeCompra"); + + b.HasIndex("IdOrdenDeCompra"); + + b.HasIndex("ProductoId"); + + b.ToTable("DetalleOrdenDeCompras"); + }); + + modelBuilder.Entity("Entidades.DetallePresupuesto", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdPresupuesto") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.Property("MontoCUPropuesto") + .HasColumnType("float"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("Id", "IdPresupuesto"); + + b.HasIndex("IdPresupuesto"); + + b.HasIndex("ProductoId"); + + b.ToTable("DetallePresupuestos"); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClienteCuit") + .HasColumnType("bigint"); + + b.Property("Fecha") + .HasColumnType("datetime2"); + + b.Property("IdCliente") + .HasColumnType("bigint"); + + b.Property("Total") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClienteCuit"); + + b.ToTable("Facturas", (string)null); + }); + + modelBuilder.Entity("Entidades.Lote", b => + { + b.Property("Id") + .HasColumnType("int"); + + b.Property("IdRemito") + .HasColumnType("int"); + + b.Property("Cantidad") + .HasColumnType("int"); + + b.Property("Fecha") + .HasColumnType("datetime2"); + + b.Property("Habilitado") + .HasColumnType("bit"); + + b.Property("IdProducto") + .HasColumnType("int"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("Id", "IdRemito"); + + b.HasIndex("IdRemito"); + + b.HasIndex("ProductoId"); + + b.ToTable("Lotes"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Entregado") + .HasColumnType("bit"); + + b.Property("IdProveedor") + .HasColumnType("bigint"); + + b.Property("ProveedorCuit") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("OrdenDeCompras"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Aceptado") + .HasColumnType("bit"); + + b.Property("Fecha") + .HasColumnType("datetime2"); + + b.Property("Habilitado") + .HasColumnType("bit"); + + b.Property("IdProveedor") + .HasColumnType("bigint"); + + b.Property("ProveedorCuit") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("Presupuestos"); + }); + + modelBuilder.Entity("Entidades.Producto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("nvarchar(21)"); + + b.Property("EsPerecedero") + .HasColumnType("bit"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Precio") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Producto"); + + b.HasDiscriminator().HasValue("Producto"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Entidades.Proveedor", b => + { + b.Property("Cuit") + .HasColumnType("bigint"); + + b.Property("Direccion") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("RazonSocial") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.HasKey("Cuit"); + + b.ToTable("Proveedores"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IdProveedor") + .HasColumnType("int"); + + b.Property("ProveedorCuit") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("Remitos"); + }); + + modelBuilder.Entity("ProductoCategoria", b => + { + b.Property("CategoriaId") + .HasColumnType("int"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("CategoriaId", "ProductoId"); + + b.HasIndex("ProductoId"); + + b.ToTable("ProductoCategoria"); + }); + + modelBuilder.Entity("ProductoProveedor", b => + { + b.Property("ProveedorId") + .HasColumnType("bigint"); + + b.Property("ProductoId") + .HasColumnType("int"); + + b.HasKey("ProveedorId", "ProductoId"); + + b.HasIndex("ProductoId"); + + b.ToTable("ProductoProveedor"); + }); + + modelBuilder.Entity("Entidades.ProductoNoPercedero", b => + { + b.HasBaseType("Entidades.Producto"); + + b.Property("TipoDeEnvase") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasDiscriminator().HasValue("ProductoNoPercedero"); + }); + + modelBuilder.Entity("Entidades.ProductoPercedero", b => + { + b.HasBaseType("Entidades.Producto"); + + b.Property("MesesHastaConsumoPreferente") + .HasColumnType("int"); + + b.Property("MesesHastaVencimiento") + .HasColumnType("int"); + + b.HasDiscriminator().HasValue("ProductoPercedero"); + }); + + modelBuilder.Entity("Entidades.DetalleFactura", b => + { + b.HasOne("Entidades.Factura", null) + .WithMany("Detalles") + .HasForeignKey("IdFactura") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("IdProducto") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b => + { + b.HasOne("Entidades.OrdenDeCompra", null) + .WithMany("Detalles") + .HasForeignKey("IdOrdenDeCompra") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.DetallePresupuesto", b => + { + b.HasOne("Entidades.Presupuesto", null) + .WithMany("detalles") + .HasForeignKey("IdPresupuesto") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.HasOne("Entidades.Cliente", "Cliente") + .WithMany() + .HasForeignKey("ClienteCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cliente"); + }); + + modelBuilder.Entity("Entidades.Lote", b => + { + b.HasOne("Entidades.Remito", null) + .WithMany("Lotes") + .HasForeignKey("IdRemito") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("ProductoCategoria", b => + { + b.HasOne("Entidades.Categoria", null) + .WithMany() + .HasForeignKey("CategoriaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", null) + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ProductoProveedor", b => + { + b.HasOne("Entidades.Producto", null) + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Proveedor", null) + .WithMany() + .HasForeignKey("ProveedorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.Navigation("Detalles"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.Navigation("Detalles"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.Navigation("detalles"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.Navigation("Lotes"); + }); #pragma warning restore 612, 618 } } diff --git a/Modelo/Repositorio.cs b/Modelo/Repositorio.cs index e04f9a0..40ee30e 100644 --- a/Modelo/Repositorio.cs +++ b/Modelo/Repositorio.cs @@ -4,7 +4,7 @@ namespace Modelo { public abstract class Repositorio { - protected Context context; + protected Context context = new Context(); //no voy a usar esta instancia igualmente public abstract List Listar(); public abstract void Add(T t); public abstract void Del(T t); @@ -16,11 +16,13 @@ namespace Modelo try { context.SaveChanges(); + context.Dispose(); + context = new Context(); ret = true; } - catch (DbUpdateException) + catch (DbUpdateException ex) { - throw; + Console.Error.WriteLine(ex); } return ret; diff --git a/Modelo/RepositorioCategoria.cs b/Modelo/RepositorioCategoria.cs index eab7cf9..d6fcc2b 100644 --- a/Modelo/RepositorioCategoria.cs +++ b/Modelo/RepositorioCategoria.cs @@ -10,7 +10,6 @@ namespace Modelo public RepositorioCategoria(Context context) { - this.context = context; } public override List Listar() @@ -20,7 +19,7 @@ namespace Modelo public Categoria ObtenerPorId(int Tid) { - Categoria cat = context.Categorias.First(x => x.Id == Tid); + Categoria cat = context.Categorias.FirstOrDefault(x => x.Id == Tid); return cat ?? new Categoria(); } diff --git a/Modelo/RepositorioClientes.cs b/Modelo/RepositorioClientes.cs index 7aaa13b..19f3393 100644 --- a/Modelo/RepositorioClientes.cs +++ b/Modelo/RepositorioClientes.cs @@ -7,6 +7,7 @@ namespace Modelo { public RepositorioClientes(Context context) { + this.context = context; } @@ -15,9 +16,9 @@ namespace Modelo return context.Clientes.ToList(); } - public Cliente ObtenerPorId(long Tid) + public Cliente ObtenerPorId(Int64 Tid) { - Cliente cli = context.Clientes.First(x => x.Cuit == Tid); + Cliente cli = context.Clientes.FirstOrDefault(x => x.Cuit == Tid); return cli ?? new Cliente(); } diff --git a/Vista/AddCategoria.Designer.cs b/Vista/FrmCategoria.Designer.cs similarity index 97% rename from Vista/AddCategoria.Designer.cs rename to Vista/FrmCategoria.Designer.cs index 479dd11..570231d 100644 --- a/Vista/AddCategoria.Designer.cs +++ b/Vista/FrmCategoria.Designer.cs @@ -1,6 +1,6 @@ namespace Vista { - partial class AddCategoria + partial class FrmCategoria { /// /// Required designer variable. @@ -90,7 +90,7 @@ btnAceptar.UseVisualStyleBackColor = true; btnAceptar.Click += button1_Click; // - // AddCategoria + // FrmCategoria // AcceptButton = btnAceptar; AutoScaleDimensions = new SizeF(7F, 15F); @@ -103,7 +103,7 @@ Controls.Add(label2); Controls.Add(label1); Controls.Add(btnCancelar); - Name = "AddCategoria"; + Name = "FrmCategoria"; Text = "Añadir Categoria"; ((System.ComponentModel.ISupportInitialize)numid).EndInit(); ResumeLayout(false); diff --git a/Vista/AddCategoria.cs b/Vista/FrmCategoria.cs similarity index 80% rename from Vista/AddCategoria.cs rename to Vista/FrmCategoria.cs index 26787ed..7563463 100644 --- a/Vista/AddCategoria.cs +++ b/Vista/FrmCategoria.cs @@ -12,10 +12,10 @@ using System.Windows.Forms; namespace Vista { - public partial class AddCategoria : Form + public partial class FrmCategoria : Form { private Categoria? categoria; - public AddCategoria() + public FrmCategoria() { InitializeComponent(); CargarDatos(); @@ -28,7 +28,12 @@ namespace Vista } private void CargarDatos() { - numid.Value = ControladoraCategorias.Instance.Listar().Max(x => x.Id + 1); + var list = ControladoraCategorias.Instance.Listar(); + var num = (list.Count == 0) ? + 1: + list.Max(x => x.Id + 1); + + numid.Value = num; numid.Enabled = false; } @@ -41,12 +46,6 @@ namespace Vista else if (textBox1.Text.Length > 100) // Ajusta el límite según sea necesario devolucion += "La descripción no puede superar los 100 caracteres\n"; - // Validar unicidad del ID solo si es una nueva categoría - if (categoria == null && ControladoraCategorias.Instance.Listar().Any(c => c.Id == (int)numid.Value)) - { - devolucion += "Ya existe una categoría con el mismo ID\n"; - } - if (devolucion == "") { return true; @@ -69,7 +68,6 @@ namespace Vista { categoria = new Categoria { - Id = (int)numid.Value, Descripcion = textBox1.Text }; diff --git a/Vista/AddCategoria.resx b/Vista/FrmCategoria.resx similarity index 99% rename from Vista/AddCategoria.resx rename to Vista/FrmCategoria.resx index a395bff..8b2ff64 100644 --- a/Vista/AddCategoria.resx +++ b/Vista/FrmCategoria.resx @@ -1,7 +1,7 @@  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Vista/FrmOrdenDeCompra.cs b/Vista/FrmOrdenDeCompra.cs index a7263eb..cccbbc8 100644 --- a/Vista/FrmOrdenDeCompra.cs +++ b/Vista/FrmOrdenDeCompra.cs @@ -73,7 +73,6 @@ namespace Vista IdOrdenDeCompra = Convert.ToInt32(numId.Value), MontoCU = detalle.MontoCUPropuesto, Producto = detalle.Producto, - presupuesto = pres, }); } diff --git a/Vista/FrmProducto.Designer.cs b/Vista/FrmProducto.Designer.cs index 7ddcd0b..8870f99 100644 --- a/Vista/FrmProducto.Designer.cs +++ b/Vista/FrmProducto.Designer.cs @@ -37,7 +37,6 @@ txtNombre = new TextBox(); numPrecio = new NumericUpDown(); checkHabilitado = new CheckBox(); - cmbCategoria = new ComboBox(); btnacept = new Button(); btncancel = new Button(); label6 = new Label(); @@ -52,13 +51,20 @@ label10 = new Label(); numericUpDown1 = new NumericUpDown(); numericUpDown2 = new NumericUpDown(); - comboBox1 = new ComboBox(); + cmbEnvase = new ComboBox(); + dgvCategoria = new DataGridView(); + label11 = new Label(); + dgvCategoriaAñadida = new DataGridView(); + btnaddCategoria = new Button(); + btnrmCategoria = new Button(); ((System.ComponentModel.ISupportInitialize)numId).BeginInit(); ((System.ComponentModel.ISupportInitialize)numPrecio).BeginInit(); ((System.ComponentModel.ISupportInitialize)dgvProveedorAñadido).BeginInit(); ((System.ComponentModel.ISupportInitialize)dgvProveedor).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDown1).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDown2).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dgvCategoria).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dgvCategoriaAñadida).BeginInit(); SuspendLayout(); // // label1 @@ -100,7 +106,7 @@ // label5 // label5.AutoSize = true; - label5.Location = new Point(7, 142); + label5.Location = new Point(373, 9); label5.Name = "label5"; label5.Size = new Size(58, 15); label5.TabIndex = 4; @@ -140,18 +146,9 @@ checkHabilitado.TabIndex = 8; checkHabilitado.UseVisualStyleBackColor = true; // - // cmbCategoria - // - cmbCategoria.DropDownStyle = ComboBoxStyle.DropDownList; - cmbCategoria.FormattingEnabled = true; - cmbCategoria.Location = new Point(70, 134); - cmbCategoria.Name = "cmbCategoria"; - cmbCategoria.Size = new Size(121, 23); - cmbCategoria.TabIndex = 9; - // // btnacept // - btnacept.Location = new Point(14, 336); + btnacept.Location = new Point(13, 311); btnacept.Name = "btnacept"; btnacept.Size = new Size(72, 21); btnacept.TabIndex = 10; @@ -161,7 +158,7 @@ // // btncancel // - btncancel.Location = new Point(106, 336); + btncancel.Location = new Point(105, 311); btncancel.Name = "btncancel"; btncancel.Size = new Size(68, 21); btncancel.TabIndex = 11; @@ -172,7 +169,7 @@ // label6 // label6.AutoSize = true; - label6.Location = new Point(230, 12); + label6.Location = new Point(652, 216); label6.Name = "label6"; label6.Size = new Size(123, 15); label6.TabIndex = 12; @@ -181,7 +178,7 @@ // label7 // label7.AutoSize = true; - label7.Location = new Point(494, 9); + label7.Location = new Point(652, 9); label7.Name = "label7"; label7.Size = new Size(72, 15); label7.TabIndex = 13; @@ -193,9 +190,8 @@ dgvProveedorAñadido.AllowUserToDeleteRows = false; dgvProveedorAñadido.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dgvProveedorAñadido.EditMode = DataGridViewEditMode.EditProgrammatically; - dgvProveedorAñadido.Location = new Point(230, 30); + dgvProveedorAñadido.Location = new Point(652, 234); dgvProveedorAñadido.Name = "dgvProveedorAñadido"; - dgvProveedorAñadido.RowTemplate.Height = 25; dgvProveedorAñadido.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvProveedorAñadido.Size = new Size(240, 150); dgvProveedorAñadido.TabIndex = 14; @@ -204,7 +200,7 @@ // dgvProveedor.AllowUserToAddRows = false; dgvProveedor.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dgvProveedor.Location = new Point(494, 30); + dgvProveedor.Location = new Point(652, 30); dgvProveedor.Name = "dgvProveedor"; dgvProveedor.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvProveedor.Size = new Size(240, 150); @@ -212,7 +208,7 @@ // // btnaddProveedor // - btnaddProveedor.Location = new Point(740, 30); + btnaddProveedor.Location = new Point(652, 186); btnaddProveedor.Name = "btnaddProveedor"; btnaddProveedor.Size = new Size(72, 21); btnaddProveedor.TabIndex = 16; @@ -222,7 +218,7 @@ // // btnrmProveedor // - btnrmProveedor.Location = new Point(740, 57); + btnrmProveedor.Location = new Point(820, 186); btnrmProveedor.Name = "btnrmProveedor"; btnrmProveedor.Size = new Size(72, 21); btnrmProveedor.TabIndex = 17; @@ -233,7 +229,7 @@ // checkBox1 // checkBox1.AutoSize = true; - checkBox1.Location = new Point(7, 187); + checkBox1.Location = new Point(6, 183); checkBox1.Name = "checkBox1"; checkBox1.Size = new Size(79, 19); checkBox1.TabIndex = 18; @@ -244,7 +240,7 @@ // label8 // label8.AutoSize = true; - label8.Location = new Point(25, 230); + label8.Location = new Point(24, 205); label8.Name = "label8"; label8.Size = new Size(185, 15); label8.TabIndex = 20; @@ -253,7 +249,7 @@ // label9 // label9.AutoSize = true; - label9.Location = new Point(141, 289); + label9.Location = new Point(140, 264); label9.Name = "label9"; label9.Size = new Size(69, 15); label9.TabIndex = 21; @@ -262,7 +258,7 @@ // label10 // label10.AutoSize = true; - label10.Location = new Point(68, 259); + label10.Location = new Point(67, 234); label10.Name = "label10"; label10.Size = new Size(142, 15); label10.TabIndex = 22; @@ -271,7 +267,7 @@ // numericUpDown1 // numericUpDown1.Enabled = false; - numericUpDown1.Location = new Point(230, 222); + numericUpDown1.Location = new Point(229, 197); numericUpDown1.Name = "numericUpDown1"; numericUpDown1.Size = new Size(120, 23); numericUpDown1.TabIndex = 23; @@ -280,20 +276,71 @@ // numericUpDown2 // numericUpDown2.Enabled = false; - numericUpDown2.Location = new Point(229, 252); + numericUpDown2.Location = new Point(228, 227); numericUpDown2.Name = "numericUpDown2"; numericUpDown2.Size = new Size(120, 23); numericUpDown2.TabIndex = 24; numericUpDown2.ValueChanged += numericUpDown2_ValueChanged; // - // comboBox1 + // cmbEnvase // - comboBox1.DropDownStyle = ComboBoxStyle.DropDownList; - comboBox1.FormattingEnabled = true; - comboBox1.Location = new Point(228, 281); - comboBox1.Name = "comboBox1"; - comboBox1.Size = new Size(121, 23); - comboBox1.TabIndex = 25; + cmbEnvase.DropDownStyle = ComboBoxStyle.DropDownList; + cmbEnvase.FormattingEnabled = true; + cmbEnvase.Location = new Point(227, 256); + cmbEnvase.Name = "cmbEnvase"; + cmbEnvase.Size = new Size(121, 23); + cmbEnvase.TabIndex = 25; + // + // dgvCategoria + // + dgvCategoria.AllowUserToAddRows = false; + dgvCategoria.AllowUserToDeleteRows = false; + dgvCategoria.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dgvCategoria.EditMode = DataGridViewEditMode.EditProgrammatically; + dgvCategoria.Location = new Point(373, 30); + dgvCategoria.Name = "dgvCategoria"; + dgvCategoria.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dgvCategoria.Size = new Size(240, 150); + dgvCategoria.TabIndex = 26; + // + // label11 + // + label11.AutoSize = true; + label11.Location = new Point(373, 216); + label11.Name = "label11"; + label11.Size = new Size(108, 15); + label11.TabIndex = 27; + label11.Text = "Categoria Añadida "; + // + // dgvCategoriaAñadida + // + dgvCategoriaAñadida.AllowUserToAddRows = false; + dgvCategoriaAñadida.AllowUserToDeleteRows = false; + dgvCategoriaAñadida.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dgvCategoriaAñadida.EditMode = DataGridViewEditMode.EditProgrammatically; + dgvCategoriaAñadida.Location = new Point(373, 234); + dgvCategoriaAñadida.Name = "dgvCategoriaAñadida"; + dgvCategoriaAñadida.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dgvCategoriaAñadida.Size = new Size(240, 150); + dgvCategoriaAñadida.TabIndex = 28; + // + // btnaddCategoria + // + btnaddCategoria.Location = new Point(373, 186); + btnaddCategoria.Name = "btnaddCategoria"; + btnaddCategoria.Size = new Size(72, 21); + btnaddCategoria.TabIndex = 29; + btnaddCategoria.Text = "Añadir"; + btnaddCategoria.UseVisualStyleBackColor = true; + // + // btnrmCategoria + // + btnrmCategoria.Location = new Point(541, 186); + btnrmCategoria.Name = "btnrmCategoria"; + btnrmCategoria.Size = new Size(72, 21); + btnrmCategoria.TabIndex = 30; + btnrmCategoria.Text = "Eliminar"; + btnrmCategoria.UseVisualStyleBackColor = true; // // FrmProducto // @@ -301,8 +348,13 @@ AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; CancelButton = btncancel; - ClientSize = new Size(877, 369); - Controls.Add(comboBox1); + ClientSize = new Size(1219, 517); + Controls.Add(btnrmCategoria); + Controls.Add(btnaddCategoria); + Controls.Add(dgvCategoriaAñadida); + Controls.Add(label11); + Controls.Add(dgvCategoria); + Controls.Add(cmbEnvase); Controls.Add(numericUpDown2); Controls.Add(numericUpDown1); Controls.Add(label10); @@ -317,7 +369,6 @@ Controls.Add(label6); Controls.Add(btncancel); Controls.Add(btnacept); - Controls.Add(cmbCategoria); Controls.Add(checkHabilitado); Controls.Add(numPrecio); Controls.Add(txtNombre); @@ -335,6 +386,8 @@ ((System.ComponentModel.ISupportInitialize)dgvProveedor).EndInit(); ((System.ComponentModel.ISupportInitialize)numericUpDown1).EndInit(); ((System.ComponentModel.ISupportInitialize)numericUpDown2).EndInit(); + ((System.ComponentModel.ISupportInitialize)dgvCategoria).EndInit(); + ((System.ComponentModel.ISupportInitialize)dgvCategoriaAñadida).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -350,7 +403,6 @@ private TextBox txtNombre; private NumericUpDown numPrecio; private CheckBox checkHabilitado; - private ComboBox cmbCategoria; private Button btnacept; private Button btncancel; private Label label6; @@ -365,6 +417,11 @@ private Label label10; private NumericUpDown numericUpDown1; private NumericUpDown numericUpDown2; - private ComboBox comboBox1; + private ComboBox cmbEnvase; + private DataGridView dgvCategoria; + private Label label11; + private DataGridView dgvCategoriaAñadida; + private Button btnaddCategoria; + private Button btnrmCategoria; } } \ No newline at end of file diff --git a/Vista/FrmProducto.cs b/Vista/FrmProducto.cs index bfb7f8a..0ffde58 100644 --- a/Vista/FrmProducto.cs +++ b/Vista/FrmProducto.cs @@ -33,7 +33,7 @@ namespace Vista } private void cargarcombo() { - comboBox1.DataSource = Enum.GetValues(typeof(EnvaseTipo)); + cmbEnvase.DataSource = Enum.GetValues(typeof(EnvaseTipo)); } private void InicializarFormulario() { @@ -42,8 +42,7 @@ namespace Vista txtNombre.Text = nuevoproducto.Nombre; numPrecio.Value = (decimal)nuevoproducto.Precio; checkHabilitado.Checked = nuevoproducto.Habilitado; - cmbCategoria.SelectedValue = nuevoproducto.Categoria.Id; - dgvProveedorAñadido.DataSource = nuevoproducto.ListarProveedores(); + dgvProveedorAñadido.DataSource = nuevoproducto.proveedores.AsReadOnly(); } @@ -62,16 +61,7 @@ namespace Vista private void CargarCategorias() { - // Obtener la lista de categorías desde la controladora - var categorias = ControladoraCategorias.Instance.Listar(); - - // Configurar el ComboBox para categorías - cmbCategoria.DisplayMember = "Descripcion"; // Mostrar la propiedad Descripcion - cmbCategoria.ValueMember = "Id"; // Usar la propiedad Id como valor - - // Asignar la lista de categorías al ComboBox - cmbCategoria.DataSource = categorias; - + var listprod = ControladoraProductos.Instance.Listar(); numId.Value = (listprod.Count > 0) ? listprod.Max(x => x.Id + 1) : @@ -100,14 +90,11 @@ namespace Vista devolucion += "Ya existe un producto con el mismo ID.\n"; } - // Validar Categoría Seleccionada - if (cmbCategoria.SelectedItem == null) - { - devolucion += "Debe seleccionar una categoría.\n"; - } + // Validar Categoría Seleccionada (wip) + //devolucion += "Debe seleccionar una categoría.\n"; // Validar Tipo de Producto - if (!checkBox1.Checked && comboBox1.SelectedItem == null) + if (!checkBox1.Checked && cmbEnvase.SelectedItem == null) { devolucion += "Debe seleccionar un tipo de envase para el producto no perecedero.\n"; } @@ -144,19 +131,18 @@ namespace Vista Nombre = txtNombre.Text, Precio = (double)numPrecio.Value, Habilitado = checkHabilitado.Checked, - Categoria = (Categoria)cmbCategoria.SelectedItem, MesesHastaConsumoPreferente = (int)numericUpDown1.Value, MesesHastaVencimiento = (int)numericUpDown2.Value, }; - foreach (var proveedor in nuevoproducto.ListarProveedores()) + foreach (var proveedor in nuevoproducto.proveedores.AsReadOnly()) { productoPerecedero.AñadirProveedor(proveedor); } string mensaje = mod - ? ControladoraProductos.Instance.Modificar(productoPerecedero) - : ControladoraProductos.Instance.Añadir(productoPerecedero); + ? ControladoraProductoPercedero.Instance.Modificar(productoPerecedero) + : ControladoraProductoPercedero.Instance.Añadir(productoPerecedero); MessageBox.Show(mensaje, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); } @@ -168,17 +154,16 @@ namespace Vista Nombre = txtNombre.Text, Precio = (double)numPrecio.Value, Habilitado = checkHabilitado.Checked, - Categoria = (Categoria)cmbCategoria.SelectedItem, - TipoDeEnvase = (EnvaseTipo)comboBox1.SelectedItem, + TipoDeEnvase = (EnvaseTipo)cmbEnvase.SelectedItem, }; - foreach (var proveedor in nuevoproducto.ListarProveedores()) + foreach (var proveedor in nuevoproducto.proveedores.AsReadOnly()) { productoNoPerecedero.AñadirProveedor(proveedor); } string mensaje = mod - ? ControladoraProductos.Instance.Modificar(productoNoPerecedero) - : ControladoraProductos.Instance.Añadir(productoNoPerecedero); + ? ControladoraProductoNoPercedero.Instance.Modificar(productoNoPerecedero) + : ControladoraProductoNoPercedero.Instance.Añadir(productoNoPerecedero); MessageBox.Show(mensaje, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); } @@ -204,7 +189,7 @@ namespace Vista foreach (DataGridViewRow selectedRow in dgvProveedor.SelectedRows) { Proveedor proveedor = (Proveedor)selectedRow.DataBoundItem; - var checkcolicion = nuevoproducto.ListarProveedores().Contains(proveedor); + var checkcolicion = nuevoproducto.proveedores.Contains(proveedor); if (checkcolicion) { MessageBox.Show("El proveedor ya fue cargado"); @@ -212,7 +197,7 @@ namespace Vista } nuevoproducto.AñadirProveedor(proveedor); dgvProveedorAñadido.DataSource = null; - dgvProveedorAñadido.DataSource = nuevoproducto.ListarProveedores(); + dgvProveedorAñadido.DataSource = nuevoproducto.proveedores.AsReadOnly(); } } else @@ -233,7 +218,7 @@ namespace Vista Proveedor proveedor = (Proveedor)selectedRow.DataBoundItem; nuevoproducto.EliminarProveedor(proveedor); dgvProveedorAñadido.DataSource = null; - dgvProveedorAñadido.DataSource = nuevoproducto.ListarProveedores(); + dgvProveedorAñadido.DataSource = nuevoproducto.proveedores.AsReadOnly(); } } else @@ -253,7 +238,7 @@ namespace Vista numericUpDown1.Enabled = esPerecedero; numericUpDown2.Enabled = esPerecedero; - comboBox1.Enabled = !esPerecedero; + cmbEnvase.Enabled = !esPerecedero; } private void numericUpDown2_ValueChanged(object sender, EventArgs e) diff --git a/Vista/FrmProducto.resx b/Vista/FrmProducto.resx index af32865..8b2ff64 100644 --- a/Vista/FrmProducto.resx +++ b/Vista/FrmProducto.resx @@ -1,7 +1,7 @@