itemListPrice::itemListPrice(QWidget* parent, const char* name, bool modal, Qt::WFlags fl) : XDialog(parent, name, modal, fl) { setupUi(this); connect(_close, SIGNAL(clicked()), this, SLOT(reject())); connect(_save, SIGNAL(clicked()), this, SLOT(sSave())); connect(_item, SIGNAL(valid(bool)), _save, SLOT(setEnabled(bool))); connect(_item, SIGNAL(newId(int)), this, SLOT(sPopulate())); connect(_listPrice, SIGNAL(lostFocus()), this, SLOT(sUpdateMargins())); _item->setType(ItemLineEdit::cSold); _listPrice->setValidator(omfgThis->priceVal()); _extPrice->setPrecision(omfgThis->priceVal()); _stdCost->setPrecision(omfgThis->costVal()); _actCost->setPrecision(omfgThis->costVal()); _extStdCost->setPrecision(omfgThis->costVal()); _extActCost->setPrecision(omfgThis->costVal()); _stdMargin->setPrecision(omfgThis->percentVal()); _actMargin->setPrecision(omfgThis->percentVal()); _pricingRatio->setPrecision(omfgThis->percentVal()); if (!_privileges->check("MaintainListPrices")) { _listPrice->setEnabled(FALSE); _close->setText(tr("&Close")); _save->hide(); } }
void itemListPrice::sPopulate() { q.prepare( "SELECT uom_name, iteminvpricerat(item_id) AS invpriceratio," " item_listprice," " (item_listprice / iteminvpricerat(item_id)) AS extprice," " stdCost(item_id) AS standardcost," " actCost(item_id) AS actualcost," " (stdCost(item_id) * iteminvpricerat(item_id)) AS extstandardcost," " (actCost(item_id) * iteminvpricerat(item_id)) AS extactualcost " "FROM item JOIN uom ON (item_price_uom_id=uom_id)" "WHERE (item_id=:item_id);" ); q.bindValue(":item_id", _item->id()); q.exec(); if (q.first()) { _cachedRatio = q.value("invpriceratio").toDouble(); _cachedStdCost = q.value("standardcost").toDouble(); _cachedActCost = q.value("actualcost").toDouble(); _listPrice->setDouble(q.value("item_listprice").toDouble()); _priceUOM->setText(q.value("uom_name").toString()); _pricingRatio->setDouble(q.value("invpriceratio").toDouble()); _extPrice->setDouble(q.value("extprice").toDouble()); _stdCost->setDouble(q.value("standardcost").toDouble()); _actCost->setDouble(q.value("actualcost").toDouble()); _extStdCost->setDouble(q.value("extstandardcost").toDouble()); _extActCost->setDouble(q.value("extactualcost").toDouble()); } sUpdateMargins(); }
void itemPricingScheduleItem::populate() { if(_itemSelected->isChecked()) { q.prepare( "SELECT ipsitem_item_id," " ipsitem_qtybreak, ipsitem_price " "FROM ipsitem " "WHERE (ipsitem_id=:ipsitem_id);" ); q.bindValue(":ipsitem_id", _ipsitemid); q.exec(); if (q.first()) { _item->setId(q.value("ipsitem_item_id").toInt()); _qtyBreak->setText(formatQty(q.value("ipsitem_qtybreak").toDouble())); _price->setLocalValue(q.value("ipsitem_price").toDouble()); sUpdateMargins(); } } else { q.prepare( "SELECT ipsprodcat_prodcat_id," " ipsprodcat_qtybreak, ipsprodcat_discntprcnt " "FROM ipsprodcat " "WHERE (ipsprodcat_id=:ipsprodcat_id);" ); q.bindValue(":ipsprodcat_id", _ipsprodcatid); q.exec(); if (q.first()) { _prodcat->setId(q.value("ipsprodcat_prodcat_id").toInt()); _qtyBreakCat->setText(formatQty(q.value("ipsprodcat_qtybreak").toDouble())); _discount->setText(formatPercent(q.value("ipsprodcat_discntprcnt").toDouble())); } } }
void itemPricingScheduleItem::sPriceUOMChanged() { if(_priceUOM->id() == -1 || _qtyUOM->id() == -1) return; XSqlQuery cost; cost.prepare( "SELECT " " formatUOMRatio(itemuomtouomratio(item_id, :qtyuomid, :priceuomid)) AS f_ratio," " ((item_listprice / iteminvpricerat(item_id)) * itemuomtouomratio(item_id, :priceuomid, item_inv_uom_id)) AS listprice, " " (stdcost(item_id) * itemuomtouomratio(item_id, :priceuomid, item_inv_uom_id)) AS standard," " (actcost(item_id, :curr_id) * itemuomtouomratio(item_id, :priceuomid, item_inv_uom_id)) AS actual " " FROM item" " WHERE (item_id=:item_id);" ); cost.bindValue(":item_id", _item->id()); cost.bindValue(":curr_id", _actCost->id()); cost.bindValue(":qtyuomid", _qtyUOM->id()); cost.bindValue(":priceuomid", _priceUOM->id()); cost.exec(); if (cost.first()) { _listPrice->setBaseValue(cost.value("listprice").toDouble()); _pricingRatio->setText(cost.value("f_ratio").toString()); _stdCost->setBaseValue(cost.value("standard").toDouble()); _actCost->setLocalValue(cost.value("actual").toDouble()); sUpdateMargins(); } }
/* * Constructs a itemPricingScheduleItem as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * * The dialog will by default be modeless, unless you set 'modal' to * true to construct a modal dialog. */ itemPricingScheduleItem::itemPricingScheduleItem(QWidget* parent, const char* name, bool modal, Qt::WFlags fl) : QDialog(parent, name, modal, fl) { setupUi(this); // signals and slots connections connect(_close, SIGNAL(clicked()), this, SLOT(reject())); connect(_save, SIGNAL(clicked()), this, SLOT(sSave())); connect(_item, SIGNAL(valid(bool)), _save, SLOT(setEnabled(bool))); connect(_item, SIGNAL(newId(int)), this, SLOT(sUpdateCosts(int))); connect(_price, SIGNAL(idChanged(int)), _actCost, SLOT(setId(int))); connect(_price, SIGNAL(idChanged(int)), _stdCost, SLOT(setId(int))); connect(_price, SIGNAL(idChanged(int)), _listPrice, SLOT(setId(int))); connect(_price, SIGNAL(effectiveChanged(const QDate&)), _actCost, SLOT(setEffective(const QDate&))); connect(_price, SIGNAL(effectiveChanged(const QDate&)), _stdCost, SLOT(setEffective(const QDate&))); connect(_price, SIGNAL(effectiveChanged(const QDate&)), _listPrice, SLOT(setEffective(const QDate&))); connect(_price, SIGNAL(valueChanged()), this, SLOT(sUpdateMargins())); connect(_itemSelected, SIGNAL(toggled(bool)), this, SLOT(sTypeChanged())); connect(_qtyUOM, SIGNAL(newID(int)), this, SLOT(sQtyUOMChanged())); connect(_priceUOM, SIGNAL(newID(int)), this, SLOT(sPriceUOMChanged())); _ipsheadid = -1; _ipsitemid = -1; _ipsprodcatid = -1; _invuomid = -1; _qtyBreak->setValidator(omfgThis->qtyVal()); _qtyBreakCat->setValidator(omfgThis->qtyVal()); _discount->setValidator(omfgThis->percentVal()); _item->setType(ItemLineEdit::cSold); _prodcat->setType(XComboBox::ProductCategories); }
/* * Constructs a itemPricingScheduleItem as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * * The dialog will by default be modeless, unless you set 'modal' to * true to construct a modal dialog. */ itemPricingScheduleItem::itemPricingScheduleItem(QWidget* parent, const char* name, bool modal, Qt::WFlags fl) : QDialog(parent, name, modal, fl) { setupUi(this); // signals and slots connections connect(_close, SIGNAL(clicked()), this, SLOT(reject())); connect(_save, SIGNAL(clicked()), this, SLOT(sSave())); connect(_item, SIGNAL(valid(bool)), _save, SLOT(setEnabled(bool))); connect(_item, SIGNAL(newId(int)), this, SLOT(sUpdateCosts(int))); connect(_price, SIGNAL(idChanged(int)), _actCost, SLOT(setId(int))); connect(_price, SIGNAL(idChanged(int)), _stdCost, SLOT(setId(int))); connect(_price, SIGNAL(idChanged(int)), _listPrice, SLOT(setId(int))); connect(_price, SIGNAL(effectiveChanged(const QDate&)), _actCost, SLOT(setEffective(const QDate&))); connect(_price, SIGNAL(effectiveChanged(const QDate&)), _stdCost, SLOT(setEffective(const QDate&))); connect(_price, SIGNAL(effectiveChanged(const QDate&)), _listPrice, SLOT(setEffective(const QDate&))); connect(_price, SIGNAL(valueChanged()), this, SLOT(sUpdateMargins())); connect(_itemSelected, SIGNAL(toggled(bool)), this, SLOT(sTypeChanged())); init(); }
void itemPricingScheduleItem::populate() { XSqlQuery itempopulate; if(_freightSelected->isChecked()) { MetaSQLQuery mql = mqlLoad("pricingFreight", "detail"); ParameterList params; params.append("ipsfreight_id", _ipsfreightid); itempopulate = mql.toQuery(params); if (itempopulate.first()) { _ipsheadid=itempopulate.value("ipsfreight_ipshead_id").toInt(); _qtyBreakFreight->setDouble(itempopulate.value("ipsfreight_qtybreak").toDouble()); _priceFreight->setLocalValue(itempopulate.value("ipsfreight_price").toDouble()); if (itempopulate.value("ipsfreight_type").toString() == "F") { _flatRateFreight->setChecked(true); _qtyBreakFreight->setEnabled(false); } else _perUOMFreight->setChecked(true); if (itempopulate.value("ipsfreight_warehous_id").toInt() > 0) _siteFreight->setId(itempopulate.value("ipsfreight_warehous_id").toInt()); else _siteFreight->setAll(); if (itempopulate.value("ipsfreight_shipzone_id").toInt() > 0) { _selectedZoneFreight->setChecked(true); _zoneFreight->setId(itempopulate.value("ipsfreight_shipzone_id").toInt()); } else _allZonesFreight->setChecked(true); if (itempopulate.value("ipsfreight_freightclass_id").toInt() > 0) { _selectedFreightClass->setChecked(true); _freightClass->setId(itempopulate.value("ipsfreight_freightclass_id").toInt()); } else _allFreightClasses->setChecked(true); // Handle the free-form Ship Via _shipViaFreight->setCurrentIndex(-1); QString shipvia = itempopulate.value("ipsfreight_shipvia").toString(); if (shipvia.trimmed().length() != 0) { _selectedShipViaFreight->setChecked(true); for (int counter = 0; counter < _shipViaFreight->count(); counter++) if (_shipViaFreight->itemText(counter) == shipvia) _shipViaFreight->setCurrentIndex(counter); if (_shipViaFreight->id() == -1) { _shipViaFreight->addItem(shipvia); _shipViaFreight->setCurrentIndex(_shipViaFreight->count() - 1); } } else _allShipViasFreight->setChecked(true); } else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Pricing Schedule Information"), itempopulate, __FILE__, __LINE__)) { done(-1); } } else { itempopulate.prepare( "SELECT * " "FROM ipsiteminfo " "WHERE (ipsitem_id=:ipsitem_id);" ); itempopulate.bindValue(":ipsitem_id", _ipsitemid); itempopulate.exec(); if (itempopulate.first()) { if(itempopulate.value("ipsitem_type").toString() == "D") _discountSelected->setChecked(true); else if(itempopulate.value("ipsitem_type").toString() == "M") _markupSelected->setChecked(true); else _itemSelected->setChecked(true); if (itempopulate.value("ipsitem_item_id").toInt() > 0) { if(itempopulate.value("ipsitem_type").toString() == "D") _dscbyItem->setChecked(true); else if(itempopulate.value("ipsitem_type").toString() == "M") _markupbyItem->setChecked(true); } else { if(itempopulate.value("ipsitem_type").toString() == "D") _dscbyprodcat->setChecked(true); else if(itempopulate.value("ipsitem_type").toString() == "M") _markupbyprodcat->setChecked(true); } _ipsheadid=itempopulate.value("ipsitem_ipshead_id").toInt(); // Nominal _item->setId(itempopulate.value("ipsitem_item_id").toInt()); _qtyBreak->setDouble(itempopulate.value("ipsitem_qtybreak").toDouble()); _price->setLocalValue(itempopulate.value("ipsitem_price").toDouble()); _qtyUOM->setId(itempopulate.value("ipsitem_qty_uom_id").toInt()); _priceUOM->setId(itempopulate.value("ipsitem_price_uom_id").toInt()); // Discount _dscitem->setId(itempopulate.value("ipsitem_item_id").toInt()); _prodcat->setId(itempopulate.value("ipsitem_prodcat_id").toInt()); _qtyBreakCat->setDouble(itempopulate.value("ipsitem_qtybreak").toDouble()); _discount->setDouble(itempopulate.value("ipsitem_discntprcnt").toDouble() * 100.0); _fixedAmtDiscount->setDouble(itempopulate.value("ipsitem_fixedamtdiscount").toDouble()); // Markup _markupitem->setId(itempopulate.value("ipsitem_item_id").toInt()); _markupProdcat->setId(itempopulate.value("ipsitem_prodcat_id").toInt()); _markupQtyBreakCat->setDouble(itempopulate.value("ipsitem_qtybreak").toDouble()); _markup->setDouble(itempopulate.value("ipsitem_discntprcnt").toDouble() * 100.0); _fixedAmtMarkup->setDouble(itempopulate.value("ipsitem_fixedamtdiscount").toDouble()); sUpdateMargins(); } else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Pricing Schedule Information"), itempopulate, __FILE__, __LINE__)) { done(-1); } } sFillList(); }
itemPricingScheduleItem::itemPricingScheduleItem(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl) : XDialog(parent, name, modal, fl) { XSqlQuery itemitemPricingScheduleItem; setupUi(this); _save = _buttonBox->button(QDialogButtonBox::Save); _save->setEnabled(false); connect(_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(_buttonBox, SIGNAL(accepted()), this, SLOT(sSave())); connect(_item, SIGNAL(newId(int)), this, SLOT(sUpdateCosts(int))); connect(_price, SIGNAL(idChanged(int)), _actCost, SLOT(setId(int))); connect(_price, SIGNAL(idChanged(int)), _stdCost, SLOT(setId(int))); connect(_price, SIGNAL(idChanged(int)), _listPrice, SLOT(setId(int))); connect(_price, SIGNAL(effectiveChanged(const QDate&)), _actCost, SLOT(setEffective(const QDate&))); connect(_price, SIGNAL(effectiveChanged(const QDate&)), _stdCost, SLOT(setEffective(const QDate&))); connect(_price, SIGNAL(effectiveChanged(const QDate&)), _listPrice, SLOT(setEffective(const QDate&))); connect(_price, SIGNAL(valueChanged()), this, SLOT(sUpdateMargins())); connect(_itemSelected, SIGNAL(toggled(bool)), this, SLOT(sTypeChanged(bool))); connect(_discountSelected, SIGNAL(toggled(bool)), this, SLOT(sTypeChanged(bool))); connect(_markupSelected, SIGNAL(toggled(bool)), this, SLOT(sTypeChanged(bool))); connect(_freightSelected, SIGNAL(toggled(bool)), this, SLOT(sTypeChanged(bool))); connect(_qtyUOM, SIGNAL(newID(int)), this, SLOT(sQtyUOMChanged())); connect(_priceUOM, SIGNAL(newID(int)), this, SLOT(sPriceUOMChanged())); connect(_new, SIGNAL(clicked()), this, SLOT(sNew())); connect(_edit, SIGNAL(clicked()), this, SLOT(sEdit())); connect(_delete, SIGNAL(clicked()), this, SLOT(sDelete())); connect(_dscbyItem, SIGNAL(toggled(bool)), this, SLOT(sCheckEnable())); connect(_dscbyprodcat, SIGNAL(toggled(bool)), this, SLOT(sCheckEnable())); connect(_markupbyItem, SIGNAL(toggled(bool)), this, SLOT(sCheckEnable())); connect(_markupbyprodcat, SIGNAL(toggled(bool)), this, SLOT(sCheckEnable())); connect(_item, SIGNAL(valid(bool)), this, SLOT(sCheckEnable())); connect(_dscitem, SIGNAL(valid(bool)), this, SLOT(sCheckEnable())); connect(_markupitem, SIGNAL(valid(bool)), this, SLOT(sCheckEnable())); connect(_prodcat, SIGNAL(valid(bool)), this, SLOT(sCheckEnable())); connect(_markupProdcat, SIGNAL(valid(bool)), this, SLOT(sCheckEnable())); _ipsheadid = -1; _ipsitemid = -1; _ipsfreightid = -1; _invuomid = -1; _listpricesched = false; _charprice->addColumn(tr("Characteristic"), _itemColumn, Qt::AlignLeft, true, "char_name" ); _charprice->addColumn(tr("Value"), -1, Qt::AlignLeft, true, "ipsitemchar_value" ); _charprice->addColumn(tr("Price"), _priceColumn,Qt::AlignRight, true, "ipsitemchar_price" ); _qtyBreak->setValidator(omfgThis->qtyVal()); _qtyBreakCat->setValidator(omfgThis->qtyVal()); _markupQtyBreakCat->setValidator(omfgThis->qtyVal()); _qtyBreakFreight->setValidator(omfgThis->weightVal()); _discount->setValidator(new XDoubleValidator(-999, 999, decimalPlaces("percent"), this)); _fixedAmtDiscount->setValidator(omfgThis->negMoneyVal()); _markup->setValidator(new XDoubleValidator(-999, 999, decimalPlaces("percent"), this)); _fixedAmtMarkup->setValidator(omfgThis->negMoneyVal()); _pricingRatio->setPrecision(omfgThis->percentVal()); _stdMargin->setPrecision(omfgThis->percentVal()); _actMargin->setPrecision(omfgThis->percentVal()); _item->setType(ItemLineEdit::cSold | ItemLineEdit::cActive); _zoneFreight->setType(XComboBox::ShippingZones); _shipViaFreight->setType(XComboBox::ShipVias); _freightClass->setType(XComboBox::FreightClasses); _tab->setTabEnabled(_tab->indexOf(_configuredPrices),false); itemitemPricingScheduleItem.exec("SELECT uom_name FROM uom WHERE (uom_item_weight);"); if (itemitemPricingScheduleItem.first()) { QString uom = itemitemPricingScheduleItem.value("uom_name").toString(); QString title (tr("Price per ")); title += uom; _perUOMFreight->setText(title); _qtyBreakFreightUOM->setText(uom); } if (_metrics->boolean("WholesalePriceCosting")) _markupLit->setText(tr("Markup Percent (Wholesale Price):")); else _markupLit->setText(tr("Markup Percent (Inventory Cost):")); /* Not used anywhere in the code _rejectedMsg = tr("The application has encountered an error and must " "stop editing this Pricing Schedule.\n%1"); */ }
void itemPricingScheduleItem::sPriceUOMChanged() { if(_priceUOM->id() == -1 || _qtyUOM->id() == -1) return; // Check for Global UOM Conversion that must be setup for Item if (_priceUOM->code() == "G") { if (QMessageBox::question(this, tr("Use Global UOM?"), tr("<p>This Global UOM Conversion is not setup for this Item." "<p>Do you want to add this UOM conversion to this Item?"), QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape) == QMessageBox::Yes) { XSqlQuery adduom; adduom.prepare("SELECT createItemUomConv(:item_id, :uom_id, :uom_type) AS result;"); adduom.bindValue(":item_id", _item->id()); adduom.bindValue(":uom_id", _priceUOM->id()); adduom.bindValue(":uom_type", "Selling"); adduom.exec(); if (ErrorReporter::error(QtCriticalMsg, this, tr("Creating Item UOM Conv"), adduom, __FILE__, __LINE__)) return; // repopulate uom comboboxes sPopulateUOM(); } else { _priceUOM->setId(_invuomid); } } XSqlQuery cost; cost.prepare( "SELECT " " itemuomtouomratio(item_id, :qtyuomid, :priceuomid) AS ratio," " ((item_listprice / iteminvpricerat(item_id)) * itemuomtouomratio(item_id, :priceuomid, item_inv_uom_id)) AS listprice, " " ((listPrice(item_id) / iteminvpricerat(item_id)) * itemuomtouomratio(item_id, :priceuomid, item_inv_uom_id)) AS schedlistprice, " " (stdcost(item_id) * itemuomtouomratio(item_id, :priceuomid, item_inv_uom_id)) AS standard," " (actcost(item_id, :curr_id) * itemuomtouomratio(item_id, :priceuomid, item_inv_uom_id)) AS actual " " FROM item" " WHERE (item_id=:item_id);" ); cost.bindValue(":item_id", _item->id()); cost.bindValue(":curr_id", _actCost->id()); cost.bindValue(":qtyuomid", _qtyUOM->id()); cost.bindValue(":priceuomid", _priceUOM->id()); cost.exec(); if (cost.first()) { if (_listpricesched) _listPrice->setBaseValue(cost.value("listprice").toDouble()); else _listPrice->setBaseValue(cost.value("schedlistprice").toDouble()); _pricingRatio->setDouble(cost.value("ratio").toDouble()); _stdCost->setBaseValue(cost.value("standard").toDouble()); _actCost->setLocalValue(cost.value("actual").toDouble()); sUpdateMargins(); } else if (ErrorReporter::error(QtCriticalMsg, this, tr("Checking Costs"), cost, __FILE__, __LINE__)) { done(-1); } }
void itemPricingScheduleItem::populate() { if(_itemSelected->isChecked()) { q.prepare( "SELECT ipsitem_ipshead_id," " ipsitem_item_id," " ipsitem_qty_uom_id," " ipsitem_qtybreak," " ipsitem_price_uom_id," " ipsitem_price " "FROM ipsitem " "WHERE (ipsitem_id=:ipsitem_id);" ); q.bindValue(":ipsitem_id", _ipsitemid); q.exec(); if (q.first()) { _ipsheadid=q.value("ipsitem_ipshead_id").toInt(); _item->setId(q.value("ipsitem_item_id").toInt()); _qtyBreak->setDouble(q.value("ipsitem_qtybreak").toDouble()); _price->setLocalValue(q.value("ipsitem_price").toDouble()); _qtyUOM->setId(q.value("ipsitem_qty_uom_id").toInt()); _priceUOM->setId(q.value("ipsitem_price_uom_id").toInt()); sUpdateMargins(); } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, _rejectedMsg.arg(q.lastError().databaseText()), __FILE__, __LINE__); done(-1); } } else if(_discountSelected->isChecked()) { if(_dscbyprodcat->isChecked()) { q.prepare( "SELECT ipsprodcat_prodcat_id," " ipsprodcat_qtybreak AS qty_brk," " (ipsprodcat_discntprcnt * 100) AS discntprcnt," " ipsprodcat_fixedamtdiscount AS fxd_amnt " "FROM ipsprodcat " "WHERE (ipsprodcat_id=:ipsprodcat_id);" ); q.bindValue(":ipsprodcat_id", _ipsprodcatid); } else if(_dscbyItem->isChecked()) { q.prepare( "SELECT ipsitem_item_id," " ipsitem_qtybreak AS qty_brk," " (ipsitem_discntprcnt * 100) AS discntprcnt," " ipsitem_fixedamtdiscount AS fxd_amnt " "FROM ipsiteminfo " "WHERE (ipsitem_id=:ipsitem_id);" ); q.bindValue(":ipsitem_id", _ipsitemid); } q.exec(); if (q.first()) { if(_dscbyprodcat->isChecked()) _prodcat->setId(q.value("ipsprodcat_prodcat_id").toInt()); else if(_dscbyItem->isChecked()) _dscitem->setId(q.value("ipsitem_item_id").toInt()); _qtyBreakCat->setDouble(q.value("qty_brk").toDouble()); _discount->setDouble(q.value("discntprcnt").toDouble()); _fixedAmtDiscount->setLocalValue(q.value("fxd_amnt").toDouble()); } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, _rejectedMsg.arg(q.lastError().databaseText()), __FILE__, __LINE__); done(-1); } } else if(_freightSelected->isChecked()) { q.prepare( "SELECT ipsfreight.* " "FROM ipsfreight " "WHERE (ipsfreight_id=:ipsfreight_id);" ); q.bindValue(":ipsfreight_id", _ipsfreightid); q.exec(); if (q.first()) { _qtyBreakFreight->setDouble(q.value("ipsfreight_qtybreak").toDouble()); _priceFreight->setLocalValue(q.value("ipsfreight_price").toDouble()); if (q.value("ipsfreight_type").toString() == "F") { _flatRateFreight->setChecked(true); _qtyBreakFreight->setEnabled(false); } else _perUOMFreight->setChecked(true); if (q.value("ipsfreight_warehous_id").toInt() > 0) _siteFreight->setId(q.value("ipsfreight_warehous_id").toInt()); else _siteFreight->setAll(); if (q.value("ipsfreight_shipzone_id").toInt() > 0) { _selectedZoneFreight->setChecked(true); _zoneFreight->setId(q.value("ipsfreight_shipzone_id").toInt()); } else _allZonesFreight->setChecked(true); if (q.value("ipsfreight_freightclass_id").toInt() > 0) { _selectedFreightClass->setChecked(true); _freightClass->setId(q.value("ipsfreight_freightclass_id").toInt()); } else _allFreightClasses->setChecked(true); // Handle the free-form Ship Via _shipViaFreight->setCurrentIndex(-1); QString shipvia = q.value("ipsfreight_shipvia").toString(); if (shipvia.trimmed().length() != 0) { _selectedShipViaFreight->setChecked(true); for (int counter = 0; counter < _shipViaFreight->count(); counter++) if (_shipViaFreight->itemText(counter) == shipvia) _shipViaFreight->setCurrentIndex(counter); if (_shipViaFreight->id() == -1) { _shipViaFreight->addItem(shipvia); _shipViaFreight->setCurrentIndex(_shipViaFreight->count() - 1); } } else _allShipViasFreight->setChecked(true); } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, _rejectedMsg.arg(q.lastError().databaseText()), __FILE__, __LINE__); done(-1); } } sFillList(); }
itemPricingScheduleItem::itemPricingScheduleItem(QWidget* parent, const char* name, bool modal, Qt::WFlags fl) : XDialog(parent, name, modal, fl) { setupUi(this); _save = _buttonBox->button(QDialogButtonBox::Save); connect(_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(_buttonBox, SIGNAL(accepted()), this, SLOT(sSave())); connect(_item, SIGNAL(valid(bool)), _save, SLOT(setEnabled(bool))); connect(_item, SIGNAL(newId(int)), this, SLOT(sUpdateCosts(int))); connect(_price, SIGNAL(idChanged(int)), _actCost, SLOT(setId(int))); connect(_price, SIGNAL(idChanged(int)), _stdCost, SLOT(setId(int))); connect(_price, SIGNAL(idChanged(int)), _listPrice, SLOT(setId(int))); connect(_price, SIGNAL(effectiveChanged(const QDate&)), _actCost, SLOT(setEffective(const QDate&))); connect(_price, SIGNAL(effectiveChanged(const QDate&)), _stdCost, SLOT(setEffective(const QDate&))); connect(_price, SIGNAL(effectiveChanged(const QDate&)), _listPrice, SLOT(setEffective(const QDate&))); connect(_price, SIGNAL(valueChanged()), this, SLOT(sUpdateMargins())); connect(_itemSelected, SIGNAL(toggled(bool)), this, SLOT(sTypeChanged(bool))); connect(_discountSelected, SIGNAL(toggled(bool)), this, SLOT(sTypeChanged(bool))); connect(_freightSelected, SIGNAL(toggled(bool)), this, SLOT(sTypeChanged(bool))); connect(_qtyUOM, SIGNAL(newID(int)), this, SLOT(sQtyUOMChanged())); connect(_priceUOM, SIGNAL(newID(int)), this, SLOT(sPriceUOMChanged())); connect(_new, SIGNAL(clicked()), this, SLOT(sNew())); connect(_edit, SIGNAL(clicked()), this, SLOT(sEdit())); connect(_delete, SIGNAL(clicked()), this, SLOT(sDelete())); connect(_dscbyItem, SIGNAL(toggled(bool)), this, SLOT(sCheckEnable())); connect(_dscbyprodcat, SIGNAL(toggled(bool)), this, SLOT(sCheckEnable())); connect(_dscitem, SIGNAL(valid(bool)), _save, SLOT(setEnabled(bool))); _ipsheadid = -1; _ipsitemid = -1; _ipsprodcatid = -1; _ipsfreightid = -1; _invuomid = -1; _charprice->addColumn(tr("Characteristic"), _itemColumn, Qt::AlignLeft, true, "char_name" ); _charprice->addColumn(tr("Value"), -1, Qt::AlignLeft, true, "ipsitemchar_value" ); _charprice->addColumn(tr("Price"), _priceColumn,Qt::AlignRight, true, "ipsitemchar_price" ); _qtyBreak->setValidator(omfgThis->qtyVal()); _qtyBreakCat->setValidator(omfgThis->qtyVal()); _qtyBreakFreight->setValidator(omfgThis->qtyVal()); _discount->setValidator(omfgThis->percentVal()); _pricingRatio->setPrecision(omfgThis->percentVal()); _stdMargin->setPrecision(omfgThis->percentVal()); _actMargin->setPrecision(omfgThis->percentVal()); _item->setType(ItemLineEdit::cSold); _prodcat->setType(XComboBox::ProductCategories); _zoneFreight->setType(XComboBox::ShippingZones); _shipViaFreight->setType(XComboBox::ShipVias); _freightClass->setType(XComboBox::FreightClasses); _tab->setTabEnabled(_tab->indexOf(_configuredPrices),FALSE); q.exec("SELECT uom_name FROM uom WHERE (uom_item_weight);"); if (q.first()) { QString uom = q.value("uom_name").toString(); QString title (tr("Price per ")); title += uom; _perUOMFreight->setText(title); _qtyBreakFreightUOM->setText(uom); } _rejectedMsg = tr("The application has encountered an error and must " "stop editing this Pricing Schedule.\n%1"); }