enum SetResponse transferOrderItem::set(const ParameterList &pParams)
{
  XDialog::set(pParams);
  QVariant  param;
  bool      valid;

  _prev->setEnabled(true);
  _next->setEnabled(true);
  _next->setText(tr("Next"));

  param = pParams.value("tohead_id", &valid);
  if (valid)
    _toheadid = param.toInt();

  param = pParams.value("srcwarehouse_id", &valid);
  if (valid)
    _warehouse->setId(param.toInt());

  param = pParams.value("taxzone_id", &valid);
  if (valid)
    _taxzoneid = param.toInt();

  param = pParams.value("orderNumber", &valid);
  if (valid)
    _orderNumber->setText(param.toString());

  param = pParams.value("curr_id", &valid);
  if (valid)
    _freight->setId(param.toInt());

  param = pParams.value("orderDate", &valid);
  if (valid)
    _freight->setEffective(param.toDate());

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if (param.toString() == "new")
    {
      _mode = cNew;

      _save->setEnabled(FALSE);
      _next->setText(tr("New"));
      _comments->setEnabled(FALSE);
      _item->setReadOnly(false);
      _item->setFocus();

      _item->addExtraClause(QString("(item_id IN ("
				    "  SELECT itemsite_item_id"
				    "  FROM itemsite"
				    "  WHERE itemsite_warehous_id=%1))")
				    .arg(_warehouse->id()) );

      prepare();

      param = pParams.value("captive", &valid);
      if (valid)
        _captive = TRUE;

      param = pParams.value("item_id", &valid);
      if (valid)
        _item->setId(param.toInt());

      param = pParams.value("dueDate", &valid);
      if (valid)
        _scheduledDate->setDate(param.toDate());

      param = pParams.value("qty", &valid);
      if (valid)
        _qtyOrdered->setDouble(param.toDouble());

      q.prepare("SELECT count(*) AS cnt"
                "  FROM toitem"
                " WHERE (toitem_tohead_id=:tohead_id);");
      q.bindValue(":tohead_id", _toheadid);
      q.exec();
      if(!q.first() || q.value("cnt").toInt() == 0)
        _prev->setEnabled(false);
      if (q.lastError().type() != QSqlError::NoError)
      {
        systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
        return UndefinedError;
      }
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;
      _item->setReadOnly(true);
      _save->setFocus();
    }
    else if (param.toString() == "view")
    {
      _mode = cView;
    }
  }

  if(cView == _mode)
  {
    _item->setReadOnly(true);
    _qtyOrdered->setEnabled(false);
    _freight->setEnabled(false);
    _scheduledDate->setEnabled(false);
    _notes->setEnabled(false);
    _comments->setReadOnly(true);
    _itemcharView->setEnabled(false);
    _promisedDate->setEnabled(false);

    _save->hide();

    _close->setFocus();
  }

  param = pParams.value("toitem_id", &valid);
  if (valid)
  {
    _toitemid = param.toInt();

    q.prepare("SELECT a.toitem_id AS id"
	      "  FROM toitem AS a, toitem AS b"
	      " WHERE ((a.toitem_tohead_id=b.toitem_tohead_id)"
	      "   AND  (b.toitem_id=:id))"
	      " ORDER BY a.toitem_linenumber "
	      " LIMIT 1;");
    q.bindValue(":id", _toitemid);
    q.exec();
    if(!q.first() || q.value("id").toInt() == _toitemid)
      _prev->setEnabled(false);
    if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return UndefinedError;
    }

    q.prepare("SELECT a.toitem_id AS id"
	      "  FROM toitem AS a, toitem AS b"
	      " WHERE ((a.toitem_tohead_id=b.toitem_tohead_id)"
	      "   AND  (b.toitem_id=:id))"
	      " ORDER BY a.toitem_linenumber DESC"
	      " LIMIT 1;");
    q.bindValue(":id", _toitemid);
    q.exec();
    if(q.first() && q.value("id").toInt() == _toitemid)
    {
      if(cView == _mode)
        _next->setEnabled(false);
      else
        _next->setText(tr("New"));
    }
    if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return UndefinedError;
    }
  }

  param = pParams.value("item_id", &valid);
  if (valid)
  {
    _item->setId(param.toInt());
    _item->setReadOnly(TRUE);
  }

  populate();	// TODO: should this go BEFORE pParams.value("item_id")?

  _modified = false;

  return NoError;
}
Example #2
0
enum SetResponse creditMemoItem::set(const ParameterList &pParams)
{
  QVariant param;
  bool     valid;
  bool     vrestrict = FALSE;

  param = pParams.value("cmhead_id", &valid);
  if (valid)
  {
    _cmheadid = param.toInt();
    q.prepare("SELECT cmhead_taxzone_id, cmhead_curr_id "
	            "FROM cmhead "
	            "WHERE (cmhead_id=:cmhead_id);");
    q.bindValue(":cmhead_id", _cmheadid);
    q.exec();
    if (q.first())
    {
      _taxzoneid = q.value("cmhead_taxzone_id").toInt();
      _tax->setId(q.value("cmhead_curr_id").toInt());
    }
    else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return UndefinedError;
    }
  }

  param = pParams.value("rsncode_id", &valid);
  if (valid)
    _rsnCode->setId(param.toInt());

  param = pParams.value("cust_id", &valid);
  if (valid)
    _custid = param.toInt();

  param = pParams.value("shipto_id", &valid);
  if (valid)
    _shiptoid = param.toInt();

  param = pParams.value("invoiceNumber", &valid);
  if (valid)
  {
    if ( (param.toInt() == 0) || (param.toInt() == -1) )
      _invoiceNumber = -1;
    else
    {
      _invoiceNumber = param.toInt();

      if (_metrics->boolean("RestrictCreditMemos"))
        vrestrict = TRUE;
    }
  }

  param = pParams.value("creditMemoNumber", &valid);
  if (valid)
    _orderNumber->setText(param.toString());

  param = pParams.value("curr_id", &valid);
  if (valid)
    _netUnitPrice->setId(param.toInt());

  param = pParams.value("effective", &valid);
  if (valid)
    _netUnitPrice->setEffective(param.toDate());

  param = pParams.value("cmitem_id", &valid);
  if (valid)
  {
    _cmitemid = param.toInt();
    populate();
  }

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if (param.toString() == "new")
    {
      _mode = cNew;

      q.prepare( "SELECT (COALESCE(MAX(cmitem_linenumber), 0) + 1) AS n_linenumber "
                 "FROM cmitem "
                 "WHERE (cmitem_cmhead_id=:cmhead_id);" );
      q.bindValue(":cmhead_id", _cmheadid);
      q.exec();
      if (q.first())
        _lineNumber->setText(q.value("n_linenumber").toString());
      else if (q.lastError().type() == QSqlError::NoError)
      {
	      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
	      return UndefinedError;
      }

      connect(_discountFromSale, SIGNAL(lostFocus()), this, SLOT(sCalculateFromDiscount()));
      connect(_item, SIGNAL(valid(bool)), _listPrices, SLOT(setEnabled(bool)));

      _item->setFocus();
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;

      _item->setReadOnly(TRUE);
      _warehouse->setEnabled(FALSE);
      _qtyReturned->setFocus();

      connect(_discountFromSale, SIGNAL(lostFocus()), this, SLOT(sCalculateFromDiscount()));
      connect(_item, SIGNAL(valid(bool)), _listPrices, SLOT(setEnabled(bool)));

      _save->setFocus();
    }
    else if (param.toString() == "view")
    {
      _mode = cView;

      _item->setReadOnly(TRUE);
      _warehouse->setEnabled(FALSE);
      _qtyReturned->setEnabled(FALSE);
      _qtyToCredit->setEnabled(FALSE);
      _netUnitPrice->setEnabled(FALSE);
      _discountFromSale->setEnabled(FALSE);
      _comments->setReadOnly(TRUE);
      _taxType->setEnabled(FALSE);
      _rsnCode->setEnabled(FALSE);

      _save->hide();
      _close->setText(tr("&Close"));
      _close->setFocus();
    }
  }

  if (vrestrict)
    _item->setQuery( QString( "SELECT DISTINCT item_id, item_number,"
                              "                (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,"
                              "                item_upccode,"
                              "                item_descrip1, item_descrip2,"
                              "                item_active, item_config, item_type, uom_name, item_upccode "
                              "FROM invchead, invcitem, item, uom "
                              "WHERE ( (invcitem_invchead_id=invchead_id)"
                              " AND (invcitem_item_id=item_id)"
                              " AND (item_inv_uom_id=uom_id)"
                              " AND (invchead_invcnumber='%1') ) "
                              "ORDER BY item_number" )
                     .arg(_invoiceNumber) );
  else
    _item->setQuery( QString( "SELECT DISTINCT item_id, item_number,"
                              "                (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,"
                              "                item_upccode,"
                              "                item_descrip1, item_descrip2,"
                              "                item_active, uom_name, item_type, item_config "
                              "FROM item, itemsite, uom "
                              "WHERE ( (itemsite_item_id=item_id)"
                              " AND (item_inv_uom_id=uom_id)"
                              " AND (itemsite_active)"
                              " AND (item_active)"
                              " AND (customerCanPurchase(item_id, %1, %2)) ) "
                              "ORDER BY item_number" )
                     .arg(_custid).arg(_shiptoid) );

  return NoError;
}
static QString variantToTextValue(const QVariant& value, const QString& typeNs, const QString& type)
{
    switch (value.userType())
    {
    case QVariant::Char:
        // fall-through
    case QVariant::String:
        return value.toString();
    case QVariant::Url:
        // xmlpatterns/data/qatomicvalue.cpp says to do this:
        return value.toUrl().toString();
    case QVariant::ByteArray:
    {
        const QByteArray data = value.toByteArray();
        if (typeNs == KDSoapNamespaceManager::xmlSchema1999() || typeNs == KDSoapNamespaceManager::xmlSchema2001()) {
            if (type == QLatin1String("hexBinary")) {
                const QByteArray hb = data.toHex();
                return QString::fromLatin1(hb.constData(), hb.size());
            }
        }
        // default to base64Binary, like variantToXMLType() does.
        const QByteArray b64 = value.toByteArray().toBase64();
        return QString::fromLatin1(b64.constData(), b64.size());
    }
    case QVariant::Int:
        // fall-through
    case QVariant::LongLong:
        // fall-through
    case QVariant::UInt:
        return QString::number(value.toLongLong());
    case QVariant::ULongLong:
        return QString::number(value.toULongLong());
    case QVariant::Bool:
    case QMetaType::Float:
    case QVariant::Double:
        return value.toString();
    case QVariant::Time:
    {
        const QTime time = value.toTime();
        if (time.msec()) {
            // include milli-seconds
            return time.toString(QLatin1String("hh:mm:ss.zzz"));
        } else {
            return time.toString(Qt::ISODate);
        }
    }
    case QVariant::Date:
        return value.toDate().toString(Qt::ISODate);
    case QVariant::DateTime: // http://www.w3.org/TR/xmlschema-2/#dateTime
        return KDDateTime(value.toDateTime()).toDateString();
    case QVariant::Invalid:
        qDebug() << "ERROR: Got invalid QVariant in a KDSoapValue";
        return QString();
    default:
        if (value.canConvert<KDDateTime>()) {
            return value.value<KDDateTime>().toDateString();
        }

        if (value.userType() == qMetaTypeId<float>())
            return QString::number(value.value<float>());

        qDebug() << QString::fromLatin1("QVariants of type %1 are not supported in "
                                        "KDSoap, see the documentation").arg(QLatin1String(value.typeName()));
        return value.toString();
    }
}
Example #4
0
DATA::Agent LiliHelper::parseAgent(const QString aPath, const QStringList aAliases, const QString aSheet)
{
    QXlsx::Document aDocument (aPath);
    DATA::Agent aAgent;

    QStringList aStringList;
    if (aSheet.length() != 0)
    {
        aStringList.append(aSheet);
    }
    else
    {
        aStringList = aDocument.sheetNames();
    }

    for (auto aSheet : aStringList)
    {
        aDocument.selectSheet(aSheet);
        QXlsx::CellRange aSheetRange (aDocument.dimension());

        QHash<QString, QDate> aRefDateMap;
        QDate aCurrentDate;
        QString aNote;
        for (int nRow = aSheetRange.firstRow(); nRow <= aSheetRange.lastRow(); ++nRow)
        {
            QVariant aCell = aDocument.read(nRow, 2);
            const bool bFirst = aCell.type() == QVariant::String && s_aWeekDays.contains(aCell.toString());

            if (bFirst)
            {
                if (aDocument.read(nRow, 19).type() == QVariant::String)
                {
                    aNote = aDocument.read(nRow, 19).toString();
                }

                QString aCellRef = QXlsx::CellReference (nRow, 9).toString();
                QVariant aDateVariant = aDocument.read(aCellRef);

                // Looking for date without reference
                if (!aCurrentDate.isValid() && aDateVariant.type() == QVariant::Date)
                {
                    aCurrentDate = aDateVariant.toDate();
                    aRefDateMap.insert(aCellRef, aCurrentDate);
                }

                // Looking for date with reference
                else if (aCurrentDate.isValid() && aDateVariant.type() == QVariant::String)
                {
                    QRegularExpression aRx;
                    QRegularExpressionMatchIterator aRxIterator;
                    aRx.setPattern("=(\\w+\\d+)\\+(\\d+)");

                    aRxIterator = aRx.globalMatch(aDateVariant.toString());

                    if (aRxIterator.hasNext())
                    {
                        QRegularExpressionMatch aMatch = aRxIterator.next();
                        QString aReferencedCell = aMatch.captured(1);
                        if (aRefDateMap.contains(aReferencedCell))
                        {
                            aCurrentDate = aRefDateMap[aReferencedCell].addDays(aMatch.captured(2).toInt());
                            aRefDateMap.insert(aCellRef, aCurrentDate);
                        }
                    }
                }

            }
            else if (aCurrentDate.isValid())
            {
                QVariant aNameVariant = aDocument.read(nRow, 1);
                if (aNameVariant.type() == QVariant::String && aAliases.contains(aNameVariant.toString()))
                {
                    int nHourHead = 2;
                    while (nHourHead <= 54)
                    {
                        QVariant aVariant = aDocument.read(nRow, nHourHead);
                        int nTempHead = nHourHead + 1;

                        if (aVariant.type() == QVariant::Double && aVariant.toInt() == 1)
                        {
                            QTime aStartTime (7, 0);
                            if (nHourHead > 2)
                            {
                                aStartTime = aStartTime.addSecs(1800 + (nHourHead - 3) * 900);
                            }
                            QTime aEndTime = aStartTime.addSecs(15 * 60);
                            aVariant = aDocument.read(nRow, nTempHead);
                            while (nTempHead <= 54 && aVariant.type() == QVariant::Double && aVariant.toInt() == 1)
                            {
                                aEndTime = aEndTime.addSecs(15 * 60);
                                ++nTempHead;
                                aVariant = aDocument.read(nRow, nTempHead);
                            }
                            aAgent.getEvents().append(DATA::CalEvent (QDateTime (aCurrentDate, aStartTime),
                                                                      QDateTime (aCurrentDate, aEndTime),
                                                                      aNote));
                        }

                        nHourHead = nTempHead;
                    }
                }
            }

        }
    }

    return aAgent;
}
Example #5
0
bool PSV_Public::getLabels(QVariant &maxValue, QVariant &minValue, QPair<double, double> &range, QList<QPair<QVariant, QString> > &labelList)
{
    if(maxValue.type() != minValue.type())
    {
        return false;
    }
    QVariant::Type type = maxValue.type();
    switch(type)
    {
    case QVariant::Double:
    case QVariant::Int:
    case QVariant::UInt:
    {
        double max = maxValue.toDouble();
        double min = minValue.toDouble();
        int numTick = getNumTicks(max, min);
        if(numTick <= 0)
        {
            return false;
        }
        adjustRange(max, min);
        labelList.clear();
        for(int i = 0; i <= numTick; ++i)
        {
            double value = min + 1.0 * (max - min) * i / numTick;
            QString str = QObject::tr("%1").arg(value);
            labelList.append(QPair<QVariant, QString>(value, str));
        }
        maxValue = max;
        minValue = min;
        range = QPair<double,double>(min,max);
        return true;
    }
        break;
    case QVariant::Date:
    {
        QDate maxDate = maxValue.toDate();
        QDate minDate = minValue.toDate();
        bool isOk = getDateLabels(maxDate, minDate, labelList);
        maxValue = maxDate;
        minValue = minDate;
        range = QPair<double,double>(0.0, 1.0 * minDate.daysTo(maxDate));
        return isOk;
    }
        break;
    case QVariant::Time:
    {
        QTime maxTime = maxValue.toTime();
        QTime minTime = minValue.toTime();
        bool isOk = getTimeLabels(maxTime, minTime, labelList);
        maxValue = maxTime;
        minValue = minTime;
        range = QPair<double,double>(0.0, 86400.0/*1.0 * minTime.secsTo(maxTime)*/);
        return isOk;
    }
        break;
    case QVariant::DateTime:
    {
        QDateTime maxTime = maxValue.toDateTime();
        QDateTime minTime = minValue.toDateTime();
        //        PSV_Public::printMes(maxTime,"1maxTime");
        //        PSV_Public::printMes(minTime,"1minTime");
        bool isOk = getDateTimeLabels(maxTime, minTime, labelList);
        maxValue = maxTime;
        minValue = minTime;
        //        PSV_Public::printMes(maxTime,"2maxTime");
        //        PSV_Public::printMes(minTime,"2minTime");

        range = QPair<double,double>(PSV_BEGIN_DATETIME.secsTo(minValue.toDateTime()),PSV_BEGIN_DATETIME.secsTo(maxValue.toDateTime()));
        return isOk;
    }
        break;
    default:
        break;
    }
    return false;
}
Example #6
0
enum SetResponse purchaseOrderItem::set(const ParameterList &pParams)
{
    QVariant param;
    bool     valid;
    bool     haveQty  = FALSE;
    bool     haveDate = FALSE;



    param = pParams.value("warehous_id", &valid);
    if (valid)
        _preferredWarehouseid = param.toInt();

    param = pParams.value("parentWo", &valid);
    if (valid)
        _parentwo = param.toInt();

    param = pParams.value("parentSo", &valid);
    if (valid)
        _parentso = param.toInt();

    param = pParams.value("pohead_id", &valid);
    if (valid)
    {
        _poheadid = param.toInt();

        q.prepare( "SELECT pohead_taxzone_id, pohead_number, pohead_orderdate, pohead_status, " // pohead_taxzone_id added
                   "       vend_id, vend_restrictpurch, pohead_curr_id "
                   "FROM pohead, vend "
                   "WHERE ( (pohead_vend_id=vend_id)"
                   " AND (pohead_id=:pohead_id) );" );
        q.bindValue(":pohead_id", param.toInt());
        q.exec();
        if (q.first())
        {
            _poNumber->setText(q.value("pohead_number").toString());
            _poStatus = q.value("pohead_status").toString();
            _unitPrice->setEffective(q.value("pohead_orderdate").toDate());
            _unitPrice->setId(q.value("pohead_curr_id").toInt());
            _taxzoneid=q.value("pohead_taxzone_id").toInt();   // added  to pick up tax zone id.
            _tax->setEffective(q.value("pohead_orderdate").toDate());
            _tax->setId(q.value("pohead_curr_id").toInt());

            if (q.value("vend_restrictpurch").toBool())
            {
                _item->setQuery( QString( "SELECT DISTINCT item_id, item_number, item_descrip1, item_descrip2,"
                                          "                (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,"
                                          "                uom_name, item_type, item_config, item_active "
                                          "FROM item, itemsite, itemsrc, uom  "
                                          "WHERE ( (itemsite_item_id=item_id)"
                                          " AND (itemsrc_item_id=item_id)"
                                          " AND (item_inv_uom_id=uom_id)"
                                          " AND (itemsite_active)"
                                          " AND (item_active)"
                                          " AND (itemsrc_active)"
                                          " AND (itemsrc_vend_id=%1) ) "
                                          "ORDER BY item_number" )
                                 .arg(q.value("vend_id").toInt()) );
                _item->setValidationQuery( QString( "SELECT DISTINCT item_id, item_number, item_descrip1, item_descrip2,"
                                                    "                (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,"
                                                    "                uom_name, item_type, item_config, item_active "
                                                    "FROM item, itemsite, itemsrc, uom  "
                                                    "WHERE ( (itemsite_item_id=item_id)"
                                                    " AND (itemsrc_item_id=item_id)"
                                                    " AND (item_inv_uom_id=uom_id)"
                                                    " AND (itemsite_active)"
                                                    " AND (item_active)"
                                                    " AND (itemsrc_active)"
                                                    " AND (itemsrc_vend_id=%1) "
                                                    " AND (itemsite_item_id=:item_id) ) ")
                                           .arg(q.value("vend_id").toInt()) );
            }
            else
            {
                _item->setType(ItemLineEdit::cGeneralPurchased | ItemLineEdit::cGeneralManufactured | ItemLineEdit::cActive);
                _item->setDefaultType(ItemLineEdit::cGeneralPurchased | ItemLineEdit::cActive);
            }
        }
        else
        {
            systemError(this, tr("A System Error occurred at %1::%2.")
                        .arg(__FILE__)
                        .arg(__LINE__) );
            return UndefinedError;
        }
    }

    param = pParams.value("poitem_id", &valid);
    if (valid)
    {
        _poitemid = param.toInt();

        q.prepare( "SELECT pohead_number "
                   "FROM pohead, poitem "
                   "WHERE ( (pohead_id=poitem_pohead_id) "
                   " AND (poitem_id=:poitem_id) );" );
        q.bindValue(":poitem_id", param.toInt());
        q.exec();
        if (q.first())
        {
            _poNumber->setText(q.value("pohead_number").toString());
        }

        populate();
    }
    // connect here and not in the .ui to avoid timing issues at initialization
    connect(_unitPrice, SIGNAL(valueChanged()), this, SLOT(sPopulateExtPrice()));

    param = pParams.value("mode", &valid);
    if (valid)
    {
        if (param.toString() == "new")
        {
            _mode = cNew;

            q.exec("SELECT NEXTVAL('poitem_poitem_id_seq') AS poitem_id;");
            if (q.first())
                _poitemid = q.value("poitem_id").toInt();
            else
            {
                systemError(this, tr("A System Error occurred at %1::%2.")
                            .arg(__FILE__)
                            .arg(__LINE__) );
                return UndefinedError;
            }

            if(_parentso != -1)
            {
                q.prepare( "INSERT INTO charass"
                           "      (charass_target_type, charass_target_id,"
                           "       charass_char_id, charass_value) "
                           "SELECT 'PI', :orderid, charass_char_id, charass_value"
                           "  FROM charass"
                           " WHERE ((charass_target_type='SI')"
                           "   AND  (charass_target_id=:soitem_id));");
                q.bindValue(":orderid", _poitemid);
                q.bindValue(":soitem_id", _parentso);
                q.exec();
            }

            q.prepare( "SELECT (COALESCE(MAX(poitem_linenumber), 0) + 1) AS _linenumber "
                       "FROM poitem "
                       "WHERE (poitem_pohead_id=:pohead_id);" );
            q.bindValue(":pohead_id", _poheadid);
            q.exec();
            if (q.first())
                _lineNumber->setText(q.value("_linenumber").toString());
            else
            {
                systemError(this, tr("A System Error occurred at %1::%2.")
                            .arg(__FILE__)
                            .arg(__LINE__) );

                return UndefinedError;
            }

            if (!_item->isValid())
                _item->setFocus();
            else if (!haveQty)
                _ordered->setFocus();
            else if (!haveDate)
                _dueDate->setFocus();

            _comments->setEnabled(FALSE);
        }
        else if (param.toString() == "edit")
        {
            _mode = cEdit;

            _typeGroup->setEnabled(FALSE);

            _ordered->setFocus();
        }
        else if (param.toString() == "view")
        {
            _mode = cView;

            _typeGroup->setEnabled(FALSE);
            _vendorItemNumber->setEnabled(FALSE);
            _vendorItemNumberList->setEnabled(FALSE);
            _vendorDescrip->setEnabled(FALSE);
            _warehouse->setEnabled(FALSE);
            _dueDate->setEnabled(FALSE);
            _ordered->setEnabled(FALSE);
            _unitPrice->setEnabled(FALSE);
            _freight->setEnabled(FALSE);
            _notes->setReadOnly(TRUE);
            _comments->setReadOnly(TRUE);
            _project->setEnabled(FALSE);
            _taxtype->setEnabled(FALSE);
            _taxRecoverable->setEnabled(FALSE);

            _close->setText(tr("&Close"));
            _save->hide();

            _close->setFocus();
        }
    }

    param = pParams.value("itemsite_id", &valid);
    if (valid)
    {
        _item->setItemsiteid(param.toInt());
        _item->setEnabled(FALSE);
        _warehouse->setEnabled(FALSE);
    }

    param = pParams.value("itemsrc_id", &valid);
    if (valid)
        sPopulateItemSourceInfo(param.toInt());

    param = pParams.value("qty", &valid);
    if (valid)
    {
        _ordered->setDouble((param.toDouble()/_invVendUOMRatio));

        if (_item->isValid())
            sDeterminePrice();

        haveQty = TRUE;
    }

    param = pParams.value("dueDate", &valid);
    if (valid)
    {
        _dueDate->setDate(param.toDate());
        haveDate = TRUE;
    }

    param = pParams.value("prj_id", &valid);
    if (valid)
        _project->setId(param.toInt());

    if(_parentso != -1)
    {
        q.prepare("SELECT coitem_prcost"
                  "  FROM coitem"
                  " WHERE (coitem_id=:parentso); ");
        q.bindValue(":parentso", _parentso);
        q.exec();
        if(q.first())
        {
            if(q.value("coitem_prcost").toDouble() > 0)
            {
                _overriddenUnitPrice = true;
                _unitPrice->setLocalValue(q.value("coitem_prcost").toDouble());
                sPopulateExtPrice();
            }
        }
    }

    return NoError;
}
Example #7
0
bool CaseInModel::editData(int i, int j, QVariant newValue)
{
	if (j == 1 || j == 8)
	{
		QString rowid = m_cache[0][i].toString();
		QString pole = (j==1)?"data_wejscia":"data_zabezpieczenia";
		QSqlQuery query( SqlConnectionController::qSqlDb() );
		query.exec("UPDATE sprawy_wejscie SET " + pole + " = '" + newValue.toString() + "' WHERE rowid = " + rowid );
		m_cache[j][i].setValue(newValue.toDate().toString("dd.MM.yyyy"));
		return true;
	}
	else if (j == 2)
	{
		if (newValue.toString() != "")
		{
			QString rowid = m_cache[0][i].toString();

			if (isHeUnique(newValue.toString()))
			{
				QSqlQuery query( SqlConnectionController::qSqlDb() );
				query.exec("UPDATE sprawy_wejscie SET nr_he = '"+newValue.toString()+"' WHERE rowid = " + rowid);
				m_cache[j][i].setValue(newValue);
			}
			return true;
		}
	}
	else if (j == 6)
	{
		if (newValue.toString() != "0")
		{
			QString rowid = m_cache[0][i].toString();
			QSqlQuery query( SqlConnectionController::qSqlDb() );
			query.exec("UPDATE sprawy_wejscie SET id_przydzial = '" + newValue.toString() + "' WHERE rowid = " + rowid );
			m_cache[j][i].setValue(QVariant(StaffModel::nameSurnameByRowId(newValue.toString())));
			return true;
		}

	} else if (j == 3)
	{
		if (newValue.toString() != "0")
		{
			QString rowid = m_cache[0][i].toString();
			QSqlQuery query( SqlConnectionController::qSqlDb() );
			query.exec("UPDATE sprawy_wejscie SET id_jednostka = '" + newValue.toString() + "' WHERE rowid = " + rowid );
			m_cache[j][i].setValue(QVariant(PoliceStationModel::cityStationByRowId(newValue.toString())));
			return true;
		}
	}
	else if (j == 7)
	{
		QString v = newValue.toString();
		if ((QStringList() << "k" << "w" << "u" <<"uk" << "r").contains(v) )
		{
			QString rowid = m_cache[0][i].toString();
			QSqlQuery query( SqlConnectionController::qSqlDb() );
			query.exec("UPDATE sprawy_wejscie SET rodzaj = '" + newValue.toString() + "' WHERE rowid = " + rowid );
			m_cache[j][i].setValue(newValue);
			return true;
		}

	}
	else if (j == 4 || j == 5 || j == 9)
	{
		QString val = newValue.toString();
		if (val != "")
		{
			QString pole;
			QString rowid = m_cache[0][i].toString();
			switch (j)
			{
			case 4:
				pole = "nr_rsd";
				break;
			case 5:
				pole = "opis";
				break;
			case 9:
				pole = "uwagi";
				break;
			}
			QSqlQuery query( SqlConnectionController::qSqlDb() );
			query.exec("UPDATE sprawy_wejscie SET "+pole+" = '" + newValue.toString() + "' WHERE rowid = " + rowid );
			m_cache[j][i].setValue(newValue);
			return true;
		}

	}
	return false;
}
    void evaluation()
    {
      QFETCH( QString, string );
      QFETCH( bool, evalError );
      QFETCH( QVariant, result );

      QgsExpression exp( string );
      QCOMPARE( exp.hasParserError(), false );
      if ( exp.hasParserError() )
        qDebug() << exp.parserErrorString();

      QVariant res = exp.evaluate();
      if ( exp.hasEvalError() )
        qDebug() << exp.evalErrorString();
      if ( res.type() != result.type() )
      {
        qDebug() << "got " << res.typeName() << " instead of " << result.typeName();
      }
      //qDebug() << res.type() << " " << result.type();
      //qDebug() << "type " << res.typeName();
      QCOMPARE( exp.hasEvalError(), evalError );

      QCOMPARE( res.type(), result.type() );
      switch ( res.type() )
      {
        case QVariant::Invalid:
          break; // nothing more to check
        case QVariant::Int:
          QCOMPARE( res.toInt(), result.toInt() );
          break;
        case QVariant::Double:
          QCOMPARE( res.toDouble(), result.toDouble() );
          break;
        case QVariant::String:
          QCOMPARE( res.toString(), result.toString() );
          break;
        case QVariant::Date:
          QCOMPARE( res.toDate(), result.toDate() );
          break;
        case QVariant::DateTime:
          QCOMPARE( res.toDateTime(), result.toDateTime() );
          break;
        case QVariant::Time:
          QCOMPARE( res.toTime(), result.toTime() );
          break;
        case QVariant::UserType:
        {
          if ( res.userType() == qMetaTypeId<QgsExpression::Interval>() )
          {
            QgsExpression::Interval inter = res.value<QgsExpression::Interval>();
            QgsExpression::Interval gotinter = result.value<QgsExpression::Interval>();
            QCOMPARE( inter.seconds(), gotinter.seconds() );
          }
          else
          {
            QFAIL( "unexpected user type" );
          }
          break;
        }
        default:
          Q_ASSERT( false ); // should never happen
      }
    }
Example #9
0
enum SetResponse dspInventoryHistoryByParameterList::set(const ParameterList &pParams)
{
  XWidget::set(pParams);
  QVariant param;
  bool     valid;

  param = pParams.value("classcode_id", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::ClassCode);
    _parameter->setId(param.toInt());
  }

  param = pParams.value("classcode_pattern", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::ClassCode);
    _parameter->setPattern(param.toString());
  }

  param = pParams.value("classcode", &valid);
  if (valid)
    _parameter->setType(ParameterGroup::ClassCode);

  param = pParams.value("plancode_id", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::PlannerCode);
    _parameter->setId(param.toInt());
  }

  param = pParams.value("plancode_pattern", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::PlannerCode);
    _parameter->setPattern(param.toString());
  }

  param = pParams.value("plancode", &valid);
  if (valid)
    _parameter->setType(ParameterGroup::PlannerCode);

  param = pParams.value("itemgrp_id", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::ItemGroup);
    _parameter->setId(param.toInt());
  }

  param = pParams.value("itemgrp_pattern", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::ItemGroup);
    _parameter->setPattern(param.toString());
  }

  param = pParams.value("itemgrp", &valid);
  if (valid)
    _parameter->setType(ParameterGroup::ItemGroup);

  param = pParams.value("warehous_id", &valid);
  if (valid)
    _warehouse->setId(param.toInt());

  param = pParams.value("startDate", &valid);
  if (valid)
    _dates->setStartDate(param.toDate());

  param = pParams.value("endDate", &valid);
  if (valid)
    _dates->setEndDate(param.toDate());

  param = pParams.value("transtype", &valid);
  if (valid)
  {
    QString transtype = param.toString();

    if (transtype == "R")
      _transType->setCurrentIndex(1);
    else if (transtype == "I")
      _transType->setCurrentIndex(2);
    else if (transtype == "S")
      _transType->setCurrentIndex(3);
    else if (transtype == "A")
      _transType->setCurrentIndex(4);
    else if (transtype == "T")
      _transType->setCurrentIndex(5);
    else if (transtype == "SC")
      _transType->setCurrentIndex(6);
  }

  param = pParams.value("ordertype", &valid);
  if (valid)
  {
    QString ordertype = param.toString();

    if (ordertype == "SO")
      _orderType->setCurrentIndex(1);
    else if (ordertype == "PO")
      _orderType->setCurrentIndex(2);
    else if (ordertype == "WO")
      _orderType->setCurrentIndex(3);
    else if (ordertype == "TO")
      _orderType->setCurrentIndex(4);
  }

  if (pParams.inList("run"))
    sFillList();

  switch (_parameter->type())
  {
    case ParameterGroup::ClassCode:
      setWindowTitle(tr("Inventory History by Class Code"));
      break;

    case ParameterGroup::PlannerCode:
      setWindowTitle(tr("Inventory History by Planner Code"));
      break;

    case ParameterGroup::ItemGroup:
      setWindowTitle(tr("Inventory History by Item Group"));
      break;

    default:
      break;
  }

  return NoError;
}
Example #10
0
void alarmMaint::set( const ParameterList & pParams )
{
  QVariant param;
  bool        valid;
  
  param = pParams.value("source", &valid);
  if (valid)
  {
    _source = (enum Alarms::AlarmSources)param.toInt();
    if ( (QString(Alarms::_alarmMap[_source].ident) == QString("TODO")) || (QString(Alarms::_alarmMap[_source].ident) == QString("J")) )
      _alarmDate->setEnabled(false);
  }
    
  param = pParams.value("source_id", &valid);
  if(valid)
    _sourceid = param.toInt();

  param = pParams.value("due_date", &valid);
  if(valid)
    _alarmDate->setDate(param.toDate());

  param = pParams.value("usrId1", &valid);
  if(valid)
    sGetUser(param.toInt());

  param = pParams.value("usrId2", &valid);
  if(valid)
    sGetUser(param.toInt());

  param = pParams.value("usrId3", &valid);
  if(valid)
    sGetUser(param.toInt());

  param = pParams.value("cntctId1", &valid);
  if(valid)
    sGetContact(param.toInt());

  param = pParams.value("cntctId2", &valid);
  if(valid)
    sGetContact(param.toInt());

  param = pParams.value("cntctId3", &valid);
  if(valid)
    sGetContact(param.toInt());

  param = pParams.value("mode", &valid);
  if(valid)
  {
    if(param.toString() == "new")
    {
      _mode = cNew;
    }
    else if(param.toString() == "edit")
      _mode = cEdit;
    else if(param.toString() == "view")
    {
      _mode = cView;
      _save->hide();
    }
  }

  param = pParams.value("alarm_id", &valid);
  if (valid)
  {
    _alarmid = param.toInt();
    sPopulate();
  }

}
Example #11
0
enum SetResponse shipOrder::set(const ParameterList &pParams)
{
  XSqlQuery shipet;
  XSqlQuery siteq;
  XDialog::set(pParams);
  QString  returnValue;
  QVariant param;
  bool     valid;

  param = pParams.value("transdate", &valid);
  if (valid)
  {
    _transDate->setDate(param.toDate(), true);
  }
  
  param = pParams.value("shiphead_id", &valid);
  if (valid)
  {
    shipet.prepare( "SELECT shiphead_order_id, shiphead_order_type "
               "FROM shiphead "
               "WHERE (shiphead_id=:shiphead_id);" );
    shipet.bindValue(":shiphead_id", param.toInt());
    shipet.exec();
    if (shipet.first())
    {
      _captive = true;	// so order handling can reject if necessary
      if (shipet.value("shiphead_order_type").toString() == "SO")
      {
        siteq.prepare( "SELECT DISTINCT itemsite_warehous_id "
                       "FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)"
                       "              JOIN coitem ON (coitem_id=shipitem_orderitem_id)"
                       "              JOIN itemsite ON (itemsite_id=coitem_itemsite_id)"
                       "WHERE (shiphead_id=:shiphead_id);" );
        siteq.bindValue(":shiphead_id", param.toInt());
        siteq.exec();
        if (siteq.first())
        {
          _warehouse->setId(siteq.value("itemsite_warehous_id").toInt());
        }
        _order->setId(param.toInt(), "SO");
      }
      else if (shipet.value("shiphead_order_type").toString() == "TO")
      {
        siteq.prepare( "SELECT DISTINCT tohead_src_warehous_id "
                      "FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)"
                      "              JOIN toitem ON (toitem_id=shipitem_orderitem_id)"
                      "              JOIN tohead ON (tohead_id=toitem_tohead_id)"
                      "WHERE (shiphead_id=:shiphead_id);" );
        siteq.bindValue(":shiphead_id", param.toInt());
        siteq.exec();
        if (siteq.first())
        {
          _warehouse->setId(siteq.value("tohead_src_warehous_id").toInt());
        }
        _order->setId(param.toInt(), "TO");
      }
    }
    else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Shipping Information"),
                                  shipet, __FILE__, __LINE__))
    {
      return UndefinedError;
    }

    _shipment->setId(param.toInt());	// last because of signal cascade
  }

  if (_reject)
    return UndefinedError;

  return NoError;
}
Example #12
0
QString DateTimeDelegate::displayText(const QVariant &value, const QLocale &locale) const
{
    if (m_IsDateOnly)
        return locale.toString(value.toDate(), tkTr(Trans::Constants::DATEFORMAT_FOR_EDITOR));
    return locale.toString(value.toDateTime(), tkTr(Trans::Constants::DATETIMEFORMAT_FOR_EDITOR));
}
Example #13
0
QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
{
    QSystemLocalePrivate *d = systemLocalePrivate();
    switch(type) {
    case DecimalPoint:
        return d->decimalPoint();
    case GroupSeparator:
        return d->groupSeparator();
    case NegativeSign:
        return d->negativeSign();
    case PositiveSign:
        return d->positiveSign();
    case DateFormatLong:
        return d->dateFormat(QLocale::LongFormat);
    case DateFormatShort:
        return d->dateFormat(QLocale::ShortFormat);
    case TimeFormatLong:
        return d->timeFormat(QLocale::LongFormat);
    case TimeFormatShort:
        return d->timeFormat(QLocale::ShortFormat);
    case DateTimeFormatLong:
        return d->dateTimeFormat(QLocale::LongFormat);
    case DateTimeFormatShort:
        return d->dateTimeFormat(QLocale::ShortFormat);
    case DayNameLong:
        return d->dayName(in.toInt(), QLocale::LongFormat);
    case DayNameShort:
        return d->dayName(in.toInt(), QLocale::ShortFormat);
    case MonthNameLong:
        return d->monthName(in.toInt(), QLocale::LongFormat);
    case MonthNameShort:
        return d->monthName(in.toInt(), QLocale::ShortFormat);
    case DateToStringShort:
        return d->toString(in.toDate(), QLocale::ShortFormat);
    case DateToStringLong:
        return d->toString(in.toDate(), QLocale::LongFormat);
    case TimeToStringShort:
        return d->toString(in.toTime(), QLocale::ShortFormat);
    case TimeToStringLong:
        return d->toString(in.toTime(), QLocale::LongFormat);
    case DateTimeToStringShort:
        return d->toString(in.toDateTime(), QLocale::ShortFormat);
    case DateTimeToStringLong:
        return d->toString(in.toDateTime(), QLocale::LongFormat);
    case ZeroDigit:
        return d->zeroDigit();
    case LanguageId:
    case CountryId: {
        QString locale = QString::fromLatin1(getWinLocaleName());
        QLocale::Language lang;
        QLocale::Script script;
        QLocale::Country cntry;
        QLocalePrivate::getLangAndCountry(locale, lang, script, cntry);
        if (type == LanguageId)
            return lang;
        if (cntry == QLocale::AnyCountry)
            return fallbackLocale().country();
        return cntry;
    }
    case ScriptId:
        return QVariant(QLocale::AnyScript);
    case MeasurementSystem:
        return d->measurementSystem();
    case AMText:
        return d->amText();
    case PMText:
        return d->pmText();
    case FirstDayOfWeek:
        return d->firstDayOfWeek();
    case CurrencySymbol:
        return d->currencySymbol(QLocale::CurrencySymbolFormat(in.toUInt()));
    case CurrencyToString:
        return d->toCurrencyString(in.value<QSystemLocale::CurrencyToStringArgument>());
    case UILanguages:
        return d->uiLanguages();
    case LocaleChanged:
        d->update();
        break;
    case NativeLanguageName:
        return d->nativeLanguageName();
    case NativeCountryName:
        return d->nativeCountryName();
    default:
        break;
    }
    return QVariant();
}
Example #14
0
enum SetResponse taxDetail::set(const ParameterList & pParams )
{
  QVariant param;
  bool     valid;
  
   _readonly = pParams.inList("readOnly");

   _new->hide();
   _delete->hide();

   param = pParams.value("taxzone_id", &valid);
   if (valid)
	   _taxzoneId = param.toInt();

   param = pParams.value("taxtype_id", &valid);
   if (valid)
   	   _taxType->setId(param.toInt());
   else
    clear();

   param = pParams.value("date", &valid);
   if (valid)
      _subtotal->setEffective(param.toDate());

   param = pParams.value("subtotal", &valid);
   if (valid)
	   _subtotal->setLocalValue(param.toDouble());
    
   param = pParams.value("curr_id", &valid);
   if (valid)
	   _subtotal->setId(param.toInt());

   param = pParams.value("order_id", &valid);
   if (valid)
    _orderid = param.toInt();

   param = pParams.value("order_type", &valid);
   if (valid)
    _ordertype = param.toString();

   param = pParams.value("display_type", &valid);
   if (valid)
    _displayType = param.toString();
	
   _adjustment = pParams.inList("adjustment"); 
   
   param = pParams.value("sense", &valid);
   if (valid)
    _sense = param.toInt();

   if (_readonly)
   {
     _taxType->setEnabled(FALSE);
     _cancel->setText(tr("&Close"));
   }

   if(_adjustment && !_readonly)
   {	
     _taxType->setEnabled(FALSE);
	   _new->show();
	   _delete->show();
   }

   sPopulate();

  return NoError;
}
Example #15
0
QVariant TableModel::data(const QModelIndex &index, int role) const
{
	QVariant ret;
	if(!index.isValid())
		return ret;
	if(role == RawValueRole) {
		ret = value(index.row(), index.column());
	}
	else if(role == ValueIsDirtyRole) {
		ret = isDirty(index.row(), index.column());
	}
	else if(role == SortRole) {
		int type = columnType(index.column());
		if(type == QVariant::Bool)
			ret = value(index.row(), index.column()).toBool();
		else
			ret = data(index, Qt::DisplayRole);
	}
	else if(role == Qt::DisplayRole) {
		ColumnDefinition cd = m_columns.value(index.column());
		if(cd.isNull()) {
			return QString("!%1").arg(index.column());
		}
		if(data(index, ValueIsNullRole).toBool()) {
			if(isNullReportedAsString())
				return QStringLiteral("null");
			return QVariant();
		}
		ret = data(index, Qt::EditRole);
		int type = columnType(index.column());
		if(type == QVariant::Invalid)
			type = ret.type(); /// pokud jsou sloupce virtualni (sloupce se pocitaji, nemusi byt pro ne definovan typ)
		if(type == QVariant::ByteArray) {
			const static QString blob_string = "{blob %1%2}";
			int size = ret.toByteArray().size();
			if(size < 1024) ret = blob_string.arg(size).arg(" B");
			else ret = blob_string.arg(size/1024).arg("kB");
		}
		else if(type == QVariant::Bool) {
			/// display check
			ret = QString();
		}
		QString format = cd.format();
		if(format.isEmpty()) {
			if(type == QVariant::Date) {
				format = m_defaultDateFormat;
			}
			else if(type == QVariant::Time) {
				format = m_defaultTimeFormat;
				//qfInfo() << "format" << format;
			}
			else if(type == QVariant::DateTime) {
				format = m_defaultDateTimeFormat;
				//qfInfo() << "format" << format;
			}
		}
		if(!format.isEmpty()) {
			if(type == QVariant::Time) {
				QTime t = ret.toTime();
				ret = t.toString(format);
			}
			else if(type == QVariant::Date) {
				QDate d = ret.toDate();
				ret = d.toString(format);
			}
			else if(type == QVariant::DateTime) {
				QDateTime dt = ret.toDateTime();
				ret = dt.toString(format);
			}
		}
	}
	else if(role == Qt::EditRole) {
		ret = data(index, RawValueRole);
		ret = rawValueToEdit(index.column(), ret);
	}
	else if (role == ValueIsNullRole) {
		ret = data(index, RawValueRole);
		return ret.isNull() && ret.isValid();
	}
	else if (role == Qt::TextAlignmentRole) {
		const ColumnDefinition cd = m_columns.value(index.column());
		Qt::Alignment al = cd.alignment();
		if(!!al)
			ret = (int)al;
		else {
			if(!data(index, ValueIsNullRole).toBool()) {
				ret = data(index, RawValueRole);
				if(ret.type() > QVariant::Bool && ret.type() <= QVariant::Double)
					ret = Qt::AlignRight;
				else
					ret = Qt::AlignLeft;
			}
		}
	}
	else if(role == Qt::TextColorRole) {
		int type = columnType(index.column());
		if(type == QVariant::ByteArray)
			return QColor(Qt::blue);
		if(data(index, ValueIsNullRole).toBool()) {
			return QColor(Qt::blue);
		}
		ret = QVariant();
	}
	else if (role == Qt::BackgroundColorRole) {
		/// delegate does it
	}
	else if (role == Qt::CheckStateRole) {
		int type = columnType(index.column());
		if(type == QVariant::Bool) {
			//qfInfo() << "BOOL";
			return (data(index, Qt::EditRole).toBool()? Qt::Checked: Qt::Unchecked);
		}
		return QVariant();
	}
	else if (role == Qt::ToolTipRole) {
		QString s = data(index, Qt::DisplayRole).toString();
		//s = "<pre>" + s + "</pre>"; /// kvuli chybe v Qt 4.6.3, kdy aplikace pada pokud je v textu za sebou 0x09 0x0A
		s.replace("\t\n", "\n");
		ret = s;
		//ret = data(index, Qt::DisplayRole);
		//qfInfo() << ret.toString();
	}
	return ret;
}
Example #16
0
enum SetResponse dspSalesHistoryByParameterList::set(const ParameterList &pParams)
{
  QVariant param;
  bool     valid;

  param = pParams.value("prodcat", &valid);
  if (valid)
    _parameter->setType(ParameterGroup::ProductCategory);

  param = pParams.value("prodcat_id", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::ProductCategory);
    _parameter->setId(param.toInt());
  }

  param = pParams.value("prodcat_pattern", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::ProductCategory);
    _parameter->setPattern(param.toString());
  }

  param = pParams.value("custtype", &valid);
  if (valid)
    _parameter->setType(ParameterGroup::CustomerType);

  param = pParams.value("custtype_id", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::CustomerType);
    _parameter->setId(param.toInt());
  }

  param = pParams.value("custtype_pattern", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::CustomerType);
    _parameter->setPattern(param.toString());
  }

  param = pParams.value("custgrp", &valid);
  if (valid)
    _parameter->setType(ParameterGroup::CustomerGroup);

  param = pParams.value("custgrp_id", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::CustomerGroup);
    _parameter->setId(param.toInt());
  }

  param = pParams.value("custgrp_pattern", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::CustomerGroup);
    _parameter->setPattern(param.toString());
  }

  param = pParams.value("warehous_id", &valid);
  if (valid)
    _warehouse->setId(param.toInt());

  param = pParams.value("startDate", &valid);
  if (valid)
    _dates->setStartDate(param.toDate());

  param = pParams.value("endDate", &valid);
  if (valid)
    _dates->setEndDate(param.toDate());

  if (pParams.inList("run"))
  {
    sFillList();
    return NoError_Run;
  }

  if (_parameter->type() == ParameterGroup::ProductCategory)
    setWindowTitle(tr("Sales History by Product Category"));
  if (_parameter->type() == ParameterGroup::CustomerType)
    setWindowTitle(tr("Sales History by Customer Type"));
  if (_parameter->type() == ParameterGroup::CustomerGroup)
    setWindowTitle(tr("Sales History by Customer Group"));

  return NoError;
}
Example #17
0
enum SetResponse dspInventoryAvailability::set(const ParameterList &pParams)
{
    XWidget::set(pParams);
    QVariant param;
    bool     valid;

    parameterWidget()->setSavedFilters();

    param = pParams.value("classcode_id", &valid);
    if (valid)
        parameterWidget()->setDefault(tr("Class Code"), param);

    param = pParams.value("classcode_pattern", &valid);
    if (valid)
        parameterWidget()->setDefault(tr("Class Code Pattern"), param);

    param = pParams.value("plancode_id", &valid);
    if (valid)
        parameterWidget()->setDefault(tr("Planner Code"), param);

    param = pParams.value("plancode_pattern", &valid);
    if (valid)
        parameterWidget()->setDefault(tr("Planner Code Pattern"), param);

    param = pParams.value("itemgrp_id", &valid);
    if (valid)
        parameterWidget()->setDefault(tr("Item Group"), param);

    param = pParams.value("itemgrp_pattern", &valid);
    if (valid)
        parameterWidget()->setDefault(tr("Item Group Pattern"), param);

    param = pParams.value("item_id", &valid);
    if (valid)
        parameterWidget()->setDefault(tr("Item"), param);

    param = pParams.value("itemsite_id", &valid);
    if (valid)
    {
        XSqlQuery qry;
        qry.prepare("SELECT itemsite_item_id, itemsite_warehous_id "
                    "FROM itemsite "
                    "WHERE itemsite_id=:itemsite_id;");
        qry.bindValue(":itemsite_id", param.toInt());
        qry.exec();
        if (qry.first())
        {
            parameterWidget()->setDefault(tr("Item"), qry.value("itemsite_item_id"));
            parameterWidget()->setDefault(tr("Site"), qry.value("itemsite_warehous_id"));
        }
    }

    param = pParams.value("warehous_id", &valid);
    if (valid)
        parameterWidget()->setDefault(tr("Site"), param);

    param = pParams.value("byDays", &valid);
    if (valid)
    {
        _forgetful = true;
        _asof->setCurrentIndex(LOOKAHEADDAYS);
        _days->setValue(param.toInt());
    }

    param = pParams.value("byDate", &valid);
    if (valid)
    {
        _forgetful = true;
        _asof->setCurrentIndex(CUTOFFDATE);
        _date->setDate(param.toDate());
    }

    // sources may not exist, so turn by Vendor off to avoid confusion
    _byVendor->setForgetful(true);
    _byVendor->setChecked(false);

    parameterWidget()->applyDefaultFilterSet();

    if (pParams.inList("run"))
    {
        sFillList();
        return NoError_Run;
    }

    return NoError;
}
Example #18
0
enum SetResponse itemPricingScheduleItem::set(const ParameterList &pParams)
{
    XDialog::set(pParams);
    QVariant param;
    bool     valid;

    param = pParams.value("ipshead_id", &valid);
    if (valid)
        _ipsheadid = param.toInt();

    param = pParams.value("curr_id", &valid);
    if (valid)
    {
        _price->setId(param.toInt());
        _priceFreight->setId(param.toInt());
    }

    param = pParams.value("updated", &valid);
    if (valid)
    {
        _price->setEffective(param.toDate());
        _priceFreight->setEffective(param.toDate());
    }

    param = pParams.value("ipsitem_id", &valid);
    if (valid)
    {
        _ipsitemid = param.toInt();
        q.prepare("SELECT ipsitem_qtybreak, "
                  "       ipsitem_discntprcnt, "
                  "       ipsitem_fixedamtdiscount "
                  "FROM ipsiteminfo "
                  "WHERE (ipsitem_id = :ipsitem_id) ");
        q.bindValue(":ipsitem_id", _ipsitemid);
        q.exec();
        if (q.first())
        {
            if(q.value("ipsitem_discntprcnt").toDouble() != 0.0 ||
                    q.value("ipsitem_fixedamtdiscount").toDouble() != 0.0)
            {
                _discountSelected->setChecked(true);
                _dscbyItem->setChecked(true);
            }
            else
            {
                _itemSelected->setChecked(true);
            }
            populate();
        }
    }

    param = pParams.value("ipsprodcat_id", &valid);
    if (valid)
    {
        _ipsprodcatid = param.toInt();
        _discountSelected->setChecked(true);
        _dscbyprodcat->setChecked(true);
        populate();
    }

    param = pParams.value("ipsfreight_id", &valid);
    if (valid)
    {
        _ipsfreightid = param.toInt();
        _freightSelected->setChecked(true);
        populate();
    }

    param = pParams.value("mode", &valid);
    if (valid)
    {
        if (param.toString() == "new")
        {
            _mode = cNew;

            _item->setFocus();
        }
        else if (param.toString() == "edit")
        {
            _mode = cEdit;

            _item->setReadOnly(TRUE);
            _prodcat->setEnabled(FALSE);
            _typeGroup->setEnabled(FALSE);
            _dscitem->setReadOnly(TRUE);
            _discountBy->setEnabled(FALSE);

            if(_ipsitemid != -1)
                _qtyBreak->setFocus();
            else if(_ipsprodcatid != -1)
                _qtyBreakCat->setFocus();
        }
        else if (param.toString() == "view")
        {
            _mode = cView;

            _item->setReadOnly(TRUE);
            _prodcat->setEnabled(FALSE);
            _qtyBreak->setEnabled(FALSE);
            _qtyBreakCat->setEnabled(FALSE);
            _qtyBreakFreight->setEnabled(FALSE);
            _price->setEnabled(FALSE);
            _discount->setEnabled(FALSE);
            _fixedAmtDiscount->setEnabled(FALSE);
            _priceFreight->setEnabled(FALSE);
            _typeGroup->setEnabled(FALSE);
            _typeFreightGroup->setEnabled(FALSE);
            _siteFreight->setEnabled(FALSE);
            _zoneFreightGroup->setEnabled(FALSE);
            _shipViaFreightGroup->setEnabled(FALSE);
            _freightClassGroup->setEnabled(FALSE);
            _dscitem->setReadOnly(TRUE);
            _discountBy->setEnabled(FALSE);
            _buttonBox->setStandardButtons(QDialogButtonBox::Close);
        }
    }

    return NoError;
}
Example #19
0
enum SetResponse substituteList::set(const ParameterList &pParams)
{
  XSqlQuery substituteet;
  XDialog::set(pParams);
  QVariant param;
  bool     valid;

  param = pParams.value("womatl_id", &valid);
  if (valid)
  {
    substituteet.prepare( "SELECT womatl_itemsite_id,"
               "       bomitem_id, COALESCE(bomitem_subtype, 'I') AS subtype,"
               "       COALESCE(wo_id, 0) AS wo_id "
               "FROM womatl LEFT OUTER JOIN bomitem ON (bomitem_id=womatl_bomitem_id) "
               "            LEFT OUTER JOIN wo ON ( (wo_ordtype='W') AND"
               "                                    (wo_ordid=womatl_wo_id) AND"
               "                                    (wo_itemsite_id=womatl_itemsite_id) ) "
               "WHERE (womatl_id=:womatl_id);" );
    substituteet.bindValue(":womatl_id", param.toInt());
    substituteet.exec();
    if (substituteet.first())
    {
      if (substituteet.value("wo_id").toInt() > 0)
      {
        QMessageBox::warning(this, tr("Child Work Order"),
            tr("A child Work Order exists for this Material \n"
               "Requirement.  You should delete this \n"
               "child Work Order before substituting.") );
      }
      _item->setItemsiteid(substituteet.value("womatl_itemsite_id").toInt());
      _item->setReadOnly(TRUE);
      _warehouse->setEnabled(FALSE);
      
      _bomitemid = substituteet.value("bomitem_id").toInt();
      _itemsiteid = substituteet.value("womatl_itemsite_id").toInt();
      _source = substituteet.value("subtype").toString();

      sFillList();
    }
  }

  _byLeadTime->setChecked(pParams.inList("byLeadTime"));

  param = pParams.value("byDays", &valid);
  if (valid)
  {
   _byDays->setChecked(TRUE);
   _days->setValue(param.toInt());
  }

  param = pParams.value("byDate", &valid);
  if (valid)
  {
   _byDate->setChecked(TRUE);
   _date->setDate(param.toDate());
  }

  if (pParams.inList("run"))
  {
    sFillList();
    return NoError_Run;
  }

  return NoError;
}
Example #20
0
QVariant LocaleModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid()
        || role != Qt::DisplayRole && role != Qt::EditRole && role != Qt::ToolTipRole
        || index.column() >= g_model_cols
        || index.row() >= g_locale_list_count + 2)
        return QVariant();

    QVariant data;
    if (index.column() < g_model_cols - 1)
        data = m_data_list.at(index.column());

    if (index.row() == 0) {
        if (role == Qt::ToolTipRole)
            return QVariant();
        switch (index.column()) {
            case 0:
                return data.toDouble();
            case 1:
                return data.toDate();
            case 2:
                return data.toDate();
            case 3:
                return data.toTime();
            case 4:
                return data.toTime();
            case 5:
                return QVariant();
            default:
                break;
        }
    } else {
        QLocale locale;
        if (index.row() == 1) {
            locale = QLocale::system();
        } else {
            LocaleListItem item = g_locale_list[index.row() - 2];
            locale = QLocale((QLocale::Language)item.language, (QLocale::Country)item.country);
        }

        switch (index.column()) {
            case 0:
                if (role == Qt::ToolTipRole)
                    return QVariant();
                return locale.toString(data.toDouble());
            case 1:
                if (role == Qt::ToolTipRole)
                    return locale.dateFormat(QLocale::LongFormat);
                return locale.toString(data.toDate(), QLocale::LongFormat);
            case 2:
                if (role == Qt::ToolTipRole)
                    return locale.dateFormat(QLocale::ShortFormat);
                return locale.toString(data.toDate(), QLocale::ShortFormat);
            case 3:
                if (role == Qt::ToolTipRole)
                    return locale.timeFormat(QLocale::LongFormat);
                return locale.toString(data.toTime(), QLocale::LongFormat);
            case 4:
                if (role == Qt::ToolTipRole)
                    return locale.timeFormat(QLocale::ShortFormat);
                return locale.toString(data.toTime(), QLocale::ShortFormat);
            case 5:
                if (role == Qt::ToolTipRole)
                    return QVariant();
                return locale.name();
            default:
                break;
        }
    }

    return QVariant();
}
Example #21
0
void KConfigBase::writeEntry(const char *pKey, const QVariant &prop, bool bPersistent, bool bGlobal, bool bNLS)
{
    switch(prop.type())
    {
        case QVariant::Invalid:
            writeEntry(pKey, "", bPersistent, bGlobal, bNLS);
            return;
        case QVariant::String:
            writeEntry(pKey, prop.toString(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::StringList:
            writeEntry(pKey, prop.toStringList(), ',', bPersistent, bGlobal, bNLS);
            return;
        case QVariant::List:
        {
            QValueList< QVariant > list = prop.toList();
            QValueList< QVariant >::ConstIterator it = list.begin();
            QValueList< QVariant >::ConstIterator end = list.end();
            QStringList strList;

            for(; it != end; ++it)
                strList.append((*it).toString());

            writeEntry(pKey, strList, ',', bPersistent, bGlobal, bNLS);

            return;
        }
        case QVariant::Font:
            writeEntry(pKey, prop.toFont(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Point:
            writeEntry(pKey, prop.toPoint(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Rect:
            writeEntry(pKey, prop.toRect(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Size:
            writeEntry(pKey, prop.toSize(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Color:
            writeEntry(pKey, prop.toColor(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Int:
            writeEntry(pKey, prop.toInt(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::UInt:
            writeEntry(pKey, prop.toUInt(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::LongLong:
            writeEntry(pKey, prop.toLongLong(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::ULongLong:
            writeEntry(pKey, prop.toULongLong(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Bool:
            writeEntry(pKey, prop.toBool(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Double:
            writeEntry(pKey, prop.toDouble(), bPersistent, bGlobal, 'g', 6, bNLS);
            return;
        case QVariant::DateTime:
            writeEntry(pKey, prop.toDateTime(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Date:
            writeEntry(pKey, QDateTime(prop.toDate()), bPersistent, bGlobal, bNLS);
            return;

        case QVariant::Pixmap:
        case QVariant::Image:
        case QVariant::Brush:
        case QVariant::Palette:
        case QVariant::ColorGroup:
        case QVariant::Map:
        case QVariant::IconSet:
        case QVariant::CString:
        case QVariant::PointArray:
        case QVariant::Region:
        case QVariant::Bitmap:
        case QVariant::Cursor:
        case QVariant::SizePolicy:
        case QVariant::Time:
        case QVariant::ByteArray:
        case QVariant::BitArray:
        case QVariant::KeySequence:
        case QVariant::Pen:
            break;
    }

    Q_ASSERT(0);
}
Example #22
0
enum SetResponse workOrder::set(const ParameterList &pParams)
{
  _captive = TRUE;

  QString  returnValue;
  QVariant param;
  bool     valid;

  param = pParams.value("itemsite_id", &valid);
  if (valid)
  {
    _item->setItemsiteid(param.toInt());
    _item->setEnabled(FALSE);
    _warehouse->setEnabled(FALSE);

    _qty->setFocus();
  }

  param = pParams.value("qty", &valid);
  if (valid)
    _qty->setText(formatQty(param.toDouble()));

  param = pParams.value("dueDate", &valid);
  if (valid)
  {
    _dueDate->setDate(param.toDate());
    sUpdateStartDate();
  }

  param = pParams.value("wo_id", &valid);
  if (valid)
    _woid = param.toInt();

  param = pParams.value("planord_id", &valid);
  if (valid)
    _planordid = param.toInt();

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if (param.toString() == "new")
    {
      _mode = cNew;

	  _item->setQuery("SELECT DISTINCT item_id, item_number, item_descrip1, item_descrip2,"
                      "       item_active, item_config, item_type, uom_name "
                      "FROM item JOIN uom ON (item_inv_uom_id=uom_id) "
                      "WHERE (item_type IN ('M', 'B') "
					  "AND (item_active)) ");
      _qtyReceivedLit->clear();
      _tabs->removePage(_tabs->page(3));

      populateWoNumber();
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;

     _item->setQuery("SELECT DISTINCT item_id, item_number, item_descrip1, item_descrip2,"
                     "       item_active, item_config, item_type, uom_name "
                     "FROM item JOIN uom ON (item_inv_uom_id=uom_id) "
                     "WHERE (item_type IN ('M', 'B', 'J')) ");
      XSqlQuery wo;
      wo.prepare( "SELECT wo_itemsite_id, wo_priority, wo_status,"
                  "       formatWoNumber(wo_id) AS f_wonumber,"
                  "       formatQty(wo_qtyord) AS f_ordered,"
                  "       formatQty(wo_qtyrcv) AS f_received,"
                  "       wo_startdate, wo_duedate,"
                  "       formatMoney(wo_wipvalue) AS f_wipvalue,"
				  "       formatMoney(wo_postedvalue) AS f_postedvalue,"
				  "       formatMoney(wo_postedvalue-wo_wipvalue) AS f_rcvdvalue,"
                  "       wo_prodnotes, wo_prj_id, "
				  "       wo_bom_rev_id, wo_boo_rev_id, "
				  "       wo_cosmethod "
                  "FROM wo "
                  "WHERE (wo_id=:wo_id);" );
      wo.bindValue(":wo_id", _woid);
      wo.exec();
      if (wo.first())
      {
        _oldPriority = wo.value("wo_priority").toInt();
        _oldStartDate = wo.value("wo_startdate").toDate();
        _oldDueDate = wo.value("wo_duedate").toDate();
        _oldQty = wo.value("f_ordered").toString();

        _woNumber->setText(wo.value("f_wonumber").toString());
        _item->setItemsiteid(wo.value("wo_itemsite_id").toInt());
        _priority->setValue(_oldPriority);
		_postedValue->setText(wo.value("f_postedvalue").toString());
		_rcvdValue->setText(wo.value("f_rcvdvalue").toString());
        _wipValue->setText(wo.value("f_wipvalue").toString());
        _qty->setText(wo.value("f_ordered").toString());
        _qtyReceived->setText(wo.value("f_received").toString());
        _startDate->setDate(_oldStartDate);
        _dueDate->setDate(_oldDueDate);
        _productionNotes->setText(wo.value("wo_prodnotes").toString());
        _comments->setId(_woid);
        _project->setId(wo.value("wo_prj_id").toInt());
		_bomRevision->setId(wo.value("wo_bom_rev_id").toInt());
		_booRevision->setId(wo.value("wo_boo_rev_id").toInt());

		if (wo.value("wo_cosmethod").toString() == "D")
		  _todate->setChecked(TRUE);
		else if (wo.value("wo_cosmethod").toString() == "P")
		  _proportional->setChecked(TRUE);
		else
	      _jobCosGroup->hide();

        // If the W/O is closed or Released don't allow changing some items.
        if(wo.value("wo_status").toString() == "C" || wo.value("wo_status") == "R")
        {
          _priority->setEnabled(false);
          _qty->setEnabled(false);
          _dueDate->setEnabled(false);
          _startDate->setEnabled(false);
        }

        _startDate->setEnabled(true);
        _woNumber->setEnabled(false);
        _item->setReadOnly(true);
	    _bomRevision->setEnabled(wo.value("wo_status").toString() == "O");
        _booRevision->setEnabled(wo.value("wo_status").toString() == "O");
        _warehouse->setEnabled(false);
        _comments->setReadOnly(false);
        _leadTimeLit->hide();
        _leadTime->hide();
        _daysLit->hide();
        _printTraveler->hide();
        _bottomSpacer->hide();
        _create->setText(tr("&Save"));

        _close->setFocus();
      }
      else
      {
        systemError(this, tr("A System Error occurred at %1::%2, W/O ID %3.")
                          .arg(__FILE__)
                          .arg(__LINE__)
                          .arg(_woid) );
        close();
      }
    }
    else if (param.toString() == "view")
    {
      _mode = cView;

      _item->setQuery("SELECT DISTINCT item_id, item_number, item_descrip1, item_descrip2,"
                      "       item_active, item_config, item_type, uom_name "
                      "FROM item JOIN uom ON (item_inv_uom_id=uom_id) "
                      "WHERE (item_type IN ('M', 'B', 'J')) ");
      XSqlQuery wo;
      wo.prepare( "SELECT wo_itemsite_id, wo_priority,"
                  "       formatWoNumber(wo_id) AS f_wonumber,"
                  "       formatQty(wo_qtyord) AS f_ordered,"
                  "       formatQty(wo_qtyrcv) AS f_received,"
                  "       wo_startdate, wo_duedate,"
                  "       formatMoney(wo_wipvalue) AS f_wipvalue,"
				  "       formatMoney(wo_postedvalue) AS f_postedvalue,"
				  "       formatMoney(wo_postedvalue-wo_wipvalue) AS f_rcvdvalue,"
                  "       wo_prodnotes, wo_prj_id, wo_bom_rev_id, "
				  "       wo_boo_rev_id, wo_cosmethod "
                  "FROM wo "
                  "WHERE (wo_id=:wo_id);" );
      wo.bindValue(":wo_id", _woid);
      wo.exec();
      if (wo.first())
      {
        _mode = cView;

        _woNumber->setText(wo.value("f_wonumber").toString());
        _item->setItemsiteid(wo.value("wo_itemsite_id").toInt());
        _priority->setValue(wo.value("wo_priority").toInt());
		_postedValue->setText(wo.value("f_postedvalue").toString());
		_rcvdValue->setText(wo.value("f_rcvdvalue").toString());
        _wipValue->setText(wo.value("f_wipvalue").toString());
        _qty->setText(wo.value("f_ordered").toString());
        _qtyReceived->setText(wo.value("f_received").toString());
        _startDate->setDate(wo.value("wo_startdate").toDate());
        _dueDate->setDate(wo.value("wo_duedate").toDate());
        _productionNotes->setText(wo.value("wo_prodnotes").toString());
        _comments->setId(_woid);
        _project->setId(wo.value("wo_prj_id").toInt());
		_bomRevision->setId(wo.value("wo_bom_rev_id").toInt());
		_booRevision->setId(wo.value("wo_boo_rev_id").toInt());

		if (wo.value("wo_cosmethod").toString() == "D")
		  _todate->setChecked(TRUE);
		else if (wo.value("wo_cosmethod").toString() == "P")
		  _proportional->setChecked(TRUE);
		else
	      _jobCosGroup->hide();
 
        _woNumber->setEnabled(FALSE);
        _item->setReadOnly(TRUE);
        _bomRevision->setEnabled(FALSE);
        _booRevision->setEnabled(FALSE);
        _warehouse->setEnabled(FALSE);
        _priority->setEnabled(FALSE);
        _qty->setEnabled(FALSE);
        _startDate->setEnabled(FALSE);
        _dueDate->setEnabled(FALSE);
        _productionNotes->setReadOnly(TRUE);
        _create->hide();
        _leadTimeLit->hide();
        _leadTime->hide();
        _daysLit->hide();
        _printTraveler->hide();
        _bottomSpacer->hide();
        _close->setText(tr("&Close"));
        _project->setEnabled(FALSE);
        _itemcharView->setEnabled(false);
		_jobCosGroup->setEnabled(FALSE);
        
        _close->setFocus();
      }
      else
      {
        systemError(this, tr("A System Error occurred at %1::%2, W/O ID %3.")
                          .arg(__FILE__)
                          .arg(__LINE__)
                          .arg(_woid) );
        close();
      }
    }
    else if (param.toString() == "release")
    {
      _mode = cRelease;
      _tabs->removePage(_tabs->page(3));

      q.prepare( "SELECT planord_itemsite_id, planord_duedate,"
                 "       CASE WHEN(planord_mps) THEN 'P'"
                 "            ELSE 'M'"
                 "       END AS sourcetype,"
                 "       CASE WHEN(planord_mps) THEN planord_pschitem_id"
                 "            ELSE planord_id"
                 "       END AS sourceid,"
                 "       formatQty(planord_qty) AS qty "
                 "FROM planord "
                 "WHERE (planord_id=:planord_id);" );
      q.bindValue(":planord_id", _planordid);
      q.exec();
      if (q.first())
      {
        _item->setReadOnly(TRUE);
        _warehouse->setEnabled(FALSE);

        _planordtype=q.value("sourcetype").toString();
        _sourceid=q.value("sourceid").toInt();
        _qty->setText(q.value("qty").toString());
        _dueDate->setDate(q.value("planord_duedate").toDate());
        _item->setItemsiteid(q.value("planord_itemsite_id").toInt());

        sUpdateStartDate();
        populateWoNumber();

        _qty->setEnabled(FALSE);
        _qtyReceivedLit->clear();
        _startDate->setEnabled(FALSE);
        _dueDate->setEnabled(FALSE);
        _wipValueLit->hide();
        _wipValue->hide();
        _leadTimeLit->hide();
        _leadTime->hide();
        _daysLit->hide();

        _create->setFocus();
      }
      else
      {
        systemError(this, tr("A System Error occurred at %1::%2, Planned Order ID %3.")
                          .arg(__FILE__)
                          .arg(__LINE__)
                          .arg(_planordid) );
        close();
      }
    }
  }
  
  return NoError;
}
Example #23
0
void PSV_Public::printMes(const QVariant &mes, const QString &frefix)
{    
    QString message;
    int type = mes.type();
    switch(type)
    {
    case QVariant::Bool :
        message = mes.toBool() ? "true":"false";
        break;
    case QVariant::Color :
    {
        QColor color = mes.value<QColor>();
        message = QObject::tr("colorname:%1,r=%2,g=%3,b=%4")
                .arg(color.name())
                .arg(color.red())
                .arg(color.green())
                .arg(color.blue());
    }
        break;
    case QVariant::Date:
        message = mes.toDate().toString("yyyy-MM-dd");
        break;
    case QVariant::DateTime:
        message = mes.toDateTime().toString("yyyy-MM-dd hh:mm:ss");
        break;
    case QVariant::Double:
        message = QString::number(mes.toDouble());
        break;
    case QVariant::UInt:
    case QVariant::Int:
        message = QString::number(mes.toInt());
        break;
    case QVariant::ULongLong:
    case QVariant::LongLong:
        message = QString::number(mes.toLongLong());
        break;
    case QVariant::Line:
    {
        QLine line = mes.toLine();
        message = QObject::tr("Line x1=%1,y1=%2,x2=%3,y2=%4")
                .arg(line.x1()).arg(line.y1()).arg(line.x2()).arg(line.y2());
    }
        break;
    case QVariant::LineF:
    {
        QLineF lineF = mes.toLineF();
        message = QObject::tr("LineF x1=%1,y1=%2,x2=%3,y2=%4")
                .arg(lineF.x1()).arg(lineF.y1()).arg(lineF.x2()).arg(lineF.y2());
    }
        break;
    case QVariant::Point:
    {
        QPoint point = mes.toPoint();
        message = QObject::tr("point x=%1,y=%2")
                .arg(point.x()).arg(point.y());
    }
        break;
    case QVariant::PointF:
    {
        QPointF pointF = mes.toPointF();
        message = QObject::tr("pointF x=%1,y=%2")
                .arg(pointF.x()).arg(pointF.y());
    }
        break;
    case QVariant::Rect:
    {
        QRect rect = mes.toRect();
        message = QObject::tr("rect x=%1,y=%2,width=%3,height=%4")
                .arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height());
    }
        break;
    case QVariant::RectF:
    {
        QRectF rectF = mes.toRect();
        message = QObject::tr("rectF x=%1,y=%2,width=%3,height=%4")
                .arg(rectF.x()).arg(rectF.y()).arg(rectF.width()).arg(rectF.height());
    }
        break;

    default:
        message = QObject::tr("type = %1,<%2>").arg(type).arg(mes.toString());
        break;
    }
    QString outMes = QObject::tr("%1 %2").arg(frefix).arg(message);

    qDebug()<<QObject::tr("PSV_LIB:<%1>%2").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")).arg(outMes);
}
Example #24
0
QVariant PeopleModel::data(const QModelIndex &item, int role) const
{
    if (role == Qt::DisplayRole) {
        const QSqlRecord rec = record(item.row());
        const int column = item.column();
        if (column == 0) {
            return rec.field("first_name").value();
        } else if (column == 1) {
            return QStringLiteral("%1 %2").arg(rec.field("surname").value().toString(),
                                               rec.field("suffix").value().toString().simplified());
        } else if (column == 2) {
            const QDate birthDate = rec.field("birth_date").value().toDate();
            if (birthDate.isValid()) {
                return birthDate;
            }
            return rec.field("birth_date").value();
        } else if (column == 3) {
            return rec.field("birth_place").value();
        } else if (column == 4) {
            const bool alive = rec.field("alive").value().toBool();
            if (alive)
                return tr("Alive");
            const QVariant dead = rec.field("death_date").value();
            const QDate deathDate = dead.toDate();
            if (deathDate.isValid()) {
                return deathDate;
            } else if (!dead.toString().isEmpty()) {
                return dead;
            }
            return tr("Deceased");
        } else if (column == 5) {
            return rec.field("death_place").value();
        } else if (column == 6) {
            return rec.field("occupation").value();
        }
    } else if (role == Qt::ToolTipRole) {
        const QSqlRecord rec = record(item.row());
        const int column = item.column();
        if (column == 2) {
            const QDate birthDate = rec.field("birth_date").value().toDate();
            if (birthDate.isValid()) {
                return birthDate.toString(Qt::DefaultLocaleLongDate);
            }
        } else if (column == 4) {
            const QDate deathDate = rec.field("death_date").value().toDate();
            if (deathDate.isValid()) {
                return deathDate.toString(Qt::DefaultLocaleLongDate);
            }
        }
    } else if (role == Qt::DecorationRole) {
        const QSqlRecord rec = record(item.row());
        const int column = item.column();
        if (column == 0) {
            const QString sex = rec.value("sex").toString();
            if (sex == "M") {
                return QIcon(":/icons/male.png");
            } else if (sex == "F") {
                return QIcon(":/icons/female.png");
            }
            return QVariant();
        }
    }

    return QSqlQueryModel::data(item, role);
}
Example #25
0
bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value )
{
    if ( !editor )
        return false;

    QgsVectorLayer::EditType editType = vl->editType( idx );
    const QgsField &field = vl->pendingFields()[idx];
    QVariant::Type myFieldType = field.type();

    QSettings settings;
    QString nullValue = settings.value( "qgis/nullValue", "NULL" ).toString();

    switch ( editType )
    {
    case QgsVectorLayer::Classification:
    case QgsVectorLayer::UniqueValues:
    case QgsVectorLayer::Enumeration:
    case QgsVectorLayer::ValueMap:
    case QgsVectorLayer::ValueRelation:
    {
        QVariant v = value;
        QComboBox *cb = qobject_cast<QComboBox *>( editor );
        if ( !cb )
            return false;

        if ( v.isNull() )
        {
            v = nullValue;
        }

        int idx = cb->findData( v );
        if ( idx < 0 )
            return false;

        cb->setCurrentIndex( idx );
    }
    break;

    case QgsVectorLayer::DialRange:
    case QgsVectorLayer::SliderRange:
    case QgsVectorLayer::EditRange:
    {
        if ( myFieldType == QVariant::Int )
        {
            if ( editType == QgsVectorLayer::EditRange )
            {
                QSpinBox *sb = qobject_cast<QSpinBox *>( editor );
                if ( !sb )
                    return false;
                sb->setValue( value.toInt() );
            }
            else
            {
                QAbstractSlider *sl = qobject_cast<QAbstractSlider *>( editor );
                if ( !sl )
                    return false;
                sl->setValue( value.toInt() );
            }
            break;
        }
        else if ( myFieldType == QVariant::Double )
        {
            QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox *>( editor );
            if ( !dsb )
                return false;
            dsb->setValue( value.toDouble() );
        }
    }

    case QgsVectorLayer::CheckBox:
    {
        QGroupBox *gb = qobject_cast<QGroupBox *>( editor );
        if ( gb )
        {
            QPair<QString, QString> states = vl->checkedState( idx );
            gb->setChecked( value == states.first );
            break;
        }

        QCheckBox *cb = qobject_cast<QCheckBox *>( editor );
        if ( cb )
        {
            QPair<QString, QString> states = vl->checkedState( idx );
            cb->setChecked( value == states.first );
            break;
        }
    }

    // fall-through

    case QgsVectorLayer::LineEdit:
    case QgsVectorLayer::UniqueValuesEditable:
    case QgsVectorLayer::Immutable:
    case QgsVectorLayer::UuidGenerator:
    default:
    {
        QLineEdit *le = qobject_cast<QLineEdit *>( editor );
        QComboBox *cb = qobject_cast<QComboBox *>( editor );
        QTextEdit *te = qobject_cast<QTextEdit *>( editor );
        QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( editor );
        if ( !le && ! cb && !te && !pte )
            return false;

        QString text;
        if ( value.isNull() )
        {
            if ( myFieldType == QVariant::Int || myFieldType == QVariant::Double || myFieldType == QVariant::LongLong )
                text = "";
            else if ( editType == QgsVectorLayer::UuidGenerator )
                text = QUuid::createUuid().toString();
            else
                text = nullValue;
        }
        else
        {
            text = value.toString();
        }

        if ( le )
            le->setText( text );
        if ( cb && cb->isEditable() )
            cb->setEditText( text );
        if ( te )
            te->setHtml( text );
        if ( pte )
            pte->setPlainText( text );
    }
    break;

    case QgsVectorLayer::FileName:
    case QgsVectorLayer::Calendar:
    {
        QCalendarWidget *cw = qobject_cast<QCalendarWidget *>( editor );
        if ( cw )
        {
            cw->setSelectedDate( value.toDate() );
            break;
        }

        QLineEdit* le = qobject_cast<QLineEdit*>( editor );
        if ( !le )
        {
            le = editor->findChild<QLineEdit *>();
        }
        if ( !le )
        {
            return false;
        }
        le->setText( value.toString() );
    }
    break;
    }

    return true;
}
Example #26
0
bool qgsVariantLessThan( const QVariant &lhs, const QVariant &rhs )
{
  // invalid < NULL < any value
  if ( !lhs.isValid() )
    return rhs.isValid();
  else if ( lhs.isNull() )
    return rhs.isValid() && !rhs.isNull();
  else if ( !rhs.isValid() || rhs.isNull() )
    return false;

  switch ( lhs.type() )
  {
    case QVariant::Int:
      return lhs.toInt() < rhs.toInt();
    case QVariant::UInt:
      return lhs.toUInt() < rhs.toUInt();
    case QVariant::LongLong:
      return lhs.toLongLong() < rhs.toLongLong();
    case QVariant::ULongLong:
      return lhs.toULongLong() < rhs.toULongLong();
    case QVariant::Double:
      return lhs.toDouble() < rhs.toDouble();
    case QVariant::Char:
      return lhs.toChar() < rhs.toChar();
    case QVariant::Date:
      return lhs.toDate() < rhs.toDate();
    case QVariant::Time:
      return lhs.toTime() < rhs.toTime();
    case QVariant::DateTime:
      return lhs.toDateTime() < rhs.toDateTime();
    case QVariant::Bool:
      return lhs.toBool() < rhs.toBool();

    case QVariant::List:
    {
      const QList<QVariant> &lhsl = lhs.toList();
      const QList<QVariant> &rhsl = rhs.toList();

      int i, n = std::min( lhsl.size(), rhsl.size() );
      for ( i = 0; i < n && lhsl[i].type() == rhsl[i].type() && lhsl[i].isNull() == rhsl[i].isNull() && lhsl[i] == rhsl[i]; i++ )
        ;

      if ( i == n )
        return lhsl.size() < rhsl.size();
      else
        return qgsVariantLessThan( lhsl[i], rhsl[i] );
    }

    case QVariant::StringList:
    {
      const QStringList &lhsl = lhs.toStringList();
      const QStringList &rhsl = rhs.toStringList();

      int i, n = std::min( lhsl.size(), rhsl.size() );
      for ( i = 0; i < n && lhsl[i] == rhsl[i]; i++ )
        ;

      if ( i == n )
        return lhsl.size() < rhsl.size();
      else
        return lhsl[i] < rhsl[i];
    }

    default:
      return QString::localeAwareCompare( lhs.toString(), rhs.toString() ) < 0;
  }
}
Example #27
0
QVariant QSystemLocale::query(QueryType type, QVariant in) const
{
    QSystemLocaleData *d = qSystemLocaleData();

    if (type == LocaleChanged) {
        d->readEnvironment();
        return QVariant();
    }

    QReadLocker locker(&d->lock);

    const QLocale &lc_numeric = d->lc_numeric;
    const QLocale &lc_time = d->lc_time;
    const QLocale &lc_monetary = d->lc_monetary;
    const QLocale &lc_messages = d->lc_messages;

    switch (type) {
    case DecimalPoint:
        return lc_numeric.decimalPoint();
    case GroupSeparator:
        return lc_numeric.groupSeparator();
    case ZeroDigit:
        return lc_numeric.zeroDigit();
    case NegativeSign:
        return lc_numeric.negativeSign();
    case DateFormatLong:
        return lc_time.dateFormat(QLocale::LongFormat);
    case DateFormatShort:
        return lc_time.dateFormat(QLocale::ShortFormat);
    case TimeFormatLong:
        return lc_time.timeFormat(QLocale::LongFormat);
    case TimeFormatShort:
        return lc_time.timeFormat(QLocale::ShortFormat);
    case DayNameLong:
        return lc_time.dayName(in.toInt(), QLocale::LongFormat);
    case DayNameShort:
        return lc_time.dayName(in.toInt(), QLocale::ShortFormat);
    case MonthNameLong:
        return lc_time.monthName(in.toInt(), QLocale::LongFormat);
    case MonthNameShort:
        return lc_time.monthName(in.toInt(), QLocale::ShortFormat);
    case StandaloneMonthNameLong:
        return lc_time.standaloneMonthName(in.toInt(), QLocale::LongFormat);
    case StandaloneMonthNameShort:
        return lc_time.standaloneMonthName(in.toInt(), QLocale::ShortFormat);
    case DateToStringLong:
        return lc_time.toString(in.toDate(), QLocale::LongFormat);
    case DateToStringShort:
        return lc_time.toString(in.toDate(), QLocale::ShortFormat);
    case TimeToStringLong:
        return lc_time.toString(in.toTime(), QLocale::LongFormat);
    case TimeToStringShort:
        return lc_time.toString(in.toTime(), QLocale::ShortFormat);
    case DateTimeFormatLong:
        return lc_time.dateTimeFormat(QLocale::LongFormat);
    case DateTimeFormatShort:
        return lc_time.dateTimeFormat(QLocale::ShortFormat);
    case DateTimeToStringLong:
        return lc_time.toString(in.toDateTime(), QLocale::LongFormat);
    case DateTimeToStringShort:
        return lc_time.toString(in.toDateTime(), QLocale::ShortFormat);
    case PositiveSign:
        return lc_numeric.positiveSign();
    case AMText:
        return lc_time.amText();
    case PMText:
        return lc_time.pmText();
    case FirstDayOfWeek:
        return lc_time.firstDayOfWeek();
    case CurrencySymbol:
        return lc_monetary.currencySymbol(QLocale::CurrencySymbolFormat(in.toUInt()));
    case CurrencyToString: {
        switch (in.type()) {
        case QVariant::Int:
            return lc_monetary.toCurrencyString(in.toInt());
        case QVariant::UInt:
            return lc_monetary.toCurrencyString(in.toUInt());
        case QVariant::Double:
            return lc_monetary.toCurrencyString(in.toDouble());
        case QVariant::LongLong:
            return lc_monetary.toCurrencyString(in.toLongLong());
        case QVariant::ULongLong:
            return lc_monetary.toCurrencyString(in.toULongLong());
        default:
            break;
        }
        return QString();
    }
    case MeasurementSystem: {
        const QString meas_locale = QString::fromLatin1(d->lc_measurement_var.constData(), d->lc_measurement_var.size());
        if (meas_locale.compare(QLatin1String("Metric"), Qt::CaseInsensitive) == 0)
            return QLocale::MetricSystem;
        if (meas_locale.compare(QLatin1String("Other"), Qt::CaseInsensitive) == 0)
            return QLocale::MetricSystem;
        return QVariant((int)QLocale(meas_locale).measurementSystem());
    }
    case UILanguages: {
        if (!d->uiLanguages.isEmpty())
            return d->uiLanguages;
        QString languages = QString::fromLatin1(qgetenv("LANGUAGE"));
        QStringList lst;
        if (languages.isEmpty())
            lst.append(QString::fromLatin1(d->lc_messages_var));
        else
            lst = languages.split(QLatin1Char(':'));

        for (int i = 0; i < lst.size(); ++i) {
            const QString &name = lst.at(i);
            QString lang, script, cntry;
            if (qt_splitLocaleName(name, lang, script, cntry)) {
                if (!cntry.length())
                    d->uiLanguages.append(lang);
                else
                    d->uiLanguages.append(lang % QLatin1Char('-') % cntry);
            }
        }
        return d->uiLanguages.isEmpty() ? QVariant() : QVariant(d->uiLanguages);
    }
    case StringToStandardQuotation:
        return lc_messages.quoteString(in.value<QStringRef>());
    case StringToAlternateQuotation:
        return lc_messages.quoteString(in.value<QStringRef>(), QLocale::AlternateQuotation);
    case ListToSeparatedString:
        return lc_messages.createSeparatedList(in.toStringList());
    case LocaleChanged:
        Q_ASSERT(false);
    default:
        break;
    }
    return QVariant();
}
Example #28
0
uint qHash( const QVariant &variant )
{
  if ( !variant.isValid() || variant.isNull() )
    return std::numeric_limits<uint>::max();

  switch ( variant.type() )
  {
    case QVariant::Int:
      return qHash( variant.toInt() );
    case QVariant::UInt:
      return qHash( variant.toUInt() );
    case QVariant::Bool:
      return qHash( variant.toBool() );
    case QVariant::Double:
      return qHash( variant.toDouble() );
    case QVariant::LongLong:
      return qHash( variant.toLongLong() );
    case QVariant::ULongLong:
      return qHash( variant.toULongLong() );
    case QVariant::String:
      return qHash( variant.toString() );
    case QVariant::Char:
      return qHash( variant.toChar() );
    case QVariant::List:

#if QT_VERSION >= 0x050600
      return qHash( variant.toList() );
#else
      {
        QVariantList list = variant.toList();
        if ( list.isEmpty() )
          return -1;
        else
          return qHash( list.at( 0 ) );
      }
#endif
    case QVariant::StringList:
#if QT_VERSION >= 0x050600
      return qHash( variant.toStringList() );
#else
      {
        QStringList list = variant.toStringList();
        if ( list.isEmpty() )
          return -1;
        else
          return qHash( list.at( 0 ) );
      }
#endif
    case QVariant::ByteArray:
      return qHash( variant.toByteArray() );
    case QVariant::Date:
      return qHash( variant.toDate() );
    case QVariant::Time:
      return qHash( variant.toTime() );
    case QVariant::DateTime:
      return qHash( variant.toDateTime() );
    case QVariant::Url:
    case QVariant::Locale:
    case QVariant::RegExp:
      return qHash( variant.toString() );
    default:
      break;
  }

  return std::numeric_limits<uint>::max();
}
Example #29
0
enum SetResponse voucherItem::set(const ParameterList &pParams)
{
  XDialog::set(pParams);
  QVariant param;
  bool     valid;

  param = pParams.value("curr_id", &valid);
  if (valid)
  {
    _freightToVoucher->setId(param.toInt());
	_tax->setId(param.toInt());
  }

  param = pParams.value("effective", &valid);
  if (valid)
  {
	_freightToVoucher->setEffective(param.toDate());
	_tax->setEffective(param.toDate());
  }

  param = pParams.value("vohead_id", &valid);
  if (valid)
  {
    _voheadid = param.toInt();
    q.prepare("SELECT vohead_taxzone_id "
	          "FROM vohead "
	          "WHERE (vohead_id = :vohead_id);");
    q.bindValue(":vohead_id", _voheadid);
    q.exec();
    if (q.first())
      _taxzoneid = q.value("vohead_taxzone_id").toInt();
    else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return UndefinedError;
    }
	else
	  _taxzoneid = -1;
  }
  else
    _voheadid = -1;

  param = pParams.value("poitem_id", &valid);
  if (valid)
  {
    _poitemid = param.toInt();

    q.prepare( "SELECT pohead_number, poitem_linenumber, poitem_taxtype_id, "
               "       COALESCE(itemsite_id, -1) AS itemsiteid,"
               "       poitem_vend_item_number, poitem_vend_uom, poitem_vend_item_descrip,"
               "       poitem_duedate,"
               "       poitem_qty_ordered,"
               "       poitem_qty_received,"
               "       poitem_qty_returned,"
               "       ( SELECT COALESCE(SUM(porecv_qty), 0)"
               "                    FROM porecv"
               "                    WHERE ( (porecv_posted)"
               "                     AND (NOT porecv_invoiced)"
       	       "                     AND (porecv_vohead_id IS NULL)"
               "                     AND (porecv_poitem_id=poitem_id) ) ) AS f_received,"
               "       ( SELECT COALESCE(SUM(poreject_qty), 0)"
               "                    FROM poreject"
               "                    WHERE ( (poreject_posted)"
               "                     AND (NOT poreject_invoiced)"
               "                     ANd (poreject_vohead_id IS NULL)"
               "                     AND (poreject_poitem_id=poitem_id) ) ) AS f_rejected,"
               "       poitem_unitprice,"
               "       poitem_unitprice * poitem_qty_ordered AS f_extprice,"
               "       poitem_freight "
               "FROM pohead, "
	       " poitem LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id) "
           "WHERE ( (poitem_pohead_id=pohead_id)"
               " AND (poitem_id=:poitem_id) );" );
    q.bindValue(":poitem_id", _poitemid);
    q.exec();
    if (q.first())
    {
      _poNumber->setText(q.value("pohead_number").toString());
      _lineNumber->setText(q.value("poitem_linenumber").toString());
      _vendItemNumber->setText(q.value("poitem_vend_item_number").toString());
      _vendUOM->setText(q.value("poitem_vend_uom").toString());
      _vendDescription->setText(q.value("poitem_vend_item_descrip").toString());
      _dueDate->setDate(q.value("poitem_duedate").toDate());
      _ordered->setText(q.value("poitem_qty_ordered").toDouble());
      _received->setText(q.value("poitem_qty_received").toDouble());
      _rejected->setText(q.value("poitem_qty_returned").toDouble());
      _uninvoicedReceived->setText(q.value("f_received").toDouble());
      _uninvoicedRejected->setText(q.value("f_rejected").toDouble());
      _unitPrice->setText(q.value("poitem_unitprice").toDouble());
      _extPrice->setText(q.value("f_extprice").toDouble());
      _lineFreight->setText(q.value("poitem_freight").toDouble());
	  _taxtype->setId(q.value("poitem_taxtype_id").toInt());
      if (q.value("itemsiteid") != -1)
        _item->setItemsiteid(q.value("itemsiteid").toInt());
    }
    else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                  __FILE__, __LINE__);
      reject();
      return UndefinedError;
    }
  }
  else
    _poitemid = -1;

  if ( (_voheadid != -1) && (_poitemid != -1) )
  {
    q.prepare( "SELECT voitem_id, voitem_close, voitem_taxtype_id, "
               "       voitem_qty,"
               "       voitem_freight "
               "FROM voitem "
               "WHERE ( (voitem_vohead_id=:vohead_id)"
               " AND (voitem_poitem_id=:poitem_id) );" );
    q.bindValue(":vohead_id", _voheadid);
    q.bindValue(":poitem_id", _poitemid);
    q.exec();
    if (q.first())
    {
      _voitemid = q.value("voitem_id").toInt();
      _closePoitem->setChecked(q.value("voitem_close").toBool());
      _qtyToVoucher->setText(q.value("voitem_qty").toDouble());
      _freightToVoucher->setLocalValue(q.value("voitem_freight").toDouble());
      _taxtype->setId(q.value("voitem_taxtype_id").toInt());
    }
    else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                  __FILE__, __LINE__);
      reject();
      return UndefinedError;
    }
    else
    {
      _voitemid = -1;
      _closePoitem->setChecked(FALSE);
      _qtyToVoucher->clear();
      _freightToVoucher->clear();
    }

	q.prepare( "SELECT SUM(COALESCE(taxhist_tax, 0.00)) AS taxamt "
	           "FROM voitem LEFT OUTER JOIN voitemtax "
			   " ON (voitem_id = taxhist_parent_id) "
               "WHERE ( (voitem_vohead_id=:vohead_id)"
               " AND (voitem_poitem_id=:poitem_id) );" );
    q.bindValue(":vohead_id", _voheadid);
    q.bindValue(":poitem_id", _poitemid);
    q.exec();
    if (q.first())
	  _tax->setLocalValue(q.value("taxamt").toDouble());
	else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, _rejectedMsg.arg(q.lastError().databaseText()),
                  __FILE__, __LINE__);
      reject();
      return UndefinedError;
    }
    else
      _tax->clear();
  }

  sFillList();
  _saved = TRUE;
  return NoError;
}
Example #30
0
enum SetResponse purchaseRequest::set(ParameterList &pParams)
{
  QVariant param;
  bool     valid;
  int      prid = -1;

  param = pParams.value("itemsite_id", &valid);
  if (valid)
  {
    _item->setItemsiteid(param.toInt());
    _item->setEnabled(FALSE);
    _warehouse->setEnabled(FALSE);
  }

  param = pParams.value("qty", &valid);
  if (valid)
    _qty->setDouble(param.toDouble());

  param = pParams.value("dueDate", &valid);
  if (valid)
    _dueDate->setDate(param.toDate());

  param = pParams.value("planord_id", &valid);
  if (valid)
    _planordid = param.toInt();

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if (param.toString() == "new")
    {
      _mode = cNew;

      populateNumber();
    }
    else if (param.toString() == "view")
    {
      _mode = cView;

      _number->setEnabled(FALSE);
      _item->setReadOnly(TRUE);
      _warehouse->setEnabled(FALSE);
      _qty->setEnabled(FALSE);
      _dueDate->setEnabled(FALSE);
      _notes->setEnabled(FALSE);
      _project->setEnabled(FALSE);
      _create->hide();

      q.prepare( "SELECT pr_itemsite_id,"
                 "       pr_number,"
                 "       wo_qtyreq,"
                 "       pr_duedate,"
                 "       pr_prj_id "
                 "FROM pr "
                 "WHERE (pr_id=:pr_id);" );
      q.bindValue(":pr_id", prid);
      if (q.first())
      {
        _number->setText(q.value("pr_number").toString());
        _item->setItemsiteid(q.value("pr_itemsite_id").toInt());
        _qty->setDouble(q.value("wo_qtyreq").toDouble());
        _dueDate->setDate(q.value("pr_duedate").toDate());
        _project->setId(q.value("pr_prj_id").toInt());
      }
    }
    else if (param.toString() == "release")
    {
      _mode = cRelease;
      _captive = TRUE;

      _number->setEnabled(FALSE);
      _item->setReadOnly(TRUE);
      _warehouse->setEnabled(FALSE);
      _qty->setEnabled(FALSE);
      _dueDate->setEnabled(FALSE);

      q.prepare( "SELECT planord_itemsite_id, planord_duedate,"
                 "       planord_qty "
                 "FROM planord "
                 "WHERE (planord_id=:planord_id);" );
      q.bindValue(":planord_id", _planordid);
      q.exec();
      if (q.first())
      {
        _item->setItemsiteid(q.value("planord_itemsite_id").toInt());
        _qty->setDouble(q.value("planord_qty").toDouble());
        _dueDate->setDate(q.value("planord_duedate").toDate());

        populateNumber();
      }

      _create->setFocus();
    }
  }

  return NoError;
}