Beispiel #1
0
    public static void Add(string DIN, string productCode, int?volume, bool isOriginal)
    {
        RedBloodDataContext db = new RedBloodDataContext();

        Donation d = null;

        if (isOriginal)
        {
            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;
        pack.ExpirationDate = DateTime.Now.Add(product.Duration.Value - RedBloodSystem.RootTime);

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


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

        if (isOriginal)
        {
            DonationBLL.SetOriginalPack(DIN, pack.ID);
        }
    }
Beispiel #2
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();
    }