private string randomCodeForProjectCode() { string letters = "abcdefghijklmnopqrstuvwxyz"; letters = letters.ToUpper(); string random = ""; bool pass = false; while (!pass) { random = ""; Random rn = new Random(); for (int i = 0; i < 3; i++) { random += letters[rn.Next(0, 25)] + "" + (rn.Next(0, 9)); } Project project = broker.IsProjectCodeUnique(random); if (project == null) { pass = true; } } return(random); }
public Project IsProjectCodeUnique(string random) { try { DBBroker broker = new DBBroker(); return(broker.IsProjectCodeUnique(random)); } catch (Exception) { throw; } }