Пример #1
0
        public bool UpdateAllergen(Session session, int?id, string name)
        {
            Allergen Allergen = session.GetObjectByKey <Allergen>(id.Value);

            if (Allergen != null)
            {
                //It is a new Product
                return(InsertAllergen(session, name));
            }

            if (string.IsNullOrEmpty(name))
            {
                throw new ApplicationException("You must provide Allergen.");
            }

            Allergen originalRecord = null;
            Cloner   cloner         = new Cloner();

            originalRecord = (Allergen)cloner.CloneTo(Allergen, typeof(Allergen));

            Allergen.AllergenName = name;

            if (!(originalRecord == null))
            {
                UpdateAuditTrail(Allergen, originalRecord);
            }

            Allergen.Save();

            return(true);
        }
Пример #2
0
        public static ForexTrade CloneForexTrade(ForexTrade fromFt)
        {
            Cloner cloner  = new Cloner();
            var    amendFt = (ForexTrade)cloner.CloneTo(fromFt, typeof(ForexTrade));

            amendFt.EventType = ForexEventType.Predeliver;
            amendFt.OrigTrade = fromFt;
            return(amendFt);
        }
Пример #3
0
        public virtual fmCPRPaymentRequest CloneRequest()
        {
            fmCPRPaymentRequest req = null;

            DevExpress.Persistent.Base.Cloner cloner = new Cloner();

            // Копирование полей из данного документа в новый
            req       = cloner.CloneTo(this, typeof(fmPaymentRequestMemorandum)) as fmPaymentRequestMemorandum;
            req.State = PaymentRequestStates.OPEN;
            return(req);
        }
Пример #4
0
        void cloneObjectController_CustomCloneObject(object sender, CustomCloneObjectEventArgs e)
        {
            var cloner        = new MiClonador();
            var defaultCloner = new Cloner();

            e.TargetObjectSpace = e.CreateDefaultTargetObjectSpace();
            object objectFromTargetObjectSpace = e.TargetObjectSpace.GetObject(e.SourceObject);

            if ((e.TargetType).Name == "Activo" || (e.TargetType).Name == "Equipo" ||
                (e.TargetType).Name == "Vehiculo" || (e.TargetType).Name == "Software")
            {
                e.ClonedObject = cloner.CloneTo(objectFromTargetObjectSpace, e.TargetType);
            }
            else
            {
                e.ClonedObject = defaultCloner.CloneTo(objectFromTargetObjectSpace, e.TargetType);
            }
        }
Пример #5
0
        public int UpdateReceivingDetails(Session session, int?detailID, int receivingID, int?itemID, string lot, int?quantity, int?units, int?LPN, DateTime?expirationDate)
        {
            if (!itemID.HasValue)
            {
                throw new ApplicationException("You must provide receiving item.");
            }

            if (!quantity.HasValue || !units.HasValue)
            {
                throw new ApplicationException("You must provide the amount of quamtity\\units received.");
            }

            if (LPN == null)
            {
                throw new ApplicationException("LPN is blank.");
            }

            Items item = session.GetObjectByKey <Items>(itemID.Value, true);

            if (!LotCodeValidator.ValidateByItem(item, lot, true))
            {
                throw new ApplicationException("Item " + item.ItemCode + " & lot # " + lot + " is invalid" + Environment.NewLine + "You must provide a valid lot.");
            }


            ReceivingDetail detail = session.GetObjectByKey <ReceivingDetail>(detailID);

            if (detail == null)
            {
                //It is a new Detail
                return(InsertDetails(session, receivingID, item, lot, quantity, units, LPN, expirationDate));
            }

            bool itemChanged = false;

            ReceivingDetail originalDetail = null;
            Cloner          cloner         = new Cloner();

            originalDetail = (ReceivingDetail)cloner.CloneTo(detail, typeof(ReceivingDetail));

            if (itemID.HasValue && originalDetail.ReceivDetItemID.ItemID != itemID)
            {
                itemChanged = true;
            }

            detail.ReceivDetItemID = item;
            detail.intUnits        = units.Value;
            detail.ReceivDetQty    = quantity.Value;
            detail.ExpirationDate  = expirationDate;
            detail.ReceivDetLPN    = LPN;
            detail.ReceivDetLot    = lot;


            if (!(originalDetail == null))
            {
                UpdateAuditTrail(detail, originalDetail);
            }

            session.Save(detail);

            if (!detail.Equals(originalDetail))
            {
                ItemsBLL items      = new ItemsBLL();
                int      locationID = session.GetObjectByKey <Receiving>(receivingID).ReceivingLocation.Oid;
                items.UpdateStock(session, originalDetail.ReceivDetItemID.ItemID, null, originalDetail.ReceivDetQty * -1, false, locationID, originalDetail.ReceivDetLot, LPN);

                items.UpdateStock(session, itemID.Value, quantity.Value, false, locationID, lot, LPN, expirationDate);
            }

            return(detail.ReceivDetID);
        }