public int ActualizarInfBasica(InfoBasicaE pinfobasica,int id, ref string oerro) { try { return _infBasDal.ActualizarInfBasica(pinfobasica, id,ref oerro); } catch (Exception) { oerro = "Ocurrio un error al ingresar sus los datos. "; throw; } }
public int ActualizarInfBasica(InfoBasicaE pinfobasica, int id, ref string oerro) { int resultado = 0; using (SqlConnection _conn = CommonDb.ObtenerConnSql()) { if (!(_conn == null)) { SqlCommand Comando = new SqlCommand(); Comando.Connection = _conn; Comando.CommandType = System.Data.CommandType.StoredProcedure; Comando.CommandText = "SP_update_infoBasica"; Comando.Parameters.AddWithValue("@id_info", id); Comando.Parameters.AddWithValue("@nombre", pinfobasica.nombre); Comando.Parameters.AddWithValue("@nacionalidad", pinfobasica.nacionalidad); Comando.Parameters.AddWithValue("@telefono_celular", pinfobasica.telefono_celular); Comando.Parameters.AddWithValue("@telefono_fijo", pinfobasica.telefono_fijo); Comando.Parameters.AddWithValue("@correo", pinfobasica.correo); Comando.Parameters.AddWithValue("@fecha_nacimiento", pinfobasica.fecha_nacimiento); Comando.Parameters.AddWithValue("@direccion", pinfobasica.direccion); Comando.Parameters.AddWithValue("@DUI", pinfobasica.DUI); Comando.Parameters.AddWithValue("@NIT", pinfobasica.NIT); Comando.Parameters.AddWithValue("@AFP", pinfobasica.AFP); Comando.Parameters.AddWithValue("@ISSS", pinfobasica.ISSS); Comando.Parameters.AddWithValue("@idgenero", pinfobasica.id_genero); Comando.Parameters.AddWithValue("@idmunicipio", pinfobasica.id_municipio); Comando.Parameters.AddWithValue("@idsituacionprofesional", pinfobasica.id_situacionProfesional); Comando.Parameters.AddWithValue("@id_profesiones", pinfobasica.id_profesiones); Comando.Parameters.AddWithValue("@foto", pinfobasica.FotoCandidato); resultado = Comando.ExecuteNonQuery(); } else resultado = 0; oerro = ""; } return resultado; }
private void btn_ActualizarInfoBasica_Click(object sender, RoutedEventArgs e) { if (!(string.IsNullOrEmpty(txtNombreInfBasica.Text) || string.IsNullOrEmpty(DateFechNacInfoBasica.Text) || string.IsNullOrEmpty(txtNombreInfBasica.Text) || (string.IsNullOrEmpty(cbDeptos.Text)) || (string.IsNullOrEmpty(cbMunic.Text)) || (string.IsNullOrEmpty(cb_profesionesIB.Text)) || (string.IsNullOrEmpty(cbSitLab.Text)) || (string.IsNullOrEmpty(txtTeNocelularInfBasica.Text)) || (string.IsNullOrEmpty(txtCorreoInfBasica.Text)) || (string.IsNullOrEmpty(txtNoduiInfBasica.Text)) || (string.IsNullOrEmpty(txtNnitInfBasica.Text)) )) { if (DateTime.Compare(DateTime.Now.Date, DateFechNacInfoBasica.SelectedDate.Value.Date) > 0) { InfoBasicaE _InfoBasicaE = new InfoBasicaE(); DateTime edad = DateFechNacInfoBasica.SelectedDate.Value; _InfoBasicaE.id_candidato = int.Parse(idCandidato); _InfoBasicaE.nombre = txtNombreInfBasica.Text.ToUpper(); _InfoBasicaE.nacionalidad = txtNacionalidadInfBasica.Text.ToUpper(); _InfoBasicaE.telefono_celular = txtTeNocelularInfBasica.Text.ToUpper(); _InfoBasicaE.telefono_fijo = txtTelefonoCasaInfBasica.Text.ToUpper(); //_InfoBasicaE.profesiones = cb_profesionesIB.Text.ToUpper(); _InfoBasicaE.id_profesiones = Convert.ToInt32(cb_profesionesIB.SelectedValue); _InfoBasicaE.correo = txtCorreoInfBasica.Text; _InfoBasicaE.fecha_nacimiento = DateFechNacInfoBasica.SelectedDate.Value; _InfoBasicaE.direccion = txtLugarResidenciaInfBasica.Text.ToUpper(); //_Imagen = ControlImagen.ObtenerImageEnBinario(_Imagen.OnlyName); if (pCapturaImagen) _InfoBasicaE.FotoCandidato = _Imagen.OnlyName; if (rbsexoM.IsChecked == true) { _InfoBasicaE.id_genero = 1; } else if (rbsexoF.IsChecked == true) { _InfoBasicaE.id_genero = 2; } _InfoBasicaE.DUI = txtNoduiInfBasica.Text; _InfoBasicaE.NIT = txtNnitInfBasica.Text; _InfoBasicaE.AFP = txtNafpInfBasica.Text; _InfoBasicaE.ISSS = txtNiss.Text; _InfoBasicaE.id_municipio = Convert.ToInt32(cbMunic.SelectedValue); _InfoBasicaE.id_situacionProfesional = Convert.ToInt32(cbSitLab.SelectedValue); string oerro = ""; int returinfobasica = 0; //capturar la imagen por el genero #region Capturar imgen por genero switch (_InfoBasicaE.id_genero) { case 1: pMensaje = "el candidato"; pURL = string.IsNullOrEmpty(_Imagen.OnlyName) ? @"C:\Imagenes\Fotos\User_default\Userman.png" : @"C:\Imagenes\Fotos\" + _Imagen.OnlyName; break; case 2: pMensaje = "la candidata"; pURL = string.IsNullOrEmpty(_Imagen.OnlyName) ? @"C:\Imagenes\Fotos\User_default\userwoman.png" : @"C:\Imagenes\Fotos\" + _Imagen.OnlyName; break; } #endregion /*proceso de eliminacion de imagen*/ if (pCapturaImagen == true) { ControlImagen.GuardarImagenEnRuta(_Imagen); // returinfobasica = _InfobasicaBL.ActualizarInfBasica(_InfoBasicaE, _InfoBasicaE.id_candidato, ref oerro); } else { returinfobasica = _InfobasicaBL.ActualizarInfBasica(_InfoBasicaE, _InfoBasicaE.id_candidato, ref oerro); } if (returinfobasica <= 0) { MessageBox.Show("Ocurrio un error y no se pudo actualizar al candidato", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { #region Mostrar mensaje personalizado SimpleAlert simpleAlert = new SimpleAlert(); simpleAlert.Title = "Nuevo Registro"; simpleAlert.NamePeople = txtNombreInfBasica.Text; simpleAlert.Url = pURL; simpleAlert.Message = "Se ha modificado " + pMensaje; simpleAlert.ShowDialog(); #region Redireccionamiento Busqueda _menusBusqueda = new Busqueda(); _menusBusqueda.InitializeComponent(); this.Close(); _menusBusqueda.Show(); #endregion #endregion } //MessageBox.Show("El candidato "+_InfoBasicaE.nombre+ " fue actualizado", "Exito", MessageBoxButton.OK, MessageBoxImage.None); } else { MessageBox.Show("La fecha de nacimiento debe ser menor a la fecha actual.", "Error", MessageBoxButton.OK, MessageBoxImage.Information); } } else { MessageBox.Show("Asegurese de que los campos obligatorios no esten vacíos.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
//VALIDACION DE CAMPOS VACIOS EN INFORMACION_BASICA private void btn_GuardarInfoBasica_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txtNombreInfBasica.Text) || string.IsNullOrEmpty(DateFechNacInfoBasica.Text) || string.IsNullOrEmpty(txtNombreInfBasica.Text) || (string.IsNullOrEmpty(cbDeptos.Text)) || (string.IsNullOrEmpty(cbMunic.Text)) || (string.IsNullOrEmpty(cb_profesionesIB.Text)) || (string.IsNullOrEmpty(cbSitLab.Text)) || (string.IsNullOrEmpty(txtTelefonoCasaInfBasica.Text)) || (string.IsNullOrEmpty(txtTelefonoCasaInfBasica.Text)) || (string.IsNullOrEmpty(txtTeNocelularInfBasica.Text)) || (string.IsNullOrEmpty(txtCorreoInfBasica.Text)) || (string.IsNullOrEmpty(txtNoduiInfBasica.Text)) || (string.IsNullOrEmpty(txtNnitInfBasica.Text)) ) { MessageBox.Show("COMPLETO TODOS LOS CAMPOS"); } else { InfoBasicaE _InfoBasicaE = new InfoBasicaE(); DateTime edad = DateFechNacInfoBasica.SelectedDate.Value; _InfoBasicaE.nombre = txtNombreInfBasica.Text.ToUpper(); _InfoBasicaE.nacionalidad = txtNacionalidadInfBasica.Text.ToUpper(); _InfoBasicaE.telefono_celular = txtTeNocelularInfBasica.Text.ToUpper(); _InfoBasicaE.telefono_fijo = txtTelefonoCasaInfBasica.Text.ToUpper(); //_InfoBasicaE.profesiones = cb_profesionesIB.Text.ToUpper(); _InfoBasicaE.id_profesiones = Convert.ToInt32(cb_profesionesIB.SelectedValue); _InfoBasicaE.correo = txtCorreoInfBasica.Text.ToUpper(); _InfoBasicaE.fecha_nacimiento = DateFechNacInfoBasica.SelectedDate.Value; _InfoBasicaE.direccion = txtLugarResidenciaInfBasica.Text.ToUpper(); if (rbsexoM.IsChecked == true) { _InfoBasicaE.id_genero = 1; } else if (rbsexoF.IsChecked == true) { _InfoBasicaE.id_genero = 2; } _InfoBasicaE.DUI = txtNoduiInfBasica.Text; _InfoBasicaE.NIT = txtNnitInfBasica.Text; _InfoBasicaE.AFP = txtNafpInfBasica.Text; _InfoBasicaE.ISSS = txtNiss.Text; _InfoBasicaE.id_municipio = Convert.ToInt32(cbMunic.SelectedValue); _InfoBasicaE.id_situacionProfesional = Convert.ToInt32(cbSitLab.SelectedValue); string oerro = ""; int returinfoacademica = 0; returinfoacademica= _InfobasicaBL.GudarInfBasica(_InfoBasicaE, ref oerro); if (returinfoacademica > 0) { MessageBox.Show("Registro fue guardado con exito..", "Informacion", MessageBoxButton.OK, MessageBoxImage.Information); tcPrincipal.SelectedIndex = 1; tab1.IsEnabled = false; } } }
//***BOTON PARA GUARDAR TODA LA INFORMACION DE UN NUEVO PERFIL***/// private void GuardarTodo_Click(object sender, RoutedEventArgs e) { //VARIABLE DE MENSAJE AL GUARDAR INFORMACION ACADEMICA int returVariable3 = 0; int variable1 = 2; int variable2 = 0; if (variable1 != returVariable3 && variable2 != returVariable3) { } else if (variable1 != returVariable3 || variable2 != returVariable3) { } string cadenaFaltanDatos = ""; ///////////////////////////////***FIN DEL IF*** ////////////////////////////// //VALIDA LOS CAMPOS OBLIGATORIOS DEL TAB 1 if (string.IsNullOrEmpty(txtNombreInfBasica.Text) || string.IsNullOrEmpty(DateFechNacInfoBasica.Text) || string.IsNullOrEmpty(txtNombreInfBasica.Text) || (string.IsNullOrEmpty(cbDeptos.Text)) || (string.IsNullOrEmpty(cbMunic.Text)) || (string.IsNullOrEmpty(cb_profesionesIB.Text)) || (string.IsNullOrEmpty(cbSitLab.Text)) || (string.IsNullOrEmpty(txtTeNocelularInfBasica.Text)) || (string.IsNullOrEmpty(txtCorreoInfBasica.Text)) || (string.IsNullOrEmpty(txtNoduiInfBasica.Text)) || (string.IsNullOrEmpty(txtNnitInfBasica.Text)) ) { MessageBox.Show("Este fomulario tiene campos obligatorios '*' ", "Informacion", MessageBoxButton.OK, MessageBoxImage.Error); } else { if (DateTime.Compare(DateTime.Now.Date, DateFechNacInfoBasica.SelectedDate.Value.Date) > 0) { //SE VALIDAN QUE LOS DEMAS GRID CONTENGAN DATOS, SE RECOMIENDA AGREGAR AQUELLOS GRID QUE CONSIDEREN SEAN NECESARIOS. if (DataG_Habilidades.Items.Count == 0 || DataGrid_InfAcademica.Items.Count == 0) { cadenaFaltanDatos = ", YA QUE NO A INGRESADO TODA LA INFORMACION NECESARIA."; MessageBox.Show("Ingrese informacion acdemica y habilidades ya que son formularios requeridos", "Infomacion", MessageBoxButton.OK, MessageBoxImage.Information); } else { //PARAMETROS QUE INGRESARAN A LA BASE TAB INFOMACION BASICA InfoBasicaE _InfoBasicaE = new InfoBasicaE(); DateTime edad = DateFechNacInfoBasica.SelectedDate.Value; _InfoBasicaE.nombre = txtNombreInfBasica.Text.ToUpper(); _InfoBasicaE.nacionalidad = txtNacionalidadInfBasica.Text.ToUpper(); _InfoBasicaE.telefono_celular = txtTeNocelularInfBasica.Text.ToUpper(); _InfoBasicaE.telefono_fijo = txtTelefonoCasaInfBasica.Text.ToUpper(); //_InfoBasicaE.profesiones = cb_profesionesIB.Text.ToUpper(); _InfoBasicaE.id_profesiones = Convert.ToInt32(cb_profesionesIB.SelectedValue); _InfoBasicaE.correo = txtCorreoInfBasica.Text; _InfoBasicaE.fecha_nacimiento = DateFechNacInfoBasica.SelectedDate.Value; _InfoBasicaE.direccion = txtLugarResidenciaInfBasica.Text.ToUpper(); //_Imagen = ControlImagen.ObtenerImagenEnObjecto(_Imagen.RutaImagen); _InfoBasicaE.FotoCandidato = _Imagen.OnlyName; if (rbsexoM.IsChecked == true) { _InfoBasicaE.id_genero = 1; } else if (rbsexoF.IsChecked == true) { _InfoBasicaE.id_genero = 2; } _InfoBasicaE.DUI = txtNoduiInfBasica.Text; _InfoBasicaE.NIT = txtNnitInfBasica.Text; _InfoBasicaE.AFP = txtNafpInfBasica.Text; _InfoBasicaE.ISSS = txtNiss.Text; _InfoBasicaE.id_municipio = Convert.ToInt32(cbMunic.SelectedValue); _InfoBasicaE.id_situacionProfesional = Convert.ToInt32(cbSitLab.SelectedValue); string oerro = ""; int returinfobasica = 0; returinfobasica = _InfobasicaBL.GudarInfBasica(_InfoBasicaE, ref oerro); // BOTON PARA GUARDAR INFORMACION ACADEMICA (EVENTO) InformacionAcademicaE refinfoAcademica = new InformacionAcademicaE(); int returinfoacademica = 0; foreach (DataRowView row in DataGrid_InfAcademica.Items) { refinfoAcademica.id_tipoEducacion = Convert.ToInt32(row[0]); refinfoAcademica.titulo = Convert.ToString(row[2]); refinfoAcademica.institucion = Convert.ToString(row[3]); refinfoAcademica.anio_de_finalizacion = Convert.ToInt32(row[4]); refinfoAcademica.id_statusAcademico = Convert.ToInt32(row[6]); returinfoacademica = _informacionAcademicaBL.GuardarInfomacionAcademica(refinfoAcademica, ref oerro); } //BOTON PARA GUARDAR INFORMACION LABORAL ExpLaboralE refExpL = new ExpLaboralE(); int returinfoLaboral = 0; foreach (DataRowView row1 in DataGrid_Inf_Laboral.Items) { refExpL.nombreEmpresa = Convert.ToString(row1[0]); refExpL.cargoDesp = Convert.ToString(row1[1]); refExpL.descripPuesto = Convert.ToString(row1[2]); refExpL.fechaInicio = Convert.ToString(row1[3]); refExpL.fechaFin = Convert.ToString(row1[4]); returinfoLaboral = _experienciaLabBL.GuardarexperienciaLab(refExpL, ref oerro); } // BOTON PARA GUARDARRR LOS DATOS HABILIDADES (METODOS) HabCandidatoE refHabCandidato = new HabCandidatoE(); int returnHabilidades = 0; foreach (DataRowView row3 in DataG_Habilidades.Items) { refHabCandidato.idhabilidadTecnica = Convert.ToInt32(row3[0]); refHabCandidato.id_nivel = Convert.ToInt32(row3[2]); refHabCandidato.id_habilidadAplicacion = Convert.ToInt32(row3[4]); returnHabilidades = _habilidadCandidatoBL.GuardarHabilidadCandidato(refHabCandidato, ref oerro); } //BOTON PARA GUARDAR CERTIFICACIONES EN LA BASE (METODOS) CertificacionesE certifi = new CertificacionesE(); int returnCertificaciones = 0; foreach (DataRowView row2 in DataGrid_Certificaciones.Items) { certifi.nombre = Convert.ToString(row2[0]); certifi.institucion = Convert.ToString(row2[1]); certifi.anio = Convert.ToInt16(row2[2]); returnCertificaciones = _certificanesBL.GuardarCertificacionesLAB(certifi, ref oerro); } //BOTON PARA INGRESAR REFERENCIAS A RefecenciasE refE = new RefecenciasE(); int returReferencias = 0; foreach (DataRowView row5 in DataGrid_Referencias.Items) { refE.id_tipoReferencias = Convert.ToInt32(row5[0]); refE.nombre = Convert.ToString(row5[2]); refE.telefono = Convert.ToString(row5[3]); refE.descripcion = Convert.ToString(row5[4]); returReferencias = _referenciasBL.GuardarReferencias(refE, ref oerro); } if (oerro == "") { #region Capturar imgen por genero string pMensaje = "", pURL = ""; switch (_InfoBasicaE.id_genero) { case 1: pMensaje = "candidato"; pURL = string.IsNullOrEmpty(_Imagen.RutaImagen) ? @"C:\Imagenes\Fotos\User_default\Userman.png" : _Imagen.RutaImagen; break; case 2: pMensaje = "candidata"; pURL = string.IsNullOrEmpty(_Imagen.RutaImagen) ? @"C:\Imagenes\Fotos\User_default\userwoman.png" : _Imagen.RutaImagen; break; } #endregion if (Elijiomagen) ControlImagen.GuardarImagenEnRuta(_Imagen); #region Mostrar mensaje personalizado SimpleAlert simpleAlert = new SimpleAlert(); simpleAlert.Title = "Nuevo Registro"; simpleAlert.NamePeople = txtNombreInfBasica.Text; simpleAlert.Url = pURL; simpleAlert.Message = "Se ha creado el nuevo " + pMensaje; simpleAlert.ShowDialog(); #region Redireccionamiento Busqueda _menusBusqueda = new Busqueda(); _menusBusqueda.InitializeComponent(); this.Close(); _menusBusqueda.Show(); #endregion #endregion } else { MessageBoxResult mbr = MessageBox.Show("OCURRIO UN ERROR AL GUARDAR SUS DATOS... ERROR: " + oerro, "Infomacion", MessageBoxButton.OK, MessageBoxImage.Information); } } } else { MessageBox.Show("La fecha de nacimiento debe ser menor a la fecha actual.","Error", MessageBoxButton.OK, MessageBoxImage.Information); } } }