Ejemplo n.º 1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (
                String.IsNullOrWhiteSpace(txtApellido.Text) ||
                String.IsNullOrWhiteSpace(txtDocumento.Text) ||
                String.IsNullOrWhiteSpace(txtSApellido.Text) ||
                String.IsNullOrWhiteSpace(txtRuc.Text)
                )
            {
                MessageBox.Show(this, "Falto ingresar un campo.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int        idEmpleado = NewPersonId();
            EmpleadoBE emBE       = new EmpleadoBE(idPerson.NewId(), short.Parse(cboPuesto.SelectedValue.ToString()),
                                                   txtDocumento.Text.Trim(), txtRuc.Text.Trim(),
                                                   dtpFecNac.Value, dtpFecIni.Value,
                                                   txtNombre.Text.Trim(), txtSNombre.Text.Trim(),
                                                   txtApellido.Text.Trim(), txtSApellido.Text.Trim(), false);

            try {
                if (emBL.NuevoEmpleado(emBE) == true)
                {
                    MessageBox.Show(this, "Se ingreso un nuevo empleado.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(this, "Ocurrió un error insertando al empleado.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            } catch (Exception ex) {
                throw new Exception(ex.Message);
            }
        }