private void btnRegist_Click(object sender, EventArgs e) { string message = string.Empty; if (!ConfirmNull(out message)) { labelWarning.Text = message; labelWarning.ForeColor = Color.Red; return; } if ((bool)txtAccount.Tag == false) { TEmployeeDTO emp = new TEmployeeDTO(); emp.EmployeeId = Guid.NewGuid().ToString(); emp.EmployeeName = txtName.Text; emp.EmployeePhone = txtTel.Text; emp.EmployeeSex = coboSex.Text; emp.EntryData = dateTimePicker1.Value; emp.IdCard = txtIdCard.Text.Replace("-", ""); emp.EmployeeAge = int.Parse(dmpAge.Text); emp.EntryImage = pictureStreamBox1.GetPictureStream(); bool result = _client.TEmployeeAdd(emp); TLoginDTO login = new TLoginDTO(); login.EmployeeId = emp.EmployeeId; login.LoginId = Guid.NewGuid().ToString(); login.LoginName = txtAccount.Text; login.LoginPsw = txtPsw.Text; login.Role = coboRole.Text; result &= _client.TLoginAdd(login); if (result) { labelWarning.ForeColor = Color.Green; labelWarning.Text = "注册成功!"; _account = login.LoginName + "," + login.LoginPsw; Thread.Sleep(2000); this.DialogResult = DialogResult.OK; } else { labelWarning.Text = "注册失败!"; labelWarning.ForeColor = Color.Red; } } }