diff --git a/Controladora/ControladoraOrdenesDeCompra.cs b/Controladora/ControladoraOrdenesDeCompra.cs index c0d508e..50fc760 100644 --- a/Controladora/ControladoraOrdenesDeCompra.cs +++ b/Controladora/ControladoraOrdenesDeCompra.cs @@ -38,6 +38,7 @@ namespace Controladora >>>>>>> 675d86f (refactor: Cambiada la estructura de las controladoras) { if (t == null) return "El OrdenDeCompra es nulo fallo la carga"; + if (t.Id < 0) return "El Id esta mal cargado"; return (RepositorioOrdenDeCompra.Instance.Del(t)) ? $"El OrdenDeCompra {t.Id} se Elimino correctamente": diff --git a/Controladora/bin/Debug/net6.0/Controladora.dll b/Controladora/bin/Debug/net6.0/Controladora.dll index 6d38b34..add0974 100644 Binary files a/Controladora/bin/Debug/net6.0/Controladora.dll and b/Controladora/bin/Debug/net6.0/Controladora.dll differ diff --git a/Controladora/bin/Debug/net6.0/Controladora.pdb b/Controladora/bin/Debug/net6.0/Controladora.pdb index e743b81..230be54 100644 Binary files a/Controladora/bin/Debug/net6.0/Controladora.pdb and b/Controladora/bin/Debug/net6.0/Controladora.pdb differ diff --git a/Controladora/obj/Debug/net6.0/Controladora.dll b/Controladora/obj/Debug/net6.0/Controladora.dll index 6d38b34..add0974 100644 Binary files a/Controladora/obj/Debug/net6.0/Controladora.dll and b/Controladora/obj/Debug/net6.0/Controladora.dll differ diff --git a/Controladora/obj/Debug/net6.0/Controladora.pdb b/Controladora/obj/Debug/net6.0/Controladora.pdb index e743b81..230be54 100644 Binary files a/Controladora/obj/Debug/net6.0/Controladora.pdb and b/Controladora/obj/Debug/net6.0/Controladora.pdb differ diff --git a/Entidades/DetalleOrdenDeCompra.cs b/Entidades/DetalleOrdenDeCompra.cs index e059d38..3185e13 100644 --- a/Entidades/DetalleOrdenDeCompra.cs +++ b/Entidades/DetalleOrdenDeCompra.cs @@ -4,5 +4,6 @@ namespace Entidades public class DetalleOrdenDeCompra: Detalle { public int IdOrdenDeCompra { get; set; } + public double MontoCU { get; set; } } } diff --git a/Entidades/Entidades.cd b/Entidades/Entidades.cd index 850af99..fdad442 100644 --- a/Entidades/Entidades.cd +++ b/Entidades/Entidades.cd @@ -14,29 +14,44 @@ Cliente.cs - - + + AAACAAEAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAA= Detalle.cs - + + + + + + + + + AAAAAAAAAAAEAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= DetalleFactura.cs - + - AAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + AAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAA= DetalleOrdenDeCompra.cs - + + + + + + + + AAAAAAAAAAAEAAAAAAAAEAAAQABAAAAAAAAAAAAAAAA= DetallePresupuesto.cs @@ -66,29 +81,40 @@ - + + + + + + - AAACAACAAAAQAAAAAAAAAAADBAABAAAAAAAAAAAAAAA= + AAACAAAAAAAQAAAAAAAAAAADBAABAAAAAAAAAAAAAAA= OrdenDeCompra.cs - - + - - + + + + + + + + + AAACAAAAAAAQAAEAAAAAAAADBAADABAAAAAAAAAAAAA= Presupuesto.cs @@ -101,16 +127,17 @@ - + + - - - - + + diff --git a/Entidades/OrdenDeCompra.cs b/Entidades/OrdenDeCompra.cs index 95a0af4..f396dee 100644 --- a/Entidades/OrdenDeCompra.cs +++ b/Entidades/OrdenDeCompra.cs @@ -8,8 +8,6 @@ namespace Entidades private List detalles = new List(); public Proveedor Proveedor { get; set; } - public Presupuesto presupuesto { get; set; } - public void AñadirDetalle(DetalleOrdenDeCompra detalle) { detalles.Add(detalle); diff --git a/Vista/FrmOrdenDeCompra.Designer.cs b/Vista/FrmOrdenDeCompra.Designer.cs new file mode 100644 index 0000000..f876113 --- /dev/null +++ b/Vista/FrmOrdenDeCompra.Designer.cs @@ -0,0 +1,147 @@ +namespace Vista +{ + partial class FrmOrdenDeCompra + { + /// + /// 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() + { + label1 = new Label(); + dgvPresupuesto = new DataGridView(); + dgvProveedor = new DataGridView(); + label2 = new Label(); + numId = new NumericUpDown(); + ID = new Label(); + btnAddProducto = new Button(); + ((System.ComponentModel.ISupportInitialize)dgvPresupuesto).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dgvProveedor).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numId).BeginInit(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(191, 7); + label1.Name = "label1"; + label1.Size = new Size(77, 15); + label1.TabIndex = 17; + label1.Text = "Presupuestos"; + // + // dgvPresupuesto + // + dgvPresupuesto.AllowUserToAddRows = false; + dgvPresupuesto.AllowUserToDeleteRows = false; + dgvPresupuesto.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dgvPresupuesto.EditMode = DataGridViewEditMode.EditProgrammatically; + dgvPresupuesto.Location = new Point(191, 25); + dgvPresupuesto.MultiSelect = false; + dgvPresupuesto.Name = "dgvPresupuesto"; + dgvPresupuesto.RowTemplate.Height = 25; + dgvPresupuesto.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dgvPresupuesto.Size = new Size(347, 338); + dgvPresupuesto.TabIndex = 16; + // + // dgvProveedor + // + dgvProveedor.AllowUserToAddRows = false; + dgvProveedor.AllowUserToDeleteRows = false; + dgvProveedor.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dgvProveedor.EditMode = DataGridViewEditMode.EditProgrammatically; + dgvProveedor.Location = new Point(544, 25); + dgvProveedor.MultiSelect = false; + dgvProveedor.Name = "dgvProveedor"; + dgvProveedor.RowTemplate.Height = 25; + dgvProveedor.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dgvProveedor.Size = new Size(376, 338); + dgvProveedor.TabIndex = 19; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(544, 7); + label2.Name = "label2"; + label2.Size = new Size(43, 15); + label2.TabIndex = 18; + label2.Text = "Detalle"; + // + // numId + // + numId.Location = new Point(42, 25); + numId.Maximum = new decimal(new int[] { 1410065407, 2, 0, 0 }); + numId.Name = "numId"; + numId.Size = new Size(120, 23); + numId.TabIndex = 21; + // + // ID + // + ID.AutoSize = true; + ID.Location = new Point(18, 27); + ID.Name = "ID"; + ID.Size = new Size(18, 15); + ID.TabIndex = 20; + ID.Text = "ID"; + // + // btnAddProducto + // + btnAddProducto.Location = new Point(191, 369); + btnAddProducto.Name = "btnAddProducto"; + btnAddProducto.Size = new Size(144, 29); + btnAddProducto.TabIndex = 22; + btnAddProducto.Text = "Seleccionar Presupuesto"; + btnAddProducto.UseVisualStyleBackColor = true; + btnAddProducto.Click += btnAddProducto_Click; + // + // OrdenDeCompra + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1194, 450); + Controls.Add(btnAddProducto); + Controls.Add(numId); + Controls.Add(ID); + Controls.Add(dgvProveedor); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(dgvPresupuesto); + Name = "OrdenDeCompra"; + Text = "OrdenDeCompra"; + ((System.ComponentModel.ISupportInitialize)dgvPresupuesto).EndInit(); + ((System.ComponentModel.ISupportInitialize)dgvProveedor).EndInit(); + ((System.ComponentModel.ISupportInitialize)numId).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private DataGridView dgvPresupuesto; + private DataGridView dgvProveedor; + private Label label2; + private NumericUpDown numId; + private Label ID; + private Button btnAddProducto; + } +} \ No newline at end of file diff --git a/Vista/FrmOrdenDeCompra.cs b/Vista/FrmOrdenDeCompra.cs new file mode 100644 index 0000000..1b79c9c --- /dev/null +++ b/Vista/FrmOrdenDeCompra.cs @@ -0,0 +1,38 @@ +using Controladora; +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 FrmOrdenDeCompra : Form + { + public FrmOrdenDeCompra() + { + InitializeComponent(); + } + + private void CargarDatos() + { + dgvPresupuesto.DataSource = null; + var listapresupuesto = ControladoraPresupuestos.Instance.Listar(); + dgvPresupuesto.DataSource = listapresupuesto; + + numId.Value = (listapresupuesto.Count > 0) ? + listapresupuesto.Max(x => x.Id + 1) : + 0; + numId.Enabled = false; + } + + private void btnAddProducto_Click(object sender, EventArgs e) + { + + } + } +} diff --git a/Vista/Remito.resx b/Vista/FrmOrdenDeCompra.resx similarity index 93% rename from Vista/Remito.resx rename to Vista/FrmOrdenDeCompra.resx index 1af7de1..a395bff 100644 --- a/Vista/Remito.resx +++ b/Vista/FrmOrdenDeCompra.resx @@ -1,24 +1,24 @@  - diff --git a/Vista/FrmOrdenesDeCompras.Designer.cs b/Vista/FrmOrdenesDeCompras.Designer.cs index f457d9c..8c11443 100644 --- a/Vista/FrmOrdenesDeCompras.Designer.cs +++ b/Vista/FrmOrdenesDeCompras.Designer.cs @@ -1,6 +1,6 @@ namespace Vista { - partial class FrmOrdenDeCompra + partial class FrmOrdenesDeCompras { /// /// Required designer variable. @@ -29,16 +29,16 @@ private void InitializeComponent() { groupBox1 = new GroupBox(); - dataGridView1 = new DataGridView(); + dgvOrdenDeCompra = new DataGridView(); BtnAdd = new Button(); BtnEliminar = new Button(); groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dgvOrdenDeCompra).BeginInit(); SuspendLayout(); // // groupBox1 // - groupBox1.Controls.Add(dataGridView1); + groupBox1.Controls.Add(dgvOrdenDeCompra); groupBox1.Controls.Add(BtnAdd); groupBox1.Controls.Add(BtnEliminar); groupBox1.Location = new Point(12, 3); @@ -47,15 +47,15 @@ groupBox1.TabIndex = 4; groupBox1.TabStop = false; // - // dataGridView1 + // dgvOrdenDeCompra // - dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells; - dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView1.Location = new Point(6, 22); - dataGridView1.Name = "dataGridView1"; - dataGridView1.RowTemplate.Height = 25; - dataGridView1.Size = new Size(550, 235); - dataGridView1.TabIndex = 3; + dgvOrdenDeCompra.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells; + dgvOrdenDeCompra.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dgvOrdenDeCompra.Location = new Point(6, 22); + dgvOrdenDeCompra.Name = "dgvOrdenDeCompra"; + dgvOrdenDeCompra.RowTemplate.Height = 25; + dgvOrdenDeCompra.Size = new Size(550, 235); + dgvOrdenDeCompra.TabIndex = 3; // // BtnAdd // @@ -75,25 +75,26 @@ BtnEliminar.TabIndex = 2; BtnEliminar.Text = "Eliminar"; BtnEliminar.UseVisualStyleBackColor = true; + BtnEliminar.Click += BtnEliminar_Click; // - // FrmOrdenDeCompra + // FrmOrdenesDeCompras // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(800, 450); Controls.Add(groupBox1); - Name = "FrmOrdenDeCompra"; + Name = "FrmOrdenesDeCompras"; Text = "OrdenDeCompra"; WindowState = FormWindowState.Maximized; groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + ((System.ComponentModel.ISupportInitialize)dgvOrdenDeCompra).EndInit(); ResumeLayout(false); } #endregion private GroupBox groupBox1; - private DataGridView dataGridView1; + private DataGridView dgvOrdenDeCompra; private Button BtnAdd; private Button BtnEliminar; } diff --git a/Vista/FrmOrdenesDeCompras.cs b/Vista/FrmOrdenesDeCompras.cs index 003a857..8babef4 100644 --- a/Vista/FrmOrdenesDeCompras.cs +++ b/Vista/FrmOrdenesDeCompras.cs @@ -1,4 +1,6 @@ -using System; +using Controladora; +using Entidades; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -10,16 +12,63 @@ using System.Windows.Forms; namespace Vista { - public partial class FrmOrdenDeCompra : Form + public partial class FrmOrdenesDeCompras : Form { - public FrmOrdenDeCompra() + public FrmOrdenesDeCompras() { InitializeComponent(); } private void BtnAdd_Click(object sender, EventArgs e) { + using (var form = new FrmOrdenDeCompra()) + { + form.ShowDialog(); + ActualizarGrilla(); + } + } + private void ActualizarGrilla() + { + dgvOrdenDeCompra.DataSource = null; + dgvOrdenDeCompra.DataSource = ControladoraOrdenDeCompras.Instance.Listar(); + + } + + private void BtnEliminar_Click(object sender, EventArgs e) + { + // Verifica si hay filas seleccionadas en dgvPresupuestos + if (dgvOrdenDeCompra.SelectedRows.Count == 0) + { + MessageBox.Show("Por favor, selecciona una orden de Compra para eliminar."); + return; + } + + // Recupera el ID del presupuesto seleccionado + int ordenId = Convert.ToInt32(dgvOrdenDeCompra.SelectedRows[0].Cells["Id"].Value.ToString()); + + // Crea un objeto de Presupuesto con el ID recuperado + var orden = new OrdenDeCompra { Id = ordenId }; + + // Confirma la eliminación con el usuario + var result = MessageBox.Show("¿Estás seguro de que deseas eliminar esta orden?", "Confirmar Eliminación", MessageBoxButtons.YesNo); + if (result == DialogResult.Yes) + { + try + { + // Llama al método Eliminar de la controladora con el objeto Presupuesto + ControladoraOrdenDeCompras.Instance.Eliminar(orden); + + // Actualiza la grilla de presupuestos después de eliminar el presupuesto + ActualizarGrilla(); + + MessageBox.Show("Orden eliminado exitosamente."); + } + catch (Exception ex) + { + MessageBox.Show($"Error al eliminar la Orden de Compra: {ex.Message}"); + } + } } } } diff --git a/Vista/FrmOrdenesDeCompras.resx b/Vista/FrmOrdenesDeCompras.resx index af32865..a395bff 100644 --- a/Vista/FrmOrdenesDeCompras.resx +++ b/Vista/FrmOrdenesDeCompras.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/FrmPresupuesto.Designer.cs b/Vista/FrmPresupuesto.Designer.cs index cdbef5c..6debb65 100644 --- a/Vista/FrmPresupuesto.Designer.cs +++ b/Vista/FrmPresupuesto.Designer.cs @@ -70,7 +70,7 @@ // ID // ID.AutoSize = true; - ID.Location = new Point(11, 26); + ID.Location = new Point(26, 20); ID.Name = "ID"; ID.Size = new Size(18, 15); ID.TabIndex = 2; diff --git a/Vista/Remito.Designer.cs b/Vista/FrmRemito.Designer.cs similarity index 97% rename from Vista/Remito.Designer.cs rename to Vista/FrmRemito.Designer.cs index 7c6a81c..b88905b 100644 --- a/Vista/Remito.Designer.cs +++ b/Vista/FrmRemito.Designer.cs @@ -1,6 +1,6 @@ namespace Vista { - partial class Remito + partial class FrmRemito { /// /// Required designer variable. diff --git a/Vista/Remito.cs b/Vista/FrmRemito.cs similarity index 81% rename from Vista/Remito.cs rename to Vista/FrmRemito.cs index fc7f2a8..16d3e94 100644 --- a/Vista/Remito.cs +++ b/Vista/FrmRemito.cs @@ -10,9 +10,9 @@ using System.Windows.Forms; namespace Vista { - public partial class Remito : Form + public partial class FrmRemito : Form { - public Remito() + public FrmRemito() { InitializeComponent(); } diff --git a/Vista/OrdenDeCompra.resx b/Vista/FrmRemito.resx similarity index 100% rename from Vista/OrdenDeCompra.resx rename to Vista/FrmRemito.resx diff --git a/Vista/OrdenDeCompra.Designer.cs b/Vista/OrdenDeCompra.Designer.cs deleted file mode 100644 index 7919e38..0000000 --- a/Vista/OrdenDeCompra.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace Vista -{ - partial class OrdenDeCompra - { - /// - /// 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() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "OrdenDeCompra"; - } - - #endregion - } -} \ No newline at end of file diff --git a/Vista/OrdenDeCompra.cs b/Vista/OrdenDeCompra.cs deleted file mode 100644 index 340bbc8..0000000 --- a/Vista/OrdenDeCompra.cs +++ /dev/null @@ -1,20 +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 OrdenDeCompra : Form - { - public OrdenDeCompra() - { - InitializeComponent(); - } - } -} diff --git a/Vista/Program.cs b/Vista/Program.cs index 9b3601a..ccaab06 100644 --- a/Vista/Program.cs +++ b/Vista/Program.cs @@ -79,6 +79,24 @@ namespace Vista producto.AñadirProveedor(proveedor); ControladoraProductos.Instance.Añadir(producto); + Presupuesto presupuesto = new Presupuesto + { + Id = 1, + Aceptado = false, + Habilitado = true, + Fecha = DateTime.Now, + Proveedor = proveedor, + }; + presupuesto.AñadirDetalle(new DetallePresupuesto + { + Id = 1, + Cantidad = 2, + IdPresupuesto = 1, + MontoCUPropuesto = 1000, + Producto = producto, + }); + ControladoraPresupuestos.Instance.Añadir(presupuesto); + } } } \ No newline at end of file diff --git a/Vista/Vista.csproj.user b/Vista/Vista.csproj.user index 1f7e571..50cc180 100644 --- a/Vista/Vista.csproj.user +++ b/Vista/Vista.csproj.user @@ -47,13 +47,13 @@ Form - + Form Form - + Form