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.Layouts
|
||||
|
||||
Item
|
||||
{
|
||||
property int selectedEmployee: -1
|
||||
id: emDet
|
||||
ColumnLayout
|
||||
{
|
||||
Label
|
||||
{
|
||||
text: qsTr("Ausgewählter Mitarbeiter " + selectedEmployee)
|
||||
}
|
||||
Item {
|
||||
property var employee
|
||||
property int row
|
||||
|
||||
Button
|
||||
{
|
||||
onRowChanged: {
|
||||
employee = employee_model.fetchApplicant(row);
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Label {
|
||||
text: qsTr("Ausgewählter Mitarbeiter ") + row
|
||||
}
|
||||
Label {
|
||||
text: employee.postcode ?? ""
|
||||
}
|
||||
Button {
|
||||
text: qsTr("Mitarbeiter zeigen")
|
||||
|
||||
onClicked: contentStack.pop()
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted:
|
||||
{
|
||||
employee_model.onRowClicked(selectedEmployee)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,9 +124,7 @@ ColumnLayout {
|
||||
hoverEnabled: true
|
||||
|
||||
onClicked: {
|
||||
contentStack.push("EmployeeDetails.qml", {
|
||||
selectedEmployee: row
|
||||
});
|
||||
contentStack.push("EmployeeDetails.qml", { row });
|
||||
}
|
||||
onEntered: {
|
||||
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):
|
||||
newEmployeeAdded = Signal(bool)
|
||||
|
||||
__cur = None
|
||||
__all_cols = None
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
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):
|
||||
try:
|
||||
if self.__cur:
|
||||
self.__cur.callproc("getEmployeeTable", (criterion, processed, fired, every_state, enc_key,))
|
||||
self.__all_cols = [desc[0] for desc in self.__cur.description]
|
||||
return self.__cur.fetchall(), self.__all_cols
|
||||
else:
|
||||
return None, None
|
||||
except mariadb.Error as e:
|
||||
print(str(e))
|
||||
cursor = self.__con.cursor()
|
||||
cursor.callproc("getEmployeeTable", (criterion, processed, fired, every_state, enc_key,))
|
||||
self.__all_cols = [desc[0] for desc in cursor.description]
|
||||
result = cursor.fetchall(), self.__all_cols
|
||||
cursor.close()
|
||||
return result
|
||||
|
||||
def getEmployee(self, employee_id, enc_key=None):
|
||||
try:
|
||||
if self.__cur:
|
||||
self.__cur.callproc("getEmployee", (employee_id, enc_key,))
|
||||
# self.__all_cols = [desc[0] for desc in self.__cur.description]
|
||||
return self.__cur.fetchall() # , self.__all_cols
|
||||
else:
|
||||
return None
|
||||
except mariadb.Error as e:
|
||||
print(str(e))
|
||||
def fetchApplicant(self, employee_id, enc_key=None) -> dict:
|
||||
cursor = self.__con.cursor(dictionary=True)
|
||||
cursor.callproc("getApplicant", (employee_id, enc_key))
|
||||
it = cursor.fetchone()
|
||||
cursor.close()
|
||||
return it
|
||||
|
||||
def addEmployee(self, data, enc_key, applicant=True):
|
||||
if self.__cur:
|
||||
self.__cur.callproc("addApplicant", (json.dumps(data), applicant, enc_key,))
|
||||
self.__con.commit()
|
||||
self.newEmployeeAdded.emit(True)
|
||||
cursor = self.__con.cursor()
|
||||
cursor.callproc("addApplicant", (json.dumps(data), applicant, enc_key,))
|
||||
self.__con.commit()
|
||||
cursor.close()
|
||||
self.newEmployeeAdded.emit(True)
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import json
|
||||
|
||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot, Signal, QJsonDocument
|
||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot, Signal
|
||||
from PySide6.QtQml import QJSValue
|
||||
|
||||
from .EmployeeDAO import EmployeeDAO
|
||||
# from ..PyqcrmFlags import PyqcrmFlags, PyqcrmAppliEmpyFlags
|
||||
from ..ConfigLoader import ConfigLoader
|
||||
import re
|
||||
|
||||
@@ -97,13 +94,7 @@ class EmployeeModel(QAbstractTableModel):
|
||||
return self.__col_name
|
||||
return super().headerData(section, orientation, role)
|
||||
|
||||
@Slot(int)
|
||||
def onRowClicked(self, row):
|
||||
# print(self.__data)
|
||||
print(f"Selected table row: {row}, corresponding DB ID: {self.__data[row][0]}")
|
||||
# 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)
|
||||
@Slot(int, result=dict)
|
||||
def fetchApplicant(self, row) -> dict:
|
||||
employee_id = self.__data[row][0]
|
||||
return self.__employee_dao.fetchApplicant(employee_id, self.__key)
|
||||
|
||||
Reference in New Issue
Block a user