/// <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 11/03/2016 /// </history> private void Cell_DoubleClick(object sender, RoutedEventArgs e) { Agency agency = (Agency)dtgAgencies.SelectedItem; frmAgencyDetail frmAgencyDetail = new frmAgencyDetail(); frmAgencyDetail.oldAgency = agency; frmAgencyDetail.Owner = this; frmAgencyDetail.enumMode = ((_blnEdit == true) ? EnumMode.Edit : EnumMode.ReadOnly); if (frmAgencyDetail.ShowDialog() == true) { int nIndex = 0; List <Agency> lstAgencies = (List <Agency>)dtgAgencies.ItemsSource;//cateamos el itemsource if (!ValidateFilters(frmAgencyDetail.agency)) { lstAgencies.Remove(agency);//quitamos el registro de la lista } else { ObjectHelper.CopyProperties(agency, frmAgencyDetail.agency); lstAgencies.Sort((x, y) => string.Compare(x.agN, y.agN));//ordenamos la lista nIndex = lstAgencies.IndexOf(agency); } dtgAgencies.Items.Refresh(); StatusBarReg.Content = lstAgencies.Count + " Agencies.";//Actualizamos el contador GridHelper.SelectRow(dtgAgencies, nIndex); } }
/// <summary> /// Abre la ventana detalle en modo agregar /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, RoutedEventArgs e) { frmAgencyDetail frmAgencyDetail = new frmAgencyDetail(); frmAgencyDetail.enumMode = EnumMode.Add;//Insertar frmAgencyDetail.Owner = this; frmAgencyDetail.oldAgency = new Agency(); if (frmAgencyDetail.ShowDialog() == true) { if (ValidateFilters(frmAgencyDetail.agency)) //Validamos si el nuevo registro cumple con los requisitos { List <Agency> lstAgencies = (List <Agency>)dtgAgencies.ItemsSource; //cateamos el itemsource lstAgencies.Add(frmAgencyDetail.agency); //Agregamos el registro nuevo lstAgencies.Sort((x, y) => string.Compare(x.agN, y.agN)); //ordenamos la lista int nIndex = lstAgencies.IndexOf(frmAgencyDetail.agency); //obtenemos el index del registro nuevo dtgAgencies.Items.Refresh(); //Refrescamos la lista GridHelper.SelectRow(dtgAgencies, nIndex); StatusBarReg.Content = lstAgencies.Count + " Agencies."; //Actualizamos el contador } } }