Exemple #1
0
        internal void Insert(InformeAmpliacion 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();
        }
Exemple #2
0
        internal void Update(InformeAmpliacion 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 DeleteSelf(InformeAmpliacion 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 <AmpliacionRecord>(Oid));
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkNew();
        }
Exemple #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();
        }
        internal void Update(InformeAmpliacion parent)
        {
            this.RaiseListChangedEvents = false;

            // update (thus deleting) any deleted child objects
            foreach (Ampliacion 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 (Ampliacion obj in this)
            {
                if (obj.IsNew)
                {
                    obj.Insert(parent);
                }
                else
                {
                    obj.Update(parent);
                }
            }

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

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

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

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

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

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

            MarkOld();
        }
        /// <summary>
        /// Devuelve el siguiente código de PlanAnual.
        /// </summary>
        /// <returns></returns>
        public virtual string GetNewCode(InformeAmpliacion parent)
        {
            Int64 lastcode = Ampliacion.GetNewSerial(parent);

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

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

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

            foreach (Ampliacion item in parent.Ampliaciones)
            {
                if (item.Serial > lastcode)
                {
                    lastcode = item.Serial;
                }
            }

            lastcode++;
            return(lastcode);
        }
Exemple #9
0
        public void CopyValues(InformeAmpliacion source)
        {
            if (source == null)
            {
                return;
            }

            _record.CopyValues(source.Base.Record);
        }
        //  private InformeAmpliacionList() { }

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

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

            CloseSession(criteria.SessionCode);

            return(list);
        }
Exemple #11
0
        public static NotificacionInterna NewChild(InformeAmpliacion 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 Ampliacion NewChild(InformeAmpliacion parent)
        {
            if (!CanAddObject())
            {
                throw new System.Security.SecurityException(
                          moleQule.Library.Resources.Messages.USER_NOT_ALLOWED);
            }

            Ampliacion obj = new Ampliacion();

            obj.OidInformeAmpliacion = parent.Oid;

            return(obj);
        }
        // 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)
                {
                    InformeAmpliacion.LOCK(AppContext.ActiveSchema.Code);

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

                    IsReadOnly = false;

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

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

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

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

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

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


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

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

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

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

            MarkOld();
        }
Exemple #16
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);
            }
        }
 public static string SELECT()
 {
     return(InformeAmpliacion.SELECT(new QueryConditions(), false));
 }
Exemple #18
0
 public NotificacionInterna NewItem(InformeAmpliacion parent)
 {
     this.AddItem(NotificacionInterna.NewChild(parent));
     return(this[Count - 1]);
 }
Exemple #19
0
 public void CopyFrom(InformeAmpliacion source)
 {
     _base.CopyValues(source);
 }
 public Ampliacion NewItem(InformeAmpliacion parent)
 {
     this.AddItem(Ampliacion.NewChild(parent));
     return(this[Count - 1]);
 }