Fiqh-us-Sunnah Volume 4, Funerals and Dhikr, Fiqh 4.132.

Section : When One is Faced with Something Difficult or Unpleasant.

Abu Hurairah related that the Prophet, peace be upon him, said, “When one of you is afflicted with any misfortune he should say, ‘Ina li llahi wa inna ‘ilayhi Raji’un (We are for Allah, and to Him is our return),’ even if it be merely losing one’s shoe straps, for this is also a misfortune.” (Ibn As-Sinni)

Abu Hurairah reported that the Prophet, peace be upon him, said, “A strong believer is better and dearer to Allah than a weak believer, and there is good in everyone, but cherish what gives you benefit in the Hereafter and seek help from Allah and do not lose heart, and if anything (in the form of trouble) comes to you, don’t say, ‘If I had not done that, such and such thing would not have happened,’ but say, ‘Allah has ordained it so, and whatever He pleases He does,’ because ‘ifs’ and ‘buts’ open the door for Satan.”(Muslim)