Fetch applicant from database
This commit is contained in:
6
.idea/sqldialects.xml
generated
Normal file
6
.idea/sqldialects.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="SqlDialectMappings">
|
||||||
|
<file url="file://$PROJECT_DIR$/doc/db_schemer_v1.1-pyqcrm-202503171158_clean.sql" dialect="MariaDB" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -2,26 +2,25 @@ import QtQuick
|
|||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
Item
|
Item {
|
||||||
{
|
property var employee
|
||||||
property int selectedEmployee: -1
|
property int row
|
||||||
id: emDet
|
|
||||||
ColumnLayout
|
onRowChanged: {
|
||||||
{
|
employee = employee_model.fetchApplicant(row);
|
||||||
Label
|
|
||||||
{
|
|
||||||
text: qsTr("Ausgewählter Mitarbeiter " + selectedEmployee)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Button
|
ColumnLayout {
|
||||||
{
|
Label {
|
||||||
|
text: qsTr("Ausgewählter Mitarbeiter ") + row
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
text: employee.postcode ?? ""
|
||||||
|
}
|
||||||
|
Button {
|
||||||
text: qsTr("Mitarbeiter zeigen")
|
text: qsTr("Mitarbeiter zeigen")
|
||||||
|
|
||||||
onClicked: contentStack.pop()
|
onClicked: contentStack.pop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted:
|
|
||||||
{
|
|
||||||
employee_model.onRowClicked(selectedEmployee)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,9 +124,7 @@ ColumnLayout {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
contentStack.push("EmployeeDetails.qml", {
|
contentStack.push("EmployeeDetails.qml", { row });
|
||||||
selectedEmployee: row
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
onEntered: {
|
onEntered: {
|
||||||
employeesTable.selectionModel.select(employeesTable.model.index(row, 0), ItemSelectionModel.SelectCurrent | ItemSelectionModel.Rows);
|
employeesTable.selectionModel.select(employeesTable.model.index(row, 0), ItemSelectionModel.SelectCurrent | ItemSelectionModel.Rows);
|
||||||
|
|||||||
@@ -6,40 +6,30 @@ from PySide6.QtCore import QObject, Signal
|
|||||||
|
|
||||||
class EmployeeDAO(QObject):
|
class EmployeeDAO(QObject):
|
||||||
newEmployeeAdded = Signal(bool)
|
newEmployeeAdded = Signal(bool)
|
||||||
|
|
||||||
__cur = None
|
|
||||||
__all_cols = None
|
__all_cols = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.__con = DbManager().getConnection()
|
self.__con = DbManager().getConnection()
|
||||||
if self.__con:
|
|
||||||
self.__cur = self.__con.cursor()
|
|
||||||
|
|
||||||
def getEmployees(self, enc_key, criterion="Alle", processed=False, fired=False, every_state=True):
|
def getEmployees(self, enc_key, criterion="Alle", processed=False, fired=False, every_state=True):
|
||||||
try:
|
cursor = self.__con.cursor()
|
||||||
if self.__cur:
|
cursor.callproc("getEmployeeTable", (criterion, processed, fired, every_state, enc_key,))
|
||||||
self.__cur.callproc("getEmployeeTable", (criterion, processed, fired, every_state, enc_key,))
|
self.__all_cols = [desc[0] for desc in cursor.description]
|
||||||
self.__all_cols = [desc[0] for desc in self.__cur.description]
|
result = cursor.fetchall(), self.__all_cols
|
||||||
return self.__cur.fetchall(), self.__all_cols
|
cursor.close()
|
||||||
else:
|
return result
|
||||||
return None, None
|
|
||||||
except mariadb.Error as e:
|
|
||||||
print(str(e))
|
|
||||||
|
|
||||||
def getEmployee(self, employee_id, enc_key=None):
|
def fetchApplicant(self, employee_id, enc_key=None) -> dict:
|
||||||
try:
|
cursor = self.__con.cursor(dictionary=True)
|
||||||
if self.__cur:
|
cursor.callproc("getApplicant", (employee_id, enc_key))
|
||||||
self.__cur.callproc("getEmployee", (employee_id, enc_key,))
|
it = cursor.fetchone()
|
||||||
# self.__all_cols = [desc[0] for desc in self.__cur.description]
|
cursor.close()
|
||||||
return self.__cur.fetchall() # , self.__all_cols
|
return it
|
||||||
else:
|
|
||||||
return None
|
|
||||||
except mariadb.Error as e:
|
|
||||||
print(str(e))
|
|
||||||
|
|
||||||
def addEmployee(self, data, enc_key, applicant=True):
|
def addEmployee(self, data, enc_key, applicant=True):
|
||||||
if self.__cur:
|
cursor = self.__con.cursor()
|
||||||
self.__cur.callproc("addApplicant", (json.dumps(data), applicant, enc_key,))
|
cursor.callproc("addApplicant", (json.dumps(data), applicant, enc_key,))
|
||||||
self.__con.commit()
|
self.__con.commit()
|
||||||
|
cursor.close()
|
||||||
self.newEmployeeAdded.emit(True)
|
self.newEmployeeAdded.emit(True)
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import json
|
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot, Signal
|
||||||
|
|
||||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot, Signal, QJsonDocument
|
|
||||||
from PySide6.QtQml import QJSValue
|
from PySide6.QtQml import QJSValue
|
||||||
|
|
||||||
from .EmployeeDAO import EmployeeDAO
|
from .EmployeeDAO import EmployeeDAO
|
||||||
# from ..PyqcrmFlags import PyqcrmFlags, PyqcrmAppliEmpyFlags
|
|
||||||
from ..ConfigLoader import ConfigLoader
|
from ..ConfigLoader import ConfigLoader
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@@ -97,13 +94,7 @@ class EmployeeModel(QAbstractTableModel):
|
|||||||
return self.__col_name
|
return self.__col_name
|
||||||
return super().headerData(section, orientation, role)
|
return super().headerData(section, orientation, role)
|
||||||
|
|
||||||
@Slot(int)
|
@Slot(int, result=dict)
|
||||||
def onRowClicked(self, row):
|
def fetchApplicant(self, row) -> dict:
|
||||||
# print(self.__data)
|
employee_id = self.__data[row][0]
|
||||||
print(f"Selected table row: {row}, corresponding DB ID: {self.__data[row][0]}")
|
return self.__employee_dao.fetchApplicant(employee_id, self.__key)
|
||||||
# if not self.__employee_dict['employee'] or self.__data[row][0] != self.__employee_dict['employee']['id']:
|
|
||||||
# self.__employee = self.__employee_dao.getEmployee(self.__data[row][0], self.__key)
|
|
||||||
# print(self.__business)
|
|
||||||
# self.__getEmployeeInfo()
|
|
||||||
# self.__getContactInfo()
|
|
||||||
# print(self.__business_dict)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user