private void buttonAccept_Click(object sender, EventArgs e) { if (textBoxPairCode.Text == "") { string captionE = "Pair code empty"; string messageE = "You must enter a pair code"; MessageBox.Show(messageE, captionE, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Form wait = new Forms.Wait(); wait.Show(); LatchResponse pair = null; try { pair = latch.Pair(textBoxPairCode.Text); } catch { wait.Close(); string message = "You do not have internet connection"; string caption = "Problem with internet connection"; DialogResult result = MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (pair.Error != null && pair.Error.Message != "") { wait.Close(); string message = pair.Error.Message; string caption = "Latch connection: " + pair.Error.Code; DialogResult result = MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { wait.Close(); accountId = pair.Data["accountId"].ToString(); this.Close(); } } }