Skip to content
Snippets Groups Projects
Commit 1bbe05c0 authored by Bouchaira Neirouz's avatar Bouchaira Neirouz
Browse files

hello

parent bbd0c8ae
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,6 @@ with ui.nav_panel("Création de compte employé"): ...@@ -18,7 +18,6 @@ with ui.nav_panel("Création de compte employé"):
with ui.card(): with ui.card():
conn = sqlite3.connect('C:/Users/neiro/Documents/GitHub/sgbd-usine/donnees/company.db') conn = sqlite3.connect('C:/Users/neiro/Documents/GitHub/sgbd-usine/donnees/company.db')
cursor = conn.cursor() cursor = conn.cursor()
res= cursor.execute("SELECT MAX(NUMERO_EMPLOYE) FROM EMPLOYE")
ui.input_text("Nom", "NOM") ui.input_text("Nom", "NOM")
ui.input_text("Prénom", "PRENOM") ui.input_text("Prénom", "PRENOM")
...@@ -42,6 +41,42 @@ with ui.nav_panel("Création de compte employé"): ...@@ -42,6 +41,42 @@ with ui.nav_panel("Création de compte employé"):
return ui.input_select("CS_PRODUCTION","Code salarial de production", choices=production) return ui.input_select("CS_PRODUCTION","Code salarial de production", choices=production)
ui.input_date("date_debut", "Date de début" ) ui.input_date("date_debut", "Date de début" )
ui.input_action_button( "create_account","Create Account") ui.input_action_button( "create_account","Create Account")
@input.create_account()
def create_account():
NOM = input.NOM()
PRENOM = input.PRENOM()
TYPE = 1 if input.type_de_contrat() == "Journalier" else 2
CS_PRODUCTION = input.CS_PRODUCTION if TYPE == 2 else None
CS_JOURNEE = input.CS_JOURNEE if TYPE == 1 else None
date_debut = input.date_debut()
conn = sqlite3.connect('C:/Users/neiro/Documents/GitHub/sgbd-usine/donnees/company.db')
cursor = conn.cursor()
cursor.execute("""
SELECT NUMERO_EMPLOYE FROM EMPLOYE
WHERE NOM = ? AND PRENOM = ? AND DATE_DEBUT = ?
""", (NOM, PRENOM, date_debut))
existing_employee = cursor.fetchone()
if existing_employee:
return f"Cet employé est déjà enregistré avec le numéro employé: {existing_employee[0]}"
else:
cursor.execute("""
SELECT MAX(NUMERO_EMPLOYE) FROM EMPLOYE
""")
max_numero_employe = cursor.fetchone()[0]
NUMERO_EMPLOYE = max_numero_employe + 1 if max_numero_employe is not None else 1
cursor.execute("""
INSERT INTO EMPLOYE (NUMERO_EMPLOYE, TYPE, NOM, PRENOM, CS_PRODUCTION, CS_JOURNEE, DATE_DEBUT)
VALUES (?, ?, ?, ?, ?, ?, ?)
""", (NUMERO_EMPLOYE, TYPE, NOM, PRENOM, CS_PRODUCTION, CS_JOURNEE, date_debut))
conn.commit()
conn.close()
return f"Nouvel employé enregistré!\n\n" + f"Numéro employé: {NUMERO_EMPLOYE}" + f"\nType de contrat: {'Journalier' if TYPE == 1 else 'Production'}" + f"\nNom: {NOM}" + f"\nPrénom: {PRENOM}" + (f"\nCode salarial de production: {CS_PRODUCTION}" if TYPE == 2 else f"\nCode salarial journalier: {CS_JOURNEE}") + f"\nDate du début du contrat: {date_debut}"
with ui.nav_panel("Suivi des employés"): with ui.nav_panel("Suivi des employés"):
@render.data_frame @render.data_frame
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment