90 lines
3.0 KiB
C#
90 lines
3.0 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 AgregarEmpleado1 : Form
|
|
{
|
|
private personal ventanaPersonal;
|
|
private string imagenPath = "";
|
|
public AgregarEmpleado1(personal ventanaPersonal)
|
|
{
|
|
InitializeComponent();
|
|
this.ventanaPersonal = ventanaPersonal;
|
|
}
|
|
|
|
|
|
private void pictureBox2_Click(object sender, EventArgs e)
|
|
{
|
|
string nombre = txtNombre.Text;
|
|
string apellidos = txtApellido.Text;
|
|
string calle = txtCalle.Text;
|
|
string fechaCon = dtFechaCon.Text;
|
|
string estado = cbEstado.Text;
|
|
string colonia = txtColonia.Text;
|
|
string cp = txtCp.Text;
|
|
string noExt = txtNoExt.Text;
|
|
string noInt = txtNoInt.Text;
|
|
string referencia = txtReferencia.Text;
|
|
string fechaNac = dtFechaNac.Text;
|
|
string telefono = txtTelefono.Text;
|
|
|
|
Empleado empleado = new Empleado(-1, nombre, apellidos, calle, fechaCon, estado, colonia
|
|
, cp, noExt, noInt, referencia, fechaNac, telefono, Path.GetFileName(imagenPath));
|
|
|
|
if (service.insertarEmpleado(empleado))
|
|
{
|
|
if (!imagenPath.Equals(""))
|
|
{
|
|
string destinationFolder = Path.Combine(Application.StartupPath, "Resources", "usuarios");
|
|
string destinationFile = Path.Combine(destinationFolder, Path.GetFileName(imagenPath));
|
|
File.Copy(imagenPath, destinationFile, true);
|
|
}
|
|
|
|
ventanaPersonal.llenarPanel();
|
|
Close();
|
|
}
|
|
}
|
|
|
|
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)
|
|
{
|
|
imagenPath = openFileDialog1.FileName;
|
|
lbImg.Text = $"Imagen: {Path.GetFileName(imagenPath)}";
|
|
//string destinationFolder = Path.Combine(Application.StartupPath, "Resources", "usuarios");
|
|
//string destinationFile = Path.Combine(destinationFolder, Path.GetFileName(sourceFile));
|
|
//File.Copy(sourceFile, destinationFile, true);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AgregarEmpleado1_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void pictureBox1_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
}
|
|
}
|