库存管理系统是一种用于管理企业库存的软件系统,它可以帮助企业实时掌握库存情况,提高库存管理效率。下面是一个简单的库存管理系统的源代码示例。
```python
class Product:
    def __init__(self, name, quantity):
        self.name = name
        self.quantity = quantity
class InventoryManagementSystem:
    def __init__(self):
        self.products = []
    def add_product(self, name, quantity):
        product = Product(name, quantity)
        self.products.append(product)
    def remove_product(self, name):
        for product in self.products:
            if product.name == name:
                self.products.remove(product)
                break
    def update_quantity(self, name, quantity):
        for product in self.products:
            if product.name == name:
                product.quantity = quantity
                break
    def get_product_quantity(self, name):
        for product in self.products:
            if product.name == name:
                return product.quantity
        return 0
    def print_inventory(self):
        for product in self.products:
            print(f"Product: {product.name}, Quantity: {product.quantity}")
# 示例用法
inventory_system = InventoryManagementSystem()
inventory_system.add_product("Apple", 10)
inventory_system.add_product("Banana", 5)
inventory_system.add_product("Orange", 3)
inventory_system.print_inventory()
# 输出:
# Product: Apple, Quantity: 10
# Product: Banana, Quantity: 5
# Product: Orange, Quantity: 3
inventory_system.update_quantity("Apple", 15)
inventory_system.remove_product("Banana")
inventory_system.print_inventory()
# 输出:
# Product: Apple, Quantity: 15
# Product: Orange, Quantity: 3
print(inventory_system.get_product_quantity("Apple"))
# 输出:15
print(inventory_system.get_product_quantity("Banana"))
# 输出:0
```
以上是一个简单的库存管理系统的源代码示例。它包含了一个`Product`类来表示产品,以及一个`InventoryManagementSystem`类来管理库存。通过调用相应的方法,可以实现添加产品、删除产品、更新产品数量以及获取产品数量等功能。这个系统可以帮助企业实时掌握库存情况,提高库存管理效率。当然,这只是一个简单的示例,实际的库存管理系统可能会更加复杂,需要根据具体需求进行扩展和优化。
点击右边的链接下载pdf文件:库存管理系统源代码.pdf
	
文章推荐: