Exemple #1
0
void bomItem::populate()
{
  q.prepare( "SELECT bomitem_item_id, bomitem_parent_item_id, item_config,"
             "       bomitem_booitem_seq_id, bomitem_createwo, bomitem_issuemethod,"
             "       bomitem_schedatwooper, bomitem_ecn, item_type,"
             "       bomitem_qtyper,"
             "       bomitem_scrap,"
             "       bomitem_effective, bomitem_expires, bomitem_subtype,"
             "       bomitem_uom_id, "
             "       bomitem_char_id, "
             "       bomitem_value "
             "FROM bomitem, item "
             "WHERE ( (bomitem_parent_item_id=item_id)"
             " AND (bomitem_id=:bomitem_id) );" );
  q.bindValue(":bomitem_id", _bomitemid);
  q.exec();
  if (q.first())
  {
    _itemid = q.value("bomitem_parent_item_id").toInt();
    _item->setId(q.value("bomitem_item_id").toInt());
    _uom->setId(q.value("bomitem_uom_id").toInt());

    if (q.value("bomitem_issuemethod").toString() == "S")
      _issueMethod->setCurrentItem(0);
    else if (q.value("bomitem_issuemethod").toString() == "L")
      _issueMethod->setCurrentItem(1);
    else if (q.value("bomitem_issuemethod").toString() == "M")
      _issueMethod->setCurrentItem(2);
    sHandleIssueMethod(_issueMethod->currentItem());

    if (q.value("item_type").toString() == "M" || q.value("item_type").toString() == "F")
      _createWo->setChecked(q.value("bomitem_createwo").toBool());

    _dates->setStartDate(q.value("bomitem_effective").toDate());
    _dates->setEndDate(q.value("bomitem_expires").toDate());
    _qtyPer->setDouble(q.value("bomitem_qtyper").toDouble());
    _scrap->setDouble(q.value("bomitem_scrap").toDouble() * 100);

    if (_mode != cCopy)
      _ecn->setText(q.value("bomitem_ecn").toString());

    bool scheduledAtWooper = q.value("bomitem_schedatwooper").toBool();
    _booitemseqid = q.value("bomitem_booitem_seq_id").toInt();

    _comments->setId(_bomitemid);

    if (q.value("item_type").toString() == "M" || 
        q.value("item_type").toString() == "F" || 
        q.value("item_type").toString() == "J")
      _createWo->setChecked(q.value("bomitem_createwo").toBool());
      
    if (q.value("item_config").toBool())
    {
      _char->populate(QString( "SELECT -1 AS charass_char_id, '' AS char_name "
                               "UNION "
                               "SELECT DISTINCT charass_char_id, char_name "
                               "FROM charass, char "
                               "WHERE ((charass_char_id=char_id) "
                               "AND (charass_target_type='I') "
                               "AND (charass_target_id= %1)) "
                               "ORDER BY char_name; ").arg(_itemid));
      _char->setId(q.value("bomitem_char_id").toInt());
      sCharIdChanged();
      _value->setText(q.value("bomitem_value").toString());
    }
    else
      _tab->removeTab(_tab->indexOf(_configurationTab));

    if (q.value("bomitem_subtype").toString() == "I")
      _itemDefinedSubstitutes->setChecked(true);
    else if (q.value("bomitem_subtype").toString() == "B")
      _bomDefinedSubstitutes->setChecked(true);
    else
      _noSubstitutes->setChecked(true);
    sFillSubstituteList();

    if (_booitemseqid != -1)
    {
      q.prepare( "SELECT (TEXT(booitem_seqnumber) || '-' || booitem_descrip1 || ' ' || booitem_descrip2) AS description "
		         "FROM booitem(:item_id) "
                 "WHERE (booitem_seq_id=:booitem_seq_id);" );
	  q.bindValue(":item_id", _itemid);
      q.bindValue(":booitem_seq_id", _booitemseqid);
      q.exec();
      if (q.first())
      {
        _usedAt->setText(q.value("description").toString());
        _scheduleAtWooper->setEnabled(TRUE);
        _scheduleAtWooper->setChecked(scheduledAtWooper);
      }
      else
      {
        _booitemseqid = -1;
        _scheduleAtWooper->setEnabled(FALSE);
      }
    }
    else
      _scheduleAtWooper->setEnabled(FALSE);
  }
  else if (q.lastError().type() != QSqlError::None)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
Exemple #2
0
void bomItem::populate()
{
  q.prepare( "SELECT bomitem_item_id, bomitem_parent_item_id, item_config,"
             "       bomitem_booitem_seq_id, bomitem_createwo, bomitem_issuemethod,"
             "       bomitem_configtype, bomitem_configid, bomitem_configflag,"
             "       bomitem_schedatwooper, bomitem_ecn, item_type,"
             "       formatQtyper(bomitem_qtyper) AS qtyper,"
             "       formatScrap(bomitem_scrap) AS scrap,"
             "       bomitem_effective, bomitem_expires, bomitem_subtype,"
             "       bomitem_uom_id "
             "FROM bomitem, item "
             "WHERE ( (bomitem_parent_item_id=item_id)"
             " AND (bomitem_id=:bomitem_id) );" );
  q.bindValue(":bomitem_id", _bomitemid);
  q.exec();
  if (q.first())
  {
    _itemid = q.value("bomitem_parent_item_id").toInt();
    _item->setId(q.value("bomitem_item_id").toInt());
    _uom->setId(q.value("bomitem_uom_id").toInt());

    if (q.value("bomitem_issuemethod").toString() == "S")
      _issueMethod->setCurrentItem(0);
    else if (q.value("bomitem_issuemethod").toString() == "L")
      _issueMethod->setCurrentItem(1);
    else if (q.value("bomitem_issuemethod").toString() == "M")
      _issueMethod->setCurrentItem(2);
    sHandleIssueMethod(_issueMethod->currentItem());

    if (q.value("item_type").toString() == "M" || q.value("item_type").toString() == "F")
      _createWo->setChecked(q.value("bomitem_createwo").toBool());

    _dates->setStartDate(q.value("bomitem_effective").toDate());
    _dates->setEndDate(q.value("bomitem_expires").toDate());
    _qtyPer->setText(q.value("qtyper").toString());
    _scrap->setText(q.value("scrap").toString());

    if (_mode != cCopy)
      _ecn->setText(q.value("bomitem_ecn").toString());

    bool scheduledAtWooper = q.value("bomitem_schedatwooper").toBool();
    _booitemseqid = q.value("bomitem_booitem_seq_id").toInt();

    _comments->setId(_bomitemid);

    if (q.value("bomitem_subtype").toString() == "N")
      _noSubstitutes->setChecked(TRUE);
    else if (q.value("bomitem_subtype").toString() == "I")
      _itemDefinedSubstitutes->setChecked(TRUE);
    else if (q.value("bomitem_subtype").toString() == "B")
      _bomDefinedSubstitutes->setChecked(TRUE);

    sFillSubstituteList();

    if (_booitemseqid != -1)
    {
      q.prepare( "SELECT (TEXT(booitem_seqnumber) || '-' || booitem_descrip1 || ' ' || booitem_descrip2) AS description "
		         "FROM booitem(:item_id) "
                 "WHERE (booitem_seq_id=:booitem_seq_id);" );
	  q.bindValue(":item_id", _itemid);
      q.bindValue(":booitem_seq_id", _booitemseqid);
      q.exec();
      if (q.first())
      {
        _usedAt->setText(q.value("description").toString());
        _scheduleAtWooper->setEnabled(TRUE);
        _scheduleAtWooper->setChecked(scheduledAtWooper);
      }
      else
      {
        _booitemseqid = -1;
        _scheduleAtWooper->setEnabled(FALSE);
      }
    }
    else
      _scheduleAtWooper->setEnabled(FALSE);
  }
  else if (q.lastError().type() != QSqlError::None)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}