private void btnMove_Click(object sender, EventArgs e) { ProtocolSystemUSerExternalList objProtocolSystemUSerExternalList = new ProtocolSystemUSerExternalList(); if (_TempProtocolSystemUSerExternalList == null) { _TempProtocolSystemUSerExternalList = new List <ProtocolSystemUSerExternalList>(); } int SystemUserID = int.Parse(treeViewUserExternal.SelectedNode.Name.ToString()); //Busco en la lista temporal si ya se agrego el item seleccionado var findResult = _TempProtocolSystemUSerExternalList.Find(p => p.i_SystemUserId == SystemUserID); if (findResult == null) { //Verificar si el usuario se encuentra en otra empresa //Verificar cuantos protocolos està asigando este usuario var ListaProtocolos = new ProtocolBL().GetProtocolbySystemUserId(SystemUserID); //Verificar si el usuario esta en una empresa diferente if (ListaProtocolos.FindAll(p => p.v_CustomerOrganizationId != _EmpresaId).Count() > 0) { MessageBox.Show("El usuario: " + treeViewUserExternal.SelectedNode.Text + " ya se encuentra asiganado a la empresa: " + ListaProtocolos[0].v_CustomerOrganizationName, "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } objProtocolSystemUSerExternalList.v_UserName = treeViewUserExternal.SelectedNode.Text; objProtocolSystemUSerExternalList.i_SystemUserId = int.Parse(treeViewUserExternal.SelectedNode.Name.ToString()); //objProtocolSystemUSerExternalList.v_ProtocolId = _TempProtocolSystemUSerExternalList.Add(objProtocolSystemUSerExternalList); } else { MessageBox.Show("Este Usuario ya se encuentra en la lista", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); } var dataList = _TempProtocolSystemUSerExternalList; grdDataUserExternal.DataSource = new ProtocolSystemUSerExternalList(); grdDataUserExternal.DataSource = dataList; grdDataUserExternal.Refresh(); if (grdDataUserExternal.Rows.Count() > 0) { btnSave.Enabled = true; } else { btnSave.Enabled = false; } }