cuentas
This commit is contained in:
@@ -0,0 +1,187 @@
|
||||
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();
|
||||
panelCuenta.Controls.Clear();
|
||||
|
||||
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, 55F));
|
||||
carta.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 45F));
|
||||
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 = 3;
|
||||
HUDPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
|
||||
HUDPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
|
||||
HUDPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
|
||||
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 = $"Cliente: {cuenta.cliente}\n";
|
||||
foreach (DetalleCuentaModel detalle in detalles)
|
||||
{
|
||||
mensaje += $"{detalle.producto.nombre} - {detalle.cantidad}\n";
|
||||
}
|
||||
MessageBox.Show(mensaje);
|
||||
});
|
||||
|
||||
Button btnSaldar = new Button();
|
||||
btnSaldar.Text = "Saldar";
|
||||
btnSaldar.Dock = DockStyle.Fill;
|
||||
btnSaldar.FlatStyle = FlatStyle.Flat;
|
||||
btnSaldar.FlatAppearance.BorderSize = 0;
|
||||
btnSaldar.BackColor = Color.FromArgb(33, 90, 255);
|
||||
btnSaldar.Font = new Font(btnVer.Font.FontFamily, 16);
|
||||
btnSaldar.ForeColor = Color.White;
|
||||
btnSaldar.Click += new EventHandler(delegate (object sender, EventArgs e)
|
||||
{
|
||||
DialogResult result = MessageBox.Show("¿Está seguro de que desea saldar esta cuenta?",
|
||||
"Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
List<DetalleCuentaModel> detalles = service.conseguirDetalleCuante(cuenta.id);
|
||||
if (service.saldarCuenta(cuenta, detalles))
|
||||
{
|
||||
llenarPanel();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
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 cancelar este registro?",
|
||||
"Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
if (service.cancelarCuenta(cuenta.id))
|
||||
{
|
||||
llenarPanel();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
HUDPanel.Controls.Add(btnVer);
|
||||
HUDPanel.Controls.Add(btnSaldar);
|
||||
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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void cuentas_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user