Sure you can. Just modify it's parameters and a Button or a string to use it as in:
private string MyFunction(yourParamsHere, string buttonName){
....
switch(buttonName)....
}
and on the click events that call the function:
MyFunction(yourParamsHere, ((Button)sender).ID);