private async void buttonModify_Click(object sender, EventArgs e) { // 首先进行容错 if (this.textBoxName.Text.Trim() == "" || this.textBoxPosition.Text.Trim() == "") { MessageBox.Show("请将信息填写完整!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.CanSign.Checked && this.PictureBox.ImageLocation == null) //if (this.m_isRepicture == false) { MessageBox.Show("签字人需要提交签字图片!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //if (UserHelper.EmpList.Where(o => o. == this.textBoxName.Text).ToList().Count > 0) //{ // MessageBox.Show("员工信息已经存在,无法再次插入\n请检查用户名是否与他人重复!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} try { this.m_employee.Name = this.textBoxName.Text; this.m_employee.Department.Id = Convert.ToInt32(this.comboBoxDepartment.SelectedValue); this.m_employee.Department.Name = this.comboBoxDepartment.SelectedItem.ToString(); this.m_employee.Position = this.textBoxPosition.Text; if (this.CanSubmit.Checked) { this.m_employee.CanSubmit = 1; } else { this.m_employee.CanSubmit = 0; } if (this.CanSign.Checked) { this.m_employee.CanSign = 1; this.PicturrName.Visible = true; // 图片路径 this.UploadButton.Visible = true; // 上传按钮 this.PictureBox.Visible = true; // } else { this.m_employee.CanSign = 0; this.PicturrName.Visible = false; this.UploadButton.Visible = false; this.PictureBox.Visible = false; // } if (this.CanAdmin.Checked) { this.m_employee.IsAdmin = 1; } else { this.m_employee.IsAdmin = 0; } if (this.CanStatistic.Checked) { this.m_employee.CanStatistic = 1; } else { this.m_employee.CanStatistic = 0; } string result = _sc.ModifyEmployee(this.m_employee); if (result == Response.MODIFY_EMPLOYEE_SUCCESS.ToString()) { MessageBox.Show("修改员工信息成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); //////////////////////////////////////// // 绑定底层数据信息 //UserHelper.UserInfo = this.m_employee; //////////////////////////////////////// if (this.CanSign.Checked && this.PictureBox.ImageLocation != null && this.m_isRepicture == true) { await _sc.UploadPicture(this.m_employee.Id, this.PictureBox.ImageLocation); MessageBox.Show("重新上传签字信息成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else if (result == "服务器连接中断") { MessageBox.Show("服务器连接中断,修改员工信息失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("修改员工信息失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } this.DialogResult = DialogResult.OK; } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }