Exemplo n.º 1
0
 public bool UpdateObject(IDBObject dbObject)
 {
     Npgsql.NpgsqlConnection  conn       = null;
     Npgsql.NpgsqlTransaction trans      = null;
     Npgsql.NpgsqlConnection  readerConn = null;
     try
     {
         if (dbObject != null)
         {
             conn       = (Npgsql.NpgsqlConnection)NpgsqlConnectionImpl.GetInstance().GetNewConnection();
             readerConn = (Npgsql.NpgsqlConnection)NpgsqlConnectionImpl.GetInstance().GetNewConnection();
             object result = this.GetDataReader(dbObject.GetObjectByIdQuery(), readerConn);
             if (result != null)
             {
                 string strSql = dbObject.GetUpdateStatement();
                 Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand(strSql);
                 command.Connection = conn;
                 trans = conn.BeginTransaction();
                 command.ExecuteNonQuery();
                 trans.Commit();
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         if (trans != null)
         {
             trans.Rollback();
         }
         throw ex;
     }
     finally
     {
         if (conn != null)
         {
             conn.Close();
         }
         if (readerConn != null)
         {
             readerConn.Close();
         }
     }
     return(false);
 }