private void gTanque_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (gTanque.Columns[e.ColumnIndex].SortMode == DataGridViewColumnSortMode.NotSortable) { return; } if (bsTanque.Count < 1) { return; } PropertyDescriptorCollection lP = TypeDescriptor.GetProperties(new CamadaDados.PostoCombustivel.Cadastros.TRegistro_TanqueCombustivel()); CamadaDados.PostoCombustivel.Cadastros.TList_TanqueCombustivel lComparer; SortOrder direcao = SortOrder.None; if ((gTanque.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.None) || (gTanque.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.Descending)) { lComparer = new CamadaDados.PostoCombustivel.Cadastros.TList_TanqueCombustivel(lP.Find(gTanque.Columns[e.ColumnIndex].DataPropertyName, true), SortOrder.Ascending); foreach (DataGridViewColumn c in gTanque.Columns) { c.HeaderCell.SortGlyphDirection = SortOrder.None; } direcao = SortOrder.Ascending; } else { lComparer = new CamadaDados.PostoCombustivel.Cadastros.TList_TanqueCombustivel(lP.Find(gTanque.Columns[e.ColumnIndex].DataPropertyName, true), SortOrder.Descending); foreach (DataGridViewColumn c in gTanque.Columns) { c.HeaderCell.SortGlyphDirection = SortOrder.None; } direcao = SortOrder.Descending; } (bsTanque.List as CamadaDados.PostoCombustivel.Cadastros.TList_TanqueCombustivel).Sort(lComparer); bsTanque.ResetBindings(false); gTanque.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection = direcao; }
public TList_TanqueCombustivel Select(Utils.TpBusca[] vBusca, int vTop, string vNM_Campo) { TList_TanqueCombustivel lista = new TList_TanqueCombustivel(); 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_TanqueCombustivel reg = new TRegistro_TanqueCombustivel(); if (!reader.IsDBNull(reader.GetOrdinal("id_tanque"))) { reg.Id_tanque = reader.GetDecimal(reader.GetOrdinal("id_tanque")); } 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_local"))) { reg.Cd_local = reader.GetString(reader.GetOrdinal("cd_local")); } if (!reader.IsDBNull(reader.GetOrdinal("DS_Local"))) { reg.Ds_local = reader.GetString(reader.GetOrdinal("DS_Local")); } 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("cd_unidproduto"))) { reg.Cd_unidproduto = reader.GetString(reader.GetOrdinal("cd_unidproduto")); } if (!reader.IsDBNull(reader.GetOrdinal("ds_undproduto"))) { reg.Ds_unidproduto = reader.GetString(reader.GetOrdinal("ds_undproduto")); } if (!reader.IsDBNull(reader.GetOrdinal("sg_produto"))) { reg.Sg_produto = reader.GetString(reader.GetOrdinal("sg_produto")); } if (!reader.IsDBNull(reader.GetOrdinal("CapacidadeTanque"))) { reg.Capacidadetanque = reader.GetDecimal(reader.GetOrdinal("CapacidadeTanque")); } if (!reader.IsDBNull(reader.GetOrdinal("saldo_tanque"))) { reg.Saldo_tanque = reader.GetDecimal(reader.GetOrdinal("saldo_tanque")); } if (!reader.IsDBNull(reader.GetOrdinal("st_registro"))) { reg.St_registro = reader.GetString(reader.GetOrdinal("st_registro")); } if (!reader.IsDBNull(reader.GetOrdinal("dt_desativacao"))) { reg.Dt_desativacao = reader.GetDateTime(reader.GetOrdinal("dt_desativacao")); } if (!reader.IsDBNull(reader.GetOrdinal("dt_ativacao"))) { reg.Dt_ativacao = reader.GetDateTime(reader.GetOrdinal("dt_ativacao")); } lista.Add(reg); } } finally { reader.Close(); reader.Dispose(); if (podeFecharBco) { this.deletarBanco_Dados(); } } return(lista); }