Пример #1
0
        /// <summary>
        /// Muestra la ventana detalle en modo edit
        /// </summary>
        /// <history>
        /// [emoguel] 14/04/2016 Created
        /// </history>
        private void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            RateType          rateType          = (RateType)dgrRateTypes.SelectedItem;
            frmRateTypeDetail frmRateTypeDetail = new frmRateTypeDetail();

            frmRateTypeDetail.Owner       = this;
            frmRateTypeDetail.enumMode    = EnumMode.Edit;
            frmRateTypeDetail.oldRateType = rateType;
            if (frmRateTypeDetail.ShowDialog() == true)
            {
                int             nIndex       = 0;
                List <RateType> lstRateTypes = (List <RateType>)dgrRateTypes.ItemsSource;
                if (ValidateFilter(frmRateTypeDetail.rateType))
                {
                    ObjectHelper.CopyProperties(rateType, frmRateTypeDetail.rateType); //Actualizamos los datos del registro
                    lstRateTypes.Sort((x, y) => string.Compare(x.raN, y.raN));         //Ordenamos los registros
                    nIndex = lstRateTypes.IndexOf(rateType);                           //obtenemos la posición del registro
                }
                else
                {
                    lstRateTypes.Remove(rateType);//Eliminamos el registro
                }
                dgrRateTypes.Items.Refresh();
                GridHelper.SelectRow(dgrRateTypes, nIndex);
                StatusBarReg.Content = lstRateTypes.Count + " Rate Types.";
            }
        }
Пример #2
0
        /// <summary>
        /// Abre la ventana detalle en Modo add
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 14/04/2016
        /// </history>
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            frmRateTypeDetail frmRateTypeDetail = new frmRateTypeDetail();

            frmRateTypeDetail.Owner    = this;
            frmRateTypeDetail.enumMode = EnumMode.Add;
            if (frmRateTypeDetail.ShowDialog() == true)
            {
                RateType rateType = frmRateTypeDetail.rateType;
                if (ValidateFilter(rateType))
                {
                    List <RateType> lstRateTypes = (List <RateType>)dgrRateTypes.ItemsSource;
                    lstRateTypes.Add(rateType);                                 //Agregamos el registro a la lista
                    lstRateTypes.Sort((x, y) => string.Compare(x.raN, y.raN));  //Ordenamos la lista
                    int nIndex = lstRateTypes.IndexOf(rateType);                //Obtenemos el index del nuevo registro
                    dgrRateTypes.Items.Refresh();                               //Actualizamos la vista
                    GridHelper.SelectRow(dgrRateTypes, nIndex);                 //Seleccionamos el registro
                    StatusBarReg.Content = lstRateTypes.Count + " Rate Types."; //Actualizamos el contador
                }
            }
        }