private void btnAdd_Click(object sender, EventArgs e) { if (txtModelname.Text != "") { try { CC.CheckConnection(); CC.AddModelName(txtModelname.Text); this.Close(); } catch (Exception) { MessageBox.Show("Connection error"); } } else { MessageBox.Show("Write the model name you want to add and then press the 'Add' button"); } }