private void dgEscalafon_KeyDown(object sender, KeyEventArgs e)
 {
     if (dgEscalafon.SelectedCells.Count > 0)
     {
         dgvHsPorCubrir.Refresh();
         DataGridViewCell celdaSeleccionada = dgEscalafon.SelectedCells[0];
         // Si se apreta F4 en alguna celda de la primer o segunda columna se abre el buscador de funcionarios.
         if (e.KeyCode == Keys.F4 && dgEscalafon.CurrentCell.ColumnIndex < 2)
         {
             // Muestro ventana de busqueda de empleados. La misma que en ABMEmpleados
             BuscarEmpleados busquedaEmps = new BuscarEmpleados();
             DialogResult res = busquedaEmps.ShowDialog(this);
             if (res == DialogResult.OK)
             {
                 try
                 {
                     EmPleadOs emp = datos.obtenerEmpleado(busquedaEmps.idEmpleadoSeleccionado);
                     dgEscalafon.Rows[celdaSeleccionada.RowIndex].Cells[0].Value = emp.NroEmpleado.ToString();
                     dgEscalafon.Rows[celdaSeleccionada.RowIndex].Cells[1].Value = emp.Apellido + " " + emp.Nombre;
                     
                     SendKeys.Send("{ENTER}");   
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
         //if (dgEscalafon.CurrentCell.ColumnIndex=0 
         
     }
 }
        private void mtFuncionario_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter && mtFuncionario.Text != "")
            {
                try
                {
                    funcionario = controller.obtenerEmpleado(int.Parse(mtFuncionario.Text));
                    if (funcionario.Activo == 0 && FechaCorresponde >= funcionario.FechaBaja)
                    {
                        // Funcionario Inactivo y la FechaCorresponde es mayor o igual a la fecha de baja.
                        funcionario = null;
                        MessageBox.Show(this, "El Funcionario " + mtFuncionario.Text + " esta Inactivo. No se puede agregar.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                       
                    }
                    else
                    {
                        mtFuncionario.Text = funcionario.NroEmpleado.ToString();
                        txtNombreFuncionarioNuevo.Text = funcionario.Nombre + " " + funcionario.Apellido;
                        btnAceptar.Enabled = true;
                        SendKeys.Send("{TAB}");

                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            if (e.KeyCode == Keys.F2)
            {
                // Muestro ventana de busqueda de empleados. La misma que en ABMEmpleados
                BuscarEmpleados busquedaEmps = new BuscarEmpleados();
                DialogResult res = busquedaEmps.ShowDialog(this);
                if (res == DialogResult.OK)
                {
                    try
                    {
                        funcionario = controller.obtenerEmpleado(busquedaEmps.idEmpleadoSeleccionado);
                        mtFuncionario.Text = funcionario.NroEmpleado.ToString();
                        txtNombreFuncionarioNuevo.Text = funcionario.Nombre + " " + funcionario.Apellido;
                        SendKeys.Send("{ENTER}");
                        btnAceptar.Enabled = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
 private void mtFuncionarioActual_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter && mtFuncionarioActual.Text != "")
     {
         try
         {
             FuncionarioViejo = Controller.obtenerEmpleado(int.Parse(mtFuncionarioActual.Text));
             mtFuncionarioActual.Text = FuncionarioViejo.NroEmpleado.ToString();
             txtNombreFuncionarioActual.Text = FuncionarioViejo.Nombre + " " + FuncionarioViejo.Apellido;
             //SendKeys.Send("{TAB}");
             mtFuncionarioNuevo.Focus();
             FVPronto = true;
             if (FVPronto && FNPronto)
                 btnAceptar.Enabled = true;
         }
         catch (Exception ex)
         {
             FVPronto = false;
             btnAceptar.Enabled = false;
             MessageBox.Show(ex.Message);
         }
     }
     if (e.KeyCode == Keys.F2)
     {
         // Muestro ventana de busqueda de empleados. La misma que en ABMEmpleados
         BuscarEmpleados busquedaEmps = new BuscarEmpleados();
         DialogResult res = busquedaEmps.ShowDialog(this);
         if (res == DialogResult.OK)
         {
             try
             {
                 FuncionarioViejo = Controller.obtenerEmpleado(busquedaEmps.idEmpleadoSeleccionado);
                 mtFuncionarioActual.Text = FuncionarioViejo.NroEmpleado.ToString();
                 txtNombreFuncionarioActual.Text = FuncionarioViejo.Nombre + " " + FuncionarioViejo.Apellido;
                 SendKeys.Send("{ENTER}");
                 mtFuncionarioNuevo.Focus();
                 FVPronto = true;
                 if (FVPronto && FNPronto)
                     btnAceptar.Enabled = true;
             }
             catch (Exception ex)
             {
                 FVPronto = false;
                 btnAceptar.Enabled = false;
                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
 private void btnBuscarEmpleado_Click(object sender, EventArgs e)
 {
     BuscarEmpleados busquedaEmps = new BuscarEmpleados();
     DialogResult res = busquedaEmps.ShowDialog(this);
     if (res == DialogResult.OK)
     {
         try
         {
             mtNumeroEmpleadoActual.Text = busquedaEmps.idEmpleadoSeleccionado.ToString();
             mtNumeroEmpleadoActual.Focus();
             SendKeys.Send("{ENTER}");
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
 private void tsbBuscarFuncionario_Click(object sender, EventArgs e)
 {
     // Muestro ventana de busqueda de empleados. La misma que en ABMEmpleados
     BuscarEmpleados busquedaEmps = new BuscarEmpleados();
     DialogResult res = busquedaEmps.ShowDialog(this);
     if (res == DialogResult.OK)
     {
         try
         {
             //EmPleadOs Funcionario = datos.obtenerEmpleado(busquedaEmps.idEmpleadoSeleccionado);
             //mtFuncionario.Text = Funcionario.NroEmpleado.ToString();
             //txtNombreFuncionario.Text = Funcionario.Nombre + " " + Funcionario.Apellido;
             SendKeys.Send("{ENTER}");
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
 private void btnBuscarEmpleado_Click(object sender, EventArgs e)
 {
     BuscarEmpleados busquedaEmps = new BuscarEmpleados();
     busquedaEmps.Show(this);
     //if (res == DialogResult.OK)
     //{
     //    try
     //    {
             //int i;
             //i = tcEmpleado.SelectedIndex;
             //tcEmpleado.SelectedIndex = 0;
             //if(busquedaEmps.idEmpleadoSeleccionado != null)
             //    mtNumeroEmpleado.Text = busquedaEmps.idEmpleadoSeleccionado.ToString();
             //mtNumeroEmpleado.Focus();
       //      SendKeys.Send("{ENTER}");
             //tcEmpleado.SelectedIndex = i;
         //}
         //catch (Exception ex)
        // {
          //   MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         //}
     //}
 }