public string SinhMaTuDong(string tenbang, string tenma, string MaBatDau) { CongViecCtrl cvCtrl = new CongViecCtrl(); int id = 0; bool dung = false; string ma = ""; DataTable dt = new DataTable(); while (dung == false) { dt = CheckID(tenbang, tenma, MaBatDau + id.ToString()); if (dt.Rows.Count == 0) { dung = true; } else { id++; dung = false; } } ma = MaBatDau + id.ToString(); return(ma); }