private void btnUpdateProtocolSystemUser_Click(object sender, EventArgs e) { if (_systemUserId == null) { MessageBox.Show("Debe Seleccionar un Usuario", "VALIDACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } var listNew = new List <protocolsystemuserDto>(); var protocolsNew = _protocolsOld.FindAll(p => p.i_RecordStatus == (int)RecordStatus.Agregado).ToList(); var permisos = chklPermisosOpciones.CheckedItems; foreach (var protNew in protocolsNew) { foreach (var item in permisos) { var oprotocolsystemuserDto = new protocolsystemuserDto(); oprotocolsystemuserDto.i_SystemUserId = _systemUserId.Value; oprotocolsystemuserDto.v_ProtocolId = protNew.v_ProtocolId; KeyValueDTO obj = (KeyValueDTO)item; oprotocolsystemuserDto.i_ApplicationHierarchyId = int.Parse(obj.Id); listNew.Add(oprotocolsystemuserDto); } } var listRemove = new List <protocolsystemuserDto>(); var protocolsRemove = _protocolsOld.FindAll(p => p.i_RecordStatus == (int)RecordStatus.EliminadoLogico).ToList(); foreach (var protRemove in protocolsRemove) { foreach (var item in permisos) { var oprotocolsystemuserDto = new protocolsystemuserDto(); oprotocolsystemuserDto.i_SystemUserId = _systemUserId.Value; oprotocolsystemuserDto.v_ProtocolId = protRemove.v_ProtocolId; KeyValueDTO obj = (KeyValueDTO)item; oprotocolsystemuserDto.i_ApplicationHierarchyId = int.Parse(obj.Id); listRemove.Add(oprotocolsystemuserDto); } } OperationResult objOperationResult = new OperationResult(); if (listNew.Count == 0 && listRemove.Count == 0) { MessageBox.Show("No hubo ningún cambio en los protocolos", "INFORMACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } _protocolBL.UpdateProtocolSystemUser(ref objOperationResult, listNew, listRemove, Globals.ClientSession.GetAsList()); if (objOperationResult.Success == 1) { MessageBox.Show("Se grabó correctamente la información. ", "INFORMACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (objOperationResult.ErrorMessage != null) { MessageBox.Show(objOperationResult.ErrorMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(Constants.GenericErrorMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }