Esempio n. 1
0
        /// <summary>
        /// obtiene una lista de tipo EfficiencyType
        /// </summary>
        /// <param name="efficiencyType">Objeto con filtro adicionales</param>
        /// <param name="nStatus">-1. Todos los registros | 0. Registro inactivos | 1. Registros Activos</param>
        /// <returns>Devuelve una lista de tipo EfficiencyType</returns>
        /// <history>
        /// [emoguel] created 18/03/2016
        /// [emoguel] modified 09/06/2016-->Se volvió async
        /// </history>
        public async static Task <List <EfficiencyType> > GetEfficiencyTypes(EfficiencyType efficiencyType = null, int nStatus = -1)
        {
            List <EfficiencyType> lstEfficency = await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from eft in dbContext.EfficiencyTypes
                                select eft;

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

                    if (efficiencyType != null)                              //Si se tiene un objeto
                    {
                        if (!string.IsNullOrWhiteSpace(efficiencyType.etID)) //Filtro por ID
                        {
                            query = query.Where(eft => eft.etID == efficiencyType.etID);
                        }

                        if (!string.IsNullOrWhiteSpace(efficiencyType.etN))//Filtro por descripcion
                        {
                            query = query.Where(eft => eft.etN.Contains(efficiencyType.etN));
                        }
                    }

                    return(query.OrderBy(eft => eft.etN).ToList());
                }
            });

            return(lstEfficency);
        }
Esempio n. 2
0
        /// <summary>
        /// Verificia si el objeto cumple con los filtros establecidos
        /// </summary>
        /// <param name="efficiencyType">Objeto a validar</param>
        /// <returns>true. cumple con los filtros | false. No cumple con los filtros</returns>
        /// <history>
        /// [emoguel] created 19/03/2016
        /// </history>
        private bool ValidateFilter(EfficiencyType efficiencyType)
        {
            if (_nStatus != -1)//Validamos el estatus
            {
                if (efficiencyType.etA != Convert.ToBoolean(_nStatus))
                {
                    return(false);
                }
            }

            if (!string.IsNullOrWhiteSpace(_efficiencyTypeFilter.etID))//Validamos el ID
            {
                if (efficiencyType.etID != _efficiencyTypeFilter.etID)
                {
                    return(false);
                }
            }

            if (!string.IsNullOrWhiteSpace(_efficiencyTypeFilter.etN))//Validamos la descripcion
            {
                if (!efficiencyType.etN.Contains(_efficiencyTypeFilter.etN, StringComparison.OrdinalIgnoreCase))
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// Muestra la ventada efficiency detail dependiendo de los permisos
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [Emoguel] created 18/03/2016
        /// </history>
        private void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            EfficiencyType          efficiencyType   = (EfficiencyType)dgrEfcyTypes.SelectedItem;
            frmEfficiencyTypeDetail frmEfyTypeDetail = new frmEfficiencyTypeDetail();

            frmEfyTypeDetail.Owner      = this;
            frmEfyTypeDetail.enumMode   = ((_blnEdit == true) ? EnumMode.Edit : EnumMode.ReadOnly);
            frmEfyTypeDetail.oldEffType = efficiencyType;

            if (frmEfyTypeDetail.ShowDialog() == true)
            {
                int nIndex = 0;
                List <EfficiencyType> lstEfcyType = (List <EfficiencyType>)dgrEfcyTypes.ItemsSource;
                if (!ValidateFilter(frmEfyTypeDetail.efficiencyType))//Si cumple con los filtros
                {
                    lstEfcyType.Remove(efficiencyType);
                }
                else
                {
                    ObjectHelper.CopyProperties(efficiencyType, frmEfyTypeDetail.efficiencyType);
                    lstEfcyType.Sort((x, y) => string.Compare(x.etN, y.etN));
                    nIndex = lstEfcyType.IndexOf(efficiencyType);
                }
                dgrEfcyTypes.Items.Refresh();
                GridHelper.SelectRow(dgrEfcyTypes, nIndex);
                StatusBarReg.Content = lstEfcyType.Count + " Efficiency Types.";
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Abre la ventana detalle en modo add
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 18/03/2016
        /// </history>
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            frmEfficiencyTypeDetail frmEfyTypeDetail = new frmEfficiencyTypeDetail();

            frmEfyTypeDetail.Owner    = this;
            frmEfyTypeDetail.enumMode = EnumMode.Add;
            if (frmEfyTypeDetail.ShowDialog() == true)
            {
                EfficiencyType efficiencyType = frmEfyTypeDetail.efficiencyType;
                if (ValidateFilter(efficiencyType))
                {
                    List <EfficiencyType> lstEfyType = (List <EfficiencyType>)dgrEfcyTypes.ItemsSource;
                    lstEfyType.Add(efficiencyType);
                    lstEfyType.Sort((x, y) => string.Compare(x.etN, y.etN));
                    int nIndex = lstEfyType.IndexOf(efficiencyType);
                    dgrEfcyTypes.Items.Refresh();
                    GridHelper.SelectRow(dgrEfcyTypes, nIndex);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Llena el grid de Efficiency Types
        /// </summary>
        /// <history>
        /// [emoguel] created 18/03/2016
        /// </history>
        private async void LoadEfficiencyTypes(EfficiencyType effType = null)
        {
            try
            {
                status.Visibility = Visibility.Visible;
                int nIndex = 0;
                List <EfficiencyType> lstEfcyTypes = await BREfficiencyTypes.GetEfficiencyTypes(_efficiencyTypeFilter, _nStatus);

                dgrEfcyTypes.ItemsSource = lstEfcyTypes;
                if (effType != null & lstEfcyTypes.Count > 0)
                {
                    effType = lstEfcyTypes.Where(ef => ef.etID == effType.etID).FirstOrDefault();
                    nIndex  = lstEfcyTypes.IndexOf(effType);
                }
                GridHelper.SelectRow(dgrEfcyTypes, nIndex);
                StatusBarReg.Content = lstEfcyTypes.Count + " Efficiency Types.";
                status.Visibility    = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                UIHelper.ShowMessage(ex);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// recarga la lista de efficiencyTypes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 18/03/2016
        /// </history>
        private void btnRef_Click(object sender, RoutedEventArgs e)
        {
            EfficiencyType effType = (EfficiencyType)dgrEfcyTypes.SelectedItem;

            LoadEfficiencyTypes(effType);
        }