What is the problem? We can't give you code, we don't know the branch or area code formats, so we have no idea about the rest of it. But Random is easy:
private Random rand = new Random();
...
int randomNumber = rand.Next(1000000);
string randomCode = randomNumber.ToString("D6");
Then combine with your branch and area codes, and see if it is in the db already!
You might want to add a check digit or similar to make it harder for human error to slip in...