Beispiel #1
0
        public static JoinPlToVpToProdBindingList GetOrderLines(
            PurOrderId orderId,
            bool shelfOrder,
            List <ProductCategory> categories,
            Dictionary <int, ProductSubCategory> subCategories,
            Dictionary <int, ProductBrand> brands,
            out PurOrder order)
        {
            JoinPlToVpToProdBindingList venprodJoinList = new JoinPlToVpToProdBindingList();

            using (Ambient.DbSession.Activate())
            {
                order = OrderingRepositories.PurOrder.Get(orderId);

                // Create dictionaries of Product and VendorProduct for PurOrder.VendorId and
                // all product categories.
                Dictionary <int, Product>       productDict       = new Dictionary <int, Product>();
                Dictionary <int, VendorProduct> vendorProductDict = new Dictionary <int, VendorProduct>();
                foreach (ProductCategory cat in categories)
                {
                    List <VendorProduct> vendorProducts = OrderingRepositories.VendorProduct.Get(
                        order.VendorId, cat.Id);
                    foreach (VendorProduct vendorProduct in vendorProducts)
                    {
                        vendorProductDict.Add(vendorProduct.Id.Value, vendorProduct);
                    }
                    List <Product> products = OrderingRepositories.Product.Get(order.VendorId, cat.Id);
                    foreach (Product product in products)
                    {
                        productDict.Add(product.Id.Value, product);
                    }
                }

                // Construct a JoinPlToVpToProd for each PurLine in order.
                List <PurLine> purLines;
                if (shelfOrder)
                {
                    purLines = OrderingRepositories.PurLine.GetInShelfOrder(orderId);
                }
                else
                {
                    purLines = OrderingRepositories.PurLine.Get(orderId);
                }
                foreach (PurLine purLine in purLines)
                {
                    VendorProduct    vendorProduct;
                    Product          product;
                    JoinPlToVpToProd join;
                    if (purLine.VendorProductId.IsNull)
                    {
                        // Must have actual objects because some generated
                        // code calls methods of these inner objects.
                        vendorProduct = new VendorProduct();
                        product       = new Product();
                    }
                    else
                    {
                        vendorProduct = vendorProductDict[purLine.VendorProductId.Value];
                        product       = productDict[vendorProduct.ProductId.Value];
                    }
                    join = new JoinPlToVpToProd(purLine, vendorProduct, product);
                    join.SetExternalData(subCategories, brands, order);
                    venprodJoinList.Add(join);
                }
            }
            return(venprodJoinList);
        }
Beispiel #2
0
 public PurLine(PurLineId Id_,
                PurOrderId PurOrderId_,
                VendorProductId VendorProductId_,
                decimal CaseCostOverride_,
                decimal EachCostOverride_,
                bool OrderedEaches_,
                int QtyOrdered_,
                int QtyReceived_,
                int QtyBackordered_,
                int QtyDamaged_,
                int QtyMissing_,
                int QtyOnHand_,
                bool SpecialOrder_,
                string Notes_,
                string ProductName_,
                ProductSubCategoryId ProductSubCategoryId_,
                string Size_,
                decimal RetailPrice_,
                ProductBrandId ProductBrandId_,
                string ManufacturerBarcode_,
                string ManufacturerPartNum_,
                string ShelfOrder_,
                decimal RetailPriceOverride_,
                string VendorPartNum_,
                decimal CaseCost_,
                int CountInCase_,
                decimal EachCost_,
                bool PreferredSource_,
                bool WholeCasesOnly_,
                DateTime CreateDate_,
                DateTime ModifyDate_)
     : base(Id_, CreateDate_, ModifyDate_)
 {
     mPurOrderId           = PurOrderId_;
     mVendorProductId      = VendorProductId_;
     mCaseCostOverride     = CaseCostOverride_;
     mEachCostOverride     = EachCostOverride_;
     mOrderedEaches        = OrderedEaches_;
     mQtyOrdered           = QtyOrdered_;
     mQtyReceived          = QtyReceived_;
     mQtyBackordered       = QtyBackordered_;
     mQtyDamaged           = QtyDamaged_;
     mQtyMissing           = QtyMissing_;
     mQtyOnHand            = QtyOnHand_;
     mSpecialOrder         = SpecialOrder_;
     mNotes                = Notes_;
     mProductName          = ProductName_;
     mProductSubCategoryId = ProductSubCategoryId_;
     mSize                = Size_;
     mRetailPrice         = RetailPrice_;
     mProductBrandId      = ProductBrandId_;
     mManufacturerBarcode = ManufacturerBarcode_;
     mManufacturerPartNum = ManufacturerPartNum_;
     mShelfOrder          = ShelfOrder_;
     mRetailPriceOverride = RetailPriceOverride_;
     mVendorPartNum       = VendorPartNum_;
     mCaseCost            = CaseCost_;
     mCountInCase         = CountInCase_;
     mEachCost            = EachCost_;
     mPreferredSource     = PreferredSource_;
     mWholeCasesOnly      = WholeCasesOnly_;
 }