/// <summary> /// Muestra la ventada detalle /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 23/03/2016 /// </history> private void Cell_DoubleClick(object sender, RoutedEventArgs e) { GiftCategory giftCategory = (GiftCategory)dgrGiftsCateg.SelectedItem; frmGiftCategoryDetail frmGiftCategoryDetail = new frmGiftCategoryDetail(); frmGiftCategoryDetail.Owner = this; frmGiftCategoryDetail.enumMode = ((_blnEdit) ? EnumMode.Edit : EnumMode.ReadOnly); frmGiftCategoryDetail.oldGiftCategory = giftCategory; if (frmGiftCategoryDetail.ShowDialog() == true) { int nIndex = 0; List <GiftCategory> lstGiftsCateg = (List <GiftCategory>)dgrGiftsCateg.ItemsSource; if (!ValidateFilter(frmGiftCategoryDetail.giftCategory)) //Verificamos si cumple con los filtros { lstGiftsCateg.Remove(giftCategory); //Removemos el registro StatusBarReg.Content = lstGiftsCateg.Count + " Gift Categories."; //Actualizamos el contador } else { ObjectHelper.CopyProperties(giftCategory, frmGiftCategoryDetail.giftCategory); //Actualizamos el registros lstGiftsCateg.Sort((x, y) => string.Compare(x.gcN, y.gcN)); //Ordenamos la lista nIndex = lstGiftsCateg.IndexOf(giftCategory); } dgrGiftsCateg.Items.Refresh(); GridHelper.SelectRow(dgrGiftsCateg, nIndex);//Seleccionamos el registro si no se eliminó } }
/// <summary> /// Abre la ventana detalle en modo add /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 23/03/2016 /// </history> private void btnAdd_Click(object sender, RoutedEventArgs e) { frmGiftCategoryDetail frmGiftCategoryDetail = new frmGiftCategoryDetail(); frmGiftCategoryDetail.Owner = this; frmGiftCategoryDetail.enumMode = EnumMode.Add; if (frmGiftCategoryDetail.ShowDialog() == true) { if (ValidateFilter(frmGiftCategoryDetail.giftCategory))//Verificamos si cumple con los filtros actuales { List <GiftCategory> lstGiftsCateg = (List <GiftCategory>)dgrGiftsCateg.ItemsSource; lstGiftsCateg.Add(frmGiftCategoryDetail.giftCategory); //Agregamos el nuevo registro lstGiftsCateg.Sort((x, y) => string.Compare(x.gcN, y.gcN)); //Ordenamos la lista int nIndex = lstGiftsCateg.IndexOf(frmGiftCategoryDetail.giftCategory); //Obtenemos la posicion del nuevo registro dgrGiftsCateg.Items.Refresh(); //Refrescamos la lista GridHelper.SelectRow(dgrGiftsCateg, nIndex); //Seleccionamos el nuevo registro StatusBarReg.Content = lstGiftsCateg.Count + " Gift Categories."; //Actualizamos el contador } } }