Beispiel #1
0
        public bool GrabarDB(Aca_Profesor_Info info, ref decimal idProfesor, ref string mensaje)
        {
            try
            {
                bool resultado = false;
                using (Entities_Academico Base = new Entities_Academico())
                {
                    decimal             idPersona    = 0;
                    Aca_Estudiante_Data daEstudiante = new Aca_Estudiante_Data();
                    tb_persona_data     Persona_data = new tb_persona_data();


                    switch (info.Base)
                    {
                    case null:
                        if (Persona_data.ExisteCedula(info.Persona_Info.pe_cedulaRuc, ref mensaje) == false)
                        {
                            resultado = Persona_data.GrabarDB(info.Persona_Info, ref idPersona, ref mensaje);
                        }
                        info.Base = "N";
                        break;

                    case "N": resultado = true; idPersona = info.IdPersona; break;
                    }

                    if (resultado == true && info.Base == "N")
                    {
                        Aca_Profesor addressProf = new Aca_Profesor();
                        addressProf.IdInstitucion = info.IdInstitucion;
                        idProfesor                  = GetId(info.IdInstitucion);
                        addressProf.IdProfesor      = idProfesor;
                        addressProf.CodProfesor     = string.IsNullOrEmpty(info.CodProfesor) ? idProfesor.ToString() : info.CodProfesor == "0" ? idProfesor.ToString() : info.CodProfesor;
                        addressProf.IdPersona       = idPersona;
                        addressProf.estado          = info.estado;
                        addressProf.FechaCreacion   = DateTime.Now;
                        addressProf.UsuarioCreacion = info.UsuarioCreacion;
                        Base.Aca_Profesor.Add(addressProf);
                        Base.SaveChanges();
                        mensaje = "Se ha procedido a grabar el Profesor #: " + idProfesor.ToString() + " exitosamente.";
                    }
                    else
                    {
                        mensaje = "El Profesor " + idProfesor.ToString() + " ya se encuentra ingresado.";
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.InnerException + " " + ex.Message;
                throw new Exception(ex.InnerException.ToString());
            }
        }
Beispiel #2
0
        public Boolean ActualizarDB(Aca_Aspirante_Info info, ref string msj)
        {
            try
            {
                Aca_Estudiante_Data daEstudiante = new Aca_Estudiante_Data();
                using (Entities_Academico context = new Entities_Academico())
                {
                    var estudiante = context.Aca_Aspirante.FirstOrDefault(obj => obj.IdInstitucion == info.IdInstitucion && obj.IdAspirante == info.IdAspirante);
                    if (estudiante != null)
                    {
                        decimal idAspirante = info.IdAspirante;
                        estudiante.cod_aspirante       = string.IsNullOrEmpty(info.CodAspirante) ? info.IdAspirante.ToString() : info.CodAspirante;
                        estudiante.IdPersona           = info.Persona_Info.IdPersona;
                        estudiante.IdPais_Nacionalidad = info.Pais_Info.IdPais;
                        estudiante.lugar               = (info.Lugar == null) ? "" : info.Lugar;
                        estudiante.FechaModificacion   = DateTime.Now;
                        estudiante.UsuarioModificacion = info.UsuarioModificacion;
                        estudiante.foto   = info.Foto;
                        estudiante.estado = info.Estado;
                        estudiante.barrio = (info.Barrio == null) ? "" : info.Barrio;

                        context.SaveChanges();
                        tb_persona_data Persona_Data = new tb_persona_data();
                        Persona_Data.ModificarDB(info.Persona_Info, ref msj);

                        msj = "Se ha procedido actualizar el Aspirante #: " + idAspirante.ToString() + " exitosamente.";
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                msj = ex.InnerException + " " + ex.Message;
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref msj);
                msj = "Se ha producido el siguiente error: " + ex.Message;
                throw new Exception(ex.InnerException.ToString());
            }
        }
Beispiel #3
0
        public bool ActualizarDB(Aca_Profesor_Info info, ref string mensaje)
        {
            try
            {
                using (Entities_Academico Base = new Entities_Academico())
                {
                    Aca_Estudiante_Data daEstudiante = new Aca_Estudiante_Data();
                    tb_persona_data     Persona_Data = new tb_persona_data();

                    bool resultado = Persona_Data.ModificarDB(info.Persona_Info, ref mensaje);

                    if (resultado)
                    {
                        var vProfesor = Base.Aca_Profesor.FirstOrDefault(j => j.IdInstitucion == info.IdInstitucion && j.IdProfesor == info.IdProfesor);
                        if (vProfesor != null)
                        {
                            vProfesor.CodProfesor         = string.IsNullOrEmpty(info.CodProfesor) ? info.IdProfesor.ToString() : info.CodProfesor == "0" ? info.IdProfesor.ToString() : info.CodProfesor;
                            vProfesor.IdPersona           = info.Persona_Info.IdPersona;
                            vProfesor.estado              = info.estado;
                            vProfesor.FechaModificacion   = DateTime.Now;
                            vProfesor.UsuarioModificacion = info.UsuarioModificacion;
                            Base.SaveChanges();
                            mensaje = "Se ha procedido actualizar el Profesor #: " + info.IdProfesor.ToString() + " exitosamente.";
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.InnerException + " " + ex.Message;
                throw new Exception(ex.InnerException.ToString());
            }
        }
Beispiel #4
0
        public bool GrabarDB(Aca_Aspirante_Info info, ref decimal idAspirante, ref string msj)
        {
            try
            {
                Aca_Estudiante_Data daEstudiante = new Aca_Estudiante_Data();
                tb_persona_data     Person_Data  = new tb_persona_data();


                using (Entities_Academico context = new Entities_Academico())
                {
                    try{
                        bool          resultado        = true;
                        Aca_Aspirante addressAspirante = new Aca_Aspirante();

                        info.IdAspirante = idAspirante = getId(info.IdInstitucion);
                        decimal idPersona = 0;
                        if (info.Persona_Info.IdPersona == 0)
                        {
                            if (Person_Data.ExisteCedula(info.Persona_Info.pe_cedulaRuc, ref msj) == false)
                            {
                                resultado = Person_Data.GrabarDB(info.Persona_Info, ref idPersona, ref msj);
                            }
                        }
                        else
                        {
                            resultado = Person_Data.ModificarDB(info.Persona_Info, ref msj);
                            idPersona = info.Persona_Info.IdPersona;
                        }

                        if (resultado)
                        {
                            addressAspirante.IdInstitucion       = info.IdInstitucion;
                            addressAspirante.IdAspirante         = info.IdAspirante;
                            addressAspirante.IdPersona           = idPersona;
                            addressAspirante.cod_aspirante       = (info.CodAspirante == null || info.CodAspirante.Trim() == "" || info.CodAspirante.Trim() == "0") ? info.IdAspirante.ToString() : info.CodAspirante;
                            addressAspirante.lugar               = info.Lugar;
                            addressAspirante.barrio              = info.Barrio;
                            addressAspirante.foto                = info.Foto;
                            addressAspirante.cod_alterno         = info.CodAlterno;
                            addressAspirante.IdPais_Nacionalidad = info.Pais_Info.IdPais;
                            addressAspirante.estado              = info.Estado;
                            addressAspirante.FechaCreacion       = DateTime.Now;
                            addressAspirante.UsuarioCreacion     = info.UsuarioCreacion;
                            context.Aca_Aspirante.Add(addressAspirante);
                            context.SaveChanges();
                            msj = "Se ha procedido a grabar el Aspirante #: " + idAspirante.ToString() + " exitosamente.";
                        }

                        return(true);
                    }
                    //catch(Exception ex)
                    //{
                    //    string arreglo = ToString();
                    //    tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data();
                    //    tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                    //                        "", "", "", "", DateTime.Now);
                    //    oDataLog.Guardar_Log_Error(Log_Error_sis, ref msj);
                    //    msj = ex.InnerException + " " + ex.Message;
                    //    return false;
                    //}
                    catch (DbEntityValidationException ex)
                    {
                        string arreglo = ToString();
                        foreach (var item in ex.EntityValidationErrors)
                        {
                            foreach (var item_validaciones in item.ValidationErrors)
                            {
                                mensaje = "Propiedad: " + item_validaciones.PropertyName + " Mensaje: " + item_validaciones.ErrorMessage + "\n";
                            }
                        }
                        tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                        tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(mensaje, "", arreglo, "", "", "", "", "", DateTime.Now);
                        oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                        throw new Exception(mensaje);
                    }
                }
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref msj);
                msj = ex.InnerException + " " + ex.Message;
                throw new Exception(ex.InnerException.ToString());
            }
        }
Beispiel #5
0
        public bool ActualizarDB(Aca_Familiar_Info info, ref string msj)
        {
            bool    resultado = false;
            bool    accion_actualizarPersona = false;
            bool    accion_actualizaFamiliar = false;
            decimal idFam = 0;

            try
            {
                Aca_Estudiante_Data da           = new Aca_Estudiante_Data();
                tb_persona_data     Persona_Data = new tb_persona_data();

                decimal idPersona = 0;
                if (info.Persona_Info.IdPersona == 0)
                {
                    if (Persona_Data.ExisteCedula(info.Persona_Info.pe_cedulaRuc, ref msj) == false)
                    {
                        resultado = Persona_Data.GrabarDB(info.Persona_Info, ref idPersona, ref msj);
                    }

                    info.Persona_Info.IdPersona = idPersona;
                }
                else
                {
                    resultado = Persona_Data.ModificarDB(info.Persona_Info, ref msj);
                    idPersona = info.Persona_Info.IdPersona;
                    accion_actualizaFamiliar = true;
                }

                if (info.IdFamiliar != 0 && accion_actualizaFamiliar)
                {
                    using (Entities_Academico Base = new Entities_Academico())
                    {
                        try
                        {
                            var familiarEst = Base.Aca_Familiar.FirstOrDefault(f => f.IdInstitucion == info.IdInstitucion &&
                                                                               //f.IdEstudiante == info.IdEstudiante &&
                                                                               f.IdFamiliar == info.IdFamiliar);

                            if (familiarEst != null)
                            {
                                familiarEst.IdPersona           = idPersona;
                                familiarEst.OcupacionLaboral    = info.OcupacionLaboral;
                                familiarEst.Titulo              = info.Titulo;
                                familiarEst.UsuarioModificacion = info.UsuarioModificacion;

                                familiarEst.IdNivelEducativo_cat   = info.IdNivelEducativo;
                                familiarEst.FechaModificacion      = DateTime.Now;
                                familiarEst.empresa_donde_trabaja  = info.EmpresaDondeTrabaja;
                                familiarEst.empresa_direccion      = info.EmpresaDireccion;
                                familiarEst.empresa_email          = info.EmpresaEmail;
                                familiarEst.empresa_telefono       = info.EmpresaTelefono;
                                familiarEst.ViveFueraDelPais       = info.ViveFueraDelPais;
                                familiarEst.Sector_Urbanizacion    = info.Sector_Urbanizacion;
                                familiarEst.PoseeDiscapacidad      = info.PoseeDiscapacidad;
                                familiarEst.IdCatalogoTipoSangre   = info.IdCatalogoTipoSangre;
                                familiarEst.IdCatalogoReligion     = info.IdCatalogoReligion;
                                familiarEst.IdCatalogoIdiomaNativo = info.IdCatalogoIdiomaNativo;
                                familiarEst.FueExAlumnoGraduado    = info.FueExAlumnoGraduado;
                                familiarEst.Fallecido        = info.Fallecido;
                                familiarEst.Calle_Secundaria = info.Calle_Secundaria;
                                familiarEst.Calle_Principal  = info.Calle_Principal;
                                familiarEst.IdCiudad         = info.IdCiudad;

                                Base.SaveChanges();
                            }
                        }
                        catch (Exception)
                        { // Cuando no existe el familiar en la tabla
                          //resultado = GrabarDB(info, ref msj, accion_actualizarPersona, ref idFamiliar);
                        }
                    }
                }
                else
                {
                    // Inserto
                    resultado = GrabarDB(info, accion_actualizarPersona, ref msj, ref idFam);
                }

                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                msj = ex.InnerException + " " + ex.Message;
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref msj);
                throw new Exception(ex.ToString());
            }
        }
Beispiel #6
0
        public bool GrabarDB(Aca_Familiar_Info info, bool actualizarPersona, ref string msj, ref decimal IdFam)
        {
            bool resultado = false;

            try
            {
                tb_persona_data Persona_Data = new tb_persona_data();
                tb_persona_Info Info_Persona = new tb_persona_Info();

                Aca_Estudiante_Data daEstudiante = new Aca_Estudiante_Data();
                decimal             idPersona    = 0;


                if (info.Persona_Info.IdPersona == 0)
                {
                    // la persona si no existe se la crea
                    if (Persona_Data.ExisteCedula(info.Persona_Info.pe_cedulaRuc, ref msj) == false)
                    {
                        resultado = Persona_Data.GrabarDB(info.Persona_Info, ref idPersona, ref msj);
                    }
                    else
                    {
                        Info_Persona = Persona_Data.Get_Info_Persona(info.Persona_Info.pe_cedulaRuc);
                        idPersona    = Info_Persona.IdPersona;

                        resultado = true;
                    }
                }
                else
                {
                    if (actualizarPersona)
                    {
                        resultado = Persona_Data.ModificarDB(info.Persona_Info, ref msj);
                    }
                    else
                    {
                        resultado = true;
                    }
                    idPersona = info.Persona_Info.IdPersona;
                }

                if (resultado)
                {
                    using (Entities_Academico Base = new Entities_Academico())
                    {
                        string       mensaje      = string.Empty;
                        Aca_Familiar infoFamiliar = new Aca_Familiar();
                        infoFamiliar.IdInstitucion = info.IdInstitucion;
                        if (info.Persona_Info.IdPersona != 0)
                        {
                            IdFam = GetIdFamiliar(info.IdInstitucion, info.Persona_Info.IdPersona, ref mensaje);
                        }
                        else
                        {
                            IdFam = GetIdFamiliar(info.IdInstitucion, idPersona, ref mensaje);
                        }
                        if (mensaje != "ExisteFamiliar")
                        {
                            infoFamiliar.IdFamiliar            = IdFam;
                            infoFamiliar.cod_familiar          = infoFamiliar.IdFamiliar.ToString();
                            infoFamiliar.IdNivelEducativo_cat  = info.IdNivelEducativo;
                            infoFamiliar.IdPersona             = idPersona;
                            infoFamiliar.empresa_donde_trabaja = (info.EmpresaDondeTrabaja == null) ? "" : info.EmpresaDondeTrabaja;
                            infoFamiliar.empresa_direccion     = (info.EmpresaDireccion == null) ? "" : info.EmpresaDireccion;
                            infoFamiliar.empresa_email         = (info.EmpresaEmail == null) ? "" : info.EmpresaEmail;
                            infoFamiliar.empresa_telefono      = (info.EmpresaTelefono == null) ? "" : info.EmpresaTelefono;
                            infoFamiliar.OcupacionLaboral      = (info.OcupacionLaboral == null) ? "" : info.OcupacionLaboral;
                            infoFamiliar.Titulo                 = (info.Titulo == null) ? "" : info.Titulo;
                            infoFamiliar.UsuarioCreacion        = info.UsuarioCreacion;
                            infoFamiliar.FechaCreacion          = DateTime.Now;
                            infoFamiliar.Calle_Principal        = (info.Calle_Principal == null) ? "" : info.Calle_Principal;
                            infoFamiliar.Calle_Secundaria       = (info.Calle_Secundaria == null) ? "" : info.Calle_Secundaria;
                            infoFamiliar.Sector_Urbanizacion    = (info.Sector_Urbanizacion == null) ? "" : info.Sector_Urbanizacion;
                            infoFamiliar.IdCiudad               = info.IdCiudad;
                            infoFamiliar.PoseeDiscapacidad      = info.PoseeDiscapacidad;
                            infoFamiliar.ViveFueraDelPais       = info.ViveFueraDelPais;
                            infoFamiliar.Fallecido              = info.Fallecido;
                            infoFamiliar.IdCatalogoIdiomaNativo = info.IdCatalogoIdiomaNativo;
                            infoFamiliar.IdCatalogoReligion     = info.IdCatalogoReligion;
                            infoFamiliar.IdCatalogoTipoSangre   = info.IdCatalogoTipoSangre;
                            infoFamiliar.FueExAlumnoGraduado    = info.FueExAlumnoGraduado;

                            Base.Aca_Familiar.Add(infoFamiliar);
                            Base.SaveChanges();
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                msj = ex.InnerException + " " + ex.Message;
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref msj);
                throw new Exception(ex.ToString());
            }
        }