Пример #1
0
from pprint import pprint
from DenRoze3_middleware import Reader_Writer, Stock, Bills, Users, Orders, sqlite_mode, Reader_Writer_json
from DenRoze3_models import Item, BillItem, Bill, DateCreator

stock = Stock()
bills = Bills()
orders = Orders()
users = Users()

if sqlite_mode:
    Reader_Writer.init()
    Reader_Writer.load_all(stock, bills, orders, users)
else:
    Reader_Writer_json.init()
    Reader_Writer_json.load_all(stock, bills, orders, users)

app_on = True
b = None
o = None
u = None
i = None

while (app_on):
    commands = []
    user_input = input()
    commands = user_input.split(' ')
    try:
        if (u == None):
            if (commands[0] == "login"):
                u = users.auth(commands[1], commands[2])
                continue
Пример #2
0
    def __init__(self):
        super(Ui,
              self).__init__()  # Call the inherited classes __init__ method
        # Program stuff
        self.stock = Stock()
        self.bills = Bills()
        self.orders = Orders()
        self.users = Users()

        if not sqlite_mode:
            Reader_Writer.init()
            Reader_Writer.load_all(self.stock, self.bills, self.orders,
                                   self.users)
        else:
            Reader_Writer_json.init()
            Reader_Writer_json.load_all(self.stock, self.bills, self.orders,
                                        self.users)

        self.b = None
        self.o = None
        self.u = None
        self.i = None
        # UIC loads
        uic.loadUi('gui.ui', self)
        uic.loadUi('login_widget.ui', self.login_widget)
        uic.loadUi('stock_widget.ui', self.stock_widget)
        uic.loadUi('bills_widget.ui', self.bills_widget)
        uic.loadUi('orders_widget.ui', self.orders_widget)
        # Fill lists
        self.get_stock_list()
        self.get_orders_list()
        self.get_bills_list()
        # List select binding
        self.stock_widget.stock_list.currentItemChanged.connect(
            self.stock_select)

        self.bills_widget.stock_list.currentItemChanged.connect(
            self.bill_stock_select)
        self.bills_widget.bills_list.currentItemChanged.connect(
            self.bill_select)
        self.bills_widget.bill_items_list.currentItemChanged.connect(
            self.bill_item_select)

        self.orders_widget.stock_list.currentItemChanged.connect(
            self.order_stock_select)
        self.orders_widget.orders_list.currentItemChanged.connect(
            self.order_select)
        self.orders_widget.order_items_list.currentItemChanged.connect(
            self.order_item_select)
        # Initial hide
        self.stock_widget.hide()
        self.bills_widget.hide()
        self.orders_widget.hide()
        self.menu_widget.hide()
        self.stock_button.setEnabled(False)
        self.bills_button.setEnabled(False)
        self.orders_button.setEnabled(False)
        # Menu buttons
        self.stock_button.clicked.connect(self.stock_menu)
        self.bills_button.clicked.connect(self.bill_menu)
        self.orders_button.clicked.connect(self.order_menu)
        self.write_button.clicked.connect(self.write)
        # Widget buttons
        self.login_widget.login_button.clicked.connect(self.login)

        self.stock_widget.stock_delete_button.clicked.connect(
            self.stock_delete)
        self.stock_widget.stock_add_button.clicked.connect(self.stock_new)
        self.stock_widget.stock_item_save_button.clicked.connect(
            self.stock_edit)

        self.bills_widget.bills_add_button.clicked.connect(self.bill_new)
        self.bills_widget.bills_delete_button.clicked.connect(self.bill_delete)
        self.bills_widget.bill_add_item_button.clicked.connect(
            self.bill_add_item)
        self.bills_widget.bill_remove_item_button.clicked.connect(
            self.bill_remove_item)
        self.bills_widget.bill_print_button.clicked.connect(self.bill_print)

        self.orders_widget.orders_add_button.clicked.connect(self.order_new)
        self.orders_widget.orders_delete_button.clicked.connect(
            self.order_delete)
        self.orders_widget.order_add_item_button.clicked.connect(
            self.order_add_item)
        self.orders_widget.order_remove_item_button.clicked.connect(
            self.order_remove_item)
        self.orders_widget.order_print_button.clicked.connect(self.order_print)
        # Show GUI
        self.show()