예제 #1
0
        internal void LoadLibroGanadero()
        {
            Hashtable oidExpedientes = new Hashtable();

            oidExpedientes.Add(0, 0);

            foreach (InputDeliveryLine item in this)
            {
                if (item.OidExpediente == 0)
                {
                    continue;
                }
                if (oidExpedientes.ContainsKey(item.OidExpediente))
                {
                    continue;
                }

                oidExpedientes.Add(item.OidExpediente, item.OidExpediente);

                Expedient expediente = Store.Expedient.Get(item.OidExpediente, false, true, SessionCode);
                if (expediente == null)
                {
                    continue;
                }
                if (expediente.ETipoExpediente != ETipoExpediente.Ganado)
                {
                    continue;
                }

                LivestockBook libro = LivestockBook.Get(1, false, true, SessionCode);
                libro.LoadLineasByExpediente(item.OidExpediente, false);
            }

            oidExpedientes.Clear();
        }
        internal void Update(LivestockBook parent)
        {
            this.RaiseListChangedEvents = false;

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

            this.RaiseListChangedEvents = true;
        }
        /// <summary>
        /// Construye el objeto y se encarga de obtener los
        /// hijos si los tiene y se solicitan
        /// </summary>
        /// <param name="criteria">Criterios de la consulta</param>
        private void Fetch(CriteriaEx criteria)
        {
            try
            {
                this.RaiseListChangedEvents = false;
                SessionCode = criteria.SessionCode;
                Childs      = criteria.Childs;

                if (nHMng.UseDirectSQL)
                {
                    LivestockBook.DoLOCK(Session());

                    IDataReader reader = nHMng.SQLNativeSelect(criteria.Query, Session());

                    while (reader.Read())
                    {
                        this.AddItem(LivestockBookLine.GetChild(SessionCode, reader, Childs));
                    }

                    SetMaxSerial();
                }
            }
            catch (Exception ex)
            {
                if (Transaction() != null)
                {
                    Transaction().Rollback();
                }
                iQExceptionHandler.TreatException(ex);
            }
            finally
            {
                this.RaiseListChangedEvents = true;
            }
        }
예제 #4
0
        internal void CopyValues(LivestockBook source)
        {
            if (source == null)
            {
                return;
            }

            _record.CopyValues(source._base.Record);
        }
        public static LivestockBookLineList GetList(long oidLibro, bool childs)
        {
            QueryConditions conditions = new QueryConditions {
                LibroGanadero = LivestockBook.New().GetInfo(false)
            };

            conditions.LibroGanadero.Oid = oidLibro;

            return(GetList(SELECT(conditions), childs));
        }
        /// <summary>
        /// Crea un nuevo elemento y lo añade a la lista
        /// </summary>
        /// <returns>Nuevo item</returns>
        public LivestockBookLine NewItem(LivestockBook parent)
        {
            this.NewItem(LivestockBookLine.NewChild(parent));
            LivestockBookLine item = this[Count - 1];

            if (MaxSerial == 0)
            {
                MaxSerial = item.Serial - 1;
            }
            SetNextCode(parent, item);
            return(item);
        }
        public static LivestockBookList GetList(bool childs)
        {
            CriteriaEx criteria = LivestockBook.GetCriteria(LivestockBook.OpenSession());

            criteria.Childs = childs;

            if (nHManager.Instance.UseDirectSQL)
            {
                criteria.Query = LivestockBookList.SELECT();
            }

            LivestockBookList list = DataPortal.Fetch <LivestockBookList>(criteria);

            CloseSession(criteria.SessionCode);
            return(list);
        }
        public void SetNextCode(LivestockBook parent, LivestockBookLine item)
        {
            int index = this.IndexOf(item);

            if (index == 0)
            {
                item.GetNewCode(parent.Oid);
                MaxSerial = item.Serial;
            }
            else
            {
                item.Serial = MaxSerial + 1;
                item.Codigo = item.Serial.ToString(Resources.Defaults.DEFAULT_CODE_FORMAT);
                MaxSerial++;
            }
        }
        public static LivestockBookLines GetChildListByExpediente(LivestockBook parent, long oidExpediente, bool childs)
        {
            CriteriaEx criteria = Stock.GetCriteria(parent.SessionCode);

            criteria.Childs = childs;

            QueryConditions conditions = new QueryConditions
            {
                LibroGanadero = parent.GetInfo(false),
                Expedient     = ExpedientInfo.New(oidExpediente)
            };

            criteria.Query = LivestockBookLines.SELECT(conditions);

            return(DataPortal.Fetch <LivestockBookLines>(criteria));
        }
 public static string SELECT(LivestockBookInfo parent)
 {
     return(LivestockBook.SELECT(new QueryConditions {
         LibroGanadero = parent
     }, true));
 }
 public static string SELECT(QueryConditions conditions)
 {
     return(LivestockBook.SELECT(conditions, false));
 }
 public static string SELECT(LivestockBook parent)
 {
     return(LivestockBookLine.SELECT(new QueryConditions {
         LibroGanadero = parent.GetInfo(false)
     }, true));
 }
 public void CopyFrom(LivestockBook source)
 {
     _base.CopyValues(source);
 }