// called to retrieve data from the database
        private void DataPortal_Fetch(CriteriaEx criteria)
        {
            try
            {
                SessionCode = criteria.SessionCode;

                Childs = criteria.Childs;

                if (nHMng.UseDirectSQL)
                {
                    Auditoria.DoLOCK(Session());
                    IDataReader reader = nHMng.SQLNativeSelect(criteria.Query);

                    if (reader.Read())
                    {
                        _base.CopyValues(reader);
                    }

                    if (Childs)
                    {
                        CuestionAuditoria.LOCK(AppContext.ActiveSchema.Code);

                        string query = CuestionesAuditoria.SELECT_BY_AUDITORIA(this.Oid);
                        reader      = nHManager.Instance.SQLNativeSelect(query, Session());
                        _cuestiones = CuestionesAuditoria.GetChildList(reader);

                        InformeDiscrepancia.LOCK(AppContext.ActiveSchema.Code);

                        query     = InformesDiscrepancias.SELECT_BY_AUDITORIA(this.Oid);
                        reader    = nHManager.Instance.SQLNativeSelect(query, Session());
                        _informes = InformesDiscrepancias.GetChildList(criteria.SessionCode, reader);

                        HistoriaAuditoria.LOCK(AppContext.ActiveSchema.Code);

                        query      = HistoriaAuditorias.SELECT_BY_AUDITORIA(Oid);
                        reader     = nHManager.Instance.SQLNativeSelect(query, Session());
                        _historial = HistoriaAuditorias.GetChildList(reader);

                        NotificacionInterna.LOCK(AppContext.ActiveSchema.Code);

                        query           = NotificacionesInternas.SELECT_BY_AUDITORIA(this.Oid, TipoNotificacionAsociado.COMUNICADO_AUDITORIA);
                        reader          = nHManager.Instance.SQLNativeSelect(query, Session());
                        _notificaciones = NotificacionesInternas.GetChildList(reader);
                    }
                }
            }
            catch (Exception ex)
            {
                if (Transaction() != null)
                {
                    Transaction().Rollback();
                }
                iQExceptionHandler.TreatException(ex);
            }
        }
        // called to retrieve data from db
        protected override void Fetch(CriteriaEx criteria)
        {
            this.RaiseListChangedEvents = false;

            Childs      = criteria.Childs;
            SessionCode = criteria.SessionCode;

            try
            {
                if (nHMng.UseDirectSQL)
                {
                    InformeDiscrepancia.LOCK(AppContext.ActiveSchema.Code);

                    IDataReader reader = nHManager.Instance.SQLNativeSelect(InformeDiscrepanciaList.SELECT(), Session());

                    IsReadOnly = false;

                    while (reader.Read())
                    {
                        this.AddItem(InformeDiscrepanciaInfo.Get(reader, Childs));
                    }

                    IsReadOnly = true;
                }
                else
                {
                    IList <InformeDiscrepancia> list = criteria.List <InformeDiscrepancia>();

                    if (list.Count > 0)
                    {
                        IsReadOnly = false;

                        foreach (InformeDiscrepancia item in list)
                        {
                            this.AddItem(item.GetInfo());
                        }

                        IsReadOnly = true;
                    }
                }
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            this.RaiseListChangedEvents = true;
        }
        private void Fetch(int session_code, IDataReader source)
        {
            try
            {
                _base.CopyValues(source);

                if (Childs)
                {
                    CuestionAuditoria.LOCK(AppContext.ActiveSchema.Code);

                    string      query  = CuestionesAuditoria.SELECT_BY_AUDITORIA(this.Oid);
                    IDataReader reader = nHManager.Instance.SQLNativeSelect(query, Session(session_code));
                    _cuestiones = CuestionesAuditoria.GetChildList(reader);

                    InformeDiscrepancia.LOCK(AppContext.ActiveSchema.Code);

                    query     = InformesDiscrepancias.SELECT_BY_AUDITORIA(this.Oid);
                    reader    = nHManager.Instance.SQLNativeSelect(query, Session(session_code));
                    _informes = InformesDiscrepancias.GetChildList(session_code, reader);

                    HistoriaAuditoria.LOCK(AppContext.ActiveSchema.Code);

                    query      = HistoriaAuditorias.SELECT_BY_AUDITORIA(Oid);
                    reader     = nHManager.Instance.SQLNativeSelect(query, Session(session_code));
                    _historial = HistoriaAuditorias.GetChildList(reader);

                    NotificacionInterna.LOCK(AppContext.ActiveSchema.Code);

                    query           = NotificacionesInternas.SELECT_BY_AUDITORIA(this.Oid, TipoNotificacionAsociado.COMUNICADO_AUDITORIA);
                    reader          = nHManager.Instance.SQLNativeSelect(query, Session(session_code));
                    _notificaciones = NotificacionesInternas.GetChildList(reader);
                }
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkOld();
        }