228 lines
8.5 KiB
C#
228 lines
8.5 KiB
C#
using compabetov2.database;
|
|
using compabetov2.database.modelos;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace compabetov2
|
|
{
|
|
public partial class personal : Form
|
|
{
|
|
List<Empleado> empleados;
|
|
public personal()
|
|
{
|
|
InitializeComponent();
|
|
llenarPanel();
|
|
}
|
|
|
|
public void llenarPanel()
|
|
{
|
|
personalPanel.Controls.Clear();
|
|
empleados = service.conseguirEmpleados();
|
|
|
|
foreach(Empleado empleado in empleados)
|
|
{
|
|
TableLayoutPanel empleadoLayout = new TableLayoutPanel();
|
|
empleadoLayout.RowCount = 1;
|
|
empleadoLayout.ColumnCount = 2;
|
|
empleadoLayout.Height = 100;
|
|
empleadoLayout.Width = 900;
|
|
empleadoLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
|
|
empleadoLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
|
|
empleadoLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
|
empleadoLayout.BorderStyle = BorderStyle.FixedSingle;
|
|
|
|
TableLayoutPanel infoEmpleado = new TableLayoutPanel();
|
|
infoEmpleado.RowCount = 1;
|
|
infoEmpleado.ColumnCount = 2;
|
|
infoEmpleado.Dock = DockStyle.Fill;
|
|
|
|
Label idEmpleado = new Label();
|
|
idEmpleado.Text = empleado.idempleado.ToString();
|
|
idEmpleado.BackColor = Color.FromArgb(82, 82, 82);
|
|
idEmpleado.ForeColor = Color.White;
|
|
idEmpleado.AutoSize = true;
|
|
idEmpleado.Dock = DockStyle.Left;
|
|
|
|
PictureBox imgEmpleado = new PictureBox();
|
|
imgEmpleado.Dock = DockStyle.Fill;
|
|
string rutaImg = Path.Combine(Application.StartupPath, "Resources", "usuarios", "usuarioAnonimo.png");
|
|
imgEmpleado.Image = Image.FromFile(rutaImg);
|
|
imgEmpleado.BackgroundImageLayout = ImageLayout.Stretch;
|
|
imgEmpleado.SizeMode = PictureBoxSizeMode.Zoom;
|
|
imgEmpleado.Controls.Add(idEmpleado);
|
|
|
|
Label nombreEmpleado = new Label();
|
|
nombreEmpleado.Dock = DockStyle.Fill;
|
|
nombreEmpleado.Text = empleado.nombre;
|
|
nombreEmpleado.Font = new Font(nombreEmpleado.Font.FontFamily, 16);
|
|
nombreEmpleado.TextAlign = ContentAlignment.MiddleLeft;
|
|
|
|
TableLayoutPanel panelBotones = new TableLayoutPanel();
|
|
panelBotones.RowCount = 1;
|
|
panelBotones.ColumnCount = 4;
|
|
panelBotones.Dock = DockStyle.Fill;
|
|
panelBotones.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
|
|
panelBotones.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
|
|
panelBotones.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
|
|
panelBotones.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
|
|
|
|
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)
|
|
{
|
|
string informacion = $"Nombre: {empleado.nombre} {empleado.apellidos}\nCalle: {empleado.calle}\nColonia: {empleado.colonia}\n" +
|
|
$"Codigo postal: {empleado.cp}\nNumero Exterior: {empleado.no_ext}\nNumero Interior: {empleado.no_int}\nReferencia: {empleado.referencia}" +
|
|
$"\nFecha de nacimiento: {empleado.fecha_nac}\nTelefono: {empleado.telefono}";
|
|
MessageBox.Show(informacion,"Informacion");
|
|
});
|
|
|
|
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)
|
|
{
|
|
EditarEmpleado editarEmpleado = new EditarEmpleado(empleado,this);
|
|
editarEmpleado.Show();
|
|
});
|
|
|
|
Button btnEliminar = new Button();
|
|
btnEliminar.Text = "Eliminar";
|
|
btnEliminar.BackColor = Color.Red;
|
|
btnEliminar.Dock = DockStyle.Fill;
|
|
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 a {empleado.nombre}?",
|
|
"Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
if (result == DialogResult.Yes)
|
|
{
|
|
service.eliminarEmpleado(empleado.idempleado);
|
|
llenarPanel();
|
|
}
|
|
});
|
|
|
|
Button btnLogin = new Button();
|
|
btnLogin.Text = "Login";
|
|
btnLogin.Dock = DockStyle.Fill;
|
|
btnLogin.FlatStyle = FlatStyle.Flat;
|
|
btnLogin.FlatAppearance.BorderSize = 0;
|
|
btnLogin.Font = new Font(btnVer.Font.FontFamily, 16);
|
|
if(empleado.fkIdLogin == null) {
|
|
|
|
btnLogin.Click += new EventHandler(delegate (object sender, EventArgs e)
|
|
{
|
|
AgregarLogin agregarLogin = new AgregarLogin();
|
|
agregarLogin.Show();
|
|
});
|
|
}
|
|
else
|
|
{
|
|
btnLogin.BackColor = Color.Yellow;
|
|
btnLogin.Click += new EventHandler(delegate (object sender, EventArgs e)
|
|
{
|
|
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
infoEmpleado.Controls.Add(imgEmpleado,0,0);
|
|
infoEmpleado.Controls.Add(nombreEmpleado,1,0);
|
|
|
|
panelBotones.Controls.Add(btnVer,0,0);
|
|
panelBotones.Controls.Add(btnEditar,1,0);
|
|
panelBotones.Controls.Add(btnEliminar,2,0);
|
|
panelBotones.Controls.Add(btnLogin,3,0);
|
|
|
|
empleadoLayout.Controls.Add(infoEmpleado,0,0);
|
|
empleadoLayout.Controls.Add(panelBotones,1,0);
|
|
personalPanel.Controls.Add(empleadoLayout);
|
|
}
|
|
}
|
|
|
|
|
|
private void label1_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void button6_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
}
|
|
|
|
|
|
|
|
private void personal_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void button7_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void button8_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lblhora_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void flowLayoutPanel3_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void btnAgregar_Click(object sender, EventArgs e)
|
|
{
|
|
AgregarEmpleado agregarEmpleado = new AgregarEmpleado(this);
|
|
agregarEmpleado.Show();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
MenuPrincipal menuPrincipal = new MenuPrincipal();
|
|
menuPrincipal.Show();
|
|
this.Dispose(true);
|
|
}
|
|
}
|
|
}
|