.
This commit is contained in:
@@ -267,6 +267,30 @@ bool cPartEditDialog::add()
|
||||
|
||||
m_id = query.value("id").toInt();
|
||||
|
||||
for(int x = 0;x < m_lpPartDistributorListModel->rowCount();x++)
|
||||
{
|
||||
QStandardItem* lpItemName = m_lpPartDistributorListModel->itemFromIndex(m_lpPartDistributorListModel->index(x, 0));
|
||||
QStandardItem* lpItemDistributor = m_lpPartDistributorListModel->itemFromIndex(m_lpPartDistributorListModel->index(x, 1));
|
||||
QStandardItem* lpItemPrice = m_lpPartDistributorListModel->itemFromIndex(m_lpPartDistributorListModel->index(x, 2));
|
||||
QStandardItem* lpItemDescription = m_lpPartDistributorListModel->itemFromIndex(m_lpPartDistributorListModel->index(x, 3));
|
||||
QStandardItem* lpItemLink = m_lpPartDistributorListModel->itemFromIndex(m_lpPartDistributorListModel->index(x, 4));
|
||||
|
||||
QSqlQuery query;
|
||||
query.prepare("INSERT INTO part_distributor (name, description, partID, distributorID, price, link) VALUES (:name, :description, :partID, :distributorID, :price, :lin);");
|
||||
query.bindValue(":name", lpItemName->text());
|
||||
query.bindValue(":description", lpItemDescription->text());
|
||||
query.bindValue(":partID", m_id);
|
||||
query.bindValue(":distributorID", m_lpDistributorList->find(lpItemDistributor->text())->id());
|
||||
query.bindValue(":price", lpItemPrice->text().toDouble());
|
||||
query.bindValue(":link", lpItemLink->text());
|
||||
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@@ -390,4 +414,12 @@ void cPartEditDialog::onEditDistributor()
|
||||
|
||||
void cPartEditDialog::onDeleteDistributor()
|
||||
{
|
||||
QStandardItem* lpItem = m_lpPartDistributorListModel->itemFromIndex(ui->m_lpPartDistributorList->selectionModel()->selectedRows().at(0));
|
||||
if(!lpItem)
|
||||
return;
|
||||
|
||||
if(QMessageBox::question(this, "DELETE", QString("Are you sure to delete this entry?")) == QMessageBox::No)
|
||||
return;
|
||||
|
||||
m_lpPartDistributorListModel->removeRow(lpItem->row());
|
||||
}
|
||||
|
||||
+1
-19
@@ -174,25 +174,7 @@ void cPartWindow::onAdd()
|
||||
delete lpDialog;
|
||||
|
||||
partChanged(0);
|
||||
showPartList();
|
||||
|
||||
for(int x = 0;x < m_lpPartListModel->rowCount();x++)
|
||||
{
|
||||
QStandardItem* lpItem = m_lpPartListModel->item(x, 0);
|
||||
if(!lpItem)
|
||||
continue;
|
||||
|
||||
cPart* lpPart = qvariant_cast<cPart*>(lpItem->data(Qt::UserRole));
|
||||
if(!lpPart)
|
||||
continue;
|
||||
|
||||
if(lpPart->id() == id)
|
||||
{
|
||||
ui->m_lpPartList->setCurrentIndex(lpItem->index());
|
||||
ui->m_lpPartList->scrollTo(lpItem->index());
|
||||
return;
|
||||
}
|
||||
}
|
||||
showPartList(id);
|
||||
}
|
||||
|
||||
void cPartWindow::onEdit()
|
||||
|
||||
Reference in New Issue
Block a user