private void Validar(BE.ClsBeTbPostulante bePostulante) { try { #region Validar Documento de Identidad bool existeDocumento = false; existeDocumento = new DA.ClsDaTbPostulante().ValidarDocumento(bePostulante.TipoDocumento.Codigo, bePostulante.NumeroDocumento, bePostulante.IdPostulante); if (existeDocumento == true) { throw new Exception("El documento ingresado ya está registrado"); } #endregion if (bePostulante.Nombres.Trim().Length == 0) { throw new Exception("No ingreso los nombres"); } if (bePostulante.ApellidoPaterno.Trim().Length == 0) { throw new Exception("No ingreso el apellido paterno"); } if (bePostulante.ApellidoMaterno.Trim().Length == 0) { throw new Exception("No ingreso el apellido materno"); } if (bePostulante.Sexo.Codigo.Trim().Length == 0) { throw new Exception("No selecciono el sexo"); } if (bePostulante.TipoDocumento == null) { throw new Exception("No selecciono el tipo de documento"); } if (bePostulante.NumeroDocumento.Trim().Length == 0) { throw new Exception("No ingreso el numero de documento"); } if (bePostulante.PaisNacimiento == null) { throw new Exception("No selecciono el pais de nacimiento"); } if (bePostulante.EstadoCivil == null) { throw new Exception("No selecciono el estado civil"); } } catch (Exception) { throw; } }
private void FrmPostulanteMant_Load(object sender, EventArgs e) { try { this.bePostulante = new BE.ClsBeTbPostulante(); } catch (Exception ex) { Util.ErrorMessage(ex.Message); } }
public bool Insertar(ref BE.ClsBeTbPostulante bePostulante) { int rowsAffected = 0; try { this.Validar(bePostulante); rowsAffected = new DA.ClsDaTbPostulante().Insertar(ref bePostulante); return(rowsAffected > 0); } catch (Exception ex) { throw ex; } }
public BE.ClsBeTbPostulante Obtener(int idPostulante) { BE.ClsBeTbPostulante bePostulante = null; try { string sp = "SpTbPostulanteGeneralObtener"; SqlConnection cnn = new SqlConnection(ConnectionManager.ConexionLocal); SqlCommand cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter dad = new SqlDataAdapter(cmd); dad.SelectCommand.Parameters.Add(new SqlParameter("@IDPOSTULANTE", idPostulante)); DataTable dt = new DataTable(); dad.Fill(dt); if ((dt.Rows.Count == 1)) { DataRow dr = dt.Rows[0]; bePostulante = this.Cargar(dr); var beUbigeoNacimiento = bePostulante.UbigeoNacimiento; if (new Ubigeo().Obtener(ref beUbigeoNacimiento)) { bePostulante.UbigeoNacimiento = beUbigeoNacimiento; } else { bePostulante.UbigeoNacimiento = null; } } return(bePostulante); } catch (Exception ex) { throw ex; } }
public bool Eliminar(BE.ClsBeTbPostulante bePostulante) { int rowsAffected = 0; try { if (bePostulante.IdPostulante == 0) { throw new Exception("No existe el Postulante"); } var daPostulante = new DA.ClsDaTbPostulante(); rowsAffected = daPostulante.Eliminar(bePostulante); return(rowsAffected > 0); } catch (Exception ex) { throw ex; } }
public bool Actualizar(BE.ClsBeTbPostulante bePostulante) { int rowsAffected = 0; try { if (bePostulante.IdPostulante == 0) { throw new Exception("No existe el Postulante"); } this.Validar(bePostulante); rowsAffected = new DA.ClsDaTbPostulante().Actualizar(bePostulante); return(rowsAffected > 0); } catch (Exception ex) { throw ex; } }
public BE.ClsBeTbPostulante Obtener(int idPostulante) { BE.ClsBeTbPostulante bePostulante = null; try { //General bePostulante = new DA.ClsDaTbPostulante().Obtener(idPostulante); if (bePostulante == null) { return(bePostulante); } //Contacto bePostulante.Contacto = new DA.ClsDaTbPostulanteContacto().Obtener(idPostulante); if (bePostulante.Contacto == null) { bePostulante = null; return(bePostulante); } else { //Telefonos var lstBePostulanteTelefonos = new DA.ClsDaTbPostulanteTelefono().Listar(idPostulante); foreach (BE.ClsBeTbPostulanteTelefono bePostulanteTelefono in lstBePostulanteTelefonos) { bePostulante.Telefonos.Add(bePostulanteTelefono); } } //Contratacion bePostulante.Reclutamiento = new DA.ClsDaTbPostulanteReclutamiento().Obtener(idPostulante); if (bePostulante.Reclutamiento == null) { bePostulante = null; return(bePostulante); } else { var lstBePostulanteHistorial = new DA.ClsDaTbPostulanteHistorial().Listar(idPostulante); for (int i = 0; i < lstBePostulanteHistorial.Count; i++) { var beEstado = new BE.ClsBeTbPostulanteEstado() { IdPostulanteEstado = lstBePostulanteHistorial[i].Estado.IdPostulanteEstado }; if (new DA.ClsDaTbPostulanteEstado().Obtener(ref beEstado)) { lstBePostulanteHistorial[i].Estado = beEstado; } } bePostulante.Reclutamiento.Historial = lstBePostulanteHistorial; } return(bePostulante); } 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; } }
public BE.ClsBeTbPostulante Cargar(DataRow dr) { try { var bePostulante = new BE.ClsBeTbPostulante(); bePostulante.IdPostulante = dr["IdPostulante"] == DBNull.Value ? 0 : int.Parse(dr["IdPostulante"].ToString()); bePostulante.Nombres = dr["Nombres"] == DBNull.Value ? "" : dr["Nombres"].ToString(); bePostulante.ApellidoPaterno = dr["ApellidoPaterno"] == DBNull.Value ? "" : dr["ApellidoPaterno"].ToString(); bePostulante.ApellidoMaterno = dr["ApellidoMaterno"] == DBNull.Value ? "" : dr["ApellidoMaterno"].ToString(); bePostulante.FechaNacimiento = dr["FechaNacimiento"] == DBNull.Value ? DateTime.Now.AddYears(-18) : DateTime.Parse(dr["FechaNacimiento"].ToString()); bePostulante.NumeroDocumento = dr["NumeroDocumento"] == DBNull.Value ? "" : dr["NumeroDocumento"].ToString(); bePostulante.Activo = dr["Activo"] == DBNull.Value ? false : bool.Parse(dr["Activo"].ToString()); bePostulante.Candidato = dr["Candidato"] == DBNull.Value ? false : bool.Parse(dr["Candidato"].ToString()); if (dr["CodNacimiento"] != DBNull.Value) { bePostulante.UbigeoNacimiento = new BE.Ubigeo() { Codigo = dr["CodNacimiento"].ToString() }; } if (dr["CodPais"] != DBNull.Value) { bePostulante.PaisNacimiento = new BE.Pais() { Codigo = dr["CodPais"].ToString(), Nombre = dr["DscPais"].ToString() }; } if (dr["CodSexo"] != DBNull.Value) { bePostulante.Sexo = new BE.Record() { Codigo = dr["CodSexo"].ToString(), Nombre = dr["DscSexo"].ToString() }; } if (dr["CodEstadoCivil"] != DBNull.Value) { bePostulante.EstadoCivil = new BE.Record() { Codigo = dr["CodEstadoCivil"].ToString(), Nombre = dr["DscEstadoCivil"].ToString() }; } if (dr["CodDocumentoIdentidad"] != DBNull.Value) { bePostulante.TipoDocumento = new BE.Record() { Codigo = dr["CodDocumentoIdentidad"].ToString(), Nombre = dr["DscDocumentoIdentidad"].ToString() }; } return(bePostulante); } catch (Exception ex) { throw ex; } }
public int Insertar(ref BE.ClsBeTbPostulante bePostulante) { SqlConnection cnn = null; SqlTransaction tns = null; try { int rowsAffected = 0; string sp = ""; using (cnn = new SqlConnection(ConnectionManager.ConexionLocal)) { cnn.Open(); tns = cnn.BeginTransaction(); SqlCommand cmd = null; //General sp = "SpTbPostulanteGeneralInsertar"; cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = tns; cmd.Parameters.Add(new SqlParameter("@IDPOSTULANTE", bePostulante.IdPostulante)); cmd.Parameters["@IDPOSTULANTE"].Direction = ParameterDirection.Output; cmd.Parameters.Add(new SqlParameter("@NOMBRES", bePostulante.Nombres)); cmd.Parameters.Add(new SqlParameter("@APELLIDOPATERNO", bePostulante.ApellidoPaterno)); cmd.Parameters.Add(new SqlParameter("@APELLIDOMATERNO", bePostulante.ApellidoMaterno)); cmd.Parameters.Add(new SqlParameter("@FECHANACIMIENTO", bePostulante.FechaNacimiento)); cmd.Parameters.Add(new SqlParameter("@CODSEXO", bePostulante.Sexo.Codigo)); cmd.Parameters.Add(new SqlParameter("@CODDOCUMENTOIDENTIDAD", bePostulante.TipoDocumento.Codigo)); cmd.Parameters.Add(new SqlParameter("@NUMERODOCUMENTO", bePostulante.NumeroDocumento)); cmd.Parameters.Add(new SqlParameter("@CODPAIS", bePostulante.PaisNacimiento.Codigo)); cmd.Parameters.Add(new SqlParameter("@CODESTADOCIVIL", bePostulante.EstadoCivil.Codigo)); cmd.Parameters.Add(new SqlParameter("@ACTIVO", bePostulante.Activo)); cmd.Parameters.Add(new SqlParameter("@CANDIDATO", bePostulante.Candidato)); if (bePostulante.UbigeoNacimiento != null) { cmd.Parameters.Add(new SqlParameter("@CODNACIMIENTO", bePostulante.UbigeoNacimiento.Codigo)); } else { cmd.Parameters.Add(new SqlParameter("@CODNACIMIENTO", DBNull.Value)); } rowsAffected += cmd.ExecuteNonQuery(); bePostulante.IdPostulante = int.Parse(cmd.Parameters["@IDPOSTULANTE"].Value.ToString()); //Contacto sp = "SpTbPostulanteContactoInsertar"; cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = tns; cmd.Parameters.Add(new SqlParameter("@IDPOSTULANTE", bePostulante.Contacto.IdPostulante)); cmd.Parameters.Add(new SqlParameter("@CODUBIGEO", bePostulante.Contacto.Ubigeo.Codigo)); cmd.Parameters.Add(new SqlParameter("@ZONA", bePostulante.Contacto.Zona)); cmd.Parameters.Add(new SqlParameter("@DIRECCION", bePostulante.Contacto.Direccion)); cmd.Parameters.Add(new SqlParameter("@REFERENCIA", bePostulante.Contacto.Referencia)); cmd.Parameters.Add(new SqlParameter("@EMAIL", bePostulante.Contacto.Email)); rowsAffected += cmd.ExecuteNonQuery(); //Telefonos sp = "SpTbPostulanteTelefonoInsertar"; foreach (var telefono in bePostulante.Telefonos) { cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = tns; cmd.Parameters.Add(new SqlParameter("@IDPOSTULANTETELEFONO", telefono.IdPostulanteTelefono)); cmd.Parameters["@IDPOSTULANTETELEFONO"].Direction = ParameterDirection.Output; cmd.Parameters.Add(new SqlParameter("@IDPOSTULANTE", telefono.IdPostulante)); cmd.Parameters.Add(new SqlParameter("@CODTIPOTELEFONO", telefono.CodTipoTelefono)); cmd.Parameters.Add(new SqlParameter("@NUMERO", telefono.Numero)); rowsAffected += cmd.ExecuteNonQuery(); telefono.IdPostulanteTelefono = int.Parse(cmd.Parameters["@IDPostulanteTELEFONO"].Value.ToString()); } //Reclutamiento sp = "SpTbPostulanteReclutamientoInsertar"; cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = tns; cmd.Parameters.Add(new SqlParameter("@IDPOSTULANTE", bePostulante.Reclutamiento.IdPostulante)); cmd.Parameters.Add(new SqlParameter("@CARGOCURRICULUM", bePostulante.Reclutamiento.CargoCurriculum)); cmd.Parameters.Add(new SqlParameter("@FECHARECEPCION", bePostulante.Reclutamiento.FechaRecepcion)); cmd.Parameters.Add(new SqlParameter("@OBSERVACION", bePostulante.Reclutamiento.Observacion)); rowsAffected += cmd.ExecuteNonQuery(); //Detalle Reclutamiento if (bePostulante.Reclutamiento.Historial.Count == 1) { sp = "SpTbPostulanteHistorialInsertar"; cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = tns; int ultima = bePostulante.Reclutamiento.Historial.Count - 1; var historial = bePostulante.Reclutamiento.Historial[ultima]; cmd.Parameters.Add(new SqlParameter("@IDPOSTULANTE", historial.IdPostulante)); cmd.Parameters.Add(new SqlParameter("@IDPOSTULANTEESTADO", historial.Estado.IdPostulanteEstado)); cmd.Parameters.Add(new SqlParameter("@ACEPTO", historial.Acepto)); cmd.Parameters.Add(new SqlParameter("@NOTA", historial.Nota)); rowsAffected += cmd.ExecuteNonQuery(); } if (tns != null) { tns.Commit(); } } return(rowsAffected); } catch (Exception ex) { if (tns != null) { tns.Rollback(); } throw ex; } }
public int Eliminar(BE.ClsBeTbPostulante bePostulante) { SqlConnection cnn = null; SqlTransaction tns = null; try { int rowsAffected = 0; string sp = ""; using (cnn = new SqlConnection(ConnectionManager.ConexionLocal)) { cnn.Open(); tns = cnn.BeginTransaction(); SqlCommand cmd = null; //Contacto sp = "SpTbPostulanteContactoEliminar"; cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = tns; cmd.Parameters.Add(new SqlParameter("@IDPOSTULANTE", bePostulante.IdPostulante)); rowsAffected += cmd.ExecuteNonQuery(); //Telefonos sp = "SpTbPostulanteTelefonoEliminar"; foreach (var telefono in bePostulante.Telefonos) { cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = tns; cmd.Parameters.Add(new SqlParameter("@IDPOSTULANTETELEFONO", telefono.IdPostulanteTelefono)); rowsAffected += cmd.ExecuteNonQuery(); } //Reclutamiento sp = "SpTbPostulanteReclutamientoEliminar"; cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = tns; cmd.Parameters.Add(new SqlParameter("@IDPOSTULANTE", bePostulante.IdPostulante)); rowsAffected += cmd.ExecuteNonQuery(); //Historial sp = "SpTbPostulanteHistorialEliminar"; cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = tns; cmd.Parameters.Add(new SqlParameter("@IDPOSTULANTE", bePostulante.IdPostulante)); rowsAffected += cmd.ExecuteNonQuery(); //General sp = "SpTbPostulanteGeneralEliminar"; cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Transaction = tns; cmd.Parameters.Add(new SqlParameter("@IDPOSTULANTE", bePostulante.IdPostulante)); rowsAffected += cmd.ExecuteNonQuery(); if (tns != null) { tns.Commit(); } } return(rowsAffected); } catch (Exception ex) { if (tns != null) { tns.Rollback(); } throw ex; } }
public void Cargar(BE.ClsBeTbPostulante bePostulante = null) { try { this.CargarSexos(true); this.CargarEstadosCiviles(true); this.CargarTiposDocumentos(true); this.CargarTelefonos(true); this.CargarReclutamientoEstado(); this.CargarReclutamientoDetalle(); this.CargarPaises(); this.CargarDepartamentos(ref this.CbxDepartamentoNacimiento, true); this.CargarProvincias(ref this.CbxProvinciaNacimiento, 0, true); this.CargarDepartamentos(ref this.CbxDepartamento, true); this.CbxDepartamento.SelectedValue = "15"; this.CargarProvincias(ref this.CbxProvincia, 15, true); this.CbxProvincia.SelectedValue = "1"; this.CargarDistritos(ref this.CbxDistrito, 15, 1, true); if (bePostulante != null) { this.bePostulante = bePostulante; //General this.TxtNombres.Text = this.bePostulante.Nombres; this.TxtApellidoPaterno.Text = this.bePostulante.ApellidoPaterno; this.TxtApellidoMaterno.Text = this.bePostulante.ApellidoMaterno; this.DtpFechaNacimiento.Value = this.bePostulante.FechaNacimiento; this.CbxSexo.SelectedValue = this.bePostulante.Sexo.Codigo; this.CbxTipoDocumento.SelectedValue = this.bePostulante.TipoDocumento.Codigo; this.TxtNumeroDocumento.Text = this.bePostulante.NumeroDocumento; this.CbxEstadoCivil.SelectedValue = this.bePostulante.EstadoCivil.Codigo; this.CbxActivo.Checked = this.bePostulante.Activo; this.CbxPaisNacimiento.SelectedValue = this.bePostulante.PaisNacimiento.Codigo; if (this.bePostulante.PaisNacimiento.Codigo != "PER") { this.CbxDepartamentoNacimiento.Enabled = false; this.CbxProvinciaNacimiento.Enabled = false; } else { if (this.bePostulante.UbigeoNacimiento != null) { int codDepartamentoNacimiento = this.bePostulante.UbigeoNacimiento.Departamento; this.CbxDepartamentoNacimiento.SelectedValue = codDepartamentoNacimiento.ToString(); this.CargarProvincias(ref this.CbxProvinciaNacimiento, codDepartamentoNacimiento, true); int codProvinciaNacimiento = this.bePostulante.UbigeoNacimiento.Provincia; this.CbxProvinciaNacimiento.SelectedValue = codProvinciaNacimiento.ToString(); } } //Contacto if (this.bePostulante.Contacto != null) { int codDepartamento = this.bePostulante.Contacto.Ubigeo.Departamento; this.CbxDepartamento.SelectedValue = codDepartamento.ToString(); int codProvincia = this.bePostulante.Contacto.Ubigeo.Provincia; this.CargarProvincias(ref this.CbxProvincia, codDepartamento, true); this.CbxProvincia.SelectedValue = codProvincia.ToString(); int codDistrito = this.bePostulante.Contacto.Ubigeo.Distrito; this.CargarDistritos(ref this.CbxDistrito, codDepartamento, codProvincia, true); this.CbxDistrito.SelectedValue = codDistrito.ToString(); this.TxtZona.Text = this.bePostulante.Contacto.Zona; this.TxtDireccion.Text = this.bePostulante.Contacto.Direccion; this.TxtReferencia.Text = this.bePostulante.Contacto.Referencia; this.TxtEmail.Text = this.bePostulante.Contacto.Email; } //Telefonos if (this.bePostulante.Telefonos != null) { foreach (var telefono in this.bePostulante.Telefonos) { this.CbxTelefono.SelectedValue = telefono.CodTipoTelefono; this.TxtTelefono.Text = telefono.Numero; break; } } //Reclutamiento if (this.bePostulante.Reclutamiento != null) { this.TxtCargoCurriculum.Text = this.bePostulante.Reclutamiento.CargoCurriculum; this.DtpFechaRecepcion.Value = this.bePostulante.Reclutamiento.FechaRecepcion; this.TxtObservacion.Text = this.bePostulante.Reclutamiento.Observacion; this.CargarReclutamientoEstado(this.bePostulante.IdPostulante); //Historial var lstResultadoHistorial = new List <BE.ClsBeResult>(); var historiales = this.bePostulante.Reclutamiento.Historial; foreach (var historial in historiales) { var result = new BE.ClsBeResult() { Id = historial.Estado.Nivel, Campo01 = historial.Estado.Nombre, Campo02 = historial.Acepto == true ? "Si" : "No", Campo03 = historial.Nota }; lstResultadoHistorial.Add(result); } this.DgvHistorial.DataSource = lstResultadoHistorial; } } } catch (Exception ex) { Util.ErrorMessage(ex.Message); } }