Compare commits
2 Commits
9a8be0409a
...
9ea0c94674
| Author | SHA256 | Date | |
|---|---|---|---|
| 9ea0c94674 | |||
| e2fe0c89c0 |
@@ -7,6 +7,7 @@ import "../js/qmldict.js" as JsLib
|
||||
|
||||
ColumnLayout
|
||||
{
|
||||
property var new_business: null
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
spacing: 15
|
||||
@@ -249,24 +250,17 @@ ColumnLayout
|
||||
enabled: false
|
||||
onClicked:
|
||||
{
|
||||
var new_business
|
||||
if (!checkAddContact.checked)
|
||||
{
|
||||
new_business = JsLib.addBusiness(businessGrid)
|
||||
business_model.addBusiness(new_business)
|
||||
business_model.addBusiness(new_business, 0)
|
||||
appLoader.source = "CustomerTable.qml"
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log("Contact available")
|
||||
var contact_id = 0
|
||||
new_business = JsLib.addBusiness(businessGrid)
|
||||
var new_contact = JsLib.addBusiness(addContactLayout)
|
||||
// bm.setContact(new_contact, contact_id)
|
||||
// bm.addBusiness(new_business, contact_id)
|
||||
contact_id = contact_model.addContact(new_contact)
|
||||
console.log(contact_id)
|
||||
appLoader.source = "CustomerTable.qml"
|
||||
contact_model.addContact(new_contact)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,6 +272,7 @@ ColumnLayout
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
Component.onCompleted: contact_model.contactIdReady.connect(onContactId)
|
||||
|
||||
function isEmptyField()
|
||||
{
|
||||
@@ -294,5 +289,9 @@ ColumnLayout
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function onContactId(con_id)
|
||||
{
|
||||
business_model.addBusiness(new_business, con_id)// bm
|
||||
appLoader.source = "CustomerTable.qml"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ Item {
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: 40
|
||||
movableColumns: true //@disable-check M16
|
||||
syncView: testTable
|
||||
syncView: customerTable
|
||||
|
||||
delegate: Rectangle {
|
||||
color: addBusinessBtn.palette.alternateBase
|
||||
@@ -99,7 +99,7 @@ Item {
|
||||
{
|
||||
//property var customWidths: [0.2, 0.5, 0.3, 05, 0.2, 0.2]
|
||||
property real newWidth: 0
|
||||
id: testTable
|
||||
id: customerTable
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
columnSpacing: 1
|
||||
@@ -111,7 +111,7 @@ Item {
|
||||
selectionModel: ItemSelectionModel
|
||||
{
|
||||
id: selModel
|
||||
model: testTable.model
|
||||
model: customerTable.model
|
||||
}
|
||||
|
||||
// columnWidthProvider: function(column)
|
||||
@@ -137,7 +137,7 @@ Item {
|
||||
repeat: false
|
||||
onTriggered:
|
||||
{
|
||||
testTable.forceLayout();
|
||||
customerTable.forceLayout();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,11 +147,11 @@ Item {
|
||||
{
|
||||
required property bool selected
|
||||
required property bool current
|
||||
implicitWidth: testTable.width / testTable.columns
|
||||
implicitWidth: customerTable.width / customerTable.columns
|
||||
implicitHeight: 25
|
||||
color: selected
|
||||
? addBusinessBtn.palette.highlight //palette.highlight
|
||||
: (testTable.alternatingRows && row % 2 !== 0
|
||||
: (customerTable.alternatingRows && row % 2 !== 0
|
||||
? addBusinessBtn.palette.base // palette.base
|
||||
: addBusinessBtn.palette.alternateBase) //palette.alternateBase)
|
||||
|
||||
@@ -178,7 +178,7 @@ Item {
|
||||
}
|
||||
onEntered:
|
||||
{
|
||||
testTable.selectionModel.select(testTable.model.index(row, 0), ItemSelectionModel.SelectCurrent | ItemSelectionModel.Rows)
|
||||
customerTable.selectionModel.select(customerTable.model.index(row, 0), ItemSelectionModel.SelectCurrent | ItemSelectionModel.Rows)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,9 @@ class BusinessDAO:
|
||||
self.__all_cols = [desc[0] for desc in self.__cur.description]
|
||||
return self.__cur.fetchall(), self.__all_cols
|
||||
|
||||
def addBusiness(self, data):
|
||||
def addBusiness(self, data, contact_id):
|
||||
try:
|
||||
print(data)
|
||||
self.__cur.callproc("addBusiness", (json.dumps(data),))
|
||||
self.__cur.callproc("addBusiness", (json.dumps(data), contact_id))
|
||||
self.__con.commit()
|
||||
|
||||
except mariadb.Error as e:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# This Python file uses the following encoding: utf-8
|
||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot
|
||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot, Signal
|
||||
from .BusinessDAO import BusinessDAO
|
||||
|
||||
# USERS TABLE
|
||||
@@ -106,11 +106,10 @@ class BusinessModel(QAbstractTableModel):
|
||||
def onRowClicked(self, row):
|
||||
print(row)
|
||||
|
||||
@Slot(dict)
|
||||
def addBusiness(self, business):
|
||||
BusinessDAO().addBusiness(business)
|
||||
#BusinessDAO().addPlz()
|
||||
|
||||
@Slot(dict, int)
|
||||
def addBusiness(self, business, contact_id):
|
||||
BusinessDAO().addBusiness(business, contact_id)
|
||||
self.__data = self.__getData()
|
||||
|
||||
@Slot(dict)
|
||||
def setContact(self, contact):
|
||||
|
||||
@@ -14,12 +14,14 @@ class ContactDAO:
|
||||
|
||||
def addContact(self, contact):
|
||||
try:
|
||||
contact_id = self.__cur.callproc("addContactPerson", (contact, 0, ))
|
||||
self.__cur.callproc("addContactPerson", (json.dumps(contact),))
|
||||
self.__con.commit()
|
||||
return contact_id[1]
|
||||
#except mariadb.Error as e:
|
||||
#print(str (e))
|
||||
self.__cur.callproc("getLastInsertId")
|
||||
contact_id = self.__cur.fetchone()
|
||||
return contact_id[0]
|
||||
except mariadb.Error as e:
|
||||
print("MDB: " + str(e))
|
||||
except Exception as e:
|
||||
print(str (e))
|
||||
print("PYT: " + str(e))
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot, QObject
|
||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot, QObject, Signal
|
||||
from .ContactDAO import ContactDAO
|
||||
import logging
|
||||
import json
|
||||
|
||||
class ContactModel(QObject):
|
||||
contactIdReady = Signal(int)
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
#self.logger = logging.getLogger()
|
||||
@@ -21,8 +21,8 @@ class ContactModel(QObject):
|
||||
|
||||
@Slot(dict)
|
||||
def addContact(self, contact):
|
||||
addC = ContactDAO()
|
||||
j = json.dumps(contact)
|
||||
a = addC.addContact(j)
|
||||
return a
|
||||
i = ContactDAO().addContact(contact)
|
||||
self.contactIdReady.emit(i)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user