示例#1
0
void reserveSalesOrderItem::populate()
{
  XSqlQuery distributepopulate;
  distributepopulate.prepare("SELECT itemsite_loccntrl, itemsite_controlmethod "
                             "FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id) "
                             "WHERE (coitem_id=:soitem_id);");
  
  distributepopulate.bindValue(":soitem_id", _soitemid);
  distributepopulate.exec();
  if (distributepopulate.first())
  {
    _locControl = distributepopulate.value("itemsite_loccntrl").toBool();
    _controlMethod = distributepopulate.value("itemsite_controlmethod").toString();

    if (_metrics->boolean("SOManualReservations") && (_locControl || _controlMethod == "L" || _controlMethod == "S"))
    {
      connect(_bcReserve,       SIGNAL(clicked()), this, SLOT(sBcReserve()), Qt::UniqueConnection);
      connect(_reserve,         SIGNAL(clicked()), this, SLOT(sReserveLocation()), Qt::UniqueConnection);
      connect(_unreserve,       SIGNAL(clicked()), this, SLOT(sUnreserveLocation()), Qt::UniqueConnection);
      connect(_itemloc, SIGNAL(itemSelected(int)), this, SLOT(sReserveLocation()), Qt::UniqueConnection);
      connect(_bc,   SIGNAL(textChanged(QString)), this, SLOT(sBcChanged(QString)), Qt::UniqueConnection);
      
      //If not lot serial control, hide info
      if (!_metrics->boolean("LotSerialControl"))
      {
        _bcLit->hide();
        _bc->hide();
        _bcQtyLit->hide();
        _bcQty->hide();
        _bcReserve->hide();
      }
      else
      {
        omfgThis->inputManager()->notify(cBCLotSerialNumber, this, this, SLOT(sCatchLotSerialNumber(QString)));
        
        _bc->setEnabled(_controlMethod == "L" || _controlMethod == "S");
        _bcQty->setEnabled(_controlMethod == "L");
        _bcReserve->setEnabled(_controlMethod == "L" || _controlMethod == "S");
        if (_controlMethod == "S")
          _bcQty->setText("1");
        else
          _bcQty->clear();

      }
    }
reserveSalesOrderItem::reserveSalesOrderItem(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
    : XDialog(parent, name, modal, fl)
{
  setupUi(this);

  connect(_save, SIGNAL(clicked()), this, SLOT(sSave()));
  connect(_close, SIGNAL(clicked()), this, SLOT(reject()));

  _item->setReadOnly(true);

  _qtyToReserve->setValidator(omfgThis->qtyVal());

  _ordered->setPrecision(omfgThis->qtyVal());
  _shipped->setPrecision(omfgThis->qtyVal());
  _atShipping->setPrecision(omfgThis->qtyVal());
  _reserved->setPrecision(omfgThis->qtyVal());
  _onHand->setPrecision(omfgThis->qtyVal());
  _allocated->setPrecision(omfgThis->qtyVal());
  _unreserved->setPrecision(omfgThis->qtyVal());

  if (_metrics->boolean("SOManualReservations"))
  {
    connect(_bcReserve,       SIGNAL(clicked()), this, SLOT(sBcReserve()));
    connect(_reserve,         SIGNAL(clicked()), this, SLOT(sReserveLocation()));
    connect(_unreserve,       SIGNAL(clicked()), this, SLOT(sUnreserveLocation()));
    connect(_itemloc, SIGNAL(itemSelected(int)), this, SLOT(sReserveLocation()));
    connect(_bc,   SIGNAL(textChanged(QString)), this, SLOT(sBcChanged(QString)));
    
    omfgThis->inputManager()->notify(cBCLotSerialNumber, this, this, SLOT(sCatchLotSerialNumber(QString)));
    
    _itemloc->addColumn(tr("Location"),       _itemColumn, Qt::AlignLeft,  true, "location");
    _itemloc->addColumn(tr("Lot/Serial #"),   -1,          Qt::AlignLeft,  true, "lotserial");
    _itemloc->addColumn(tr("Expiration"),     _dateColumn, Qt::AlignCenter,true, "f_expiration");
    _itemloc->addColumn(tr("This Reserved"),  _qtyColumn,  Qt::AlignRight, true, "reserved");
    _itemloc->addColumn(tr("Total Reserved"), _qtyColumn,  Qt::AlignRight, true, "totalreserved");
    _itemloc->addColumn(tr("Unreserved"),     _qtyColumn,  Qt::AlignRight, true, "unreserved");

    //If not lot serial control, hide info
    if (!_metrics->boolean("LotSerialControl"))
    {
      _bcLit->hide();
      _bc->hide();
      _bcQtyLit->hide();
      _bcQty->hide();
      _bcReserve->hide();
    }
    else
    {
      // Add columns for lotserial characteristics
      QString column;
      QString name;
      QString sql = QString("SELECT char_id, char_name, char_type "
                            "FROM char "
                            "WHERE (char_lotserial) "
                            " AND (char_search) "
                            "ORDER BY char_name;");
      XSqlQuery chars;
      chars.exec(sql);
      while (chars.next())
      {
        characteristic::Type chartype = (characteristic::Type)chars.value("char_type").toInt();
        column = QString("char%1").arg(chars.value("char_id").toString());
        name = chars.value("char_name").toString();
        _itemloc->addColumn(name, -1, Qt::AlignLeft , true, column );
        if (chartype == characteristic::Text)
        {
          _charidstext.append(chars.value("char_id").toInt());
        }
        else if (chartype == characteristic::List)
        {
          _charidslist.append(chars.value("char_id").toInt());
        }
        else if (chartype == characteristic::Date)
        {
          _charidsdate.append(chars.value("char_id").toInt());
        }
      }
    }
  }