private void txtName_Leave(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtName.Text) == true) { txtName.Focus(); MessageBox.Show("Vui lòng nhập tên nhân viên.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { SystemUsersBO aSystemUsersBO = new SystemUsersBO(); string domain = Properties.Resources.Domain1; txtUsername.Text = aSystemUsersBO.GetAvaiableUsername(txtName.Text, domain); txtPassword.Text = txtUsername.Text + "12345678"; } } catch (Exception ex) { // MessageBox.Show("frmTsk_SystemUser_Infromation.txtName_Leave\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult a= MessageBox.Show("Email của người dùng không tồn tại! Bạn có muốn nhập lại","Thông báo",MessageBoxButtons.YesNo); if (a == DialogResult.Yes) { txtName.Focus(); } else if (a == DialogResult.No) { this.Close(); } } }