/// <summary>
        /// Crea un nuevo elemento y lo añade a la lista
        /// </summary>
        /// <returns>Nuevo item</returns>
        public WorkReportResource NewItem(WorkReport parent)
        {
            this.NewItem(WorkReportResource.NewChild(parent));
            WorkReportResource item = this[Count - 1];

            return(item);
        }
        /// <summary>
        /// Realiza el Save de los objetos de la lista. Inserta, Actualiza o Borra en función
        /// de los flags de cada objeto de la lista
        /// </summary>
        /// <param name="parent">BusinessBaseEx padre de la lista</param>
        internal void Update(WorkReport parent)
        {
            try
            {
                this.RaiseListChangedEvents = false;

                SessionCode = parent.SessionCode;

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

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

                // add/update any current child objects
                foreach (WorkReportResource obj in this)
                {
                    if (obj.IsNew)
                    {
                        obj.Insert(parent);
                    }
                    else
                    {
                        obj.Update(parent);
                    }
                }
            }
            finally
            {
                this.RaiseListChangedEvents = true;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Actualiza un registro en la base de datos
        /// </summary>
        /// <param name="parent">Objeto padre</param>
        internal void Update(WorkReport parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            //Debe obtener la sesion del padre pq el objeto es padre a su vez
            SessionCode = parent.SessionCode;

            OidWorkReport = parent.Oid;

            ValidationRules.CheckRules();

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

            WorkReportResourceRecord obj = parent.Session().Get <WorkReportResourceRecord>(Oid);

            obj.CopyValues(Base.Record);
            parent.Session().Update(obj);

            MarkOld();
        }
Esempio n. 4
0
 public static string SELECT(WorkReport item)
 {
     Library.Store.QueryConditions conditions = new Library.Store.QueryConditions {
         WorkReport = item.GetInfo(false)
     };
     return(SELECT(conditions, false));
 }
        public static WorkReportResources GetChildList(WorkReport parent, bool childs)
        {
            CriteriaEx criteria = WorkReport.GetCriteria(parent.SessionCode);

            criteria.Query  = SELECT(parent);
            criteria.Childs = childs;

            return(DataPortal.Fetch <WorkReportResources>(criteria));
        }
Esempio n. 6
0
        protected virtual void CopyFrom(WorkReport source)
        {
            if (source == null)
            {
                return;
            }

            OidWorkReport = source.Oid;
            From          = source.From;
            Till          = source.Till;
            Hours         = source.Hours;
        }
Esempio n. 7
0
        public void CopyValues(WorkReport source)
        {
            if (source == null)
            {
                return;
            }

            _record.CopyValues(source.Base.Record);

            _expedient     = source.Expedient;
            _owner         = source.Owner;
            _category_name = source.CategoryName;
        }
Esempio n. 8
0
        public static WorkReportResource NewChild(WorkReport parent, IWorkResource item = null)
        {
            if (!CanAddObject())
            {
                throw new System.Security.SecurityException(Library.Resources.Messages.USER_NOT_ALLOWED);
            }

            WorkReportResource obj = DataPortal.Create <WorkReportResource>(new CriteriaCs(-1));

            obj.CopyFrom(parent);
            obj.CopyFrom(item);
            obj.MarkAsChild();
            return(obj);
        }
Esempio n. 9
0
        /// <summary>
        /// Borra un registro de la base de datos.
        /// </summary>
        /// <param name="parent">Objeto padre</param>
        /// <remarks>Borrado inmediato<remarks/>
        internal void DeleteSelf(WorkReport 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;
            }

            if (EEntityType == ETipoEntidad.OutputDelivery)
            {
                OutputDelivery.Delete(OidResource, ETipoEntidad.WorkReport, parent.SessionCode);
            }

            SessionCode = parent.SessionCode;
            Session().Delete(Session().Get <WorkReportResourceRecord>(Oid));

            MarkNew();
        }
 public WorkReportResource NewItem(WorkReport parent, WorkReportResourceInfo item)
 {
     this.NewItem(WorkReportResource.NewChild(parent, item));
     return(this[Count - 1]);
 }
 public static string SELECT(WorkReport parent)
 {
     return(WorkReportResource.SELECT(new QueryConditions {
         WorkReport = parent.GetInfo(false)
     }, true));
 }