private void metroButton1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtUserName.Text) || string.IsNullOrEmpty(txtPwd.Text)) { this.txtUserName.Focus(); MetroMessageBox.Show(this, "请输入用户名和密码", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } MemberLogin loginDto = new MemberLogin() { Pwd = txtPwd.Text, UserName = txtUserName.Text }; MemberServices mServices = new MemberServices(); var result = mServices.Login(loginDto); if (result.Code == ResultCodeEnums.Error) { MetroMessageBox.Show(this, result.Msg, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { this.DialogResult = DialogResult.OK;//关键:设置登陆成功状态 this.Close(); } }