コード例 #1
0
        /// <summary>
        /// Gets all product inventory.
        /// </summary>
        /// <returns>Get All ProductInventory</returns>
        public List <ProductInventory> GetAllProductInventory()
        {
            IProductInventoryDAL    productInventoryDAL = new ProductInventoryDAL();
            List <ProductInventory> result = productInventoryDAL.GetAllProductInventory();

            return(result);
        }
コード例 #2
0
        public void createInvoice(Record document)
        {
            if (SafeUser != null && SafeUser.isLoggedIn())
            {
                try
                {
                    SqlHelper   helper = new SqlHelper();
                    SecurityDAL sdal   = new SecurityDAL(helper);
                    if (sdal.hasPermission(SafeUser.SignIN.UID, "UPDATE") &&
                        sdal.hasPermission(SafeUser.SignIN.UID, "DELETE"))
                    {
                        ProductInventoryDAL       piDAL = new ProductInventoryDAL(helper);
                        ProductDocumentDAL        pdDAL = new ProductDocumentDAL(helper);
                        ProductTypeDAL            ptDAL = new ProductTypeDAL(helper);
                        InventoryDocumentationDAL idDAL = new InventoryDocumentationDAL(helper);
                        ProductType type = ptDAL.getProductType(document.ProductType);
                        if (type == null)
                        {
                            ptDAL.addProductType(document.ProductType);
                            type = ptDAL.getProductType(document.ProductType);
                        }

                        ProductInventory product = piDAL.getProduct(document.ProductName, type.TID);
                        if (product != null && product.TotalQuantity - document.ProductQuantity >= 0)
                        {
                            product.TotalQuantity += document.ProductQuantity;
                            piDAL.updateProduct(product);
                        }
                        else
                        {
                            log(404, "No such product");
                            return;
                        }

                        ProductDocument delivery = new ProductDocument();
                        delivery.Name        = document.DocumentName;
                        delivery.PrID        = product.PrID;
                        delivery.Description = document.Description;
                        delivery.Quantity    = document.ProductQuantity;
                        pdDAL.addDocument(delivery);

                        delivery = pdDAL.getDocument(document.DocumentName, product.PrID,
                                                     document.ProductQuantity, document.Description);
                        idDAL.assignDocument(SafeUser.SignIN.UID, delivery.DocumentID);
                    }
                }catch (Exception ex)
                {
                    log(ex);
                }
            }
        }
コード例 #3
0
        public void GetAllProductInventory()
        {
            IProductInventoryDAL    dal    = new ProductInventoryDAL();
            List <ProductInventory> dummy  = this.GetDummyProductInventory();
            List <ProductInventory> actual = dal.GetAllProductInventory();

            for (int i = 0; i < dummy.Count; i++)
            {
                Assert.AreEqual(dummy[i].ProductInventoryID, actual[i].ProductInventoryID);
                Assert.AreEqual(dummy[i].Product, actual[i].Product);
                Assert.AreEqual(dummy[i].Inventory_Location, actual[i].Inventory_Location);
                Assert.AreEqual(dummy[i].Qty_Available, actual[i].Qty_Available);
            }
        }