Exemplo n.º 1
0
 public override int buscarRegistros()
 {
     CamadaDados.Fazenda.Cadastros.TList_Talhoes lista =
         CamadaNegocio.Fazenda.Cadastros.TCN_Talhoes.Buscar(cd_fazenda.Text,
                                                            id_area.Text,
                                                            id_talhao.Text,
                                                            ds_talhao.Text,
                                                            null);
     if (lista != null)
     {
         if (lista.Count > 0)
         {
             this.Lista           = lista;
             bsTalhoes.DataSource = lista;
         }
         else
         if ((vTP_Modo == Utils.TTpModo.tm_Standby) || (vTP_Modo == Utils.TTpModo.tm_busca))
         {
             bsTalhoes.Clear();
         }
         return(lista.Count);
     }
     else
     {
         return(0);
     }
 }
Exemplo n.º 2
0
        private void gTalhoes_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (gTalhoes.Columns[e.ColumnIndex].SortMode == DataGridViewColumnSortMode.NotSortable)
            {
                return;
            }
            if (bsTalhoes.Count < 1)
            {
                return;
            }
            PropertyDescriptorCollection lP = TypeDescriptor.GetProperties(new CamadaDados.Fazenda.Cadastros.TRegistro_Talhoes());

            CamadaDados.Fazenda.Cadastros.TList_Talhoes lComparer;
            SortOrder direcao = SortOrder.None;

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