public bool Grabar(Aca_PeriodoLectivo_Info info, ref string mensaje) { try { using (EntitiesCAHAcademico Base = new EntitiesCAHAcademico()) { Aca_Periodo_Lectivo address = new Aca_Periodo_Lectivo(); address.IdInstitucion = info.IdInstitucion; address.IdPeriodoLectivo = info.IdPeriodoLectivo; address.Descripcion = info.Descripcion; address.FechaInicio = info.FechaInicio; address.FechaFin = info.FechaFin; address.Estado = "A"; address.FechaCreacion = info.FechaCreacion; address.UsuarioCreacion = info.UsuarioCreacion; Base.Aca_Periodo_Lectivo.Add(address); Base.SaveChanges(); mensaje = "Se ha producido ingresar un nuevo periodo lectivo 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); mensaje = ex.InnerException + " " + ex.Message; oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = "Se ha producido el siguiente error: " + ex.Message; throw new Exception(ex.ToString()); } }
public bool Actualizar(Aca_PeriodoLectivo_Info info, ref string mensaje) { try { using (EntitiesCAHAcademico Base = new EntitiesCAHAcademico()) { var anioLectivo = Base.Aca_Periodo_Lectivo.FirstOrDefault(o => o.IdInstitucion == info.IdInstitucion && o.IdPeriodoLectivo == info.IdPeriodoLectivo); if (anioLectivo != null) { anioLectivo.Descripcion = info.Descripcion; anioLectivo.FechaInicio = info.FechaInicio; anioLectivo.FechaFin = info.FechaFin; anioLectivo.FechaModificacion = info.FechaModificacion; anioLectivo.UsuarioModificacion = info.UsuarioModificacion; Base.SaveChanges(); mensaje = "Se ha producido actualizar el periodo lectivo 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); mensaje = ex.InnerException + " " + ex.Message; oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = "Se ha producido el siguiente error: " + ex.Message; throw new Exception(ex.ToString()); } }
public bool AnularDB(Aca_PeriodoLectivo_Info info, ref string mensaje) { try { using (EntitiesCAHAcademico context = new EntitiesCAHAcademico()) { var address = context.Aca_Periodo_Lectivo.FirstOrDefault(a => a.IdInstitucion == info.IdInstitucion && a.IdPeriodoLectivo == info.IdPeriodoLectivo); if (address != null) { address.Estado = "I"; address.FechaAnulacion = DateTime.Now; address.UsuarioAnulacion = info.UsuarioAnulacion; address.MotivoAnulacion = info.MotivoAnulacion; context.SaveChanges(); mensaje = "Se ha procedido anular el periodo leactivo: " + info.IdPeriodoLectivo.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); mensaje = ex.InnerException + " " + ex.Message; oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = "Se ha producido el siguiente error: " + ex.Message; throw new Exception(ex.ToString()); } }