知識百科
進銷存系統源代碼
2022/9/18 11:22:48 來源:企業管理軟件公司
內容摘要:進銷存系統源代碼
進銷存系統是一種用于管理企業庫存、銷售和采購等業務的軟件系統。它可以幫助企業實現對產品的準確跟蹤和管理,提高庫存管理的效率和準確性。下面是一個簡單的進銷存系統的源代碼示例。```python
# 導入所需的庫
import datetime
# 定義產品類
class Product:
def __init__(self, name, price, quantity):
self.name = name
self.price = price
self.quantity = quantity
# 定義進銷存系統類
class InventorySystem:
def __init__(self):
self.products = []
# 添加產品
def add_product(self, product):
self.products.append(product)
# 銷售產品
def sell_product(self, product_name, quantity):
for product in self.products:
if product.name == product_name:
if product.quantity >= quantity:
product.quantity -= quantity
print(f"成功銷售{quantity}個{product_name}")
else:
print(f"{product_name}庫存不足")
return
print(f"找不到產品{product_name}")
# 采購產品
def purchase_product(self, product_name, quantity):
for product in self.products:
if product.name == product_name:
product.quantity += quantity
print(f"成功采購{quantity}個{product_name}")
return
new_product = Product(product_name, 0, quantity)
self.products.append(new_product)
print(f"成功采購{quantity}個{product_name}")
# 顯示庫存
def display_inventory(self):
print("當前庫存:")
for product in self.products:
print(f"{product.name}: {product.quantity}")
# 創建進銷存系統實例
inventory_system = InventorySystem()
# 添加產品
product1 = Product("手機", 2000, 10)
product2 = Product("電腦", 5000, 5)
inventory_system.add_product(product1)
inventory_system.add_product(product2)
# 銷售產品
inventory_system.sell_product("手機", 3)
# 采購產品
inventory_system.purchase_product("電腦", 2)
# 顯示庫存
inventory_system.display_inventory()
```
以上是一個簡單的進銷存系統的源代碼示例。通過這個系統,企業可以方便地管理產品的庫存、銷售和采購等業務,提高了庫存管理的效率和準確性。當然,這只是一個簡單的示例,實際的進銷存系統可能會更加復雜和完善。
免責聲明:本文章部分圖片素材和內容素材來源于網絡,僅供學習與參考,不代表本站立場,如果損害了您的權利,請聯系網站客服,我們核實后會立即刪除。