cambio de nombre, añadida otra precarga de datos para

This commit is contained in:
fedpo
2024-08-05 23:21:01 +01:00
committed by fede
parent 81f879eec3
commit e1502ecab0
22 changed files with 351 additions and 130 deletions

147
Vista/FrmOrdenDeCompra.Designer.cs generated Normal file
View File

@@ -0,0 +1,147 @@
namespace Vista
{
partial class FrmOrdenDeCompra
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

38
Vista/FrmOrdenDeCompra.cs Normal file
View File

@@ -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)
{
}
}
}

View File

@@ -1,24 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
@@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@@ -1,6 +1,6 @@
namespace Vista
{
partial class FrmOrdenDeCompra
partial class FrmOrdenesDeCompras
{
/// <summary>
/// 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;
}

View File

@@ -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}");
}
}
}
}
}

View File

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

View File

@@ -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;

View File

@@ -1,6 +1,6 @@
namespace Vista
{
partial class Remito
partial class FrmRemito
{
/// <summary>
/// Required designer variable.

View File

@@ -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();
}

View File

@@ -1,39 +0,0 @@
namespace Vista
{
partial class OrdenDeCompra
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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
}
}

View File

@@ -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();
}
}
}

View File

@@ -79,6 +79,24 @@ namespace Vista
producto.A<EFBFBD>adirProveedor(proveedor);
ControladoraProductos.Instance.A<EFBFBD>adir(producto);
Presupuesto presupuesto = new Presupuesto
{
Id = 1,
Aceptado = false,
Habilitado = true,
Fecha = DateTime.Now,
Proveedor = proveedor,
};
presupuesto.A<EFBFBD>adirDetalle(new DetallePresupuesto
{
Id = 1,
Cantidad = 2,
IdPresupuesto = 1,
MontoCUPropuesto = 1000,
Producto = producto,
});
ControladoraPresupuestos.Instance.A<EFBFBD>adir(presupuesto);
}
}
}

View File

@@ -47,13 +47,13 @@
<Compile Update="FrmRemitos.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="OrdenDeCompra.cs">
<Compile Update="FrmOrdenDeCompra.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="PantallaPrincipal.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Remito.cs">
<Compile Update="FrmRemito.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>