167 lines
5.8 KiB
C#
167 lines
5.8 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.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace compabetov2
|
|
{
|
|
public partial class mermas : Form
|
|
{
|
|
private LoginModel loginPrincipal;
|
|
private List<Merma> mermasList;
|
|
public mermas(LoginModel loginPrincipal)
|
|
{
|
|
InitializeComponent();
|
|
this.loginPrincipal = loginPrincipal;
|
|
llenarPanel();
|
|
}
|
|
|
|
public void llenarPanel()
|
|
{
|
|
mermaPanel.Controls.Clear();
|
|
getData();
|
|
foreach (Merma merma in mermasList)
|
|
{
|
|
TableLayoutPanel carta = new TableLayoutPanel();
|
|
carta.RowCount = 1;
|
|
carta.ColumnCount = 2;
|
|
carta.Height = 100;
|
|
carta.Width = 770;
|
|
carta.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
|
|
carta.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
|
|
carta.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
|
carta.BorderStyle = BorderStyle.FixedSingle;
|
|
|
|
|
|
Label fecha = new Label();
|
|
fecha.Text = merma.fecha;
|
|
fecha.Dock = DockStyle.Fill;
|
|
fecha.TextAlign = ContentAlignment.MiddleLeft;
|
|
fecha.Font = new Font(fecha.Font.FontFamily, 16, FontStyle.Bold);
|
|
|
|
TableLayoutPanel panelBotones = new TableLayoutPanel();
|
|
panelBotones.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
|
|
panelBotones.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
|
|
panelBotones.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
|
|
panelBotones.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
|
panelBotones.Dock = DockStyle.Fill;
|
|
|
|
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)
|
|
{
|
|
verMerma ver = new verMerma(merma);
|
|
ver.Owner = this;
|
|
ver.Show();
|
|
});
|
|
|
|
Button btnEditar = new Button();
|
|
btnEditar.Text = "Editar";
|
|
btnEditar.Dock = DockStyle.Fill;
|
|
btnEditar.FlatStyle = FlatStyle.Flat;
|
|
btnEditar.FlatAppearance.BorderSize = 0;
|
|
btnEditar.BackColor = Color.FromArgb(33, 90, 255);
|
|
btnEditar.Font = new Font(btnVer.Font.FontFamily, 16);
|
|
btnEditar.ForeColor = Color.White;
|
|
btnEditar.Click += new EventHandler(delegate (object sender, EventArgs e)
|
|
{
|
|
ActualizarMerma ver = new ActualizarMerma(merma,this);
|
|
ver.Owner = this;
|
|
ver.Show();
|
|
});
|
|
|
|
|
|
Button btnEliminar = new Button();
|
|
btnEliminar.Text = "Eliminar";
|
|
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)
|
|
{
|
|
if (service.eliminarMerma(merma))
|
|
{
|
|
llenarPanel();
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
panelBotones.Controls.Add(btnVer,0,0);
|
|
panelBotones.Controls.Add(btnEditar,1,0);
|
|
panelBotones.Controls.Add(btnEliminar,2,0);
|
|
|
|
carta.Controls.Add(fecha,0,0);
|
|
carta.Controls.Add(panelBotones,1,0);
|
|
|
|
mermaPanel.Controls.Add(carta);
|
|
}
|
|
}
|
|
|
|
private void getData()
|
|
{
|
|
mermasList = service.conseguirMerma();
|
|
}
|
|
|
|
private void mermas_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void horafecha_Tick(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void horafecha_Tick_1(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void horafecha_Tick_2(object sender, EventArgs e)
|
|
{
|
|
lblhora.Text = DateTime.Now.ToString("h:mm:ss");
|
|
lblfecha.Text = DateTime.Now.ToLongDateString();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
MenuPrincipal menuPrincipal = new MenuPrincipal(loginPrincipal);
|
|
menuPrincipal.ShowDialog();
|
|
this.Dispose(true);
|
|
}
|
|
|
|
private void mermaPanel_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void btnAgregar_Click(object sender, EventArgs e)
|
|
{
|
|
agregarmermas agregarmermas = new agregarmermas(this);
|
|
agregarmermas.Owner = this;
|
|
agregarmermas.Show();
|
|
}
|
|
}
|
|
}
|