Exemplo n.º 1
0
 // ---------------------------------------------------------------------------------
 bool operator == (dp::Project const& lhs, dp::Project const& rhs)
 {
   if(lhs.id().isNull())
   {
     return (rhs.id().isNull());
   }
   return lhs.id() == rhs.id();
 }
Exemplo n.º 2
0
 // ---------------------------------------------------------------------------------
 success Project::update ( const dp::Project& _p ) const
 {
   if ( _p.id().isNull())
   {
     return error();
   }
   QSqlQuery query;
   query.prepare ( UPDATE_PROJECT );
   query.addBindValue ( _p.name() );
   query.addBindValue ( _p.creationDate() );
   query.addBindValue( _p.comment() );
   query.addBindValue ( _p.id().toString() );
   return execute ( query );
 }
Exemplo n.º 3
0
 // ---------------------------------------------------------------------------------
 // private stuff:
 // ---------------------------------------------------------------------------------
 bool Project::exists ( const dp::Project& _project ) const
 {
   if ( _project.id().isNull() )
   {
     return false;
   }
   QSqlQuery query;
   query.prepare ( SELECT_DISTINCT_PROJECT );
   query.addBindValue ( _project.id().toString() );
   if ( execute ( query ).has_failed() )
   {
     return false;
   }
   return query.first();
 }
Exemplo n.º 4
0
 // ---------------------------------------------------------------------------------
 success Project::insert ( dp::Project const& _p ) const
 {
   if ( _p.id().isNull())
   {
     return error();
   }
   QSqlQuery query;
   query.prepare ( INSERT_PROJECT );
   query.addBindValue ( _p.id().toString() );
   query.addBindValue ( _p.name() );
   query.addBindValue ( _p.creationDate() );
   query.addBindValue( _p.comment() );
   if ( execute ( query ).has_failed() )
   {
     return error();
   }
   return successful();
 }
Exemplo n.º 5
0
 // ---------------------------------------------------------------------------------
 success Project::remove(dp::Project const& _project) const
 {
   if ( _project.id().isNull())
   {
     return error();
   }
   if(!exists(_project))
   {
       return successful();
   }
   QSqlQuery query;
   query.prepare(REMOVE_PROJECT);
   query.addBindValue(_project.id().toString());
   if(execute(query).has_failed())
   {
     return error();
   }
   return successful();
 }
Exemplo n.º 6
0
 // ---------------------------------------------------------------------------------
 success Project::load ( dp::Project &p ) const
 {
   if ( p.id().isNull())
   {
     return error();
   }
   QSqlQuery query;
   query.prepare ( SELECT_DISTINCT_PROJECT );
   query.addBindValue ( p.id().toString() );
   if ( execute ( query ).has_failed() )
   {
     kWarning()<<"last error: "<<query.lastError();
     return error();
   }
   if ( !query.first() )
   {
     kWarning()<<"last error: "<<query.lastError();
     return error();
   }
   return assign_query_values_to_entity ( query, p );
 }