153 lines
5.7 KiB
C#
153 lines
5.7 KiB
C#
using compabetov2.database;
|
|
using compabetov2.database.modelos;
|
|
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 compabetov2
|
|
{
|
|
public partial class cuentas : Form
|
|
{
|
|
private LoginModel loginPrincipal;
|
|
public cuentas(LoginModel loginPrincipal)
|
|
{
|
|
InitializeComponent();
|
|
this.loginPrincipal = loginPrincipal;
|
|
llenarPanel();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
// Cerrar el formulario de ventas
|
|
this.Close();
|
|
|
|
// Verificar si ya hay una instancia del formulario principal
|
|
MenuPrincipal menuprincipalForm = Application.OpenForms.OfType<MenuPrincipal>().FirstOrDefault();
|
|
|
|
if (menuprincipalForm == null)
|
|
{
|
|
// Si no hay una instancia, crear una nueva
|
|
menuprincipalForm = new MenuPrincipal(loginPrincipal);
|
|
|
|
// Establecer el formulario principal como el formulario MDI padre
|
|
menuprincipalForm.MdiParent = this.MdiParent;
|
|
|
|
// Mostrar el formulario principal
|
|
menuprincipalForm.Show();
|
|
}
|
|
else
|
|
{
|
|
// Si ya hay una instancia, simplemente llevarlo al frente
|
|
menuprincipalForm.BringToFront();
|
|
}
|
|
}
|
|
|
|
private void llenarPanel()
|
|
{
|
|
List<Cuenta> cuentas = service.conseguirCuentaDAO();
|
|
|
|
foreach (Cuenta cuenta in cuentas)
|
|
{
|
|
TableLayoutPanel carta = new TableLayoutPanel();
|
|
carta.RowCount = 1;
|
|
carta.ColumnCount = 2;
|
|
carta.Height = 100;
|
|
carta.Width = 820;
|
|
carta.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 70F));
|
|
carta.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 30F));
|
|
carta.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
|
carta.BackColor = Color.Gray;
|
|
|
|
FlowLayoutPanel infoPanel = new FlowLayoutPanel();
|
|
infoPanel.Dock = DockStyle.Fill;
|
|
infoPanel.FlowDirection = FlowDirection.TopDown;
|
|
|
|
Label cliente = new Label();
|
|
cliente.Text = $"Cliente: {cuenta.cliente}";
|
|
cliente.Font = new Font(cliente.Font.FontFamily, 18);
|
|
cliente.Width = 600;
|
|
|
|
Label fecha = new Label();
|
|
fecha.Text = "Fecha: " + cuenta.fecha;
|
|
fecha.Font = new Font(fecha.Font.FontFamily, 18);
|
|
fecha.Width = 600;
|
|
|
|
Label total = new Label();
|
|
total.Text = "Total: $" + cuenta.total;
|
|
total.Font = new Font(total.Font.FontFamily, 18);
|
|
total.Width = 600;
|
|
|
|
infoPanel.Controls.Add(fecha);
|
|
infoPanel.Controls.Add(cliente);
|
|
infoPanel.Controls.Add(total);
|
|
|
|
TableLayoutPanel HUDPanel = new TableLayoutPanel();
|
|
HUDPanel.Dock = DockStyle.Fill;
|
|
HUDPanel.RowCount = 1;
|
|
HUDPanel.ColumnCount = 2;
|
|
HUDPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
|
|
HUDPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
|
|
HUDPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
|
|
|
Button btnVer = new Button();
|
|
btnVer.Text = "Ver";
|
|
btnVer.Dock = DockStyle.Fill;
|
|
btnVer.FlatStyle = FlatStyle.Flat;
|
|
btnVer.FlatAppearance.BorderSize = 0;
|
|
btnVer.BackColor = Color.FromArgb(33, 90, 255);
|
|
btnVer.Font = new Font(btnVer.Font.FontFamily, 16);
|
|
btnVer.ForeColor = Color.White;
|
|
btnVer.Click += new EventHandler(delegate (object sender, EventArgs e)
|
|
{
|
|
List<DetalleCuentaModel> detalles = service.conseguirDetalleCuante(cuenta.id);
|
|
string mensaje = "";
|
|
foreach (DetalleCuentaModel detalle in detalles)
|
|
{
|
|
mensaje += $"{detalle.producto.nombre} - {detalle.cantidad}\n";
|
|
}
|
|
MessageBox.Show(mensaje);
|
|
});
|
|
|
|
Button btnEliminar = new Button();
|
|
btnEliminar.Text = "Cancelar";
|
|
btnEliminar.Dock = DockStyle.Fill;
|
|
btnEliminar.BackColor = Color.Red;
|
|
btnEliminar.FlatStyle = FlatStyle.Flat;
|
|
btnEliminar.FlatAppearance.BorderSize = 0;
|
|
btnEliminar.Font = new Font(btnVer.Font.FontFamily, 16);
|
|
btnEliminar.ForeColor = Color.White;
|
|
btnEliminar.Click += new EventHandler(delegate (object sender, EventArgs e)
|
|
{
|
|
DialogResult result = MessageBox.Show("¿Está seguro de que desea eliminar este registro?",
|
|
"Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
if (result == DialogResult.Yes)
|
|
{
|
|
}
|
|
});
|
|
|
|
HUDPanel.Controls.Add(btnVer);
|
|
HUDPanel.Controls.Add(btnEliminar);
|
|
|
|
|
|
carta.Controls.Add(infoPanel,0,0);
|
|
carta.Controls.Add(HUDPanel,1,0);
|
|
|
|
panelCuenta.Controls.Add(carta);
|
|
panelCuenta.BackColor = Color.Aqua;
|
|
|
|
}
|
|
}
|
|
|
|
private void panelCuenta_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|