/// <summary> /// Muestra la ventada Charge To ReadOnly /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Cell_DoubleClick(object sender, RoutedEventArgs e) { Currency currency = (Currency)dgrCurrencies.SelectedItem; frmCurrencyDetail frmCurrencyDetail = new frmCurrencyDetail(); frmCurrencyDetail.Owner = this; frmCurrencyDetail.mode = ((_blnEdit == true) ? EnumMode.Edit : EnumMode.ReadOnly); frmCurrencyDetail.oldCurrency = currency; if (frmCurrencyDetail.ShowDialog() == true) { List <Currency> lstCurrencies = (List <Currency>)dgrCurrencies.ItemsSource; int nIndex = 0; if (!ValidateFilters(frmCurrencyDetail.currency)) //Verificar si cumple con los filtros { lstCurrencies.Remove(currency); //se quita el registro } else { ObjectHelper.CopyProperties(currency, frmCurrencyDetail.currency); lstCurrencies.Sort((x, y) => string.Compare(x.cuN, y.cuN));//ordenamos la lista nIndex = lstCurrencies.IndexOf(currency); } dgrCurrencies.Items.Refresh(); //refrescamos la lista GridHelper.SelectRow(dgrCurrencies, nIndex); StatusBarReg.Content = lstCurrencies.Count + " Currencies."; //Actualizamos el contador } }
/// <summary> /// Abre la ventana de detalles en modo add /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [Emoguel] created 08/03/2016 /// </history> private void btnAdd_Click(object sender, RoutedEventArgs e) { frmCurrencyDetail frmCurrencyDetail = new frmCurrencyDetail(); frmCurrencyDetail.Owner = this; frmCurrencyDetail.mode = EnumMode.Add; if (frmCurrencyDetail.ShowDialog() == true) { if (ValidateFilters(frmCurrencyDetail.currency))//valida que cumpla con los filtros { List <Currency> lstCurrencies = (List <Currency>)dgrCurrencies.ItemsSource; lstCurrencies.Add(frmCurrencyDetail.currency); //Agregamos el registro nuevo lstCurrencies.Sort((x, y) => string.Compare(x.cuN, y.cuN)); //ordenamos la lista int nIndex = lstCurrencies.IndexOf(frmCurrencyDetail.currency); //obtenemos el index del registro nuevo dgrCurrencies.Items.Refresh(); //refrescamos la lista GridHelper.SelectRow(dgrCurrencies, nIndex); StatusBarReg.Content = lstCurrencies.Count + " Currencies."; //Actualizamos el contador } } }