private void btnLogin_Click(object sender, EventArgs e) { bool status = true; try { string username = txtUserName.Text; string password = txtPassword.Text; if (username.ToString() == "" && password.ToString() == "") { MessageBox.Show("Enter username and password"); return; } else { using (PurelifeErpClient.PurelifeErpClient purelifeErpClient = new PurelifeErpClient.PurelifeErpClient()) { PurelifeErpClient.Result res = purelifeErpClient.UserLogin(PurelifeErpClient.PageName.MSTUserDetails, username, password); if (res.Id.ToInt() > 0) { SessionManager.UserCode = res.Id; SessionManager.UserName = username; this.Close(); _k.Value = "true"; Close(); } else { ShowError.SetError(txtPassword, "Please enter correct details"); base.ShowMessage("Invalid user, Please enter correct details"); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Login failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }