private void buttonConnect_Click(object sender, EventArgs e) { string ipAddressFromUser = textBoxIP.Text; if (_server.IsUserVaild(textBoxUserName.Text, textBoxPassword.Text)) { if (ipAddressFromUser != string.Empty) { ConnectionManager.Instance.Close(); ConnectionManager.Instance.Init(ipAddressFromUser, textBoxUserName.Text, textBoxPassword.Text); //if (ConnectionManager.Instance.Connect()) { WriteDetailsToMailServerFile(textBoxUserName.Text, textBoxPassword.Text, textBoxIP.Text); MessageBox.Show("Login succeeded.", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } //else //{ // MessageBox.Show("Something wrong please try again.", "Login", // MessageBoxButtons.OK, MessageBoxIcon.Error); // this.Close(); //} } else { MessageBox.Show("You must write IP address", "Login", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }