I don't mind a person telling me to smile, even when I'm upset. They could never know my personal situation if I haven't told them so I can't hate on them for asking. It's when they are persistent is what bugs me. To ask again...and again....and again....yeah, it can make a person come so close to snapping.
Instead of being told to "Smile!" which may or may not be followed by the usual annoying/cliched comments (e.g. "it might never happen"; "it could be worse"; etc), throwing a random yet sincere compliment works wonders (e.g. "I love the way you've styled your hair this morning") and normally elicits a more natural smile and a raise in the other person's spirits.
One of the most socially incompetent approaches I had was a guy who approached me with a grin saying "You look peed* off!" (*he used the stronger version of the word). When I replied that I in fact was not, he kept on saying with a smile "Well, you do look peed off!" hoping it would get me to smile. Of course, this started to irk me, and I even went as far as to tell him that it was an inappropriate way to 'greet' a stranger yet he just kept on repeating it, yet expecting me to smile and engage him in what he hoped would be a pleasant conversation. It resulted in me ignoring the man and him wondering why I wouldn't talk to him. Go figure.