private void dgvMain_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } string UserID = Convert.ToString(dgvMain.Rows[e.RowIndex].Cells["KeyID"].Value); if (string.IsNullOrEmpty(UserID)) { return; } WSMain.t_SystemUser mUser = LUser.Where(n => n.KeyID.Equals(UserID)).ToList()[0]; if (dgvMain.Columns[e.ColumnIndex].HeaderText.Equals("编辑")) { frmUserEdit UserEdit = new frmUserEdit(); UserEdit.mUser = mUser; UserEdit.ShowDialog(); if (!UserEdit.IsCancel) { bgInit.RunWorkerAsync(); } } if (dgvMain.Columns[e.ColumnIndex].HeaderText.Equals("是否启用")) { string sContent = string.Format("是否要{0}账户:『{1}』?", mUser.IsEnable ? "禁用" : "启用", mUser.sLoginName); System.Windows.Forms.DialogResult result = MessageBox.Show(sContent, "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes) { if (mUser.IsEnable) { Func.tSysUser.DisableUser(UserID); } else { Func.tSysUser.EnableUser(UserID); } bgInit.RunWorkerAsync(); } } }
private void dgvMain_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex<0) return; string UserID = Convert.ToString(dgvMain.Rows[e.RowIndex].Cells["KeyID"].Value); if (string.IsNullOrEmpty(UserID)) return; WSMain.t_SystemUser mUser = LUser.Where(n => n.KeyID.Equals(UserID)).ToList()[0]; if (dgvMain.Columns[e.ColumnIndex].HeaderText.Equals("编辑")) { frmUserEdit UserEdit = new frmUserEdit(); UserEdit.mUser = mUser; UserEdit.ShowDialog(); if (!UserEdit.IsCancel) bgInit.RunWorkerAsync(); } if (dgvMain.Columns[e.ColumnIndex].HeaderText.Equals("是否启用")) { string sContent = string.Format("是否要{0}账户:『{1}』?", mUser.IsEnable ? "禁用" : "启用", mUser.sLoginName); System.Windows.Forms.DialogResult result = MessageBox.Show(sContent, "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result==System.Windows.Forms.DialogResult.Yes) { if (mUser.IsEnable) Func.tSysUser.DisableUser(UserID); else Func.tSysUser.EnableUser(UserID); bgInit.RunWorkerAsync(); } } }