public void EnablePosition(int id) { dal.Update(id, true); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Position model) { return(dal.Update(model)); }
/// <summary> /// “修改” 按钮的单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdate_Click(object sender, EventArgs e) { try { if (this.dgvPositionList.SelectedRows.Count > 0)//选中行 { if (dgvPositionList.SelectedRows.Count > 1) { MessageBox.Show("修改只能选中一行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (this.txtPosition_Name.Text == "") { PublicClass.ShowToolTip(ToolTipIcon.Info, "提示", "门岗名称不能为空!", txtPosition_Name, this); return; } if (!btnCheck()) { return; // 去重复 } Expression <Func <Position, bool> > p = n => n.Position_ID == int.Parse(this.dgvPositionList.SelectedRows[0].Cells["Position_ID"].Value.ToString()); string id = ""; string strfront = ""; string strContent = ""; Action <Position> ap = s => { strfront = s.Position_Name + "," + s.Position_Value + "," + s.Position_State + "," + s.Position_UserId + "," + s.Position_Add + "," + s.Position_Phone + "," + s.Position_CameraValue + "," + s.Position_Remark; s.Position_Name = this.txtPosition_Name.Text.Trim(); s.Position_Value = this.txtPosition_Value.Text.Trim(); s.Position_State = this.cbxPosition_State.Text; s.Position_UserId = int.Parse(common.USERID); // 用户编号 s.Position_Add = this.txtPosition_ADD.Text.Trim(); s.Position_Phone = this.txtPosition_Phone.Text.Trim(); s.Position_CameraValue = this.txtPosition_CameraValue.Text.Trim(); s.Position_Remark = this.txtPosition_Remark.Text.Trim(); strContent = s.Position_Name + "," + s.Position_Value + "," + s.Position_State + "," + s.Position_UserId + "," + s.Position_Add + "," + s.Position_Phone + "," + s.Position_CameraValue + "," + s.Position_Remark; }; if (PositionDAL.Update(p, ap)) { MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); CommonalityEntity.WriteLogData("修改", "更新编号为:" + id + "的门岗信息;修改前:" + strfront + ";修改后:" + strContent, common.USERNAME);//添加日志 Empty(); } else { MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } catch { common.WriteTextLog("门岗管理 btnUpdate_Click()"); } finally { LogInfoLoad(""); this.btnUpdate.Enabled = false; this.btnSave.Enabled = true; } }