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

question 4

parent fcf40150
Branches
No related tags found
No related merge requests found
%% Cell type:code id: tags:
```
num=input("Entrez le nombre employé: ")
```
%% Cell type:code id: tags:
```
``` python
import sqlite3
# Connect to the database
conn = sqlite3.connect('company.db')
# Create a cursor object
cursor = conn.cursor()
print("Connected to company.db")
```
%% Output
Connected to company.db
%% Cell type:code id: tags:
``` python
# Journées
import datetime
cursor.execute("SELECT NUMERO_EMPLOYE, NOM, PRENOM, CS_PRODUCTION,CS_JOURNEE, DATE_DEBUT FROM EMPLOYE")
employees = cursor.fetchall()
cursor.execute("SELECT * FROM LOG_JOURNEE_JOUR")
LOG_JOURNEE_JOUR=cursor.fetchall()
# Find the smallest date
smallest_date = min(row[1] for row in LOG_JOURNEE_JOUR)
today = datetime.datetime.now().strftime("%Y-%m-%d")
delta = datetime.datetime.strptime(today, "%Y-%m-%d") - datetime.datetime.strptime(smallest_date, "%Y-%m-%d")
for i in range(delta.days + 1):
date = (datetime.datetime.strptime(smallest_date, "%Y-%m-%d") + datetime.timedelta(days=i)).strftime("%Y-%m-%d")
if datetime.datetime.strptime(date, "%Y-%m-%d").weekday() == 0:
for employee in employees:
NUMERO_EMPLOYE, NOM, PRENOM,CS_PRODUCTION,CS_JOURNEE, DATE_DEBUT = employee
cursor.execute("SELECT * FROM SALAIRE_SEMAINE where DATE_LUNDI=? and NUMERO_EMPLOYE=?", (date,NUMERO_EMPLOYE))
semaine=cursor.fetchall()
if semaine ==[] and CS_JOURNEE is not None:
liste_jours_travail=[]
for j in range(2,8):
cursor.execute("SELECT * FROM LOG_JOURNEE_JOUR where DATE=? and NUMERO_EMPLOYE=?", ((datetime.datetime.strptime(date, "%Y-%m-%d") - datetime.timedelta(days=j)).strftime("%Y-%m-%d"), NUMERO_EMPLOYE))
jour=cursor.fetchall()
liste_jours_travail.insert(0, jour)
if liste_jours_travail!=[[], [], [], [], [], []]:
for k in liste_jours_travail:
nb_heures=0
if k!=[]:
nb_heures=+k[0][6]
print(nb_heures)
cursor.execute(f"SELECT SALAIRE_HORAIRE FROM GRILLE_SALAIRE_HORAIRE WHERE CS_HORAIRE = {CS_JOURNEE}")
salaire_horaire=cursor.fetchone()[0]
cursor.execute("INSERT INTO SALAIRE_SEMAINE (DATE_LUNDI,NUMERO_EMPLOYE,NB_HEURES, NB_PRODUCTION,SALAIRE_AVANT,NOEL,ANCIENNETE,SALAIRE_APRES) VALUES (?,?,?,?,?,?,?,?)", (date,NUMERO_EMPLOYE,nb_heures,0,salaire_horaire*nb_heures,0,0,0))
```
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment