public TList_ProgCombustivel Select(Utils.TpBusca[] vBusca, int vTop, string vNM_Campo) { TList_ProgCombustivel lista = new TList_ProgCombustivel(); bool podeFecharBco = false; if (Banco_Dados == null) { podeFecharBco = this.CriarBanco_Dados(false); } System.Data.SqlClient.SqlDataReader reader = this.ExecutarBusca(this.SqlCodeBusca(vBusca, Convert.ToInt16(vTop), vNM_Campo)); try { while (reader.Read()) { TRegistro_ProgCombustivel reg = new TRegistro_ProgCombustivel(); if (!reader.IsDBNull(reader.GetOrdinal("cd_empresa"))) { reg.Cd_empresa = reader.GetString(reader.GetOrdinal("cd_empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("nm_empresa"))) { reg.Nm_empresa = reader.GetString(reader.GetOrdinal("nm_empresa")); } if (!reader.IsDBNull(reader.GetOrdinal("cd_produto"))) { reg.Cd_produto = reader.GetString(reader.GetOrdinal("cd_produto")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_produto"))) { reg.Ds_produto = reader.GetString(reader.GetOrdinal("ds_produto")); } if (!reader.IsDBNull(reader.GetOrdinal("pc_desconto"))) { reg.Pc_desconto = reader.GetDecimal(reader.GetOrdinal("pc_desconto")); } if (!reader.IsDBNull(reader.GetOrdinal("tp_desconto"))) { reg.Tp_desconto = reader.GetString(reader.GetOrdinal("tp_desconto")); } if (!reader.IsDBNull(reader.GetOrdinal("st_descvlunit"))) { reg.St_descvlunit = reader.GetString(reader.GetOrdinal("st_descvlunit")); } lista.Add(reg); } } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { this.deletarBanco_Dados(); } } return(lista); }
private void gProg_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (gProg.Columns[e.ColumnIndex].SortMode == DataGridViewColumnSortMode.NotSortable) { return; } if (bsProgCombustivel.Count < 1) { return; } PropertyDescriptorCollection lP = TypeDescriptor.GetProperties(new CamadaDados.PostoCombustivel.Cadastros.TRegistro_ProgCombustivel()); CamadaDados.PostoCombustivel.Cadastros.TList_ProgCombustivel lComparer; SortOrder direcao = SortOrder.None; if ((gProg.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.None) || (gProg.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.Descending)) { lComparer = new CamadaDados.PostoCombustivel.Cadastros.TList_ProgCombustivel(lP.Find(gProg.Columns[e.ColumnIndex].DataPropertyName, true), SortOrder.Ascending); foreach (DataGridViewColumn c in gProg.Columns) { c.HeaderCell.SortGlyphDirection = SortOrder.None; } direcao = SortOrder.Ascending; } else { lComparer = new CamadaDados.PostoCombustivel.Cadastros.TList_ProgCombustivel(lP.Find(gProg.Columns[e.ColumnIndex].DataPropertyName, true), SortOrder.Descending); foreach (DataGridViewColumn c in gProg.Columns) { c.HeaderCell.SortGlyphDirection = SortOrder.None; } direcao = SortOrder.Descending; } (bsProgCombustivel.List as CamadaDados.PostoCombustivel.Cadastros.TList_ProgCombustivel).Sort(lComparer); bsProgCombustivel.ResetBindings(false); gProg.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection = direcao; }