Code
Code
Code
#Fonction Connecter
def Seconnecter():
surnom = txtnomUtilisateur.get()
mdp = txtmdp.get()
if (surnom == "" and mdp == ""):
messagebox.showerror("", "il faut rentrer les Données")
txtmdp.delete("0", "end")
txtnomUtilisateur.delete("0", "end")
elif (surnom == "admin" and mdp == "admin"):
messagebox.showinfo("", "Bienvenue")
txtnomUtilisateur.delete("0", "end")
txtmdp.delete("0", "end")
root.destroy()
call(["python", "Chambre2.py"])
else:
messagebox.showwarning("", "Erreur de Connexion")
txtmdp.delete("0", "end")
txtnomUtilisateur.delete("0", "end")
#Ma fenetre
root = Tk()
root.title("FENTRE DE CONNECTION")
root.geometry("400x300+450+200")
root.resizable(False, False)
root.configure(background="#091821")
#Ajouter le titre
lbltitre = Label(root,borderwidth = 3, relief = SUNKEN
, text = "Formulaire de connexion", font = ("Sans Serif", 25),
background = "#091821", foreground="white")
lbltitre.place(x = 0, y = 0, width = 400)
#Bouton Connecter
btnenregistrer = Button(root, text = "Connexion", font = ("Arial", 16),bg
="#FF4500", fg = "white", command=Seconnecter)
btnenregistrer.place(x=150, y= 200, width=200)
#Execution
root.mainloop()
def Ajouter():
matricule = txtNumero.get()
nom = txtnom.get()
prenom = txtprenom.get()
sexe = valeurSexe.get()
classe = comboClasse.get()
matiere = txtmatiere.get()
note = txtnote.get()
try:
sql = "INSERT INTO note (code, nom, prenom, sexe, classe, matiere, notes)
VALUES (%s, %s, %s,%s, %s, %s, %s) "
val = (matricule, nom,prenom, sexe,classe, matiere ,note )
meConnect.execute(sql, val)
maBase.commit()
derniereMatricule = meConnect.lastrowid
messagebox.showinfo("information", "Note ajouter")
root.destroy()
call(["python", "Chambre2.py"])
except Exception as e:
print(e)
#retour
maBase.rollback()
maBase.close()
def Modifer():
matricule = txtNumero.get()
nom = txtnom.get()
prenom = txtprenom.get()
sexe = valeurSexe.get()
classe = comboClasse.get()
matiere = txtmatiere.get()
note = txtnote.get()
try:
sql = "update note set nom=%s,prenom= %s,sexe= %s,classe=%s,matiere=
%s,notes= %s where code= %s "
val = (nom,prenom, sexe,classe, matiere ,note, matricule )
meConnect.execute(sql, val)
maBase.commit()
derniereMatricule = meConnect.lastrowid
messagebox.showinfo("information", "Note modifier")
root.destroy()
call(["python", "Chambre2.py"])
except Exception as e:
print(e)
#retour
maBase.rollback()
maBase.close()
def Supprimer():
matricule = txtNumero.get()
try:
sql = "delete from note where code= %s "
val = ( matricule,)
meConnect.execute(sql, val)
maBase.commit()
derniereMatricule = meConnect.lastrowid
messagebox.showinfo("information", "Note Supprimer")
root.destroy()
call(["python", "Chambre.py"])
except Exception as e:
print(e)
#retour
maBase.rollback()
maBase.close()
#Ma fenetre
root = Tk()
root.title("MENUE PRINCIPALE")
root.geometry("1350x700+0+0")
root.resizable(False, False)
root.configure(background="#091821")
#Ajouter le titre
lbltitre = Label(root,borderwidth = 3, relief = SUNKEN
, text = "GESTION NOTES DES ETUDIANTS", font = ("Sans Serif", 25),
background = "#2F4F4F", fg="#FFFAFA")
lbltitre.place(x = 0, y = 0, width = 1350, height=100)
#Matricule
lblNumero = Label(root, text="MATRICULE", font=("Arial", 18), bg="#091821",
fg="white")
lblNumero.place(x=70, y=150, width=150)
txtNumero = Entry(root,bd=4, font=("Arial", 14))
txtNumero.place(x=250,y=150,width=150)
#Nom
lblnom = Label(root, text="NOM", font=("Arial", 18), bg="#091821", fg="white")
lblnom.place(x=70, y=200, width=150)
txtnom = Entry(root,bd=4, font=("Arial", 14))
txtnom.place(x=250,y=200,width=300)
#Prenom
lblprenom = Label(root, text="PRENOM", font=("Arial", 18), bg="#091821",
fg="white")
lblprenom.place(x=70, y=250, width=150, )
txtprenom = Entry(root,bd=4, font=("Arial", 14))
txtprenom.place(x=250,y=250,width=300)
#sexe
valeurSexe = StringVar()
#Classe
lblClasse = Label(root, text="CLASSE", font=("Arial", 18), bg="#091821",
fg="white")
lblClasse.place(x=70, y=350, width=150, )
#Matiere
lblmatiere = Label(root, text="MATIERE", font=("Arial", 18), bg="#091821",
fg="white")
lblmatiere.place(x=70, y=400, width=150, )
txtmatiere = Entry(root,bd=4, font=("Arial", 14))
txtmatiere.place(x=250,y=400,width=300)
#note
lblnote = Label(root, text="NOTE", font=("Arial", 18), bg="#091821", fg="white")
lblnote.place(x=70, y=450, width=150, )
txtnote = Entry(root,bd=4, font=("Arial", 14))
txtnote.place(x=250,y=450,width=200)
#Enregistrer
btnenregistrer = Button(root, text = "Enregistrer", font = ("Arial", 16),bg =
"#D2691E", fg = "white", command=Ajouter)
btnenregistrer.place(x=250, y= 500, width=200)
#modifier
btnmodofier = Button(root, text = "Modifier", font = ("Arial", 16),bg = "#D2691E",
fg = "white", command=Modifer)
btnmodofier.place(x=250, y= 550, width=200)
#Supprimer
btnSupprimer = Button(root, text = "Supprimer", font = ("Arial", 16),bg =
"#D2691E", fg = "white", command=Supprimer)
btnSupprimer.place(x=250, y= 600, width=200)
#Table
table = ttk.Treeview(root, columns = (1, 2, 3, 4, 5, 6, 7), height = 5, show =
"headings")
table.place(x = 560,y = 150, width = 790, height = 450)
#Entete
table.heading(1 , text = "MAT")
table.heading(2 , text = "NOM")
table.heading(3 , text = "PRENOM")
table.heading(4 , text = "SEXE")
table.heading(5 , text = "CLASSE")
table.heading(6 , text = "MATIERE")
table.heading(7 , text = "NOTE")
#Execution
root.mainloop()