Ejemplo n.º 1
0
 bool DeppointCardPage::insertIntoDatabase()
 {
   static const char* querySql = "insert into \"DEPPOINT\"(" \
     "\"DEPPOINT_ID\", \"FULL_NAME\", \"SHORT_NAME\", \"REMARK\", " \
     "\"CREATE_USER_ID\", \"UPDATE_USER_ID\", \"CREATE_TIME\", \"UPDATE_TIME\") " \
     "values (?, ?, ?, ?, ?, ?, \'NOW\', \'NOW\')";
   
   if (OptionalQInt64 newEntityId = databaseModel()->generateId(deppointEntity))
   {
     entityData_.deppointId = newEntityId.get();
     QSqlQuery query(databaseModel()->database());              
     if (query.prepare(querySql))
     {
       query.bindValue(0, entityData_.deppointId);
       query.bindValue(1, entityData_.fullName);
       query.bindValue(2, entityData_.shortName);
       query.bindValue(3, entityData_.remark ? entityData_.remark.get() : QVariant(QVariant::String));          
       query.bindValue(4, databaseModel()->userId());
       query.bindValue(5, databaseModel()->userId());
       if (query.exec())
       {
         if (0 < query.numRowsAffected())
         {
           setEntityId(newEntityId.get());
           databaseModel()->notifyInsert(entityData_);
           return true;
         }            
       }
     }
   }
   return false;
 }
Ejemplo n.º 2
0
    bool DeppointCardPage::removeFromDatabase()
    {
      static const char* querySql = "delete from \"DEPPOINT\" where \"DEPPOINT_ID\" = ?";

      if (QMessageBox::Yes == QMessageBox::question(this, tr("Departure points"), 
        tr("Delete departure point?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
      {
        if (entityId())
        {
          QSqlQuery query(databaseModel()->database());              
          if (query.prepare(querySql))
          {
            query.bindValue(0, entityData_.deppointId);
            if (query.exec())
            {
              setEntityId(OptionalQInt64());
              if (0 < query.numRowsAffected())
              {
                databaseModel()->notifyRemove(entityData_);
                return true;
              }            
            }
          }
        }
      }
      return false;
    }
Ejemplo n.º 3
0
bool BankCardPage::removeFromDatabase()
{
  static const char* querySql = "delete from \"BANK\" where \"BANK_ID\" = ?";

  if (QMessageBox::Yes == QMessageBox::question(this, tr("Banks"), 
      tr("Delete bank?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
  {
    if (!entityId())
    {
      return false;
    }

    QSqlQuery query(databaseModel()->database());              
    if (!query.prepare(querySql))
    {
      return false;
    }

    query.bindValue(0, entityData_.bankId);
    if (!query.exec())
    {
      return false;
    }

    setEntityId(OptionalQInt64());

    if (query.numRowsAffected() > 0)
    {
      databaseModel()->notifyRemove(entityData_);
      return true;
    }            
  }
  return false;
}
Ejemplo n.º 4
0
Event::Event(const Event& other):
	applicationID_(other.applicationID_),
	eventTime_(other.eventTime_),
	neededResQuantity_(other.neededResQuantity_),
	seizedResQuantity_(other.seizedResQuantity_),
	nextEventType_(other.nextEventType_),
	destinationEventType_(other.destinationEventType_),
	eventBehavior_(other.eventBehavior_),
	linkBehavior_ (other.linkBehavior_),
	entityIns_(other.entityIns_.getEntityType(), other.entityIns_.getAttribute()),
	fsLoc_(other.fsLoc_),
	fsID_(other.fsID_),
	redID_(other.redID_),
	recordID_(other.recordID_),
	spillTally_(other.spillTally_){

	setEntityId(other.entityIns_.getEntityId());
}
Ejemplo n.º 5
0
Event& Event::operator=(const Event& other){
	applicationID_ = other.applicationID_;
	eventTime_ = other.eventTime_;
	neededResQuantity_ = other.neededResQuantity_;
	seizedResQuantity_ = other.seizedResQuantity_;
	nextEventType_ =other.nextEventType_;
	destinationEventType_ = other.destinationEventType_;
	eventBehavior_ = other.eventBehavior_;
	linkBehavior_  = other.linkBehavior_;
	entityIns_.setAttribute(other.entityIns_.getAttribute());
	entityIns_.setEntityType(other.entityIns_.getEntityType());
	fsLoc_ = other.fsLoc_;
	fsID_ = other.fsID_;
	redID_ = other.redID_;
	recordID_ = other.recordID_;
	spillTally_ = other.spillTally_;

	setEntityId(other.entityIns_.getEntityId());
    return *this;
}
Ejemplo n.º 6
0
bool AutoenterpriseCardPage::insertIntoDatabase()
{
  static const char* querySql = "insert into \"AUTOENTERPRISE\"(" \
      "\"AUTOENTERPRISE_ID\", \"FULL_NAME\", \"SHORT_NAME\", \"REMARK\", " \
      "\"CREATE_USER_ID\", \"UPDATE_USER_ID\", " \
      "\"CREATE_TIME\", \"UPDATE_TIME\") " \
      "values (?, ?, ?, ?, ?, ?, \'NOW\', \'NOW\')";
      
  if (OptionalQInt64 newEntityId = 
      databaseModel()->generateId(autoenterpriseEntity))
  {
    entityData_.autoenterpriseId = newEntityId.get();
    QSqlQuery query(databaseModel()->database());              
    if (!query.prepare(querySql))
    {
      return false;
    }

    query.bindValue(0, entityData_.autoenterpriseId);
    query.bindValue(1, entityData_.fullName);
    query.bindValue(2, entityData_.shortName);
    query.bindValue(3, buildQVariant(entityData_.remark));
    query.bindValue(4, databaseModel()->userId());
    query.bindValue(5, databaseModel()->userId());
    if (!query.exec())
    {
      return false;
    }

    if (query.numRowsAffected() > 0)
    {
      setEntityId(newEntityId.get());
      databaseModel()->notifyInsert(entityData_);
      return true;
    }    
  }
  return false;
}
Ejemplo n.º 7
0
 bool CountryCardPage::insertIntoDatabase()
 {
   static const char* querySql = "insert into \"COUNTRY\"(" \
     "\"COUNTRY_ID\", \"FULL_NAME\", \"SHORT_NAME\", \"TRIGRAM_CYRILLIC_CODE\", " \
     "\"TRIGRAM_LATIN_CODE\", \"TWO_LETTER_LATIN_CODE\", \"NUMERIC_CODE\", " \
     "\"CREATE_USER_ID\", \"UPDATE_USER_ID\", \"CREATE_TIME\", \"UPDATE_TIME\") " \
     "values (?, ?, ?, ?, ?, ?, ?, ?, ?, \'NOW\', \'NOW\')";
   
   if (OptionalQInt64 newEntityId = databaseModel()->generateId(countryEntity))
   {
     entityData_.countryId = newEntityId.get();
     QSqlQuery query(databaseModel()->database());              
     if (query.prepare(querySql))
     {
       query.bindValue(0, entityData_.countryId);
       query.bindValue(1, entityData_.fullName);
       query.bindValue(2, entityData_.shortName);
       query.bindValue(3, entityData_.trigramCyrillicCode);
       query.bindValue(4, entityData_.trigramLatinCode);
       query.bindValue(5, entityData_.twoLetterLatinCode);
       query.bindValue(6, entityData_.numericCode);
       query.bindValue(7, databaseModel()->userId());
       query.bindValue(8, databaseModel()->userId());
       if (query.exec())
       {
         if (0 < query.numRowsAffected())
         {
           setEntityId(newEntityId.get());
           databaseModel()->notifyInsert(entityData_);
           return true;
         }            
       }
     }
   }
   return false;
 }