/// <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 28/06/2016 /// </history> private void Cell_DoubleClick(object sender, RoutedEventArgs e) { Gift gift = (Gift)dgrGifs.SelectedItem; frmGiftDetail frmGiftDetail = new frmGiftDetail(); frmGiftDetail.Owner = this; frmGiftDetail._oldGift = gift; frmGiftDetail.enumMode = _blnEdit ? EnumMode.Edit : EnumMode.ReadOnly; if (frmGiftDetail.ShowDialog() == true) { List <Gift> lstGifts = (List <Gift>)dgrGifs.ItemsSource; int nIndex = 0; if (ValidateFilter(frmGiftDetail.gift)) { ObjectHelper.CopyProperties(gift, frmGiftDetail.gift); //Actualizamos los datos lstGifts.Sort((x, y) => string.Compare(x.giN, y.giN)); //Ordenamos la lista nIndex = lstGifts.IndexOf(gift); //Obtenemos la posición del registro } else { lstGifts.Remove(gift);//Quitamos el registro } dgrGifs.Items.Refresh(); GridHelper.SelectRow(dgrGifs, nIndex); StatusBarReg.Content = lstGifts.Count + " Gifts.";//Actualizamos el contador } }
/// <summary> /// Recarga los registros del grid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] cretaed 29/06/2016 /// </history> private void btnAdd_Click(object sender, RoutedEventArgs e) { frmGiftDetail frmGiftDetail = new frmGiftDetail(); frmGiftDetail.enumMode = EnumMode.Add; frmGiftDetail.Owner = this; if (frmGiftDetail.ShowDialog() == true) { if (ValidateFilter(frmGiftDetail.gift)) { List <Gift> lstGifts = (List <Gift>)dgrGifs.ItemsSource; lstGifts.Add(frmGiftDetail.gift); //Agregamos el registro lstGifts.Sort((x, y) => string.Compare(x.giN, y.giN)); //Ordenamos la lista int nIndex = lstGifts.IndexOf(frmGiftDetail.gift); //Buscamos el index del registro dgrGifs.Items.Refresh(); //Actualizamos la vista GridHelper.SelectRow(dgrGifs, nIndex); //Seleccionamos el registro StatusBarReg.Content = lstGifts.Count + " Gifts."; //Actualizamos el contador } } }