/// <summary> /// User GridView CellContent Click Event. /// </summary> private void UserGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex == -1 || e.ColumnIndex == -1) { return; } var key = (Guid)UserGridView.Rows[e.RowIndex].Cells["UIDColumn"].Value; var obj = GridUsers.Find(r => r.UserID == key); if (obj == null) { MessageBox.Show("未找到相关数据项", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } switch (UserGridView.Columns[e.ColumnIndex].Name) { case "DeleteColumn": if (key == Common.CurUser.UserID) { MessageBox.Show("禁止删除当前用户", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show(String.Format("用户[{0}]将被删除,您确定要删除吗?", obj.UserName), "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK) { var result = Common.ShowWait(() => { MemberShipEntity.DeleteUsers(new List <Guid> { obj.UserID }); }, default(String), "正在删除,请稍后...", default(Int32), default(Int32)); if (result == System.Windows.Forms.DialogResult.OK) { Users.Remove(obj); GridUsers.Remove(obj); UserGridView.Rows.RemoveAt(e.RowIndex); Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.UserManagerForm.UserGridView.CellContentClick", String.Format("删除用户:[{0}]", obj.UserName), null); } } break; case "EditColumn": if (new SaveUserForm(EnmSaveBehavior.Edit, obj).ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { UserGridView.InvalidateRow(e.RowIndex); } break; case "LockedOutColumn": if (obj.IsLockedOut && MessageBox.Show(String.Format("您确定要对用户[{0}]解锁吗?", obj.UserName), "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK) { obj.FailedPasswordAttemptCount = 0; obj.IsLockedOut = false; MemberShipEntity.UpdateUser(obj); UserGridView.InvalidateRow(e.RowIndex); Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.UserManagerForm.UserGridView.CellContentClick", String.Format("解锁用户:[{0}]", obj.UserName), null); MessageBox.Show("已解锁完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; default: break; } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.UserManagerForm.UserGridView.CellContentClick", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }