Example #1
0
        public TList_CadAlmoxarifado Select(TpBusca[] vBusca, Int32 vTop, string vNM_Campo)
        {
            TList_CadAlmoxarifado lista  = new TList_CadAlmoxarifado();
            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_CadAlmoxarifado reg = new TRegistro_CadAlmoxarifado();
                    if (!(reader.IsDBNull(reader.GetOrdinal("Id_Almox"))))
                    {
                        reg.Id_almox = reader.GetDecimal(reader.GetOrdinal("Id_Almox"));
                    }
                    if (!(reader.IsDBNull(reader.GetOrdinal("DS_Almoxarifado"))))
                    {
                        reg.Ds_almoxarifado = reader.GetString(reader.GetOrdinal("DS_Almoxarifado"));
                    }

                    lista.Add(reg);
                }
                return(lista);
            }
            finally
            {
                reader.Close();
                reader.Dispose();
                if (podeFecharBco)
                {
                    deletarBanco_Dados();
                }
            }
        }
Example #2
0
        private void gAlmoxarif_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (gAlmoxarif.Columns[e.ColumnIndex].SortMode == DataGridViewColumnSortMode.NotSortable)
            {
                return;
            }
            if (BS_CadAlmoxarifado.Count < 1)
            {
                return;
            }
            PropertyDescriptorCollection lP = TypeDescriptor.GetProperties(new CamadaDados.Almoxarifado.TRegistro_CadAlmoxarifado());

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

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