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 105 106 107 108 109 110 111 112
|
class PageOne(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
mysqldb = mysql.connector.connect(
host='localhost',
user='root',
password='*******',
port='3306',
database='fiche_patient_sql'
)
mycursor = mysqldb.cursor()
global today
today = date.today()
print(today)
def Add():
with open("idsaver.txt", "r") as fic:
content = fic.read()
print(content)
id = int(content)
date =today
type = vartype.get()
motif = emotif.get()
atcd = getallatcd
symptome = esymptome.get()
bio = ebio.get()
diagnostic = edg.get()
print(id, date,type,motif,atcd,symptome,bio,diagnostic)
mysqldb = mysql.connector.connect(
host='localhost',
user='root',
password='******',
port='3306',
database='fiche_patient_sql'
)
mycursor = mysqldb.cursor()
try:
sql = "INSERT INTO fiche_pat_table (id,date,type,motif,atcd, symptome,bio,diagnostic) " \
"VALUES (%s,%s,%s,%s,%s,%s,%s,%s)"
val = (id, date, type, motif, atcd, symptome, bio, diagnostic)
mycursor.execute(sql, val)
mysqldb.commit()
messagebox.showinfo("information", "Employee inserted successfully...")
emotif.focus_set()
except Exception as e:
print(e)
mysqldb.rollback()
mysqldb.close()
global typechoosen
global emotif
global eatcd
global esymptome
global ebio
global edg
################## ATCD ####################################
frame_atcd = Frame(fTable, bg="#F5CBA7", bd=1, relief=SUNKEN)
frame_atcd.grid(row=3,sticky='nsew', pady=10, padx=5)
label_title = tk.Label(frame_atcd, text="Antécédents", font=("Courrier", 15), bg="#F5CBA7",
fg="black")
label_title.grid(row=1, column=0)
geteatcd = tk.StringVar()
latcd = tk.Label(frame_atcd, text="antécédent", bg="#F5CBA7").grid(row=2, column=0)
eatcd = tk.Entry(frame_atcd, textvariable=geteatcd)
eatcd.grid(row=2, column=1)
info = eatcd.grid_info()
rowentry = info["row"]
with open("rowsaver.txt", "w") as fic:
therow = rowentry
fic.write(str(therow))
def createEntry():
with open("rowsaver.txt", "r") as fic:
therow = fic.read()
lerow = int(therow) + 1
tk.Label(frame_atcd, text="antécédent", bg="#F5CBA7").grid(row=lerow, column=0)
createEntry.getearcd = tk.StringVar()
eatcd = tk.Entry(frame_atcd, textvariable=createEntry.getearcd).grid(row=lerow, column=1)
with open("rowsaver.txt", "w") as fic:
therow = int(therow) + 1
fic.write(str(therow))
plusentry = tk.Button(frame_atcd, text="+", command=createEntry, height=1, width=3)
plusentry.grid(row=2, column=2, padx=20)
createEntry()
getallatcd = str(geteatcd)+ "\n" +str(createEntry.getearcd)
###########frame Button ##########################
frame_butt = Frame(fTable, bg="#F5CBA7", bd=1, relief=SUNKEN)
frame_butt.grid(row=7, sticky='nsew', pady=10, padx=5)
Button(frame_butt, text="enregister fiche", command=Add, height=3, width=13).grid(row=0, column=0, padx=20) |