private void BtnLogin_Click(object sender, EventArgs e) { try { accountProperty = accountMgr.CheckNameAndPasswd(textBox1.Text.Trim(), maskedTextBox1.Text.Trim()); Logger.Info(accountProperty.UserId + "," + accountProperty.Job + " logged in"); } catch (Exception ex) { MessageBox.Show("Can not connect to the server.Please contact the admin"); Logger.Error(ex.StackTrace); return; } if (accountProperty == null) { MessageBox.Show("Invalid Name or Password"); } else { UserInfo.UserId = accountProperty.UserId; UserInfo.UserName = accountProperty.AccountName; UserInfo.Job = (JobDescription)accountProperty.Job; MainFrame mainFrame = new MainFrame(); this.Hide(); mainFrame.WindowState = FormWindowState.Maximized; mainFrame.Show(); } }