import datetime
import sqlite3
import tkinter.messagebox
from tkinter import *
conn = sqlite3.connect ( "C:\\Users\\Samuel\\Dropbox\\PycharmProjects\\TkinterVendas\\DataBase\\store.db" )
c = conn.cursor ( )
date = datetime.datetime.now ( ).date ( )
products_list = []
product_price = []
product_quantity = []
product_id = []
class Application:
def __init__(self, master, *args, **kwargs):
self.master = master
self.left = Frame ( master, width=700, height=768, bg='white' )
self.left.pack ( side=LEFT )
self.right = Frame ( master, width=666, height=768, bg='lightblue' )
self.right.pack ( side=RIGHT )
self.heading = Label ( self.left, text="R. R. Incorporações Ltda.", font=('arial 40 bold'), bg='lightblue' )
self.heading.place ( x=0, y=0 )
self.date_1 = Label ( self.right, text="Data de Hoje: " + str ( date ), font='arial 16 bold',
bg='lightblue' )
self.date_1.place ( x=0, y=0 )
self.produto = Label ( self.right, text="Produto:", font=('arial 18 bold'), bg='lightblue', fg='white' )
self.produto.place ( x=0, y=60 )
self.quantidade = Label ( self.right, text="Quantidade:", font=('arial 18 bold'), bg='lightblue', fg='white' )
self.quantidade .place ( x=300, y=60 )
self.valor = Label ( self.right, text="Valor:", font=('arial 18 bold'), bg='lightblue', fg='white' )
self.valor.place ( x=500, y=60 )
self.inserir = Label ( self.left, text="Produto ID: ", font=('arial 18 bold'), bg='white')
self.inserir.place ( x=0, y=80 )
self.inserir = Entry (self.left, width=35, bd="0", font='arial 16 bold', bg='Lavender' )
self.inserir.place ( x=140, y=80 )
self.btn_pesquisar = Button (self.left, text="Pesquisar", width=25, height=2,
font='arial 10 bold', bg='RoyalBlue', fg='white',command= self.jx )
self.btn_pesquisar.place(x=350 , y=120)
self.nomeproduto = Label ( self.left, text="", font='arial 16 bold', bg='white', fg='MidnightBlue' )
self.nomeproduto.place ( x=0, y=250 )
self.ppreco = Label ( self.left, text="", font='arial 16 bold', bg='white', fg='MidnightBlue' )
self.ppreco.place ( x=0, y=300 )
self.total_1 = Label ( self.right, text="Valor Total: ", font='arial 30 bold', bg='lightblue', fg='LightSalmon' )
self.total_1.place ( x=0, y=650 )
def jx(self, *args, **kwargs):
self.get_id = self.inserir.get()
query = "SELECT name, stock, sp FROM inventory WHERE id=?"
result = c.execute ( query, (self.get_id,))
for self.r in result :
self.get_id = self.r[0]
self.get_name = self.r[1]
self.get_stock = self.r[2]
self.get_price = self.r[4]
self.nomeproduto.configure(text = "Nome Produto: " + str(self.get_name))
self.ppreco.configure (text="Valor Produto: R$ " + str(self.get_price))
self.quantity_1 = Label ( self.left, text="Quantidade: ", font='arial 16 bold', bg='white', fg='MidnightBlue' )
self.quantity_1.place ( x=0, y=370 )
self.quantity_e = Entry ( self.left, width=30, bd="0", font='arial 16 bold', bg='Lavender' )
self.quantity_e.place ( x=190, y=370 )
self.quantity_e.focus()
self.descunt_1 = Label ( self.left, text="Desconto: ", font=('arial 16 bold'), bg='white', fg='MidnightBlue' )
self.descunt_1.place ( x=0, y=410 )
self.descunt_e = Entry ( self.left, width=30, bd="0", font='arial 16 bold', bg='Lavender' )
self.descunt_e.place ( x=190, y=410)
self.descunt_e.insert(END, 0)
self.car_btn = Button ( self.left, text="Carrinho", width=23, height=2, font='arial 10 bold', bg='RoyalBlue', fg='white')
self.car_btn.place ( x=350, y=450 )
self.change_1 = Label ( self.left, text="Total Pago: ", font='arial 16 bold', bg='white', fg='MidnightBlue' )
self.change_1.place ( x=0, y=550 )
self.change_e = Entry ( self.left, width=30, bd="0", font='arial 16 bold', bg='GreenYellow' )
self.change_e.place ( x=190, y=550 )
self.change_btn = Button ( self.left, text="Calcular Troco", width=23, height=2, font='arial 10 bold', bg='tomato', fg='white' )
self.change_btn.place ( x=350, y=590 )
self.Gerarrec_btn = Button ( self.left, text="Gerar Recibo", width=23, height=2, font='arial 10 bold',
bg='Gold')
self.Gerarrec_btn.place ( x=350, y=640 )
def car(self, *args, **kwargs) :
self.quantity_value = int(self.quantity_e.get())
if self.quantity_value >int(self.get_stock):
tkinter.messagebox.showinfo("Atenção!!!","Quantidade Sugerida a Maior do que quantidade no Estoque.!")
else:
self.final_price = (float(self.quantity_value)*float(self.get_price))-(float(self.descunt_e.get()))
products_list.append(self.get_name)
product_price.append ( self.final_price)
product_quantity.append ( self.quantity_value )
product_id.append ( self.get_id )
self.x_index = 0
self.y_index = 100
self.x_counter = 0
for self.p in products_list:
self.tempname = label(self.right, text = str(products_list[self.x_counter]), font = 'arial 18 bold', bg='ligthblue', fg='white')
self.tempname.place(x=0, y=y_index)
labels_list.append(self.tempname)
self.tempqt = label(self.right, text = str(product_quantity[self.x_counter]), font = 'arial 18 bold', bg='ligthblue', fg='white')
self.tempqt.place(x=300, y=y_index)
labels_list.append(self.tempqt)
self.tempprice = label(self.right, text = str(product_price[self.x_counter]), font = 'arial 18 bold', bg='ligthblue', fg='white')
self.tempprice.place(x=500, y=y_index)
labels_list.append(self.tempprice)
self.y_index += 40
self.x_counter +=1
root = Tk ( )
b = Application ( root )
root.geometry ( "1366x768+0+0" )
root.title ( "R.R Incorporações Ltda." )
root.mainloop ( )