public int AgregarExpLaboral(ExpLaboralE pexpeLaboral, 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_insertar_ExperienciaLaboralConId";
                   comando.Parameters.AddWithValue("@id", id);
                   comando.Parameters.AddWithValue("@id_experienciaLaboral", pexpeLaboral.id_experienciaLaboral);
                   comando.Parameters.AddWithValue("@nombreEmpresa", pexpeLaboral.nombreEmpresa);
                   comando.Parameters.AddWithValue("@cargoDesempe", pexpeLaboral.cargoDesp);
                   comando.Parameters.AddWithValue("@descripcionPuesto", pexpeLaboral.descripPuesto);
                   comando.Parameters.AddWithValue("@fechaIncio", pexpeLaboral.fechaInicio);
                   comando.Parameters.AddWithValue("@fechaFin", pexpeLaboral.fechaFin);

                   resultado = (int)comando.ExecuteScalar();

               }

               else
                   resultado = 0;
               oerro = "";
               }
               return resultado;
        }
 public int GuardarexperienciaLab(ExpLaboralE pexpeLaboral, ref string oerro)
 {
     try
      {
          return _experienciaLabDAL.GuardarExpLaboral(pexpeLaboral, ref oerro);
      }
      catch (Exception)
      {
          oerro = "Ocurrio un error al ingresar sus datos";
          throw;
      }
 }
 public int AgregarexperienciaLab(ExpLaboralE refExpL,int id, ref string oerro)
 {
     try
      {
          return _experienciaLabDAL.AgregarExpLaboral(refExpL,id, ref oerro);
      }
      catch (Exception)
      {
          oerro = "Ocurrio un error al ingresar sus datos";
          throw;
      }
 }
        //**************************//**************************//**************************
        protected void agregarExperiencia()
        {
            string NombreEmpesa, CargoDesempeñado, DescripcionPuesto, FechaInicio, fechaFin;
            NombreEmpesa = txt_NombreEmpresaLab.Text;
            CargoDesempeñado = txt_CargoDespeLab.Text;
            DescripcionPuesto = txt_DescripPuestoLab.Text;
            FechaInicio = txt_FechaInicioLab.Text;
            fechaFin = txt_FechaFinLab.Text;

            //procedimiento para agregar una nueva experiencia a la base

            ExpLaboralE refExpL = new ExpLaboralE();
            int returinfoLaboral = 0;
            refExpL.nombreEmpresa = NombreEmpesa;
            refExpL.cargoDesp = CargoDesempeñado;
            refExpL.descripPuesto = DescripcionPuesto;
            refExpL.fechaInicio = FechaInicio;
            refExpL.fechaFin = fechaFin;

            bool agregar = true;
                    foreach (DataRowView dr in DataGrid_Inf_Laboral.Items)
                    {
                        if (dr.Row.ItemArray[1].ToString() == NombreEmpesa.ToString() && dr.Row.ItemArray[2].ToString().ToLower() == CargoDesempeñado.ToLower() &&
                            dr.Row.ItemArray[3].ToString().ToLower() == DescripcionPuesto.ToLower() && dr.Row.ItemArray[4].ToString().ToLower() == FechaInicio.ToLower() &&
                            dr.Row.ItemArray[5].ToString().ToLower() == fechaFin.ToLower())
                        {
                            agregar = false;
                        }
                    }
                    if (agregar)
                    {
                        returinfoLaboral = _experienciaLabBL.AgregarexperienciaLab(refExpL, int.Parse(idCandidato), ref oerro);

                            //************************************************

                            tablaExperiencia.Rows.Add(returinfoLaboral, NombreEmpesa, CargoDesempeñado, DescripcionPuesto, FechaInicio, fechaFin);

                    }
                    else
                    {
                        MessageBox.Show("Esa informacion ya ha sido ingresada, por favor revisar los datos.");
                        agregar = true;
                    }

            txt_NombreEmpresaLab.Text = string.Empty;
            txt_CargoDespeLab.Text = string.Empty;
            txt_DescripPuestoLab.Text = string.Empty;
            txt_FechaInicioLab.Text = string.Empty;
            txt_FechaFinLab.Text = string.Empty;
        }
        private void BTOAgregarInfLaboral_Click(object sender, RoutedEventArgs e)
        {
            if (!(string.IsNullOrEmpty(txt_NombreEmpresaLab.Text) | string.IsNullOrEmpty(txt_CargoDespeLab.Text) |
                    string.IsNullOrEmpty(txt_DescripPuestoLab.Text) | string.IsNullOrEmpty(txt_FechaInicioLab.Text) |
                    string.IsNullOrEmpty(txt_FechaFinLab.Text)))
            {
                if (nuevoExpe == false)
                {
                    tablaExperiencia.Rows.Remove(RowPivotInfoAca);
                    RowPivotInfoAca = null;

                    string NombreEmpesa, CargoDesempeñado, DescripcionPuesto, FechaInicio, fechaFin;
                    NombreEmpesa = txt_NombreEmpresaLab.Text;
                    CargoDesempeñado = txt_CargoDespeLab.Text;
                    DescripcionPuesto = txt_DescripPuestoLab.Text;
                    FechaInicio = txt_FechaInicioLab.Text;
                    fechaFin = txt_FechaFinLab.Text;

                    //ds.Tables.Add(dt);

                    ExpLaboralE expeObj = new ExpLaboralE();
                    expeObj.id_experienciaLaboral = Int32.Parse(idUpdateExpe);
                    expeObj.nombreEmpresa = NombreEmpesa;
                    expeObj.cargoDesp = CargoDesempeñado;
                    expeObj.descripPuesto = DescripcionPuesto;
                    expeObj.fechaInicio = FechaInicio;
                    expeObj.fechaFin = fechaFin;

                    bool agregar = true;
                    foreach (DataRowView dr in DataGrid_Inf_Laboral.Items)
                    {
                        if (dr.Row.ItemArray[1].ToString() == NombreEmpesa.ToString() && dr.Row.ItemArray[2].ToString().ToLower() == CargoDesempeñado.ToLower() &&
                          dr.Row.ItemArray[3].ToString().ToLower() == DescripcionPuesto.ToLower() && dr.Row.ItemArray[4].ToString().ToLower() == FechaInicio.ToLower() &&
                          dr.Row.ItemArray[5].ToString().ToLower() == fechaFin.ToLower())
                        {
                            agregar = false;
                        }
                    }
                    if (agregar)
                    {

                         ExperienciaLaboralBLL expeBll = new ExperienciaLaboralBLL();
                    expeBll.ActualizarExperienciaLab(expeObj, Int32.Parse(idCandidato), ref oerro);

                    tablaExperiencia.Rows.Add(idUpdateExpe, NombreEmpesa, CargoDesempeñado, DescripcionPuesto, FechaInicio, fechaFin);

                    }
                    else
                    {
                        MessageBox.Show("Esa informacion ya ha sido ingresada, por favor revisar los datos.");
                        agregar = true;
                    }

                    txt_NombreEmpresaLab.Text = string.Empty;
                    txt_CargoDespeLab.Text = string.Empty;
                    txt_DescripPuestoLab.Text = string.Empty;
                    txt_FechaInicioLab.Text = string.Empty;
                    txt_FechaFinLab.Text = string.Empty;

                    //DataGrid_InfAcademica.ItemsSource = dt;

                    nuevoExpe = true;

                }
                else
                {
                    agregarExperiencia();
                }

            }
            else
            {
                MessageBox.Show("Debe llenar todos los datos solicitados");
            }
        }
        private void btn_Guardar_InfoLaboral_Click(object sender, RoutedEventArgs e)
        {
            // VARIABLE PARA MENSAJE DE GUARDAR INFORMACION LABORAL
            int returVariable2 = 0;

            //BOTON PARA GUARDAR INFORMACION LABORAL DE LA GRID

            string oerror = "";
            ExpLaboralE refExpL = new ExpLaboralE();
            foreach (DataRowView row in DataGrid_Inf_Laboral.Items)
            {

                refExpL.nombreEmpresa = Convert.ToString(row[0]);
                refExpL.cargoDesp = Convert.ToString(row[1]);
                refExpL.descripPuesto = Convert.ToString(row[2]);
                refExpL.fechaInicio = Convert.ToString(row[3]);
                refExpL.fechaFin = Convert.ToString(row[4]);

                returVariable2 = _experienciaLabBL.GuardarexperienciaLab(refExpL, ref oerror);

            }
            if (returVariable2 > 0)
            {
                MessageBox.Show("Registro fue guardado con exito..", "Informacion", MessageBoxButton.OK, MessageBoxImage.Information);
                tcPrincipal.SelectedIndex = 3;
                tab3.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);
                }
            }
        }