示例#1
0
 def refresh(self):
     list_1, count_row = product_db.select_all()
     self.p_list.setRowCount(count_row)
     for i in range(0, count_row):
         self.p_list.setItem(
             i, 0,
             QtWidgets.QTableWidgetItem(str(list_1[i]["product_code"])))
         self.p_list.setItem(
             i, 1,
             QtWidgets.QTableWidgetItem(str(list_1[i]["product_name"])))
         self.p_list.setItem(
             i, 2,
             QtWidgets.QTableWidgetItem(str(list_1[i]["product_category"])))
         self.p_list.setItem(
             i, 3,
             QtWidgets.QTableWidgetItem(str(list_1[i]["product_image"])))
         self.p_list.setItem(
             i, 4,
             QtWidgets.QTableWidgetItem(str(list_1[i]["product_brand"])))
         self.p_list.setItem(
             i, 5,
             QtWidgets.QTableWidgetItem(str(list_1[i]["product_price"])))
         self.p_list.setItem(
             i, 6,
             QtWidgets.QTableWidgetItem(str(list_1[i]["product_detail"])))
         self.p_list.setItem(i, 7, QtWidgets.QTableWidgetItem("Edit"))
         self.p_list.setItem(i, 8, QtWidgets.QTableWidgetItem("Delete"))
示例#2
0
    def refresh(self):
        """ Refresh method """
        # Refresh product table list
        while (self.product_list.rowCount() > 0):
            self.product_list.removeRow(0)

        self.product_list_db, self.product_amount_entry = product_db.select_all(
        )
        for i in range(self.product_amount_entry):
            self.product_list.insertRow(i)
        self.load_product_from_db()

        # Refresh employee table list
        self.employee_list, self.employee_amount_entry = employee_db.select_all(
        )
        self.employee_value.setCurrentItem(self.employee_value.item(0))
        for i in range(self.employee_amount_entry, 0, -1):
            self.employee_value.takeItem(i)

        for j in range(self.employee_amount_entry):
            self.employee_value.addItem(self.employee_list[j]["employee_name"])

        # Refresh customer table list
        self.customer_list, self.customer_amount_entry = customer_db.select_all(
        )
        self.customer_value.setCurrentItem(self.customer_value.item(0))
        for i in range(self.customer_amount_entry, 0, -1):
            # self.customer_value.takeItem(self.customer_value.currentRow())
            self.customer_value.takeItem(i)

        # self.customer_value.clear()
        # self.customer_value.takeItem(self.customer_value.currentItem())

        for j in range(self.customer_amount_entry):
            self.customer_value.addItem(self.customer_list[j]["customer_name"])
示例#3
0
    def init_ui(self):
        self.button = QtWidgets.QPushButton('Refresh', self)
        self.button.move(700, 1)
        self.button.clicked.connect(self.refresh)

        list_1, count_row = product_db.select_all()
        self.p_list = QtWidgets.QTableWidget(self)
        self.p_list.move(1, 25)
        self.p_list.resize(800, 600)
        self.p_list.setRowCount(count_row)
        self.p_list.setColumnCount(9)
        self.p_list.setHorizontalHeaderLabels([
            "Code", "Name", "Category", "Image", "Brand", "Price", "Detail",
            "", ""
        ])
        self.p_list.verticalHeader().hide()
        self.p_list.setColumnWidth(0, 50)
        self.p_list.setColumnWidth(1, 120)
        self.p_list.setColumnWidth(2, 200)
        self.p_list.setColumnWidth(3, 100)
        self.p_list.setColumnWidth(4, 50)
        self.p_list.setColumnWidth(5, 80)
        self.p_list.setColumnWidth(6, 80)
        self.p_list.setColumnWidth(7, 50)
        self.p_list.setColumnWidth(8, 50)
        self.p_list.setEditTriggers(QtWidgets.QTableWidget.NoEditTriggers)
        self.p_list.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection)
        for i in range(0, count_row):
            self.p_list.setItem(
                i, 0,
                QtWidgets.QTableWidgetItem(str(list_1[i]["product_code"])))
            self.p_list.setItem(
                i, 1,
                QtWidgets.QTableWidgetItem(str(list_1[i]["product_name"])))
            self.p_list.setItem(
                i, 2,
                QtWidgets.QTableWidgetItem(str(list_1[i]["product_category"])))
            self.p_list.setItem(
                i, 3,
                QtWidgets.QTableWidgetItem(str(list_1[i]["product_image"])))
            self.p_list.setItem(
                i, 4,
                QtWidgets.QTableWidgetItem(str(list_1[i]["product_brand"])))
            self.p_list.setItem(
                i, 5,
                QtWidgets.QTableWidgetItem(str(list_1[i]["product_price"])))
            self.p_list.setItem(
                i, 6,
                QtWidgets.QTableWidgetItem(str(list_1[i]["product_detail"])))
            self.p_list.setItem(i, 7, QtWidgets.QTableWidgetItem("Edit"))
            self.p_list.setItem(i, 8, QtWidgets.QTableWidgetItem("Delete"))
        self.p_list.cellClicked.connect(self.modify)
示例#4
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.title = "Quản lý bán hàng"
        self.width = 1050
        self.height = 600
        self.amount_of_products = 0  # this variable is used for counting the number of purchased item
        self.discount_percentage = 0
        self.total_cost = None
        self.discount_cost = None
        self.already_added_row = []
        self.bill = None
        self.bill_detail = None
        self.bill_info = None
        self.bill_detail_info = None
        self.product_list_db, self.product_amount_entry = product_db.select_all(
        )  # get the product list from database
        self.warehouse_list_db, self.warehouse_amount_entry = warehouse_db.select_all(
        )

        # Pre-initialize gui variables *
        # Buttons **
        self.search_btn = None
        self.add_product_btn = None
        self.add_tab_btn = None
        self.charge_btn = None
        # Labels & Combobox **
        self.total_price = None
        self.total_price_value = None
        self.discount = None
        self.discount_value = None
        self.actual_money = None
        self.actual_money_value = None
        self.payed_money = None
        self.payed_money_value = None
        self.change_money = None
        self.change_money_value = None
        # Edit box
        self.search_box = None
        # Table
        self.purchased_list = None
        self.product_list = None

        self.init_ui()
        self.show()
示例#5
0
    def init_ui(self):
        # self.button = QtWidgets.QPushButton('Refresh',self)
        # self.button.move(600, 1)
        # self.button.clicked.connect(self.refresh)

        self.button = QtWidgets.QPushButton('Export CSV', self)
        self.button.move(700, 1)
        self.button.clicked.connect(self.export)

        list_1, count_row = product_db.select_all()
        self.p_list = QtWidgets.QTableWidget(self)
        self.p_list.move(1, 25)
        self.p_list.resize(800, 400)
        self.p_list.setStyleSheet('background-color:white')
        self.p_list.setRowCount(count_row)
        self.p_list.setColumnCount(9)
        self.p_list.setHorizontalHeaderLabels([
            "Code", "Name", "Category", "Image", "Brand", "Price", "Detail",
            "", ""
        ])
        ############
        item0 = QtWidgets.QTableWidgetItem("Code")
        item0.setBackground(QtGui.QColor(0, 255, 0))
        self.p_list.setHorizontalHeaderItem(0, item0)
        item1 = QtWidgets.QTableWidgetItem("Name")
        item1.setBackground(QtGui.QColor(0, 255, 0))
        self.p_list.setHorizontalHeaderItem(1, item1)
        item2 = QtWidgets.QTableWidgetItem("Category")
        item2.setBackground(QtGui.QColor(0, 255, 0))
        self.p_list.setHorizontalHeaderItem(2, item2)
        item3 = QtWidgets.QTableWidgetItem("Image")
        item3.setBackground(QtGui.QColor(0, 255, 0))
        self.p_list.setHorizontalHeaderItem(3, item3)
        item4 = QtWidgets.QTableWidgetItem("Brand")
        item4.setBackground(QtGui.QColor(0, 255, 0))
        self.p_list.setHorizontalHeaderItem(4, item4)
        item5 = QtWidgets.QTableWidgetItem("Price")
        item5.setBackground(QtGui.QColor(0, 255, 0))
        self.p_list.setHorizontalHeaderItem(5, item5)
        item6 = QtWidgets.QTableWidgetItem("Detail")
        item6.setBackground(QtGui.QColor(0, 255, 0))
        self.p_list.setHorizontalHeaderItem(6, item6)
        ############
        self.p_list.verticalHeader().hide()
        self.p_list.setColumnWidth(0, 50)
        self.p_list.setColumnWidth(1, 120)
        self.p_list.setColumnWidth(2, 200)
        self.p_list.setColumnWidth(3, 100)
        self.p_list.setColumnWidth(4, 50)
        self.p_list.setColumnWidth(5, 80)
        self.p_list.setColumnWidth(6, 80)
        self.p_list.setColumnWidth(7, 50)
        self.p_list.setColumnWidth(8, 50)
        self.p_list.setEditTriggers(QtWidgets.QTableWidget.NoEditTriggers)
        self.p_list.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection)
        for i in range(0, count_row):
            self.p_list.setItem(
                i, 0,
                QtWidgets.QTableWidgetItem(str(list_1[i]["product_code"])))
            self.p_list.setItem(
                i, 1,
                QtWidgets.QTableWidgetItem(str(list_1[i]["product_name"])))
            self.p_list.setItem(
                i, 2,
                QtWidgets.QTableWidgetItem(str(list_1[i]["product_category"])))
            self.p_list.setItem(
                i, 3,
                QtWidgets.QTableWidgetItem(str(list_1[i]["product_image"])))
            self.p_list.setItem(
                i, 4,
                QtWidgets.QTableWidgetItem(str(list_1[i]["product_brand"])))
            self.p_list.setItem(
                i, 5,
                QtWidgets.QTableWidgetItem(str(list_1[i]["product_price"])))
            self.p_list.setItem(
                i, 6,
                QtWidgets.QTableWidgetItem(str(list_1[i]["product_detail"])))
            self.p_list.setItem(i, 7, QtWidgets.QTableWidgetItem("Edit"))
            self.p_list.setItem(i, 8, QtWidgets.QTableWidgetItem("Delete"))
        self.p_list.cellClicked.connect(self.modify)

        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.refresh)
        self.timer.start(1000)
示例#6
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.title = "Quản lý bán hàng"
        self.setStyleSheet('background-color:#1effff')
        self.width = 1050
        self.height = 600
        # self.amount_of_products = 0  # this variable is used for counting the number of purchased item
        self.discount_percentage = 0
        self.total_cost = None
        self.discount_cost = None
        self.already_added_row = []
        self.bill = None
        self.bill_detail = None
        self.bill_info = None
        self.bill_detail_info = None
        self.employee_code = None
        self.customer_code = None
        self.product_list_db, self.product_amount_entry = product_db.select_all(
        )  # get the product list from database
        self.product_name_list = [
            self.product_list_db[member]["product_name"]
            for member in range(self.product_amount_entry)
        ]
        self.warehouse_list_db, self.warehouse_amount_entry = warehouse_db.select_all(
        )
        self.customer_list, self.customer_amount_entry = customer_db.select_all(
        )
        self.employee_list, self.employee_amount_entry = employee_db.select_all(
        )

        # Pre-initialize gui variables *
        # Buttons **
        self.search_btn = None
        self.add_product_btn = None
        self.add_tab_btn = None
        self.charge_btn = None
        # Labels & Combobox **
        self.total_price = None
        self.total_price_value = None
        self.discount = None
        self.discount_value = None
        self.actual_money = None
        self.actual_money_value = None
        self.payed_money = None
        self.payed_money_value = None
        self.change_money = None
        self.change_money_value = None

        # Edit box
        self.search_box = None  # search box
        self.model = QtCore.QStringListModel(self)
        self.model.setStringList([
            self.product_list_db[member]["product_name"]
            for member in range(self.product_amount_entry)
        ])
        # print(self.model.stringList())
        self.completer = QtWidgets.QCompleter(self)
        self.completer.setModel(self.model)

        # Table
        self.purchased_list = None
        self.product_list = None

        self.init_ui()
        self.show()