Hello Sepithol,
You are referring to King David (PUH) of the Israelites whom God loved so much. The complete story has many wonderful lessons that we can apply to our own lives. It seems that David (PUH) allowed Satan to take a foot hold on his heart one when day he came across Bathseba, well, taking a bath. Instead of looking away and protecting his heart he endulged is eyes. Anyway, he eventually sent Bathseba's husband to the front lines of war so, that he could have her to himself. One sin leading to another. After the husband died David (PUH) took Bathseba as his wife.
God then sent Nathan to David (PUH) with the story you mentioned about the sheep. He asked David (PUH) 'what do you think about this - what should we do'? David (PUH) said, this is wrong, this person deserves to die. Nathan then said, you are this man. God of Israel, says: I anointed you king over Israel and delivered you from the hands of Saul. I gave you the house of Israel and Judah. And, if all this would have been too little, I would have given you more. Why did you despise the word of the Lord by doing what is evil in his eyes? You see, David (PUH) relied on his self instead of God. He fell weak to his flesh. Why, if God gave him all this would he still take from others who have not what he had?
David (PUH) paid for this sin with the death of his son. But, David (PUH)understood what he had done and after praying he got up and continued to praise God because he realized it was him who strayed from the path and he understood more then a lot of us what that truly means.
Him and Bathseba later bore a son named Solomon (PUH)! A great man who prayed for God to accept the prayers of Gentiles.
Read 2 Samuel 11 & 12 for a better understanding.
As for Islam I know they believe in David but, not sure what of this information is in the Quaran. But, I am curious to find out the Islamic perspective.
Praise to God for making the passages known in order to reply to this post.
Regards.