title: Generate Invoice Number for Multi user environment in C#
body: <p>I am generating invoice numbers using Max function and adding 1 to the last invoice number. Very straightforward. but i applied this into Multi User environment getting problem. because two users open a invoice window at a same time both could get same id, invoice number should be the first thing to appear and not the last so i cannot use identity (auto generate id) for invoice number. I want to generate invoice number for Multi User environment windows form application in C#...</p>
  
  <p>The other problem is what will happen two users accessing and updating the same record same time. </p>
  
  <p>I hope you will understand the problem. i read about the Optimistic vs. Pessimistic locking but i need a solution. so can anyone please reply to me</p>