public void AutoCodeGenerate() { decimal AlreadyExistData = _CategoriesManager.AlreadyExistData(); int code = 000; if (AlreadyExistData >= 1) { var GetLastCode = _CategoriesManager.GetLastCode(); if (GetLastCode != null) { code = Convert.ToInt32(GetLastCode.Code); code++; } txtCategoryCode.Text = code.ToString("000"); } else { txtCategoryCode.Text = "001"; } }