Beispiel #1
0
    def remove_user(self, user):

        if user == '':
            self.notify.add_widget(
                Label(text='[color=#FF0000[b]All Fields Required[/b]'
                      '[/color]',
                      markup=True))
            self.notify.open()
            Clock.schedule_once(self.killswitch, 1)
        else:
            target_user = self.users.find_one({'user_name': user})
            if target_user == None:
                self.notify.add_widget(
                    Label(text='[color=#FF0000[b]Invalid Username[/b]'
                          '[/color]',
                          markup=True))
                self.notify.open()
                Clock.schedule_once(self.killswitch, 1)
            else:
                content = self.ids.scrn_contents
                content.clear_widgets()
                # self.users.remove({'user_name:user})

        sql = 'DELETE FROM users WHERE user_name=%s'
        values = [user]
        self.mycursor.execute(sql, values)
        self.mydb.commit()

        users = self.get_users()
        userstable = DataTable(table=users)
        content.add_widget(userstable)
Beispiel #2
0
 def remove_product(self, code):
     if code == '':
         self.notify.add_widget(
             Label(
                 text=
                 '[color=#FF0000][b]Product Code Field Required[/b][/color]',
                 markup=True))
         self.notify.open()
         Clock.schedule_once(self.kill_switch, 1)
     else:
         code = self.db.search_register(
             'product_code',
             'STOCKS',
             where="product_code='%s'".format(code))
         code = code[0]
         if code is None:
             self.notify.add_widget(
                 Label(
                     text='[color=#FF0000][b]Invalid UserName[/b][/color]',
                     markup=True))
             self.notify.open()
             Clock.schedule_once(self.kill_switch, 1)
         else:
             content = self.ids.scrn_product_contents
             content.clear_widgets()
             self.db.delete_register(
                 'STOCKS', where="product_code = '{}'".format(code))
             products = self.get_products()
             prod_table = DataTable(table=products)
             content.add_widget(prod_table)
Beispiel #3
0
 def remove_user(self, user):
     if user == '':
         self.notify.add_widget(
             Label(text='[color=#FF0000][b]User Field Required[/b][/color]',
                   markup=True))
         self.notify.open()
         Clock.schedule_once(self.kill_switch, 1)
     else:
         user = self.db.search_register(
             'user_names', 'USERS', where="user_names='%s'".format(user))
         user = user[0]
         if user is None:
             self.notify.add_widget(
                 Label(
                     text='[color=#FF0000][b]Invalid UserName[/b][/color]',
                     markup=True))
             self.notify.open()
             Clock.schedule_once(self.kill_switch, 1)
         else:
             content = self.ids.scrn_contents
             content.clear_widgets()
             self.db.delete_register('USERS',
                                     where="user_names = '{}'".format(user))
             users = self.get_users()
             userstable = DataTable(table=users)
             content.add_widget(userstable)
Beispiel #4
0
    def remove_product(self, code):

        if code == '':
            self.notify.add_widget(
                Label(text='[color=#FF0000[b]All Fields Required[/b]'
                      '[/color]',
                      markup=True))
            self.notify.open()
            Clock.schedule_once(self.killswitch, 1)
        else:
            target_code = self.products.find_one({'product_code': code})
            if target_code == None:
                self.notify.add_widget(
                    Label(text='[color=#FF0000[b]Invalid Code[/b]'
                          '[/color]',
                          markup=True))
                self.notify.open()
                Clock.schedule_once(self.killswitch, 1)
            else:
                content = self.ids.scrn_contents
                content.clear_widgets()
                # self.products.remove({'product_code': code})

        sql = 'DELETE FROM stocks WHERE product_code=%s'
        values = [code]
        self.mycursor.execute(sql, values)
        self.mydb.commit()

        prodz = self.get_products()
        stocktable = DataTable(table=prodz)
        content.add_widget(stocktable)
Beispiel #5
0
    def add_product(self, code, name, weight, stock, sold, order, purchase):

        sql = 'INSERT INTO stocks(code, name, weight, stock, sold, order,' \
              ' purchase) VALUES(%s,%s,%s,%s,%s,%s,%s)'
        values = [code, name, weight, stock, sold, order,
                  purchase]  # [datetime.now()]#

        if code == '' or name == '' or weight == '' or stock == '' or order == '':
            self.notify.add_widget(
                Label(text='[color=#FF0000[b]All Fields Required[/b]'
                      '[/color]',
                      markup=True))
            self.notify.open()
            Clock.schedule_once(self.killswitch, 1)
        else:
            self.products.insert_one({
                'product_code': code,
                'product_name': name,
                'product_weight': weight,
                'in_stock': stock,
                'sold': sold,
                'order': order,
                'last_purchase': purchase
            })

        content = self.ids.scrn_products_contents
        content.clear_widgets()

        self.mycursor.execute(sql, values)
        self.mydb.commit()

        prodz = self.get_products()
        stocktable = DataTable(table=prodz)
        content.add_widget(stocktable)
Beispiel #6
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        self.notify = Notify()

        # Connection with DB
        self.db = ClientDB(database_dir)

        # Display Users
        content = self.ids.scrn_contents
        users = self.get_users()
        userstable = DataTable(table=users)
        content.add_widget(userstable)

        # Display Products
        product_scrn = self.ids.scrn_product_contents
        products = self.get_products()
        prod_table = DataTable(table=products)
        product_scrn.add_widget(prod_table)
Beispiel #7
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.mydb = mysql.connector.connect(host='localhost',
                                            user='******',
                                            passwd='Livingstone2#',
                                            database='pos')
        self.mycursor = self.mydb.cursor()
        self.products = self.get_products()
        #self.notify = Notify()

        product_code = []
        product_name = []
        spinvals = []
        in_stock = []
        '''sql = 'SELECT *FROM stocks'
        self.mycursor.execute(sql)
        self.products = self.mycursor.fetchall()'''
        for product in self.products:
            product_code.append(product[0])
            name = product[1]
            if len(name) > 30:
                name = name[:30] + '...'
            product_name.append(name)

        for x in range(len(product_code)):
            line = '|'.join([product_code[x], product_name[x]])
            spinvals.append(line)
        self.ids.target_product.values = spinvals

        # print(self.get_products())
        content = self.ids.scrn_contents
        users = self.get_users()
        userstable = DataTable(table=users)
        content.add_widget(userstable)

        # Display Products
        product_scrn = self.ids.scrn_product_contents
        products = self.get_products()
        prod_table = DataTable(table=products)
        product_scrn.add_widget(prod_table)
Beispiel #8
0
    def update_user(self, first, last, user, pwd):
        pwd = hashlib.sha3_512(pwd.encode()).hexdigest()

        if user == '':
            self.notify.add_widget(
                Label(text='[color=#FF0000][b]User Field Required[/b][/color]',
                      markup=True))
            self.notify.open()
            Clock.schedule_once(self.kill_switch, 1)
        else:
            user = self.db.search_register('user_names',
                                           'USERS',
                                           where="user_names='%s'" % user)
            user = user[0]
            if user is None:
                self.notify.add_widget(
                    Label(
                        text='[color=#FF0000][b]Invalid Username[/b][/color]',
                        markup=True))
                self.notify.open()
                Clock.schedule_once(self.kill_switch, 1)
            else:
                if first == '':
                    first = self.db.search_register('first_names',
                                                    'USERS',
                                                    where="user_names='%s'" %
                                                    user)
                    first = first[0]
                if last == '':
                    last = self.db.search_register('last_names',
                                                   'USERS',
                                                   where="user_names='%s'" %
                                                   user)
                    last = last[0]
                if pwd == '':
                    pwd = self.db.search_register('passwords',
                                                  'USERS',
                                                  where="user_names='%s'" %
                                                  user)
                    pwd = pwd[0]

                update = "first_names = '{}', last_names = '{}', user_names =  '{}', passwords = '{}'".format(
                    first, last, user, pwd)
                content = self.ids.scrn_contents
                content.clear_widgets()
                self.db.update_register('USERS',
                                        update,
                                        where="user_names = '{}'".format(user))

                users = self.get_users()
                userstable = DataTable(table=users)
                content.add_widget(userstable)
Beispiel #9
0
    def update_product(self, code, name, weight, qty):
        if code == '':
            self.notify.add_widget(
                Label(
                    text=
                    '[color=#FF0000][b]Product Code Field Required[/b][/color]',
                    markup=True))
            self.notify.open()
            Clock.schedule_once(self.kill_switch, 1)
        else:
            code = self.db.search_register('product_code',
                                           'STOCKS',
                                           where="product_code='%s'" % code)
            code = code[0]
            if code is None:
                self.notify.add_widget(
                    Label(text=
                          '[color=#FF0000][b]Invalid Product Code[/b][/color]',
                          markup=True))
                self.notify.open()
                Clock.schedule_once(self.kill_switch, 1)
            else:
                if name == '':
                    name = self.db.search_register('product_name',
                                                   'STOCKS',
                                                   where="product_code='%s'" %
                                                   code)
                    name = name[0]
                if weight == '':
                    weight = self.db.search_register(
                        'product_weight',
                        'STOCKS',
                        where="product_code='%s'" % code)
                    weight = weight[0]
                if qty == '':
                    qty = self.db.search_register('qty_stock',
                                                  'STOCKS',
                                                  where="product_code='%s'" %
                                                  code)
                    qty = qty[0]
                content = self.ids.scrn_product_contents
                content.clear_widgets()

                update = "product_code = '{}', product_name = '{}', product_weight = '{}', qty_stock = '{}'".format(
                    code, name, weight, qty)
                self.db.update_register(
                    'STOCKS', update, where="product_code = '{}'".format(code))

                products = self.get_products()
                prod_table = DataTable(table=products)
                content.add_widget(prod_table)
Beispiel #10
0
    def update_user(self, first, last, user, pwd, des):

        pwd = hashlib.sha256(pwd.encode()).hexdigest()

        sql = 'UPDATE users SET first_name=%s,last_name=%s,user_name=%s,password=%s,designation=%s,'
        'WHERE user_name =%s'
        if user == '':
            self.notify.add_widget(
                Label(text='[color=#FF0000[b]All Fields Required[/b]'
                      '[/color]',
                      markup=True))
            self.notify.open()
            Clock.schedule_once(self.killswitch, 1)
        else:
            user = self.users.find_one({'user_name': user})
            if user == None:
                self.notify.add_widget(
                    Label(text='[color=#FF0000[b]Invalid Username[/b]'
                          '[/color]',
                          markup=True))
                self.notify.open()
                Clock.schedule_once(self.killswitch, 1)
            else:
                if first == '':
                    first = user['first_name']
                if last == '':
                    last = user['last_name']
                if pwd == '':
                    pwd = user['password']

                content = self.ids.scrn_contents
                content.clear_widgets()

        values = [first, last, user, pwd, des]

        self.mycursor.execute(sql, values)
        self.mydb.commit()

        users = self.get_users()
        userstable = DataTable(table=users)
        content.add_widget(userstable)
Beispiel #11
0
 def add_user(self, first, last, user, pwd):
     pwd = hashlib.sha3_512(pwd.encode()).hexdigest()
     if first == '' or last == '' or user == '' or pwd == '':
         self.notify.add_widget(
             Label(text='[color=#FF0000][b]All Fields Required[/b][/color]',
                   markup=True))
         self.notify.open()
         Clock.schedule_once(self.kill_switch, 1)
     else:
         self.db.input_register(
             'USERS', {
                 'first_names': first,
                 'last_names': last,
                 'user_names': user,
                 'passwords': pwd
             })
         content = self.ids.scrn_contents
         content.clear_widgets()
         users = self.get_users()
         userstable = DataTable(table=users)
         content.add_widget(userstable)
Beispiel #12
0
    def add_product(self, code, name, weight, qty):
        if code == '' or name == '' or weight == '' or qty == '':
            self.notify.add_widget(
                Label(text='[color=#FF0000][b]All Fields Required[/b][/color]',
                      markup=True))
            self.notify.open()
            Clock.schedule_once(self.kill_switch, 1)
        else:
            self.db.input_register(
                'STOCKS', {
                    'product_code': code,
                    'product_name': name,
                    'product_weight': weight,
                    'qty_stock': qty
                })
            content = self.ids.scrn_product_contents
            content.clear_widgets()

            products = self.get_products()
            prod_table = DataTable(table=products)
            content.add_widget(prod_table)
Beispiel #13
0
    def add_user(self, first, last, user, pwd, des):

        content = self.ids.scrn_contents
        content.clear_widgets()

        sql = 'INSERT INTO users(first_name,last_name,user_name,password,designation,'
        'date) VALUES(%s,%s,%s,%s,%s,%s)'
        values = [first, last, user, pwd, des, datetime.now()]
        '''if first == '' or last == '' or user == '' or pwd == '':
            self.notify.add_widget(Label(text='[color=#FF0000[b]All Fields Required[/b]'
            '[/color]', markup=True))
            self.notify.open()
            Clock.schedule_once(self.killswitch, 1)
        else:
            values = [first, last, user, pwd, des, datetime.now()]

            content = self.ids.scrn_contents'''

        self.mycursor.execute(sql, values)
        self.mydb.commit()

        users = self.get_users()
        userstable = DataTable(table=users)
        content.add_widget(userstable)
Beispiel #14
0
    def update_product(self,
                       code,
                       name,
                       weight,
                       stock,
                       sold,
                       order,
                       purchase,
                       pwd=None):

        pwd = hashlib.sha256(pwd.encode()).hexdigest()

        sql = 'UPDATE stocks SET product_code=%s, product_name=%s, ' \
              'product_weight=%s,sold_items, order_date, last_purchase'

        'WHERE product_code =%s'

        if code == '':
            self.notify.add_widget(
                Label(text='[color=#FF0000[b]Code required[/b]'
                      '[/color]',
                      markup=True))
            self.notify.open()
            Clock.schedule_once(self.killswitch, 1)
        else:
            target_code = self.products.find_one({'product_code': code})
            if target_code == None:
                self.notify.add_widget(
                    Label(text='[color=#FF0000[b]Invalid Code[/b]'
                          '[/color]',
                          markup=True))
                self.notify.open()
                Clock.schedule_once(self.killswitch, 1)
            else:
                if name == '':
                    name = target_code['product_name']
                if weight == '':
                    weight = target_code['product_weight']
                if stock == '':
                    stock = target_code['in_stock']
                if sold == '':
                    sold = target_code['sold_item']
                if order == '':
                    order = target_code['order_date']
                if purchase == '':
                    purchase = target_code['last_purchase']

                content = self.ids.scrn_contents
                content.clear_widgets()

                self.add_products.update_one({'product_code': code}, {
                    '$set': {
                        'product_code': code,
                        'product_name': name,
                        'product_weight': weight,
                        'in_stock': stock,
                        'sold': sold,
                        'order': order,
                        'last_purchase': purchase
                    }
                })
                '''self.products.update_one({'product_code': code, 'product_name': name,
                                          'product_weight': weight, 'in_stock': stock, 
                                          'sold': sold, 'order': order,
                                          'last_purchase': purchase})'''

        values = [code, name, weight, stock, sold, order, purchase]

        self.mycursor.execute(sql, values)
        self.mydb.commit()

        prodz = self.get_products()
        stocktable = DataTable(table=prodz)
        content.add_widget(stocktable)