/// <summary> /// Muestra la ventana de AssistanceStatusDetail en modo ReadOnly /// </summary> /// <history> /// [emoguel] 27/Feb/2016 Created /// </history> private void Cell_DoubleClick(object sender, RoutedEventArgs e) { AssistanceStatus assistance = (AssistanceStatus)dtgAssitances.SelectedItem; frmAssistanceStatusDetail frmAssistanceDetail = new frmAssistanceStatusDetail(); frmAssistanceDetail.oldAssistance = assistance; frmAssistanceDetail.Owner = this; frmAssistanceDetail.mode = ((_blnEdit == true) ? EnumMode.Edit : EnumMode.ReadOnly); if (frmAssistanceDetail.ShowDialog() == true) { List <AssistanceStatus> lstAssistancesStatus = (List <AssistanceStatus>)dtgAssitances.ItemsSource; int nIndex = 0; if (!ValidateFilters(frmAssistanceDetail.assistance)) //Validamos si cumple con los filtros { lstAssistancesStatus.Remove(assistance); //Quitamos el registro } else { ObjectHelper.CopyProperties(assistance, frmAssistanceDetail.assistance); lstAssistancesStatus.Sort((x, y) => string.Compare(x.atN, y.atN));//ordenamos la lista nIndex = lstAssistancesStatus.IndexOf(assistance); } dtgAssitances.Items.Refresh(); //regrescamos el grid GridHelper.SelectRow(dtgAssitances, nIndex); StatusBarReg.Content = lstAssistancesStatus.Count + " Assistances Status."; //Actualizamos el contador } }
/// <summary> /// Muestra la ventana de AssistanceStatusDetail para agregar un registro nuevo /// </summary> /// <history> /// [emoguel] 27/Feb/2016 Created /// </history> private void btnAdd_Click(object sender, RoutedEventArgs e) { frmAssistanceStatusDetail frmAssistanceDetail = new frmAssistanceStatusDetail(); frmAssistanceDetail.Owner = this; frmAssistanceDetail.mode = EnumMode.Add;//insertar if (frmAssistanceDetail.ShowDialog() == true) { if (ValidateFilters(frmAssistanceDetail.assistance))//Validamos si cumple con los filtros { List <AssistanceStatus> lstAssistancesStatus = (List <AssistanceStatus>)dtgAssitances.ItemsSource; lstAssistancesStatus.Add(frmAssistanceDetail.assistance); //Agregamos el registro nuevo lstAssistancesStatus.Sort((x, y) => string.Compare(x.atN, y.atN)); //ordenamos la lista int nIndex = lstAssistancesStatus.IndexOf(frmAssistanceDetail.assistance); //Obtenemos el index del registro nuevo dtgAssitances.Items.Refresh(); //regrescamos el grid GridHelper.SelectRow(dtgAssitances, nIndex); StatusBarReg.Content = lstAssistancesStatus.Count + " Assistances Status."; //Actualizamos el contador } } }