107 lines
3.4 KiB
C#
107 lines
3.4 KiB
C#
using compabetov2.database.modelos;
|
|
using compabetov2.database;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace compabetov2.Empleados
|
|
{
|
|
public partial class EditarEmpleado1 : Form
|
|
{
|
|
private Empleado empleado;
|
|
private personal ventanaPadre;
|
|
private string imagePath;
|
|
public EditarEmpleado1(Empleado empleado, personal ventanaPadre)
|
|
{
|
|
InitializeComponent();
|
|
this.empleado = empleado;
|
|
this.ventanaPadre = ventanaPadre;
|
|
imagePath = Path.Combine(Application.StartupPath, "Resources", "usuarios", empleado.img);
|
|
llenarCampos();
|
|
}
|
|
|
|
private void llenarCampos()
|
|
{
|
|
txtNombre.Text = empleado.nombre;
|
|
txtApellido.Text = empleado.apellidos;
|
|
txtCalle.Text = empleado.calle;
|
|
txtColonia.Text = empleado.colonia;
|
|
txtCp.Text = empleado.cp;
|
|
txtNoExt.Text = empleado.no_ext;
|
|
txtNoInt.Text = empleado.no_int;
|
|
txtReferencia.Text = empleado.referencia;
|
|
txtTelefono.Text = empleado.telefono;
|
|
dtFechaCon.Text = empleado.fecha_contratacion;
|
|
dtFechaNac.Text = empleado.fecha_nac;
|
|
cbEstado.Text = empleado.estado;
|
|
lbImg.Text = $"Imagen: {Path.GetFileName(imagePath)}";
|
|
}
|
|
private void label1_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
OpenFileDialog openFileDialog1 = new OpenFileDialog();
|
|
|
|
openFileDialog1.Filter = "Archivos de imagen (*.jpg, *.jpeg, *.png, *.bmp)|*.jpg;*.jpeg;*.png;*.bmp";
|
|
openFileDialog1.Title = "Seleccionar imagen";
|
|
|
|
if (openFileDialog1.ShowDialog() == DialogResult.OK)
|
|
{
|
|
imagePath = openFileDialog1.FileName;
|
|
lbImg.Text = $"Imagen: {Path.GetFileName(imagePath)}";
|
|
}
|
|
}
|
|
|
|
private void pictureBox2_Click(object sender, EventArgs e)
|
|
{
|
|
Empleado empleadoNuevo = new Empleado(
|
|
empleado.idempleado,
|
|
txtNombre.Text,
|
|
txtApellido.Text,
|
|
txtCalle.Text,
|
|
dtFechaCon.Text,
|
|
cbEstado.Text,
|
|
txtColonia.Text,
|
|
txtCp.Text,
|
|
txtNoExt.Text,
|
|
txtNoInt.Text,
|
|
txtReferencia.Text,
|
|
dtFechaNac.Text,
|
|
txtTelefono.Text,
|
|
Path.GetFileName(imagePath));
|
|
if (service.actualizarEmpleado(empleadoNuevo))
|
|
{
|
|
if (!empleado.img.Equals(empleadoNuevo.img))
|
|
{
|
|
string destinationFolder = Path.Combine(Application.StartupPath, "Resources", "usuarios");
|
|
string destinationFile = Path.Combine(destinationFolder, Path.GetFileName(imagePath));
|
|
File.Copy(imagePath, destinationFile, true);
|
|
}
|
|
ventanaPadre.llenarPanel();
|
|
Close();
|
|
}
|
|
}
|
|
|
|
private void EditarEmpleado1_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void pictureBox1_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
|
|
}
|
|
}
|
|
}
|