modificacion a la interfaz de personal

This commit is contained in:
carlos
2024-01-09 23:29:11 -06:00
parent 0ff84fd596
commit 45a34a62b6
18 changed files with 288 additions and 715 deletions
+122 -95
View File
@@ -6,6 +6,7 @@ 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;
@@ -15,13 +16,121 @@ namespace compabetov2
{
public partial class personal : Form
{
List<Empleado> empleados;
public personal()
{
InitializeComponent();
llenarGrid();
limpiarCampos();
llenarPanel();
}
private 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, 60F));
empleadoLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 40F));
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 = 3;
panelBotones.Dock = DockStyle.Fill;
panelBotones.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
panelBotones.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
panelBotones.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
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;
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)
{
// Código para continuar aquí
}
});
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);
empleadoLayout.Controls.Add(infoEmpleado,0,0);
empleadoLayout.Controls.Add(panelBotones,1,0);
personalPanel.Controls.Add(empleadoLayout);
}
}
private void label1_Click(object sender, EventArgs e)
{
@@ -30,52 +139,14 @@ namespace compabetov2
private void button6_Click(object sender, EventArgs e)
{
Empleado empleado = new Empleado(
-1,
txtnombrepersonal.Text,
txtapellidopersonal.Text,
txtcallepersonal.Text,
dtpfechapersonal.Text,
cbestadopersonal.Text,
txtcoloniapersonal.Text,
txtcodigopersonal.Text,
txtnoextpersonal.Text,
txtnointpersonal.Text,
txtreferenciapersonal.Text,
dtpnacimientopersonal.Text,
txttelefonopersonal.Text
);
service.insertarEmpleado( empleado );
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void llenarGrid()
{
List<Empleado> empleados = service.conseguirEmpleados();
empleados.Reverse();
foreach(Empleado empleado in empleados)
{
dataGridView1.Rows.Insert(0,
empleado.idempleado,
empleado.nombre,
empleado.apellidos,
empleado.fecha_contratacion,
empleado.estado,
empleado.calle,
empleado.colonia,
empleado.cp,
empleado.no_ext,
empleado.no_int,
empleado.referencia,
empleado.fecha_nac,
empleado.telefono);
}
dataGridView1.Enabled = false;
}
private void personal_Load(object sender, EventArgs e)
{
@@ -84,71 +155,27 @@ namespace compabetov2
private void button7_Click(object sender, EventArgs e)
{
btnEditar.Enabled = true;
btnEliminar.Enabled = true;
dataGridView1.Enabled = true;
btnAgregar.Enabled = false;
}
private void button8_Click(object sender, EventArgs e)
{
int fila = dataGridView1.CurrentCell.RowIndex;
int idEmpleado = int.Parse(dataGridView1.Rows[fila].Cells[0].Value.ToString());
Empleado empleado = new Empleado();
}
private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
{
DataGridViewRow row = dataGridView1.Rows[e.RowIndex] as DataGridViewRow;
if(row.Cells[1].Value != null && row.Cells[0].Value != null)
{
txtnombrepersonal.Text = row.Cells[1].Value.ToString();
txtapellidopersonal.Text = row.Cells[2].Value.ToString();
dtpfechapersonal.Text = row.Cells[3].Value.ToString();
cbestadopersonal.Text = row.Cells[4].Value.ToString();
txtcallepersonal.Text = row.Cells[5].Value.ToString();
txtcoloniapersonal.Text = row.Cells[6].Value.ToString();
txtcodigopersonal.Text = row.Cells[7].Value.ToString();
txtnoextpersonal.Text = row.Cells[8].Value.ToString();
txtnointpersonal.Text = row.Cells[9].Value.ToString();
txtreferenciapersonal.Text = row.Cells[10].Value.ToString();
dtpnacimientopersonal.Text = row.Cells[11].Value.ToString();
txttelefonopersonal.Text = row.Cells[12].Value.ToString();
}
}
private void btnNuevo_Click(object sender, EventArgs e)
private void lblhora_Click(object sender, EventArgs e)
{
btnEditar.Enabled = false;
btnEliminar.Enabled = false;
btnAgregar.Enabled = true;
dataGridView1.Enabled = false;
limpiarCampos();
}
private void limpiarCampos()
private void flowLayoutPanel3_Paint(object sender, PaintEventArgs e)
{
txtnombrepersonal.Text = "";
txtapellidopersonal.Text = "";
dtpfechapersonal.Text = "";
cbestadopersonal.Text = "";
txtcallepersonal.Text = "";
txtcoloniapersonal.Text = "";
txtcodigopersonal.Text = "";
txtnoextpersonal.Text = "";
txtnointpersonal.Text = "";
txtreferenciapersonal.Text = "";
dtpnacimientopersonal.Text = "";
txttelefonopersonal.Text = "";
}
private void button1_Click(object sender, EventArgs e)
{
MenuPrincipal menuPrincipal = new MenuPrincipal();
menuPrincipal.Show();
this.Dispose(true);
}
}
}