From e774b41d04bea2c7909901e478fc3f7709edbda6 Mon Sep 17 00:00:00 2001 From: Daniel Schlapa Date: Mon, 13 May 2024 16:08:20 +0200 Subject: [PATCH] Upload --- .flake8 | 8 +++ .gitignore | 148 +++++++++++++++++++++++++++++++++++++++++++++++ Datenbank.py | 80 +++++++++++++++++++++++++ Registrierung.py | 93 +++++++++++++++++++++++++++++ Tabelle.py | 38 ++++++++++++ 5 files changed, 367 insertions(+) create mode 100644 .flake8 create mode 100644 .gitignore create mode 100644 Datenbank.py create mode 100644 Registrierung.py create mode 100644 Tabelle.py diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..3fcfb22 --- /dev/null +++ b/.flake8 @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f937bdb --- /dev/null +++ b/.gitignore @@ -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/ diff --git a/Datenbank.py b/Datenbank.py new file mode 100644 index 0000000..4871f10 --- /dev/null +++ b/Datenbank.py @@ -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() diff --git a/Registrierung.py b/Registrierung.py new file mode 100644 index 0000000..231ea25 --- /dev/null +++ b/Registrierung.py @@ -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: + +except : + + +if ';' in string: + +else: + +""" + + +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() diff --git a/Tabelle.py b/Tabelle.py new file mode 100644 index 0000000..755a2b9 --- /dev/null +++ b/Tabelle.py @@ -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()