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.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace compabetov2 { public partial class personal : Form { public personal() { InitializeComponent(); llenarGrid(); } private void label1_Click(object sender, EventArgs e) { } 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 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) { } 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) { } 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) { btnEditar.Enabled = false; btnEliminar.Enabled = false; btnAgregar.Enabled = true; dataGridView1.Enabled = false; } } }