示例#1
0
        private void gRua_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (gRua.Columns[e.ColumnIndex].SortMode == DataGridViewColumnSortMode.NotSortable)
            {
                return;
            }
            if (BS_CadRua.Count < 1)
            {
                return;
            }
            PropertyDescriptorCollection lP = TypeDescriptor.GetProperties(new CamadaDados.Almoxarifado.TRegistro_CadRua());

            CamadaDados.Almoxarifado.TList_CadRua lComparer;
            SortOrder direcao = SortOrder.None;

            if ((gRua.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.None) ||
                (gRua.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.Descending))
            {
                lComparer = new CamadaDados.Almoxarifado.TList_CadRua(lP.Find(gRua.Columns[e.ColumnIndex].DataPropertyName, true), SortOrder.Ascending);
                foreach (DataGridViewColumn c in gRua.Columns)
                {
                    c.HeaderCell.SortGlyphDirection = SortOrder.None;
                }
                direcao = SortOrder.Ascending;
            }
            else
            {
                lComparer = new CamadaDados.Almoxarifado.TList_CadRua(lP.Find(gRua.Columns[e.ColumnIndex].DataPropertyName, true), SortOrder.Descending);
                foreach (DataGridViewColumn c in gRua.Columns)
                {
                    c.HeaderCell.SortGlyphDirection = SortOrder.None;
                }
                direcao = SortOrder.Descending;
            }
            (BS_CadRua.List as CamadaDados.Almoxarifado.TList_CadRua).Sort(lComparer);
            BS_CadRua.ResetBindings(false);
            gRua.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection = direcao;
        }
示例#2
0
        public TList_CadRua Select(TpBusca[] vBusca, Int32 vTop, string vNm_Campo)
        {
            TList_CadRua  lista         = new TList_CadRua();
            SqlDataReader reader        = null;
            bool          podeFecharBco = false;

            if (Banco_Dados == null)
            {
                podeFecharBco = CriarBanco_Dados(false);
            }
            try
            {
                reader = ExecutarBusca(SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNm_Campo));
                while (reader.Read())
                {
                    TRegistro_CadRua reg = new TRegistro_CadRua();
                    if (!(reader.IsDBNull(reader.GetOrdinal("Id_Rua"))))
                    {
                        reg.Id_rua = reader.GetDecimal(reader.GetOrdinal("Id_Rua"));
                    }
                    if (!(reader.IsDBNull(reader.GetOrdinal("Ds_Rua"))))
                    {
                        reg.Ds_rua = reader.GetString(reader.GetOrdinal("Ds_Rua"));
                    }
                    lista.Add(reg);
                }
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    deletarBanco_Dados();
                }
            }
            return(lista);
        }