private void YESBtn_Click(object sender, EventArgs e) { DataAgent dataAgent = DataAgentFactory.GetDataAgent(); DataTable dt = dataAgent.GetExistUser(userIdTextBox.Text); if (dt.Rows.Count > 0) { int A = dataAgent.AddExistUser(OMWorkBench.AgentId, OMWorkBench.MangerId, userIdTextBox.Text); this.DialogResult = DialogResult.Yes; } else { userExistLabel.Text = "此用户不存在!"; userExistLabel.ForeColor = Color.Red; } }