Exemplo n.º 1
0
        /// <summary>
        /// Verifica si un objeto tipo GiftCategory con los filtros del grid
        /// </summary>
        /// <param name="newGiftCategory"></param>
        /// <returns>True. SI cumple | False. No cumple</returns>
        /// <history>
        /// [emoguel] created 23/03/2016
        /// </history>
        private bool ValidateFilter(GiftCategory newGiftCategory)
        {
            if (_nStatus != -1)//Filtro por ID
            {
                if (newGiftCategory.gcA != Convert.ToBoolean(_nStatus))
                {
                    return(false);
                }
            }

            if (!string.IsNullOrWhiteSpace(_giftCategoryFilter.gcID))//Filtro por ID
            {
                if (_giftCategoryFilter.gcID != newGiftCategory.gcID)
                {
                    return(false);
                }
            }

            if (!string.IsNullOrWhiteSpace(_giftCategoryFilter.gcN))//Filtro por descripcion
            {
                if (!newGiftCategory.gcN.Contains(_giftCategoryFilter.gcN, StringComparison.OrdinalIgnoreCase))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Muestra la ventada detalle
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 23/03/2016
        /// </history>
        private void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            GiftCategory          giftCategory          = (GiftCategory)dgrGiftsCateg.SelectedItem;
            frmGiftCategoryDetail frmGiftCategoryDetail = new frmGiftCategoryDetail();

            frmGiftCategoryDetail.Owner           = this;
            frmGiftCategoryDetail.enumMode        = ((_blnEdit) ? EnumMode.Edit : EnumMode.ReadOnly);
            frmGiftCategoryDetail.oldGiftCategory = giftCategory;
            if (frmGiftCategoryDetail.ShowDialog() == true)
            {
                int nIndex = 0;
                List <GiftCategory> lstGiftsCateg = (List <GiftCategory>)dgrGiftsCateg.ItemsSource;
                if (!ValidateFilter(frmGiftCategoryDetail.giftCategory))              //Verificamos si cumple con los filtros
                {
                    lstGiftsCateg.Remove(giftCategory);                               //Removemos el registro
                    StatusBarReg.Content = lstGiftsCateg.Count + " Gift Categories."; //Actualizamos el contador
                }
                else
                {
                    ObjectHelper.CopyProperties(giftCategory, frmGiftCategoryDetail.giftCategory); //Actualizamos el registros
                    lstGiftsCateg.Sort((x, y) => string.Compare(x.gcN, y.gcN));                    //Ordenamos la lista
                    nIndex = lstGiftsCateg.IndexOf(giftCategory);
                }
                dgrGiftsCateg.Items.Refresh();
                GridHelper.SelectRow(dgrGiftsCateg, nIndex);//Seleccionamos el registro si no se eliminó
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// obtiene registros del catalogo GiftsCategs
        /// </summary>
        /// <param name="giftCategory">Objeto con filtros adicionales</param>
        /// <param name="nStatus">-1. Todos los registros | 0. Registros inactivos | 1.Registros activos</param>
        /// <returns>Lista de tipo GiftCategory</returns>
        /// <history>
        /// [emoguel] created 23/03/2016
        /// </history>
        public async static Task <List <GiftCategory> > GetGiftsCategories(GiftCategory giftCategory = null, int nStatus = -1)
        {
            return(await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from gc in dbContext.GiftsCategories
                                select gc;

                    if (nStatus != -1)//Filtro por estatus
                    {
                        bool blnEstatus = Convert.ToBoolean(nStatus);
                        query = query.Where(gc => gc.gcA == blnEstatus);
                    }

                    if (giftCategory != null)                              //Verificamos si se tiene objeto
                    {
                        if (!string.IsNullOrWhiteSpace(giftCategory.gcID)) //Filtro por ID
                        {
                            query = query.Where(gc => gc.gcID == giftCategory.gcID);
                        }

                        if (!string.IsNullOrWhiteSpace(giftCategory.gcN))//Filtro por descripcion
                        {
                            query = query.Where(gc => gc.gcN.Contains(giftCategory.gcN));
                        }
                    }

                    return query.OrderBy(gc => gc.gcN).ToList();
                }
            }));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Llena el grid de GiftCategories
        /// </summary>
        /// <param name="nIndex">Indice a seleccionar en el grid</param>
        /// <history>
        /// [emoguel] created 23/03/2016
        /// </history>
        private async void LoadGiftsCategories(GiftCategory giftCategory = null)
        {
            try
            {
                status.Visibility = Visibility.Visible;
                int nIndex = 0;
                List <GiftCategory> lstGiftsCategories = await BRGiftsCategories.GetGiftsCategories(_giftCategoryFilter, _nStatus);

                dgrGiftsCateg.ItemsSource = lstGiftsCategories;
                if (giftCategory != null && lstGiftsCategories.Count > 0)
                {
                    giftCategory = lstGiftsCategories.Where(gc => gc.gcID == giftCategory.gcID).FirstOrDefault();
                    nIndex       = lstGiftsCategories.IndexOf(giftCategory);
                }
                GridHelper.SelectRow(dgrGiftsCateg, nIndex);
                StatusBarReg.Content = lstGiftsCategories.Count + " Gift Categories.";
                status.Visibility    = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                UIHelper.ShowMessage(ex);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Recarga el grid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 23/03/2016
        /// </history>
        private void btnRef_Click(object sender, RoutedEventArgs e)
        {
            GiftCategory giftCategory = (GiftCategory)dgrGiftsCateg.SelectedItem;

            LoadGiftsCategories(giftCategory);
        }