Example #1
0
void BOM::sSave()
{
  if(_batchSize->text().length() == 0)
    _batchSize->setDouble(1.0);
  else if(_batchSize->toDouble() == 0.0)
  {
    QMessageBox::warning( this, tr("Batch Size Error"),
      tr("<p>The Batch Size quantity must be greater than zero.") );
    return;
  }

  if(!sCheckRequiredQtyPer())
    return;
  
  q.prepare( "SELECT bomhead_id "
             "FROM bomhead "
             "WHERE ((bomhead_item_id=:item_id) "
			 "AND (bomhead_rev_id=:bomhead_rev_id));" );
  q.bindValue(":item_id", _item->id());
  q.bindValue(":bomhead_rev_id", _revision->id());
  q.exec();
  if (q.first())
  {   
    q.prepare( "UPDATE bomhead "
               "SET bomhead_docnum=:bomhead_docnum,"
               "    bomhead_revision=:bomhead_revision, bomhead_revisiondate=:bomhead_revisiondate,"
               "    bomhead_batchsize=:bomhead_batchsize,"
               "    bomhead_requiredqtyper=:bomhead_requiredqtyper "
               "WHERE ((bomhead_item_id=:bomhead_item_id) "
			   "AND (bomhead_rev_id=:bomhead_rev_id));" );
    q.bindValue(":bomhead_item_id", _item->id());
    q.bindValue(":bomhead_rev_id", _revision->id());
  }
  else
  {
    q.prepare( "INSERT INTO bomhead "
               "( bomhead_item_id, bomhead_docnum,"
               "  bomhead_revision, bomhead_revisiondate,"
               "  bomhead_batchsize, bomhead_requiredqtyper ) "
               "VALUES "
               "( :bomhead_item_id, :bomhead_docnum,"
               "  :bomhead_revision, :bomhead_revisiondate, "
               "  :bomhead_batchsize, :bomhead_requiredqtyper ) " );
    q.bindValue(":bomhead_item_id", _item->id());
  }
  
  q.bindValue(":bomhead_docnum", _documentNum->text());
  q.bindValue(":bomhead_revision", _revision->number());
  q.bindValue(":bomhead_revisiondate", _revisionDate->date());
  q.bindValue(":bomhead_batchsize", _batchSize->toDouble());
  if(_doRequireQtyPer->isChecked())
    q.bindValue(":bomhead_requiredqtyper", _requiredQtyPer->text().toDouble());
  q.exec();
  
  close();
}
Example #2
0
void BOM::sSave()
{
  if(!sCheckRequiredQtyPer())
    return;
  
  q.prepare( "SELECT bomhead_id "
             "FROM bomhead "
             "WHERE ((bomhead_item_id=:item_id) "
			 "AND (bomhead_rev_id=:bomhead_rev_id));" );
  q.bindValue(":item_id", _item->id());
  q.bindValue(":bomhead_rev_id", _revision->id());
  q.exec();
  if (q.first())
  {   
    q.prepare( "UPDATE bomhead "
               "SET bomhead_docnum=:bomhead_docnum,"
               "    bomhead_revision=:bomhead_revision, bomhead_revisiondate=:bomhead_revisiondate,"
               "    bomhead_batchsize=:bomhead_batchsize,"
               "    bomhead_requiredqtyper=:bomhead_requiredqtyper "
               "WHERE ((bomhead_item_id=:bomhead_item_id) "
			   "AND (bomhead_rev_id=:bomhead_rev_id));" );
    q.bindValue(":bomhead_item_id", _item->id());
    q.bindValue(":bomhead_rev_id", _revision->id());
  }
  else
  {
    q.prepare( "INSERT INTO bomhead "
               "( bomhead_item_id, bomhead_docnum,"
               "  bomhead_revision, bomhead_revisiondate,"
               "  bomhead_batchsize, bomhead_requiredqtyper ) "
               "VALUES "
               "( :bomhead_item_id, :bomhead_docnum,"
               "  :bomhead_revision, :bomhead_revisiondate, "
               "  :bomhead_batchsize, :bomhead_requiredqtyper ) " );
    q.bindValue(":bomhead_item_id", _item->id());
  }
  
  q.bindValue(":bomhead_docnum", _documentNum->text());
  q.bindValue(":bomhead_revision", _revision->number());
  q.bindValue(":bomhead_revisiondate", _revisionDate->date());
  q.bindValue(":bomhead_batchsize", _batchSize->toDouble());
  if(_doRequireQtyPer->isChecked())
    q.bindValue(":bomhead_requiredqtyper", _requiredQtyPer->text().toDouble());
  q.exec();
  
  close();
}
Example #3
0
void BOM::sClose()
{
    if(sCheckRequiredQtyPer())
        close();
}