private void OnClickAdd(object sender, EventArgs e) { if (int.TryParse(NumberBox.Text, System.Globalization.NumberStyles.Integer, null, out int number)) { if (Cliloc.IsNumberFree(number)) { Cliloc.AddEntry(number); Close(); } else { MessageBox.Show( "Number not free.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } else { MessageBox.Show( "Error reading Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }