/// <summary> /// Abre la ventana detalle en modo "detalle" o "edición" dependiendo de sus permisos /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 17/05/2016 /// </history> private void Cell_DoubleClick(object sender, RoutedEventArgs e) { LocationCategory locationCategory = (LocationCategory)dgrLocationCategories.SelectedItem; frmLocationCategoryDetail frmLocationCategoryDetail = new frmLocationCategoryDetail(); frmLocationCategoryDetail.Owner = this; frmLocationCategoryDetail.enumMode = EnumMode.Edit; frmLocationCategoryDetail.oldLocationCategory = locationCategory; if (frmLocationCategoryDetail.ShowDialog() == true) { List <LocationCategory> lstLocationCategory = (List <LocationCategory>)dgrLocationCategories.ItemsSource; int nIndex = 0; if (ValidateFilter(frmLocationCategoryDetail.locationCategory)) //Verificamos que cumpla con los filtros { ObjectHelper.CopyProperties(locationCategory, frmLocationCategoryDetail.locationCategory); //Actualizamos los datos lstLocationCategory.Sort((x, y) => string.Compare(x.lcN, y.lcN)); //ordenamos la lista nIndex = lstLocationCategory.IndexOf(locationCategory); //Obtenemos la posición del registro } else { lstLocationCategory.Remove(locationCategory); //Quitamos el registro } dgrLocationCategories.Items.Refresh(); //Actualizamos la vista GridHelper.SelectRow(dgrLocationCategories, nIndex); //Seleccionamos el registro StatusBarReg.Content = lstLocationCategory.Count + " Location categories."; //Actualizamos el contador } }
/// <summary> /// Abre la ventana detalle en modo Add /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 17/05/2016 /// </history> private void btnAdd_Click(object sender, RoutedEventArgs e) { frmLocationCategoryDetail frmLocartionCategoryDetail = new frmLocationCategoryDetail(); frmLocartionCategoryDetail.Owner = this; frmLocartionCategoryDetail.enumMode = EnumMode.Add; if (frmLocartionCategoryDetail.ShowDialog() == true) { if (ValidateFilter(frmLocartionCategoryDetail.locationCategory))//Verificamos que cumpla con los filtros { List <LocationCategory> lstLocationCategory = (List <LocationCategory>)dgrLocationCategories.ItemsSource; lstLocationCategory.Add(frmLocartionCategoryDetail.locationCategory); //Agregamos el registro lstLocationCategory.Sort((x, y) => string.Compare(x.lcN, y.lcN)); //Ordenamos la lista int nIndex = lstLocationCategory.IndexOf(frmLocartionCategoryDetail.locationCategory); //Buscamos la posición del registro dgrLocationCategories.Items.Refresh(); //Actualizamos la vista GridHelper.SelectRow(dgrLocationCategories, nIndex); //Seleccionamos el registro StatusBarReg.Content = lstLocationCategory.Count + " Location Category."; //Actualizamos el contador } } }