Beispiel #1
0
        /// <summary>
        /// Muestra la ventada detalle
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 07/04/2016
        /// </history>
        private void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            Period          period          = (Period)dgrPeriods.SelectedItem;
            frmPeriodDetail frmPeriodDetail = new frmPeriodDetail();

            frmPeriodDetail.Owner     = this;
            frmPeriodDetail.enumMode  = (_blnEdit) ? EnumMode.Edit : EnumMode.ReadOnly;
            frmPeriodDetail.oldPeriod = period;
            if (frmPeriodDetail.ShowDialog() == true)
            {
                int           nIndex     = 0;
                List <Period> lstPeriods = (List <Period>)dgrPeriods.ItemsSource;
                if (ValidateFilter(frmPeriodDetail.period))                      //Verificamos si cumple con los filtros
                {
                    ObjectHelper.CopyProperties(period, frmPeriodDetail.period); //Asignamos los nuevos valores
                    lstPeriods.Sort((x, y) => string.Compare(x.pdN, y.pdN));     //ordenamos la lista
                    nIndex = lstPeriods.IndexOf(period);                         //Obtenemos la posición del registro
                }
                else
                {
                    lstPeriods.Remove(period);                        //removemos el registro
                }
                dgrPeriods.Items.Refresh();                           //actualizamos la vista
                GridHelper.SelectRow(dgrPeriods, nIndex);             //Seleccionamos el registro
                StatusBarReg.Content = lstPeriods.Count + "Periods."; //Actualizamos el contador
            }
        }
Beispiel #2
0
        /// <summary>
        /// Abre la ventana detalle en modo Add
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 07/04/2016
        /// </history>
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            frmPeriodDetail frmPeriodDetail = new frmPeriodDetail();

            frmPeriodDetail.Owner    = this;
            frmPeriodDetail.enumMode = EnumMode.Add;
            if (frmPeriodDetail.ShowDialog() == true)
            {
                Period period = frmPeriodDetail.period;
                if (ValidateFilter(period))//Verificamos que cumpla con los filtros actuales
                {
                    List <Period> lstPeriod = (List <Period>)dgrPeriods.ItemsSource;
                    lstPeriod.Add(period);                                  //Agregamos el registro a la lista
                    lstPeriod.Sort((x, y) => string.Compare(x.pdN, y.pdN)); //ordenamos la lista
                    int nIndex = lstPeriod.IndexOf(period);                 //obtenemos la posición del nuevo registro
                    dgrPeriods.Items.Refresh();                             //Actualizamos la vista
                    GridHelper.SelectRow(dgrPeriods, nIndex);               //Seleccionamos la lista
                    StatusBarReg.Content = lstPeriod.Count + " Periods.";   //Actualizamos el contador
                }
            }
        }