According to the Lord Buddha's teaching, there are three things we should keep in mind when someone dies:
1) no one benefits when we mourn
2) everyone dies in the end
3) all that we take with us is our good and bad deeds.
When we keep these things in mind, it leads us to practice correctly towards a death in three ways:
1) we don't hold on to our sadness any more, and in fact we want to be happy, which is exactly what our dearly beloved wanted for us. An easy way to achieve this goal is to simply acknowledge our sadness for what it is. We can say to ourselves in our hearts: "sad, sad, sad..." for as long as the sadness lasts. If we cry, we can say in our minds "crying, crying, crying..." so that it doesn't overwhelm us. By not following it and not repressing it, we are able to let it go. This is what we want and what our beloved wanted for us as well.
2) we are able to reflect on the inevitability of death and work hard to prepare ourselves and those around us so that they will not have to suffer when we die. If we all were at peace with this very natural part of existence, we would never suffer because of it. It is good to reflect on our own mortality in this way, because it helps us find freedom from fear and sadness when we or one we love dies.
3) we live our lives carrying on and carrying out the goodness of the deceased. Whatever good deeds they set themselves in, we set ourselves in those, and more. And when we do good deeds, we dedicate them to the memory of the person who has died. We give to charity, we practice moral virtue, and we develop our minds in meditation. This brings us happiness, and the dedication to the deceased brings happiness to them as well.