예제 #1
0
void printShippingForm::sHandleSo()
{
  if (_so->isValid())
  {
    _to->setId(-1);
    QString sql("SELECT cohead_id AS order_id, cohead_shiptoname AS shipto, "
		"       cohead_shiptoaddress1 AS addr1, shiphead_order_type, "
		"       shiphead_id, shiphead_shipchrg_id, shiphead_shipped, "
		"	COALESCE(shiphead_shipform_id, cohead_shipform_id) AS shipform_id "
		"FROM cohead, shiphead "
		"WHERE ((cohead_id=shiphead_order_id)"
		"  AND  (shiphead_order_type='SO')"
		"  AND  (cohead_id=<? value(\"sohead_id\") ?> )"
		"<? if exists(\"shiphead_id\") ?>"
		"  AND  (shiphead_id=<? value(\"shiphead_id\") ?> )"
		"<? endif ?>"
		") "
		"ORDER BY shiphead_shipped "
		"LIMIT 1;");

    ParameterList params;
    MetaSQLQuery mql(sql);
    params.append("sohead_id", _so->id());
    if (_shipment->isValid())
      params.append("shiphead_id", _shipment->id());
    q = mql.toQuery(params);

    if (q.first())
    {
      if (_shipment->id() != q.value("shiphead_id").toInt())
	_shipment->setId(q.value("shiphead_id").toInt());

      _shipToName->setText(q.value("shipto").toString());
      _shipToAddr1->setText(q.value("addr1").toString());
      _shippingForm->setId(q.value("shipform_id").toInt());
      _shipchrg->setId(q.value("shiphead_shipchrg_id").toInt());
    }
    else if (q.lastError().type() != QSqlError::None)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }
    else if (_shipment->isValid())
    {
      _shipment->setId(-1);
      sHandleSo();
    }
    else
    {
      QMessageBox::critical(this, tr("Could not find data"),
		      tr("<p>Could not find a Shipment for this Sales Order."));

      depopulate();
    }
  }
  else
  {
    depopulate();
  }
}
예제 #2
0
void printShippingForm::sHandleOrder()
{
  if (_order->isSO())
    sHandleSo();
  else if (_order->isTO())
    sHandleTo();
  else
  {
    _shipment->removeOrderLimit();
    _shipment->clear();
    depopulate();
  }
}
예제 #3
0
void shipOrder::sHandleOrder()
{
  if (_order->id() < 0 || _warehouse->id() < 0)
  {
    _shipment->clear();
    _billToName->setText("");
    _shipToName->setText("");
    _shipToAddr1->setText("");
    _shipValue->setDouble(0);
    _coitem->clear();
    _order->setFocus();
    return;
  }
  else if (_order->isSO())
    sHandleSo();
  else if (_order->isTO())
    sHandleTo();
}