/// <summary> /// Valida si existe el codigo de candidato /// </summary> /// <param name="beCandidato">Objeto candidato</param> /// <returns></returns> public bool ValidarCodigo(BE.Candidato beCandidato) { try { return(new DA.ClsDaTbCandidato().ValidarCodigo(beCandidato.IdCandidato, beCandidato.Codigo)); } catch (Exception ex) { throw ex; } }
private void FrmCandidatoMant_Load(object sender, EventArgs e) { try { this.beCandidatoGeneral = new BE.Candidato(); } catch (Exception ex) { Util.ErrorMessage(ex.Message); } }
public bool Insertar(ref BE.Candidato beCandidato) { try { this.Validar(beCandidato); return(new DA.ClsDaTbCandidato().Insertar(ref beCandidato)); } catch (Exception ex) { throw ex; } }
public bool Eliminar(BE.Candidato beCandidato) { try { if (beCandidato.IdCandidato == 0) { throw new Exception("No existe el Candidato"); } return(new DA.ClsDaTbCandidato().Eliminar(beCandidato)); } catch (Exception ex) { throw ex; } }
public BE.Candidato Obtener(string codigo) { BE.Candidato beCandidato = null; try { //General beCandidato = new DA.ClsDaTbCandidato().Obtener(codigo); if (beCandidato == null) { return(beCandidato); } //Contacto beCandidato.Contacto = new DA.ClsDaTbCandidatoContacto().Obtener(beCandidato.IdCandidato); if (beCandidato.Contacto == null) { beCandidato = null; return(beCandidato); } else { //Telefonos var lstBeCandidatoTelefonos = new DA.ClsDaTbCandidatoTelefono().Listar(beCandidato.IdCandidato); foreach (BE.ClsBeTbCandidatoTelefono beCandidatoTelefono in lstBeCandidatoTelefonos) { beCandidato.Telefonos.Add(beCandidatoTelefono); } } //Contratacion beCandidato.Contratacion = new DA.ClsDaTbCandidatoContratacion().Obtener(beCandidato.IdCandidato); if (beCandidato.Contratacion == null) { beCandidato = null; return(beCandidato); } return(beCandidato); } catch (Exception ex) { throw ex; } }
public bool Actualizar(BE.Candidato beCandidato) { try { this.Validar(beCandidato); if (beCandidato.IdCandidato == 0) { throw new Exception("No existe el Candidato"); } return(new DA.ClsDaTbCandidato().Actualizar(beCandidato)); } catch (Exception ex) { throw ex; } }
public void Contratar(BE.ClsBeTbPostulante bePostulante) { try { #region Validaciones if (bePostulante == null) { return; } if (bePostulante.Contacto == null) { return; } if (bePostulante.Telefonos == null) { return; } if (bePostulante.Reclutamiento == null) { return; } #endregion #region Convertir datos generales var beCandidato = new BE.Candidato(); beCandidato.IdCandidato = 0; beCandidato.Codigo = ""; beCandidato.Nombres = bePostulante.Nombres; beCandidato.ApellidoPaterno = bePostulante.ApellidoPaterno; beCandidato.ApellidoMaterno = bePostulante.ApellidoMaterno; beCandidato.FechaNacimiento = bePostulante.FechaNacimiento; beCandidato.NumeroDocumento = bePostulante.NumeroDocumento; beCandidato.Activo = true; beCandidato.UbigeoNacimiento = bePostulante.UbigeoNacimiento; beCandidato.PaisNacimiento = bePostulante.PaisNacimiento; beCandidato.Sexo = bePostulante.Sexo; beCandidato.EstadoCivil = bePostulante.EstadoCivil; beCandidato.TipoDocumento = bePostulante.TipoDocumento; beCandidato.IdPostulante = bePostulante.IdPostulante; #endregion #region Convertir datos contacto beCandidato.Contacto = new BE.ClsBeTbCandidatoContacto(); beCandidato.Contacto.IdCandidato = 0; beCandidato.Contacto.Zona = bePostulante.Contacto.Zona; beCandidato.Contacto.Direccion = bePostulante.Contacto.Direccion; beCandidato.Contacto.Referencia = bePostulante.Contacto.Referencia; beCandidato.Contacto.Email = bePostulante.Contacto.Email; beCandidato.Contacto.Ubigeo = bePostulante.Contacto.Ubigeo; var lstBeCandidatoTelefonos = new List <BE.ClsBeTbCandidatoTelefono>(); foreach (BE.ClsBeTbPostulanteTelefono bePostulanteTelefono in bePostulante.Telefonos) { var beCandidatoTelefono = new BE.ClsBeTbCandidatoTelefono(); beCandidatoTelefono.IdCandidatoTelefono = 0; beCandidatoTelefono.IdCandidato = 0; beCandidatoTelefono.CodTipoTelefono = bePostulanteTelefono.CodTipoTelefono; beCandidatoTelefono.Numero = bePostulanteTelefono.Numero; lstBeCandidatoTelefonos.Add(beCandidatoTelefono); } beCandidato.Telefonos = lstBeCandidatoTelefonos; #endregion #region Inicializar datos de contratacion beCandidato.Contratacion = new BE.ClsBeTbCandidatoContratacion(); #endregion this.Cargar(beCandidato); this.contratarPostulante = true; } catch (Exception ex) { throw ex; } }
private void ValidacionesFormulario() { try { #region Validaciones del formulario TabPage selectedTap = null; #region General selectedTap = this.TbpGeneral; if (this.TxtNombres.Text.Trim().Length == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.TxtNombres.Focus(); throw new Exception("Ingrese los nombres del candidato"); } else { string codEmpleado = this.TxtCodigo.Text.Trim(); int idCandidato = this.beCandidatoGeneral.IdCandidato; var beCandidato = new BE.Candidato() { IdCandidato = idCandidato, Codigo = codEmpleado }; if (new LN.Candidato().ValidarCodigo(beCandidato)) { this.TbcMantenimiento.SelectedTab = selectedTap; this.TxtCodigo.Focus(); throw new Exception("El codigo de candidato ya existe"); } beCandidato = null; int idEmpleado = 0; var beEmpleado = new BE.ClsBeTbEmpleado() { IdEmpleado = idEmpleado, Codigo = codEmpleado }; if (new LN.Empleado().ValidarCodigo(beEmpleado)) { this.TbcMantenimiento.SelectedTab = selectedTap; this.TxtCodigo.Focus(); throw new Exception("El codigo de empleado ya existe"); } beEmpleado = null; } if (this.TxtApellidoPaterno.Text.Trim().Length == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.TxtApellidoPaterno.Focus(); throw new Exception("Ingrese el apellido paterno del candidato"); } if (this.TxtApellidoMaterno.Text.Trim().Length == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.TxtApellidoMaterno.Focus(); throw new Exception("Ingrese el apellido materno del candidato"); } if (int.Parse(this.TxtEdad.Text) < 18) { this.TbcMantenimiento.SelectedTab = selectedTap; this.DtpFechaNacimiento.Focus(); throw new Exception("El candidato debe tener minimo 18 años"); } if (this.CbxSexo.SelectedIndex == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.CbxSexo.Focus(); throw new Exception("Seleccione el sexo del candidato"); } if (this.CbxTipoDocumento.SelectedIndex == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.CbxTipoDocumento.Focus(); throw new Exception("Seleccione el tipo de documento del candidato"); } if (this.TxtNumeroDocumento.Text.Trim().Length == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.TxtNumeroDocumento.Focus(); throw new Exception("Ingrese el numero de documento del candidato"); } if (this.CbxPaisNacimiento.SelectedIndex == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.CbxPaisNacimiento.Focus(); throw new Exception("Seleccione el pais de nacimiento del candidato"); } if (this.CbxDepartamentoNacimiento.SelectedValue.ToString() == "PER") { if (this.CbxDepartamentoNacimiento.SelectedIndex == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.CbxDepartamentoNacimiento.Focus(); throw new Exception("Seleccione el departamento de nacimiento del candidato"); } if (this.CbxProvinciaNacimiento.SelectedIndex == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.CbxProvinciaNacimiento.Focus(); throw new Exception("Seleccione la provincia de nacimiento del candidato"); } } #endregion #region Contacto selectedTap = this.TbpConctacto; if (this.CbxDepartamento.SelectedIndex == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.CbxDepartamento.Focus(); throw new Exception("Seleccione el departamento de contacto del candidato"); } if (this.CbxProvincia.SelectedIndex == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.CbxProvincia.Focus(); throw new Exception("Seleccione la provincia de contacto del candidato"); } if (this.CbxDistrito.SelectedIndex == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.CbxDepartamento.Focus(); throw new Exception("Seleccione el distrito de contacto del candidato"); } if (this.TxtZona.Text.Trim().Length == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.TxtZona.Focus(); throw new Exception("Ingrese la zona del candidato"); } if (this.TxtDireccion.Text.Trim().Length == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.TxtDireccion.Focus(); throw new Exception("Ingrese la direccion del candidato"); } if (this.TxtReferencia.Text.Trim().Length == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.TxtReferencia.Focus(); throw new Exception("Ingrese la referencia del candidato"); } if (this.TxtEmail.Text.Trim().Length > 0) { if (Util.IsValidEmail(this.TxtEmail.Text.Trim()) == false) { this.TbcMantenimiento.SelectedTab = selectedTap; this.TxtEmail.Focus(); throw new Exception("Ingrese un correo electronico valido"); } } if (this.CbxTelefono.SelectedIndex == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.CbxTelefono.Focus(); throw new Exception("Seleccione el telefono del candidato"); } if (this.TxtTelefono.Text.Trim().Length == 0) { this.TbcMantenimiento.SelectedTab = selectedTap; this.TxtTelefono.Focus(); throw new Exception("Ingrese el número de telefono del candidato"); } #endregion #region Contratacion selectedTap = this.TbpContratacion; if (this.DtpInicioInduccion.Value > this.DtpFinInduccion.Value) { this.TbcMantenimiento.SelectedTab = selectedTap; this.DtpInicioInduccion.Focus(); throw new Exception("La fecha de inicio es mayor a la fecha final de inducción"); } #endregion #endregion } catch (Exception ex) { throw ex; } }
public void Cargar(BE.Candidato beCandidato = null) { try { this.Cargar(); if (beCandidato != null) { this.beCandidatoGeneral = beCandidato; //General this.TxtCodigo.Text = this.beCandidatoGeneral.Codigo; this.TxtNombres.Text = this.beCandidatoGeneral.Nombres; this.TxtApellidoPaterno.Text = this.beCandidatoGeneral.ApellidoPaterno; this.TxtApellidoMaterno.Text = this.beCandidatoGeneral.ApellidoMaterno; this.DtpFechaNacimiento.Value = this.beCandidatoGeneral.FechaNacimiento; this.CbxSexo.SelectedValue = this.beCandidatoGeneral.Sexo.Codigo; this.CbxTipoDocumento.SelectedValue = this.beCandidatoGeneral.TipoDocumento.Codigo; this.TxtNumeroDocumento.Text = this.beCandidatoGeneral.NumeroDocumento; this.CbxEstadoCivil.SelectedValue = this.beCandidatoGeneral.EstadoCivil.Codigo; this.CbxActivo.Checked = this.beCandidatoGeneral.Activo; this.CbxPaisNacimiento.SelectedValue = this.beCandidatoGeneral.PaisNacimiento.Codigo; if (this.beCandidatoGeneral.PaisNacimiento.Codigo != "PER") { this.CbxDepartamentoNacimiento.Enabled = false; this.CbxProvinciaNacimiento.Enabled = false; } else { if (this.beCandidatoGeneral.UbigeoNacimiento != null) { int codDepartamentoNacimiento = this.beCandidatoGeneral.UbigeoNacimiento.Departamento; this.CbxDepartamentoNacimiento.SelectedValue = codDepartamentoNacimiento.ToString(); this.CargarProvincias(ref this.CbxProvinciaNacimiento, codDepartamentoNacimiento, true); int codProvinciaNacimiento = this.beCandidatoGeneral.UbigeoNacimiento.Provincia; this.CbxProvinciaNacimiento.SelectedValue = codProvinciaNacimiento.ToString(); } } //Contacto if (this.beCandidatoGeneral.Contacto != null) { int codDepartamento = this.beCandidatoGeneral.Contacto.Ubigeo.Departamento; this.CbxDepartamento.SelectedValue = codDepartamento.ToString(); int codProvincia = this.beCandidatoGeneral.Contacto.Ubigeo.Provincia; this.CargarProvincias(ref this.CbxProvincia, codDepartamento, true); this.CbxProvincia.SelectedValue = codProvincia.ToString(); int codDistrito = this.beCandidatoGeneral.Contacto.Ubigeo.Distrito; this.CargarDistritos(ref this.CbxDistrito, codDepartamento, codProvincia, true); this.CbxDistrito.SelectedValue = codDistrito.ToString(); this.TxtZona.Text = this.beCandidatoGeneral.Contacto.Zona; this.TxtDireccion.Text = this.beCandidatoGeneral.Contacto.Direccion; this.TxtReferencia.Text = this.beCandidatoGeneral.Contacto.Referencia; this.TxtEmail.Text = this.beCandidatoGeneral.Contacto.Email; } //Telefonos if (this.beCandidatoGeneral.Telefonos != null) { foreach (var telefono in beCandidatoGeneral.Telefonos) { this.CbxTelefono.SelectedValue = telefono.CodTipoTelefono; this.TxtTelefono.Text = telefono.Numero; break; } } //Contratacion if (this.beCandidatoGeneral.Contratacion != null) { this.DtpInicioInduccion.Value = this.beCandidatoGeneral.Contratacion.InduccionFechaInicio; if (this.beCandidatoGeneral.Contratacion.InduccionFechaFin != null) { this.DtpFinInduccion.Value = (DateTime)this.beCandidatoGeneral.Contratacion.InduccionFechaFin; this.CbxConcluyoInduccion.Checked = true; } this.CbxAproboInduccion.Checked = this.beCandidatoGeneral.Contratacion.Induccion; this.CbxAproboDisciplinario.Checked = this.beCandidatoGeneral.Contratacion.Disciplina; this.CbxAproboAdministrativo.Checked = this.beCandidatoGeneral.Contratacion.Informe; this.CbxAproboDocumentos.CheckedChanged -= CbxAproboDocumentos_CheckedChanged; this.ClbDocumentos.ItemCheck -= ClbDocumentos_ItemCheck; this.CbxAproboDocumentos.Checked = this.beCandidatoGeneral.Contratacion.Documentacion; if (this.beCandidatoGeneral.Contratacion.Documentacion == true) { for (int x = 0; x < this.ClbDocumentos.Items.Count; x++) { this.ClbDocumentos.SetItemChecked(x, true); } } this.ClbDocumentos.ItemCheck += ClbDocumentos_ItemCheck; this.CbxAproboDocumentos.CheckedChanged += CbxAproboDocumentos_CheckedChanged; this.TxtObservacion.Text = this.beCandidatoGeneral.Contratacion.Observacion; this.txtSueldo.Text = this.beCandidatoGeneral.Contratacion.Sueldo.ToString("N2"); if (this.beCandidatoGeneral.Contratacion.Cargo != null) { this.cboCargo.SelectedValue = this.beCandidatoGeneral.Contratacion.Cargo.IdCargo; } } } } catch (Exception ex) { Util.ErrorMessage(ex.Message); } }
public void Validar(BE.Candidato beCandidato) { try { #region General #region Validar Documento de Identidad bool existeDocumento = false; existeDocumento = new DA.ClsDaTbCandidato().ValidarDocumento(beCandidato.TipoDocumento.Codigo, beCandidato.NumeroDocumento, beCandidato.IdCandidato); if (existeDocumento == true) { throw new Exception("El documento ingresado ya está registrado"); } #endregion if (beCandidato.Nombres.Trim().Length == 0) { throw new Exception("No ingreso los nombres"); } if (beCandidato.ApellidoPaterno.Trim().Length == 0) { throw new Exception("No ingreso el apellido paterno"); } if (beCandidato.ApellidoMaterno.Trim().Length == 0) { throw new Exception("No ingreso el apellido materno"); } if (beCandidato.Sexo == null || beCandidato.Sexo.Codigo.Trim().Length == 0) { throw new Exception("No selecciono el sexo"); } if (beCandidato.TipoDocumento == null || beCandidato.TipoDocumento.Codigo.Trim().Length == 0) { throw new Exception("No selecciono el tipo de documento"); } if (beCandidato.NumeroDocumento.Trim().Length == 0) { throw new Exception("No ingreso el numero de documento"); } if (beCandidato.EstadoCivil == null || beCandidato.EstadoCivil.Codigo.Trim().Length == 0) { throw new Exception("No selecciono el estado civil"); } if (beCandidato.PaisNacimiento == null || beCandidato.PaisNacimiento.Codigo.Trim().Length == 0) { throw new Exception("No selecciono el pais de nacimiento"); } else if (beCandidato.PaisNacimiento.Codigo.Equals("PER")) { if (beCandidato.UbigeoNacimiento == null || beCandidato.UbigeoNacimiento.Codigo.Trim().Length == 0) { throw new Exception("No selecciono la ubicación de nacimiento"); } } #endregion } catch (Exception ex) { throw ex; } }