Ejemplo n.º 1
0
        public static void Add(string DIN, string productCode, int?volume, Pack orgPack = null, DateTime?packDate = null)
        {
            RedBloodDataContext db = new RedBloodDataContext();

            Donation d = null;

            if (orgPack == null)
            {
                d = DonationBLL.Get4CreateOriginal(db, DIN);
            }
            else
            {
                d = DonationBLL.Get(DIN);
            }

            Product product = ProductBLL.Get(productCode);

            if (IsExist(DIN, productCode))
            {
                throw new Exception(PackErrEnum.Existed.Message);
            }


            //TODO: Check to see valid product code in collection
            //Code will be here

            //TODO: Check to see if the pack is collector too late
            //Code check will be here.

            Pack pack = new Pack();

            pack.DIN         = DIN;
            pack.ProductCode = productCode;
            pack.Status      = Pack.StatusX.Product;
            pack.Actor       = RedBloodSystem.CurrentActor;
            //pack.Volume = product.OriginalVolume.HasValue ? product.OriginalVolume : defaultVolume;
            pack.Volume = volume;

            if (orgPack != null &&
                product.CreatedDateFromOrgPack.HasValue &&
                product.CreatedDateFromOrgPack.Value)
            {
                pack.Date = orgPack.Date;
            }
            else
            {
                if (packDate != null)
                {
                    pack.Date = packDate;
                }
                else
                {
                    pack.Date = DateTime.Now;
                }
            }
            pack.ExpirationDate = pack.Date.Value.Add(product.Duration.Value - RedBloodSystem.RootTime);

            db.Packs.InsertOnSubmit(pack);
            db.SubmitChanges();


            PackTransactionBLL.Add(pack.ID, Pack.StatusX.Non, Pack.StatusX.Product,
                                   orgPack == null ? PackTransaction.TypeX.In_Collect : PackTransaction.TypeX.In_Product);

            if (orgPack == null)
            {
                DonationBLL.SetOriginalPack(DIN, pack.ID);
            }
        }
Ejemplo n.º 2
0
        public static void Add(string DIN, string productCode, Pack orgPack = null)
        {
            Product product = ProductBLL.Get(productCode);

            Add(DIN, productCode, product.OriginalVolume, orgPack);
        }