def __init__(self, **kwargs): super().__init__(**kwargs) client = MongoClient() db = client.silverpos self.users = db.users self.products = db.stocks product_code = [] product_name = [] spinvals = [] for product in self.products.find(): product_code.append(product['product_code']) name = product['product_name'] 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 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)
def __init__(self, **kwargs): super().__init__(**kwargs) client = MongoClient() db = client.silverpos self.users = db.users self.products = db.stocks # stb = { # 'TH0':{0:'St0',1:'Sample1',2:'Sample2',3:'Sample4'}, # 'TH1':{0:'Stm0',1:'Sample1',2:'Sample2',3:'Sample4'}, # 'TH2':{0:'Stmp0',1:'Sampled1.0',2:'Sampled2.0',3:'Sampled4.0'}, # 'TH3':{0:'Stmpl0',1:'Sample1',2:'Sample2',3:'Sample4'}, # 'TH4':{0:'Stmple0',1:'Sample1',2:'Sample2',3:'Sample4'}, # 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_content products = self.get_products() prod_table = DataTable(table=products) product_scrn.add_widget(prod_table)
def __init__(self, **kwargs): super().__init__(**kwargs) self.mydb = sqlite3.connect('dbPos.db') self.myc = self.mydb.cursor() print(self.get_products()) content = self.ids.scrn_contents users = self.get_users() userstable = DataTable(table=users) content.add_widget(userstable) #Display products product_content = self.ids.scrn_product_contents products = self.get_products() producttable = DataTable(table=products) product_content.add_widget(producttable) #Admin Spinner spinvalues = [] for x in range(len(products['product_code'])): line = ' | '.join( [products['product_code'][x], products['product_name'][x]]) spinvalues.append(line) self.ids.target_product.values = spinvalues
def __init__(self, **kwargs): super().__init__(**kwargs) self.mydb = mysql.connector.connect(host='localhost', user='******', passwd='#hasH537', database='pos') self.mycursor = self.mydb.cursor() # stb = { # 'TH0':{0:'St0',1:'Sample1',2:'Sample2',3:'Sample4'}, # 'TH1':{0:'Stm0',1:'Sample1',2:'Sample2',3:'Sample4'}, # 'TH2':{0:'Stmp0',1:'Sampled1.0',2:'Sampled2.0',3:'Sampled4.0'}, # 'TH3':{0:'Stmpl0',1:'Sample1',2:'Sample2',3:'Sample4'}, # 'TH4':{0:'Stmple0',1:'Sample1',2:'Sample2',3:'Sample4'}, # 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_content products = self.get_products() prod_table = DataTable(table=products) product_scrn.add_widget(prod_table)
def add_users(self, surname, first_name, mobile, address, next_kin, username, password): Screen_user = self.ids.scrn_manage_users Screen_user.clear_widgets() handle = self.conn.cursor() if username == '' or password == '': self.info.text = '[color=#FF0000]Either Username, Password Question Field is incorrect[/color]' # This print to the GUI elif mobile.isdigit() == False: self.info.text = '[color=#FF0000]"Mobile Number should be should be Integer[/color]' else: # Obsfucation of Password for Security using sha256 password = hashlib.sha256(password.encode()).hexdigest() # Save Users Details into DB handle.execute( '''INSERT INTO Rep_login(username, pin)VALUES(?,?)''', (username, password)) lastAccountID = handle.lastrowid handle.execute( '''INSERT INTO Rep_Details(repID, surname, first_name, mobile, address, next_of_kin_name)VALUES(?,?,?,?,?,?)''', (lastAccountID, surname, first_name, mobile, address, next_kin)) self.conn.commit() users = self.get_saleRep() usertable = DataTable(table=users) Screen_user.add_widget(usertable)
def remove_product(self, code): if code == '': self.notify.add_widget( Label( text='[color=#FF0000][b]Product 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 Product Code[/b][/color]', markup=True)) self.notify.open() Clock.schedule_once(self.killswitch, 1) else: content = self.ids.scrn_product_contents content.clear_widgets() self.products.delete_one({"product_code": code}) prodz = self.get_products() stocktable = DataTable(table=prodz) content.add_widget(stocktable)
def add_product(self, code, name, weight, stock, sold, order, purchase): 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_product_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()] # self.mycursor.execute(sql, values) # self.mydb.commit() prodz = self.get_products() stocktable = DataTable(table=prodz) content.add_widget(stocktable)
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}) users = self.get_users() userstable = DataTable(table=users) content.add_widget(userstable)
def add_user(self, first, last, user, pwd, des): pwd = hashlib.sha256(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.killswitch, 1) else: target_user = self.users.find_one({'user_name': user}) if target_user == None: self.users.insert_one({ 'first_name': first, 'last_name': last, 'user_name': user, 'password': pwd, 'designation': des, 'date': datetime.now() }) content = self.ids.scrn_contents content.clear_widgets() users = self.get_users() userstable = DataTable(table=users) content.add_widget(userstable) else: self.notify.add_widget( Label( text= '[color=#FF0000][b]Already existing UserName[/b][/color]', markup=True)) self.notify.open() Clock.schedule_once(self.killswitch, 1)
def add_product(self, code, name, weight, stock, sold, order, purchase): 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: target_code = self.products.find_one({'product_code': code}) if target_code == None: 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_product_contents content.clear_widgets() prodz = self.get_products() stocktable = DataTable(table=prodz) content.add_widget(stocktable) else: self.notify.add_widget( Label( text= '[color=#FF0000][b]Already existing Product code[/b][/color]', markup=True)) self.notify.open() Clock.schedule_once(self.killswitch, 1)
def add_user(self, first, last, user, pwd, des): pwd = hashlib.sha256(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.killswitch, 1) else: self.users.insert_one({ "first_name": first, "last_name": last, "user_name": user, "password": pwd, "designation": des, "date": datetime.now() }) 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()] # self.mycursor.execute(sql, values) # self.mydb.commit() users = self.get_users() userstable = DataTable(table=users) content.add_widget(userstable)
def __init__(self, **kwargs): super().__init__(**kwargs) self.mydb = mysql.connector.connect( host='localhost', user='******', passwd='899171022mrvl', database='posdata' ) self.mycursor = self.mydb.cursor() self.notify = Notify() mydb = mysql.connector.connect( host='localhost', user='******', passwd='899171022mrvl', database='posdata' ) mycursor = mydb.cursor() product_code = [] product_name = [] spinvals = [] sql = 'SELECT * FROM stocks' mycursor.execute(sql) products = mycursor.fetchall() for product in products: product_code.append(product[1]) name = product[2] 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 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)
def update_user(self, first,last,user,pwd,des): content = self.ids.scrn_contents content.clear_widgets() pwd = hashlib.sha256(pwd.encode()).hexdigest() self.users.update_one({'user_name':user},{'$set':{'first_name':first,'last_name':last,'user_name':user,'password':pwd,'designation':des,'date':datetime.now()}}) users = self.get_users() userstable = DataTable(table=users) content.add_widget(userstable)
def add_product(self,code,name,weight,stock,sold,order,purchase): content = self.ids.scrn_product_contents content.clear_widgets() self.products.insert_one({'product_code':code,'product_name':name,'product_weight':weight,'in_stock':stock,'sold':sold,'order':order,'last_purchase':purchase}) prodz = self.get_products() stocktable = DataTable(table=prodz) content.add_widget(stocktable)
def remove_user(self, user): user_content = self.ids.users_scrn user_content.clear_widgets() self.users.delete_one({'user_name': user}) users = self.get_users() datatable = DataTable(table=users) user_content.add_widget(datatable)
def remove_user(self,user): content = self.ids.scrn_contents content.clear_widgets() self.users.remove({'user_name':user}) users = self.get_users() userstable = DataTable(table=users) content.add_widget(userstable)
def remove_product(self,code): content = self.ids.scrn_product_contents content.clear_widgets() self.products.remove({'product_code':code}) prodz = self.get_products() stocktable = DataTable(table=prodz) content.add_widget(stocktable)
def remove_product(self, code): user_content = self.ids.products_scrn user_content.clear_widgets() print(code) self.stocks.delete_one({'product_code': code}) prods = self.get_products() datatable = DataTable(table=prods) user_content.add_widget(datatable)
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()] self.mycursor.execute(sql, values) self.mydb.commit() users = self.get_users() userstable = DataTable(table=users) content.add_widget(userstable)
def __init__(self, **kwargs): super().__init__(**kwargs) client = MongoClient("mongodb+srv://Inam:[email protected]/dev_connector?retryWrites=true&w=majority") db = client['POS'] self.users = db['users_table'] self.stocks = db['stocks_table'] # Init values for product analysis product_code = [] product_name = [] spinvals = [] for product in self.stocks.find(): # print(user) product_code.append(product['product_code']) prd_name = product.get('product_name') if prd_name != None: if len(prd_name) > 30: prd_name = prd_name[:30] + '...' product_name.append(prd_name) for x in range(len(product_name)): line = ' | '.join([product_code[x], product_name[x]]) spinvals.append(line) self.ids.target_product.values = spinvals #Display Users user_content = self.ids.users_scrn users = self.get_users() datatable = DataTable(table=users) user_content.add_widget(datatable) #Display Products prod_content = self.ids.products_scrn products = self.get_products() datatable = DataTable(table=products) prod_content.add_widget(datatable)
def remove_user(self, user): content = self.ids.scrn_contents content.clear_widgets() sql = 'DELETE FROM users WHERE username=?' values = [user] print(sql) self.myc.execute(sql, values) self.mydb.commit() users = self.get_users() userstable = DataTable(table=users) content.add_widget(userstable)
def remove_user(self, user): content = self.ids.scrn_contents content.clear_widgets() sql = 'DELETE FROM users WHERE user_name = %s' # self.users.remove({'user_name':user}) values = [user] self.mycursor.execute(sql, values) self.mydb.commit() users = self.get_users() userstable = DataTable(table=users) content.add_widget(userstable)
def __init__(self, **kwargs): super().__init__(**kwargs) self.conn = dbconn.con() self.page_title = self.ids.page_title self.product_quantity = '' self.crud_product_name = '' self.crud_product_quantity = '' self.order_product_cost = '' self.old_stock = '' self.sms_username = '******' self.sms_password = '******' # Save all Shopping Cart for Current User self.cart = [] self.qty = [] self.total = 0.00 self.product_total_cost = [] self.customerid = '' self.productid = [] self.get_sold_products() # ALL Stock Display Screen screen_all_products = self.ids.scrn_all_stock products = self.get_products() productstable = DataTable(table=products) screen_all_products.add_widget(productstable) # # ALL Sold Products Display Screen screen_all_solds = self.ids.scrn_all_sales sold_products = self.get_sold_products() sold_products_table = DataTable(table=sold_products) screen_all_solds.add_widget(sold_products_table) # Order Page products_screen = self.ids.view_available_products product = self.get_available_products() producttable = DataTable(table=product) self.ids.view_available_products.add_widget(producttable)
def update_user(self, first, last, user, password, des): content = self.ids.scrn_contents content.clear_widgets() password = hashlib.sha256(password.encode()).hexdigest() sql = 'UPDATE users SET firstname=?,lastame=?,username=?,password=?,destination=? WHERE username=?' values = [first, last, user, password, des, user] print(sql) self.myc.execute(sql, values) self.mydb.commit() users = self.get_users() userstable = DataTable(table=users) content.add_widget(userstable)
def add_product(self, code, name, weight, stock, sold, sorder, purchase): product_content = self.ids.scrn_product_contents product_content.clear_widgets() sql = "INSERT INTO stocks(product_code,product_name,product_weight,in_stock,sold,product_order,last_purchase) values(?,?,?,?,?,?,?)" values = [code, name, weight, stock, sold, sorder, purchase] print(sql) self.myc.execute(sql, values) self.mydb.commit() products = self.get_products() producttable = DataTable(table=products) product_content.add_widget(producttable)
def remove_product(self, code): product_content = self.ids.scrn_product_contents product_content.clear_widgets() sql = "DELETE FROM stocks WHERE product_code=?" values = [code] print(sql) self.myc.execute(sql, values) self.mydb.commit() products = self.get_products() producttable = DataTable(table=products) product_content.add_widget(producttable)
def update_user(self, first, last, user, pwd, des): content = self.ids.scrn_contents content.clear_widgets() 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' values = [first, last, user, pwd, des, user] self.mycursor.execute(sql, values) self.mydb.commit() users = self.get_users() userstable = DataTable(table=users) content.add_widget(userstable)
def update_products(self, product_name, product_quantity, unit_cost, selling_cost, stock_low_alert): Screen_product = self.ids.scrn_manage_products Screen_product.clear_widgets() handle = self.conn.cursor() update_query = handle.execute( '''UPDATE Products SET p_quantity=?, p_cost=?, p_selling_price=?, stock_lowAt=? WHERE p_name=?''', (product_quantity, unit_cost, selling_cost, stock_low_alert, product_name)) self.conn.commit() products = self.get_products() producttable = DataTable(table=products) Screen_product.add_widget(producttable)
def update_product(self, code, name, weight, stock, sold, sorder, purchase): product_content = self.ids.scrn_product_contents product_content.clear_widgets() sql = "UPDATE stocks SET product_code=?,product_name=?,product_weight=?,in_stock=?,sold=?,product_order=?,last_purchase=? WHERE product_code=?" values = [code, name, weight, stock, sold, sorder, purchase, code] print(sql) self.myc.execute(sql, values) self.mydb.commit() products = self.get_products() producttable = DataTable(table=products) product_content.add_widget(producttable)
def add_user(self, first, last, user, password, des): content = self.ids.scrn_contents content.clear_widgets() password = hashlib.sha256(password.encode()).hexdigest() sql = "INSERT INTO users(firstname,lastame,username,password,destination) values(?,?,?,?,?)" values = [first, last, user, password, des] print(sql) self.myc.execute(sql, values) self.mydb.commit() users = self.get_users() userstable = DataTable(table=users) content.add_widget(userstable)