Ejemplo n.º 1
0
 def show_targrt(self):
     try:
         Nclients = str(cursor2.execute(f'SELECT clients_numbers FROM users_rates WHERE user_name = "{self.global_user_name}" AND date = "{date.today()}" ').fetchone()[0])
         self.label_22.setText(Nclients.zfill(3))
     except TypeError:
         check_rates_existant(self.global_user_name)
         self.show_targrt()
Ejemplo n.º 2
0
    def check(self):
        admin_exe = c.execute(
            "SELECT User_Name, Password FROM users").fetchone()
        users_exe = c.execute(
            "SELECT User_Name, Password FROM users").fetchall()
        users_name_exe = [
            i[0] for i in c.execute("SELECT User_Name FROM users").fetchall()
        ]
        if (self.lineEdit.text(), self.lineEdit_2.text()) in users_exe:
            if (self.lineEdit.text(), self.lineEdit_2.text()) == admin_exe:
                self.open_admin_page()

            else:
                check_TDtable_existant()
                check_rates_existant(self.lineEdit.text())
                self.open_user_page()

        else:
            if self.lineEdit.text() in users_name_exe:
                msg = QMessageBox.information(self, 'Informative Message',
                                              'Uncorrect Password.',
                                              QMessageBox.Ok)
            else:
                msg = QMessageBox.information(
                    self, 'Informative Message',
                    'Sorry, This user can\'t be found.', QMessageBox.Yes)
Ejemplo n.º 3
0
    def submit_3(self, counter, timer, time_edit ,groupbox, radios, password_input, food_list, products_list, products_prices_list, price_label, buttons):
        if (not timer.isActive()):
            try : 
                user_name = self.global_user_name
                user_password = cursor.execute(f'SELECT Password FROM Users WHERE User_Name = "{user_name}" ').fetchone()[0]
                singleHour = float(cursor.execute(f'SELECT "Price/Hour" FROM "Consoles and Screens" WHERE Name = "{groupbox.title()}" ').fetchone()[0])
                controllerHour = float(cursor.execute(f'SELECT "Controller price/hour" FROM "Consoles and Screens" WHERE Name = "{groupbox.title()}" ').fetchone()[0])
                if radios[0].isChecked():
                    HoursType = "Signle"
                    PricePerHour = singleHour
                elif radios[1].isChecked():
                    HoursType = "Multi 1"
                    PricePerHour = singleHour + controllerHour
                elif radios[2].isChecked():
                    HoursType = "Multi 2"
                    PricePerHour = singleHour + (2*controllerHour)
                
                if password_input.text() == user_password:
    # Setting "itmes:count" to be put in the list with the correct form
                    products_list = collections.Counter(products_list)
                    products_list = [f"{i}:{products_list[i]}" for i in products_list.keys()]

    # Setting variables that will sent to the table
                    device = groupbox.title()
                    start_time =( datetime.now() - timedelta(minutes= counter) ).time().strftime("%I:%M %p")
                    end_time = datetime.now().time().strftime("%I:%M %p")
                    total_foods_prices = 0
                    total_hours_prices = counter * (PricePerHour/60)
                    food_list_items = " / ".join(products_list)
                    
    # Getting the price for each item in the ListWidget & and all the prices to the "total_foods_prices"
    # Setting the "total_prices" variable
                    for i in range(food_list.count()):
                        products_prices_list.append(cursor.execute(f'''
                        SELECT "Price" FROM Foods WHERE "Name" = "{food_list.item(i).text()}" 
                        ''').fetchone()[0])
                    for i in products_prices_list:
                        total_foods_prices += i

                    total_prices = (total_foods_prices + total_hours_prices)

    # Sending the data to the table
                  
                # Insert data into yields
                    cursor2.execute(f'''
                    INSERT INTO "{date.today()}" VALUES ("{user_name}", "{device}", "{HoursType}", "{start_time}", "{end_time}", "{f'{counter} ' + 'Minutes' }", {round(total_hours_prices)}, "{food_list_items}", {total_foods_prices}, {round(total_prices)});
                    ''')
                    conn2.commit()
                # Update clients numbers for this user
                    current_numbers_of_clients = cursor2.execute(f'SELECT clients_numbers FROM users_rates WHERE user_name = "{user_name}" AND date = "{date.today()}" ').fetchone()[0] 
                    cursor2.execute(f'UPDATE users_rates SET clients_numbers = {current_numbers_of_clients+1} WHERE user_name = "{user_name}" ')
                    conn2.commit()
                    self.show_targrt()

                    price_label.setText(f"Required Paid is only {round(total_prices)} EG")
                    price_label.setStyleSheet("background-color: green; color: white;")
                    QTimer.singleShot(30000,lambda : price_label.setStyleSheet("background-color: none; color:#f0f0f0;") )

                

# Cleaning the form to start another operation

                    #@@@@@@@@@@@@@@@@
                    self.Mcounter_3 = 0
                    self.is_open_3 = False
                    #@@@@@@@@@@@@@@@@
                    products_prices_list.clear()
                    products_list.clear()
                    password_input.setText("")
                    food_list.clear()
                    time_edit.setEnabled(True)
                    time_edit.setTime(time(0,0))
                    time_edit.setReadOnly(False)
                    buttons[1].setEnabled(True)
                    buttons[0].setEnabled(True)
                    radios[0].setChecked(True)
                

                else :
                    # msg = QMessageBox.warning(self, 'Ucorrect Data', 'Uncorrect Password! Maybe caps lock is turned on ??', QMessageBox.Ok)
                    price_label.setText('Uncorrect password')
                    price_label.setStyleSheet("background-color: red; color: white;")
                    QTimer.singleShot(3000,lambda : price_label.setStyleSheet("background-color: none; color:#f0f0f0;") )
                    password_input.setText("")
                    pass

            except ValueError:
                price_label.setText('Unrecoginzed Prices for this device')
                price_label.setStyleSheet("background-color: black; color: white;")
                QTimer.singleShot(3000,lambda : price_label.setStyleSheet("background-color: none; color:#f0f0f0;") )

            except sqlite3.OperationalError :
                check_rates_existant(self.global_user_name)
                check_TDtable_existant()
                #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                self.submit_3(self.Mcounter_3 ,self.timer_3, self.timeEdit_3, self.groupBox_3,
                    [self.single_radioBttn_3, self.multi1_radioBttn_3, self.multi2_radioBttn_3], self.lineEdit_3, self.listWidget_3, 
                    self.products_list_3, self.products_prices_list_3, self.label_3, [self.start_time_bttn_3, self.start_open_time_bttn_3])
                #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

                
        else:
            price_label.setText('Timer is running')
            price_label.setStyleSheet("background-color: blue; color: white;")
            QTimer.singleShot(3000,lambda : price_label.setStyleSheet("background-color: none; color:#f0f0f0;") )
            pass