forked from LalitkumarDeshmukh/Inventory-Management-System
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsales.py
106 lines (84 loc) · 4.16 KB
/
sales.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
from tkinter import*
from PIL import Image,ImageTk #pip install pillow
from tkinter import ttk,messagebox
import sqlite3
import os
class salesClass:
def __init__(self,root):
self.cat_list=[]
self.sup_list=[]
self.root=root
self.root.geometry("1100x500+220+130")
self.root.title("Inventory Management System")
self.root.config(bg="white")
self.root.focus_force()
self.bill_list=[]
self.var_invoice=StringVar()
######### title ###########
lbl_title=Label(self.root,text="View Customer Bills",font=("goudy old style",30),bg="#184a45",fg="white",bd=3,relief=RIDGE).pack(side=TOP,fill=X,padx=10,pady=20)
lbl_invoice=Label(self.root,text="Bill Holder :",font=("times new roman",15),bg="white").place(x=50,y=100)
txt_invoice=Entry(self.root,textvariable=self.var_invoice,font=("times new roman",15),bg="lightyellow").place(x=160,y=100,width=180,height=28)
btn_search=Button(self.root,text="search",command=self.search,font=("times new roman",15,"bold"),bg="#2196f3",fg="white",cursor="hand2").place(x=360,y=100,width=120,height=28)
btn_clear=Button(self.root,text="Clear",command=self.clear,font=("times new roman",15,"bold"),bg="lightgray",cursor="hand2").place(x=490,y=100,width=120,height=28)
sales_Frame=Frame(self.root,bd=3,relief=RIDGE)
sales_Frame.place(x=50,y=140,width=200,height=330)
scrolly=Scrollbar(sales_Frame,orient=VERTICAL)
self.Sales_List=Listbox(sales_Frame,font=("goudy old style",15),bg="white",yscrollcommand=scrolly.set)
scrolly.pack(side=RIGHT,fill=Y)
scrolly.config(command=self.Sales_List.yview)
self.Sales_List.pack(fill=BOTH,expand=1)
self.Sales_List.bind("<ButtonRelease-1>",self.get_data)
#=====bill area====
bill_Frame=Frame(self.root,bd=3,relief=RIDGE)
bill_Frame.place(x=280,y=140,width=410,height=330)
lbl_title2=Label(bill_Frame,text="Customer Bill Area",font=("goudy old style",20),bg="orange",fg="white").pack(side=TOP,fill=X)
scrolly2=Scrollbar(bill_Frame,orient=VERTICAL)
self.bill_area=Text(bill_Frame,font=("goudy old style",15),bg="lightyellow",yscrollcommand=scrolly2.set)
scrolly2.pack(side=RIGHT,fill=Y)
scrolly2.config(command=self.bill_area.yview)
self.bill_area.pack(fill=BOTH,expand=1)
#=========Image============
self.bill_photo=Image.open("Images/cat3.jpeg")
self.bill_photo=self.bill_photo.resize((450,300),Image.ANTIALIAS)
self.bill_photo=ImageTk.PhotoImage(self.bill_photo)
lbl_image=Label(self.root,image=self.bill_photo)
lbl_image.place(x=700,y=110)
self.show()
#==========================================================================
def show(self):
del self.bill_list[:]
self.Sales_List.delete(0,END)
#print(os.listdir('../IMS')) bill1.txt, category. py
for i in os.listdir('bill'):
# print(i.split('.'),i.split('.')[-1])
if i.split('.')[-1]=='txt':
self.Sales_List.insert(END,i)
self.bill_list.append(i.split('.')[0])
def get_data(self,ev):
index_=self.Sales_List.curselection()
file_name=self.Sales_List.get(index_)
print(file_name)
self.bill_area.delete('1.0',END)
fp=open(f'bill/{file_name}','r')
for i in fp:
self.bill_area.insert(END,i)
fp.close()
def search(self):
if self.var_invoice.get()=="":
messagebox.showerror("Error","Invoice no. should be rrquired",parent=self.root)
else:
if self.var_invoice.get() in self.bill_list:
self.bill_area.delete('1.0',END)
fp=open(f'bill/{self.var_invoice.get()}.txt','r')
for i in fp:
self.bill_area.insert(END,i)
fp.close()
else:
messagebox.showerror("Error","Invalid Invoice NO.",parent=self.root)
def clear(self):
self.show()
self.bill_area.delete('1.0',END)
if __name__=="__main__":
root=Tk()
obj=salesClass(root)
root.mainloop()