コード例 #1
0
void PlanOrdLineEdit::setId(int pId)
{
  XSqlQuery planord;
  planord.prepare( "SELECT formatPloNumber(planord_id) AS plnumber,"
                   "       warehous_code, item_number, uom_name,"
                   "       item_descrip1, item_descrip2,"
                   "       formatQty(planord_qty) AS qty,"
                   "       formatDate(planord_duedate) AS duedate "
                   "FROM planord, itemsite, item, warehous, uom "
                   "WHERE ( (planord_itemsite_id=itemsite_id)"
                   " AND (itemsite_item_id=item_id)"
                   " AND (item_inv_uom_id=uom_id)"
                   " AND (itemsite_warehous_id=warehous_id)"
                   " AND (planord_id=:planord_id) );" );
  planord.bindValue(":planord_id", pId);
  planord.exec();
  if (planord.first())
  {
    _id    = pId;
    _valid = TRUE;

    setText(planord.value("plnumber").toString());

    emit newId(_id);
    emit warehouseChanged(planord.value("warehous_code").toString());
    emit itemNumberChanged(planord.value("item_number").toString());
    emit uomChanged(planord.value("uom_name").toString());
    emit itemDescrip1Changed(planord.value("item_descrip1").toString());
    emit itemDescrip2Changed(planord.value("item_descrip2").toString());
    emit dueDateChanged(planord.value("duedate").toString());
    emit qtyChanged(planord.value("qty").toString());
    emit valid(TRUE);
  }
  else
  {
    _id    = -1;
    _valid = FALSE;

    setText("");

    emit newId(-1);
    emit warehouseChanged("");
    emit itemNumberChanged("");
    emit uomChanged("");
    emit itemDescrip1Changed("");
    emit itemDescrip2Changed("");
    emit dueDateChanged("");
    emit qtyChanged("");
    emit valid(FALSE);
  }
  
  if (_mapper->model() &&
    _mapper->model()->data(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(this))).toString() != text())
      _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(this)), text());
}
コード例 #2
0
void WoLineEdit::setId(int pId)
{
  bool found = FALSE;
  if (pId != -1)
  {
    XSqlQuery wo;
	if (_useQuery)
    {
      wo.prepare(_sql);
      wo.exec();
      found = (wo.findFirst("wo_id", pId) != -1);
    }
	else
	{
      wo.prepare( "SELECT formatWONumber(wo_id) AS wonumber,"
                  "       warehous_code, item_id, item_number, uom_name,"
                  "       item_descrip1, item_descrip2,"
                  "       wo_qtyord, wo_qtyrcv, wo_status,"
                  "       formatDate(wo_duedate) AS duedate,"
                  "       formatDate(wo_startdate) AS startdate,"
                  "       formatQtyPer(wo_qtyord) AS ordered,"
                  "       formatQtyPer(wo_qtyrcv) AS received, "
                  "       formatQtyPer(noNeg(wo_qtyord - wo_qtyrcv)) AS balance "
                  "FROM wo, itemsite, item, warehous, uom "
                  "WHERE ((wo_itemsite_id=itemsite_id)"
                  " AND (itemsite_item_id=item_id)"
                  " AND (item_inv_uom_id=uom_id)"
                  " AND (itemsite_warehous_id=warehous_id)"
                  " AND (wo_id=:wo_id));" );
      wo.bindValue(":wo_id", pId);
      wo.exec();
      found = (wo.first());
	}
	if (found)
    {
      _id    = pId;
      _valid = TRUE;

      setText(wo.value("wonumber").toString());

      emit newId(_id);
      emit newItemid(wo.value("item_id").toInt());
      emit warehouseChanged(wo.value("warehous_code").toString());
      emit itemNumberChanged(wo.value("item_number").toString());
      emit uomChanged(wo.value("uom_name").toString());
      emit itemDescrip1Changed(wo.value("item_descrip1").toString());
      emit itemDescrip2Changed(wo.value("item_descrip2").toString());
      emit startDateChanged(wo.value("startdate").toString());
      emit dueDateChanged(wo.value("duedate").toString());
      emit qtyOrderedChanged(wo.value("ordered").toString());
      emit qtyReceivedChanged(wo.value("received").toString());
      emit qtyBalanceChanged(wo.value("balance").toString());
      emit statusChanged(wo.value("wo_status").toString());
      emit valid(TRUE);

      _qtyOrdered  = wo.value("wo_qtyord").toDouble();
      _qtyReceived = wo.value("wo_qtyrcv").toDouble();

      _parsed = TRUE;

      return;
    }
  }

  _id    = -1;
  _valid = FALSE;

  setText("");

  emit newId(-1);
  emit newItemid(-1);
  emit warehouseChanged("");
  emit itemNumberChanged("");
  emit uomChanged("");
  emit itemDescrip1Changed("");
  emit itemDescrip2Changed("");
  emit startDateChanged("");
  emit dueDateChanged("");
  emit qtyOrderedChanged("");
  emit qtyReceivedChanged("");
  emit qtyBalanceChanged("");
  emit statusChanged("");
  emit valid(FALSE);
    
  _qtyOrdered  = 0;
  _qtyReceived = 0;

  _parsed = TRUE;
}
コード例 #3
0
void WoLineEdit::setId(int pId)
{
  bool found = FALSE;
  if (pId != -1)
  {
    XSqlQuery wo;
    if (_useQuery)
    {
      wo.prepare(_sql);
      wo.exec();
      found = (wo.findFirst("wo_id", pId) != -1);
    }
    else
    {
      wo.prepare( "SELECT formatWONumber(wo_id) AS wonumber,"
                  "       warehous_code, item_id, item_number, uom_name,"
                  "       item_descrip1, item_descrip2,"
                  "       abs(wo_qtyord) AS wo_qtyord,"
                  "       abs(wo_qtyrcv) AS wo_qtyrcv, "
                  "       CASE WHEN (wo_status = 'O') THEN :open "
                  "       WHEN (wo_status = 'E') THEN :exploded "
                  "       WHEN (wo_status = 'I') THEN :inprocess "
                  "       WHEN (wo_status = 'R') THEN :released "
                  "       WHEN (wo_status = 'C') THEN :closed "
                  "       ELSE :unknown END AS wo_status,"
                  "       wo_duedate,"
                  "       wo_startdate,"
                  "       noNeg(abs(wo_qtyord) - abs(wo_qtyrcv)) AS balance, "
                  "       CASE WHEN (wo_qtyord >= 0) THEN "
                  "         :assemble "
                  "       ELSE "
                  "         :disassemble "
                  "       END AS wo_method, "
                  "       CASE WHEN (wo_qtyord >= 0) THEN "
                  "         'A' "
                  "       ELSE "
                  "         'D' "
                  "       END AS method "
                  "FROM wo, itemsite, item, warehous, uom "
                  "WHERE ((wo_itemsite_id=itemsite_id)"
                  " AND (itemsite_item_id=item_id)"
                  " AND (item_inv_uom_id=uom_id)"
                  " AND (itemsite_warehous_id=warehous_id)"
                  " AND (wo_id=:wo_id));" );
      wo.bindValue(":wo_id", pId);
      wo.bindValue(":assemble", tr("Assembly"));
      wo.bindValue(":disassemble", tr("Disassembly"));
      wo.bindValue(":open", tr("Open"));
      wo.bindValue(":exploded", tr("Exploded"));
      wo.bindValue(":inprocess", tr("In Process"));
      wo.bindValue(":released", tr("Released"));
      wo.bindValue(":closed", tr("Closed"));
      wo.exec();
      found = (wo.first());
    }
    if (found)
    {
      _id    = pId;
      _valid = TRUE;

      setText(wo.value("wonumber").toString());

      _qtyOrdered  = wo.value("wo_qtyord").toDouble();
      _qtyReceived = wo.value("wo_qtyrcv").toDouble();
      _method = wo.value("method").toString();

      emit newId(_id);
      emit newItemid(wo.value("item_id").toInt());
      emit warehouseChanged(wo.value("warehous_code").toString());
      emit itemNumberChanged(wo.value("item_number").toString());
      emit uomChanged(wo.value("uom_name").toString());
      emit itemDescrip1Changed(wo.value("item_descrip1").toString());
      emit itemDescrip2Changed(wo.value("item_descrip2").toString());
      emit startDateChanged(wo.value("wo_startdate").toDate());
      emit dueDateChanged(wo.value("wo_duedate").toDate());
      emit qtyOrderedChanged(wo.value("wo_qtyord").toDouble());
      emit qtyReceivedChanged(wo.value("wo_qtyrcv").toDouble());
      emit qtyBalanceChanged(wo.value("balance").toDouble());
      emit statusChanged(wo.value("wo_status").toString());
      emit methodChanged(wo.value("wo_method").toString());
      emit valid(TRUE);
    }
  }
  else
  {
    _id    = -1;
    _valid = FALSE;

    setText("");

    emit newId(-1);
    emit newItemid(-1);
    emit warehouseChanged("");
    emit itemNumberChanged("");
    emit uomChanged("");
    emit itemDescrip1Changed("");
    emit itemDescrip2Changed("");
    emit startDateChanged(QDate());
    emit dueDateChanged(QDate());
    emit qtyOrderedChanged(0);
    emit qtyReceivedChanged(0);
    emit qtyBalanceChanged(0);
    emit statusChanged("");
    emit methodChanged("");
    emit valid(FALSE);
      
    _qtyOrdered  = 0;
    _qtyReceived = 0;
  }
  
  if (_mapper->model() &&
    _mapper->model()->data(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(this))).toString() != text())
      _mapper->model()->setData(_mapper->model()->index(_mapper->currentIndex(),_mapper->mappedSection(this)), text());
  
  _parsed = TRUE;
}
コード例 #4
0
ファイル: woCluster.cpp プロジェクト: AlFoX/qt-client
void WoLineEdit::silentSetId(const int pId)
{
  if (pId != -1)
  {
    XSqlQuery wo;

    wo.prepare(_query + _idClause +
               (_extraClause.isEmpty() || !_strict ? "" : " AND " + _extraClause) +
               QString(";"));
    wo.bindValue(":id", pId);
    wo.exec();
    if (wo.first())
    {
      if (_completer)
        static_cast<QSqlQueryModel* >(_completer->model())->setQuery(QSqlQuery());

      _id    = pId;
      _valid = TRUE;

      setText(wo.value("number").toString());

      _qtyOrdered  = wo.value("wo_qtyord").toDouble();
      _qtyReceived = wo.value("wo_qtyrcv").toDouble();
      _method = wo.value("method").toString();
      _currentWarehouseid = (wo.value("warehous_id").isNull())
                                      ? -1 : wo.value("warehous_id").toInt();

      emit newId(_id);
      emit newItemid(wo.value("item_id").toInt());
      emit warehouseChanged(wo.value("warehous_code").toString());
      emit itemNumberChanged(wo.value("item_number").toString());
      emit uomChanged(wo.value("uom_name").toString());
      emit itemDescrip1Changed(wo.value("item_descrip1").toString());
      emit itemDescrip2Changed(wo.value("item_descrip2").toString());
      emit startDateChanged(wo.value("wo_startdate").toDate());
      emit dueDateChanged(wo.value("wo_duedate").toDate());
      emit qtyOrderedChanged(wo.value("wo_qtyord").toDouble());
      emit qtyReceivedChanged(wo.value("wo_qtyrcv").toDouble());
      emit qtyBalanceChanged(wo.value("balance").toDouble());
      emit statusChanged(wo.value("wo_status").toString());
      emit methodChanged(wo.value("wo_method").toString());
      emit valid(TRUE);
    }
  }
  else
  {
    _id    = -1;
    _valid = FALSE;
    _currentWarehouseid = -1;

    XLineEdit::clear();

    emit newId(-1);
    emit newItemid(-1);
    emit warehouseChanged("");
    emit itemNumberChanged("");
    emit uomChanged("");
    emit itemDescrip1Changed("");
    emit itemDescrip2Changed("");
    emit startDateChanged(QDate());
    emit dueDateChanged(QDate());
    emit qtyOrderedChanged(0);
    emit qtyReceivedChanged(0);
    emit qtyBalanceChanged(0);
    emit statusChanged("");
    emit methodChanged("");
    emit valid(FALSE);
      
    _qtyOrdered  = 0;
    _qtyReceived = 0;
  }

  _parsed = TRUE;
  emit parsed();
}