Chapter 107 of 133
مَا يَقُولُ مَنْ أَتَاهُ أَمْرٌ يَسُرُّهُ أَوْ يَكْرَهُهُ
كَانَ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ إِذَا أَتَاهُ الأَمْرُ يَسُرُّهُ قَالَ: (الحَمْدُ لِلَّهِ الذِي بِنِعْمَتِهِ تَتِمُّ الصَّالِحَاتُ) وَإِذَا أَتَاهُ الأَمْرُ يَكْرَهُهُ قَالَ: (الحَمْدُ لِلَّهِ عَلَى كُلِّ حَالٍ)
Transliteration
When something happened that pleased him, the Prophet used to say:((Alhamdu lillaahil-lathee bini'matihi tatimmuus-saalihaat)).And if something happened that displeased him, he used to say:((Alhamdulillaahi 'alaa kulli haal)
Translation
When something happened that pleased him, the Prophet used to say:((Alhamdu lillaahil-lathee bini'matihi tatimmuus-saalihaat)). Praise is to Allah Who by His blessings all good things are perfected. And if something happened that displeased him, he used to say:((Alhamdulillaahi 'alaa kulli haal)).Praise is to Allah in all circumstances.
Reference
أخرجه ابن السّني في عمل اليوم واللّيلة، والحاكم وصحّحه 1/ 499 وصحّحه الألباني رحمه اللّه في صحيح الجامع 4/ 201
References are as given in Hisn al-Muslim (book volume/page).
Source: Hisn al-Muslim by Sa'id ibn Ali ibn Wahf al-Qahtani. Arabic text and references: asellam/HisnElMuslim. English translation, transliteration and audio: hisnmuslim.com.