/// <summary> /// 更新信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Update_Click(object sender, EventArgs e) { if (btn_Update.Text == "保 存") //保存功能 { if (!string.IsNullOrEmpty(txtName.Text.Trim())) { //判断姓名是否重复 string sql = "Select * from Personnel where enable='1' and name='" + DESJiaMi.Encrypt(txtName.Text.Trim()) + "' and id<>" + CurrentSelectNumber + " ;"; DataTable userUpdate = DbHelperOleDb.Query(sql, new Dictionary <string, object>()).Tables[0]; if (userUpdate != null && userUpdate.Rows.Count > 0) { MessageBox.Show("该姓名信息已经存在,不能重新添加该姓名的员工信息!!!", "保存", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { //执行更新 Personnel personnel = new Personnel(); personnel.name = DESJiaMi.Encrypt(txtName.Text.Trim()); personnel.gender = cboxGender.Text != "" ? DESJiaMi.Encrypt(cboxGender.Text.Trim()) : ""; personnel.lxdh = txtLxdh.Text != "" ? DESJiaMi.Encrypt(txtLxdh.Text.Trim()) : ""; personnel.mainwork = richMainjob.Text; personnel.createtime = labCreateTime.Text; personnel.createusername = UserInfo.userName; personnel.enable = "1"; List <termList> termes = new List <termList>(); termes.Add(new termList("id", "id1", CurrentSelectNumber, 0)); if (DbHelperOleDb.Update(personnel, "Personnel", termes, null, true)) { updateORAddSuccess = true; MessageBox.Show("保存成功!", "修改", MessageBoxButtons.OK, MessageBoxIcon.Information); //ClearnNeiRong(); //清空内容 IsAddNeiRong(false); SetButtonStatus(true, true, true); //重置按钮状态 LoadPersonelInfo(); //重新加载职工列表 btn_Update.Text = "修 改"; } else { MessageBox.Show("保存失败!", "修改", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { MessageBox.Show("请先输入有效的“姓名”信息!!!", "保存", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { if (!string.IsNullOrEmpty(txtName.Text) && !string.IsNullOrEmpty(CurrentSelectNumber)) //修改功能 { //信息可编状态 IsAddNeiRong(true); btn_Update.Text = "保 存"; //设置按钮状态 SetButtonStatus(true, false, false); } else { MessageBox.Show("未选择有效的员工信息数据,无法进行修改。\r\n请先双击左侧待修改的员工列表中需要修改的记录", "修改", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }