/// <summary>
        /// Devuelve el siguiente código de PlanAnual.
        /// </summary>
        /// <returns></returns>
        public static string GetNewCode(InformeCorrector parent)
        {
            Int64 lastcode = AccionCorrectora.GetNewSerial(parent);

            // Devolvemos el siguiente codigo de PlanAnual
            return(lastcode.ToString(Resources.Defaults.ACCION_CORRECTORA_CODE_FORMAT));
        }
        /// <summary>
        /// Devuelve el siguiente Serial de PlanAnual
        /// </summary>
        /// <returns></returns>
        private static Int64 GetNewSerial(InformeCorrector parent)
        {
            // Obtenemos la lista de clientes ordenados por serial
            SortedBindingList <AccionCorrectoraInfo> Acciones =
                AccionCorrectoraList.GetSortedList("Serial", ListSortDirection.Ascending);

            // Obtenemos el último serial de servicio
            Int64 lastcode;

            if (Acciones.Count > 0)
            {
                lastcode = Acciones[Acciones.Count - 1].Serial;
            }
            else
            {
                lastcode = Convert.ToInt64(Resources.Defaults.ACCION_CORRECTORA_CODE_FORMAT);
            }

            foreach (AccionCorrectora item in parent.Acciones)
            {
                if (item.Serial > lastcode)
                {
                    lastcode = item.Serial;
                }
            }

            lastcode++;
            return(lastcode);
        }
        internal void DeleteSelf(InformeCorrector parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            // if we're new then don't update the database
            if (this.IsNew)
            {
                return;
            }

            try
            {
                SessionCode = parent.SessionCode;
                Session().Delete(Session().Get <AccionCorrectoraRecord>(Oid));
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkNew();
        }
示例#4
0
        private void Fetch(InformeDiscrepancia source)
        {
            try
            {
                SessionCode = source.SessionCode;

                _base.CopyValues(source);

                CriteriaEx criteria = InformeAmpliacion.GetCriteria(Session());
                criteria.AddEq("OidInformeDiscrepancia", this.Oid);
                _ampliaciones = InformesAmpliaciones.GetChildList(criteria.List <InformeAmpliacion>());

                criteria = InformeCorrector.GetCriteria(Session());
                criteria.AddEq("OidInformeDiscrepancia", this.Oid);
                _correctores = InformesCorrectores.GetChildList(criteria.List <InformeCorrector>());

                criteria = Discrepancia.GetCriteria(Session());
                criteria.AddEq("OidInformeDiscrepancia", this.Oid);
                _discrepancias = Discrepancias.GetChildList(criteria.List <Discrepancia>());

                criteria = NotificacionInterna.GetCriteria(Session());
                criteria.AddEq("OidAsociado", this.Oid);
                criteria.AddEq("TipoAsociado", (long)TipoNotificacionAsociado.INFORME_DISCREPANCIAS);
                _notificaciones = NotificacionesInternas.GetChildList(criteria.List <NotificacionInterna>());
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkOld();
        }
示例#5
0
        internal void Update(InformeCorrector parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            OidAsociado = parent.Oid;

            try
            {
                ValidationRules.CheckRules();

                if (!IsValid)
                {
                    throw new iQValidationException(moleQule.Library.Resources.Messages.GENERIC_VALIDATION_ERROR);
                }

                NotificacionInternaRecord obj = parent.Session().Get <NotificacionInternaRecord>(Oid);
                obj.CopyValues(this.Base.Record);
                parent.Session().Update(obj);
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkOld();
        }
        internal void Update(InformeCorrector parent)
        {
            this.RaiseListChangedEvents = false;

            // update (thus deleting) any deleted child objects
            foreach (AccionCorrectora obj in DeletedList)
            {
                obj.DeleteSelf(parent);
            }

            // now that they are deleted, remove them from memory too
            DeletedList.Clear();

            // AddItem/update any current child objects
            foreach (AccionCorrectora obj in this)
            {
                if (obj.IsNew)
                {
                    obj.Insert(parent);
                }
                else
                {
                    obj.Update(parent);
                }
            }

            this.RaiseListChangedEvents = true;
        }
示例#7
0
        internal void Insert(InformeCorrector parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            OidAsociado = parent.Oid;
            GetNewCode();

            try
            {
                ValidationRules.CheckRules();

                if (!IsValid)
                {
                    throw new iQValidationException(moleQule.Library.Resources.Messages.GENERIC_VALIDATION_ERROR);
                }

                parent.Session().Save(this.Base.Record);
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkOld();
        }
示例#8
0
        public void CopyValues(InformeCorrector source)
        {
            if (source == null)
            {
                return;
            }

            _record.CopyValues(source.Base.Record);
        }
示例#9
0
        //  private InformeCorrectorList() { }

        /// <summary>
        /// Retrieve the complete list from db
        /// </summary>
        /// <returns>InformeCorrectorList</returns>
        public static InformeCorrectorList GetList()
        {
            CriteriaEx criteria = InformeCorrector.GetCriteria(InformeCorrector.OpenSession());

            //No criteria. Retrieve all de List
            InformeCorrectorList list = DataPortal.Fetch <InformeCorrectorList>(criteria);

            CloseSession(criteria.SessionCode);

            return(list);
        }
示例#10
0
        public static NotificacionInterna NewChild(InformeCorrector parent)
        {
            if (!CanAddObject())
            {
                throw new System.Security.SecurityException(
                          moleQule.Library.Resources.Messages.USER_NOT_ALLOWED);
            }

            NotificacionInterna obj = new NotificacionInterna();

            obj.OidAsociado = parent.Oid;
            return(obj);
        }
        public static AccionCorrectora NewChild(InformeCorrector parent)
        {
            if (!CanAddObject())
            {
                throw new System.Security.SecurityException(
                          moleQule.Library.Resources.Messages.USER_NOT_ALLOWED);
            }

            AccionCorrectora obj = new AccionCorrectora();

            obj.OidInformeCorrector = parent.Oid;

            return(obj);
        }
示例#12
0
        // 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)
                {
                    InformeCorrector.LOCK(AppContext.ActiveSchema.Code);

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

                    IsReadOnly = false;

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

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

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

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

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

            this.RaiseListChangedEvents = true;
        }
        internal void Update(InformeCorrector parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }


            try
            {
                SessionCode = parent.SessionCode;
                AccionCorrectoraRecord obj = Session().Get <AccionCorrectoraRecord>(Oid);
                obj.CopyValues(this.Base.Record);
                Session().Update(obj);
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkOld();
        }
        internal void Insert(InformeCorrector parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            OidInformeCorrector = parent.Oid;
            Codigo = GetNewCode(parent);
            Serial = GetNewSerial(parent);

            try
            {
                parent.Session().Save(this.Base.Record);
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkOld();
        }
示例#15
0
 public static string SELECT()
 {
     return(InformeCorrector.SELECT(new QueryConditions(), false));
 }
 public void CopyFrom(InformeCorrector source)
 {
     _base.CopyValues(source);
 }
示例#17
0
 public NotificacionInterna NewItem(InformeCorrector parent)
 {
     this.AddItem(NotificacionInterna.NewChild(parent));
     return(this[Count - 1]);
 }
 public AccionCorrectora NewItem(InformeCorrector parent)
 {
     this.AddItem(AccionCorrectora.NewChild(parent));
     return(this[Count - 1]);
 }
示例#19
0
        // called to retrieve data from the database
        private void DataPortal_Fetch(CriteriaEx criteria)
        {
            try
            {
                SessionCode = criteria.SessionCode;

                Childs = criteria.Childs;

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

                    IDataReader reader = InformeDiscrepancia.DoSELECT(AppContext.ActiveSchema.Code, Session(), criteria.Oid);

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

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

                        string query = InformesAmpliaciones.SELECT_BY_INFORME_DISCREPANCIA(this.Oid);
                        reader        = nHManager.Instance.SQLNativeSelect(query, Session());
                        _ampliaciones = InformesAmpliaciones.GetChildList(criteria.SessionCode, reader);

                        InformeCorrector.LOCK(AppContext.ActiveSchema.Code);

                        query        = InformesCorrectores.SELECT_BY_INFORME_DISCREPANCIA(this.Oid);
                        reader       = nHManager.Instance.SQLNativeSelect(query, Session());
                        _correctores = InformesCorrectores.GetChildList(criteria.SessionCode, reader);

                        Discrepancia.LOCK(AppContext.ActiveSchema.Code);

                        query          = Discrepancias.SELECT_BY_INFORME_DISCREPANCIA(this.Oid);
                        reader         = nHManager.Instance.SQLNativeSelect(query, Session());
                        _discrepancias = Discrepancias.GetChildList(criteria.SessionCode, reader);

                        NotificacionInterna.LOCK(AppContext.ActiveSchema.Code);

                        query           = NotificacionesInternas.SELECT_BY_INFORME_DISCREPANCIA(this.Oid, TipoNotificacionAsociado.INFORME_DISCREPANCIAS);
                        reader          = nHManager.Instance.SQLNativeSelect(query, Session());
                        _notificaciones = NotificacionesInternas.GetChildList(reader);
                    }
                }
                else
                {
                    _base.Record.CopyValues((InformeDiscrepanciaRecord)(criteria.UniqueResult()));

                    Session().Lock(Session().Get <InformeDiscrepanciaRecord>(Oid), LockMode.UpgradeNoWait);

                    if (Childs)
                    {
                        criteria = InformeAmpliacion.GetCriteria(Session());
                        criteria.AddEq("OidInformeDiscrepancia", this.Oid);
                        _ampliaciones = InformesAmpliaciones.GetChildList(criteria.List <InformeAmpliacion>());

                        criteria = InformeCorrector.GetCriteria(Session());
                        criteria.AddEq("OidInformeDiscrepancia", this.Oid);
                        _correctores = InformesCorrectores.GetChildList(criteria.List <InformeCorrector>());

                        criteria = Discrepancia.GetCriteria(Session());
                        criteria.AddEq("OidInformeDiscrepancia", this.Oid);
                        _discrepancias = Discrepancias.GetChildList(criteria.List <Discrepancia>());

                        criteria = NotificacionInterna.GetCriteria(Session());
                        criteria.AddEq("OidAsociado", this.Oid);
                        criteria.AddEq("TipoAsociado", (long)TipoNotificacionAsociado.INFORME_DISCREPANCIAS);
                        _notificaciones = NotificacionesInternas.GetChildList(criteria.List <NotificacionInterna>());
                    }
                }
            }
            catch (NHibernate.ADOException)
            {
                if (Transaction() != null)
                {
                    Transaction().Rollback();
                }
                throw new iQLockException(moleQule.Library.Resources.Messages.LOCK_ERROR);
            }
            catch (Exception ex)
            {
                if (Transaction() != null)
                {
                    Transaction().Rollback();
                }
                iQExceptionHandler.TreatException(ex);
            }
        }