This commit is contained in:
fedpo
2024-09-08 02:39:13 +01:00
parent c15ae743ab
commit 393caac989
65 changed files with 1138 additions and 282 deletions

View File

@@ -33,15 +33,6 @@ namespace Controladora
$"Fallo la Eliminacion del Presupuesto {t.Id}"; $"Fallo la Eliminacion del Presupuesto {t.Id}";
} }
public string Modificar(Presupuesto t)
{
if (t == null) return "El Presupuesto es nulo fallo la carga";
repositorioPresupuestos.Mod(t);
return (repositorioPresupuestos.Guardar()) ?
$"El Presupuesto {t.Id} se Modifico correctamente":
$"Fallo la Modificacion del Presupuesto {t.Id}";
}
public string AceptarPresupuesto(Presupuesto t) public string AceptarPresupuesto(Presupuesto t)
{ {
if (t == null) return "El Presupuesto es nulo fallo la carga"; if (t == null) return "El Presupuesto es nulo fallo la carga";
@@ -83,12 +74,9 @@ namespace Controladora
return productos; return productos;
} }
public object ListarProveedores() public ReadOnlyCollection<Proveedor> ListarProveedores()
{ {
return ControladoraProveedores.Instance.Listar() return ControladoraProveedores.Instance.Listar();
.Where(x => x.Habilitado == true)
.ToList()
.AsReadOnly();
} }
public ReadOnlyCollection<Presupuesto> ListarTodo() public ReadOnlyCollection<Presupuesto> ListarTodo()

View File

@@ -17,9 +17,16 @@ namespace Controladora
public ReadOnlyCollection<Proveedor> ListarProveedores(Producto producto) public ReadOnlyCollection<Proveedor> ListarProveedores(Producto producto)
{ {
Producto productoalistar = new RepositorioProductos(new Context()).Listar().First(x => x.Id == producto.Id); Producto productoalistar = new RepositorioProductos(new Context()).Listar().First(x => x.Id == producto.Id);
if (productoalistar == null) return new ReadOnlyCollection<Proveedor>(new List<Proveedor>()); if (productoalistar == null) return new List<Proveedor>().AsReadOnly();
return productoalistar.proveedores.AsReadOnly(); return productoalistar.proveedores.AsReadOnly();
}
public ReadOnlyCollection<Categoria> ListarCategorias(Producto producto)
{
Producto productoalistar = new RepositorioProductos(new Context()).Listar().First(x => x.Id == producto.Id);
if (productoalistar == null) return new List<Categoria>().AsReadOnly();
return productoalistar.categorias.AsReadOnly();
} }
public Producto? MostrarPorId(Producto producto) public Producto? MostrarPorId(Producto producto)

View File

@@ -11,8 +11,7 @@ namespace Entidades
public long IdProveedor { get; set; } public long IdProveedor { get; set; }
public bool Entregado { get; set; } public bool Entregado { get; set; }
private List<DetalleOrdenDeCompra> detalles = new List<DetalleOrdenDeCompra>(); public List<DetalleOrdenDeCompra> detalles = new List<DetalleOrdenDeCompra>();
public ReadOnlyCollection<DetalleOrdenDeCompra> Detalles => detalles.AsReadOnly();
public void AñadirDetalle(DetalleOrdenDeCompra detalle) public void AñadirDetalle(DetalleOrdenDeCompra detalle)
{ {
detalles.Add(detalle); detalles.Add(detalle);

View File

@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Informes")] [assembly: System.Reflection.AssemblyCompanyAttribute("Informes")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+670190c44b669009d2d84e1f849117de0d18586f")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c15ae743ab4e6f1c270349cbe1eadde8c6404874")]
[assembly: System.Reflection.AssemblyProductAttribute("Informes")] [assembly: System.Reflection.AssemblyProductAttribute("Informes")]
[assembly: System.Reflection.AssemblyTitleAttribute("Informes")] [assembly: System.Reflection.AssemblyTitleAttribute("Informes")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@@ -1 +1 @@
3686af964ab837044e10a22154c7a4ac73f28162a711d7a0fa37d00d14ff75af 063488f106d4df3b350dc1d03b4f97c1bb306fa93a8938b525a7dd6820ac6ea7

View File

@@ -167,7 +167,7 @@ public class Context : Microsoft.EntityFrameworkCore.DbContext
.HasKey(x => x.Id); .HasKey(x => x.Id);
modelBuilder.Entity<OrdenDeCompra>() modelBuilder.Entity<OrdenDeCompra>()
.HasMany(x => x.Detalles) .HasMany(x => x.detalles)
.WithOne() .WithOne()
.HasForeignKey(x => x.IdOrdenDeCompra); .HasForeignKey(x => x.IdOrdenDeCompra);

View File

@@ -0,0 +1,576 @@
// <auto-generated />
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("20240907203054_funcatodo")]
partial class funcatodo
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Descripcion")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("Id");
b.ToTable("Categoria", (string)null);
});
modelBuilder.Entity("Entidades.Cliente", b =>
{
b.Property<long>("Cuit")
.HasColumnType("bigint");
b.Property<string>("Apellido")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("Correo")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.Property<string>("Direccion")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.HasKey("Cuit");
b.ToTable("Clientes", (string)null);
});
modelBuilder.Entity("Entidades.DetalleFactura", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdFactura")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdFactura");
b.HasIndex("IdFactura");
b.HasIndex("ProductoId");
b.ToTable("DetallesFacturas", (string)null);
});
modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdOrdenDeCompra")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<int>("IdPresupuesto")
.HasColumnType("int");
b.Property<double>("MontoCU")
.HasColumnType("float");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdOrdenDeCompra");
b.HasIndex("IdOrdenDeCompra");
b.HasIndex("ProductoId");
b.ToTable("DetalleOrdenDeCompras");
});
modelBuilder.Entity("Entidades.DetallePresupuesto", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdPresupuesto")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<double>("MontoCUPropuesto")
.HasColumnType("float");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdPresupuesto");
b.HasIndex("IdPresupuesto");
b.HasIndex("ProductoId");
b.ToTable("DetallePresupuestos");
});
modelBuilder.Entity("Entidades.Factura", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<long>("ClienteCuit")
.HasColumnType("bigint");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<long>("IdCliente")
.HasColumnType("bigint");
b.Property<double>("Total")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClienteCuit");
b.ToTable("Facturas", (string)null);
});
modelBuilder.Entity("Entidades.Lote", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("IdRemito")
.HasColumnType("int");
b.Property<int>("Cantidad")
.HasColumnType("int");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<bool>("Habilitado")
.HasColumnType("bit");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("Id", "IdRemito");
b.HasIndex("IdRemito");
b.HasIndex("ProductoId");
b.ToTable("Lotes");
});
modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("Entregado")
.HasColumnType("bit");
b.Property<long>("IdProveedor")
.HasColumnType("bigint");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("OrdenDeCompras");
});
modelBuilder.Entity("Entidades.Presupuesto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("Aceptado")
.HasColumnType("bit");
b.Property<DateTime>("Fecha")
.HasColumnType("datetime2");
b.Property<bool>("Habilitado")
.HasColumnType("bit");
b.Property<long>("IdProveedor")
.HasColumnType("bigint");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("Presupuestos");
});
modelBuilder.Entity("Entidades.Producto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Discriminator")
.IsRequired()
.HasMaxLength(21)
.HasColumnType("nvarchar(21)");
b.Property<bool>("EsPerecedero")
.HasColumnType("bit");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<double>("Precio")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Producto");
b.HasDiscriminator().HasValue("Producto");
b.UseTphMappingStrategy();
});
modelBuilder.Entity("Entidades.Proveedor", b =>
{
b.Property<long>("Cuit")
.HasColumnType("bigint");
b.Property<string>("Direccion")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.Property<bool>("Habilitado")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(true);
b.Property<string>("Nombre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("RazonSocial")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.HasKey("Cuit");
b.ToTable("Proveedores");
});
modelBuilder.Entity("Entidades.Remito", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("IdProveedor")
.HasColumnType("int");
b.Property<long>("ProveedorCuit")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ProveedorCuit");
b.ToTable("Remitos");
});
modelBuilder.Entity("ProductoCategoria", b =>
{
b.Property<int>("CategoriaId")
.HasColumnType("int");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("CategoriaId", "ProductoId");
b.HasIndex("ProductoId");
b.ToTable("ProductoCategoria");
});
modelBuilder.Entity("ProductoProveedor", b =>
{
b.Property<long>("ProveedorId")
.HasColumnType("bigint");
b.Property<int>("ProductoId")
.HasColumnType("int");
b.HasKey("ProveedorId", "ProductoId");
b.HasIndex("ProductoId");
b.ToTable("ProductoProveedor");
});
modelBuilder.Entity("Entidades.ProductoNoPercedero", b =>
{
b.HasBaseType("Entidades.Producto");
b.Property<string>("TipoDeEnvase")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasDiscriminator().HasValue("ProductoNoPercedero");
});
modelBuilder.Entity("Entidades.ProductoPercedero", b =>
{
b.HasBaseType("Entidades.Producto");
b.Property<int>("MesesHastaConsumoPreferente")
.HasColumnType("int");
b.Property<int>("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("ProductoId")
.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
}
}
}

View File

@@ -0,0 +1,95 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Modelo.Migrations
{
/// <inheritdoc />
public partial class funcatodo : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_DetallesFacturas_Producto_IdProducto",
table: "DetallesFacturas");
migrationBuilder.DropColumn(
name: "IdProducto",
table: "Lotes");
migrationBuilder.DropColumn(
name: "IdProducto",
table: "DetallePresupuestos");
migrationBuilder.DropColumn(
name: "IdProducto",
table: "DetalleOrdenDeCompras");
migrationBuilder.RenameColumn(
name: "IdProducto",
table: "DetallesFacturas",
newName: "ProductoId");
migrationBuilder.RenameIndex(
name: "IX_DetallesFacturas_IdProducto",
table: "DetallesFacturas",
newName: "IX_DetallesFacturas_ProductoId");
migrationBuilder.AddForeignKey(
name: "FK_DetallesFacturas_Producto_ProductoId",
table: "DetallesFacturas",
column: "ProductoId",
principalTable: "Producto",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_DetallesFacturas_Producto_ProductoId",
table: "DetallesFacturas");
migrationBuilder.RenameColumn(
name: "ProductoId",
table: "DetallesFacturas",
newName: "IdProducto");
migrationBuilder.RenameIndex(
name: "IX_DetallesFacturas_ProductoId",
table: "DetallesFacturas",
newName: "IX_DetallesFacturas_IdProducto");
migrationBuilder.AddColumn<int>(
name: "IdProducto",
table: "Lotes",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "IdProducto",
table: "DetallePresupuestos",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "IdProducto",
table: "DetalleOrdenDeCompras",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddForeignKey(
name: "FK_DetallesFacturas_Producto_IdProducto",
table: "DetallesFacturas",
column: "IdProducto",
principalTable: "Producto",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@@ -86,14 +86,14 @@ namespace Modelo.Migrations
b.Property<int>("Cantidad") b.Property<int>("Cantidad")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("IdProducto") b.Property<int>("ProductoId")
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id", "IdFactura"); b.HasKey("Id", "IdFactura");
b.HasIndex("IdFactura"); b.HasIndex("IdFactura");
b.HasIndex("IdProducto"); b.HasIndex("ProductoId");
b.ToTable("DetallesFacturas", (string)null); b.ToTable("DetallesFacturas", (string)null);
}); });
@@ -112,9 +112,6 @@ namespace Modelo.Migrations
b.Property<int>("IdPresupuesto") b.Property<int>("IdPresupuesto")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.Property<double>("MontoCU") b.Property<double>("MontoCU")
.HasColumnType("float"); .HasColumnType("float");
@@ -127,7 +124,7 @@ namespace Modelo.Migrations
b.HasIndex("ProductoId"); b.HasIndex("ProductoId");
b.ToTable("DetalleOrdenDeCompras"); b.ToTable("DetalleOrdenDeCompras", (string)null);
}); });
modelBuilder.Entity("Entidades.DetallePresupuesto", b => modelBuilder.Entity("Entidades.DetallePresupuesto", b =>
@@ -141,9 +138,6 @@ namespace Modelo.Migrations
b.Property<int>("Cantidad") b.Property<int>("Cantidad")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.Property<double>("MontoCUPropuesto") b.Property<double>("MontoCUPropuesto")
.HasColumnType("float"); .HasColumnType("float");
@@ -156,7 +150,7 @@ namespace Modelo.Migrations
b.HasIndex("ProductoId"); b.HasIndex("ProductoId");
b.ToTable("DetallePresupuestos"); b.ToTable("DetallePresupuestos", (string)null);
}); });
modelBuilder.Entity("Entidades.Factura", b => modelBuilder.Entity("Entidades.Factura", b =>
@@ -203,9 +197,6 @@ namespace Modelo.Migrations
b.Property<bool>("Habilitado") b.Property<bool>("Habilitado")
.HasColumnType("bit"); .HasColumnType("bit");
b.Property<int>("IdProducto")
.HasColumnType("int");
b.Property<int>("ProductoId") b.Property<int>("ProductoId")
.HasColumnType("int"); .HasColumnType("int");
@@ -215,7 +206,7 @@ namespace Modelo.Migrations
b.HasIndex("ProductoId"); b.HasIndex("ProductoId");
b.ToTable("Lotes"); b.ToTable("Lotes", (string)null);
}); });
modelBuilder.Entity("Entidades.OrdenDeCompra", b => modelBuilder.Entity("Entidades.OrdenDeCompra", b =>
@@ -239,7 +230,7 @@ namespace Modelo.Migrations
b.HasIndex("ProveedorCuit"); b.HasIndex("ProveedorCuit");
b.ToTable("OrdenDeCompras"); b.ToTable("OrdenDeCompras", (string)null);
}); });
modelBuilder.Entity("Entidades.Presupuesto", b => modelBuilder.Entity("Entidades.Presupuesto", b =>
@@ -269,7 +260,7 @@ namespace Modelo.Migrations
b.HasIndex("ProveedorCuit"); b.HasIndex("ProveedorCuit");
b.ToTable("Presupuestos"); b.ToTable("Presupuestos", (string)null);
}); });
modelBuilder.Entity("Entidades.Producto", b => modelBuilder.Entity("Entidades.Producto", b =>
@@ -303,7 +294,7 @@ namespace Modelo.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Producto"); b.ToTable("Producto", (string)null);
b.HasDiscriminator().HasValue("Producto"); b.HasDiscriminator().HasValue("Producto");
@@ -337,7 +328,7 @@ namespace Modelo.Migrations
b.HasKey("Cuit"); b.HasKey("Cuit");
b.ToTable("Proveedores"); b.ToTable("Proveedores", (string)null);
}); });
modelBuilder.Entity("Entidades.Remito", b => modelBuilder.Entity("Entidades.Remito", b =>
@@ -358,7 +349,7 @@ namespace Modelo.Migrations
b.HasIndex("ProveedorCuit"); b.HasIndex("ProveedorCuit");
b.ToTable("Remitos"); b.ToTable("Remitos", (string)null);
}); });
modelBuilder.Entity("ProductoCategoria", b => modelBuilder.Entity("ProductoCategoria", b =>
@@ -373,7 +364,7 @@ namespace Modelo.Migrations
b.HasIndex("ProductoId"); b.HasIndex("ProductoId");
b.ToTable("ProductoCategoria"); b.ToTable("ProductoCategoria", (string)null);
}); });
modelBuilder.Entity("ProductoProveedor", b => modelBuilder.Entity("ProductoProveedor", b =>
@@ -388,7 +379,7 @@ namespace Modelo.Migrations
b.HasIndex("ProductoId"); b.HasIndex("ProductoId");
b.ToTable("ProductoProveedor"); b.ToTable("ProductoProveedor", (string)null);
}); });
modelBuilder.Entity("Entidades.ProductoNoPercedero", b => modelBuilder.Entity("Entidades.ProductoNoPercedero", b =>
@@ -425,7 +416,7 @@ namespace Modelo.Migrations
b.HasOne("Entidades.Producto", "Producto") b.HasOne("Entidades.Producto", "Producto")
.WithMany() .WithMany()
.HasForeignKey("IdProducto") .HasForeignKey("ProductoId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();

View File

@@ -22,7 +22,7 @@ namespace Modelo
} }
catch (DbUpdateException ex) catch (DbUpdateException ex)
{ {
Console.Error.WriteLine(ex); throw;
} }
return ret; return ret;

View File

@@ -14,7 +14,9 @@ namespace Modelo
public override List<Categoria> Listar() public override List<Categoria> Listar()
{ {
return context.Categorias.ToList(); return context.Categorias
.AsNoTracking()
.ToList();
} }
public Categoria ObtenerPorId(int Tid) public Categoria ObtenerPorId(int Tid)

View File

@@ -1,4 +1,5 @@
using Entidades; using Entidades;
using Microsoft.EntityFrameworkCore;
using System.Security.Cryptography; using System.Security.Cryptography;
namespace Modelo namespace Modelo
@@ -13,7 +14,9 @@ namespace Modelo
public override List<Cliente> Listar() public override List<Cliente> Listar()
{ {
return context.Clientes.ToList(); return context.Clientes
.AsNoTracking()
.ToList();
} }
public Cliente ObtenerPorId(Int64 Tid) public Cliente ObtenerPorId(Int64 Tid)

View File

@@ -1,5 +1,6 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using Entidades; using Entidades;
using Microsoft.EntityFrameworkCore;
namespace Modelo namespace Modelo
{ {
@@ -12,7 +13,9 @@ namespace Modelo
public override List<Factura> Listar() public override List<Factura> Listar()
{ {
return context.Facturas.ToList(); return context.Facturas
.AsNoTracking()
.ToList();
} }
public Factura ObtenerPorId(int Tid) public Factura ObtenerPorId(int Tid)

View File

@@ -1,4 +1,5 @@
using Entidades; using Entidades;
using Microsoft.EntityFrameworkCore;
using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.Arm;
namespace Modelo namespace Modelo
@@ -12,7 +13,10 @@ namespace Modelo
public override List<Lote> Listar() public override List<Lote> Listar()
{ {
return context.Lotes.ToList(); return context.Lotes
.AsNoTracking()
.Include(x => x.Producto)
.ToList();
} }
public Lote ObtenerPorId(int Tid) public Lote ObtenerPorId(int Tid)

View File

@@ -1,5 +1,6 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using Entidades; using Entidades;
using Microsoft.EntityFrameworkCore;
namespace Modelo namespace Modelo
{ {
@@ -12,7 +13,12 @@ namespace Modelo
public override List<OrdenDeCompra> Listar() public override List<OrdenDeCompra> Listar()
{ {
return context.OrdenDeCompras.ToList(); return context.OrdenDeCompras
.AsNoTracking()
.Include(x => x.Proveedor)
.Include(x => x.detalles)
.ThenInclude(x => x.Producto)
.ToList();
} }
public OrdenDeCompra ObtenerPorId(int Tid) public OrdenDeCompra ObtenerPorId(int Tid)
@@ -23,6 +29,14 @@ namespace Modelo
public override void Add(OrdenDeCompra t) public override void Add(OrdenDeCompra t)
{ {
t.Proveedor = context.Proveedores.First(x => x.Cuit == t.Proveedor.Cuit);
foreach (var detalle in t.detalles)
{
detalle.Producto = (detalle.Producto.EsPerecedero) ?
context.ProductoPercederos.First(x => x.Id == detalle.Producto.Id) :
context.ProductoNoPercederos.First(x => x.Id == detalle.Producto.Id);
}
context.OrdenDeCompras.Add(t); context.OrdenDeCompras.Add(t);
} }

View File

@@ -1,5 +1,6 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using Entidades; using Entidades;
using Microsoft.EntityFrameworkCore;
namespace Modelo namespace Modelo
{ {
@@ -12,7 +13,12 @@ namespace Modelo
public override List<Presupuesto> Listar() public override List<Presupuesto> Listar()
{ {
return context.Presupuestos.ToList(); return context.Presupuestos
.AsNoTracking()
.Include(x => x.detalles)
.ThenInclude(x => x.Producto)
.Include(x => x.Proveedor)
.ToList();
} }
public Presupuesto ObtenerPorId(int Tid) public Presupuesto ObtenerPorId(int Tid)
@@ -23,6 +29,18 @@ namespace Modelo
public override void Add(Presupuesto t) public override void Add(Presupuesto t)
{ {
t.Proveedor = context.Proveedores.First(x => x.Cuit == t.Proveedor.Cuit);
foreach (var detalle in t.detalles)
{
detalle.IdPresupuesto = t.Id;
detalle.Producto = detalle.Producto.EsPerecedero ?
context.ProductoPercederos.First(x => x.Id == detalle.Producto.Id) :
context.ProductoNoPercederos.First(x => x.Id == detalle.Producto.Id);
}
context.Presupuestos.Add(t); context.Presupuestos.Add(t);
} }
@@ -34,8 +52,10 @@ namespace Modelo
} }
public override void Mod(Presupuesto t) public override void Mod(Presupuesto t)
{ { // más que modificar es un marcar como aceptado
context.Presupuestos.Update(t); var pre = context.Presupuestos.First(x => x.Id == t.Id);
pre.Aceptado = t.Aceptado;
} }
} }
} }

View File

@@ -1,4 +1,5 @@
using Entidades; using Entidades;
using Microsoft.EntityFrameworkCore;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -16,7 +17,11 @@ namespace Modelo
public override List<ProductoNoPercedero> Listar() public override List<ProductoNoPercedero> Listar()
{ {
return context.ProductoNoPercederos.ToList(); return context.ProductoNoPercederos
.AsNoTracking()
.Include(x => x.proveedores)
.Include(x => x.categorias)
.ToList();
} }
public ProductoNoPercedero ObtenerPorId(int Tid) public ProductoNoPercedero ObtenerPorId(int Tid)
@@ -27,6 +32,16 @@ namespace Modelo
public override void Add(ProductoNoPercedero t) public override void Add(ProductoNoPercedero t)
{ {
foreach (var prov in t.proveedores)
{
var prove = context.Proveedores.First(x => x.Cuit == prov.Cuit);
t.proveedores.Add(prove);
}
foreach (var categoria in t.categorias)
{
var cat = context.Categorias.First(x => x.Id == categoria.Id);
t.categorias.Add(cat);
}
context.ProductoNoPercederos.Add(t); context.ProductoNoPercederos.Add(t);
} }
@@ -39,7 +54,30 @@ namespace Modelo
public override void Mod(ProductoNoPercedero t) public override void Mod(ProductoNoPercedero t)
{ {
context.ProductoNoPercederos.Update(t); ProductoNoPercedero pro = context.ProductoNoPercederos
.Include(x => x.proveedores)
.Include(x => x.categorias)
.First(x => x.Id == t.Id);
pro.Nombre = t.Nombre;
pro.Precio = t.Precio;
pro.Habilitado = t.Habilitado;
pro.TipoDeEnvase = t.TipoDeEnvase;
pro.EsPerecedero = t.EsPerecedero;
pro.proveedores.Clear();
pro.categorias.Clear();
foreach (var prov in t.proveedores)
{
var prove = context.Proveedores.First(x => x.Cuit == prov.Cuit);
pro.proveedores.Add(prove);
}
foreach (var categoria in t.categorias)
{
var cat = context.Categorias.First(x => x.Id == categoria.Id);
pro.categorias.Add(cat);
}
} }
} }
} }

View File

@@ -1,4 +1,5 @@
using Entidades; using Entidades;
using Microsoft.EntityFrameworkCore;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@@ -20,8 +21,16 @@ namespace Modelo
public ReadOnlyCollection<Producto> Listar() public ReadOnlyCollection<Producto> Listar()
{ {
List<Producto> prod = new(); List<Producto> prod = new();
prod.AddRange(_context.ProductoNoPercederos.ToList()); prod.AddRange(_context.ProductoNoPercederos
prod.AddRange(_context.ProductoPercederos.ToList()); .AsNoTracking()
.Include(x => x.categorias)
.Include(x => x.proveedores)
.ToList());
prod.AddRange(_context.ProductoPercederos
.AsNoTracking()
.Include(x => x.categorias)
.Include(x => x.proveedores)
.ToList());
return prod.AsReadOnly(); return prod.AsReadOnly();
} }

View File

@@ -1,4 +1,5 @@
using Entidades; using Entidades;
using Microsoft.EntityFrameworkCore;
namespace Modelo namespace Modelo
{ {
@@ -11,7 +12,11 @@ namespace Modelo
public override List<ProductoPercedero> Listar() public override List<ProductoPercedero> Listar()
{ {
return context.ProductoPercederos.ToList(); return context.ProductoPercederos
.AsNoTracking()
.Include(x => x.proveedores)
.Include(x => x.categorias)
.ToList();
} }
public ProductoPercedero ObtenerPorId(int Tid) public ProductoPercedero ObtenerPorId(int Tid)
@@ -22,6 +27,16 @@ namespace Modelo
public override void Add(ProductoPercedero t) public override void Add(ProductoPercedero t)
{ {
foreach (var prov in t.proveedores)
{
var prove = context.Proveedores.First(x => x.Cuit == prov.Cuit);
t.proveedores.Add(prove);
}
foreach (var categoria in t.categorias)
{
var cat = context.Categorias.First(x => x.Id == categoria.Id);
t.categorias.Add(cat);
}
context.ProductoPercederos.Add(t); context.ProductoPercederos.Add(t);
} }
@@ -34,7 +49,40 @@ namespace Modelo
public override void Mod(ProductoPercedero t) public override void Mod(ProductoPercedero t)
{ {
context.ProductoPercederos.Update(t); ProductoPercedero pro = context.ProductoPercederos
.Include(x => x.proveedores)
.Include(x => x.categorias)
.First(x => x.Id == t.Id);
pro.Nombre = t.Nombre;
pro.Precio = t.Precio;
pro.Habilitado = t.Habilitado;
pro.MesesHastaConsumoPreferente = t.MesesHastaConsumoPreferente;
pro.MesesHastaVencimiento = t.MesesHastaVencimiento;
pro.EsPerecedero = t.EsPerecedero;
pro.proveedores.Clear();
pro.categorias.Clear();
foreach (var prov in t.proveedores)
{
var prove = context.Proveedores.First(x => x.Cuit == prov.Cuit);
pro.proveedores.Add(prove);
}
foreach (var categoria in t.categorias)
{
var cate = context.Categorias.First(x => x.Id == categoria.Id);
pro.categorias.Add(cate); // Añade las categorías actualizadas
}
//List<Proveedor> proveedores = new List<Proveedor>();
//foreach (var prov in t.proveedores)
//{
// var prove = context.Proveedores.First(x => x.Cuit == prov.Cuit);
// proveedores.Add(prove);
//}
//t.proveedores = proveedores;
//context.ProductoPercederos.Update(t);
} }
} }
} }

View File

@@ -1,4 +1,5 @@
using Entidades; using Entidades;
using Microsoft.EntityFrameworkCore;
namespace Modelo namespace Modelo
{ {
@@ -11,7 +12,9 @@ namespace Modelo
public override List<Proveedor> Listar() public override List<Proveedor> Listar()
{ {
return context.Proveedores.ToList(); return context.Proveedores
.AsNoTracking()
.ToList();
} }
public Proveedor ObtenerPorId(long Tid) public Proveedor ObtenerPorId(long Tid)

View File

@@ -1,5 +1,6 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using Entidades; using Entidades;
using Microsoft.EntityFrameworkCore;
namespace Modelo namespace Modelo
{ {
@@ -13,7 +14,12 @@ namespace Modelo
public override List<Remito> Listar() public override List<Remito> Listar()
{ {
return context.Remitos.ToList(); return context.Remitos
.AsNoTracking()
.Include(x => x.Lotes)
.ThenInclude(x => x.Producto)
.Include(x => x.Proveedor)
.ToList();
} }
public Remito ObtenerPorId(int Tid) public Remito ObtenerPorId(int Tid)

View File

@@ -65,7 +65,7 @@
groupBox1.Controls.Add(BtnModificar); groupBox1.Controls.Add(BtnModificar);
groupBox1.Location = new Point(12, 2); groupBox1.Location = new Point(12, 2);
groupBox1.Name = "groupBox1"; groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(776, 351); groupBox1.Size = new Size(1206, 341);
groupBox1.TabIndex = 3; groupBox1.TabIndex = 3;
groupBox1.TabStop = false; groupBox1.TabStop = false;
// //
@@ -89,16 +89,15 @@
dgvCliente.MultiSelect = false; dgvCliente.MultiSelect = false;
dgvCliente.Name = "dgvCliente"; dgvCliente.Name = "dgvCliente";
dgvCliente.ReadOnly = true; dgvCliente.ReadOnly = true;
dgvCliente.RowTemplate.Height = 25;
dgvCliente.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvCliente.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvCliente.Size = new Size(737, 235); dgvCliente.Size = new Size(1194, 235);
dgvCliente.TabIndex = 3; dgvCliente.TabIndex = 3;
// //
// FrmClientes // FrmClientes
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450); ClientSize = new Size(1230, 509);
Controls.Add(groupBox1); Controls.Add(groupBox1);
Name = "FrmClientes"; Name = "FrmClientes";
Text = "Clientes"; Text = "Clientes";

View File

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

View File

@@ -48,7 +48,7 @@
groupBox1.Controls.Add(BtnAdd); groupBox1.Controls.Add(BtnAdd);
groupBox1.Location = new Point(12, 12); groupBox1.Location = new Point(12, 12);
groupBox1.Name = "groupBox1"; groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(1041, 426); groupBox1.Size = new Size(1223, 426);
groupBox1.TabIndex = 5; groupBox1.TabIndex = 5;
groupBox1.TabStop = false; groupBox1.TabStop = false;
// //
@@ -80,9 +80,8 @@
dgvDetalles.ImeMode = ImeMode.On; dgvDetalles.ImeMode = ImeMode.On;
dgvDetalles.Location = new Point(520, 40); dgvDetalles.Location = new Point(520, 40);
dgvDetalles.Name = "dgvDetalles"; dgvDetalles.Name = "dgvDetalles";
dgvDetalles.RowTemplate.Height = 25;
dgvDetalles.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvDetalles.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvDetalles.Size = new Size(384, 241); dgvDetalles.Size = new Size(697, 241);
dgvDetalles.TabIndex = 4; dgvDetalles.TabIndex = 4;
// //
// dgvFacturas // dgvFacturas
@@ -94,7 +93,6 @@
dgvFacturas.EditMode = DataGridViewEditMode.EditProgrammatically; dgvFacturas.EditMode = DataGridViewEditMode.EditProgrammatically;
dgvFacturas.Location = new Point(6, 40); dgvFacturas.Location = new Point(6, 40);
dgvFacturas.Name = "dgvFacturas"; dgvFacturas.Name = "dgvFacturas";
dgvFacturas.RowTemplate.Height = 25;
dgvFacturas.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvFacturas.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvFacturas.Size = new Size(508, 241); dgvFacturas.Size = new Size(508, 241);
dgvFacturas.TabIndex = 3; dgvFacturas.TabIndex = 3;
@@ -114,7 +112,7 @@
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1068, 450); ClientSize = new Size(1247, 465);
Controls.Add(groupBox1); Controls.Add(groupBox1);
Name = "FrmFacturas"; Name = "FrmFacturas";
Text = "Ventas"; Text = "Ventas";

View File

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

View File

@@ -151,7 +151,6 @@ namespace Vista
{ {
if (Validaciones()) return; if (Validaciones()) return;
orden.Id = Convert.ToInt32(numId.Value);
orden.Proveedor = (Proveedor)dgvProveedor.SelectedRows[0].DataBoundItem; orden.Proveedor = (Proveedor)dgvProveedor.SelectedRows[0].DataBoundItem;
string msg = ControladoraOrdenDeCompras.Instance.Añadir(orden); string msg = ControladoraOrdenDeCompras.Instance.Añadir(orden);
MessageBox.Show(msg); MessageBox.Show(msg);

View File

@@ -50,7 +50,7 @@
groupBox1.Controls.Add(BtnEliminar); groupBox1.Controls.Add(BtnEliminar);
groupBox1.Location = new Point(12, 3); groupBox1.Location = new Point(12, 3);
groupBox1.Name = "groupBox1"; groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(938, 351); groupBox1.Size = new Size(1211, 351);
groupBox1.TabIndex = 4; groupBox1.TabIndex = 4;
groupBox1.TabStop = false; groupBox1.TabStop = false;
// //
@@ -66,7 +66,7 @@
// label1 // label1
// //
label1.AutoSize = true; label1.AutoSize = true;
label1.Location = new Point(404, 4); label1.Location = new Point(484, 4);
label1.Name = "label1"; label1.Name = "label1";
label1.Size = new Size(48, 15); label1.Size = new Size(48, 15);
label1.TabIndex = 5; label1.TabIndex = 5;
@@ -78,11 +78,10 @@
dgvDetalles.AllowUserToDeleteRows = false; dgvDetalles.AllowUserToDeleteRows = false;
dgvDetalles.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dgvDetalles.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dgvDetalles.EditMode = DataGridViewEditMode.EditProgrammatically; dgvDetalles.EditMode = DataGridViewEditMode.EditProgrammatically;
dgvDetalles.Location = new Point(404, 22); dgvDetalles.Location = new Point(484, 22);
dgvDetalles.Name = "dgvDetalles"; dgvDetalles.Name = "dgvDetalles";
dgvDetalles.RowTemplate.Height = 25;
dgvDetalles.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvDetalles.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvDetalles.Size = new Size(525, 235); dgvDetalles.Size = new Size(714, 235);
dgvDetalles.TabIndex = 4; dgvDetalles.TabIndex = 4;
// //
// dgvOrdenDeCompra // dgvOrdenDeCompra
@@ -94,9 +93,8 @@
dgvOrdenDeCompra.EditMode = DataGridViewEditMode.EditProgrammatically; dgvOrdenDeCompra.EditMode = DataGridViewEditMode.EditProgrammatically;
dgvOrdenDeCompra.Location = new Point(6, 22); dgvOrdenDeCompra.Location = new Point(6, 22);
dgvOrdenDeCompra.Name = "dgvOrdenDeCompra"; dgvOrdenDeCompra.Name = "dgvOrdenDeCompra";
dgvOrdenDeCompra.RowTemplate.Height = 25;
dgvOrdenDeCompra.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvOrdenDeCompra.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvOrdenDeCompra.Size = new Size(392, 235); dgvOrdenDeCompra.Size = new Size(472, 235);
dgvOrdenDeCompra.TabIndex = 3; dgvOrdenDeCompra.TabIndex = 3;
dgvOrdenDeCompra.CellClick += dgvOrdenDeCompra_CellClick; dgvOrdenDeCompra.CellClick += dgvOrdenDeCompra_CellClick;
// //
@@ -124,7 +122,7 @@
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(953, 450); ClientSize = new Size(1250, 450);
Controls.Add(groupBox1); Controls.Add(groupBox1);
Name = "FrmOrdenesDeCompras"; Name = "FrmOrdenesDeCompras";
Text = "OrdenDeCompra"; Text = "OrdenDeCompra";

View File

@@ -102,5 +102,7 @@ namespace Vista
|| column.Name == "Cantidad" || column.Name == "SubTotal"; || column.Name == "Cantidad" || column.Name == "SubTotal";
} }
} }
} }
} }

View File

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

View File

@@ -58,10 +58,9 @@
dgvProducto.AllowUserToDeleteRows = false; dgvProducto.AllowUserToDeleteRows = false;
dgvProducto.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dgvProducto.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dgvProducto.EditMode = DataGridViewEditMode.EditProgrammatically; dgvProducto.EditMode = DataGridViewEditMode.EditProgrammatically;
dgvProducto.Location = new Point(631, 32); dgvProducto.Location = new Point(349, 32);
dgvProducto.MultiSelect = false; dgvProducto.MultiSelect = false;
dgvProducto.Name = "dgvProducto"; dgvProducto.Name = "dgvProducto";
dgvProducto.RowTemplate.Height = 25;
dgvProducto.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvProducto.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvProducto.Size = new Size(347, 338); dgvProducto.Size = new Size(347, 338);
dgvProducto.TabIndex = 1; dgvProducto.TabIndex = 1;
@@ -70,7 +69,7 @@
// ID // ID
// //
ID.AutoSize = true; ID.AutoSize = true;
ID.Location = new Point(26, 20); ID.Location = new Point(119, 407);
ID.Name = "ID"; ID.Name = "ID";
ID.Size = new Size(18, 15); ID.Size = new Size(18, 15);
ID.TabIndex = 2; ID.TabIndex = 2;
@@ -79,7 +78,7 @@
// label2 // label2
// //
label2.AutoSize = true; label2.AutoSize = true;
label2.Location = new Point(249, 14); label2.Location = new Point(12, 14);
label2.Name = "label2"; label2.Name = "label2";
label2.Size = new Size(55, 15); label2.Size = new Size(55, 15);
label2.TabIndex = 3; label2.TabIndex = 3;
@@ -87,7 +86,7 @@
// //
// numId // numId
// //
numId.Location = new Point(50, 18); numId.Location = new Point(143, 405);
numId.Maximum = new decimal(new int[] { 1410065407, 2, 0, 0 }); numId.Maximum = new decimal(new int[] { 1410065407, 2, 0, 0 });
numId.Name = "numId"; numId.Name = "numId";
numId.Size = new Size(120, 23); numId.Size = new Size(120, 23);
@@ -95,7 +94,7 @@
// //
// btnGuardar // btnGuardar
// //
btnGuardar.Location = new Point(12, 407); btnGuardar.Location = new Point(14, 449);
btnGuardar.Name = "btnGuardar"; btnGuardar.Name = "btnGuardar";
btnGuardar.Size = new Size(77, 26); btnGuardar.Size = new Size(77, 26);
btnGuardar.TabIndex = 9; btnGuardar.TabIndex = 9;
@@ -105,7 +104,7 @@
// //
// btnCerrar // btnCerrar
// //
btnCerrar.Location = new Point(892, 407); btnCerrar.Location = new Point(1159, 449);
btnCerrar.Name = "btnCerrar"; btnCerrar.Name = "btnCerrar";
btnCerrar.Size = new Size(81, 26); btnCerrar.Size = new Size(81, 26);
btnCerrar.TabIndex = 10; btnCerrar.TabIndex = 10;
@@ -115,7 +114,7 @@
// //
// btnAddProducto // btnAddProducto
// //
btnAddProducto.Location = new Point(12, 246); btnAddProducto.Location = new Point(520, 376);
btnAddProducto.Name = "btnAddProducto"; btnAddProducto.Name = "btnAddProducto";
btnAddProducto.Size = new Size(115, 29); btnAddProducto.Size = new Size(115, 29);
btnAddProducto.TabIndex = 11; btnAddProducto.TabIndex = 11;
@@ -125,7 +124,7 @@
// //
// btnrmProducto // btnrmProducto
// //
btnrmProducto.Location = new Point(12, 281); btnrmProducto.Location = new Point(520, 411);
btnrmProducto.Name = "btnrmProducto"; btnrmProducto.Name = "btnrmProducto";
btnrmProducto.Size = new Size(115, 29); btnrmProducto.Size = new Size(115, 29);
btnrmProducto.TabIndex = 12; btnrmProducto.TabIndex = 12;
@@ -139,29 +138,27 @@
dgvProveedor.AllowUserToDeleteRows = false; dgvProveedor.AllowUserToDeleteRows = false;
dgvProveedor.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dgvProveedor.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dgvProveedor.EditMode = DataGridViewEditMode.EditProgrammatically; dgvProveedor.EditMode = DataGridViewEditMode.EditProgrammatically;
dgvProveedor.Location = new Point(249, 32); dgvProveedor.Location = new Point(12, 32);
dgvProveedor.MultiSelect = false; dgvProveedor.MultiSelect = false;
dgvProveedor.Name = "dgvProveedor"; dgvProveedor.Name = "dgvProveedor";
dgvProveedor.RowTemplate.Height = 25;
dgvProveedor.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvProveedor.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvProveedor.Size = new Size(376, 338); dgvProveedor.Size = new Size(331, 338);
dgvProveedor.TabIndex = 13; dgvProveedor.TabIndex = 13;
dgvProveedor.CellClick += dgvProveedor_CellClick; dgvProveedor.CellClick += dgvProveedor_CellClick;
// //
// dgvPedido // dgvPedido
// //
dgvPedido.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dgvPedido.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dgvPedido.Location = new Point(11, 67); dgvPedido.Location = new Point(702, 32);
dgvPedido.Name = "dgvPedido"; dgvPedido.Name = "dgvPedido";
dgvPedido.RowTemplate.Height = 25;
dgvPedido.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvPedido.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvPedido.Size = new Size(227, 171); dgvPedido.Size = new Size(538, 408);
dgvPedido.TabIndex = 14; dgvPedido.TabIndex = 14;
// //
// label1 // label1
// //
label1.AutoSize = true; label1.AutoSize = true;
label1.Location = new Point(626, 9); label1.Location = new Point(349, 14);
label1.Name = "label1"; label1.Name = "label1";
label1.Size = new Size(56, 15); label1.Size = new Size(56, 15);
label1.TabIndex = 15; label1.TabIndex = 15;
@@ -170,7 +167,7 @@
// label3 // label3
// //
label3.AutoSize = true; label3.AutoSize = true;
label3.Location = new Point(11, 49); label3.Location = new Point(702, 14);
label3.Name = "label3"; label3.Name = "label3";
label3.Size = new Size(44, 15); label3.Size = new Size(44, 15);
label3.TabIndex = 16; label3.TabIndex = 16;
@@ -178,7 +175,7 @@
// //
// numCantidad // numCantidad
// //
numCantidad.Location = new Point(310, 376); numCantidad.Location = new Point(75, 376);
numCantidad.Maximum = new decimal(new int[] { 1410065407, 2, 0, 0 }); numCantidad.Maximum = new decimal(new int[] { 1410065407, 2, 0, 0 });
numCantidad.Name = "numCantidad"; numCantidad.Name = "numCantidad";
numCantidad.Size = new Size(120, 23); numCantidad.Size = new Size(120, 23);
@@ -187,7 +184,7 @@
// label4 // label4
// //
label4.AutoSize = true; label4.AutoSize = true;
label4.Location = new Point(249, 378); label4.Location = new Point(14, 378);
label4.Name = "label4"; label4.Name = "label4";
label4.Size = new Size(55, 15); label4.Size = new Size(55, 15);
label4.TabIndex = 18; label4.TabIndex = 18;
@@ -195,7 +192,7 @@
// //
// numPreciopropuesto // numPreciopropuesto
// //
numPreciopropuesto.Location = new Point(562, 376); numPreciopropuesto.Location = new Point(298, 378);
numPreciopropuesto.Maximum = new decimal(new int[] { 1410065407, 2, 0, 0 }); numPreciopropuesto.Maximum = new decimal(new int[] { 1410065407, 2, 0, 0 });
numPreciopropuesto.Name = "numPreciopropuesto"; numPreciopropuesto.Name = "numPreciopropuesto";
numPreciopropuesto.Size = new Size(120, 23); numPreciopropuesto.Size = new Size(120, 23);
@@ -204,7 +201,7 @@
// label5 // label5
// //
label5.AutoSize = true; label5.AutoSize = true;
label5.Location = new Point(466, 378); label5.Location = new Point(202, 380);
label5.Name = "label5"; label5.Name = "label5";
label5.Size = new Size(94, 15); label5.Size = new Size(94, 15);
label5.TabIndex = 20; label5.TabIndex = 20;
@@ -216,7 +213,7 @@
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
CancelButton = btnCerrar; CancelButton = btnCerrar;
ClientSize = new Size(985, 445); ClientSize = new Size(1252, 484);
Controls.Add(label5); Controls.Add(label5);
Controls.Add(numPreciopropuesto); Controls.Add(numPreciopropuesto);
Controls.Add(label4); Controls.Add(label4);

View File

@@ -42,32 +42,24 @@ namespace Vista
private void btnGuardar_Click(object sender, EventArgs e) private void btnGuardar_Click(object sender, EventArgs e)
{ {
// Crear una nueva instancia de Presupuesto
var presupuesto = new Presupuesto();
// Obtener el ID del NumericUpDown
int idPresupuesto = (int)numId.Value; // Asegúrate de que numId es el nombre correcto del NumericUpDown
presupuesto.Id = idPresupuesto;
// Obtener la fecha actual
presupuesto.Fecha = DateTime.Now;
// Obtener el proveedor seleccionado del DataGridView // Obtener el proveedor seleccionado del DataGridView
if (dgvProveedor.SelectedRows.Count == 0) if (dgvProveedor.SelectedRows.Count == 0)
{ {
MessageBox.Show("Por favor, seleccione un proveedor."); MessageBox.Show("Por favor, seleccione un proveedor.");
return; return;
} }
var proveedorSeleccionado = (Proveedor)dgvProveedor.SelectedRows[0].DataBoundItem; var proveedorSeleccionado = (Proveedor)dgvProveedor.SelectedRows[0].DataBoundItem;
presupuesto.Proveedor = proveedorSeleccionado; proveedorSeleccionado = ControladoraProveedores.Instance.Listar().First(x => x.Cuit == proveedorSeleccionado.Cuit);
// Obtener el estado habilitado y aceptado desde los controles si es necesario // Crear una nueva instancia de Presupuesto
presupuesto.Habilitado = true; // Ajusta según el estado actual var presupuesto = new Presupuesto
presupuesto.Aceptado = false; // Ajusta según el estado actual {
Fecha = DateTime.Now,
Proveedor = proveedorSeleccionado,
Habilitado = true,
Aceptado = false,
};
// Aquí deberías tener la lógica para asegurarte de que los detalles están añadidos al presupuesto
// Si ya tienes los detalles en un DataGridView, puedes hacerlo así:
foreach (var detalle in GetDetallesFromDataGridView()) foreach (var detalle in GetDetallesFromDataGridView())
{ {
presupuesto.AñadirDetalle(detalle); presupuesto.AñadirDetalle(detalle);
@@ -134,7 +126,7 @@ namespace Vista
// Crear el detalle del presupuesto // Crear el detalle del presupuesto
DetallePresupuesto detalle = new DetallePresupuesto DetallePresupuesto detalle = new DetallePresupuesto
{ {
Id = (int)numId.Value, Id = id++,
Producto = producto, Producto = producto,
Cantidad = cantidad, Cantidad = cantidad,
MontoCUPropuesto = Convert.ToDouble(numPreciopropuesto.Value), MontoCUPropuesto = Convert.ToDouble(numPreciopropuesto.Value),
@@ -153,11 +145,11 @@ namespace Vista
dgvPedido.DataSource = presupuesto.MostrarDetalles(); dgvPedido.DataSource = presupuesto.MostrarDetalles();
// Configura las columnas a mostrar y sus encabezados // Configura las columnas a mostrar y sus encabezados
foreach (DataGridViewColumn column in dgvPedido.Columns) //foreach (DataGridViewColumn column in dgvPedido.Columns)
{ //{
column.Visible = column.Name == "IdPresupuesto" || column.Name == "Cantidad" // column.Visible = column.Name == "IdPresupuesto" || column.Name == "Cantidad"
|| column.Name == "NombreDelProducto"; // || column.Name == "NombreDelProducto";
} //}
} }
catch (OverflowException ex) catch (OverflowException ex)
{ {

View File

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

View File

@@ -45,12 +45,12 @@
dgvProveedor = new DataGridView(); dgvProveedor = new DataGridView();
btnaddProveedor = new Button(); btnaddProveedor = new Button();
btnrmProveedor = new Button(); btnrmProveedor = new Button();
checkBox1 = new CheckBox(); checkpercedero = new CheckBox();
label8 = new Label(); label8 = new Label();
label9 = new Label(); label9 = new Label();
label10 = new Label(); label10 = new Label();
numericUpDown1 = new NumericUpDown(); numConsumoPreferente = new NumericUpDown();
numericUpDown2 = new NumericUpDown(); numvencimiento = new NumericUpDown();
cmbEnvase = new ComboBox(); cmbEnvase = new ComboBox();
dgvCategoria = new DataGridView(); dgvCategoria = new DataGridView();
label11 = new Label(); label11 = new Label();
@@ -61,8 +61,8 @@
((System.ComponentModel.ISupportInitialize)numPrecio).BeginInit(); ((System.ComponentModel.ISupportInitialize)numPrecio).BeginInit();
((System.ComponentModel.ISupportInitialize)dgvProveedorAñadido).BeginInit(); ((System.ComponentModel.ISupportInitialize)dgvProveedorAñadido).BeginInit();
((System.ComponentModel.ISupportInitialize)dgvProveedor).BeginInit(); ((System.ComponentModel.ISupportInitialize)dgvProveedor).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDown1).BeginInit(); ((System.ComponentModel.ISupportInitialize)numConsumoPreferente).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDown2).BeginInit(); ((System.ComponentModel.ISupportInitialize)numvencimiento).BeginInit();
((System.ComponentModel.ISupportInitialize)dgvCategoria).BeginInit(); ((System.ComponentModel.ISupportInitialize)dgvCategoria).BeginInit();
((System.ComponentModel.ISupportInitialize)dgvCategoriaAñadida).BeginInit(); ((System.ComponentModel.ISupportInitialize)dgvCategoriaAñadida).BeginInit();
SuspendLayout(); SuspendLayout();
@@ -148,9 +148,9 @@
// //
// btnacept // btnacept
// //
btnacept.Location = new Point(13, 311); btnacept.Location = new Point(14, 475);
btnacept.Name = "btnacept"; btnacept.Name = "btnacept";
btnacept.Size = new Size(72, 21); btnacept.Size = new Size(72, 30);
btnacept.TabIndex = 10; btnacept.TabIndex = 10;
btnacept.Text = "Aceptar"; btnacept.Text = "Aceptar";
btnacept.UseVisualStyleBackColor = true; btnacept.UseVisualStyleBackColor = true;
@@ -158,9 +158,9 @@
// //
// btncancel // btncancel
// //
btncancel.Location = new Point(105, 311); btncancel.Location = new Point(92, 475);
btncancel.Name = "btncancel"; btncancel.Name = "btncancel";
btncancel.Size = new Size(68, 21); btncancel.Size = new Size(69, 30);
btncancel.TabIndex = 11; btncancel.TabIndex = 11;
btncancel.Text = "Cancelar"; btncancel.Text = "Cancelar";
btncancel.UseVisualStyleBackColor = true; btncancel.UseVisualStyleBackColor = true;
@@ -169,7 +169,7 @@
// label6 // label6
// //
label6.AutoSize = true; label6.AutoSize = true;
label6.Location = new Point(652, 216); label6.Location = new Point(679, 275);
label6.Name = "label6"; label6.Name = "label6";
label6.Size = new Size(123, 15); label6.Size = new Size(123, 15);
label6.TabIndex = 12; label6.TabIndex = 12;
@@ -178,7 +178,7 @@
// label7 // label7
// //
label7.AutoSize = true; label7.AutoSize = true;
label7.Location = new Point(652, 9); label7.Location = new Point(679, 9);
label7.Name = "label7"; label7.Name = "label7";
label7.Size = new Size(72, 15); label7.Size = new Size(72, 15);
label7.TabIndex = 13; label7.TabIndex = 13;
@@ -190,25 +190,25 @@
dgvProveedorAñadido.AllowUserToDeleteRows = false; dgvProveedorAñadido.AllowUserToDeleteRows = false;
dgvProveedorAñadido.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dgvProveedorAñadido.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dgvProveedorAñadido.EditMode = DataGridViewEditMode.EditProgrammatically; dgvProveedorAñadido.EditMode = DataGridViewEditMode.EditProgrammatically;
dgvProveedorAñadido.Location = new Point(652, 234); dgvProveedorAñadido.Location = new Point(679, 293);
dgvProveedorAñadido.Name = "dgvProveedorAñadido"; dgvProveedorAñadido.Name = "dgvProveedorAñadido";
dgvProveedorAñadido.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvProveedorAñadido.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvProveedorAñadido.Size = new Size(240, 150); dgvProveedorAñadido.Size = new Size(510, 212);
dgvProveedorAñadido.TabIndex = 14; dgvProveedorAñadido.TabIndex = 14;
// //
// dgvProveedor // dgvProveedor
// //
dgvProveedor.AllowUserToAddRows = false; dgvProveedor.AllowUserToAddRows = false;
dgvProveedor.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dgvProveedor.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dgvProveedor.Location = new Point(652, 30); dgvProveedor.Location = new Point(679, 30);
dgvProveedor.Name = "dgvProveedor"; dgvProveedor.Name = "dgvProveedor";
dgvProveedor.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvProveedor.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvProveedor.Size = new Size(240, 150); dgvProveedor.Size = new Size(510, 215);
dgvProveedor.TabIndex = 15; dgvProveedor.TabIndex = 15;
// //
// btnaddProveedor // btnaddProveedor
// //
btnaddProveedor.Location = new Point(652, 186); btnaddProveedor.Location = new Point(679, 251);
btnaddProveedor.Name = "btnaddProveedor"; btnaddProveedor.Name = "btnaddProveedor";
btnaddProveedor.Size = new Size(72, 21); btnaddProveedor.Size = new Size(72, 21);
btnaddProveedor.TabIndex = 16; btnaddProveedor.TabIndex = 16;
@@ -218,7 +218,7 @@
// //
// btnrmProveedor // btnrmProveedor
// //
btnrmProveedor.Location = new Point(820, 186); btnrmProveedor.Location = new Point(757, 251);
btnrmProveedor.Name = "btnrmProveedor"; btnrmProveedor.Name = "btnrmProveedor";
btnrmProveedor.Size = new Size(72, 21); btnrmProveedor.Size = new Size(72, 21);
btnrmProveedor.TabIndex = 17; btnrmProveedor.TabIndex = 17;
@@ -226,21 +226,21 @@
btnrmProveedor.UseVisualStyleBackColor = true; btnrmProveedor.UseVisualStyleBackColor = true;
btnrmProveedor.Click += btnrmProveedor_Click; btnrmProveedor.Click += btnrmProveedor_Click;
// //
// checkBox1 // checkpercedero
// //
checkBox1.AutoSize = true; checkpercedero.AutoSize = true;
checkBox1.Location = new Point(6, 183); checkpercedero.Location = new Point(14, 196);
checkBox1.Name = "checkBox1"; checkpercedero.Name = "checkpercedero";
checkBox1.Size = new Size(79, 19); checkpercedero.Size = new Size(79, 19);
checkBox1.TabIndex = 18; checkpercedero.TabIndex = 18;
checkBox1.Text = "Percedero"; checkpercedero.Text = "Percedero";
checkBox1.UseVisualStyleBackColor = true; checkpercedero.UseVisualStyleBackColor = true;
checkBox1.CheckedChanged += checkBox1_CheckedChanged; checkpercedero.CheckedChanged += checkpercedero_CheckedChanged;
// //
// label8 // label8
// //
label8.AutoSize = true; label8.AutoSize = true;
label8.Location = new Point(24, 205); label8.Location = new Point(12, 218);
label8.Name = "label8"; label8.Name = "label8";
label8.Size = new Size(185, 15); label8.Size = new Size(185, 15);
label8.TabIndex = 20; label8.TabIndex = 20;
@@ -249,7 +249,7 @@
// label9 // label9
// //
label9.AutoSize = true; label9.AutoSize = true;
label9.Location = new Point(140, 264); label9.Location = new Point(128, 277);
label9.Name = "label9"; label9.Name = "label9";
label9.Size = new Size(69, 15); label9.Size = new Size(69, 15);
label9.TabIndex = 21; label9.TabIndex = 21;
@@ -258,35 +258,33 @@
// label10 // label10
// //
label10.AutoSize = true; label10.AutoSize = true;
label10.Location = new Point(67, 234); label10.Location = new Point(55, 247);
label10.Name = "label10"; label10.Name = "label10";
label10.Size = new Size(142, 15); label10.Size = new Size(142, 15);
label10.TabIndex = 22; label10.TabIndex = 22;
label10.Text = "Meses Hasta Vencimiento"; label10.Text = "Meses Hasta Vencimiento";
// //
// numericUpDown1 // numConsumoPreferente
// //
numericUpDown1.Enabled = false; numConsumoPreferente.Enabled = false;
numericUpDown1.Location = new Point(229, 197); numConsumoPreferente.Location = new Point(217, 210);
numericUpDown1.Name = "numericUpDown1"; numConsumoPreferente.Name = "numConsumoPreferente";
numericUpDown1.Size = new Size(120, 23); numConsumoPreferente.Size = new Size(120, 23);
numericUpDown1.TabIndex = 23; numConsumoPreferente.TabIndex = 23;
numericUpDown1.ValueChanged += numericUpDown1_ValueChanged;
// //
// numericUpDown2 // numvencimiento
// //
numericUpDown2.Enabled = false; numvencimiento.Enabled = false;
numericUpDown2.Location = new Point(228, 227); numvencimiento.Location = new Point(216, 240);
numericUpDown2.Name = "numericUpDown2"; numvencimiento.Name = "numvencimiento";
numericUpDown2.Size = new Size(120, 23); numvencimiento.Size = new Size(120, 23);
numericUpDown2.TabIndex = 24; numvencimiento.TabIndex = 24;
numericUpDown2.ValueChanged += numericUpDown2_ValueChanged;
// //
// cmbEnvase // cmbEnvase
// //
cmbEnvase.DropDownStyle = ComboBoxStyle.DropDownList; cmbEnvase.DropDownStyle = ComboBoxStyle.DropDownList;
cmbEnvase.FormattingEnabled = true; cmbEnvase.FormattingEnabled = true;
cmbEnvase.Location = new Point(227, 256); cmbEnvase.Location = new Point(215, 269);
cmbEnvase.Name = "cmbEnvase"; cmbEnvase.Name = "cmbEnvase";
cmbEnvase.Size = new Size(121, 23); cmbEnvase.Size = new Size(121, 23);
cmbEnvase.TabIndex = 25; cmbEnvase.TabIndex = 25;
@@ -300,13 +298,13 @@
dgvCategoria.Location = new Point(373, 30); dgvCategoria.Location = new Point(373, 30);
dgvCategoria.Name = "dgvCategoria"; dgvCategoria.Name = "dgvCategoria";
dgvCategoria.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvCategoria.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvCategoria.Size = new Size(240, 150); dgvCategoria.Size = new Size(300, 215);
dgvCategoria.TabIndex = 26; dgvCategoria.TabIndex = 26;
// //
// label11 // label11
// //
label11.AutoSize = true; label11.AutoSize = true;
label11.Location = new Point(373, 216); label11.Location = new Point(373, 275);
label11.Name = "label11"; label11.Name = "label11";
label11.Size = new Size(108, 15); label11.Size = new Size(108, 15);
label11.TabIndex = 27; label11.TabIndex = 27;
@@ -318,29 +316,31 @@
dgvCategoriaAñadida.AllowUserToDeleteRows = false; dgvCategoriaAñadida.AllowUserToDeleteRows = false;
dgvCategoriaAñadida.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dgvCategoriaAñadida.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dgvCategoriaAñadida.EditMode = DataGridViewEditMode.EditProgrammatically; dgvCategoriaAñadida.EditMode = DataGridViewEditMode.EditProgrammatically;
dgvCategoriaAñadida.Location = new Point(373, 234); dgvCategoriaAñadida.Location = new Point(373, 293);
dgvCategoriaAñadida.Name = "dgvCategoriaAñadida"; dgvCategoriaAñadida.Name = "dgvCategoriaAñadida";
dgvCategoriaAñadida.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvCategoriaAñadida.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvCategoriaAñadida.Size = new Size(240, 150); dgvCategoriaAñadida.Size = new Size(300, 212);
dgvCategoriaAñadida.TabIndex = 28; dgvCategoriaAñadida.TabIndex = 28;
// //
// btnaddCategoria // btnaddCategoria
// //
btnaddCategoria.Location = new Point(373, 186); btnaddCategoria.Location = new Point(373, 251);
btnaddCategoria.Name = "btnaddCategoria"; btnaddCategoria.Name = "btnaddCategoria";
btnaddCategoria.Size = new Size(72, 21); btnaddCategoria.Size = new Size(72, 21);
btnaddCategoria.TabIndex = 29; btnaddCategoria.TabIndex = 29;
btnaddCategoria.Text = "Añadir"; btnaddCategoria.Text = "Añadir";
btnaddCategoria.UseVisualStyleBackColor = true; btnaddCategoria.UseVisualStyleBackColor = true;
btnaddCategoria.Click += btnaddCategoria_Click;
// //
// btnrmCategoria // btnrmCategoria
// //
btnrmCategoria.Location = new Point(541, 186); btnrmCategoria.Location = new Point(451, 251);
btnrmCategoria.Name = "btnrmCategoria"; btnrmCategoria.Name = "btnrmCategoria";
btnrmCategoria.Size = new Size(72, 21); btnrmCategoria.Size = new Size(72, 21);
btnrmCategoria.TabIndex = 30; btnrmCategoria.TabIndex = 30;
btnrmCategoria.Text = "Eliminar"; btnrmCategoria.Text = "Eliminar";
btnrmCategoria.UseVisualStyleBackColor = true; btnrmCategoria.UseVisualStyleBackColor = true;
btnrmCategoria.Click += btnrmCategoria_Click;
// //
// FrmProducto // FrmProducto
// //
@@ -348,19 +348,19 @@
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
CancelButton = btncancel; CancelButton = btncancel;
ClientSize = new Size(1219, 517); ClientSize = new Size(1239, 517);
Controls.Add(btnrmCategoria); Controls.Add(btnrmCategoria);
Controls.Add(btnaddCategoria); Controls.Add(btnaddCategoria);
Controls.Add(dgvCategoriaAñadida); Controls.Add(dgvCategoriaAñadida);
Controls.Add(label11); Controls.Add(label11);
Controls.Add(dgvCategoria); Controls.Add(dgvCategoria);
Controls.Add(cmbEnvase); Controls.Add(cmbEnvase);
Controls.Add(numericUpDown2); Controls.Add(numvencimiento);
Controls.Add(numericUpDown1); Controls.Add(numConsumoPreferente);
Controls.Add(label10); Controls.Add(label10);
Controls.Add(label9); Controls.Add(label9);
Controls.Add(label8); Controls.Add(label8);
Controls.Add(checkBox1); Controls.Add(checkpercedero);
Controls.Add(btnrmProveedor); Controls.Add(btnrmProveedor);
Controls.Add(btnaddProveedor); Controls.Add(btnaddProveedor);
Controls.Add(dgvProveedor); Controls.Add(dgvProveedor);
@@ -384,8 +384,8 @@
((System.ComponentModel.ISupportInitialize)numPrecio).EndInit(); ((System.ComponentModel.ISupportInitialize)numPrecio).EndInit();
((System.ComponentModel.ISupportInitialize)dgvProveedorAñadido).EndInit(); ((System.ComponentModel.ISupportInitialize)dgvProveedorAñadido).EndInit();
((System.ComponentModel.ISupportInitialize)dgvProveedor).EndInit(); ((System.ComponentModel.ISupportInitialize)dgvProveedor).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDown1).EndInit(); ((System.ComponentModel.ISupportInitialize)numConsumoPreferente).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDown2).EndInit(); ((System.ComponentModel.ISupportInitialize)numvencimiento).EndInit();
((System.ComponentModel.ISupportInitialize)dgvCategoria).EndInit(); ((System.ComponentModel.ISupportInitialize)dgvCategoria).EndInit();
((System.ComponentModel.ISupportInitialize)dgvCategoriaAñadida).EndInit(); ((System.ComponentModel.ISupportInitialize)dgvCategoriaAñadida).EndInit();
ResumeLayout(false); ResumeLayout(false);
@@ -411,12 +411,12 @@
private DataGridView dgvProveedor; private DataGridView dgvProveedor;
private Button btnaddProveedor; private Button btnaddProveedor;
private Button btnrmProveedor; private Button btnrmProveedor;
private CheckBox checkBox1; private CheckBox checkpercedero;
private Label label8; private Label label8;
private Label label9; private Label label9;
private Label label10; private Label label10;
private NumericUpDown numericUpDown1; private NumericUpDown numConsumoPreferente;
private NumericUpDown numericUpDown2; private NumericUpDown numvencimiento;
private ComboBox cmbEnvase; private ComboBox cmbEnvase;
private DataGridView dgvCategoria; private DataGridView dgvCategoria;
private Label label11; private Label label11;

View File

@@ -20,13 +20,13 @@ namespace Vista
public FrmProducto(Producto? producto = null) public FrmProducto(Producto? producto = null)
{ {
InitializeComponent(); InitializeComponent();
CargarCategorias(); CargarNumid();
CargarTabla(); CargarTabla();
cargarcombo(); cargarcombo();
if (producto != null) if (producto != null)
{ {
nuevoproducto = producto; nuevoproducto = ControladoraProductos.Instance.MostrarPorId(producto);
mod = true; mod = true;
InicializarFormulario(); InicializarFormulario();
} }
@@ -43,7 +43,19 @@ namespace Vista
numPrecio.Value = (decimal)nuevoproducto.Precio; numPrecio.Value = (decimal)nuevoproducto.Precio;
checkHabilitado.Checked = nuevoproducto.Habilitado; checkHabilitado.Checked = nuevoproducto.Habilitado;
dgvProveedorAñadido.DataSource = nuevoproducto.proveedores.AsReadOnly(); dgvProveedorAñadido.DataSource = nuevoproducto.proveedores.AsReadOnly();
checkpercedero.Checked = nuevoproducto.EsPerecedero;
checkpercedero.Enabled = false;
if (nuevoproducto.EsPerecedero)
{
var Prodperc = (ProductoPercedero)nuevoproducto;
numConsumoPreferente.Value = Prodperc.MesesHastaConsumoPreferente;
numvencimiento.Value = Prodperc.MesesHastaVencimiento;
}
else
{
}
} }
private void CargarTabla() private void CargarTabla()
@@ -52,16 +64,22 @@ namespace Vista
dgvProveedor.DataSource = ControladoraProductos.Instance.ListarProveedores(); dgvProveedor.DataSource = ControladoraProductos.Instance.ListarProveedores();
if (mod) if (mod)
{ {
foreach (Proveedor prov in ControladoraProductos.Instance.ListarProveedores(nuevoproducto)) dgvProveedorAñadido.DataSource = ControladoraProductos.Instance.ListarProveedores(nuevoproducto);
{
nuevoproducto.AñadirProveedor(prov);
}
}
} }
private void CargarCategorias() dgvCategoria.DataSource = null;
dgvCategoria.DataSource = ControladoraCategorias.Instance.Listar();
if (mod)
{ {
dgvCategoriaAñadida.DataSource = ControladoraProductos.Instance.ListarCategorias(nuevoproducto);
}
}
private void CargarNumid()
{
var listprod = ControladoraProductos.Instance.Listar(); var listprod = ControladoraProductos.Instance.Listar();
numId.Value = (listprod.Count > 0) ? numId.Value = (listprod.Count > 0) ?
listprod.Max(x => x.Id + 1) : listprod.Max(x => x.Id + 1) :
@@ -94,14 +112,14 @@ namespace Vista
//devolucion += "Debe seleccionar una categoría.\n"; //devolucion += "Debe seleccionar una categoría.\n";
// Validar Tipo de Producto // Validar Tipo de Producto
if (!checkBox1.Checked && cmbEnvase.SelectedItem == null) if (!checkpercedero.Checked && cmbEnvase.SelectedItem == null)
{ {
devolucion += "Debe seleccionar un tipo de envase para el producto no perecedero.\n"; devolucion += "Debe seleccionar un tipo de envase para el producto no perecedero.\n";
} }
if (checkBox1.Checked) // Producto Perecedero if (checkpercedero.Checked) // Producto Perecedero
{ {
if (numericUpDown1.Value <= 0 || numericUpDown2.Value <= 0) if (numConsumoPreferente.Value <= 0 || numvencimiento.Value <= 0)
{ {
devolucion += "Los meses hasta consumo preferente y vencimiento deben ser mayores a cero.\n"; devolucion += "Los meses hasta consumo preferente y vencimiento deben ser mayores a cero.\n";
} }
@@ -123,23 +141,31 @@ namespace Vista
if (ValidarDatos()) if (ValidarDatos())
{ {
if (checkBox1.Checked) // Producto Perecedero if (checkpercedero.Checked) // Producto Perecedero
{ {
var productoPerecedero = new ProductoPercedero var productoPerecedero = new ProductoPercedero
{ {
Id = (int)numId.Value,
Nombre = txtNombre.Text, Nombre = txtNombre.Text,
Precio = (double)numPrecio.Value, Precio = (double)numPrecio.Value,
Habilitado = checkHabilitado.Checked, Habilitado = checkHabilitado.Checked,
MesesHastaConsumoPreferente = (int)numericUpDown1.Value, MesesHastaConsumoPreferente = (int)numConsumoPreferente.Value,
MesesHastaVencimiento = (int)numericUpDown2.Value, MesesHastaVencimiento = (int)numvencimiento.Value,
EsPerecedero = checkpercedero.Checked
}; };
foreach (var proveedor in nuevoproducto.proveedores.AsReadOnly()) if (mod) productoPerecedero.Id = (int)numId.Value;
foreach (var proveedor in nuevoproducto.proveedores)
{ {
productoPerecedero.AñadirProveedor(proveedor); productoPerecedero.AñadirProveedor(proveedor);
} }
foreach (var cat in nuevoproducto.categorias)
{
productoPerecedero.AñadirCategoria(cat);
}
string mensaje = mod string mensaje = mod
? ControladoraProductoPercedero.Instance.Modificar(productoPerecedero) ? ControladoraProductoPercedero.Instance.Modificar(productoPerecedero)
: ControladoraProductoPercedero.Instance.Añadir(productoPerecedero); : ControladoraProductoPercedero.Instance.Añadir(productoPerecedero);
@@ -150,17 +176,23 @@ namespace Vista
{ {
var productoNoPerecedero = new ProductoNoPercedero var productoNoPerecedero = new ProductoNoPercedero
{ {
Id = (int)numId.Value,
Nombre = txtNombre.Text, Nombre = txtNombre.Text,
Precio = (double)numPrecio.Value, Precio = (double)numPrecio.Value,
Habilitado = checkHabilitado.Checked, Habilitado = checkHabilitado.Checked,
TipoDeEnvase = (EnvaseTipo)cmbEnvase.SelectedItem, TipoDeEnvase = (EnvaseTipo)cmbEnvase.SelectedItem,
}; };
foreach (var proveedor in nuevoproducto.proveedores.AsReadOnly()) if (mod) productoNoPerecedero.Id = (int)numId.Value;
foreach (var proveedor in nuevoproducto.proveedores)
{ {
productoNoPerecedero.AñadirProveedor(proveedor); productoNoPerecedero.AñadirProveedor(proveedor);
} }
foreach (var cat in nuevoproducto.categorias)
{
productoNoPerecedero.AñadirCategoria(cat);
}
string mensaje = mod string mensaje = mod
? ControladoraProductoNoPercedero.Instance.Modificar(productoNoPerecedero) ? ControladoraProductoNoPercedero.Instance.Modificar(productoNoPerecedero)
: ControladoraProductoNoPercedero.Instance.Añadir(productoNoPerecedero); : ControladoraProductoNoPercedero.Instance.Añadir(productoNoPerecedero);
@@ -177,11 +209,6 @@ namespace Vista
this.Close(); this.Close();
} }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void btnaddProveedor_Click(object sender, EventArgs e) private void btnaddProveedor_Click(object sender, EventArgs e)
{ {
if (dgvProveedor.SelectedRows.Count > 0) if (dgvProveedor.SelectedRows.Count > 0)
@@ -232,23 +259,62 @@ namespace Vista
} }
} }
private void checkBox1_CheckedChanged(object sender, EventArgs e) private void btnaddCategoria_Click(object sender, EventArgs e)
{ {
bool esPerecedero = checkBox1.Checked; if (dgvCategoria.SelectedRows.Count > 0)
{
foreach (DataGridViewRow selectedRow in dgvCategoria.SelectedRows)
{
var cat = (Categoria)selectedRow.DataBoundItem;
var checkcolicion = nuevoproducto.categorias.Contains(cat);
if (checkcolicion)
{
MessageBox.Show("La Categoria ya fue cargada");
return;
}
nuevoproducto.AñadirCategoria(cat);
dgvCategoriaAñadida.DataSource = null;
dgvCategoriaAñadida.DataSource = nuevoproducto.categorias.AsReadOnly();
}
}
else
{
MessageBox.Show("Por favor, selecciona una fila para añadir Categoria al producto.");
}
}
numericUpDown1.Enabled = esPerecedero; private void checkpercedero_CheckedChanged(object sender, EventArgs e)
numericUpDown2.Enabled = esPerecedero; {
bool esPerecedero = checkpercedero.Checked;
numConsumoPreferente.Enabled = esPerecedero;
numvencimiento.Enabled = esPerecedero;
cmbEnvase.Enabled = !esPerecedero; cmbEnvase.Enabled = !esPerecedero;
} }
private void numericUpDown2_ValueChanged(object sender, EventArgs e) private void btnrmCategoria_Click(object sender, EventArgs e)
{ {
try
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{ {
if (dgvCategoriaAñadida.SelectedRows.Count > 0)
{
foreach (DataGridViewRow selectedRow in dgvCategoriaAñadida.SelectedRows)
{
var cat = (Categoria)selectedRow.DataBoundItem;
nuevoproducto.EliminarCategoria(cat);
dgvCategoriaAñadida.DataSource = null;
dgvCategoriaAñadida.DataSource = nuevoproducto.categorias.AsReadOnly();
}
}
else
{
MessageBox.Show("Por favor, selecciona una fila para eliminar Categoria del producto.");
}
}
catch (Exception ex)
{
MessageBox.Show($"Error al eliminar proveedor: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
} }
} }
} }

View File

@@ -72,7 +72,7 @@
groupBox1.Controls.Add(BtnEliminar); groupBox1.Controls.Add(BtnEliminar);
groupBox1.Location = new Point(12, 0); groupBox1.Location = new Point(12, 0);
groupBox1.Name = "groupBox1"; groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(1196, 305); groupBox1.Size = new Size(1258, 305);
groupBox1.TabIndex = 5; groupBox1.TabIndex = 5;
groupBox1.TabStop = false; groupBox1.TabStop = false;
// //
@@ -106,7 +106,7 @@
// label3 // label3
// //
label3.AutoSize = true; label3.AutoSize = true;
label3.Location = new Point(613, 9); label3.Location = new Point(675, 9);
label3.Name = "label3"; label3.Name = "label3";
label3.Size = new Size(72, 15); label3.Size = new Size(72, 15);
label3.TabIndex = 10; label3.TabIndex = 10;
@@ -115,7 +115,7 @@
// dgvProveedores // dgvProveedores
// //
dgvProveedores.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dgvProveedores.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dgvProveedores.Location = new Point(613, 22); dgvProveedores.Location = new Point(675, 22);
dgvProveedores.Name = "dgvProveedores"; dgvProveedores.Name = "dgvProveedores";
dgvProveedores.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvProveedores.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvProveedores.Size = new Size(577, 235); dgvProveedores.Size = new Size(577, 235);
@@ -138,7 +138,7 @@
dgvProductos.Location = new Point(6, 22); dgvProductos.Location = new Point(6, 22);
dgvProductos.Name = "dgvProductos"; dgvProductos.Name = "dgvProductos";
dgvProductos.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvProductos.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvProductos.Size = new Size(591, 235); dgvProductos.Size = new Size(663, 235);
dgvProductos.TabIndex = 3; dgvProductos.TabIndex = 3;
dgvProductos.CellClick += dgvProductos_CellClick; dgvProductos.CellClick += dgvProductos_CellClick;
// //
@@ -187,6 +187,7 @@
numConsumoPreferente.Enabled = false; numConsumoPreferente.Enabled = false;
numConsumoPreferente.Location = new Point(164, 33); numConsumoPreferente.Location = new Point(164, 33);
numConsumoPreferente.Name = "numConsumoPreferente"; numConsumoPreferente.Name = "numConsumoPreferente";
numConsumoPreferente.ReadOnly = true;
numConsumoPreferente.Size = new Size(120, 23); numConsumoPreferente.Size = new Size(120, 23);
numConsumoPreferente.TabIndex = 15; numConsumoPreferente.TabIndex = 15;
// //
@@ -195,6 +196,7 @@
numHastaVencimiento.Enabled = false; numHastaVencimiento.Enabled = false;
numHastaVencimiento.Location = new Point(164, 68); numHastaVencimiento.Location = new Point(164, 68);
numHastaVencimiento.Name = "numHastaVencimiento"; numHastaVencimiento.Name = "numHastaVencimiento";
numHastaVencimiento.ReadOnly = true;
numHastaVencimiento.Size = new Size(120, 23); numHastaVencimiento.Size = new Size(120, 23);
numHastaVencimiento.TabIndex = 17; numHastaVencimiento.TabIndex = 17;
// //
@@ -261,7 +263,7 @@
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1237, 616); ClientSize = new Size(1274, 616);
Controls.Add(groupBox3); Controls.Add(groupBox3);
Controls.Add(groupBox2); Controls.Add(groupBox2);
Controls.Add(label1); Controls.Add(label1);

View File

@@ -59,13 +59,6 @@ namespace Vista
HeaderText = "Habilitado", HeaderText = "Habilitado",
Name = "Habilitado" Name = "Habilitado"
}; };
// Crear una columna para la categoría (mostrando la descripción)
var colCategoria = new DataGridViewTextBoxColumn
{
DataPropertyName = "CategoriaDescripcion",
HeaderText = "Categoría",
Name = "Categoria"
};
var colPercedero = new DataGridViewTextBoxColumn var colPercedero = new DataGridViewTextBoxColumn
{ {
@@ -80,20 +73,12 @@ namespace Vista
dgvProductos.Columns.Add(colNombre); dgvProductos.Columns.Add(colNombre);
dgvProductos.Columns.Add(colPrecio); dgvProductos.Columns.Add(colPrecio);
dgvProductos.Columns.Add(colHabilitado); dgvProductos.Columns.Add(colHabilitado);
dgvProductos.Columns.Add(colCategoria);
dgvProductos.Columns.Add(colPercedero); dgvProductos.Columns.Add(colPercedero);
} }
private void ActualizarGrilla() private void ActualizarGrilla()
{ {
// Obtén todos los productos de la controladora o la fuente de datos
var todosLosProductos = ControladoraProductos.Instance.Listar();
dgvProductos.DataSource = null; dgvProductos.DataSource = null;
dgvCategorias.DataSource = null;
var categorias = ControladoraProductos.Instance.ListarCategorias();
dgvCategorias.DataSource = categorias;
// Obtener la lista de productos y proyectar los datos // Obtener la lista de productos y proyectar los datos
var productos = ControladoraProductos.Instance.Listar() var productos = ControladoraProductos.Instance.Listar()
@@ -169,7 +154,11 @@ namespace Vista
{ {
Id = Convert.ToInt32(selectedRow.Cells["Id"].Value) Id = Convert.ToInt32(selectedRow.Cells["Id"].Value)
}; };
bool esPercedero = Convert.ToBoolean(selectedRow.Cells["EsPerecedero"].Value);
bool esPercedero = (ControladoraProductos.Instance.MostrarPorId(Producto).GetType().ToString() == "Entidades.ProductoPercedero") ?
true : false;
// Nacho evadamos usar esto porque da error mejor usa el classname
//bool esPercedero = Convert.ToBoolean(selectedRow.Cells["EsPerecedero"].Value);
if (esPercedero) if (esPercedero)
{ {
ProductoPercedero prod = (ProductoPercedero)ControladoraProductos.Instance.MostrarPorId(Producto); ProductoPercedero prod = (ProductoPercedero)ControladoraProductos.Instance.MostrarPorId(Producto);
@@ -188,7 +177,7 @@ namespace Vista
if (prod == null) return; if (prod == null) return;
cmbTipoEnvase.Items.Clear(); cmbTipoEnvase.Items.Clear();
cmbTipoEnvase.Items.Add(prod.TipoDeEnvase.GetType().FullName); cmbTipoEnvase.Items.Add(prod.TipoDeEnvase.ToString());
cmbTipoEnvase.SelectedIndex = 0; cmbTipoEnvase.SelectedIndex = 0;
numHastaVencimiento.Value = 0; numHastaVencimiento.Value = 0;
@@ -211,10 +200,23 @@ namespace Vista
{ {
if (dgvProductos.SelectedRows.Count == 0) return; if (dgvProductos.SelectedRows.Count == 0) return;
ActualizarGrillaProveedores(); ActualizarGrillaProveedores();
ActualizarGrillaCategorias();
ActualizarGeneralizaciones(); ActualizarGeneralizaciones();
MostrarStock(); MostrarStock();
} }
private void ActualizarGrillaCategorias()
{
if (dgvProductos.SelectedRows.Count > 0)
{
Producto producto = new Producto
{
Id = Convert.ToInt32(dgvProductos.SelectedRows[0].Cells["Id"].Value),
};
dgvCategorias.DataSource = ControladoraProductos.Instance.ListarCategorias(producto);
}
}
private void btnModificar_Click(object sender, EventArgs e) private void btnModificar_Click(object sender, EventArgs e)
{ {
if (dgvProductos.SelectedRows.Count < 1) if (dgvProductos.SelectedRows.Count < 1)
@@ -226,9 +228,10 @@ namespace Vista
Producto producto = new Producto Producto producto = new Producto
{ {
Id = Convert.ToInt32(dgvProductos.SelectedRows[0].Cells["Id"].Value), Id = Convert.ToInt32(dgvProductos.SelectedRows[0].Cells["Id"].Value),
Nombre = dgvProductos.SelectedRows[0].Cells["Nombre"].Value as String, //Nombre = dgvProductos.SelectedRows[0].Cells["Nombre"].Value as String,
Precio = Convert.ToDouble(dgvProductos.SelectedRows[0].Cells["Precio"].Value), //Precio = Convert.ToDouble(dgvProductos.SelectedRows[0].Cells["Precio"].Value),
Habilitado = Convert.ToBoolean(dgvProductos.SelectedRows[0].Cells["Habilitado"].Value), //Habilitado = Convert.ToBoolean(dgvProductos.SelectedRows[0].Cells["Habilitado"].Value),
//EsPerecedero = Convert.ToBoolean(dgvProductos.SelectedRows[0].Cells["EsPerecedero"].Value)
}; };
foreach (Proveedor prov in ControladoraProductos.Instance.ListarProveedores(producto)) foreach (Proveedor prov in ControladoraProductos.Instance.ListarProveedores(producto))
{ {

View File

@@ -140,7 +140,7 @@
// //
// BtnCancelar // BtnCancelar
// //
BtnCancelar.Location = new Point(322, 195); BtnCancelar.Location = new Point(135, 195);
BtnCancelar.Name = "BtnCancelar"; BtnCancelar.Name = "BtnCancelar";
BtnCancelar.Size = new Size(75, 23); BtnCancelar.Size = new Size(75, 23);
BtnCancelar.TabIndex = 11; BtnCancelar.TabIndex = 11;
@@ -154,7 +154,7 @@
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
CancelButton = BtnCancelar; CancelButton = BtnCancelar;
ClientSize = new Size(409, 230); ClientSize = new Size(228, 230);
Controls.Add(BtnCancelar); Controls.Add(BtnCancelar);
Controls.Add(label4); Controls.Add(label4);
Controls.Add(checkBoxHabilitado); Controls.Add(checkBoxHabilitado);

View File

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

View File

@@ -45,7 +45,7 @@
groupBox1.Controls.Add(BtnModificar); groupBox1.Controls.Add(BtnModificar);
groupBox1.Location = new Point(12, 12); groupBox1.Location = new Point(12, 12);
groupBox1.Name = "groupBox1"; groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(776, 351); groupBox1.Size = new Size(1228, 351);
groupBox1.TabIndex = 5; groupBox1.TabIndex = 5;
groupBox1.TabStop = false; groupBox1.TabStop = false;
// //
@@ -60,9 +60,8 @@
dataGridView1.Location = new Point(6, 22); dataGridView1.Location = new Point(6, 22);
dataGridView1.Name = "dataGridView1"; dataGridView1.Name = "dataGridView1";
dataGridView1.ReadOnly = true; dataGridView1.ReadOnly = true;
dataGridView1.RowTemplate.Height = 25;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.Size = new Size(550, 235); dataGridView1.Size = new Size(1216, 235);
dataGridView1.TabIndex = 3; dataGridView1.TabIndex = 3;
// //
// BtnAdd // BtnAdd
@@ -99,7 +98,7 @@
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 382); ClientSize = new Size(1252, 382);
Controls.Add(groupBox1); Controls.Add(groupBox1);
Name = "FrmProveedores"; Name = "FrmProveedores";
Text = "Proveedores"; Text = "Proveedores";

View File

@@ -67,14 +67,12 @@ namespace Vista
var remito = new Remito var remito = new Remito
{ {
Id = Convert.ToInt32(numId.Value),
Proveedor = orden.Proveedor Proveedor = orden.Proveedor
}; };
foreach (var detalle in ControladoraRemito.Instance.ListarDetallesOrdenesDeCompra(orden)) foreach (var detalle in ControladoraRemito.Instance.ListarDetallesOrdenesDeCompra(orden))
{ {
Lote lote = new Lote Lote lote = new Lote
{ {
Id = detalle.Id,
Cantidad = detalle.Cantidad, Cantidad = detalle.Cantidad,
Fecha = DateTime.Now, Fecha = DateTime.Now,
Habilitado = true, Habilitado = true,

View File

@@ -53,7 +53,7 @@
groupBox1.Controls.Add(BtnAdd); groupBox1.Controls.Add(BtnAdd);
groupBox1.Location = new Point(12, 12); groupBox1.Location = new Point(12, 12);
groupBox1.Name = "groupBox1"; groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(1183, 432); groupBox1.Size = new Size(1257, 478);
groupBox1.TabIndex = 5; groupBox1.TabIndex = 5;
groupBox1.TabStop = false; groupBox1.TabStop = false;
// //
@@ -91,11 +91,10 @@
dgvTodosLotes.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dgvTodosLotes.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dgvTodosLotes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dgvTodosLotes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dgvTodosLotes.EditMode = DataGridViewEditMode.EditProgrammatically; dgvTodosLotes.EditMode = DataGridViewEditMode.EditProgrammatically;
dgvTodosLotes.Location = new Point(0, 319); dgvTodosLotes.Location = new Point(6, 319);
dgvTodosLotes.Name = "dgvTodosLotes"; dgvTodosLotes.Name = "dgvTodosLotes";
dgvTodosLotes.RowTemplate.Height = 25;
dgvTodosLotes.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvTodosLotes.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvTodosLotes.Size = new Size(1171, 107); dgvTodosLotes.Size = new Size(1165, 153);
dgvTodosLotes.TabIndex = 5; dgvTodosLotes.TabIndex = 5;
// //
// dgvDetallesRemito // dgvDetallesRemito
@@ -107,7 +106,6 @@
dgvDetallesRemito.EditMode = DataGridViewEditMode.EditProgrammatically; dgvDetallesRemito.EditMode = DataGridViewEditMode.EditProgrammatically;
dgvDetallesRemito.Location = new Point(562, 22); dgvDetallesRemito.Location = new Point(562, 22);
dgvDetallesRemito.Name = "dgvDetallesRemito"; dgvDetallesRemito.Name = "dgvDetallesRemito";
dgvDetallesRemito.RowTemplate.Height = 25;
dgvDetallesRemito.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvDetallesRemito.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvDetallesRemito.Size = new Size(609, 235); dgvDetallesRemito.Size = new Size(609, 235);
dgvDetallesRemito.TabIndex = 4; dgvDetallesRemito.TabIndex = 4;
@@ -121,7 +119,6 @@
dgvRemito.EditMode = DataGridViewEditMode.EditProgrammatically; dgvRemito.EditMode = DataGridViewEditMode.EditProgrammatically;
dgvRemito.Location = new Point(6, 22); dgvRemito.Location = new Point(6, 22);
dgvRemito.Name = "dgvRemito"; dgvRemito.Name = "dgvRemito";
dgvRemito.RowTemplate.Height = 25;
dgvRemito.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvRemito.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvRemito.Size = new Size(550, 235); dgvRemito.Size = new Size(550, 235);
dgvRemito.TabIndex = 3; dgvRemito.TabIndex = 3;
@@ -141,7 +138,7 @@
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1281, 450); ClientSize = new Size(1281, 502);
Controls.Add(groupBox1); Controls.Add(groupBox1);
Name = "FrmRemitos"; Name = "FrmRemitos";
Text = "Remitos"; Text = "Remitos";

View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("testing")] [assembly: System.Reflection.AssemblyCompanyAttribute("testing")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+670190c44b669009d2d84e1f849117de0d18586f")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c15ae743ab4e6f1c270349cbe1eadde8c6404874")]
[assembly: System.Reflection.AssemblyProductAttribute("testing")] [assembly: System.Reflection.AssemblyProductAttribute("testing")]
[assembly: System.Reflection.AssemblyTitleAttribute("testing")] [assembly: System.Reflection.AssemblyTitleAttribute("testing")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@@ -1 +1 @@
11e3546ad2295b54deb0ec86f31e7dbd3c3c2b4ce531b9f1388e97287778ffe5 61c944394d80796eab68c80421f3d70d87e7c76b24136ff08a133fa8b31e15fa

Binary file not shown.

Binary file not shown.