Exemplo n.º 1
0
        public static void ChangeStatus(Guid ID, Pack.StatusX toStatus, PackTransaction.TypeX transType, string note)
        {
            RedBloodDataContext db = new RedBloodDataContext();

            Pack p = Get(db, ID);

            if (p.Status == toStatus)
            {
                throw new Exception("Can not change statuses which are the same.");
            }

            PackTransactionBLL.Add(ID, p.Status, toStatus, transType, note);

            p.Status = toStatus;
            db.SubmitChanges();
        }
Exemplo n.º 2
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);
            }
        }