-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataEntry.py
66 lines (53 loc) · 2.72 KB
/
DataEntry.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
import mysql.connector as co
from tkinter import *
import tkinter as tk
def enter_data():
mycon=co.connect(host='localhost',
user='root',
passwd='Sarvesh@27' ,
database='Shubham_Collection'
)
# Create a cursor object to execute SQL commands
mycursor = mycon.cursor()
root = tk.Tk()
root.title("ADD DATA")
root.geometry("1920x1080")
root.config(bg='lightblue')
tk.Label(root, text="ENTER PRODUCT DETAILS",font=('Arial',30,'bold'),bg='lightblue',fg='red').pack(side="top")
tk.Label(root, text="Brand:",font=('Arial',15,'bold'),bg='lightblue',fg='black').place(x=50,y=75)
tk.Label(root, text="Garment Type:",font=('Arial',15,'bold'),bg='lightblue',fg='black').place(x=50,y=125)
tk.Label(root, text="Product Code:",font=('Arial',15,'bold'),bg='lightblue',fg='black').place(x=50,y=175)
tk.Label(root, text="Size:",font=('Arial',15,'bold'),bg='lightblue',fg='black').place(x=50,y=225)
tk.Label(root, text="Colour:",font=('Arial',15,'bold'),bg='lightblue',fg='black').place(x=50,y=275)
tk.Label(root, text="Quantity:",font=('Arial',15,'bold'),bg='lightblue',fg='black').place(x=50,y=325)
tk.Label(root, text="MRP:",font=('Arial',15,'bold'),bg='lightblue',fg='black').place(x=50,y=375)
# Blocks for entering the data
Brand_entry = tk.Entry(root)
Garment_Type_entry = tk.Entry(root)
Product_Code_entry = tk.Entry(root)
Size_entry = tk.Entry(root)
Colour_entry = tk.Entry(root)
Quantity_entry = tk.Entry(root)
MRP_entry = tk.Entry(root)
Brand_entry.place(x=200,y=75)
Garment_Type_entry.place(x=200,y=125)
Product_Code_entry.place(x=200,y=175)
Size_entry.place(x=200,y=225)
Colour_entry.place(x=200,y=275)
Quantity_entry.place(x=200,y=325)
MRP_entry.place(x=200,y=375)
# Function to insert data into the MySQL database
def insert_data():
Brand = Brand_entry.get()
Garment_Type = Garment_Type_entry.get()
Product_Code = Product_Code_entry.get()
Size=Size_entry.get()
Colour=Colour_entry.get()
Quantity=Quantity_entry.get()
MRP=MRP_entry.get()
sql = "INSERT INTO Product_Details (Brand, Garment_Type, Product_Code, Size, Colour, Quantity, MRP) VALUES (%s, %s, %s, %s, %s, %s, %s)"
val = (Brand, Garment_Type, Product_Code, Size, Colour, Quantity, MRP)
mycursor.execute(sql, val)
mycon.commit()
tk.Button(root, text="Add Product", command=insert_data,font=('Arial',25,'bold'),bg='#FFFDD0',fg='red',borderwidth=3,width=10, height=1).place(x=200,y=425)
root.mainloop()