This commit is contained in:
2024-05-13 16:08:20 +02:00
commit e774b41d04
5 changed files with 367 additions and 0 deletions

8
.flake8 Normal file
View File

@@ -0,0 +1,8 @@
[flake8]
exclude =
.git,
__pycache__
extend-ignore = D100
max-line-length = 119
select = E,W,F,N,I,D
application-import-names = flake8_import_order,tests

148
.gitignore vendored Normal file
View File

@@ -0,0 +1,148 @@
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/

80
Datenbank.py Normal file
View File

@@ -0,0 +1,80 @@
import sqlite3
def datenbank_erstellen():
try:
conn = sqlite3.connect('einsatz.db')
print("Datenbank verbunden")
cursor = conn.cursor()
create_table_query = '''
CREATE TABLE IF NOT EXISTS einsatzkraefte (
id INTEGER PRIMARY KEY,
vorname TEXT,
nachname TEXT,
strasse TEXT,
plz TEXT,
ort TEXT,
geburtsdatum TEXT,
geschlecht TEXT,
nationalitaet TEXT,
hiorg TEXT,
start_datum TEXT,
start_uhrzeit TEXT,
ende_datum TEXT,
ende_uhrzeit TEXT,
position TEXT,
qrcode TEXT
);
'''
cursor.execute(create_table_query)
conn.commit()
print("Tabelle 'einsatzkraefte' erstellt")
except sqlite3.Error as e:
print("Fehler beim Arbeiten mit der Datenbank:", e)
finally:
conn.close()
def daten_einfuegen(
vorname, nachname, strasse, plz, ort, geburtsdatum, geschlecht, nationalitaet, hiorg, start_datum,
start_uhrzeit, ende_datum, ende_uhrzeit, position, qrcode):
try:
conn = sqlite3.connect('einsatz.db')
cursor = conn.cursor()
insert_data_query = '''
INSERT INTO einsatzkraefte (
vorname, nachname, strasse, plz, ort, geburtsdatum,
geschlecht, nationalitaet, hiorg, start_datum, start_uhrzeit,
ende_datum, ende_uhrzeit, position, qrcode
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
'''
cursor.execute(insert_data_query, (
vorname, nachname, strasse, plz, ort, geburtsdatum,
geschlecht, nationalitaet, hiorg, start_datum, start_uhrzeit,
ende_datum, ende_uhrzeit, position, qrcode
))
conn.commit()
print("Daten eingefügt")
except sqlite3.Error as e:
print("Fehler beim Einfügen von Daten:", e)
finally:
conn.close()
def main():
datenbank_erstellen()
daten_einfuegen(
"Max", "Mustermann", "Musterstraße 123", "12345", "Musterstadt",
"01.01.1990", "männlich", "deutsch", "Deutsches Rotes Kreuz",
"01.01.2024", "08:00", "01.01.2024", "17:00",
"Sanitäter", "ABC123"
)
if __name__ == '__main__':
main()

93
Registrierung.py Normal file
View File

@@ -0,0 +1,93 @@
# Registrierung BY DANIEL SCHLAPA
# Bsp. QRCODE: Mustermann;Max;01.01.1982;m;40000;Musterdorf;deutsch;Musterstrasse;;Düsseldorf;Deutsches Rotes Kreuz ;;;;
# qrcode = "Mustermann;Max;01.01.1982;m;40000;Musterdorf;deutsch;Musterstrasse;;Düsseldorf;Deutsches Rotes Kreuz ;;;;"
import time
import qrcode
# print(time.strftime("%d%H%M%b%y"))
# print(time.strftime("%d.%m.%Y %H:%M:%S"))
"""
try:
<Code, der einen Fehler werfen könnte>
except <Fehlertyp, z.B. ValueError>:
<Fehlerbehandlung>
if ';' in string:
<Mehrere Werte>
else:
<Ein Wert>
"""
def input_code():
scancode = input("Scan den QR-Code: ").strip()
arbeitskartencode = input("Scan den Arbeitskartencode: ").strip()
if ';' in scancode:
kompletter_qrcode = scancode
nachname, vorname, geburtsdatum, geschlecht, plz, ort, nationalitaet, strasse, helferid, _, hiorg, _, _, _, _ = kompletter_qrcode.split(";")
kompletter_name = nachname + ", " + vorname
print("AUSGABE DER DATEN")
print("-----------------\n")
print(f"Kompletter Name: {kompletter_name}")
print("Vorname: " + vorname)
print("Nachname: " + nachname)
print("Straße: " + strasse)
print(f"Postleitzzahl + Ort: {plz} {ort}")
print("Geburtsdatum: " + geburtsdatum)
print("Geschlecht: " + geschlecht)
print("Nationalität: " + nationalitaet)
print("Hilfsorganisation: " + hiorg)
print("Arbeitskartencode:" + arbeitskartencode)
start_datum = time.strftime("%d.%m.%Y")
start_uhrzeit = time.strftime("%H:%M:%S")
print(f"Einsatzbeginn: {start_datum} - {start_uhrzeit}")
else:
print("Code: " + scancode)
return nachname, vorname, geburtsdatum, geschlecht, plz, ort, nationalitaet, strasse, helferid, hiorg, arbeitskartencode
def make_qrcode():
dateinname_qrcode = input("Dateiname: ").strip()
img = qrcode.make('Daniel')
img.save(dateinname_qrcode + ".png")
print("QR-Code " + dateinname_qrcode + ".png" + " wurde erstellt.")
return dateinname_qrcode
def main():
print("""Menü
----
[1] - Einregistrieren
[2] - Ausregistrieren
[3] - QR-Code erstellen
[4] - Test
[5] - Ende""")
while True:
menu_auswahl = int(input("Menüpunkt: "))
if (menu_auswahl == 1):
input_code()
elif (menu_auswahl == 2):
print("SORRY - 2")
elif (menu_auswahl == 3):
make_qrcode()
elif (menu_auswahl == 4):
print("SORRY - 4")
elif (menu_auswahl == 5):
return
else:
print("Auswahl ist ungültig!")
if __name__ == '__main__':
main()

38
Tabelle.py Normal file
View File

@@ -0,0 +1,38 @@
import openpyxl
from openpyxl.styles import Font
def make_tabellen_ueberschrift():
workbook = openpyxl.Workbook()
tabelle1 = workbook.active
tabelle1['A1'] = 'Name'
tabelle1['B1'] = 'Vorname'
tabelle1['C1'] = 'Geburtsdatum'
tabelle1['D1'] = 'Hilfsorganisation'
tabelle1['E1'] = 'PLZ'
tabelle1['F1'] = 'Ort'
tabelle1['G1'] = 'Nationalität'
tabelle1['H1'] = 'Strasse'
tabelle1['I1'] = 'Kommt Datum'
tabelle1['J1'] = 'Kommt Zeit'
tabelle1['K1'] = 'Geht Datum'
tabelle1['L1'] = 'Geht Zeit'
tabelle1['M1'] = 'Position'
tabelle1['N1'] = 'Geschlecht'
schrift_fett = Font(bold=True)
for col in range(1, 15):
cell = tabelle1.cell(row=1, column=col)
cell.font = schrift_fett
workbook.save('Registrierliste.xlsx')
def main():
make_tabellen_ueberschrift()
if __name__ == '__main__':
main()