más cambios ahora funciona el tema de las facturas pero no el emailer
This commit is contained in:
@@ -30,37 +30,25 @@ namespace Vista
|
||||
dgvProductos.DataSource = null;
|
||||
dgvProductos.DataSource = ControladoraFacturas.Instance.ListarProductos();
|
||||
|
||||
dgvDetalles.AutoGenerateColumns = false;
|
||||
dgvClientes.DataSource = null;
|
||||
dgvClientes.DataSource = ControladoraFacturas.Instance.ListarClientes();
|
||||
|
||||
// Definir las columnas manualmente
|
||||
dgvDetalles.Columns.Add(new DataGridViewTextBoxColumn
|
||||
|
||||
foreach (DataGridViewColumn column in dgvDetalles.Columns)
|
||||
{
|
||||
DataPropertyName = "Id", // Usa la propiedad NombreProducto
|
||||
HeaderText = "Id",
|
||||
Name = "Id"
|
||||
});
|
||||
dgvDetalles.Columns.Add(new DataGridViewTextBoxColumn
|
||||
column.Visible = column.Name == "Id" || column.Name == "Producto" || column.Name == "Cantidad"
|
||||
|| column.Name == "PrecioUnitario" || column.Name == "Subtotal";
|
||||
}
|
||||
|
||||
foreach (DataGridViewColumn column in dgvClientes.Columns)
|
||||
{
|
||||
DataPropertyName = "Producto", // Usa la propiedad NombreProducto
|
||||
HeaderText = "Producto",
|
||||
Name = "Producto"
|
||||
});
|
||||
dgvDetalles.Columns.Add(new DataGridViewTextBoxColumn
|
||||
column.Visible = column.Name == "Cuit" || column.Name == "NombreCompleto" || column.Name == "Correo";
|
||||
}
|
||||
|
||||
foreach (DataGridViewColumn column in dgvProductos.Columns)
|
||||
{
|
||||
DataPropertyName = "CantidadDeProductos",
|
||||
HeaderText = "Cantidad",
|
||||
Name = "CantidadDeProductos"
|
||||
});
|
||||
dgvDetalles.Columns.Add(new DataGridViewTextBoxColumn
|
||||
{
|
||||
DataPropertyName = "PrecioUnitario",
|
||||
HeaderText = "PrecioUnitario"
|
||||
});
|
||||
dgvDetalles.Columns.Add(new DataGridViewTextBoxColumn
|
||||
{
|
||||
DataPropertyName = "Subtotal",
|
||||
HeaderText = "Subtotal"
|
||||
});
|
||||
column.Visible = column.Name == "Id" || column.Name == "Nombre" || column.Name == "Precio";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,7 +88,7 @@ namespace Vista
|
||||
string devolucion = "";
|
||||
|
||||
if (string.IsNullOrEmpty(numid.Text)) devolucion += "El ID no puede ser nulo o vacío\n";
|
||||
//if (cmbCliente.SelectedIndex == -1) devolucion += "Debe seleccionar un cliente\n";
|
||||
//if (dgvClientes.Enabled == true) devolucion += "Debe seleccionar un cliente\n";
|
||||
|
||||
if (devolucion == "")
|
||||
{
|
||||
@@ -120,8 +108,7 @@ namespace Vista
|
||||
{
|
||||
factura.Total = Convert.ToDouble(numtotal.Value);
|
||||
factura.Fecha = datepick.Value;
|
||||
factura.Id = Convert.ToInt32(numid.Value);
|
||||
|
||||
factura.Cliente = new Cliente { Cuit = (long)dgvClientes.SelectedRows[0].Cells["Cuit"].Value };
|
||||
|
||||
string mensaje = ControladoraFacturas.Instance.Añadir(factura);
|
||||
MessageBox.Show(mensaje, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
@@ -131,7 +118,10 @@ namespace Vista
|
||||
|
||||
private void btnAddDetalle_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Validar los datos antes de crear el detalle
|
||||
|
||||
// No quiero que cambien de cliente una vez que ya empezaron a armar la factura
|
||||
dgvClientes.Enabled = false;
|
||||
|
||||
if (ValidarDatosdetalle()) return;
|
||||
if (dgvProductos.SelectedRows.Count > 0)
|
||||
{
|
||||
@@ -147,9 +137,8 @@ namespace Vista
|
||||
|
||||
factura.AñadirDetalle(new DetalleFactura
|
||||
{
|
||||
Id = int.Parse(detalleid++.ToString()),
|
||||
|
||||
Cantidad = (int)numCantidad.Value,
|
||||
IdFactura = factura.Id,
|
||||
Producto = ControladoraProductos.Instance.Listar().First(x => x.Id == producto.Id),
|
||||
});
|
||||
ActualizarGrillaDetalles();
|
||||
|
||||
Reference in New Issue
Block a user