protected override void executeCellEndEditChild(object sender, DataGridViewCellEventArgs e) { base.executeCellEndEditChild(sender, e); Cliente_TransportadoraBLL = new Cliente_TransportadoraBLL(); int id = 0; string cliente = string.Empty; string transportadora = string.Empty; if (dgvFiltro[col_Id, e.RowIndex].Value != null) { if (!string.IsNullOrEmpty((string)dgvFiltro[col_Id, e.RowIndex].Value.ToString())) { id = Convert.ToInt32(dgvFiltro[col_Id, e.RowIndex].Value); } } if (dgvFiltro[col_cliente, e.RowIndex].Value != null) { if (!string.IsNullOrEmpty((string)dgvFiltro[col_cliente, e.RowIndex].Value)) { cliente = dgvFiltro[col_cliente, e.RowIndex].Value.ToString(); } } if (dgvFiltro[col_transportadora, e.RowIndex].Value != null) { if (!string.IsNullOrEmpty((string)dgvFiltro[col_transportadora, e.RowIndex].Value)) { transportadora = dgvFiltro[col_transportadora, e.RowIndex].Value.ToString(); } } Expression <Func <Cliente_Transportadora, bool> > predicate = p => true; if (id > 0) { predicate = predicate = p => p.Id == id; } if (!string.IsNullOrEmpty(cliente)) { predicate = predicate.And(p => p.Cliente.razao_social.ToLower().Contains(cliente.ToLower())); } if (!string.IsNullOrEmpty(transportadora)) { predicate = predicate.And(p => p.Transportadora.nome_fantasia.ToLower().Contains(transportadora.ToLower())); } List <Cliente_Transportadora> Cliente_TransportadoraList = Cliente_TransportadoraBLL.getCliente_Transportadora(predicate.Expand(), t => t.Id.ToString(), false, deslocamento, tamanhoPagina, out totalReg); dgvDados.DataSource = Cliente_TransportadoraBLL.ToList_Cliente_TransportadoraView(Cliente_TransportadoraList); }
protected override void carregaConsulta() { Cliente_TransportadoraBLL = new Cliente_TransportadoraBLL(); base.carregaConsulta(); dgvDados.DataSource = null; dgvDados.DataSource = Cliente_TransportadoraBLL.ToList_Cliente_TransportadoraView(Cliente_TransportadoraBLL.getCliente_Transportadora(p => p.Id.ToString(), false, deslocamento, tamanhoPagina, out totalReg)); colOrdem = 0; }
protected override void ordenaCelula(object sender, DataGridViewCellMouseEventArgs e) { base.ordenaCelula(sender, e); Cliente_TransportadoraBLL = new Cliente_TransportadoraBLL(); DataGridViewColumn col = dgvFiltro.Columns[e.ColumnIndex]; DataGridViewColumn colAnt = dgvFiltro.Columns[colOrdem]; ListSortDirection direction; switch (col.HeaderCell.SortGlyphDirection) { case SortOrder.None: direction = ListSortDirection.Ascending; break; case SortOrder.Ascending: direction = ListSortDirection.Ascending; break; case SortOrder.Descending: direction = ListSortDirection.Descending; break; default: direction = ListSortDirection.Ascending; break; } if (colOrdem == e.ColumnIndex) { if (direction == ListSortDirection.Ascending) { direction = ListSortDirection.Descending; } else { direction = ListSortDirection.Ascending; col.HeaderCell.SortGlyphDirection = SortOrder.None; } } else { direction = ListSortDirection.Ascending; colAnt.HeaderCell.SortGlyphDirection = SortOrder.None; } switch (e.ColumnIndex) { case col_cliente: { List <Cliente_Transportadora> Cliente_TransportadoraList = Cliente_TransportadoraBLL.getCliente_Transportadora(p => p.Cliente.razao_social, direction != ListSortDirection.Ascending, deslocamento, tamanhoPagina, out totalReg); dgvDados.DataSource = Cliente_TransportadoraBLL.ToList_Cliente_TransportadoraView(Cliente_TransportadoraList); } break; case col_transportadora: { List <Cliente_Transportadora> Cliente_TransportadoraList = Cliente_TransportadoraBLL.getCliente_Transportadora(p => p.Cliente.razao_social, direction != ListSortDirection.Ascending, deslocamento, tamanhoPagina, out totalReg); dgvDados.DataSource = Cliente_TransportadoraBLL.ToList_Cliente_TransportadoraView(Cliente_TransportadoraList); } break; //O default será executado quando o index for 0 default: { List <Cliente_Transportadora> Cliente_TransportadoraList = Cliente_TransportadoraBLL.getCliente_Transportadora(p => p.Id.ToString(), direction != ListSortDirection.Ascending, deslocamento, tamanhoPagina, out totalReg); dgvDados.DataSource = Cliente_TransportadoraBLL.ToList_Cliente_TransportadoraView(Cliente_TransportadoraList); } break; } colOrdem = e.ColumnIndex; col.HeaderCell.SortGlyphDirection = direction == ListSortDirection.Ascending ? SortOrder.Ascending : SortOrder.Descending; }