/// <summary> /// Muestra la ventana detalle /// </summary> /// <history> /// [emoguel] 11/04/2016 Created /// </history> private void Cell_DoubleClick(object sender, RoutedEventArgs e) { PermissionLevel permissionLevel = (PermissionLevel)dgrPermissionsLevels.SelectedItem; frmPermissionLevelDetail frmPermissionLevelDetail = new frmPermissionLevelDetail(); frmPermissionLevelDetail.Owner = this; frmPermissionLevelDetail.enumMode = EnumMode.Edit; frmPermissionLevelDetail.oldPermissionLevel = permissionLevel; if (frmPermissionLevelDetail.ShowDialog() == true) { int nIndex = 0; List <PermissionLevel> lstPermissionsLevels = (List <PermissionLevel>)dgrPermissionsLevels.ItemsSource; if (ValidateFilter(frmPermissionLevelDetail.permissionLevel)) { ObjectHelper.CopyProperties(permissionLevel, frmPermissionLevelDetail.permissionLevel); //Actualizamos los datos lstPermissionsLevels.Sort((x, y) => string.Compare(x.plN, y.plN)); //ordenamos la lista nIndex = lstPermissionsLevels.IndexOf(permissionLevel); //obtenemos la posición } else { lstPermissionsLevels.Remove(permissionLevel); //Elminamos el registro } dgrPermissionsLevels.Items.Refresh(); //actualizamos la lista GridHelper.SelectRow(dgrPermissionsLevels, nIndex); //seleccionamos el registro StatusBarReg.Content = lstPermissionsLevels.Count + " Permission Levels."; } }
/// <summary> /// Abre la ventana detalle en modo Add /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [Emoguel] created 11/04/2016 /// </history> private void btnAdd_Click(object sender, RoutedEventArgs e) { frmPermissionLevelDetail frmPermissionLevelDetail = new frmPermissionLevelDetail(); frmPermissionLevelDetail.Owner = this; frmPermissionLevelDetail.enumMode = EnumMode.Add; if (frmPermissionLevelDetail.ShowDialog() == true) { PermissionLevel permissionLevel = frmPermissionLevelDetail.permissionLevel; if (ValidateFilter(permissionLevel))//Validamos si cumple con los permisos actuales { List <PermissionLevel> lstPermissionsLevels = (List <PermissionLevel>)dgrPermissionsLevels.ItemsSource; lstPermissionsLevels.Add(permissionLevel); //Agregamos el nuevo registro lstPermissionsLevels.Sort((x, y) => string.Compare(x.plN, y.plN)); //ordenamos la lista int nIndex = lstPermissionsLevels.IndexOf(permissionLevel); //obtenemos la posicion del nuevo registro dgrPermissionsLevels.Items.Refresh(); //Actualizamos la vista GridHelper.SelectRow(dgrPermissionsLevels, nIndex); //Seleccionamos el registro nuevo StatusBarReg.Content = lstPermissionsLevels.Count + " Permission Levels."; //Actualizamos el contador } } }