private void button2Buscar_Click(object sender, EventArgs e) { int cedula; try { cedula = Int32.Parse(txtCedula.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } try { Empleado mostrar; mostrar = ServicioListaEmpleado.buscarEmpleadoPorCedula2(cedula); if (mostrar != null) { MessageBox.Show("Se encontro al empleado", "Encontrado"); } textBox1.Text = mostrar.getCedula().ToString(); textBox2.Text = mostrar.getNombre(); textBox3.Text = mostrar.getFecha().ToString(); textBox4.Text = mostrar.getTelefono().ToString(); } catch (Exception ex) { MessageBox.Show("No se encontro el empleado", "Aviso"); return; } }
private void button1Modificar_Click(object sender, EventArgs e) { int posicion; Double telefono; telefono = Convert.ToDouble(txtTelefono.Text); try { posicion = Int32.Parse(txtPosicion.Text); } catch (Exception) { MessageBox.Show("Debe de ingrsar un valor entero.", "Error de entrada!"); return; } try { ServicioListaEmpleado.modificarEmpleado(telefono, posicion); MessageBox.Show("Se modifico"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); return; } }
private void button1Aceptar_Click(object sender, EventArgs e) { int posicion; try { posicion = Int32.Parse(txtPosicion.Text); } catch (Exception ex) { MessageBox.Show("Debe ingresar datos numericos", "Aviso" + ex.Message); return; } try { ServicioListaEmpleado.EliminarEmpleadoPorPosicion(posicion); MessageBox.Show("Se elimino el empelado", "Aviso"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); return; } }
private void eliminarInicioToolStripMenuItem_Click(object sender, EventArgs e) { try { ServicioListaEmpleado.eliminarEmpleadoInicio(); MessageBox.Show("Se ha eliminado", "Aviso"); } catch (Exception ex) { MessageBox.Show("No se ha podido eliminar", "Aviso"); } }
private void button2_Click(object sender, EventArgs e) { int cedula = 0; string nombre; DateTime fecha; int posicion; Double telefono; fecha = txtfechaIngreso.Value; try { cedula = Int32.Parse(txtCedula.Text); } catch (Exception ex) { MessageBox.Show("Debe ingresar un valor numerico", ex.Message); return; } try { telefono = Convert.ToDouble(txtTelefono.Text); } catch (Exception ex) { MessageBox.Show("Debe ingresar un valor numerico", ex.Message); return; } nombre = txtNombre.Text; if (int.TryParse(nombre, out _)) { MessageBox.Show("No puede ingresar numeros como nombre.", "Aviso"); } else { posicion = Int32.Parse(txtPosicion.Text); Empleado nuevo = new Empleado(cedula, nombre, fecha, telefono); try { ServicioListaEmpleado.adicionarEmpleadoPosicion(nuevo, posicion); MessageBox.Show("Empleado se ha agregado!", "AVISO"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } } }
public void mostrarLista() { if (ServicioListaEmpleado.darCab() != null) { grillaLista.Rows.Clear(); for (int i = 0; i < ServicioListaEmpleado.darTotalLista(); i++) { grillaLista.Rows.Add(); grillaLista.Rows[i].Cells[0].Value = i + 1; grillaLista.Rows[i].Cells[1].Value = ServicioListaEmpleado.empleadoPorPosicion(i).getCedula(); grillaLista.Rows[i].Cells[2].Value = ServicioListaEmpleado.empleadoPorPosicion(i).getNombre(); grillaLista.Rows[i].Cells[3].Value = ServicioListaEmpleado.empleadoPorPosicion(i).getFecha(); grillaLista.Rows[i].Cells[4].Value = ServicioListaEmpleado.empleadoPorPosicion(i).getTelefono(); } } else { MessageBox.Show("La lista se encuentra vacia!!", "Error"); } }