Пример #1
0
        public override int buscarRegistros()
        {
            TList_PrecoANP lista = TCN_PrecoANP.Buscar(id_preco.Text,
                                                       cd_combustivel.Text,
                                                       dt_preco.Text,
                                                       string.Empty,
                                                       null);

            if (lista != null)
            {
                if (lista.Count > 0)
                {
                    this.Lista            = lista;
                    bsPrecoANP.DataSource = lista;
                }
                else
                if ((vTP_Modo == TTpModo.tm_Standby) || (vTP_Modo == TTpModo.tm_busca))
                {
                    bsPrecoANP.Clear();
                }
                return(lista.Count);
            }
            else
            {
                return(0);
            }
        }
Пример #2
0
        private void gPrecoANP_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (gPrecoANP.Columns[e.ColumnIndex].SortMode == DataGridViewColumnSortMode.NotSortable)
            {
                return;
            }
            if (bsPrecoANP.Count < 1)
            {
                return;
            }
            PropertyDescriptorCollection lP = TypeDescriptor.GetProperties(new TRegistro_PrecoANP());
            TList_PrecoANP lComparer;
            SortOrder      direcao = SortOrder.None;

            if ((gPrecoANP.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.None) ||
                (gPrecoANP.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.Descending))
            {
                lComparer = new TList_PrecoANP(lP.Find(gPrecoANP.Columns[e.ColumnIndex].DataPropertyName, true), SortOrder.Ascending);
                foreach (DataGridViewColumn c in gPrecoANP.Columns)
                {
                    c.HeaderCell.SortGlyphDirection = SortOrder.None;
                }
                direcao = SortOrder.Ascending;
            }
            else
            {
                lComparer = new TList_PrecoANP(lP.Find(gPrecoANP.Columns[e.ColumnIndex].DataPropertyName, true), SortOrder.Descending);
                foreach (DataGridViewColumn c in gPrecoANP.Columns)
                {
                    c.HeaderCell.SortGlyphDirection = SortOrder.None;
                }
                direcao = SortOrder.Descending;
            }
            (bsPrecoANP.List as TList_PrecoANP).Sort(lComparer);
            bsPrecoANP.ResetBindings(false);
            gPrecoANP.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection = direcao;
        }