At times like this, there are a few things it may help you to remember. First of all, no one can control every aspect of his or her life, and adversity comes to all of us, no matter how moral we are, and no matter how good our attitude is. Bad things happen to good people all the time.
Second, it's important to realise that there is one and only one thing in life that is completely within your power to control, and that is your response to what happens to you.
Your feelings are a direct result of the thoughts you think, and setting aside some time every morning and evening for positive visualisation, affirmation, or guided meditation is a highly effective way of getting these thoughts back under your control again. Try it.