diff --git a/Controladora/ControladoraFacturas.cs b/Controladora/ControladoraFacturas.cs index 201339a..1301f1a 100644 --- a/Controladora/ControladoraFacturas.cs +++ b/Controladora/ControladoraFacturas.cs @@ -10,21 +10,24 @@ namespace Controladora { if (t == null) return "La Factura es nula, fallo la carga"; - if (RepositorioFactura.Instance.ExistePorId(t.Id)) - { - return $"La Factura con el ID {t.Id} ya existe"; - } + if (RepositorioFactura.Instance.ExistePorId(t.Id)) return $"La Factura con el ID {t.Id} ya existe"; + if (t.Cliente == null || t.Cliente.Cuit == 0) return "Debe seleccionar un cliente antes de agregar la factura"; - // Verificar si el cliente está seleccionado - if (t.Cliente == null || t.Cliente.Cuit == 0) + string checkstock = ""; + foreach (var detalle in t.MostrarDetalles()) { - return "Debe seleccionar un cliente antes de agregar la factura"; + if (detalle.Cantidad > ControladoraLotes.Instance.MostrarStockDeProducto(detalle.Producto)) + { + checkstock += $"No hay existencias en stock para realizar la venta de {detalle.Producto.Nombre}\n"; + } } + if (checkstock != "") return checkstock; try { bool resultado = RepositorioFactura.Instance.Add(t); - return resultado ? + string resultadolote = ControladoraLotes.Instance.DisminuirStock(t.MostrarDetalles()); + return (resultado && (resultadolote == "Se Descontaron los productos")) ? $"La Factura con el ID {t.Id} se cargó correctamente" : $"Falló la carga de la Factura con el ID {t.Id}"; } @@ -35,24 +38,6 @@ namespace Controladora } } - public string Eliminar(Factura t) - { - if (t == null) return "La Factura es nula, fallo la carga"; - - return (RepositorioFactura.Instance.Del(t)) ? - $"La Factura con el ID {t.Id} se eliminó correctamente" : - $"Falló la eliminación de la Factura con el ID {t.Id}"; - } - - public string Modificar(Factura t) - { - if (t == null) return "La Factura es nula, fallo la carga"; - - return (RepositorioFactura.Instance.Mod(t)) ? - $"La Factura con el ID {t.Id} se modificó correctamente" : - $"Falló la modificación de la Factura con el ID {t.Id}"; - } - public ReadOnlyCollection Listar() { return RepositorioFactura.Instance.Listar(); @@ -65,6 +50,21 @@ namespace Controladora return facturaalistar.MostrarDetalles(); } + + public ReadOnlyCollection ListarProductos() + { + return RepositorioProductos.Instance.Listar() + .Where(x => x.Habilitado == true) + .ToList() + .AsReadOnly(); + } + + public ReadOnlyCollection ListarClientes() + { + return RepositorioClientes.Instance.Listar().Where(x => x.Habilitado == true) + .ToList() + .AsReadOnly(); + } } } \ No newline at end of file diff --git a/Controladora/ControladoraInformes.cs b/Controladora/ControladoraInformes.cs new file mode 100644 index 0000000..96c60c3 --- /dev/null +++ b/Controladora/ControladoraInformes.cs @@ -0,0 +1,42 @@ +using Informes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; + +namespace Controladora +{ + public class ControladoraInformes : Singleton + { + const string configpath = "settings.json"; + + public void GuardarConfig(ConfigEmail config) + { + try + { + string json = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true }); + File.WriteAllText(configpath, json); + + } + catch (IOException ex) { throw; } + } + + public ConfigEmail RecuperarConfig() + { + try + { + if (!File.Exists(configpath)) + { + string json = JsonSerializer.Serialize(new ConfigEmail { EmailAddr = "", EmailPass = "", EmailTarget = new List() }, new JsonSerializerOptions { WriteIndented = true }); + File.WriteAllText(configpath, json); + } + } + catch (IOException ex) { throw; } + + string jsonString = File.ReadAllText(configpath); + return JsonSerializer.Deserialize(jsonString); + } + } +} diff --git a/Controladora/ControladoraLotes.cs b/Controladora/ControladoraLotes.cs index ee190af..1e63170 100644 --- a/Controladora/ControladoraLotes.cs +++ b/Controladora/ControladoraLotes.cs @@ -11,6 +11,7 @@ namespace Controladora { public class ControladoraLotes : Singleton { + /* public string Añadir(Lote t) { if (t == null) return "El Lote es nulo, falló la carga"; @@ -64,21 +65,39 @@ namespace Controladora return $"Ocurrió un error inesperado: {ex.Message}"; } } + */ - /*public ReadOnlyCollection ListarPorFacturaId(int facturaId) + public string DisminuirStock(ReadOnlyCollection detalleFactura) { - try + var ret = false; + foreach (var detalle in detalleFactura) { - var lotes = RepositorioLote.Instance.Listar(); - var lotesPorFactura = lotes.Where(lote => lote.Id == facturaId).ToList(); - return new ReadOnlyCollection(lotesPorFactura); + if (detalle == null) return "El detalle es nulo"; + if (detalle.Producto.Id < 0) return "Esta mal cargada la Id de producto"; + var productos = RepositorioProductos.Instance.Listar(); + if (productos.Any(x => x.Id != detalle.Producto.Id)) return "No hay Productos con esa id"; + ret = RepositorioLote.Instance.DisminuirStock(detalle); + } - catch (Exception ex) - { - // Captura cualquier excepción no prevista - throw new InvalidOperationException($"Ocurrió un error inesperado: {ex.Message}"); - } - }*/ + + return (ret) ? + "Se Descontaron los productos": + "Se fallo al diminuir el stock"; + + } + + public int MostrarStockDeProducto(Producto producto) + { + if (producto == null) return -1; + if (producto.Id < 0) return -1; + var lotes = RepositorioLote.Instance.Listar(); + if (lotes.Any(x => x.Producto.Id != producto.Id)) return -1; // basicamente no hay productos con esa id + + var CantidadStock = lotes + .Where(x => x.Producto.Id == producto.Id) + .Sum(x=> x.Cantidad); + return CantidadStock; + } public ReadOnlyCollection Listar() { diff --git a/Controladora/ControladoraOrdenesDeCompra.cs b/Controladora/ControladoraOrdenesDeCompra.cs index bb517c5..be887a2 100644 --- a/Controladora/ControladoraOrdenesDeCompra.cs +++ b/Controladora/ControladoraOrdenesDeCompra.cs @@ -66,6 +66,41 @@ namespace Controladora return ordenalistar.MostrarDetalles(); } + + public Presupuesto? MostrarPresupuestoPorId(Presupuesto? presupuesto) + { + if (presupuesto == null) return null; + if (presupuesto.Id < 0) return null; + var pres = RepositorioPresupuesto.Instance.Listar().First(x => x.Id == presupuesto.Id); + return pres; + } + + public object ListarProveedores() + { + return RepositorioProveedor.Instance.Listar() + .Where(x => x.Habilitado == true) + .ToList() + .AsReadOnly(); + } + + public ReadOnlyCollection ListarDetallesDePresupuesto(Presupuesto presupuesto) + { + Presupuesto pres = RepositorioPresupuesto.Instance.Listar().First(x => x.Id == presupuesto.Id); + if (pres == null) return new ReadOnlyCollection(new List()); + return pres.MostrarDetalles(); + } + + public object ListarPresupuestosPorProveedorHabilitados(Proveedor proveedor) + { + if (proveedor == null) return null; + if (proveedor.Cuit < 0) return null; + var presupuestos = RepositorioPresupuesto.Instance.Listar() + .Where(x => x.Proveedor.Cuit == proveedor.Cuit) + .Where(x => x.Habilitado == true) + .ToList() + .AsReadOnly(); + return presupuestos; + } } } diff --git a/Controladora/ControladoraPresupuestos.cs b/Controladora/ControladoraPresupuestos.cs index 284e2b7..762638b 100644 --- a/Controladora/ControladoraPresupuestos.cs +++ b/Controladora/ControladoraPresupuestos.cs @@ -49,15 +49,6 @@ namespace Controladora .AsReadOnly(); } - public ReadOnlyCollection ListarAceptado() - { - return RepositorioPresupuesto.Instance.Listar() - .Where(x => x.Habilitado == true) - .Where(x => x.Aceptado == true) - .ToList() - .AsReadOnly(); - } - public ReadOnlyCollection ListarDetalles(Presupuesto presupuesto) { Presupuesto pres = RepositorioPresupuesto.Instance.Listar().First(x=> x.Id == presupuesto.Id); @@ -66,25 +57,26 @@ namespace Controladora } - public Presupuesto? MostrarPresupuestoPorId(Presupuesto presupuesto) + public object ListarProductosPorProveedor(Proveedor proveedor) { - if (presupuesto == null) return null; - if (presupuesto.Id < 0) return null; - var pres = RepositorioPresupuesto.Instance.Listar().First(x => x.Id == presupuesto.Id); - return pres; - - } - - public ReadOnlyCollection? ListarPresupuestosPorProveedor(Proveedor proveedor) - { - if (proveedor == null) return null; - if (proveedor.Cuit < 0) return null; - var presupuestos = RepositorioPresupuesto.Instance.Listar() - .Where(x => x.Proveedor.Cuit == proveedor.Cuit) + if (proveedor == null) return new List().AsReadOnly(); + if (proveedor.Cuit < 0) return new List().AsReadOnly(); + var productos = RepositorioProductos.Instance + .Listar() + .Where(x => x.ListarProveedores() + .Any(x => x.Cuit == proveedor.Cuit)) .ToList() .AsReadOnly(); - return presupuestos; + return productos; + } + + public object ListarProveedores() + { + return RepositorioProveedor.Instance.Listar() + .Where(x => x.Habilitado == true) + .ToList() + .AsReadOnly(); } } } diff --git a/Controladora/ControladoraProductos.cs b/Controladora/ControladoraProductos.cs index 957a294..eec8097 100644 --- a/Controladora/ControladoraProductos.cs +++ b/Controladora/ControladoraProductos.cs @@ -60,5 +60,18 @@ namespace Controladora } return null; } + + public ReadOnlyCollection ListarProveedores() + { + return RepositorioProveedor.Instance.Listar() + .Where(x => x.Habilitado == true) + .ToList() + .AsReadOnly(); + } + + public ReadOnlyCollection ListarCategorias() + { + return RepositorioCategoria.Instance.Listar(); + } } } \ No newline at end of file diff --git a/Controladora/ControladoraProveedores.cs b/Controladora/ControladoraProveedores.cs index d68de48..f9fd022 100644 --- a/Controladora/ControladoraProveedores.cs +++ b/Controladora/ControladoraProveedores.cs @@ -49,5 +49,6 @@ namespace Controladora .ToList() .AsReadOnly(); } + } } diff --git a/Controladora/ControladoraRemito.cs b/Controladora/ControladoraRemito.cs index dc1aa06..4746c7f 100644 --- a/Controladora/ControladoraRemito.cs +++ b/Controladora/ControladoraRemito.cs @@ -11,15 +11,18 @@ namespace Controladora return RepositorioRemito.Instance.Listar(); } - public string Añadir(Remito t) + public string Añadir(Remito t, OrdenDeCompra orden ) { if (t == null) return "El Remito es nulo fallo la carga"; if (t.Id < 0) return "El id Esta Mal Cargado"; + var retMarcarOrdenEntregada = RepositorioOrdenDeCompra.Instance.MarcarEntregado(orden); + if (retMarcarOrdenEntregada == false) return "La orden Esta Mal Cargada"; var retRemito = RepositorioRemito.Instance.Add(t); + if (retRemito == false) return "El Remito Esta Mal Cargado"; var retLotes = RepositorioLote.Instance.Add(t); - return (!retLotes) ? + return (retLotes) ? $"El remito {t.Id} se cargo correctamente": $"Fallo la carga del remito {t.Id}"; @@ -40,6 +43,42 @@ namespace Controladora $"Fallo la Eliminacion del remito {t.Id}"; */ } + + public object ListarLotes() + { + return RepositorioLote.Instance.Listar().Where(x => x.Habilitado == true) + .ToList().AsReadOnly(); + } + + public ReadOnlyCollection ListarOrdenesSinEntregar() + { + return RepositorioOrdenDeCompra.Instance.Listar() + .Where(x => x.Entregado == false) + .ToList() + .AsReadOnly(); + } + public object ListarDetallesOrdenesDeCompra(OrdenDeCompra orden) + { + var ordenalistar = RepositorioOrdenDeCompra.Instance.Listar().First(x => x.Id == orden.Id); + if (ordenalistar == null) return new ReadOnlyCollection(new List()); + return ordenalistar.MostrarDetalles(); + + } + + public OrdenDeCompra? MostrarOrdenDeCompraPorId(OrdenDeCompra ordenDeCompra) + { + if (ordenDeCompra == null) return null; + if (ordenDeCompra.Id < 0) return null; + return RepositorioOrdenDeCompra.Instance.Listar().First(x => x.Id == ordenDeCompra.Id); + } + + public ReadOnlyCollection ListarLotesPorRemito(Remito rem) + { + var remalistar = RepositorioRemito.Instance.Listar().First(x => x.Id == rem.Id); + if (remalistar == null) return new ReadOnlyCollection(new List()); + return remalistar.MostrarLotes(); + + } } } \ No newline at end of file diff --git a/Informes/ConfigEmail.cs b/Entidades/ConfigEmail.cs similarity index 82% rename from Informes/ConfigEmail.cs rename to Entidades/ConfigEmail.cs index 0b6e860..5fcc7e7 100644 --- a/Informes/ConfigEmail.cs +++ b/Entidades/ConfigEmail.cs @@ -6,5 +6,7 @@ public string EmailPass { get; set; } public List EmailTarget { get; set; } + public bool Informar { get; set; } + } } \ No newline at end of file diff --git a/Entidades/Lote.cs b/Entidades/Lote.cs index abfc822..697ca9c 100644 --- a/Entidades/Lote.cs +++ b/Entidades/Lote.cs @@ -3,8 +3,16 @@ namespace Entidades { public class Lote: Detalle { + public int IdRemito { get; set; } public DateTime Fecha { get; set; } public bool Habilitado { get; set; } + public string NombreProducto + { + get + { + return Producto.Nombre; + } + } } } diff --git a/Entidades/OrdenDeCompra.cs b/Entidades/OrdenDeCompra.cs index 95a0df6..67232de 100644 --- a/Entidades/OrdenDeCompra.cs +++ b/Entidades/OrdenDeCompra.cs @@ -8,6 +8,7 @@ namespace Entidades public int Id { get; set; } private List detalles = new List(); public Proveedor Proveedor { get; set; } + public bool Entregado { get; set; } public void AñadirDetalle(DetalleOrdenDeCompra detalle) { diff --git a/Entidades/Producto.cs b/Entidades/Producto.cs index 4a8371f..2f1e35c 100644 --- a/Entidades/Producto.cs +++ b/Entidades/Producto.cs @@ -21,7 +21,7 @@ namespace Entidades } } - public List proveedores = new List(); + private List proveedores = new List(); public void AñadirProveedor(Proveedor proveedor) { @@ -38,6 +38,7 @@ namespace Entidades { return proveedores.AsReadOnly(); } + private List categorias = new List(); public void AñadirCategoria(Categoria cat) { diff --git a/Entidades/Remito.cs b/Entidades/Remito.cs index 259b0b6..e74a9ae 100644 --- a/Entidades/Remito.cs +++ b/Entidades/Remito.cs @@ -23,5 +23,12 @@ namespace Entidades throw; } } + public string NombreProveedor + { + get + { + return Proveedor.Nombre; + } + } } } diff --git a/Informes/InformeEmail.cs b/Informes/InformeEmail.cs index de6952d..294978e 100644 --- a/Informes/InformeEmail.cs +++ b/Informes/InformeEmail.cs @@ -12,6 +12,8 @@ namespace Informes /// Envia Informes por Email /// + public bool Informar { get; set; } + private static InformeEmail instance = new(); public static InformeEmail Instance { diff --git a/Informes/obj/Debug/net6.0/Informes.csproj.CoreCompileInputs.cache b/Informes/obj/Debug/net6.0/Informes.csproj.CoreCompileInputs.cache index bc286ec..4f1310f 100644 --- a/Informes/obj/Debug/net6.0/Informes.csproj.CoreCompileInputs.cache +++ b/Informes/obj/Debug/net6.0/Informes.csproj.CoreCompileInputs.cache @@ -1,5 +1,9 @@ <<<<<<< HEAD +<<<<<<< HEAD 3fd66116ceaea5e07433507fe6494c4f357d71a3a526da0eea8f6d1df7fb86c5 ======= 100fa21bf2f76b06ab70964d65200e354f5837e3 >>>>>>> a9ebcff (añadida ¿Reactividad? a que se elija entre percedero o no) +======= +b8f7575a0ad69c743b6dc87a6ac87340793ee335 +>>>>>>> 8b80e42 (falta que se actualize numProducto y los infomes) diff --git a/Modelo/RepositorioLote.cs b/Modelo/RepositorioLote.cs index ddb0d4e..af52225 100644 --- a/Modelo/RepositorioLote.cs +++ b/Modelo/RepositorioLote.cs @@ -80,5 +80,29 @@ namespace Modelo return ret; } + public bool DisminuirStock(DetalleFactura detalleFactura) + { + bool ret = false; + while (detalleFactura.Cantidad >= 0) + { + var elementoAdisminuir = almacen.Where(x=> x.Habilitado == true) + .First(x => x.Producto.Id == detalleFactura.Producto.Id); + + detalleFactura.Cantidad -= elementoAdisminuir.Cantidad; + + if (detalleFactura.Cantidad > 0) + { + elementoAdisminuir.Cantidad = 0; + elementoAdisminuir.Habilitado = false; + } + else + { + elementoAdisminuir.Cantidad = -detalleFactura.Cantidad; + ret = true; + } + } + return ret; + } + } } diff --git a/Modelo/RepositorioOrdenDeCompra.cs b/Modelo/RepositorioOrdenDeCompra.cs index 3ebe845..dd4585d 100644 --- a/Modelo/RepositorioOrdenDeCompra.cs +++ b/Modelo/RepositorioOrdenDeCompra.cs @@ -68,5 +68,20 @@ namespace Modelo { return orden.MostrarDetalles(); } + + public bool MarcarEntregado(OrdenDeCompra orden) + { + bool ret = false; + if (orden == null) return ret; + if (orden.Id < 0) return ret; + if (orden.Entregado == false) return ret; + var ordenAModificar = almacen.FindIndex(x => x.Id == orden.Id); + if (ordenAModificar > -1) + { + almacen[ordenAModificar].Entregado = true; + ret = true; + } + return ret; + } } } diff --git a/Modelo/RepositorioRemito.cs b/Modelo/RepositorioRemito.cs index 5d4599d..f061b8c 100644 --- a/Modelo/RepositorioRemito.cs +++ b/Modelo/RepositorioRemito.cs @@ -47,7 +47,7 @@ namespace Modelo return ret; } - + override public bool Del(Remito t) { @@ -70,10 +70,5 @@ namespace Modelo return ret; } - - public ReadOnlyCollection MostrarLotes(Remito remito) - { - return remito.MostrarLotes(); - } } } diff --git a/Vista/AddProducto.Designer.cs b/Vista/AddProducto.Designer.cs deleted file mode 100644 index c25bf32..0000000 --- a/Vista/AddProducto.Designer.cs +++ /dev/null @@ -1,122 +0,0 @@ -namespace Vista -{ - partial class AddProducto - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - comboBox1 = new ComboBox(); - label1 = new Label(); - label2 = new Label(); - numericUpDown1 = new NumericUpDown(); - button1 = new Button(); - button2 = new Button(); - ((System.ComponentModel.ISupportInitialize)numericUpDown1).BeginInit(); - SuspendLayout(); - // - // comboBox1 - // - comboBox1.DropDownStyle = ComboBoxStyle.DropDownList; - comboBox1.FormattingEnabled = true; - comboBox1.Location = new Point(98, 37); - comboBox1.Name = "comboBox1"; - comboBox1.Size = new Size(121, 23); - comboBox1.TabIndex = 0; - // - // label1 - // - label1.AutoSize = true; - label1.Location = new Point(26, 40); - label1.Name = "label1"; - label1.Size = new Size(56, 15); - label1.TabIndex = 1; - label1.Text = "Producto"; - // - // label2 - // - label2.AutoSize = true; - label2.Location = new Point(27, 86); - label2.Name = "label2"; - label2.Size = new Size(55, 15); - label2.TabIndex = 2; - label2.Text = "Cantidad"; - // - // numericUpDown1 - // - numericUpDown1.Location = new Point(99, 78); - numericUpDown1.Maximum = new decimal(new int[] { 10000000, 0, 0, 0 }); - numericUpDown1.Name = "numericUpDown1"; - numericUpDown1.Size = new Size(120, 23); - numericUpDown1.TabIndex = 3; - // - // button1 - // - button1.Location = new Point(12, 160); - button1.Name = "button1"; - button1.Size = new Size(71, 23); - button1.TabIndex = 4; - button1.Text = "Guardar"; - button1.UseVisualStyleBackColor = true; - button1.Click += button1_Click; - // - // button2 - // - button2.Location = new Point(146, 160); - button2.Name = "button2"; - button2.Size = new Size(73, 23); - button2.TabIndex = 5; - button2.Text = "Cancelar"; - button2.UseVisualStyleBackColor = true; - button2.Click += button2_Click; - // - // AddProducto - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(236, 201); - Controls.Add(button2); - Controls.Add(button1); - Controls.Add(numericUpDown1); - Controls.Add(label2); - Controls.Add(label1); - Controls.Add(comboBox1); - Name = "AddProducto"; - Text = "Form1"; - ((System.ComponentModel.ISupportInitialize)numericUpDown1).EndInit(); - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private ComboBox comboBox1; - private Label label1; - private Label label2; - private NumericUpDown numericUpDown1; - private Button button1; - private Button button2; - } -} \ No newline at end of file diff --git a/Vista/AddProducto.cs b/Vista/AddProducto.cs deleted file mode 100644 index 8477764..0000000 --- a/Vista/AddProducto.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace Vista -{ - public partial class AddProducto : Form - { - public AddProducto() - { - InitializeComponent(); - } - - private void button1_Click(object sender, EventArgs e) - { - Close(); - } - - private void button2_Click(object sender, EventArgs e) - { - Close(); - } - } -} diff --git a/Vista/AddProducto.resx b/Vista/AddProducto.resx deleted file mode 100644 index a395bff..0000000 --- a/Vista/AddProducto.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Vista/FrmCliente.Designer.cs b/Vista/FrmCliente.Designer.cs index d6352a3..9890db2 100644 --- a/Vista/FrmCliente.Designer.cs +++ b/Vista/FrmCliente.Designer.cs @@ -129,7 +129,7 @@ namespace Vista // // BtnCancelar // - BtnCancelar.Location = new Point(158, 190); + BtnCancelar.Location = new Point(190, 190); BtnCancelar.Name = "BtnCancelar"; BtnCancelar.Size = new Size(75, 23); BtnCancelar.TabIndex = 11; @@ -144,7 +144,6 @@ namespace Vista numCuit.Name = "numCuit"; numCuit.Size = new Size(173, 23); numCuit.TabIndex = 12; - numCuit.ValueChanged += numCuit_ValueChanged; // // FrmCliente // @@ -152,7 +151,7 @@ namespace Vista AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; CancelButton = BtnCancelar; - ClientSize = new Size(420, 245); + ClientSize = new Size(304, 245); ControlBox = false; Controls.Add(numCuit); Controls.Add(BtnCancelar); diff --git a/Vista/FrmCliente.cs b/Vista/FrmCliente.cs index f58d04c..e150c94 100644 --- a/Vista/FrmCliente.cs +++ b/Vista/FrmCliente.cs @@ -103,13 +103,6 @@ namespace Vista MessageBox.Show(msg, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } - - - } - - private void numCuit_ValueChanged(object sender, EventArgs e) - { - } } } diff --git a/Vista/FrmCliente.resx b/Vista/FrmCliente.resx index af32865..a395bff 100644 --- a/Vista/FrmCliente.resx +++ b/Vista/FrmCliente.resx @@ -18,7 +18,7 @@ System.Resources.ResXResourceReader, System.Windows.Forms, ... System.Resources.ResXResourceWriter, System.Windows.Forms, ... this is my long stringthis is a comment - Blue + Blue [base64 mime encoded serialized .NET Framework object] diff --git a/Vista/FrmFactura.cs b/Vista/FrmFactura.cs index c85710d..1a9beb9 100644 --- a/Vista/FrmFactura.cs +++ b/Vista/FrmFactura.cs @@ -30,7 +30,7 @@ namespace Vista private void ActualizarGrilla() { dgvProductos.DataSource = null; - dgvProductos.DataSource = ControladoraProductos.Instance.Listar(); + dgvProductos.DataSource = ControladoraFacturas.Instance.ListarProductos(); dgvDetalles.AutoGenerateColumns = false; @@ -69,7 +69,7 @@ namespace Vista private void CargarDatos() { // Asignar la lista de clientes como origen de datos para el ComboBox - cmbCliente.DataSource = ControladoraClientes.Instance.Listar(); + cmbCliente.DataSource = ControladoraFacturas.Instance.ListarClientes(); // Establecer la propiedad para mostrar el nombre del cliente en el ComboBox cmbCliente.DisplayMember = "NombreCompleto"; @@ -127,7 +127,7 @@ namespace Vista factura.Total = Convert.ToDouble(numtotal.Value); factura.Fecha = datepick.Value; factura.Id = Convert.ToInt32(numid.Value); - factura.Cliente = ControladoraClientes.Instance.Listar().First(x => x.NombreCompleto == cmbCliente.SelectedValue.ToString()); + factura.Cliente = ControladoraFacturas.Instance.ListarClientes().First(x => x.NombreCompleto == cmbCliente.SelectedValue.ToString()); string mensaje = ControladoraFacturas.Instance.Añadir(factura); MessageBox.Show(mensaje, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); diff --git a/Vista/FrmInforme.Designer.cs b/Vista/FrmInforme.Designer.cs index 89a9a77..9a9ec18 100644 --- a/Vista/FrmInforme.Designer.cs +++ b/Vista/FrmInforme.Designer.cs @@ -38,6 +38,7 @@ btnAñadir = new Button(); btnGuardar = new Button(); btnEliminar = new Button(); + checkinfome = new CheckBox(); ((System.ComponentModel.ISupportInitialize)dgvEmailTarget).BeginInit(); SuspendLayout(); // @@ -133,11 +134,22 @@ btnEliminar.UseVisualStyleBackColor = true; btnEliminar.Click += btnEliminar_Click; // + // checkinfome + // + checkinfome.AutoSize = true; + checkinfome.Location = new Point(335, 22); + checkinfome.Name = "checkinfome"; + checkinfome.Size = new Size(121, 19); + checkinfome.TabIndex = 10; + checkinfome.Text = "Habilitar Informes"; + checkinfome.UseVisualStyleBackColor = true; + // // FrmInforme // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(800, 450); + Controls.Add(checkinfome); Controls.Add(btnEliminar); Controls.Add(btnGuardar); Controls.Add(btnAñadir); @@ -168,5 +180,6 @@ private Button btnAñadir; private Button btnGuardar; private Button btnEliminar; + private CheckBox checkinfome; } } \ No newline at end of file diff --git a/Vista/FrmInforme.cs b/Vista/FrmInforme.cs index 916d1a3..26f0c6c 100644 --- a/Vista/FrmInforme.cs +++ b/Vista/FrmInforme.cs @@ -1,4 +1,5 @@ -using Informes; +using Controladora; +using Informes; using System; using System.Collections.Generic; using System.ComponentModel; @@ -14,19 +15,11 @@ namespace Vista { public partial class FrmInforme : Form { - const string configpath = "settings.json"; public FrmInforme() { InitializeComponent(); - if (!File.Exists(configpath)) - { - string json = JsonSerializer.Serialize(new ConfigEmail { EmailAddr = "", EmailPass = "", EmailTarget = new List() }, new JsonSerializerOptions { WriteIndented = true }); - File.WriteAllText(configpath, json); - } - - string jsonString = File.ReadAllText(configpath); - ConfigEmail config = JsonSerializer.Deserialize(jsonString); + ConfigEmail config = ControladoraInformes.Instance.RecuperarConfig(); CargaDatos(config); } @@ -60,11 +53,13 @@ namespace Vista { EmailAddr = txtEmailAddr.Text, EmailPass = txtEmailPass.Text, - EmailTarget = emailTarget + EmailTarget = emailTarget, + Informar = checkinfome.Checked + }; - string json = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true }); - File.WriteAllText(configpath, json); + ControladoraInformes.Instance.GuardarConfig(config); + } private void btnAñadir_Click(object sender, EventArgs e) diff --git a/Vista/FrmOrdenDeCompra.cs b/Vista/FrmOrdenDeCompra.cs index 1a2111e..c1000a5 100644 --- a/Vista/FrmOrdenDeCompra.cs +++ b/Vista/FrmOrdenDeCompra.cs @@ -38,7 +38,7 @@ namespace Vista } dgvProveedor.DataSource = null; - dgvProveedor.DataSource = ControladoraProveedores.Instance.Listar(); + dgvProveedor.DataSource = ControladoraOrdenDeCompras.Instance.ListarProveedores(); } @@ -53,7 +53,7 @@ namespace Vista { Id = Convert.ToInt32(selectedRow.Cells["Id"].Value.ToString()), }; - pres = ControladoraPresupuestos.Instance.MostrarPresupuestoPorId(pres); + pres = ControladoraOrdenDeCompras.Instance.MostrarPresupuestoPorId(pres); if (pres == null) { @@ -61,7 +61,7 @@ namespace Vista return; } - var listadetalle = ControladoraPresupuestos.Instance.ListarDetalles(pres); + var listadetalle = ControladoraOrdenDeCompras.Instance.ListarDetallesDePresupuesto(pres); foreach (var detalle in listadetalle) { @@ -106,7 +106,7 @@ namespace Vista }; // Obtén los detalles del presupuesto usando el método de la controladora - var detallesPresupuesto = ControladoraPresupuestos.Instance.ListarDetalles(presupuesto); + var detallesPresupuesto = ControladoraOrdenDeCompras.Instance.ListarDetallesDePresupuesto(presupuesto); // Crea una lista para mostrar el proveedor y los detalles del presupuesto var proveedorYDetalles = detallesPresupuesto.Select(d => new @@ -166,10 +166,10 @@ namespace Vista var selectedRow = dgvProveedor.SelectedRows[0]; var proveedor = new Proveedor { - Cuit = Convert.ToInt32(selectedRow.Cells["Cuit"].Value), + Cuit = Convert.ToInt64(selectedRow.Cells["Cuit"].Value), }; - var presupuestos = ControladoraPresupuestos.Instance.ListarPresupuestosPorProveedor(proveedor); + var presupuestos = ControladoraOrdenDeCompras.Instance.ListarPresupuestosPorProveedorHabilitados(proveedor); dgvPresupuesto.DataSource = null; dgvPresupuesto.DataSource = presupuestos; diff --git a/Vista/FrmPresupuesto.Designer.cs b/Vista/FrmPresupuesto.Designer.cs index 46e69e3..853a74b 100644 --- a/Vista/FrmPresupuesto.Designer.cs +++ b/Vista/FrmPresupuesto.Designer.cs @@ -58,7 +58,7 @@ dgvProducto.AllowUserToDeleteRows = false; dgvProducto.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dgvProducto.EditMode = DataGridViewEditMode.EditProgrammatically; - dgvProducto.Location = new Point(244, 26); + dgvProducto.Location = new Point(631, 32); dgvProducto.MultiSelect = false; dgvProducto.Name = "dgvProducto"; dgvProducto.RowTemplate.Height = 25; @@ -79,7 +79,7 @@ // label2 // label2.AutoSize = true; - label2.Location = new Point(597, 8); + label2.Location = new Point(249, 14); label2.Name = "label2"; label2.Size = new Size(55, 15); label2.TabIndex = 3; @@ -139,13 +139,14 @@ dgvProveedor.AllowUserToDeleteRows = false; dgvProveedor.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dgvProveedor.EditMode = DataGridViewEditMode.EditProgrammatically; - dgvProveedor.Location = new Point(597, 26); + dgvProveedor.Location = new Point(249, 32); dgvProveedor.MultiSelect = false; dgvProveedor.Name = "dgvProveedor"; dgvProveedor.RowTemplate.Height = 25; dgvProveedor.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvProveedor.Size = new Size(376, 338); dgvProveedor.TabIndex = 13; + dgvProveedor.CellClick += dgvProveedor_CellClick; // // dgvPedido // @@ -160,7 +161,7 @@ // label1 // label1.AutoSize = true; - label1.Location = new Point(244, 8); + label1.Location = new Point(626, 9); label1.Name = "label1"; label1.Size = new Size(56, 15); label1.TabIndex = 15; diff --git a/Vista/FrmPresupuesto.cs b/Vista/FrmPresupuesto.cs index f346b53..0bd7e78 100644 --- a/Vista/FrmPresupuesto.cs +++ b/Vista/FrmPresupuesto.cs @@ -25,8 +25,8 @@ namespace Vista private void CargarDatos() { - dgvProducto.DataSource = null; - dgvProducto.DataSource = ControladoraProductos.Instance.Listar(); + dgvProveedor.DataSource = null; + dgvProveedor.DataSource = ControladoraPresupuestos.Instance.ListarProveedores(); var presupuestolist = ControladoraPresupuestos.Instance.Listar(); numId.Value = (presupuestolist.Count > 0) ? @@ -144,26 +144,19 @@ namespace Vista // Añadir el detalle al presupuesto presupuesto.AñadirDetalle(detalle); + //bloqueamos el dgv de proveedor porque solo se puede cargar un presupuesto + //donde todos los productos provengan de un mismo proveedor. + dgvProveedor.Enabled = false; + // Actualizar el DataGridView dgvPedido.DataSource = null; dgvPedido.DataSource = presupuesto.MostrarDetalles(); // Configura las columnas a mostrar y sus encabezados - dgvPedido.Columns["IDPresupuesto"].Visible = true; - dgvPedido.Columns["Cantidad"].Visible = true; - dgvPedido.Columns["NombreDelProducto"].Visible = true; - - dgvPedido.Columns["IDPresupuesto"].HeaderText = "ID Presupuesto"; - dgvPedido.Columns["Cantidad"].HeaderText = "Cantidad"; - dgvPedido.Columns["NombreDelProducto"].HeaderText = "Producto"; - - // Oculta todas las demás columnas foreach (DataGridViewColumn column in dgvPedido.Columns) { - if (column.Name != "IDPresupuesto" && column.Name != "Cantidad" && column.Name != "NombreDelProducto") - { - column.Visible = false; - } + column.Visible = column.Name == "IdPresupuesto" || column.Name == "Cantidad" + || column.Name == "NombreDelProducto"; } } catch (OverflowException ex) @@ -186,14 +179,14 @@ namespace Vista { string ret = ""; - if (numCantidad.Value <= 0) ret += "Cantidad de productos invalida"; - if (numPreciopropuesto.Value <= 0) ret += "Precio C/U Invalido"; + if (numCantidad.Value <= 0) ret += "Cantidad de productos invalida\n"; + if (numPreciopropuesto.Value <= 0) ret += "Precio C/U Invalido\n"; if (ret == "") { return false; } - MessageBox.Show("ret"); + MessageBox.Show(ret); return true; } @@ -263,15 +256,20 @@ namespace Vista private void dgvProducto_CellClick(object sender, DataGridViewCellEventArgs e) { - if (dgvProducto.SelectedRows.Count == 0) return; - if (dgvProducto.SelectedRows.Count > 0) + } + + private void dgvProveedor_CellClick(object sender, DataGridViewCellEventArgs e) + { + if (dgvProveedor.SelectedRows.Count == 0) return; + + if (dgvProveedor.SelectedRows.Count > 0) { - Producto producto = new Producto + var proveedor = new Proveedor { - Id = Convert.ToInt32(dgvProducto.SelectedRows[0].Cells["Id"].Value.ToString()), + Cuit = Convert.ToInt64(dgvProveedor.SelectedRows[0].Cells["Cuit"].Value.ToString()), }; - dgvProveedor.DataSource = ControladoraProductos.Instance.ListarProveedores(producto); + dgvProducto.DataSource = ControladoraPresupuestos.Instance.ListarProductosPorProveedor(proveedor); } } } diff --git a/Vista/FrmPresupuestos.Designer.cs b/Vista/FrmPresupuestos.Designer.cs index 8f222bf..bc0db2d 100644 --- a/Vista/FrmPresupuestos.Designer.cs +++ b/Vista/FrmPresupuestos.Designer.cs @@ -64,7 +64,6 @@ // numtotal // numtotal.Enabled = false; - numtotal.ImeMode = ImeMode.NoControl; numtotal.InterceptArrowKeys = false; numtotal.Location = new Point(665, 263); numtotal.Maximum = new decimal(new int[] { -727379969, 232, 0, 0 }); diff --git a/Vista/FrmPresupuestos.cs b/Vista/FrmPresupuestos.cs index d159981..820b282 100644 --- a/Vista/FrmPresupuestos.cs +++ b/Vista/FrmPresupuestos.cs @@ -89,13 +89,8 @@ namespace Vista || column.Name == "Subtotal"; } + numtotal.Value = Convert.ToDecimal(detallesPresupuesto.Sum(x => x.Subtotal).ToString()); - numtotal.Value = Convert.ToDecimal(presupuesto.MostrarDetalles().Sum(x => x.Subtotal)); - // Asegúrate de que solo las columnas que deseas mostrar están visibles - //foreach (DataGridViewColumn column in dgvdetallesPresupuesto.Columns) - //{ - // column.Visible = column.Name == "NombreDelProducto" || column.Name == "Cantidad"; - //} } private void BtnEliminar_Click(object sender, EventArgs e) @@ -125,8 +120,8 @@ namespace Vista // Actualiza la grilla de presupuestos después de eliminar el presupuesto ActualizarGrilla(); - // Limpia o actualiza el dgvDetalles para reflejar que el presupuesto ha sido eliminado - dgvdetallesPresupuesto.DataSource = null; // O actualiza el datasource si tienes uno + + dgvdetallesPresupuesto.DataSource = null; MessageBox.Show("Presupuesto eliminado exitosamente."); } diff --git a/Vista/FrmProducto.cs b/Vista/FrmProducto.cs index f70b831..bfb7f8a 100644 --- a/Vista/FrmProducto.cs +++ b/Vista/FrmProducto.cs @@ -50,7 +50,7 @@ namespace Vista private void CargarTabla() { dgvProveedor.DataSource = null; - dgvProveedor.DataSource = ControladoraProveedores.Instance.Listar(); + dgvProveedor.DataSource = ControladoraProductos.Instance.ListarProveedores(); if (mod) { foreach (Proveedor prov in ControladoraProductos.Instance.ListarProveedores(nuevoproducto)) @@ -135,7 +135,6 @@ namespace Vista { if (ValidarDatos()) { - var proveedores = new List(nuevoproducto.ListarProveedores()); if (checkBox1.Checked) // Producto Perecedero { @@ -148,9 +147,13 @@ namespace Vista Categoria = (Categoria)cmbCategoria.SelectedItem, MesesHastaConsumoPreferente = (int)numericUpDown1.Value, MesesHastaVencimiento = (int)numericUpDown2.Value, - proveedores = proveedores }; + foreach (var proveedor in nuevoproducto.ListarProveedores()) + { + productoPerecedero.AñadirProveedor(proveedor); + } + string mensaje = mod ? ControladoraProductos.Instance.Modificar(productoPerecedero) : ControladoraProductos.Instance.Añadir(productoPerecedero); @@ -167,9 +170,12 @@ namespace Vista Habilitado = checkHabilitado.Checked, Categoria = (Categoria)cmbCategoria.SelectedItem, TipoDeEnvase = (EnvaseTipo)comboBox1.SelectedItem, - proveedores = proveedores }; - + + foreach (var proveedor in nuevoproducto.ListarProveedores()) + { + productoNoPerecedero.AñadirProveedor(proveedor); + } string mensaje = mod ? ControladoraProductos.Instance.Modificar(productoNoPerecedero) : ControladoraProductos.Instance.Añadir(productoNoPerecedero); diff --git a/Vista/FrmProductos.Designer.cs b/Vista/FrmProductos.Designer.cs index 1bbeb23..00569b0 100644 --- a/Vista/FrmProductos.Designer.cs +++ b/Vista/FrmProductos.Designer.cs @@ -43,16 +43,21 @@ dgvNoPercedero = new DataGridView(); label4 = new Label(); label5 = new Label(); + label6 = new Label(); + numStock = new NumericUpDown(); groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dgvProveedores).BeginInit(); ((System.ComponentModel.ISupportInitialize)dgvProductos).BeginInit(); ((System.ComponentModel.ISupportInitialize)dgvCategorias).BeginInit(); ((System.ComponentModel.ISupportInitialize)dgvPercedero).BeginInit(); ((System.ComponentModel.ISupportInitialize)dgvNoPercedero).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numStock).BeginInit(); SuspendLayout(); // // groupBox1 // + groupBox1.Controls.Add(numStock); + groupBox1.Controls.Add(label6); groupBox1.Controls.Add(btnModificar); groupBox1.Controls.Add(label3); groupBox1.Controls.Add(dgvProveedores); @@ -62,7 +67,7 @@ groupBox1.Controls.Add(BtnEliminar); groupBox1.Location = new Point(12, 0); groupBox1.Name = "groupBox1"; - groupBox1.Size = new Size(939, 305); + groupBox1.Size = new Size(1196, 305); groupBox1.TabIndex = 5; groupBox1.TabStop = false; // @@ -92,7 +97,7 @@ dgvProveedores.Name = "dgvProveedores"; dgvProveedores.RowTemplate.Height = 25; dgvProveedores.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dgvProveedores.Size = new Size(280, 235); + dgvProveedores.Size = new Size(577, 235); dgvProveedores.TabIndex = 9; // // label2 @@ -139,7 +144,7 @@ // // btnCrearCategoria // - btnCrearCategoria.Location = new Point(966, 263); + btnCrearCategoria.Location = new Point(958, 582); btnCrearCategoria.Name = "btnCrearCategoria"; btnCrearCategoria.Size = new Size(128, 23); btnCrearCategoria.TabIndex = 4; @@ -152,7 +157,7 @@ dgvCategorias.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dgvCategorias.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dgvCategorias.EditMode = DataGridViewEditMode.EditProgrammatically; - dgvCategorias.Location = new Point(966, 22); + dgvCategorias.Location = new Point(958, 341); dgvCategorias.Name = "dgvCategorias"; dgvCategorias.RowTemplate.Height = 25; dgvCategorias.SelectionMode = DataGridViewSelectionMode.FullRowSelect; @@ -162,7 +167,7 @@ // label1 // label1.AutoSize = true; - label1.Location = new Point(969, 4); + label1.Location = new Point(961, 323); label1.Name = "label1"; label1.Size = new Size(63, 15); label1.TabIndex = 7; @@ -214,6 +219,23 @@ label5.TabIndex = 13; label5.Text = "Productos Percederos"; // + // label6 + // + label6.AutoSize = true; + label6.Location = new Point(275, 271); + label6.Name = "label6"; + label6.Size = new Size(36, 15); + label6.TabIndex = 12; + label6.Text = "Stock"; + // + // numStock + // + numStock.Enabled = false; + numStock.Location = new Point(317, 269); + numStock.Name = "numStock"; + numStock.Size = new Size(120, 23); + numStock.TabIndex = 13; + // // FrmProductos // AutoScaleDimensions = new SizeF(7F, 15F); @@ -237,6 +259,7 @@ ((System.ComponentModel.ISupportInitialize)dgvCategorias).EndInit(); ((System.ComponentModel.ISupportInitialize)dgvPercedero).EndInit(); ((System.ComponentModel.ISupportInitialize)dgvNoPercedero).EndInit(); + ((System.ComponentModel.ISupportInitialize)numStock).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -258,5 +281,7 @@ private DataGridView dgvNoPercedero; private Label label4; private Label label5; + private NumericUpDown numStock; + private Label label6; } } \ No newline at end of file diff --git a/Vista/FrmProductos.cs b/Vista/FrmProductos.cs index 59da4a2..7a1742c 100644 --- a/Vista/FrmProductos.cs +++ b/Vista/FrmProductos.cs @@ -168,7 +168,7 @@ namespace Vista dgvProductos.DataSource = null; dgvCategorias.DataSource = null; - var categorias = ControladoraCategorias.Instance.Listar(); + var categorias = ControladoraProductos.Instance.ListarCategorias(); dgvCategorias.DataSource = categorias; // Obtener la lista de productos y proyectar los datos @@ -245,12 +245,12 @@ namespace Vista Id = Convert.ToInt32(selectedRow.Cells["Id"].Value) }; bool esPercedero = Convert.ToBoolean(selectedRow.Cells["EsPerecedero"].Value); - if(esPercedero) + if (esPercedero) { ProductoPercedero prod = (ProductoPercedero)ControladoraProductos.Instance.MostrarPorId(Producto); if (prod == null) return; - - dgvPercedero.DataSource = new List{ prod }; + + dgvPercedero.DataSource = new List { prod }; } else { diff --git a/Vista/FrmRemito.Designer.cs b/Vista/FrmRemito.Designer.cs index b88905b..711e26a 100644 --- a/Vista/FrmRemito.Designer.cs +++ b/Vista/FrmRemito.Designer.cs @@ -28,12 +28,121 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Remito"; + dgvOrdenDeCompra = new DataGridView(); + label1 = new Label(); + label2 = new Label(); + dgvDetalles = new DataGridView(); + BtnAdd = new Button(); + label3 = new Label(); + numId = new NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)dgvOrdenDeCompra).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dgvDetalles).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numId).BeginInit(); + SuspendLayout(); + // + // dgvOrdenDeCompra + // + dgvOrdenDeCompra.AllowUserToAddRows = false; + dgvOrdenDeCompra.AllowUserToDeleteRows = false; + dgvOrdenDeCompra.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dgvOrdenDeCompra.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dgvOrdenDeCompra.EditMode = DataGridViewEditMode.EditProgrammatically; + dgvOrdenDeCompra.Location = new Point(12, 23); + dgvOrdenDeCompra.Name = "dgvOrdenDeCompra"; + dgvOrdenDeCompra.RowTemplate.Height = 25; + dgvOrdenDeCompra.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dgvOrdenDeCompra.Size = new Size(368, 235); + dgvOrdenDeCompra.TabIndex = 4; + dgvOrdenDeCompra.CellClick += dgvOrdenDeCompra_CellClick; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 5); + label1.Name = "label1"; + label1.Size = new Size(102, 15); + label1.TabIndex = 7; + label1.Text = "Orden de Compra"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(386, 9); + label2.Name = "label2"; + label2.Size = new Size(48, 15); + label2.TabIndex = 8; + label2.Text = "Detalles"; + // + // dgvDetalles + // + dgvDetalles.AllowUserToAddRows = false; + dgvDetalles.AllowUserToDeleteRows = false; + dgvDetalles.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dgvDetalles.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dgvDetalles.EditMode = DataGridViewEditMode.EditProgrammatically; + dgvDetalles.Location = new Point(386, 23); + dgvDetalles.Name = "dgvDetalles"; + dgvDetalles.RowTemplate.Height = 25; + dgvDetalles.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dgvDetalles.Size = new Size(368, 235); + dgvDetalles.TabIndex = 9; + // + // BtnAdd + // + BtnAdd.Location = new Point(12, 264); + BtnAdd.Name = "BtnAdd"; + BtnAdd.Size = new Size(165, 23); + BtnAdd.TabIndex = 10; + BtnAdd.Text = "Certificar Llegada Productos"; + BtnAdd.UseVisualStyleBackColor = true; + BtnAdd.Click += BtnAdd_Click; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(225, 269); + label3.Name = "label3"; + label3.Size = new Size(17, 15); + label3.TabIndex = 11; + label3.Text = "Id"; + // + // numId + // + numId.Enabled = false; + numId.Location = new Point(248, 266); + numId.Name = "numId"; + numId.Size = new Size(120, 23); + numId.TabIndex = 12; + // + // FrmRemito + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 293); + Controls.Add(numId); + Controls.Add(label3); + Controls.Add(BtnAdd); + Controls.Add(dgvDetalles); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(dgvOrdenDeCompra); + Name = "FrmRemito"; + Text = "Remito"; + ((System.ComponentModel.ISupportInitialize)dgvOrdenDeCompra).EndInit(); + ((System.ComponentModel.ISupportInitialize)dgvDetalles).EndInit(); + ((System.ComponentModel.ISupportInitialize)numId).EndInit(); + ResumeLayout(false); + PerformLayout(); } #endregion + + private DataGridView dgvOrdenDeCompra; + private Label label1; + private Label label2; + private DataGridView dgvDetalles; + private Button BtnAdd; + private Label label3; + private NumericUpDown numId; } } \ No newline at end of file diff --git a/Vista/FrmRemito.cs b/Vista/FrmRemito.cs index 16d3e94..5e4accc 100644 --- a/Vista/FrmRemito.cs +++ b/Vista/FrmRemito.cs @@ -1,4 +1,6 @@ -using System; +using Controladora; +using Entidades; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -15,6 +17,76 @@ namespace Vista public FrmRemito() { InitializeComponent(); + ActualizarTablaOrdendeCompra(); + } + private void ActualizarTablaOrdendeCompra() + { + dgvOrdenDeCompra.DataSource = null; + dgvOrdenDeCompra.DataSource = ControladoraRemito.Instance.ListarOrdenesSinEntregar(); + foreach (DataGridViewColumn column in dgvOrdenDeCompra.Columns) + { + column.Visible = column.Name == "Id" || column.Name == "NombreProveedor" + || column.Name == "MontoTotal"; + } + numId.Value = (ControladoraRemito.Instance.Listar().Count) > 0 ? + ControladoraRemito.Instance.Listar().Max(x=> x.Id+1): + 0; + } + + private void dgvOrdenDeCompra_CellClick(object sender, DataGridViewCellEventArgs e) + { + if (dgvOrdenDeCompra.SelectedRows.Count == 0) return; + + int ordenid = Convert.ToInt32(dgvOrdenDeCompra.SelectedRows[0].Cells["Id"].Value.ToString()); + + var orden = new OrdenDeCompra { Id = ordenid }; + + var detallesorden = ControladoraRemito.Instance.ListarDetallesOrdenesDeCompra(orden); + + dgvDetalles.DataSource = null; + dgvDetalles.DataSource = detallesorden; + + foreach (DataGridViewColumn column in dgvDetalles.Columns) + { + column.Visible = column.Name == "IdPresupuesto" || column.Name == "NombreProducto" || column.Name == "MontoCU" + || column.Name == "Cantidad" || column.Name == "SubTotal"; + } + } + + private void BtnAdd_Click(object sender, EventArgs e) + { + if (dgvOrdenDeCompra.SelectedRows.Count <= 0) return; + var selectedRow = dgvOrdenDeCompra.SelectedRows[0]; + var orden = new OrdenDeCompra + { + Id = Convert.ToInt32(selectedRow.Cells["Id"].Value.ToString()), + }; + orden = ControladoraRemito.Instance.MostrarOrdenDeCompraPorId(orden); + orden.Entregado = true; + if (orden == null) return; + + var remito = new Remito + { + Id = Convert.ToInt32(numId.Value), + Proveedor = orden.Proveedor + }; + foreach (var detalle in orden.MostrarDetalles()) + { + Lote lote = new Lote + { + Id = detalle.Id, + Cantidad = detalle.Cantidad, + Fecha = DateTime.Now, + Habilitado = true, + IdRemito = remito.Id, + Producto = detalle.Producto, + }; + remito.AñadirLote(lote); + } + + var msg = ControladoraRemito.Instance.Añadir(remito, orden); + MessageBox.Show(msg); + this.Close(); } } } diff --git a/Vista/FrmRemito.resx b/Vista/FrmRemito.resx index 1af7de1..a395bff 100644 --- a/Vista/FrmRemito.resx +++ b/Vista/FrmRemito.resx @@ -1,24 +1,24 @@  - diff --git a/Vista/FrmRemitos.Designer.cs b/Vista/FrmRemitos.Designer.cs index 570d789..fb4b297 100644 --- a/Vista/FrmRemitos.Designer.cs +++ b/Vista/FrmRemitos.Designer.cs @@ -29,24 +29,93 @@ private void InitializeComponent() { groupBox1 = new GroupBox(); + label3 = new Label(); + label2 = new Label(); + label1 = new Label(); + dgvTodosLotes = new DataGridView(); + dgvDetallesRemito = new DataGridView(); dgvRemito = new DataGridView(); BtnAdd = new Button(); groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dgvTodosLotes).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dgvDetallesRemito).BeginInit(); ((System.ComponentModel.ISupportInitialize)dgvRemito).BeginInit(); SuspendLayout(); // // groupBox1 // + groupBox1.Controls.Add(label3); + groupBox1.Controls.Add(label2); + groupBox1.Controls.Add(label1); + groupBox1.Controls.Add(dgvTodosLotes); + groupBox1.Controls.Add(dgvDetallesRemito); groupBox1.Controls.Add(dgvRemito); groupBox1.Controls.Add(BtnAdd); groupBox1.Location = new Point(12, 12); groupBox1.Name = "groupBox1"; - groupBox1.Size = new Size(776, 351); + groupBox1.Size = new Size(1183, 432); groupBox1.TabIndex = 5; groupBox1.TabStop = false; // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(6, 301); + label3.Name = "label3"; + label3.Size = new Size(90, 15); + label3.TabIndex = 8; + label3.Text = "Todos Los Lotes"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(562, 4); + label2.Name = "label2"; + label2.Size = new Size(48, 15); + label2.TabIndex = 7; + label2.Text = "Detalles"; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(6, 4); + label1.Name = "label1"; + label1.Size = new Size(50, 15); + label1.TabIndex = 6; + label1.Text = "Remitos"; + // + // dgvTodosLotes + // + dgvTodosLotes.AllowUserToAddRows = false; + dgvTodosLotes.AllowUserToDeleteRows = false; + dgvTodosLotes.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dgvTodosLotes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dgvTodosLotes.EditMode = DataGridViewEditMode.EditProgrammatically; + dgvTodosLotes.Location = new Point(0, 319); + dgvTodosLotes.Name = "dgvTodosLotes"; + dgvTodosLotes.RowTemplate.Height = 25; + dgvTodosLotes.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dgvTodosLotes.Size = new Size(1171, 107); + dgvTodosLotes.TabIndex = 5; + // + // dgvDetallesRemito + // + dgvDetallesRemito.AllowUserToAddRows = false; + dgvDetallesRemito.AllowUserToDeleteRows = false; + dgvDetallesRemito.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dgvDetallesRemito.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dgvDetallesRemito.EditMode = DataGridViewEditMode.EditProgrammatically; + dgvDetallesRemito.Location = new Point(562, 22); + dgvDetallesRemito.Name = "dgvDetallesRemito"; + dgvDetallesRemito.RowTemplate.Height = 25; + dgvDetallesRemito.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dgvDetallesRemito.Size = new Size(609, 235); + dgvDetallesRemito.TabIndex = 4; + // // dgvRemito // + dgvRemito.AllowUserToAddRows = false; + dgvRemito.AllowUserToDeleteRows = false; dgvRemito.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dgvRemito.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dgvRemito.EditMode = DataGridViewEditMode.EditProgrammatically; @@ -56,26 +125,31 @@ dgvRemito.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvRemito.Size = new Size(550, 235); dgvRemito.TabIndex = 3; + dgvRemito.CellClick += dgvRemito_CellClick; // // BtnAdd // - BtnAdd.Location = new Point(6, 302); + BtnAdd.Location = new Point(6, 263); BtnAdd.Name = "BtnAdd"; BtnAdd.Size = new Size(75, 23); BtnAdd.TabIndex = 0; BtnAdd.Text = "Añadir"; BtnAdd.UseVisualStyleBackColor = true; + BtnAdd.Click += BtnAdd_Click; // // FrmRemitos // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); + ClientSize = new Size(1281, 450); Controls.Add(groupBox1); Name = "FrmRemitos"; Text = "Remitos"; WindowState = FormWindowState.Maximized; groupBox1.ResumeLayout(false); + groupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dgvTodosLotes).EndInit(); + ((System.ComponentModel.ISupportInitialize)dgvDetallesRemito).EndInit(); ((System.ComponentModel.ISupportInitialize)dgvRemito).EndInit(); ResumeLayout(false); } @@ -85,5 +159,10 @@ private GroupBox groupBox1; private DataGridView dgvRemito; private Button BtnAdd; + private Label label3; + private Label label2; + private Label label1; + private DataGridView dgvTodosLotes; + private DataGridView dgvDetallesRemito; } } \ No newline at end of file diff --git a/Vista/FrmRemitos.cs b/Vista/FrmRemitos.cs index e001046..f56409f 100644 --- a/Vista/FrmRemitos.cs +++ b/Vista/FrmRemitos.cs @@ -1,4 +1,6 @@ -using System; +using Controladora; +using Entidades; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -15,6 +17,48 @@ namespace Vista public FrmRemitos() { InitializeComponent(); + ActualizarGrilla(); + } + private void ActualizarGrilla() + { + dgvTodosLotes.DataSource = null; + dgvTodosLotes.DataSource = ControladoraRemito.Instance.ListarLotes(); + foreach (DataGridViewColumn column in dgvTodosLotes.Columns) + { + column.Visible = column.Name == "Id" || column.Name == "Fecha" + || column.Name == "Cantidad" || column.Name == "NombreProducto"; + } + + dgvRemito.DataSource = null; + dgvRemito.DataSource = ControladoraRemito.Instance.Listar(); + foreach (DataGridViewColumn column in dgvRemito.Columns) + { + column.Visible = column.Name == "Id" || column.Name == "NombreProveedor"; + } + } + private void BtnAdd_Click(object sender, EventArgs e) + { + var form = new FrmRemito(); + form.ShowDialog(); + ActualizarGrilla(); + } + + private void dgvRemito_CellClick(object sender, DataGridViewCellEventArgs e) + { + if (dgvRemito.SelectedRows.Count == 0) return; + + int ordenid = Convert.ToInt32(dgvRemito.SelectedRows[0].Cells["Id"].Value.ToString()); + + var rem = new Remito { Id = ordenid }; + + var detallesrem = ControladoraRemito.Instance.ListarLotesPorRemito(rem); + dgvDetallesRemito.DataSource = null; + dgvDetallesRemito.DataSource = detallesrem; + foreach (DataGridViewColumn column in dgvDetallesRemito.Columns) + { + column.Visible = column.Name == "Id" || column.Name == "Fecha" + || column.Name == "Cantidad" || column.Name == "NombreProducto"; + } } } } diff --git a/Vista/PantallaPrincipal.Designer.cs b/Vista/PantallaPrincipal.Designer.cs index 4cb7eb0..7b00f5e 100644 --- a/Vista/PantallaPrincipal.Designer.cs +++ b/Vista/PantallaPrincipal.Designer.cs @@ -62,49 +62,49 @@ // clientesToolStripMenuItem // clientesToolStripMenuItem.Name = "clientesToolStripMenuItem"; - clientesToolStripMenuItem.Size = new Size(180, 22); + clientesToolStripMenuItem.Size = new Size(164, 22); clientesToolStripMenuItem.Text = "Clientes"; clientesToolStripMenuItem.Click += clientesToolStripMenuItem_Click; // // ventasToolStripMenuItem // ventasToolStripMenuItem.Name = "ventasToolStripMenuItem"; - ventasToolStripMenuItem.Size = new Size(180, 22); + ventasToolStripMenuItem.Size = new Size(164, 22); ventasToolStripMenuItem.Text = "Ventas"; ventasToolStripMenuItem.Click += ventasToolStripMenuItem_Click; // // proveedoresToolStripMenuItem // proveedoresToolStripMenuItem.Name = "proveedoresToolStripMenuItem"; - proveedoresToolStripMenuItem.Size = new Size(180, 22); + proveedoresToolStripMenuItem.Size = new Size(164, 22); proveedoresToolStripMenuItem.Text = "Proveedores"; proveedoresToolStripMenuItem.Click += proveedoresToolStripMenuItem_Click; // // productosToolStripMenuItem // productosToolStripMenuItem.Name = "productosToolStripMenuItem"; - productosToolStripMenuItem.Size = new Size(180, 22); + productosToolStripMenuItem.Size = new Size(164, 22); productosToolStripMenuItem.Text = "Productos"; productosToolStripMenuItem.Click += productosToolStripMenuItem_Click; // // remitosToolStripMenuItem // remitosToolStripMenuItem.Name = "remitosToolStripMenuItem"; - remitosToolStripMenuItem.Size = new Size(180, 22); + remitosToolStripMenuItem.Size = new Size(164, 22); remitosToolStripMenuItem.Text = "Remitos"; remitosToolStripMenuItem.Click += remitosToolStripMenuItem_Click; // // ordenDeCompraToolStripMenuItem // ordenDeCompraToolStripMenuItem.Name = "ordenDeCompraToolStripMenuItem"; - ordenDeCompraToolStripMenuItem.Size = new Size(180, 22); + ordenDeCompraToolStripMenuItem.Size = new Size(164, 22); ordenDeCompraToolStripMenuItem.Text = "OrdenDeCompra"; ordenDeCompraToolStripMenuItem.Click += ordenDeCompraToolStripMenuItem_Click; // // pedidosPresupuestoToolStripMenuItem // pedidosPresupuestoToolStripMenuItem.Name = "pedidosPresupuestoToolStripMenuItem"; - pedidosPresupuestoToolStripMenuItem.Size = new Size(180, 22); + pedidosPresupuestoToolStripMenuItem.Size = new Size(164, 22); pedidosPresupuestoToolStripMenuItem.Text = "Presupuesto"; pedidosPresupuestoToolStripMenuItem.Click += pedidosPresupuestoToolStripMenuItem_Click; // @@ -131,7 +131,7 @@ IsMdiContainer = true; MainMenuStrip = menuStrip1; Name = "PantallaPrincipal"; - Text = "Form1"; + Text = "Sistema Control de Stock"; WindowState = FormWindowState.Maximized; menuStrip1.ResumeLayout(false); menuStrip1.PerformLayout(); diff --git a/Vista/Vista.csproj.user b/Vista/Vista.csproj.user index 50cc180..5857e23 100644 --- a/Vista/Vista.csproj.user +++ b/Vista/Vista.csproj.user @@ -5,9 +5,6 @@ Form - - Form - Form